summaryrefslogtreecommitdiff
path: root/simpleperf/dso.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-10-19 15:06:29 -0700
committerYabin Cui <yabinc@google.com>2016-11-10 15:38:58 -0800
commit16501ffbd73483c498dde1ea4ad2670da7c9df55 (patch)
tree3c7c3a7f69ff65a7b984a93a3b96818f4f5acf7f /simpleperf/dso.cpp
parentf94f3d3d43aaaec680fffa43b12eaa7d6c83d98a (diff)
downloadextras-16501ffbd73483c498dde1ea4ad2670da7c9df55.tar.gz
simpleperf: use file records in protobuf output.
Dump file name and symbol name for each CallChainEntry takes too much space. So instead we store file_id and symbol_id for each CallChainEntry, and store file records separately. In CallChainEntry, replace ip with vaddr_in_file, because vaddr_in_file is more useful in finding instructions in elf file. Bug: http://b/32210800 Test: simpleperf_unit_test. Change-Id: I85542db21acbaa4d81b3c3aa7f9215f2d23c4878
Diffstat (limited to 'simpleperf/dso.cpp')
-rw-r--r--simpleperf/dso.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index 2950939c..1c59e606 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -38,7 +38,7 @@ Symbol::Symbol(const std::string& name, uint64_t addr, uint64_t len)
len(len),
name_(symbol_name_allocator.AllocateString(name)),
demangled_name_(nullptr),
- has_dumped_(false) {}
+ dump_id_(UINT_MAX) {}
const char* Symbol::DemangledName() const {
if (demangled_name_ == nullptr) {
@@ -58,6 +58,7 @@ std::string Dso::vmlinux_;
std::string Dso::kallsyms_;
std::unordered_map<std::string, BuildId> Dso::build_id_map_;
size_t Dso::dso_count_;
+uint32_t Dso::g_dump_id_;
void Dso::SetDemangle(bool demangle) { demangle_ = demangle; }
@@ -136,7 +137,11 @@ Dso::Dso(DsoType type, const std::string& path)
debug_file_path_(path),
min_vaddr_(std::numeric_limits<uint64_t>::max()),
is_loaded_(false),
- hit_flag_(false) {
+ dump_id_(UINT_MAX),
+ symbol_dump_id_(0) {
+ if (type_ == DSO_KERNEL) {
+ min_vaddr_ = 0;
+ }
// Check if file matching path_ exists in symfs directory before using it as
// debug_file_path_.
if (!symfs_dir_.empty()) {
@@ -167,6 +172,7 @@ Dso::~Dso() {
vmlinux_.clear();
kallsyms_.clear();
build_id_map_.clear();
+ g_dump_id_ = 0;
}
}
@@ -174,6 +180,17 @@ static bool CompareSymbol(const Symbol& symbol1, const Symbol& symbol2) {
return symbol1.addr < symbol2.addr;
}
+uint32_t Dso::CreateDumpId() {
+ CHECK(!HasDumpId());
+ return dump_id_ = g_dump_id_++;
+}
+
+uint32_t Dso::CreateSymbolDumpId(const Symbol* symbol) {
+ CHECK(!symbol->HasDumpId());
+ symbol->dump_id_ = symbol_dump_id_++;
+ return symbol->dump_id_;
+}
+
const Symbol* Dso::FindSymbol(uint64_t vaddr_in_dso) {
if (!is_loaded_) {
Load();