Commit graph

395 commits

Author SHA1 Message Date
Brigid Smith
50eb546ec1 Removed log.quiet and log = NULL cases from debuggerd.
Now the functionality implemented by these semi-confusing cases has been
replaced with the same logtype enum behavior that is easier to
understand, and cases that used log-looking behavior to print to logcat
(when log = NULL) now use the more transparent ALOGE/ALOGD functions.

Change-Id: I7e38f2d4ca74a828df4d2266b3ea34edd3c6f5bb
2014-06-19 10:59:01 -07:00
Brigid Smith
7b2078eeb4 Changed maps output in debuggerd.
Now the map output is only sent to the tombstone, and the entire
contents of /prod/$PID/maps is logged, not just 3 lines.  Additionally,
crasher now supports "crasher SIGSEGV-non-null", which attempts to write to a
dereferenced function address, causing a SIGSEGV at a non-zero address.
This new crasher mode can be used to test the new maps output.

Bug: 15343662
Change-Id: I796d92e8352a6b9714bbbfe96f3143c56565ef2f
2014-06-17 15:32:22 -07:00
Brigid Smith
1babede38b Fixed logcat debug output issue.
Change-Id: Ibeb048b683ec11b05af23371e5e4b17cdd50fea0
2014-06-17 14:24:43 -07:00
Brigid Smith
62ba489ba0 Changing how debuggerd filters log messages to different locations.
The system by which debuggerd filters its output to different locations
is now based on an enum called logtype with easy to understand
categories for log messages (like THREAD, MEMORY, etc.) instead of the
old, fairly esoteric scope_flags variable.  Now much of the output that
previously went to logcat does not show up on the screen, but all output
can be found in the tombstone file.  In addition, the tombstone's
location is now printed so it can be located easily.

Bug: 15341747
Change-Id: Ia2f2051d1dfdea934d0e6ed220f24345e35ba6a2
2014-06-16 14:41:21 -07:00
Elliott Hughes
20df39a089 Merge "Adding ABI output to debuggerd tombstones." 2014-06-04 21:11:47 +00:00
Brigid Smith
9c8dacce55 Adding ABI output to debuggerd tombstones.
Bug: 15084471
Change-Id: If9fb260a3403e86f80928f2f5f79331fc0936030
2014-06-04 12:29:24 -07:00
Christopher Ferris
3520086e3d Fix x86 and x86_64 builds.
Change-Id: I1ee9117843aff2abe4067f288b8496d4bfc78c9e
2014-06-03 17:13:37 -07:00
Elliott Hughes
ddde05f3ee Merge "[MIPS64] Build debuggerd for mips64" 2014-06-03 23:26:33 +00:00
Duane Sand
a80b759857 [MIPS64] Build debuggerd for mips64
Change-Id: I361e9668baa218fc01e723c2df1a34ca6329cf47
2014-06-03 16:24:57 -07:00
Elliott Hughes
8c597684b1 Clean up the debuggerd makefile.
In particular, turn on -Wunused, which is globally off by default
thanks to build/core/config.mk.

Change-Id: Iba3ee1c0726f43eced972a53959f0e1cd97190c9
2014-06-03 15:12:07 -07:00
Mark Salyzyn
e4369d68a2 logd: logcat: debuggerd: audit logs to events and main
- auditd spawn log copy to events and main
- logcat delete events as one of the default logs
- debuggerd do not collect events.
- squish multiple spaces
- switch from strcpy to memmove for overlapping buffers

BUG: 14626551
Change-Id: I89b30273ce931ed2b25a53ea9be48e77f4c1bbf4
2014-05-27 14:29:56 -07:00
Douglas Leung
6254f32f21 Fix register dump and back trace after a crash.
Change-Id: Ie5f6624b9dcf81d84769b9cdaf9d8a301c8826f7
Signed-off-by: Douglas Leung <douglas@mips.com>
2014-05-21 16:41:20 -07:00
Elliott Hughes
a323b504a7 Teach debuggerd the name of SIGTRAP.
Also add SIGTRAP to the list of signals we don't want to double fault on.

