simpleperf: add report-sample command.
1. Add report-sample command to report each sample with symbol information.
2. Add --dump-symbols option to record command to collect dso and symbol
information in perf.data.
Bug: 28114205
Change-Id: I37424ee6abd74a21ad41cd3b6c4249cf0625c201
diff --git a/simpleperf/thread_tree.h b/simpleperf/thread_tree.h
index 5d7d0c1..f685350 100644
--- a/simpleperf/thread_tree.h
+++ b/simpleperf/thread_tree.h
@@ -24,6 +24,9 @@
#include <set>
#include "dso.h"
+#include "environment.h"
+
+struct Record;
namespace simpleperf {
@@ -57,13 +60,16 @@
std::set<MapEntry*, MapComparator> maps;
};
+// ThreadTree contains thread information (in ThreadEntry) and mmap information
+// (in MapEntry) of the monitored threads. It also has interface to access
+// symbols in executable binaries mapped in the monitored threads.
class ThreadTree {
public:
ThreadTree() : unknown_symbol_("unknown", 0, std::numeric_limits<unsigned long long>::max()) {
unknown_dso_ = Dso::CreateDso(DSO_ELF_FILE, "unknown");
unknown_map_ =
MapEntry(0, std::numeric_limits<unsigned long long>::max(), 0, 0, unknown_dso_.get(), false);
- kernel_dso_ = Dso::CreateDso(DSO_KERNEL);
+ kernel_dso_ = Dso::CreateDso(DSO_KERNEL, DEFAULT_KERNEL_MMAP_NAME);
}
void AddThread(int pid, int tid, const std::string& comm);
@@ -81,7 +87,12 @@
return &unknown_map_;
}
- void Clear();
+ // Clear thread and map information, but keep loaded dso information. It saves
+ // the time to reload dso information.
+ void ClearThreadAndMap();
+
+ // Update thread tree with information provided by record.
+ void Update(const Record& record);
private:
Dso* FindKernelDsoOrNew(const std::string& filename);
@@ -101,6 +112,7 @@
std::unordered_map<std::string, std::unique_ptr<Dso>> user_dso_tree_;
std::unique_ptr<Dso> unknown_dso_;
Symbol unknown_symbol_;
+ std::unordered_map<uint64_t, Dso*> dso_id_to_dso_map_;
};
} // namespace simpleperf
@@ -109,8 +121,5 @@
using ThreadEntry = simpleperf::ThreadEntry;
using ThreadTree = simpleperf::ThreadTree;
-struct Record;
-
-void BuildThreadTree(const Record& record, ThreadTree* thread_tree);
#endif // SIMPLE_PERF_THREAD_TREE_H_