diff options
author | Jason Molenda <jmolenda@apple.com> | 2011-11-08 04:28:12 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2011-11-08 04:28:12 +0000 |
commit | 1f3966bebd9e08b40c6185b9b39938b5d06d5ef5 (patch) | |
tree | 53e2b7ddc697fd04cd25095145b9b55eb47abcbd /lldb/tools/debugserver/source/DNB.cpp | |
parent | 9586cdb01e1086c851911d8d3cbb5da6c2193505 (diff) | |
download | bcm5719-llvm-1f3966bebd9e08b40c6185b9b39938b5d06d5ef5.tar.gz bcm5719-llvm-1f3966bebd9e08b40c6185b9b39938b5d06d5ef5.zip |
Add "QAddressIsExecutable" packet to debugserver. Used to test
whether a given address is in an executable region of memory or
not. I haven't written the lldb side that will use this packet it
hasn't been tested yet but it's a simple enough bit of code.
I want to have this feature available for the unwinder code. When
we're stopped at an address with no valid symbol context, there are
a number of questions I'd like to ask --
is the current pc value in an executable region (e.g. did they
jump to unallocated/unexecutable memory? we know how to unwind
from here if so.)
Is the stack pointer or the frame pointer the correct register
to use to find the caller's saved pc value?
Once we're past the first frame we can trust things like eh_frame
and ABI unwind schemes but the first frame is challenging and having
a way to check potential addresses to see if they're executable or
not would help narrow down the possibilities a lot.
llvm-svn: 144074
Diffstat (limited to 'lldb/tools/debugserver/source/DNB.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/DNB.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index 268b30b195d..e9461221954 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -1124,6 +1124,34 @@ DNBProcessMemoryDeallocate (nub_process_t pid, nub_addr_t addr) return 0; } +//---------------------------------------------------------------------- +// Try to determine if a given address in the process PID is in an +// executable region or not. Used for sniffing potential caller addresses +// when unwinding a stack and we're making guesses about where the caller +// frame addr might be saved. +// +// RETURNS: 1 if executable +// 0 if not executable +// -1 if we cannot make a determination on this target +// +// Note that unmapped memory (an address that is not an allocated page in +// PID) will return as 0 - it is not executable memory. -1 is intended +// for a platform where we can't inspect memory region attributes. +//---------------------------------------------------------------------- +int +DNBIsAddressExecutable (nub_process_t pid, nub_addr_t addr) +{ + MachProcessSP procSP; + if (GetProcessSP (pid, procSP)) + { + if (procSP->IsAddressExecutable(addr)) + return 1; + else + return 0; + } + return -1; +} + //---------------------------------------------------------------------- // Formatted output that uses memory and registers from process and |