Bug: 15024256
Change-Id: I23ab80800563c007fcd3e42527329fedf762f0c8
2014-05-16 21:12:17 -07:00
Elliott Hughes
27ab751c7b Remove the broken LED flashing code from debuggerd.
Change-Id: I4d0cbe14daa90ac5f91ce4597584448ee3c65dda
2014-05-16 20:54:36 -07:00
Elliott Hughes
d9bf2b2137 Output correct gdbserver instructions from debuggerd.
Bug: 15021938
Change-Id: I2df433d939f5f83ed2a2a30af357b83e4d8e5331
2014-05-16 19:51:41 -07:00
Elliott Hughes
c4afc19236 Merge "Add SIGTRAP support to crasher and debuggerd." 2014-05-17 00:39:22 +00:00
Elliott Hughes
7e35ae8fc8 Add SIGTRAP support to crasher and debuggerd.
Bug: 15024256
Change-Id: I3f34993fcfd9799306852b0a2195db468370be6e
2014-05-16 17:27:59 -07:00
Mark Salyzyn
989980c55d logd: logcat: debuggerd: auditd logs to events
- auditd switch to recording logs to events log id
- logcat add events as one of the default logs
- debuggerd collect events log as well.

ToDo: debuggerd & bugreport collect intermixed logs.

BUG: 14626551
Change-Id: I958f0e729b7596748be57488a38824db5645be7b
2014-05-15 08:50:50 -07:00
Elliott Hughes
99d4a697c7 Fix mips debuggerd <corkscrew/ptrace.h> build breakage.
The uapi headers have everything we need, and the corkscrew
header files have been removed.

Change-Id: I274b44463638112f1ab290926094c094c9253586
2014-05-07 15:42:41 -07:00
Christopher Ferris
c5bb49a138 Log stack even if tombstone cannot be created.
Bug: 14498701
Change-Id: I62c271bef2f73166eeb91d3fa3ce1e1b724a081f
2014-05-05 15:01:14 -07:00
Mark Salyzyn
f1a8dfa0eb debuggerd: turn on -Werror
- Deal with some -Wunused / -Wunused-variable issues

Change-Id: I39849fe30170f69d1cab7d4ad2629b3a49e14ee7
2014-05-02 14:16:00 -07:00
Elliott Hughes
855fcc3114 Use the si_code value bionic passes us.
Bionic needs to re-raise various signals, which means the si_code
debuggerd sees has been clobbered. If bionic sends us the original
si_code value, we can use that instead of the one we see when the
ptrace the crashed process' siginfo.

Change-Id: If116a6bc667d55a6fb39b74f96673292af4e4c8c
2014-04-25 20:20:39 -07:00
Elliott Hughes
bd395b9a14 Add missing si_code values to debuggerd.
Also add static_asserts so we'll be notified if any more new ones show up.

Change-Id: I3a502dd4da35354e1ac65865191d31ccdacef298
2014-04-24 13:53:22 -07:00
Elliott Hughes
da6b2e2fd7 Improve liblog's fatal logging.
This makes LOG_ALWAYS_FATAL and LOG_ALWAYS_FATAL_IF as good as regular
assert(3).

Change-Id: I0666684d30cae7baf23c64b33d35c1e43f81acf0
2014-04-24 13:28:24 -07:00
Mark Salyzyn
99f47a9e7c logd: liblog: logcat: debuggerd: Add LOG_ID_CRASH
Change-Id: Iea453764a1a4fc1661f461f10c641c30150e4d20
2014-04-16 15:38:50 -07:00
Colin Cross
87a6b1d799 debuggerd: use LOCAL_MULTILIB
Use LOCAL_MULTILIB to build multiple versions of executables
instead of manually creating two build rules.

Change-Id: I1a993ff7b5f527a88735f46eec9822bb97d16490
2014-03-26 15:16:23 -07:00
Colin Cross
579c9bc8a4 build debuggerd and debuggerd64 on 64-bit architectures
Change-Id: I1518d45ae0c5e0fed31d071fdaf19a67bad1bdfc
2014-02-12 22:32:26 -08:00
Nick Kralevich
2e7347d617 Merge "Convert all selinux_android_restorecon and _setfilecon calls to new API." 2014-02-12 23:09:28 +00:00
Christopher Ferris
4207df11c5 Merge "Use stat structure to keep oldest mtime." 2014-02-08 02:13:58 +00:00
Christopher Ferris
68bd59f6d2 Use stat structure to keep oldest mtime.
Change-Id: If9496127db28d2dcd09bc5b3144632a43afb8d55
2014-02-07 18:08:38 -08:00
Elliott Hughes
0df8e4f86c Use socklen_t instead of int in debuggerd.
Also other trivial C++ cleanup.

