Commit graph

210 commits

Author SHA1 Message Date
Christopher Ferris
a3ee46f105 Merge "Dump memory going from unreadable to readable." 2015-07-09 23:38:26 +00:00
Christopher Ferris
456abbabf2 Dump memory going from unreadable to readable.
If the first read when dumping memory returns no data, skip ahead to
the next page boundary and try and read from there. This fixes a case
where the address at which to start dumping memory is unreadable, but
crosses back into readable memory.

Bug: 22234753
Change-Id: Ie28d5c027013577ca06f5396aba498366a3b6749
2015-07-09 15:35:47 -07:00
Christopher Ferris
d79f2bebcc New property that determines when to wait for gdb.
Use debug.debuggerd.wait_for_gdb being set to non-zero to
determine if debuggerd should stop and wait for someone to
attach gdb to the crashing process.

Bug: 22233908
Change-Id: Id55a1572b479a70d395b7270392ce6fb70dbfdca
2015-07-08 16:01:49 -07:00
Christopher Ferris
41a0654e2a Merge "Replace all _LOG error calls with ALOGE." 2015-07-08 19:16:03 +00:00
Elliott Hughes
39a28c2526 Fix debuggerd's gdbclient instructions.
We improved gdbclient to make the process simpler, but didn't update
debuggerd to match.

Bug: http://b/22233857
Change-Id: If4137943f567a9e566a3ac7f485c9b1eab2c68e9
2015-07-07 14:34:39 -07:00
Christopher Ferris
b36b592338 Replace all _LOG error calls with ALOGE.
The debuggerd code sometimes calls _LOG(..., logtype::ERROR, ...)
and sometimes ALOGE(). Standardize on ALOGE since the _LOG message
will wind up in the tombstone in weird places, but using ALOGE
will wind up in the logcat portion of the tombstone.

Bug: 21467089
Change-Id: Ie893f5e91d45b48ef3f5864c3a714e60ac848fb3
2015-07-01 13:23:19 -07:00
Nick Kralevich
4d87095ebf Remove calls to is_selinux_enabled()
d34e407aeb removed support for
running with SELinux completely disabled. SELinux must either be
in permissive or enforcing mode now.

Remove unnecessary calls to is_selinux_enabled(). It always returns
true now.

Change-Id: Ife3156b74b13b2e590afe4accf716fc7776567e5
2015-06-12 22:12:33 -07:00
Christopher Ferris
862fe02919 Change the 64 bit map address format.
Previously, the map printing in tombstones for 64 bit devices uses
a variable length value. This means that the maps are not lined up.
The new format is to print the map as 00000000'00000000 in all ways.

Also fix a bug where the backtrace_map_t did not initialize all
parameters.

Add unit tests for all of the dump_all_maps function.

Bug: 20950813
Change-Id: I30901c8a0251b00d85c4c01476b033ef8db84e32
2015-06-03 10:24:21 -07:00
Christopher Ferris
a684d9dad5 Merge "Refactor dump_memory function." 2015-05-28 18:02:10 +00:00
Christopher Ferris
e8bc77eb84 Refactor dump_memory function.
- Add dumping memory around registers for x86/x86_64.
- Add unit tests for new dump_memory function.
- Cleanup all of the machine.cpp files.
- Increase the high address check for 32 bit, and decrease the high
  address allowed for 64 bit slightly to match mips64.

Bug: 21206576
Change-Id: I6f75141f3282db48b10f7c695a1cf2eb75a08351
2015-05-27 17:21:38 -07:00
Elliott Hughes
47b0134ec2 Don't use TEMP_FAILURE_RETRY on close in system/core.
Bug: http://b/20501816
Change-Id: I1839b48ee4f891b8431ecb809e37a4566a5b3e50
2015-05-15 19:16:40 -07:00
Christopher Ferris
6e96403b8f Switch UniquePtr to std::unique_ptr.
Bug: 21209050
Change-Id: I91d4c44de479b37f2729382fcdf103b8c69aa668
2015-05-15 17:30:21 -07:00
Christopher Ferris
30c942cf10 Prevent crashes if a map cannot be created.
Under some conditions, /proc/<pid>/maps might return nothing. If we
try and unwind in this case, we'll crash. Check this case and fail
the unwind.

Add checks that no other functions try and use map_ without
checking for nullptr.

