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/dso.h b/simpleperf/dso.h
index e11ea38..e823aca 100644
--- a/simpleperf/dso.h
+++ b/simpleperf/dso.h
@@ -18,6 +18,7 @@
#define SIMPLE_PERF_DSO_H_
#include <memory>
+#include <set>
#include <string>
#include <unordered_map>
#include <vector>
@@ -29,15 +30,24 @@
uint64_t len;
Symbol(const std::string& name, uint64_t addr, uint64_t len);
- const char* Name() const {
- return name_;
- }
+ const char* Name() const { return name_; }
const char* DemangledName() const;
+ bool HasDumped() const { return has_dumped_; }
+
+ void SetDumped() const { has_dumped_ = true; }
+
private:
const char* name_;
mutable const char* demangled_name_;
+ mutable bool has_dumped_;
+};
+
+struct SymbolComparator {
+ bool operator()(const Symbol& symbol1, const Symbol& symbol2) {
+ return symbol1.addr < symbol2.addr;
+ }
};
enum DsoType {
@@ -60,16 +70,24 @@
kallsyms_ = std::move(kallsyms);
}
}
- static void SetBuildIds(const std::vector<std::pair<std::string, BuildId>>& build_ids);
+ static void SetBuildIds(
+ const std::vector<std::pair<std::string, BuildId>>& build_ids);
- static std::unique_ptr<Dso> CreateDso(DsoType dso_type, const std::string& dso_path = "");
+ static std::unique_ptr<Dso> CreateDso(DsoType dso_type,
+ const std::string& dso_path);
~Dso();
+ DsoType type() const { return type_; }
+
+ uint64_t id() const { return id_; }
+
// Return the path recorded in perf.data.
- const std::string& Path() const {
- return path_;
- }
+ const std::string& Path() const { return path_; }
+
+ bool HasDumped() const { return has_dumped_; }
+
+ void SetDumped() { has_dumped_ = true; }
// Return the accessible path. It may be the same as Path(), or
// return the path with prefix set by SetSymFsDir().
@@ -79,6 +97,7 @@
uint64_t MinVirtualAddress();
const Symbol* FindSymbol(uint64_t vaddr_in_dso);
+ void InsertSymbol(const Symbol& symbol);
private:
static BuildId GetExpectedBuildId(const std::string& filename);
@@ -94,20 +113,23 @@
static std::unordered_map<std::string, BuildId> build_id_map_;
static size_t dso_count_;
- Dso(DsoType type, const std::string& path);
+ Dso(DsoType type, uint64_t id, const std::string& path);
bool Load();
bool LoadKernel();
bool LoadKernelModule();
bool LoadElfFile();
bool LoadEmbeddedElfFile();
- void InsertSymbol(const Symbol& symbol);
void FixupSymbolLength();
const DsoType type_;
+ const uint64_t id_;
const std::string path_;
uint64_t min_vaddr_;
- std::vector<Symbol> symbols_;
+ std::set<Symbol, SymbolComparator> symbols_;
bool is_loaded_;
+ bool has_dumped_;
};
+const char* DsoTypeToString(DsoType dso_type);
+
#endif // SIMPLE_PERF_DSO_H_