Change-Id: I9b5278c5205e0ea4f9dcbbe3e7b99921dd2436dc
2014-02-07 12:13:30 -08:00
Stephen Smalley
27a93650c0 Convert all selinux_android_restorecon and _setfilecon calls to new API.
libselinux selinux_android_restorecon API is changing to the more
general interface with flags and dropping the older variants.

Also get rid of the old, no longer used selinux_android_setfilecon API
and rename selinux_android_setfilecon2 to it as it is the only API in use.

Change-Id: I1e71ec398ccdc24cac4ec76f1b858d0f680f4925
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-02-07 09:38:32 -05:00
Elliott Hughes
5d9fe779c8 system/core LP64 cleanup.
Fixes -Wint-to-pointer and -Wpointer-to-int warnings, plus various -Wformat
warnings.

Change-Id: I6c5eea6b4273d82d28b8e5d2925f3e5457511b17
2014-02-05 18:02:11 -08:00
Elliott Hughes
f7b4b519e4 Fix debuggerd's symbol offset output.
Before:
  00007fff33e489d8  00007ff286e4ad94  /system/lib64/libc.so (__libc_init+54u)

After:
  00007fff45c6c158  00007f61bc36fd94  /system/lib64/libc.so (__libc_init+84)

Change-Id: I36796c99843a41583824a96793a5a4c81ddb666e
2014-01-31 23:13:55 -08:00
Elliott Hughes
e9edf7a0ef LP64 should have debuggerd and debuggerd64.
Change-Id: I4e39c200e6867bb9a5bbcfec1c449b8864028feb
2014-01-31 17:15:10 -08:00
Elliott Hughes
6694d3e3d5 Remove dead code that looked like part of debuggerd.
Note that these were two different functions. The definition was unused,
and the declaration was undefined.

Change-Id: I2edd10a0ab9422cd5252bdb9ccdd726dc5fad531
2014-01-31 10:37:18 -08:00
Kévin PETIT
abc60c26b7 AArch64: Port debuggerd
Change-Id: Ib18f76f375a1d70c84e0a09d221e17ac43144b96
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-01-30 18:05:03 -08:00
Pavel Chupin
c6c194ced0 LP64: Enable debuggerd/libbacktrace/libunwind.
Change-Id: I2e432839f86c33c2adbaac8cc12ca8961956044b
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2014-01-30 17:15:24 -08:00
Kévin PETIT
4bb477205a debuggerd: a few generic improvements
This one makes dump_memory reasonably architecture-agnostic so it is
possible to share the code between architectures.

It also includes a few small improvements in tombstone.cpp.

Change-Id: Ib8a9599bfa420b41e80207988e87aee1b9d79541
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-01-30 15:55:33 -08:00
Christopher Ferris
d391c9b4ac Merge "Re-enable libunwind for arm." 2014-01-28 21:23:50 +00:00
Christopher Ferris
df2906186b Re-enable libunwind for arm.
Update to handle the new optimized way that libunwind works.

In addition, a small refactor of the BacktraceMap code.

A few new tests of for good measure.

Change-Id: I2f9b4f5ad5a0dfe907b31febee76e4b9b94fb76f
2014-01-28 12:03:36 -08:00
Mark Salyzyn
fca0bd1a38 debuggerd: Support newline split in log messages
(cherry picked from commit 706fad2b5f)

Change-Id: I2c19f12ef027ab1e1455ce78824537da1b03edcd
2014-01-27 15:17:13 -08:00
Mark Salyzyn
22b5cef127 debuggerd: Incorporate liblog reading API
(cherry picked from commit a63f927ce1)

Change-Id: Ic26e9dba3b45c827d122b03e34cc4a5bd48f7deb
2014-01-27 15:11:10 -08:00
Christopher Ferris
46756821c4 Rewrite libbacktrace to be all C++.
This includes removing the map_info.c source and replacing it with the
BacktraceMap class to handle all map related code.

