Commit graph

27 commits

Author SHA1 Message Date
Kalesh Singh
a9ea7e5b8e debuggerd_client: also log errors to the dump file.
Dumping stack in ANR can fail, but error message is only printed
to logcat. To allow easier debugging of such cases we add the
error messages in the ANR file as well.

Also factor out some duplication, inline single-call functions to
their call sites, and make some of the lambdas clearer by only having
implicit state unrelated to their primary purpose in captures but
passing as arguments things they fundamentally need to do their job
(and actually adding some duplication for time_left() which was subtle
enough to fool me into thinking that we only needed one call of
set_timeout(), which I've renamed to update_timeout()).

Bug: 191172191
Test: Manual
Change-Id: I39a50ca5b72059bfeff48b010d3be44f19eb32fa
2021-06-29 11:59:14 -07:00
Josh Gao
31348a74e0 debuggerd: store commandline instead of process name.
Bug: http://b/180605583
Test: debuggerd_test
Change-Id: I018d399a5460f357766dc1b429f645f78fe88565
2021-03-30 12:15:56 -07:00
Elliott Hughes
a660cb3f13 debuggerd: use One True timestamp function.
An OEM asks for sub-second granularity, and that's most easily done if
we only have one timestamp generator. I'm not convinced sub-second
granularity is particularly useful myself, and I definitely don't think
that nanosecond resolution is meaningful but I do like this cleanup, and
if I'm going to use sub-second precision I may as well use the maximum
precision available to me.

Also reduce some duplication of code reading cmdline/comm.

Bug: https://issuetracker.google.com/161860597
Test: head /data/tombstones/*
Change-Id: I035ecfd4a3338ccd84dae0ef973a998a7c7c5056
2020-07-23 16:33:53 -07:00
Mitch Phillips
e0b4bb1b2e [GWP-ASan] Add GWP-ASan information to tombstones.
GWP-ASan can provide information about a crash that it caused. Grab the
GWP-ASan regions from the globals shared by the linker for crash-handler
purpopses, pull the information from GWP-ASan, and display it.

This adds two regions:
 1. Causality tracking by GWP-ASan. We now print a cause header about
 the crash, like `Cause: [GWP-ASan]: Use After Free on a 1-byte
 allocation at 0x7365bb3ff8`
 2. Allocation and deallocation stack traces.

Bug: 135634846
Test: atest debuggerd_test

Change-Id: Id28d5400c9a9a053fcde83a4788f971e677d4643
2020-02-18 16:49:50 -08:00
Josh Gao
a48b41bcb8 debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.
Test: treehugger
Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
2019-12-17 16:36:05 -08:00
Treehugger Robot
ecc9b1bd7f Merge "debuggerd_client_test: massively increase timeouts." 2019-10-17 21:33:46 +00:00
Josh Gao
f10d4a15d2 debuggerd_client_test: massively increase timeouts.
debuggerd_client.race seems to have suddenly started to flake, for no
apparent reason. This doesn't seem to reproduce locally, so increase
the timeouts to rule out our test VMs being slow.

Bug: http://b/142571257
Test: treehugger
Change-Id: Ic54a78b8da36cb1163cec7e7976c73c3da628a30
2019-10-17 12:09:49 -07:00
Nick Desaulniers
67d52aa0f6 [debuggerd] fix -Wreorder-init-list
C++20 wants members to be ordered unlike C99.

Bug: 139945549
Test: mm
Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-10-10 14:54:35 -07:00
Kalesh Singh
1489e27bda Add wchan data to ANR dump
Since only privileged processes with CAP_SYS_ADMIN can read kernel
stack traces from /proc/*/stack, we dump the waiting channels
instead to provide some insight as to where the process might
be stuck in the kernel.

Bug: 135458700
Fixes: 135458700
Test: adb shell am hang; Check /data/anr/<anr-file> for
      wchan data.
Change-Id: I9f13511ad89a259ce5e5465155db15d45d2c46d8
2019-07-18 16:02:57 -07:00
Josh Gao
5f87bbdb0a debuggerd: switch to base::{Send,Receive}FileDescriptors.
Bug: http://b/12204763
Test: debuggerd_test
Change-Id: I0be40916214de51ab36fd6bd6d44090a84312e51
2019-02-13 13:21:54 -08:00
Greg Kaiser
3fa9a59ea3 debuggerd: Fix return type in error case
With our method returning 'bool', a "return -1" is interpretted
as 'true'.  We change this to an explicit 'false', as desired.

Test: TreeHugger
Change-Id: I222858b797bc4242a2dc6d4fe81df3d2586d055a
2019-01-08 06:29:22 -08:00
Josh Gao
4175cee3cc debuggerd_client: resolve tid to tgid when dumping Java stacks.
Bug: http://b/121438213
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I4d114c8b0c4586ba64de5b45b47b0ec5c10354f8
2019-01-04 13:57:09 -08:00
Josh Gao
be0c1af6f0 debuggerd_client: improve error logging.
system_server is sometimes failing to dump with the following error:

    libdebuggerd_client: received packet of unexpected length from tombstoned: expected 128, received -1

Improve the logging to try to figure out what's going on.

Bug: http://b/114139908
Test: treehugger
Change-Id: Iee1bdc0891b9fc7bd80a330495ec22a530febddb
2018-09-06 13:00:57 -07:00
Jaesung Chung
cde2b524f1 crash_dump: lower THREAD_COUNT in debuggerd_client.race for low-speed devices
The debuggerd_client.race tests the crash_dump process to finalize the
killed process within 2 seconds. The 2 seconds timeout for finalizing a
process, which has 1024 threads, is bit small for low-speed devices.
This CL lowers the bar in order to make such devices pass the test.
Wraping up 128 threads within 2 seconds looks safe.

Bug: 62600479
Test: debuggerd_test passes on low-speed devices.
Change-Id: I3089415961422e6933405d2c872913273425caff
2017-06-23 08:59:22 +09:00
Josh Gao
5675f3c321 debuggerd_client: increase pipe buffer size to max.
If a process tries to dump itself (e.g. system_server during ANRs),
crash_dump will block trying to write to its pipe if it's not
sufficiently large. Increase the pipe size to the max, and add a test
to make sure that it's always at least 1MB (the default value).

Bug: http://b/38427757
Test: debuggerd_test
Change-Id: Iddb0cb1e5ce9e687efa9e94c2748a1edfe09f119
2017-06-01 12:42:44 -07:00
Narayan Kamath
a73df601b7 tombstoned: allow intercepts for java traces.
All intercept requests and crash dump requests must now specify a
dump_type, which can be one of kDebuggerdNativeBacktrace,
kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have
only one outstanding intercept registered at a time.

There's only one non-trivial change in this changeset; and that is
to crash_dump. We now pass the type of dump via a command line
argument instead of inferring it from the (resent) signal, this allows
us to connect to tombstoned before we wait for the signal as the
protocol requires.

Test: debuggerd_test

Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37
2017-05-31 10:35:32 +01:00
Narayan Kamath
2d377cd688 tombstoned: Add a shared library version of libtombstoned_client...
.. for ART and the frameworks to link against. In the new stack dumping
scheme (see related bug), the Java runtime will communicate with
tombstoned in order to obtain a FD to which it can write its traces.

Also move things around to separate headers that are private
implementation details from headers that constitute the public debuggerd
API. There are currently only three such headers :

- tombstoned/tombstoned.h
- debuggerd/client.h
- debuggerd/handler.h

Bug: 32064548
Test: make

Change-Id: If1b8578550e373d84828b180bbe585f1088d1aa3
2017-05-22 16:55:21 +01:00
Liu Changcheng
3492221fcf check send_signal result before further dealing
If send_signal failed, debuggerd_trigger_dump should return
instead of further dealing

Change-Id: I0a1ac4255344d1da7a21917ad559b9de4d5a4fee
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Signed-off-by: Jerry Liu <primerlink@gmail.com>
2017-04-06 22:47:00 +08:00
Josh Gao
287d50dc59 debuggerd_client: fix infinite timeouts.
Bug: http://b/36897117
Test: debuggerd_test
Test: debuggerd -b `pidof zygote`
Change-Id: I743433bc420b1c433b82ef62795abb6ea9f5d840
2017-04-04 14:08:54 -07:00
Josh Gao
460b336d6a tombstoned: fix a race between intercept and crash_dump.
Previously, there was no way to detect when tombstoned processed an
intercept request packet, making it possible for a intercept request
followed by a crash_dump being processed in the wrong order.

Add a response to intercept registration, to eliminate this race.

Test: debuggerd_test
Change-Id: If38c6d14081ebc86ff1ed0edd7afaeafc40a8381
2017-03-30 16:49:02 -07:00
Josh Gao
ae9d7676a5 debuggerd_client: properly wait for completion.
Use an intermediate pipe to detect and report when a requested dump has
completed.

Bug: http://b/35241370
Bug: http://b/35813071
Test: debuggerd_test
Test: manually triggered a background ANR
Change-Id: If14aedf6071288360f1a7853d5a2ee79db121759
2017-03-27 16:11:38 -07:00
Josh Gao
981761bbb2 debuggerd: remove obsolete dumpable check.
PR_SET_DUMPABLE is ignored now.

Bug: http://b/35872161
Test: debuggerd -b `pidof surfaceflinger`
Change-Id: Iefd090f2b762d454d1e6ce8061ff5f992974267c
2017-03-01 11:55:16 -08:00
Josh Gao
cbe70cb0a8 debuggerd: advance our amazing bet.
Remove debuggerd in favor of a helper process that gets execed by
crashing processes.

Bug: http://b/30705528
Test: debuggerd_test
Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906
2017-01-17 13:57:57 -08:00
Josh Gao
218f7fb68e debuggerd: report crashes even when out of file descriptors.
Use nasty clone hacks to let us close random file descriptors to be
able to connect to debuggerd when the fd table is full.

Bug: http://b/32013594
Test: crasher exhaustfd-SIGSEGV
Change-Id: I47772e9a5994da4473bd935b105d9c36827c017a
2016-10-07 18:04:05 -07:00
Elliott Hughes
6fff551728 Teach debuggerd about SIGSYS SYS_SECCOMP signals.
These should be easier to interpret.

Bug: http://b/31171101
Change-Id: I362361d218390ab2306f86976172f8365b26b6ef
2016-09-07 13:55:50 -07:00
Josh Gao
a04c80255c debuggerd: remove unnecessary arguments.
These were previously required when bionic used tgkill to reraise
signals, but now that we use rt_tgsigqueueinfo to reraise signals, they
are no longer necessary.

Change-Id: I46ba9f14039a727d0a2c4c3a9d93a3532ba8f263
2016-08-12 11:00:18 -07:00
Josh Gao
9c02dc5916 debuggerd: add libdebuggerd_client.
Bug: http://b/24414818
Change-Id: I079c534d2c952b6975bf0428eb86cc7a55525737
2016-06-17 13:11:29 -07:00