History log of /system/core/debuggerd/debuggerd.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
231e3c83a3a70b11160fb0da108ebf2e0e7470e2 11-Aug-2012 Chris Dearman <chris@mips.com> [MIPS] debuggerd and libcorkscrew support

Change-Id: I5a241dc2e470148be0ad2c138e31f1aba5ab8812
053b865412d1982ad1dc0e840898d82527deeb99 07-Jun-2012 Jeff Brown <jeffbrown@google.com> Enhance native stack dumps.

Provides a new mechanism for dumpstate (while running as root)
to request that debuggerd dump the stacks of native processes that
we care about in bug reports. In this mode, the backtrace
is formatted to look similar to a Dalvik backtrace.

Moved the tombstone generating code into a separate file to
make it easier to maintain.

Fixed a bug where sometimes the stack traces would be incomplete
because we were not waiting for each thread to stop after issuing
PTRACE_ATTACH, only the main thread. So sometimes we were missing
traces for some threads.

Refactored the logging code to prevent accidentally writing data
to logcat when explicitly dumping a tombstone or backtrace from the

Only root or system server can request to dump backtraces but
only root can dump tombstones.

Bug: 6615693
Change-Id: Ib3edcc16f9f3a687e414e3f2d250d9500566123b
424e07fcf655b65306bb846115e22594d6527056 09-Mar-2012 Andy McFadden <fadden@android.com> Reduce suicidal tendencies

Some changes to debuggerd:

(1) Send a SIGSTOP to the target process before doing any of the
PTRACE_ATTACH work. This causes the threads that weren't hit by
the signal to stop moving, which seems to get rid of the "ptrace
detach failed: No such process" problems that result in missed
stack traces and debuggerd self-immolation.

(2) SIGPIPE was in the list of "interesting" signals caught by
debugger_signal_handler(), but debuggerd didn't recognize it, and
you'd get "unexpected signal 13" complaints. It's now in the list.

(3) Fixed a bit-rotted XLOG.

Change-Id: I33297ea6b09ce450671c07dc25846f684afbf480
fb9804bfc2111aace2d56b15dbbe32e4d26767bc 09-Nov-2011 Jeff Brown <jeffbrown@google.com> Print the tombstone path.

When explicitly requesting a dump, show the user the path of
the tombstone file that was generated.

Change-Id: I7fff7dea606872a61687ca087e99f604107b70c4
f0c5872637a63e28e3cd314cfc915c07f76df9c6 04-Nov-2011 Jeff Brown <jeffbrown@google.com> 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
9524e4158fbb988b6a5e4f5be68ee10b7e4dd6d8 24-Oct-2011 Jeff Brown <jeffbrown@google.com> Add support for explicitly dumping native stacks.

This change modifies debuggerd so that it can be used to grab
the native stacks of a process that has hung and not just crashed.
Note that only the root user can do this (for now).

adb shell debuggerd <tid>

Then use logcat to find the tombstone file that was generated
which will have the native stacks of all threads in the
requested process. The specified thread will be shown first
and will also appear in the main log.

Also made some minor tweaks to libcorkscrew so that we
could handle statically compiled executables in the future
if we compiled the library statically.

Improved the "wait_for_user_action" function to support
volume down as an alternative for devices that do not
have home keys.

Removed a mess of gotos.

Change-Id: Ic149653986b0c2f503c7f0e8b7cb1f3be7c84d1e
13e715b491e876865e752a3a69dd6f347049a488 21-Oct-2011 Jeff Brown <jeffbrown@google.com> Use libcorkscrew in debuggerd.

Change-Id: I5e3645a39d96c808f87075b49111d0262a19a0c8
e5cc5396e83d12b7ca02ff6096a9950807aa010d 19-Oct-2011 Andy McFadden <fadden@android.com> Add log summary to tombstones

When the tombstones are uploaded to APR, they're truncated at 64KB.
This causes the log data, which is at the end, to be lost if the
process has more than about 12 threads (which many do).

This change adds the last few lines of the log right below the
report for the crashing thread, where we should be guaranteed to
keep it.

Also, clean up trailing newlines on log messages (which end up in
the tombstone), and don't print a "------- log" banner if there
aren't any messages in that log file (e.g. slog).

Also also, don't try to show_nearby_maps unless this is the crashing

Bug 5471955

Change-Id: Iaa4fd2fafbaeda2f20bb95f202177d7744a91f9d
41e0cef301637cd1f2daf72953d1230b7fb174b8 14-Oct-2011 Andy McFadden <fadden@android.com> Append log data to tombstones

The Android Problem Report site shows tombstones uploaded from
devices. We can see the native stack traces for every thread,
but sometimes there's a very important bit of information sitting
in the log, and without it we can't analyze the failure.

