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
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
thread.
Bug 5471955
Change-Id: Iaa4fd2fafbaeda2f20bb95f202177d7744a91f9d
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
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
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
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
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
trace.
Change-Id: I6b0579041165a710d74ec1bece113ff7b828aed4
Merge commit '5c5ff87ded019537bbaf6383618ef2956aaa0407'
* commit '5c5ff87ded019537bbaf6383618ef2956aaa0407':
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.
Merge commit '891180320f0b08758d053a8562dfcd601ef846b0' into gingerbread-plus-aosp
* commit '891180320f0b08758d053a8562dfcd601ef846b0':
Fix bug in debuggerd so it can successfully find the exidx section in
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
address.
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
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").