OSDN Git Service

simpleperf: add --symfs option for record command.
authorYabin Cui <yabinc@google.com>
Thu, 7 Jul 2016 17:56:47 +0000 (10:56 -0700)
committerYabin Cui <yabinc@google.com>
Thu, 7 Jul 2016 18:56:29 +0000 (11:56 -0700)
When running record command with -g or --dump-symbols command,
files with symbol table and debug information are needed. Similar
to report command, we can add --symfs option to record command.

Bug: 28911532
Test: run simpleperf_unit_test.

Change-Id: I8e2b6320ca29c8de78b4f217cd25e1ea4383150e

simpleperf/cmd_record.cpp
simpleperf/cmd_record_test.cpp

index 441c733..0e6b64e 100644 (file)
@@ -129,6 +129,9 @@ class RecordCommand : public Command {
 "               will be unwound while recording by default. But it may lose\n"
 "               records as stacking unwinding can be time consuming. Use this\n"
 "               option to unwind the user's stack after recording.\n"
+"--symfs <dir>    Look for files with symbols relative to this directory.\n"
+"                 This option is used to provide files with symbol table and\n"
+"                 debug information, which are used by --dump-symbols and -g.\n"
 "-t tid1,tid2,... Record events on existing threads. Mutually exclusive with -a.\n"
             // clang-format on
             ),
@@ -463,6 +466,13 @@ bool RecordCommand::ParseOptions(const std::vector<std::string>& args,
       }
     } else if (args[i] == "--post-unwind") {
       post_unwind_ = true;
+    } else if (args[i] == "--symfs") {
+      if (!NextArgumentOrError(args, &i)) {
+        return false;
+      }
+      if (!Dso::SetSymFsDir(args[i])) {
+        return false;
+      }
     } else if (args[i] == "-t") {
       if (!NextArgumentOrError(args, &i)) {
         return false;
index ed199c9..ebca010 100644 (file)
@@ -299,3 +299,5 @@ TEST(record_cmd, group_option) {
                             "cpu-cycles:u,cpu-clock:u", "--group",
                             "cpu-cycles:k,cpu-clock:k"}));
 }
+
+TEST(record_cmd, symfs_option) { ASSERT_TRUE(RunRecordCmd({"--symfs", "/"})); }