Change all callers of libbacktrace map functionality.

Also modify the corkscrew thread code so that it doesn't need to build
the map twice (once in the corkscrew format and once in the libbacktrace
format).

Change-Id: I32865a39f83a3dd6f958fc03c2759ba47d12382e
2014-01-16 16:12:29 -08:00
Christopher Ferris
20303f856f Next phase of the move, reformat use C++ features.
Use the libbacktrace C++ interface instead of the C interface in debuggerd.

Reformat the debuggerd code to be closer to Google C++ style.

Fix all debuggerd casts to be C++ casts.

Add a frame number to the frame data structure for ease of formatting and
add another FormatFrameData function.

Change the format_test to use the new FormatFrameData function.

Modify all of the backtrace_test to use the C++ interface.

Change-Id: I10e1610861acf7f4a3ad53276b74971cfbfda464
2014-01-13 14:21:52 -08:00
Christopher Ferris
d607495b89 Move to C++ for debuggerd.
This is part 1, only including the bare minimum changes because
our diff tool doesn't easily show differences when a file moves. This
also breaks it into a small chunk in case some other changes break things,
as unlikely as I think that will be.

Change-Id: Ib7a3e7a2cc1ac574d15b65fda23813ebcf5d31af
2014-01-10 16:05:12 -08:00
Elliott Hughes
cac5d8c223 Use the more portable <elf.h> instead of <sys/exec_elf.h>.
Bug: 12476126
Change-Id: I08684987e867371d5537dadf1acb3408b420ad0c
2014-01-10 14:40:53 -08:00
Christopher Ferris
9846497f79 Refactor to share map_info amongst threads.
Allow the use of the same map info to be shared when getting information on
multiple threads from the same pid.

Change-Id: I2e460e20154a10f4894ae563331fb32179e4551f
2014-01-08 15:32:28 -08:00
Elliott Hughes
9e7d2180c7 Switch ARM debuggerd over to <sys/user.h>.
Change-Id: I106d4e80a2e819f1d47ca81893340f567bb8b4d9
2013-11-26 18:01:29 -08:00
The Android Open Source Project
66ed50af68 Merge commit '536dea9d61a032e64bbe584a97463c6638ead009' into HEAD
Change-Id: I5c469a4b738629d99d721cad7ded02d6c35f56d5
2013-11-22 13:44:43 -08:00
Elliott Hughes
76e7f5e508 Switch MIPS over to <sys/user.h>.
Bug: 11559337
Change-Id: I47ce51ec2d45d9cfdfbb6cccce93a66b0f02d967
2013-11-20 11:31:29 -08:00
Elliott Hughes
18ddd42092 Remove x86 debuggerd dependencies on non-uapi headers and corkscrew.
Also remove a hack that claims to be "just like ARM", but which was
different from the ARM and MIPS behavior.

Change-Id: I9b16da9a56430998ded27d304ce52c7cc8bfedfc
2013-11-14 17:06:46 -08:00
Christopher Ferris
17e91d44ed Rewrite libbacktrace using C++.
The old code was essentially trying to be C++ in C and was awkward. This
change makes it all objects with a thin layer that C code can use.

There is a C++ backtrace object that is not very useful, this code will
replace it.

This change also includes moving the backtrace test to a gtest, and adding
coverage of all major functionality.

Bug: 8410085
Change-Id: Iae0f1b09b3dd60395f71ed66010c1ea5cdd37841
2013-10-28 17:55:25 -07:00
Christopher Ferris
f84f7fa4d2 am 9492b6e7: am 2de8102d: Merge "Fix bug in abort message processing."
* commit '9492b6e72cef71422ba624e3cd11f07156cfb34a':
  Fix bug in abort message processing.
2013-10-09 23:08:59 -07:00
Christopher Ferris
dbd2ab4dca Fix bug in abort message processing.
Bug: 11156592
Change-Id: I4b82e7be5d7fccd167f6c52f78a5af3d3a553779
2013-10-09 18:31:40 -07:00
Christopher Ferris
816c9a64f9 am fa135f5c: am 7dbe9660: Merge "Update debuggerd to use libbacktrace."
* commit 'fa135f5ce95a8eff2ff51c03ad2e9d9b2a8b2274':
  Update debuggerd to use libbacktrace.
