summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_report.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-06-08 10:38:10 -0700
committerYabin Cui <yabinc@google.com>2015-06-09 11:09:18 -0700
commitec12ed9010128483993a87d68edc02d3a89d56cf (patch)
tree208a0c69c45725bef9a563146af0004f0cb7191c /simpleperf/cmd_report.cpp
parentf7383f39e5a66731e6e34ca85c1ad599f39faf1d (diff)
downloadextras-ec12ed9010128483993a87d68edc02d3a89d56cf.tar.gz
Simpleperf: support symbol parsing in report command.
Also fix the storage of ProcessEntry. Bug: 19483574 Change-Id: I2182a804f6ecbd28e7aa3c1a38a6f19b86f583c9
Diffstat (limited to 'simpleperf/cmd_report.cpp')
-rw-r--r--simpleperf/cmd_report.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index f2dc443d..d6aca57b 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -45,7 +45,7 @@ struct ReportItem {
};
static int ComparePid(const SampleEntry& sample1, const SampleEntry& sample2) {
- return sample1.process_entry->pid - sample2.process_entry->pid;
+ return sample1.process->pid - sample2.process->pid;
}
static std::string PrintHeaderPid() {
@@ -53,7 +53,7 @@ static std::string PrintHeaderPid() {
}
static std::string PrintPid(const SampleEntry& sample) {
- return android::base::StringPrintf("%d", sample.process_entry->pid);
+ return android::base::StringPrintf("%d", sample.process->pid);
}
static ReportItem report_pid_item = {
@@ -63,7 +63,7 @@ static ReportItem report_pid_item = {
};
static int CompareComm(const SampleEntry& sample1, const SampleEntry& sample2) {
- return strcmp(sample1.process_entry->comm.c_str(), sample2.process_entry->comm.c_str());
+ return strcmp(sample1.process->comm.c_str(), sample2.process->comm.c_str());
}
static std::string PrintHeaderComm() {
@@ -71,7 +71,7 @@ static std::string PrintHeaderComm() {
}
static std::string PrintComm(const SampleEntry& sample) {
- return sample.process_entry->comm;
+ return sample.process->comm;
}
static ReportItem report_comm_item = {
@@ -81,7 +81,7 @@ static ReportItem report_comm_item = {
};
static int CompareDso(const SampleEntry& sample1, const SampleEntry& sample2) {
- return strcmp(sample1.map_entry->filename.c_str(), sample2.map_entry->filename.c_str());
+ return strcmp(sample1.map->dso->path.c_str(), sample2.map->dso->path.c_str());
}
static std::string PrintHeaderDso() {
@@ -89,10 +89,8 @@ static std::string PrintHeaderDso() {
}
static std::string PrintDso(const SampleEntry& sample) {
- std::string filename = sample.map_entry->filename;
- if (filename == DEFAULT_KERNEL_MMAP_NAME) {
- filename = "[kernel.kallsyms]";
- } else if (filename == DEFAULT_EXECNAME_FOR_THREAD_MMAP) {
+ std::string filename = sample.map->dso->path;
+ if (filename == DEFAULT_EXECNAME_FOR_THREAD_MMAP) {
filename = "[unknown]";
}
return filename;
@@ -104,8 +102,29 @@ static ReportItem report_dso_item = {
.print_function = PrintDso,
};
+static int CompareSymbol(const SampleEntry& sample1, const SampleEntry& sample2) {
+ return strcmp(sample1.symbol->name.c_str(), sample2.symbol->name.c_str());
+}
+
+static std::string PrintHeaderSymbol() {
+ return "Symbol";
+}
+
+static std::string PrintSymbol(const SampleEntry& sample) {
+ return sample.symbol->name;
+}
+
+static ReportItem report_symbol_item = {
+ .compare_function = CompareSymbol,
+ .print_header_function = PrintHeaderSymbol,
+ .print_function = PrintSymbol,
+};
+
static std::unordered_map<std::string, ReportItem*> report_item_map = {
- {"comm", &report_comm_item}, {"pid", &report_pid_item}, {"dso", &report_dso_item},
+ {"comm", &report_comm_item},
+ {"pid", &report_pid_item},
+ {"dso", &report_dso_item},
+ {"symbol", &report_symbol_item},
};
class ReportCommand : public Command {
@@ -115,7 +134,7 @@ class ReportCommand : public Command {
"Usage: simpleperf report [options]\n"
" -i <file> specify path of record file, default is perf.data\n"
" --sort key1,key2,... Select the keys to sort and print the report.\n"
- " Possible keys include pid, comm, dso.\n"
+ " Possible keys include pid, comm, dso, symbol.\n"
" Default keys are \"comm,pid,dso\"\n"),
record_filename_("perf.data") {
}