Add logging when an unwind fails so it's clear what happened.

Bug: 21162746
Change-Id: I56ce51dda0cfc9db20475a441f118108196aa07c
2015-05-14 17:56:41 -07:00
Christopher Ferris
5c8856854d Add offset to map data.
Also, print the offset in the maps section.

Bug: 20864928
Change-Id: I71f005726e5ef73cf75bbcb8f829fd5127cb9d61
2015-05-06 12:50:09 -07:00
Christopher Ferris
b0412a5c2b All debuggerd log output marked fatal.
This avoids the log daemon skipping some of the log output from
debuggerd.

Bug: 20846525
Change-Id: Ifed48814d76c7e855645b6d5487d5e6e1fcafd9e
2015-05-05 13:27:41 -07:00
Christopher Ferris
2106f4ba95 Add load base to map for relocation packing.
The new linker relocation packing support uses non-zero load bases,
so we better handle them properly.

Also print out the load base for a map if it's non-zero.

Bug: 20687795
(cherry picked from commit 329ed7dae4)

Change-Id: Ibc37d8c8bb032820dca4e7531184349ba6d402d2
2015-05-01 17:09:49 -07:00
Elliott Hughes
b7cd09b93e Use WriteFully in debuggerd to talk to ActivityManager.
Change-Id: I5b57fda9b0343434e1c0f9189147075a368e0282
2015-04-24 22:25:12 -07:00
Yabin Cui
03dca28def Fix alignment when reading note segment.
ELF said that padding is present, if necessary, to ensure 4-byte
alignment for the descriptor and next note entry, but such padding
is not included in namesz and descsz.

Change-Id: I7896783f3d9a787772d56c49905f52a493c9fba1
2015-04-14 10:27:54 -07:00
Christopher Ferris
a21bd93ef5 Print the build id of shared libraries if present.
For every map that has a name, and if it's a mapped in shared library,
print the build id.

Refactor the way dump_all_maps logs data.

Refactor the way stack segments are dumped.

Bug: 19371018
Change-Id: Ic08d05a4b13f128925743936fb84d8059f7cb56f
2015-03-17 15:13:35 -07:00
Douglas Leung
2ea9a32434 Add backtrace support for mips64.
Change-Id: I12ea2fcbe6780bb596f51988eae1ceafcec858df
2015-03-09 18:43:10 -07:00
Mark Salyzyn
2d3f38a6b8 liblog: introduce ANDROID_LOG_* flags
Move away from using POSIX open(2) flags and introduce ANDROID_LOG_* flags to
replace them. Add security by preventing random mode flags from getting into
underlying POSIX calls. ANDROID_LOG_* flags overlap POSIX O_* flag definitions.

Change-Id: Ib32bb64c287e8bf150be62242e1ba46bb37839fc
2015-02-25 17:44:18 +00:00
Christopher Ferris
ab9e7dcef6 Do not dump maps/memory/code of sibling threads.
Modifies the code so that if the unwind fails, the code still prints
as much data as possible.

Also, for sibling threads, skip printing the maps and memory/code
since it's not likely to be very relevant.

Fix a few cases where extra space is at the end of lines.

Fix an inverted if statement that was checking the wrong condition.

Bug: 18816322
Change-Id: Ic659e0c34489bf2c65c5a23e2b83e31653b927e4
2015-02-09 19:22:33 -08:00
Christopher Ferris
12385e3ad0 Move map data into backtrace data proper.
The backtrace structure used to include a pointer to a backtrace_map_t
that represented the map data for a particular pc. This introduced a
race condition where the pointer could be discarded, but the backtrace
structure still contained a pointer to garbage memory. Now all of the map
information is right in the structure.

Bug: 19028453
Change-Id: If7088a73f3c6bf1f3bc8cdd2bb4b62e7cab831c0
2015-02-06 15:00:09 -08:00
Christopher Ferris
b817094081 Remove the pt_regs_mips_t structure.
The kernel finally has the pt_regs structure properly defined for mips,
so we don't need to define it ourselves.