2013-10-04 15:42:14 -07:00
Christopher Ferris
365e4ae745 Update debuggerd to use libbacktrace.
Remove all of the code in debuggerd that uses libcorkscrew directly
and replace with libbacktrace.

Also do a bit of refactoring to clean up some functions that were
passing around variables that weren't used.

Bug: 8410085

Change-Id: I27da4fbe3f12ce38a85b4432fc1119984c9c391b
2013-10-03 11:07:56 -07:00
Colin Cross
9227bd3855 Move liblog headers to system/core/include/log
Move the liblog headers to log/ instead of cutils/ to complete
the separation of libcutils and liblog.  cutils/log.h still
exists and includes log/log.h in order to support the many existing
modules that use cutils/log.h.

Change-Id: I2758c9f4aedcb809ca7ba8383d0f55041dd44345
2013-07-24 12:32:39 -07:00
Elliott Hughes
0246f8f6f6 am a570312a: am f265426f: am 596ee9ea: Merge "Improve the crasher stack-overflow command."
* commit 'a570312a56938f6ebfcadc3ec9830ab8a2407654':
  Improve the crasher stack-overflow command.
2013-07-16 10:24:44 -07:00
Elliott Hughes
f265426f02 am 596ee9ea: Merge "Improve the crasher stack-overflow command."
* commit '596ee9ea8ae37b17fbdff91508f55250d528f1d2':
  Improve the crasher stack-overflow command.
2013-07-16 10:21:22 -07:00
Elliott Hughes
b1be27e29b Improve the crasher stack-overflow command.
Runs a lot quicker, with no intermediate noise.

Change-Id: Icd911ff305da2e0889029dc78d5c2b39f32111c5
2013-07-15 17:19:02 -07:00
Nick Kralevich
96bcd488c2 debuggerd: Ignore SIGPIPE
The system server may prematurely close the connection to
/data/system/ndebugsocket if it's not interested in the data
from debuggerd.  If it does so, we don't want to die due to a
SIGPIPE.

Change-Id: Iaef1f497bcd630144e6df6a06644a3293b85b6e0
2013-06-18 17:57:08 -07:00
Elliott Hughes
65d8ec099d am 6ef0dfec: Merge "Add a new test to crasher to upset dlmalloc."
* commit '6ef0dfecca9fde5abe15ceea30e0615897d7b374':
  Add a new test to crasher to upset dlmalloc.
2013-06-12 14:23:29 -07:00
Elliott Hughes
6f40cafd9f Add a new test to crasher to upset dlmalloc.
We should also add a test for heap corruption, but I failed to come up
with a kind of corruption that dlmalloc actually detects (rather than
just crashing accidentally).

Change-Id: I7457e732729635b171ffc44517c3de71f55608e6
2013-06-12 14:04:34 -07:00
Elliott Hughes
82081f71f6 am cb6a842c: Merge "Add a stack overflow test to crasher, and document all the options."
* commit 'cb6a842c6e2048e6cd3c5a2d478113347c75d7aa':
  Add a stack overflow test to crasher, and document all the options.
2013-04-23 19:29:40 -07:00
Elliott Hughes
3808c4ecb4 Add a stack overflow test to crasher, and document all the options.
Change-Id: Iebe80c24ef43f08d258881e7847516d414436931
2013-04-23 17:14:56 -07:00
Christopher Tate
300fd6fdbc Fix regression: log mem maps around native fault address
Restore the logging of the mem maps around the fault address along
with the rest of the faulting thread's information.  (It was still
being written to the tombstone file, but the logging got dropped on
the floor in the refactoring around AM report integration).

Bug 8654694

Change-Id: Id8851fa765dfe6b6ce41ccfc39e85eaac0acc629
2013-04-18 14:12:31 -07:00
Ying Wang
083b5ccba3 Add liblog
Bug: 8580410
Change-Id: Iab3a9b4307f207c14a04a922cc7350c54e60e9ad
2013-04-09 22:03:45 -07:00
Christopher Tate
7716aef138 Uploaded native crash dumps do not include memory contents
Also fixed the LOG() macro to actually write to the log again, tracking
the change in _LOG() argument semantics.

