Commit graph

395 commits

Author SHA1 Message Date
Jeff Brown
9524e4158f 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
2011-10-25 17:00:17 -07:00
Jeff Brown
13e715b491 Use libcorkscrew in debuggerd.
Change-Id: I5e3645a39d96c808f87075b49111d0262a19a0c8
2011-10-22 16:43:00 -07:00
Andy McFadden
08dedcfd5c Enable verbose register memory dumps
Dump some memory at addresses for all registers that look like they
might have valid addresses.  Previously this was only done for PC
and LR.

(This is expected to be disabled before ship.)

Bug 5484924

Change-Id: I9802eaa396783e1286ae0c53eaf2473892c38a02
2011-10-19 13:28:33 -07:00
Andy McFadden
e5cc5396e8 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
thread.

Bug 5471955

Change-Id: Iaa4fd2fafbaeda2f20bb95f202177d7744a91f9d
2011-10-18 20:20:14 -07:00
Andy McFadden
f2eae5a860 Enhance debuggerd memory dumps
This makes two changes:

(1) Display ASCII values next to the memory dumps.  For example:

I DEBUG: 00008ac4 706f6f4c 20676e69 74206425 73656d69  Looping %d times
I DEBUG: 00008ad4 7453000a 6e69726f 6f742067 0a702520  ..Storing to %p.
I DEBUG: 00008ae4 65642f00 657a2f76 55006f72 6c62616e  ./dev/zero.Unabl

(The hex values are still displayed as little-endian word values, while
the ASCII part is byte oriented.)

(2) Optionally display memory dumps for all registers, not just LR
and PC, for the crashing thread.  This is meant for situations where
we crash dereferencing foo->bar and want to see what the memory near
"foo" looks like -- could be handy if it got stomped by MUTF-16 text
or something recognizable.

Change #2 is currently disabled, via a compile-time setting.

Bug 5471955

Change-Id: Iacfd01c314055bad81db2f43b7d239f10086fcfb
2011-10-18 16:18:02 -07:00
Andy McFadden
41e0cef301 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
2011-10-13 16:05:08 -07:00
Andy McFadden
136dcc5ce6 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
2011-10-13 12:35:55 -07:00
Andy McFadden
655835be2a 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
2011-08-04 13:37:15 -07:00
Andy McFadden
44e12eceec 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
2011-07-29 12:36:47 -07:00
Vladimir Chtchetkine
953907faa3 am 716104b4: am 771f5146: am 4c0b9e3d: Merge "Fix crash reporting on x86 platform."
* commit '716104b40df12d367cb5f649b92c6105d5978787':
  Fix crash reporting on x86 platform.
2011-06-09 11:24:17 -07:00
Vladimir Chtchetkine
716104b40d am 771f5146: am 4c0b9e3d: Merge "Fix crash reporting on x86 platform."
* commit '771f5146893aa9bbc451aed78e61b3b18c1bc3b4':
  Fix crash reporting on x86 platform.
2011-06-07 15:56:33 -07:00
Vladimir Chtchetkine
714d9de60d Fix crash reporting on x86 platform.
Make sure that crash frame gets printed in one line

Change-Id: If097a5a1655b17165b2a3271f0f5ee8ace57686f
2011-06-07 09:24:03 -07:00
Brian Carlstrom
e2f7123032 Revert "Debuggerd now outputs the offset of libc.so on the device as a separate item."
This reverts commit c031a3b006.

Conflicts:

	debuggerd/debuggerd.c

Change-Id: Ib37ae793bbffdb4a81837bc51171cc62b12abe7d
2011-03-17 16:38:15 -07:00
Ben Cheng
dce4d06b5c Fix overflow prevention code in memory dump.
The delta between start and end pointers in memory dump has to be
multiples of 4 or 16.

Bug: 3486787
Change-Id: Ie34aa79ffb704ca647805dbc6a16f2c35adf849c
2011-02-24 16:37:52 -08:00
David 'Digit' Turner
2c259914a0 debuggerd: Fix missing include.
The structure user_vfp is incorrectly defined in bionic/libc/kernel/arch-arm/asm/ptrace.h
at the moment, while it should be under bionic/libc/kernel/arch-arm/asm/user.h instead.

Before moving its definition in the corresponding source files, we need to fix its users.
It happens that debuggerd is the only one for now, so fix this by including <linux/user.h>
instead (which will include <asm/user.h> and <asm/ptrace.h>).

Also, make the debug output less chatty by specifying all symbols to be listed
through XLOG2 instead of XLOG.

Change-Id: I16e0fa700945d86efd44ee885a84ad609c0a9b58
2011-02-01 14:38:30 +01:00
Brian Swetland
cecec9d027 remove crasher and vfp-crasher from standard builds
These are only for debuggerd testing.

Change-Id: If2d2ff85e8c182d366cc251e9446ae7fdd094e55
2011-01-23 17:51:54 -08:00
David 'Digit' Turner
02526d4868 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
trace.

