summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2018-03-29 10:08:19 -0700
committerAndreas Gampe <agampe@google.com>2018-03-29 17:52:12 -0700
commit7f85bff629e68efd3f5127fc43edddcadfecb007 (patch)
treeb575aeed51c6ab0c75ac85bd72414d18eb7389eb
parenta145b35d4780b4f81a8355bb3fe58a79af8a06f0 (diff)
downloadextras-7f85bff629e68efd3f5127fc43edddcadfecb007.tar.gz
Perfprofd: Move dropbox functionality into core
Move functionality into core, let cmdline version react to dropbox configuration. Bug: 73175642 Test: mmma system/extras/perfprofd Test: perfprofd_test Change-Id: I3415d7c15cf527afe70d93e4b4992a121d52164c
-rw-r--r--perfprofd/Android.bp1
-rw-r--r--perfprofd/binder_interface/Android.bp3
-rw-r--r--perfprofd/binder_interface/perfprofd_binder.cc4
-rw-r--r--perfprofd/config.h3
-rw-r--r--perfprofd/configreader.cc4
-rw-r--r--perfprofd/perfprofd_cmdline.cc30
-rw-r--r--perfprofd/tests/Android.bp5
7 files changed, 33 insertions, 17 deletions
diff --git a/perfprofd/Android.bp b/perfprofd/Android.bp
index e46aa471..243477a3 100644
--- a/perfprofd/Android.bp
+++ b/perfprofd/Android.bp
@@ -122,6 +122,7 @@ cc_defaults {
"libsimpleperf_elf_read",
],
whole_static_libs: [
+ "libperfprofd_dropbox",
"libperfprofd_record_proto",
"libquipper",
],
diff --git a/perfprofd/binder_interface/Android.bp b/perfprofd/binder_interface/Android.bp
index 4ec851d0..c40036bd 100644
--- a/perfprofd/binder_interface/Android.bp
+++ b/perfprofd/binder_interface/Android.bp
@@ -30,9 +30,6 @@ cc_library_static {
"libperfprofdcore",
"libprotobuf-cpp-lite",
],
- whole_static_libs: [
- "libperfprofd_dropbox",
- ],
srcs: [
"perfprofd_binder.cc",
":perfprofd_aidl",
diff --git a/perfprofd/binder_interface/perfprofd_binder.cc b/perfprofd/binder_interface/perfprofd_binder.cc
index 30476208..87e0c5f6 100644
--- a/perfprofd/binder_interface/perfprofd_binder.cc
+++ b/perfprofd/binder_interface/perfprofd_binder.cc
@@ -60,8 +60,6 @@ using Status = ::android::binder::Status;
class BinderConfig : public Config {
public:
- bool send_to_dropbox = false;
-
bool is_profiling = false;
void Sleep(size_t seconds) override {
@@ -97,8 +95,6 @@ class BinderConfig : public Config {
// Copy base fields.
*static_cast<Config*>(this) = static_cast<const Config&>(rhs);
- send_to_dropbox = rhs.send_to_dropbox;
-
return *this;
}
diff --git a/perfprofd/config.h b/perfprofd/config.h
index 4c1f12b1..774f7e86 100644
--- a/perfprofd/config.h
+++ b/perfprofd/config.h
@@ -96,6 +96,9 @@ struct Config {
// If true, use libz to compress the output proto.
bool compress = true;
+ // If true, send the proto to dropbox instead to a file.
+ bool send_to_dropbox = false;
+
// Sleep for the given number of seconds.
virtual void Sleep(size_t seconds) = 0;
diff --git a/perfprofd/configreader.cc b/perfprofd/configreader.cc
index f7d6fd29..d3396b33 100644
--- a/perfprofd/configreader.cc
+++ b/perfprofd/configreader.cc
@@ -130,6 +130,9 @@ void ConfigReader::addDefaultEntries()
// If true, use libz to compress the output proto.
addUnsignedEntry("compress", 0, 0, 1);
+
+ // If true, send the proto to dropbox instead to a file.
+ addUnsignedEntry("dropbox", 0, 0, 1);
}
void ConfigReader::addUnsignedEntry(const char *key,
@@ -329,4 +332,5 @@ void ConfigReader::FillConfig(Config* config) {
config->process = -1;
config->use_elf_symbolizer = getBoolValue("use_elf_symbolizer");
config->compress = getBoolValue("compress");
+ config->send_to_dropbox = getBoolValue("dropbox");
}
diff --git a/perfprofd/perfprofd_cmdline.cc b/perfprofd/perfprofd_cmdline.cc
index 105b1e8c..fb9c2c17 100644
--- a/perfprofd/perfprofd_cmdline.cc
+++ b/perfprofd/perfprofd_cmdline.cc
@@ -36,6 +36,7 @@
#include "perfprofd_record.pb.h"
#include "configreader.h"
+#include "dropbox.h"
#include "perfprofdcore.h"
#include "perfprofd_io.h"
@@ -224,16 +225,25 @@ int perfprofd_main(int argc, char** argv, Config* config)
if (proto == nullptr) {
return false;
}
- std::string data_file_path(handler_config->destination_directory);
- data_file_path += "/";
- data_file_path += PERF_OUTPUT;
- std::string path = android::base::StringPrintf("%s.encoded.%d", data_file_path.c_str(), seq);
- if (!android::perfprofd::SerializeProtobuf(proto, path.c_str(), handler_config->compress)) {
- return false;
- }
-
- if (!post_process(*handler_config, seq)) {
- return false;
+ if (handler_config->send_to_dropbox) {
+ std::string error_msg;
+ if (!android::perfprofd::dropbox::SendToDropbox(proto,
+ handler_config->destination_directory,
+ &error_msg)) {
+ LOG(ERROR) << "Failed dropbox submission: " << error_msg;
+ return false;
+ }
+ } else {
+ std::string data_file_path(handler_config->destination_directory);
+ data_file_path += "/";
+ data_file_path += PERF_OUTPUT;
+ std::string path = android::base::StringPrintf("%s.encoded.%d", data_file_path.c_str(), seq);
+ if (!android::perfprofd::SerializeProtobuf(proto, path.c_str(), handler_config->compress)) {
+ return false;
+ }
+ if (!post_process(*handler_config, seq)) {
+ return false;
+ }
}
seq++;
return true;
diff --git a/perfprofd/tests/Android.bp b/perfprofd/tests/Android.bp
index 9fa0d730..f601aaf5 100644
--- a/perfprofd/tests/Android.bp
+++ b/perfprofd/tests/Android.bp
@@ -48,6 +48,11 @@ cc_test {
required: [
"simpleperf",
],
+ shared_libs: [
+ "libbinder",
+ "libservices",
+ "libutils",
+ ],
},
},