summaryrefslogtreecommitdiff
path: root/simpleperf/utils.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-03-18 18:47:43 -0700
committerYabin Cui <yabinc@google.com>2016-03-26 16:05:06 -0700
commit8f680f60dc800bec880c5c35bfbc1ac36165e1f3 (patch)
tree79824a7e07f91607f46b4364730db568ad183370 /simpleperf/utils.cpp
parentea4a5a44c8748a7763fe64446b7da54dc69ca4fe (diff)
downloadextras-8f680f60dc800bec880c5c35bfbc1ac36165e1f3.tar.gz
Simpleperf: add test for reporting callgraph of shared libraries in apk file.
Also add comment for how to generate each perf.data in testdata/. Add --log <leve> argument in unit test to help debugging. Bug: 26962895 Change-Id: Iaa5a81cd8da5174d5b5b4e7847811e2432bf0db8
Diffstat (limited to 'simpleperf/utils.cpp')
-rw-r--r--simpleperf/utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp
index f2418a65..dd09fbd3 100644
--- a/simpleperf/utils.cpp
+++ b/simpleperf/utils.cpp
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <algorithm>
+#include <map>
#include <string>
#include <android-base/file.h>
@@ -230,3 +231,19 @@ bool XzDecompress(const std::string& compressed_data, std::string* decompressed_
*decompressed_data = std::move(dst);
return true;
}
+
+bool GetLogSeverity(const std::string& name, android::base::LogSeverity* severity) {
+ static std::map<std::string, android::base::LogSeverity> log_severity_map = {
+ {"verbose", android::base::VERBOSE},
+ {"debug", android::base::DEBUG},
+ {"warning", android::base::WARNING},
+ {"error", android::base::ERROR},
+ {"fatal", android::base::FATAL},
+ };
+ auto it = log_severity_map.find(name);
+ if (it != log_severity_map.end()) {
+ *severity = it->second;
+ return true;
+ }
+ return false;
+}