summaryrefslogtreecommitdiffstats
path: root/include/backtrace/BacktraceMap.h
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2015-02-06 13:22:01 -0800
committerChristopher Ferris <cferris@google.com>2015-02-06 15:00:09 -0800
commit12385e3ad085aa1ac06c26529b32b688503a9fcf (patch)
treec73a344e4e481a95eae2e9a9fb2216ec09cf64a3 /include/backtrace/BacktraceMap.h
parent6289412222bfe26ebeef2ea9c422e828c11ffc30 (diff)
downloadsystem_core-12385e3ad085aa1ac06c26529b32b688503a9fcf.zip
system_core-12385e3ad085aa1ac06c26529b32b688503a9fcf.tar.gz
system_core-12385e3ad085aa1ac06c26529b32b688503a9fcf.tar.bz2
Move map data into backtrace data proper.
The backtrace structure used to include a pointer to a backtrace_map_t that represented the map data for a particular pc. This introduced a race condition where the pointer could be discarded, but the backtrace structure still contained a pointer to garbage memory. Now all of the map information is right in the structure. Bug: 19028453 Change-Id: If7088a73f3c6bf1f3bc8cdd2bb4b62e7cab831c0
Diffstat (limited to 'include/backtrace/BacktraceMap.h')
-rw-r--r--include/backtrace/BacktraceMap.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/include/backtrace/BacktraceMap.h b/include/backtrace/BacktraceMap.h
index 4ed23a8..da96307 100644
--- a/include/backtrace/BacktraceMap.h
+++ b/include/backtrace/BacktraceMap.h
@@ -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;
@@ -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;
}
@@ -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);