This change modifies debuggerd so that the log contents for the
crashing process are appended to the tombstone. The format matches
the output of "logcat -v threadtime". Both "system" and "main" logs
are included (but not interleaved -- we're not that fancy).

This feature is only enabled when the "ro.debuggable" system property
is set to 1 (indicating a development device).

Bug 5456676

Change-Id: I3be1df59813ccf1058cec496a906f6d31fbc7b04
136dcc5ce628a1ba600a6818e5cb24d5f15eb016 23-Sep-2011 Andy McFadden <fadden@android.com> Show maps near native fault address

This adds some additional output to native crashes. For example, if
something tried to access a bit of mmap(/dev/zero) memory that had
been mprotect()ed, you might see output like this:

I DEBUG : memory map around addr 4015a00c:
I DEBUG : 40159000-4015a000 /system/lib/libstdc++.so
I DEBUG : 4015a000-40162000 /dev/zero
I DEBUG : b0001000-b0009000 /system/bin/linker

The idea is to see what's in and around the fault address to make it
easier to identify bus errors due to file truncation and segmentation
faults caused by buffer over/underruns.

No output is generated for accesses below 0x1000 (which are likely
NULL pointer dereferences) or for signals that don't set si_addr.

Also, suppress the fault address for signals that don't set si_addr:
I DEBUG : signal 6 (SIGABRT), code 0 (?), fault addr --------

We still print "fault addr" followed by 8 characters for anything
that is parsing the contents. The "address" shown for signals like
SIGABRT was meaningless and possibly confusing.

Bug 5358516

Change-Id: Icae8ef309ea2d89b129f68d30f96b2ca8a69cc6c
655835be2a0e6d656040f4dd8f7e3e1035734ef7 26-Jul-2011 Andy McFadden <fadden@android.com> Don't stall waiting for target to crash

This modifies debuggerd to sleep-poll while waiting for the target
process to crash, rather than block (potentially forever).

Also, add/fix some error reporting.

Bug 5035703

Change-Id: Id62ab79f53104927f8de684dff1a5734dbdb8390
44e12eceecd0be8ba832a003733bfc859b2ccd9d 29-Jul-2011 Andy McFadden <fadden@android.com> debuggerd can't handle debuggerd crashes

When a process receives a fatal signal, it connects to debuggerd
and initiates a conversation over a socket. When the crashing
process is debuggerd, the conversation stalls forever, and you
stop getting native crash details.

This resets the signal handlers to SIG_DFL, so that debuggerd
simply crashes and gets restarted.

Bug 5035703

Change-Id: Ie081d710d046f701bca7e7d8ea3e1d24766d9f61
e2f712303279039310ddb8e59cf7884338c0e40d 18-Mar-2011 Brian Carlstrom <bdc@google.com> Revert "Debuggerd now outputs the offset of libc.so on the device as a separate item."

This reverts commit c031a3b006129ca408eaade325a53a334daee3b2.



Change-Id: Ib37ae793bbffdb4a81837bc51171cc62b12abe7d
02526d486803de153d03851f4d5f9be7c555e46c 21-Jan-2011 David 'Digit' Turner <digit@google.com> debuggerd: properly unblock signal handler.

This change ensures that debuggered properly releases
the signal handler that invoked it after the PTRACE_ATTACH.

The previous code simply did a close() of the file descriptor,
but for some reason, this didn't always make the read() blocking
the signal handler exit. Instead, the thread would stay blocked
and never fault, preventing the generation of a useful stack

Change-Id: I6b0579041165a710d74ec1bece113ff7b828aed4
abf7378f1ebc9012701e84b0796397b0ba630f95 13-Dec-2010 Jean-Baptiste Queru <jbq@google.com> am 44659e90: am d3f59eab: Merge "debuggerd: IA version"

* commit '44659e90fe8df25c71195936eabe0cc9158c18a6':
debuggerd: IA version
44659e90fe8df25c71195936eabe0cc9158c18a6 13-Dec-2010 Jean-Baptiste Queru <jbq@google.com> am d3f59eab: Merge "debuggerd: IA version"

* commit 'd3f59eab07d102b9506978aca9541dd62dcea919':
debuggerd: IA version
5599029c8dacd2c3dc348ac903b35dfa76a93bf0 13-Dec-2010 Jean-Baptiste Queru <jbq@google.com> Manual merge of 144773f9

Change-Id: I0ac3f88ac85bbc604fdc151768da20e86318fb46
144773f9e1371a8d4b848c3136b931d5d0687b38 13-Dec-2010 Jean-Baptiste Queru <jbq@google.com> am e382cc99: Merge "debuggerd: Reorganize to facilitate IA commit"

* commit 'e382cc999e48b3faabea7743ec8cec303b6005ba':
debuggerd: Reorganize to facilitate IA commit
6cc492308712613cd23bee9240b1757428841a2f 14-Oct-2010 Bruce Beare <bruce.j.beare@intel.com> debuggerd: IA version

Change-Id: I0c0d9c2d7e476b8d117aaf505a9480a47c0b5c05
Signed-off-by: Lei Li <lei.l.li@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
849249064cae9c1bb23b0204b5d35b832567801e 13-Oct-2010 Bruce Beare <bruce.j.beare@intel.com> debuggerd: Reorganize to facilitate IA commit

Change-Id: I22dd02daf617672fc0a8ba7e396017c57f17e26e
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
503818eb662a9376b5d5d3ed06d7d2516db389ec 11-Oct-2010 Carl Shapiro <cshapiro@google.com> am 5c5ff87d: am 83c6b052: Print out the signal code along with signal number and address.

Merge commit '5c5ff87ded019537bbaf6383618ef2956aaa0407'

* commit '5c5ff87ded019537bbaf6383618ef2956aaa0407':
Print out the signal code along with signal number and address.
5c5ff87ded019537bbaf6383618ef2956aaa0407 10-Oct-2010 Carl Shapiro <cshapiro@google.com> am 83c6b052: Print out the signal code along with signal number and address.

Merge commit '83c6b052918178033875e7ea54ca746cf7303f87' into gingerbread-plus-aosp

* commit '83c6b052918178033875e7ea54ca746cf7303f87':
Print out the signal code along with signal number and address.
83c6b052918178033875e7ea54ca746cf7303f87 09-Oct-2010 Carl Shapiro <cshapiro@google.com> Print out the signal code along with signal number and address.

Change-Id: I60a8b13f706714e80b11bc517101715dfe1c73c1
c031a3b006129ca408eaade325a53a334daee3b2 27-Aug-2010 Hristo Bojinov <hristo@google.com> Debuggerd now outputs the offset of libc.so on the device as a separate item.

Change-Id: I350c9ddb496a76d1ee897ae84893bf0e86abd45c
7fdcc435b67ddc82e4bfb68067b8bb96f34ebf77 17-Jul-2010 Mike Dodd <mdodd@google.com> am 89118032: Merge "Fix bug in debuggerd so it can successfully find the exidx section in libraries. This should fix the bug where the exception stack wasn\'t being printed past the PC." into gingerbread

Merge commit '891180320f0b08758d053a8562dfcd601ef846b0' into gingerbread-plus-aosp

* commit '891180320f0b08758d053a8562dfcd601ef846b0':
Fix bug in debuggerd so it can successfully find the exidx section in
6b657472331ddb2cf5286167ff2460047a321be7 14-Jul-2010 Mike Dodd <mdodd@google.com> Fix bug in debuggerd so it can successfully find the exidx section in
libraries. This should fix the bug where the exception stack wasn't
being printed past the PC.

Change-Id: Ia69ebd49606ee34e329ba43c07b325660248e8fa
75a1d218d82b8a7d6e0196465dc02ca03fc173c6 10-Jun-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: I50b7bc6faa6d0abd4998cae8fc7dda1e8fa49407
ae7b91b68008ab09635a97a18e7d07a35e8404aa 05-Nov-2009 Meng Hu <meng.hu@garmin.com> debuggerd: Show function names in tombstone backtraces

This change enables debuggerd to provide backtraces with function
names in tombstone files and log messages. It does this by reading
the image file that the address is found in, and parsing the dynamic
symbol table to try to extract the symbol corresponding to the given

This works best when "-Wl,-export-dynamic" is added to the LDFLAGS
of each library and executable, because this will cause all symbols
to be added to the dynamic symbol table. If this flag is not present,
it will still work, but it will only be able to identify functions
which are part of the external API of the library/executable.

Change-Id: I618baaff9ed9143b7d1a1f302224e9f21d2b0626
e951f60e77a986494fafeadf53ba726fe79c498d 09-Mar-2010 Colin Cross <ccross@android.com> Use arch flags instead of TARGET_ARCH_VARIANT, and add support for VFP_D16

Change-Id: I6007ff21076e92b04a17fb030472a9f8842f0315
2854db8969cd061d83a931769dfaf4e57108d9df 28-Jan-2010 Ben Cheng <bccheng@android.com> Bug fix for pre-NEON platforms and enhancement for JIT debugging.

Use __ARM_NEON__ instead of __VFP_FP__ to detect the need to retrieve FP

Dump more code around PC and LR to facilitate JIT debugging.
bdcff7d66ef8f6602e017d03cf4ffa57bac39b92 17-Dec-2009 Ben Cheng <bccheng@google.com> Dump VFP registers and status word when native app crashes.

Bug: 2226399
Caveat: d0/d1 appear to be clobbered by ptrace. It will be tracked by a new bug.
3bfdcc979da0f857b014318f3df5d95a0f93eb27 01-Dec-2009 Andy McFadden <fadden@android.com> Minor tweaks to debuggerd.

Changed "process has crashed" message:
- say ":5039" instead of ":port" so mouse-paste of command is trivial
- removed trailing spaces, which consume log buffer to little effect
- improved (I hope) the short explanation of what's going on and
what the HOME key does

Fixed typo ("ignorning").
09e713789e31f640a80af1cddb2fc40cbeb02ad5 28-Sep-2009 Ben Cheng <bccheng@google.com> Print code around PC and LR in the inline log.

8 more lines should provide more crucial information in weird cases.
dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
e54eebbf1a908d65ee8cf80bab62821c05666d70 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution