diff options
author | Andreas Gampe <agampe@google.com> | 2018-03-29 10:08:19 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2018-03-29 20:53:25 -0700 |
commit | 0622a5d412780be13ef9b9fab63314e0780b3c3b (patch) | |
tree | 9ff491ce6561e9252f9c34c20786aab6864364a6 | |
parent | f03e021c07fcd00618baa140b5d4023088d2e9ea (diff) | |
download | extras-0622a5d412780be13ef9b9fab63314e0780b3c3b.tar.gz |
Perfprofd: Move dropbox functionality into core
Move functionality into core, let cmdline version react to
dropbox configuration.
(cherry picked from commit 7f85bff629e68efd3f5127fc43edddcadfecb007)
Bug: 73175642
Test: mmma system/extras/perfprofd
Test: perfprofd_test
Merged-In: I3415d7c15cf527afe70d93e4b4992a121d52164c
Change-Id: I3415d7c15cf527afe70d93e4b4992a121d52164c
-rw-r--r-- | perfprofd/Android.bp | 1 | ||||
-rw-r--r-- | perfprofd/binder_interface/Android.bp | 3 | ||||
-rw-r--r-- | perfprofd/binder_interface/perfprofd_binder.cc | 4 | ||||
-rw-r--r-- | perfprofd/config.h | 3 | ||||
-rw-r--r-- | perfprofd/configreader.cc | 4 | ||||
-rw-r--r-- | perfprofd/perfprofd_cmdline.cc | 30 | ||||
-rw-r--r-- | perfprofd/tests/Android.bp | 5 |
7 files changed, 33 insertions, 17 deletions
diff --git a/perfprofd/Android.bp b/perfprofd/Android.bp index 7cecbe92..eb35a039 100644 --- a/perfprofd/Android.bp +++ b/perfprofd/Android.bp @@ -107,6 +107,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 7d0b7061..50d9ca83 100644 --- a/perfprofd/tests/Android.bp +++ b/perfprofd/tests/Android.bp @@ -50,6 +50,11 @@ cc_test { required: [ "simpleperf", ], + shared_libs: [ + "libbinder", + "libservices", + "libutils", + ], }, }, |