Loading libbacktrace/UnwindStack.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) { static std::set<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"}; static std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"}; UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map); auto process_memory = stack_map->process_memory(); unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(), regs, stack_map->process_memory()); unwinder.Unwind(&skip_names); unwinder.Unwind(&skip_names, &stack_map->GetSuffixesToIgnore()); if (num_ignore_frames >= unwinder.NumFrames()) { frames->resize(0); Loading libbacktrace/include/backtrace/BacktraceMap.h +9 −2 Original line number Diff line number Diff line Loading @@ -107,13 +107,20 @@ public: return map.end > 0; } void SetSuffixesToIgnore(std::vector<std::string> suffixes) { suffixes_to_ignore_.insert(suffixes_to_ignore_.end(), suffixes.begin(), suffixes.end()); } const std::vector<std::string>& GetSuffixesToIgnore() { return suffixes_to_ignore_; } protected: BacktraceMap(pid_t pid); virtual bool ParseLine(const char* line, backtrace_map_t* map); std::deque<backtrace_map_t> maps_; pid_t pid_; std::deque<backtrace_map_t> maps_; std::vector<std::string> suffixes_to_ignore_; }; class ScopedBacktraceMapIteratorLock { Loading libunwindstack/Unwinder.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <sys/types.h> #include <unistd.h> #include <algorithm> #include <android-base/stringprintf.h> #include <unwindstack/Elf.h> Loading Loading @@ -64,7 +66,8 @@ void Unwinder::FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, bool ad } } static bool ShouldStop(const std::set<std::string>* map_suffixes_to_ignore, std::string& map_name) { static bool ShouldStop(const std::vector<std::string>* map_suffixes_to_ignore, std::string& map_name) { if (map_suffixes_to_ignore == nullptr) { return false; } Loading @@ -72,11 +75,13 @@ static bool ShouldStop(const std::set<std::string>* map_suffixes_to_ignore, std: if (pos == std::string::npos) { return false; } return map_suffixes_to_ignore->find(map_name.substr(pos + 1)) != map_suffixes_to_ignore->end(); return std::find(map_suffixes_to_ignore->begin(), map_suffixes_to_ignore->end(), map_name.substr(pos + 1)) != map_suffixes_to_ignore->end(); } void Unwinder::Unwind(const std::set<std::string>* initial_map_names_to_skip, const std::set<std::string>* map_suffixes_to_ignore) { void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, const std::vector<std::string>* map_suffixes_to_ignore) { frames_.clear(); bool return_address_attempt = false; Loading @@ -97,8 +102,8 @@ void Unwinder::Unwind(const std::set<std::string>* initial_map_names_to_skip, } if (map_info == nullptr || initial_map_names_to_skip == nullptr || initial_map_names_to_skip->find(basename(map_info->name.c_str())) == initial_map_names_to_skip->end()) { std::find(initial_map_names_to_skip->begin(), initial_map_names_to_skip->end(), basename(map_info->name.c_str())) == initial_map_names_to_skip->end()) { FillInFrame(map_info, elf, rel_pc, adjust_pc); // Once a frame is added, stop skipping frames. initial_map_names_to_skip = nullptr; Loading libunwindstack/include/unwindstack/Unwinder.h +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ #include <sys/types.h> #include <memory> #include <set> #include <string> #include <vector> Loading Loading @@ -60,8 +59,8 @@ class Unwinder { } ~Unwinder() = default; void Unwind(const std::set<std::string>* initial_map_names_to_skip = nullptr, const std::set<std::string>* map_suffixes_to_ignore = nullptr); void Unwind(const std::vector<std::string>* initial_map_names_to_skip = nullptr, const std::vector<std::string>* map_suffixes_to_ignore = nullptr); size_t NumFrames() { return frames_.size(); } Loading libunwindstack/tests/UnwinderTest.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -308,8 +308,8 @@ TEST_F(UnwinderTest, verify_frames_skipped) { ElfInterfaceFake::FakePushStepData(StepData(0, 0, true)); Unwinder unwinder(64, &maps_, ®s_, process_memory_); std::set<std::string> skip_set{"libunwind.so", "libanother.so"}; unwinder.Unwind(&skip_set); std::vector<std::string> skip_libs{"libunwind.so", "libanother.so"}; unwinder.Unwind(&skip_libs); ASSERT_EQ(3U, unwinder.NumFrames()); Loading Loading @@ -572,7 +572,7 @@ TEST_F(UnwinderTest, map_ignore_suffixes) { ElfInterfaceFake::FakePushStepData(StepData(0, 0, true)); Unwinder unwinder(64, &maps_, ®s_, process_memory_); std::set<std::string> suffixes{"oat"}; std::vector<std::string> suffixes{"oat"}; unwinder.Unwind(nullptr, &suffixes); ASSERT_EQ(2U, unwinder.NumFrames()); Loading Loading
libbacktrace/UnwindStack.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) { static std::set<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"}; static std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"}; UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map); auto process_memory = stack_map->process_memory(); unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(), regs, stack_map->process_memory()); unwinder.Unwind(&skip_names); unwinder.Unwind(&skip_names, &stack_map->GetSuffixesToIgnore()); if (num_ignore_frames >= unwinder.NumFrames()) { frames->resize(0); Loading
libbacktrace/include/backtrace/BacktraceMap.h +9 −2 Original line number Diff line number Diff line Loading @@ -107,13 +107,20 @@ public: return map.end > 0; } void SetSuffixesToIgnore(std::vector<std::string> suffixes) { suffixes_to_ignore_.insert(suffixes_to_ignore_.end(), suffixes.begin(), suffixes.end()); } const std::vector<std::string>& GetSuffixesToIgnore() { return suffixes_to_ignore_; } protected: BacktraceMap(pid_t pid); virtual bool ParseLine(const char* line, backtrace_map_t* map); std::deque<backtrace_map_t> maps_; pid_t pid_; std::deque<backtrace_map_t> maps_; std::vector<std::string> suffixes_to_ignore_; }; class ScopedBacktraceMapIteratorLock { Loading
libunwindstack/Unwinder.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <sys/types.h> #include <unistd.h> #include <algorithm> #include <android-base/stringprintf.h> #include <unwindstack/Elf.h> Loading Loading @@ -64,7 +66,8 @@ void Unwinder::FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, bool ad } } static bool ShouldStop(const std::set<std::string>* map_suffixes_to_ignore, std::string& map_name) { static bool ShouldStop(const std::vector<std::string>* map_suffixes_to_ignore, std::string& map_name) { if (map_suffixes_to_ignore == nullptr) { return false; } Loading @@ -72,11 +75,13 @@ static bool ShouldStop(const std::set<std::string>* map_suffixes_to_ignore, std: if (pos == std::string::npos) { return false; } return map_suffixes_to_ignore->find(map_name.substr(pos + 1)) != map_suffixes_to_ignore->end(); return std::find(map_suffixes_to_ignore->begin(), map_suffixes_to_ignore->end(), map_name.substr(pos + 1)) != map_suffixes_to_ignore->end(); } void Unwinder::Unwind(const std::set<std::string>* initial_map_names_to_skip, const std::set<std::string>* map_suffixes_to_ignore) { void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, const std::vector<std::string>* map_suffixes_to_ignore) { frames_.clear(); bool return_address_attempt = false; Loading @@ -97,8 +102,8 @@ void Unwinder::Unwind(const std::set<std::string>* initial_map_names_to_skip, } if (map_info == nullptr || initial_map_names_to_skip == nullptr || initial_map_names_to_skip->find(basename(map_info->name.c_str())) == initial_map_names_to_skip->end()) { std::find(initial_map_names_to_skip->begin(), initial_map_names_to_skip->end(), basename(map_info->name.c_str())) == initial_map_names_to_skip->end()) { FillInFrame(map_info, elf, rel_pc, adjust_pc); // Once a frame is added, stop skipping frames. initial_map_names_to_skip = nullptr; Loading
libunwindstack/include/unwindstack/Unwinder.h +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ #include <sys/types.h> #include <memory> #include <set> #include <string> #include <vector> Loading Loading @@ -60,8 +59,8 @@ class Unwinder { } ~Unwinder() = default; void Unwind(const std::set<std::string>* initial_map_names_to_skip = nullptr, const std::set<std::string>* map_suffixes_to_ignore = nullptr); void Unwind(const std::vector<std::string>* initial_map_names_to_skip = nullptr, const std::vector<std::string>* map_suffixes_to_ignore = nullptr); size_t NumFrames() { return frames_.size(); } Loading
libunwindstack/tests/UnwinderTest.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -308,8 +308,8 @@ TEST_F(UnwinderTest, verify_frames_skipped) { ElfInterfaceFake::FakePushStepData(StepData(0, 0, true)); Unwinder unwinder(64, &maps_, ®s_, process_memory_); std::set<std::string> skip_set{"libunwind.so", "libanother.so"}; unwinder.Unwind(&skip_set); std::vector<std::string> skip_libs{"libunwind.so", "libanother.so"}; unwinder.Unwind(&skip_libs); ASSERT_EQ(3U, unwinder.NumFrames()); Loading Loading @@ -572,7 +572,7 @@ TEST_F(UnwinderTest, map_ignore_suffixes) { ElfInterfaceFake::FakePushStepData(StepData(0, 0, true)); Unwinder unwinder(64, &maps_, ®s_, process_memory_); std::set<std::string> suffixes{"oat"}; std::vector<std::string> suffixes{"oat"}; unwinder.Unwind(nullptr, &suffixes); ASSERT_EQ(2U, unwinder.NumFrames()); Loading