Change-Id: Ifdf75ed827cd2390962e9b3a182bdbbf02fe0732
2015-01-26 13:52:35 -08:00
Christopher Ferris
9774df6134 Move 32 bit/64 bit check into debuggerd.
On 64 bit systems, calls to dump_backtrace_to_file or dump_tombstone
try and directly contact the correct debuggerd (32 bit vs 64 bit)
by reading the elf information for the executable.
Unfortunately, system_server makes a call to dump_backtrace_to_file
and it doesn't have permissions to read the executable data, so it
defaults to always contacting the 64 bit debuggerd.
This CL changes the code so that all dump requests go to the 64 bit
debuggerd, which reads the elf information and redirects requests for
32 bit processes to the 32 bit debuggerd.

Testing:

- Forced the watchdog code in system_server to dump stacks and
  verified that all native stacks are dumped correctly.
- Verified that dumpstate and bugreport still properly dump the native
  processes on a 64 bit and 32 bit system.
- Intentionally forced the 64 bit to 32 bit redirect to write only a
  byte at a time and verified there are no errors, and no dropped data.
- Used debuggerd and debuggerd64 to dump 32 bit and 64 bit processes
  seemlessly.
- Used debuggerd on a 32 bit system to dump native stacks.

Bug: https://code.google.com/p/android/issues/detail?id=97024
Change-Id: Ie01945153bdc1c4ded696c7334b61d58575314d1
2015-01-20 17:22:07 -08:00
Elliott Hughes
c184d5655a #include <arpa/inet.h> for htonl.
Not sure why this only shows up with clang.

Change-Id: Id5603483e32f8a8d4b091dbb31b3142e3f77deac
2014-12-18 23:49:17 +00:00
Yabin Cui
2331b95609 Make crasher smash-stack work.
Bug: 18721888
Change-Id: Id0280df7cb2c29832256d3d395e6399fcef9aa2b
2014-12-11 17:49:12 -08:00
Dmitriy Ivanov
052fc0a225 Print ASCII near register for all archs
Bug: 17880617
Change-Id: I6870e8ac670c08e45d8efb64479976a38edfdc93
2014-12-10 10:21:12 -08:00
Dan Albert
80b88cb5d2 Move debuggerd to libc++.
Bug: 15193147
Change-Id: I935a08e98077b688d1735fb5b84a615cb7df8810
2014-11-15 16:35:30 -08:00
Christopher Ferris
d4c7a1cfad am a11ac455: Merge "Fix debuggerd issues."
* commit 'a11ac45536f0722becefccdb6b58378c5d9d0d4b':
  Fix debuggerd issues.
2014-11-03 20:23:55 +00:00
Christopher Ferris
1072f917cf Fix debuggerd issues.
- Fix a problem where a tid exits before the attach completes, and it
  causes debuggerd to self terminate.
- Fix a problem where sibling tid dumps do not properly wait for the tid
  to get signalled.

Bug: 17800180
Bug: 12567315

(cherry picked from commit 84ddb34a3a)

Change-Id: I45e33865614d4c96f4a89cf117398666b556d500
2014-11-03 11:26:33 -08:00
Chih-Hung Hsieh
845867b2c2 am d88323b2: Merge "Add volatile to avoid clang optimization."
* commit 'd88323b2667c443c2738eb601eb0b9eaad1c3049':
  Add volatile to avoid clang optimization.
2014-10-28 04:49:12 +00:00
Chih-Hung Hsieh
a1ff475b07 Add volatile to avoid clang optimization.
BUG: 18108178
Change-Id: Ie5b8b1808fcf6d1eacc14a7c6ac0c8d49641fec2
2014-10-23 16:50:51 -07:00
Jeff Brown
55fbad69a1 am c3e6eb21: Merge "Move ABI: line below header when dumping stacks." into lmp-dev
* commit 'c3e6eb21b58ae3067ed03358687d1edb851f2abf':
  Move ABI: line below header when dumping stacks.
2014-09-12 05:43:08 +00:00
Jeff Brown
9b12d53b1a Move ABI: line below header when dumping stacks.
Bug: 17474152
Change-Id: I66b6e7e1cbb004f7a1915a2c1515df6555fe176f
2014-09-11 14:20:04 -07:00
Dmitriy Ivanov
a639b97d4a Do not suppress maps dump when si_addr<PAGE_SIZE
Also remove alignment of si_addr.

(cherry picked from commit f10aa3ae9d)