Bug 8322568

Change-Id: I79330c85c26d3ffb734315b6d0f2c0bb80bd234a
2013-04-05 16:30:15 -07:00
Elliott Hughes
e5f8a692e4 Modify debuggerd to cope with the abort message.
(cherry picked from commit 707b8bbe18)

Bug: 8531731
Change-Id: I2785a07ef83e085f338d3094f9972de23117807c
2013-04-05 15:59:17 -07:00
Elliott Hughes
707b8bbe18 Modify debuggerd to cope with the abort message.
Bug: 8531731
Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
2013-04-04 13:52:01 -07:00
Christopher Tate
ded2e5acfc debuggerd now notifies the Activity Manager about native crashes
The Activity Manager sets up a permission-guarded domain socket, which
debuggerd connects to when a crash happens.  If this is successful,
the daemon then mirrors the logged crash report to that socket, then
closes it.

Bug 8322568

Change-Id: Ife0c772a628ef82e8457094e511ce1edbfe57460
2013-04-01 10:37:24 -07:00
Elliott Hughes
e05093b924 am 3e77b752: am 0b535558: Merge "Unwinding implementation via eh_frame sections for x86"
* commit '3e77b7521ba96fd1ff6fed0e019aff5f46a31428':
  Unwinding implementation via eh_frame sections for x86
2013-03-14 17:25:04 -07:00
Pavel Chupin
af2cb3667b Unwinding implementation via eh_frame sections for x86
Backtracing through eh_frame section is more effective allowing to reuse
ebp register for other purposes within routine. GCC with turned on
optimizations (-O1 and above) implicitly defines -fomit-frame-pointer
anyway. eh_frame sections are generated by default with GCC on any
optimization level.

This change implements remote unwinding (separate process unwinding).
Local unwinding is already implemented through _Unwind_Backtrace call
which is implemented in libgcc.

Change-Id: I1aea1ecd19c21710f9cf5f05dc272fc51b67b7aa
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-03-14 19:11:44 +04:00
Elliott Hughes
3b7c584fe9 am 910b7a8b: am 17361134: Merge "Add a "smash-stack" option to crasher."
# Via Android Git Automerger (1) and others
* commit '910b7a8b88b29ee16c6014630b450dda56c5d578':
  Add a "smash-stack" option to crasher.
2013-02-14 16:21:04 -08:00
Elliott Hughes
df4200e8c2 Add a "smash-stack" option to crasher.
bionic's __stack_chk_fail was preventing debuggerd from dumping
stacks, which was not helpful.

Bug: 2487269
Change-Id: Idba2a274037b960dfb2ac1c21686323268c4b372
2013-02-14 14:41:57 -08:00
Elliott Hughes
e8097be24e am a82985b6: am 7cd45071: Merge "Include page protections in the debuggerd map output."
* commit 'a82985b6686f8b47119193fee2f804376a90125b':
  Include page protections in the debuggerd map output.
2013-01-03 15:21:56 -08: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
Elliott Hughes
c75cbf456e am 3de7fe9f: am 5fb042dd: Merge "Expand crasher with a "thread-" prefix to crash on another thread."
* commit '3de7fe9f40489db691407d6ebfd77cfde23d8049':
  Expand crasher with a "thread-" prefix to crash on another thread.
2012-12-10 17:36:23 -08:00
Elliott Hughes
aa4213057b Expand crasher with a "thread-" prefix to crash on another thread.
So "thread-nostack" runs the "nostack" code on a new thread, and
"thread-abort" runs the "abort" code on a new thread, and so on.

Bug: http://code.google.com/p/android/issues/detail?id=16672
Change-Id: I026a0e43eea147f1a7a74243846954599bcf4238
2012-12-10 14:15:42 -08:00
Elliott Hughes
6dc5128a81 am 435c223d: am 5144fa28: Merge "Add missing signal codes to get_sigcode."
* commit '435c223d483c5e408fdbd7b6177e881ae445a24b':
  Add missing signal codes to get_sigcode.