Change-Id: I6b0579041165a710d74ec1bece113ff7b828aed4
2011-01-21 04:27:12 +01:00
Paul Eastham
3227b5c25f Prevent rollover when dumping data around PC, SP, etc.
Change-Id: Ifc5f0e8eb5fed191c39f0878869e04b4d4f3b9ca
2010-12-14 16:07:58 -08:00
Jean-Baptiste Queru
660c8b7195 am cbb9257a: Merge "Fix debuggerd (native crash dump)."
* commit 'cbb9257a872a0f35b0aa1018410ca6025e628c36':
  Fix debuggerd (native crash dump).
2010-12-14 13:32:45 -08:00
Mike Dodd
0b4836f2cd Fix debuggerd (native crash dump).
Change 44659e90f (6cc4923087 in AOSP) introduced walking
both the symbol table and dynamic symbol table. The problem
is that it was dereferencing values whether or not the two tables
were both present, which could wind up reading from invalid memory.
The read from a bad address would cause debuggerd itself to crash,
which isn't handled.

Change-Id: Ie936f660018b1980dee5b6ed669588db861f1a79
2010-12-14 13:15:47 -08:00
Mike Dodd
584b8e30bc Fix debuggerd (native crash dump).
Change 44659e90f (6cc4923087 in AOSP) introduced walking
both the symbol table and dynamic symbol table. The problem
is that it was dereferencing values whether or not the two tables
were both present, which could wind up reading from invalid memory.
The read from a bad address would cause debuggerd itself to crash,
which isn't handled.

Change-Id: Ie936f660018b1980dee5b6ed669588db861f1a79
2010-12-14 12:16:23 -08:00
Jean-Baptiste Queru
abf7378f1e am 44659e90: am d3f59eab: Merge "debuggerd: IA version"
* commit '44659e90fe8df25c71195936eabe0cc9158c18a6':
  debuggerd: IA version
2010-12-13 12:32:04 -08:00
Jean-Baptiste Queru
44659e90fe am d3f59eab: Merge "debuggerd: IA version"
* commit 'd3f59eab07d102b9506978aca9541dd62dcea919':
  debuggerd: IA version
2010-12-13 11:37:40 -08:00
Jean-Baptiste Queru
5599029c8d Manual merge of 144773f9
Change-Id: I0ac3f88ac85bbc604fdc151768da20e86318fb46
2010-12-13 11:31:04 -08:00
Jean-Baptiste Queru
144773f9e1 am e382cc99: Merge "debuggerd: Reorganize to facilitate IA commit"
* commit 'e382cc999e48b3faabea7743ec8cec303b6005ba':
  debuggerd: Reorganize to facilitate IA commit
2010-12-13 11:14:26 -08:00
Bruce Beare
6cc4923087 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>
2010-11-29 11:28:11 -08:00
Bruce Beare
849249064c debuggerd: Reorganize to facilitate IA commit
Change-Id: I22dd02daf617672fc0a8ba7e396017c57f17e26e
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2010-11-29 11:03:48 -08:00
Carl Shapiro
503818eb66 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.
2010-10-11 10:49:17 -07:00
Carl Shapiro
5c5ff87ded 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.
2010-10-10 12:12:55 -07:00
Carl Shapiro
83c6b05291 Print out the signal code along with signal number and address.
Change-Id: I60a8b13f706714e80b11bc517101715dfe1c73c1
2010-10-08 18:10:24 -07:00
Hristo Bojinov
c031a3b006 Debuggerd now outputs the offset of libc.so on the device as a separate item.
Change-Id: I350c9ddb496a76d1ee897ae84893bf0e86abd45c
2010-08-27 14:58:07 -07:00
Mike Dodd
7fdcc435b6 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
2010-07-16 16:47:37 -07:00
Mike Dodd
6b65747233 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
2010-07-14 11:28:29 -07:00
The Android Open Source Project
75a1d218d8 merge from open-source master
Change-Id: I50b7bc6faa6d0abd4998cae8fc7dda1e8fa49407
2010-06-10 08:51:33 -07:00
Meng Hu
ae7b91b680 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
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
2010-05-24 17:20:10 -05:00
Colin Cross
e951f60e77 Use arch flags instead of TARGET_ARCH_VARIANT, and add support for VFP_D16
Change-Id: I6007ff21076e92b04a17fb030472a9f8842f0315
2010-03-10 14:36:08 -08:00
Ben Cheng
2854db8969 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
registers.

Dump more code around PC and LR to facilitate JIT debugging.
2010-01-28 10:00:03 -08:00
Ben Cheng
bdcff7d66e 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.
2009-12-17 12:53:06 -08:00
Doug Kwan
092799072f Add missing symbol type directives. 2009-12-03 17:20:58 -08:00
Andy McFadden
3bfdcc979d 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").
2009-12-01 15:56:30 -08:00
Ben Cheng
09e713789e Print code around PC and LR in the inline log.
8 more lines should provide more crucial information in weird cases.
2009-09-28 11:09:22 -07:00
The Android Open Source Project
dd7bc3319d auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
The Android Open Source Project
e54eebbf1a auto import from //depot/cupcake/@135843 2009-03-03 18:29:04 -08:00
The Android Open Source Project
35237d1358 Code drop from //branches/cupcake/...@124589 2008-12-17 18:08:08 -08:00
The Android Open Source Project
4f6e8d7a00 Initial Contribution 2008-10-21 07:00:00 -07:00