summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-03-26 10:47:57 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-26 10:47:57 +0000
commit8560442f5bf63bfc37c8e14702d08efd45804aca (patch)
tree8346a7bae2e842cb9aebf820af50f75f50c0bb1b
parent68d41126d5bb7931a5753da7effbf1d6f7482863 (diff)
parentb3f184f5c87c6fd150770cb9ba7cfb40f8bdbc75 (diff)
downloadextras-8560442f5bf63bfc37c8e14702d08efd45804aca.tar.gz
Merge "simpleperf: report: add an option to specify symbol searching directory" into main
-rw-r--r--simpleperf/cmd_report.cpp7
-rw-r--r--simpleperf/cmd_report_test.cpp24
2 files changed, 26 insertions, 5 deletions
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index 524174e4..f2fb527f 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -449,6 +449,7 @@ class ReportCommand : public Command {
" The default sort keys are:\n"
" comm,pid,tid,dso,symbol\n"
"--symfs <dir> Look for files with symbols relative to this directory.\n"
+"--symdir <dir> Look for files with symbols in a directory recursively.\n"
"--vmlinux <file> Parse kernel symbols from <file>.\n"
"\n"
"Sample filter options:\n"
@@ -585,6 +586,7 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
{"--sort", {OptionValueType::STRING, OptionType::SINGLE}},
{"--symbols", {OptionValueType::STRING, OptionType::MULTIPLE}},
{"--symfs", {OptionValueType::STRING, OptionType::SINGLE}},
+ {"--symdir", {OptionValueType::STRING, OptionType::SINGLE}},
{"--vmlinux", {OptionValueType::STRING, OptionType::SINGLE}},
};
OptionFormatMap record_filter_options = GetRecordFilterOptionFormats(false);
@@ -692,6 +694,11 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
return false;
}
}
+ if (auto value = options.PullValue("--symdir"); value) {
+ if (!Dso::AddSymbolDir(*value->str_value)) {
+ return false;
+ }
+ }
if (auto value = options.PullValue("--vmlinux"); value) {
Dso::SetVmlinux(*value->str_value);
}
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index 6dfbae5c..fcb9fac4 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -40,16 +40,23 @@ static std::unique_ptr<Command> ReportCmd() {
class ReportCommandTest : public ::testing::Test {
protected:
void Report(const std::string& perf_data,
- const std::vector<std::string>& add_args = std::vector<std::string>()) {
- ReportRaw(GetTestData(perf_data), add_args);
+ const std::vector<std::string>& add_args = std::vector<std::string>(),
+ bool with_symfs = true) {
+ ReportRaw(GetTestData(perf_data), add_args, with_symfs);
}
void ReportRaw(const std::string& perf_data,
- const std::vector<std::string>& add_args = std::vector<std::string>()) {
+ const std::vector<std::string>& add_args = std::vector<std::string>(),
+ bool with_symfs = true) {
success = false;
TemporaryFile tmp_file;
- std::vector<std::string> args = {"-i", perf_data, "--symfs", GetTestDataDir(),
- "-o", tmp_file.path};
+ std::vector<std::string> args = {"-i", perf_data, "-o", tmp_file.path};
+
+ if (with_symfs) {
+ args.emplace_back("--symfs");
+ args.emplace_back(GetTestDataDir());
+ }
+
args.insert(args.end(), add_args.begin(), add_args.end());
ASSERT_TRUE(ReportCmd()->Run(args));
ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &content));
@@ -365,6 +372,13 @@ TEST_F(ReportCommandTest, report_dumped_symbols_with_symfs_dir) {
ASSERT_NE(content.find("main"), std::string::npos);
}
+TEST_F(ReportCommandTest, report_dumped_symbols_with_symdir) {
+ // Check if we can report symbols by specifying symdir.
+ Report(PERF_DATA, {"--symdir", GetTestDataDir()}, false);
+ ASSERT_TRUE(success);
+ ASSERT_NE(content.find("GlobalFunc"), std::string::npos);
+}
+
TEST_F(ReportCommandTest, report_without_symfs_dir) {
TemporaryFile tmpfile;
ASSERT_TRUE(ReportCmd()->Run({"-i", GetTestData(PERF_DATA), "-o", tmpfile.path}));