Commit graph

8 commits

Author SHA1 Message Date
Elliott Hughes
89054056a7 Add flush_my_map_info_list() and fix a bug in the Mac load_map_info_list().
(If you fclose(3) rather than pclose(3) a FILE* you got from popen(3),
future popen(3)s fail obscurely, at least on Mac OS.)

(cherry picked from commit 2bf76e143da933184d1392fb9bea3a3896c37e76)

Change-Id: I5578fe06753061b0dbc5ee951ebf31eb2bab0389
2013-05-14 19:49:30 -07:00
Elliott Hughes
d1420be613 Include page protections in the debuggerd map output.
Bug: 7941716
Change-Id: I3bf475425c628c06f7799340c8a6132aab741742
2013-01-03 13:39:57 -08:00
Jean-Baptiste Queru
5731de9620 am 83c4398b: am cc12ed32: Merge "[MIPS] debuggerd and libcorkscrew support"
* commit '83c4398b4adb5c2cfaf6487699a8b94901ce0fb1':
  [MIPS] debuggerd and libcorkscrew support
2012-08-15 09:37:54 -07:00
Chris Dearman
231e3c83a3 [MIPS] debuggerd and libcorkscrew support
Change-Id: I5a241dc2e470148be0ad2c138e31f1aba5ab8812
2012-08-10 18:16:20 -07:00
Elliott Hughes
420a7fa82d Add missing #includes.
Change-Id: I81405d638f80fc96874ea0b21af3538229aa38a7
2012-05-17 18:28:01 -07:00
Jeff Brown
19b39f371b Improve backtrace formatting.
Show the symbol offset, when available.

Centralized formatting of native stack traces in libcorkscrew.
It's handy for automated tools if all stacks look the same.
Since we already made them all look them same, we might as well
do the formatting in just one place.

Do not strip the Thumb bit on ARM.  This fixes an off-by-one
issue that could happen when resolving a PC that was at the
very beginning of a Thumb function, since the symbol table would
have the Thumb bit set but since we stripped the bit from our
PC, we would be looking for an address one byte before the
one listed in the symbol table.  It's also quite useful to see
whether a given function is executing in Thumb mode just by glancing
at the PC.

Change-Id: Icaa29add85ce0bcafe24d5ce2098e138d809e2ab
2011-11-22 12:13:46 -08:00
Jeff Brown
f0c5872637 Improve stack unwinder robustness.
Keep track of whether memory maps are readable.  Use the information
in try_get_word to try to avoid accidentally dereferencing an invalid
pointer within the current process.  (Note that I haven't ever
seen that happen during normal unwinding, but it pays to be
a little more careful.)

Refactored try_get_word a little to make it easier to pass it the
needed state for validation checks by way of a little memory_t struct.

Improved how the memory map for the current process is cached.  This is
important because we need up to date information about readable maps.
Use a 5 second cache expiration.

Improved the PC -> LR fallback logic in the unwinder so we can
eke out an extra frame sometimes.

Fixed a bug reading ELF program headers.  The phnum & phentsize
fields are half-words.  We were incorrectly interpreting
phnum as a whole word.

Used android_atomic_* operations carefully in the unwinder
to prevent possible memory races between the dumper and the dumpee.
This was highly unlikely (or even impossible due to the presence
of other barriers along the way) but the code is clearer now about
its invariants.

Fixed a bug in debuggerd where the pid was being passed to have
its stack dump taken instead of the tid, resulting in short
stacks because ptrace couldn't read the data if pid != tid.
Did a full sweep to ensure that we use pid / tid correctly everywhere.

Ported old code from debuggerd to rewind the program counter back
one instruction so that it points to the branch instruction itself
instead of the return address.

Change-Id: Icc4eb08320052975a4ae7f0f5f0ac9308a2d33d7
2011-11-04 01:11:04 -07:00
Jeff Brown
501edd29b8 Add a new library for collecting stack traces.
Supports collecting the stack trace of the current thread,
another thread in the same process, or a thread in a
different process (using ptrace).

Change-Id: Ica2594e4436edde4ceb7bcc3d78e6c31a7902cbf
2011-10-22 16:42:59 -07:00