summaryrefslogtreecommitdiff
path: root/simpleperf/report_lib_interface.cpp
diff options
context:
space:
mode:
authorDaniel Friederich <dfriederich@magicleap.com>2016-10-17 12:28:03 -0500
committerDaniel Friederich <dfriederich@magicleap.com>2016-11-16 10:53:25 -0600
commitb2465ad8bae68531dd9dbed88be469612cd7229a (patch)
tree058302152fb8beb4a5a8a3532c057b69b5608433 /simpleperf/report_lib_interface.cpp
parent0e48e18171e17c76834916c2c87360195edf8667 (diff)
downloadextras-b2465ad8bae68531dd9dbed88be469612cd7229a.tar.gz
Support to use kallsyms
Also: - Adapt to use with Python 3 (where str is a wide type but our C API's expect 8 bit character strings) - Use OS specific so names (e.g. simpleperf_report.dll on Windows) - On Windows as we use mingw to build, preload libwinpthread-1.dll. Test: with manual incovation using report_sample.py Change-Id: Id973c463608c520b8eec229026c74dc5e8144cf8
Diffstat (limited to 'simpleperf/report_lib_interface.cpp')
-rw-r--r--simpleperf/report_lib_interface.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/simpleperf/report_lib_interface.cpp b/simpleperf/report_lib_interface.cpp
index cdd9fb1c..2aa0ccc6 100644
--- a/simpleperf/report_lib_interface.cpp
+++ b/simpleperf/report_lib_interface.cpp
@@ -15,8 +15,10 @@
*/
#include <memory>
+#include <utility>
#include <android-base/logging.h>
+#include <android-base/file.h>
#include "dso.h"
#include "event_attr.h"
@@ -71,6 +73,7 @@ void DestroyReportLib(ReportLib* report_lib) EXPORT;
bool SetLogSeverity(ReportLib* report_lib, const char* log_level) EXPORT;
bool SetSymfs(ReportLib* report_lib, const char* symfs_dir) EXPORT;
bool SetRecordFile(ReportLib* report_lib, const char* record_file) EXPORT;
+bool SetKallsymsFile(ReportLib* report_lib, const char* kallsyms_file) EXPORT;
void ShowIpForUnknownSymbol(ReportLib* report_lib) EXPORT;
Sample* GetNextSample(ReportLib* report_lib) EXPORT;
@@ -110,6 +113,8 @@ class ReportLib {
return true;
}
+ bool SetKallsymsFile(const char* kallsyms_file);
+
void ShowIpForUnknownSymbol() { thread_tree_.ShowIpForUnknownSymbol(); }
Sample* GetNextSample();
@@ -146,6 +151,17 @@ bool ReportLib::SetLogSeverity(const char* log_level) {
return true;
}
+bool ReportLib::SetKallsymsFile(const char* kallsyms_file) {
+ std::string kallsyms;
+ if (!android::base::ReadFileToString(kallsyms_file, &kallsyms)) {
+ LOG(WARNING) << "Failed to read in kallsyms file from " << kallsyms_file;
+ return false;
+ }
+ Dso::SetKallsyms(std::move(kallsyms));
+ return true;
+}
+
+
Sample* ReportLib::GetNextSample() {
if (record_file_reader_ == nullptr) {
record_file_reader_ = RecordFileReader::CreateInstance(record_filename_);
@@ -301,6 +317,10 @@ void ShowIpForUnknownSymbol(ReportLib* report_lib) {
return report_lib->ShowIpForUnknownSymbol();
}
+bool SetKallsymsFile(ReportLib* report_lib, const char* kallsyms_file) {
+ return report_lib->SetKallsymsFile(kallsyms_file);
+}
+
Sample* GetNextSample(ReportLib* report_lib) {
return report_lib->GetNextSample();
}