Bug: 16950250
Change-Id: I60170b9eb7dd8fe99c0eeeaec74d13cfbaa920d9
2014-08-11 10:01:58 -07:00
Dmitriy Ivanov
c326115115 am 75ef453e: am 2f40ddf3: Merge "Do not suppress maps dump when si_addr<PAGE_SIZE"
* commit '75ef453e5d3352aad8c55cd8fa572945c6f4bbfa':
  Do not suppress maps dump when si_addr<PAGE_SIZE
2014-08-10 00:08:34 +00:00
Dmitriy Ivanov
f10aa3ae9d Do not suppress maps dump when si_addr<PAGE_SIZE
Also remove alignment of si_addr.

Change-Id: Ie5445bf8a5baa49e04e37c643c25ebd0f1dc9d22
2014-08-09 12:07:51 -07:00
Mark Salyzyn
a9d3ed32e9 am 1d497f8a: am cddc97cb: Merge "debuggerd: tombstone: suppress logger request for logd process"
* commit '1d497f8a92994abeb5baeaacdec037268838af20':
  debuggerd: tombstone: suppress logger request for logd process
2014-07-29 23:26:05 +00:00
Mark Salyzyn
45ae446cab debuggerd: tombstone: suppress logger request for logd process
Change-Id: I619880342ee6febd1a6cc98d2a4f536120efc1c8
2014-07-28 15:16:05 -07:00
Mark Salyzyn
2f2e79de0c debuggerd: tombstone: suppress logger request for logd process
(cherry pick from 45ae446cab)

Change-Id: I619880342ee6febd1a6cc98d2a4f536120efc1c8
2014-07-29 16:13:23 -07:00
Brigid Smith
166cfe68c3 Added default constructor for log_t.
Bug: 16357258

(cherry picked from commit c75a02fe3f)

Change-Id: I96be34ee1664af54b0dcbc928ea542cd749852fd
2014-07-29 16:08:34 -07:00
Nick Kralevich
d753da344e am c70ebca4: am 6bc762b2: Merge "Add SELinux MAC to debuggerd."
* commit 'c70ebca44cc37b0d261736446ccf52bbdb61e7d1':
  Add SELinux MAC to debuggerd.
2014-07-24 20:31:11 +00:00
Stephen Smalley
69b800391c Add SELinux MAC to debuggerd.
debuggerd allows uid-0 processes to dump tombstones or backtraces
of any process, and uid-system processes to dump backtraces of any
processes.  Restrict these operations via SELinux based on the
client context, the target process context, and the action.

Depends on I8e120d319512ff207ed22ed87cde4e0432a13dda for the
corresponding policy definitions.

Change-Id: Ib317564e54e07cc21f259e75124b762ad17c6e16
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-07-24 16:01:56 -04:00
Elliott Hughes
8d2136922a am 4a95a209: am 719fd238: Merge "Added default constructor for log_t."
* commit '4a95a209e8fc472461aa75282b486e1860edde19':
  Added default constructor for log_t.
2014-07-17 23:09:05 +00:00
Brigid Smith
c75a02fe3f Added default constructor for log_t.
Bug: 16357258
Change-Id: I39169b35653d2b717fadbcff75978db01cc375ef
2014-07-17 15:49:39 -07:00
Nick Kralevich
04f9b2a809 debuggerd: use O_NOFOLLOW|O_CLOEXEC for tombstones
Change-Id: I71bdfba30346a9fad3129b404f39eda8190698e3
2014-07-16 20:08:41 -07:00
Elliott Hughes
e9f7361ea9 Add SIGFPE to crasher.
Bug: 3399996

(cherry picked from commit 3ecc42106e)

Change-Id: I075613ca3c022ce8d38a06a5ba236ceff32d181c
2014-07-15 13:18:32 -07:00
Elliott Hughes
aae5d43755 Add missing arm64 registers.
Also fix dumping of arm64's vector registers, which are actually 128 bits wide.

Also move the arm/arm64 FP registers to the tombstone. (We've never dumped
them at all for the other architectures.)

(cherry picked from commit b40c50351e)

Change-Id: Ic646fb9ea01e9beb42e1757feb8742c1d4efafa7
2014-07-14 18:56:53 -07:00
Elliott Hughes
3ecc42106e Add SIGFPE to crasher.
Bug: 3399996
Change-Id: I115caf846a47f57984c1b1844104e37d29e6f24e
2014-07-15 11:38:47 -07:00