2012-12-10 11:43:29 -08:00
Andy McFadden
b08084850d Show pid+uid in certain failures
If somebody sends debuggerd bad data, it logs a complaint
but doesn't give any indication of the source.  Now we show
the pid and uid we get from SO_PEERCRED.

Bug 7704699

Change-Id: I2738eb972932cc868ad969b60e16dd0b623212a1
2012-12-10 10:40:28 -08:00
Elliott Hughes
8f7d4430f3 Add missing signal codes to get_sigcode.
The only common one we were missing is SI_TKILL, but we've had the full
set on the dalvik-dev branch for some time now.

Change-Id: I7cf52d352b8624e0adb17a2ed440e7a10f490dfd
2012-12-10 10:35:11 -08:00
Elliott Hughes
3427e80ef3 am a6fb0e05: Merge "Fix debuggerd\'s use of readdir_r(3)."
* commit 'a6fb0e05aa95995445c6f2b65f07db26bdbfd46c':
  Fix debuggerd's use of readdir_r(3).
2012-10-30 16:57:51 -07:00
Elliott Hughes
c463d2cf9c Fix debuggerd's use of readdir_r(3).
Change-Id: I1b178af054cefebfb774320e4b4699d6dc8bbb01
2012-10-26 16:47:09 -07:00
Kenny Root
2a36ae5608 am 7b88a90d: Merge "Remove HAVE_SELINUX guards"
* commit '7b88a90da2a27e347fc16c14fa577f4ae1ef07fd':
  Remove HAVE_SELINUX guards
2012-10-17 09:57:10 -07:00
Kenny Root
b5982bf7c6 Remove HAVE_SELINUX guards
Change-Id: I8272c573b3c5dc663203bafab68fad5e94d89364
2012-10-16 23:18:18 -07:00
Ben Cheng
c47b772b67 Dump 256 bytes per chunk pointed by general-purpose registers.
Bug: 7216522
Change-Id: Iddcec8399b00ad411be6863dd866a3f74377ba03
2012-09-24 14:13:37 -07:00
Ben Cheng
d7760c1688 Print the revision number in the tombstone file.
Bug: 7168261
Change-Id: Icb412760d018e4bbb1a5d742ed7d484d5cf6b470
2012-09-19 19:19:53 -07:00
Chris Dearman
231e3c83a3 [MIPS] debuggerd and libcorkscrew support
Change-Id: I5a241dc2e470148be0ad2c138e31f1aba5ab8812
2012-08-10 18:16:20 -07:00
rpcraig
f1186f3e98 restorecon tombstone directory.
Restore the security contexts of tombstone directory
when initially created.

Change-Id: I25b53730991576eccb62ca57050decd584acc639
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
2012-07-19 09:38:06 -04:00
Jeff Brown
f87d9c8698 am 9cec175c: Remove a stray newline in the backtrace output.
* commit '9cec175c66100d9edbb1054f3f2977a5c3f80af2':
  Remove a stray newline in the backtrace output.
2012-06-08 15:30:33 -07:00
Jeff Brown
536b81afed resolved conflicts for merge of 053b8654 to jb-dev-plus-aosp
Change-Id: Idfef8c26b7a9e1a1a202e21dc5d34022bbaa92cc
2012-06-08 15:27:01 -07:00
Jeff Brown
9cec175c66 Remove a stray newline in the backtrace output.
Bug: 6615693
Change-Id: I1ac1746286afb77c3f5c4042c4592333ebb08a51
2012-06-08 14:21:51 -07:00
Jeff Brown
053b865412 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
console.

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

Bug: 6615693
Change-Id: Ib3edcc16f9f3a687e414e3f2d250d9500566123b
2012-06-08 13:29:23 -07:00
Jean-Baptiste Queru
5820a99f3f Fix build
Change-Id: Ie2af6aab7e236c31bb7a607659813218ef9c5400
2012-05-16 16:56:57 -07:00
Andy McFadden
424e07fcf6 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
2012-03-08 15:42:30 -08: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
fb9804bfc2 Print the tombstone path.
When explicitly requesting a dump, show the user the path of
the tombstone file that was generated.

Change-Id: I7fff7dea606872a61687ca087e99f604107b70c4
2011-11-08 20:17:28 -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
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