summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-11-13 11:09:20 -0800
committerYabin Cui <yabinc@google.com>2018-11-13 11:38:05 -0800
commit16f93100e5dd671501dced487e0ac9d777484d7c (patch)
tree38e1bdf0a8a0de623e8bc1574af502c50eaec2aa
parent14a93639fd124abc8c100fb6f6c7a017236b05b1 (diff)
downloadextras-16f93100e5dd671501dced487e0ac9d777484d7c.tar.gz
simpleperf: fix a bug setting symfs dir.
Bug: 119438870 Test: run simpleperf_unit_test. Test: run simpleperf manually. Change-Id: I2f7ca659dc3a9833650f326ff5560fef44e769a5
-rw-r--r--simpleperf/cmd_report.cpp9
-rw-r--r--simpleperf/cmd_report_test.cpp5
2 files changed, 8 insertions, 6 deletions
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index 1a4cb4c6..e6f5dabb 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -508,7 +508,6 @@ bool ReportCommand::Run(const std::vector<std::string>& args) {
bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
bool demangle = true;
bool show_ip_for_unknown_symbol = true;
- std::string symfs_dir;
std::string vmlinux;
bool print_sample_count = false;
std::vector<std::string> sort_keys = {"comm", "pid", "tid", "dso", "symbol"};
@@ -613,8 +612,9 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
if (!NextArgumentOrError(args, &i)) {
return false;
}
- symfs_dir = args[i];
-
+ if (!Dso::SetSymFsDir(args[i])) {
+ return false;
+ }
} else if (args[i] == "--vmlinux") {
if (!NextArgumentOrError(args, &i)) {
return false;
@@ -627,9 +627,6 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
}
Dso::SetDemangle(demangle);
- if (!Dso::SetSymFsDir(symfs_dir)) {
- return false;
- }
if (!vmlinux.empty()) {
Dso::SetVmlinux(vmlinux);
}
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index 03a67bd5..a7670300 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -351,6 +351,11 @@ TEST_F(ReportCommandTest, report_dumped_symbols_with_symfs_dir) {
ASSERT_NE(content.find("main"), std::string::npos);
}
+TEST_F(ReportCommandTest, report_without_symfs_dir) {
+ TemporaryFile tmpfile;
+ ASSERT_TRUE(ReportCmd()->Run({"-i", GetTestData(PERF_DATA), "-o", tmpfile.path}));
+}
+
TEST_F(ReportCommandTest, report_sort_vaddr_in_file) {
Report(PERF_DATA, {"--sort", "vaddr_in_file"});
ASSERT_TRUE(success);