Loading debuggerd/tombstone.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -240,12 +240,13 @@ static void dump_stack_segment( break; } const backtrace_map_t* map = backtrace->FindMap(stack_content); backtrace_map_t map; backtrace->FillInMap(stack_content, &map); const char* map_name; if (!map) { if (BacktraceMap::IsValid(map)) { map_name = ""; } else { map_name = map->name.c_str(); map_name = map.name.c_str(); } uintptr_t offset = 0; std::string func_name(backtrace->GetFunctionName(stack_content, &offset)); Loading include/backtrace/Backtrace.h +3 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ struct backtrace_frame_data_t { uintptr_t pc; // The absolute pc. uintptr_t sp; // The top of the stack. size_t stack_size; // The size of the stack, zero indicate an unknown stack size. const backtrace_map_t* map; // The map associated with the given pc. backtrace_map_t map; // The map associated with the given pc. std::string func_name; // The function name associated with this pc, NULL if not found. uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL. }; Loading Loading @@ -78,8 +78,8 @@ public: // If the string is empty, then no valid function name was found. virtual std::string GetFunctionName(uintptr_t pc, uintptr_t* offset); // Find the map associated with the given pc. virtual const backtrace_map_t* FindMap(uintptr_t pc); // Fill in the map data associated with the given pc. virtual void FillInMap(uintptr_t pc, backtrace_map_t* map); // Read the data at a specific address. virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0; Loading include/backtrace/BacktraceMap.h +12 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ #include <string> struct backtrace_map_t { backtrace_map_t(): start(0), end(0), flags(0) {} uintptr_t start; uintptr_t end; int flags; Loading @@ -48,15 +50,16 @@ public: virtual ~BacktraceMap(); // Get the map data structure for the given address. virtual const backtrace_map_t* Find(uintptr_t addr); // Fill in the map data structure for the given address. virtual void FillIn(uintptr_t addr, backtrace_map_t* map); // The flags returned are the same flags as used by the mmap call. // The values are PROT_*. int GetFlags(uintptr_t pc) { const backtrace_map_t* map = Find(pc); if (map) { return map->flags; backtrace_map_t map; FillIn(pc, &map); if (IsValid(map)) { return map.flags; } return PROT_NONE; } Loading @@ -75,6 +78,10 @@ public: virtual bool Build(); static inline bool IsValid(const backtrace_map_t& map) { return map.end > 0; } protected: BacktraceMap(pid_t pid); Loading libbacktrace/BacktraceImpl.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -99,15 +99,15 @@ std::string Backtrace::FormatFrameData(size_t frame_num) { std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { const char* map_name; if (frame->map && !frame->map->name.empty()) { map_name = frame->map->name.c_str(); if (BacktraceMap::IsValid(frame->map) && !frame->map.name.empty()) { map_name = frame->map.name.c_str(); } else { map_name = "<unknown>"; } uintptr_t relative_pc; if (frame->map) { relative_pc = frame->pc - frame->map->start; if (BacktraceMap::IsValid(frame->map)) { relative_pc = frame->pc - frame->map.start; } else { relative_pc = frame->pc; } Loading @@ -128,8 +128,8 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { return buf; } const backtrace_map_t* Backtrace::FindMap(uintptr_t pc) { return map_->Find(pc); void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { map_->FillIn(pc, map); } //------------------------------------------------------------------------- Loading @@ -147,8 +147,9 @@ bool BacktraceCurrent::ReadWord(uintptr_t ptr, word_t* out_value) { return false; } const backtrace_map_t* map = FindMap(ptr); if (map && map->flags & PROT_READ) { backtrace_map_t map; FillInMap(ptr, &map); if (BacktraceMap::IsValid(map) && map.flags & PROT_READ) { *out_value = *reinterpret_cast<word_t*>(ptr); return true; } else { Loading libbacktrace/BacktraceImpl.h +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ public: inline pid_t Pid() { return backtrace_obj_->Pid(); } inline pid_t Tid() { return backtrace_obj_->Tid(); } inline const backtrace_map_t* FindMap(uintptr_t addr) { return backtrace_obj_->FindMap(addr); inline void FillInMap(uintptr_t addr, backtrace_map_t* map) { backtrace_obj_->FillInMap(addr, map); } inline std::string GetFunctionName(uintptr_t pc, uintptr_t* offset) { return backtrace_obj_->GetFunctionName(pc, offset); Loading Loading
debuggerd/tombstone.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -240,12 +240,13 @@ static void dump_stack_segment( break; } const backtrace_map_t* map = backtrace->FindMap(stack_content); backtrace_map_t map; backtrace->FillInMap(stack_content, &map); const char* map_name; if (!map) { if (BacktraceMap::IsValid(map)) { map_name = ""; } else { map_name = map->name.c_str(); map_name = map.name.c_str(); } uintptr_t offset = 0; std::string func_name(backtrace->GetFunctionName(stack_content, &offset)); Loading
include/backtrace/Backtrace.h +3 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ struct backtrace_frame_data_t { uintptr_t pc; // The absolute pc. uintptr_t sp; // The top of the stack. size_t stack_size; // The size of the stack, zero indicate an unknown stack size. const backtrace_map_t* map; // The map associated with the given pc. backtrace_map_t map; // The map associated with the given pc. std::string func_name; // The function name associated with this pc, NULL if not found. uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL. }; Loading Loading @@ -78,8 +78,8 @@ public: // If the string is empty, then no valid function name was found. virtual std::string GetFunctionName(uintptr_t pc, uintptr_t* offset); // Find the map associated with the given pc. virtual const backtrace_map_t* FindMap(uintptr_t pc); // Fill in the map data associated with the given pc. virtual void FillInMap(uintptr_t pc, backtrace_map_t* map); // Read the data at a specific address. virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0; Loading
include/backtrace/BacktraceMap.h +12 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ #include <string> struct backtrace_map_t { backtrace_map_t(): start(0), end(0), flags(0) {} uintptr_t start; uintptr_t end; int flags; Loading @@ -48,15 +50,16 @@ public: virtual ~BacktraceMap(); // Get the map data structure for the given address. virtual const backtrace_map_t* Find(uintptr_t addr); // Fill in the map data structure for the given address. virtual void FillIn(uintptr_t addr, backtrace_map_t* map); // The flags returned are the same flags as used by the mmap call. // The values are PROT_*. int GetFlags(uintptr_t pc) { const backtrace_map_t* map = Find(pc); if (map) { return map->flags; backtrace_map_t map; FillIn(pc, &map); if (IsValid(map)) { return map.flags; } return PROT_NONE; } Loading @@ -75,6 +78,10 @@ public: virtual bool Build(); static inline bool IsValid(const backtrace_map_t& map) { return map.end > 0; } protected: BacktraceMap(pid_t pid); Loading
libbacktrace/BacktraceImpl.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -99,15 +99,15 @@ std::string Backtrace::FormatFrameData(size_t frame_num) { std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { const char* map_name; if (frame->map && !frame->map->name.empty()) { map_name = frame->map->name.c_str(); if (BacktraceMap::IsValid(frame->map) && !frame->map.name.empty()) { map_name = frame->map.name.c_str(); } else { map_name = "<unknown>"; } uintptr_t relative_pc; if (frame->map) { relative_pc = frame->pc - frame->map->start; if (BacktraceMap::IsValid(frame->map)) { relative_pc = frame->pc - frame->map.start; } else { relative_pc = frame->pc; } Loading @@ -128,8 +128,8 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { return buf; } const backtrace_map_t* Backtrace::FindMap(uintptr_t pc) { return map_->Find(pc); void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { map_->FillIn(pc, map); } //------------------------------------------------------------------------- Loading @@ -147,8 +147,9 @@ bool BacktraceCurrent::ReadWord(uintptr_t ptr, word_t* out_value) { return false; } const backtrace_map_t* map = FindMap(ptr); if (map && map->flags & PROT_READ) { backtrace_map_t map; FillInMap(ptr, &map); if (BacktraceMap::IsValid(map) && map.flags & PROT_READ) { *out_value = *reinterpret_cast<word_t*>(ptr); return true; } else { Loading
libbacktrace/BacktraceImpl.h +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ public: inline pid_t Pid() { return backtrace_obj_->Pid(); } inline pid_t Tid() { return backtrace_obj_->Tid(); } inline const backtrace_map_t* FindMap(uintptr_t addr) { return backtrace_obj_->FindMap(addr); inline void FillInMap(uintptr_t addr, backtrace_map_t* map) { backtrace_obj_->FillInMap(addr, map); } inline std::string GetFunctionName(uintptr_t pc, uintptr_t* offset) { return backtrace_obj_->GetFunctionName(pc, offset); Loading