Commit Graph

199 Commits

Author SHA1 Message Date
Greg Hartman
a6e5520bce Provide a way to disassemble code in a tombstone.
Test: ran disassemble_test.py

Change-Id: Id6beb23ff40d72b89b4d8400d645f7f868fd87d2
2017-07-20 16:57:51 -07:00
Kevin Rocard
258c89e9e4 Resolve gdbclient.py -r executable from target
gdbclient.py -r allows to provide an executable to be run on the target.
Before this patch the absolute path of the executable had to be
provided. This was inconvenient as the user has to first look up for the
exe on the target before debuging it.

With this patch, gdbclient.py will look for the executable on the
target if an absolute path is not provided.

Test: gdbserver -r ls
Change-Id: I610fd0a57b034ba8864874eeb1f7345d4a7daad9
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-07-12 18:48:16 -07:00
Elliott Hughes
89e1ecf9a1 Fix gdbclient.py -p.
Bug: http://b/26413900
Test: manually ran gdbserver on device, connected with -p
Change-Id: If58b95e52167c38263e77fe85bea14e0d7401bf4
2017-06-30 14:03:32 -07:00
Kevin Rocard
75b24f1270 Warn that gdbclient is deprecated in favor of gdbclient.py
Users of gdbclient might not know that a new and improved version exist
in the form of gdbclient.py.

Change-Id: I65243a8d25a1ecbe8ff734d0be4dbe40b50db4b2
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-06-21 18:49:50 -07:00
Mathieu Chartier
9ae5ff4895 Fix potential divide by zero in display_html
When using logwrapper, there is only a zygote heap. This caused
a divide by zero for the app heap.

Test: native_heapdump_viewer.py --html art/native_heap.txt > test.html

Change-Id: I7defd94935d72ee9c4cb6e53d7a1a308a1030eb3
2017-06-13 11:00:26 -07:00
Christopher Ferris
8d3f61724d Merge "Fix potential divide by zero." 2017-06-09 22:12:22 +00:00
Elliott Hughes
1a2f12d23e Move away from device.get_props.
Properties can include \n so get_props isn't sound, and it's not obvious how
to fix it (without adding something like cat's -v to getprop, which wouldn't
help the intended use case of working with arbitrary old devices).

Bug: https://issuetracker.google.com/37093233
Test: gdbclient -r /system/bin/date
Change-Id: I96042fd44f1de17974968954fab6c916a9d13b61
2017-06-02 13:15:59 -07:00
Treehugger Robot
3099f0c89d Merge "gdbrunner: take a run-as/su command instead of a user." 2017-05-31 00:35:47 +00:00
Josh Gao
057c2739fc gdbrunner: take a run-as/su command instead of a user.
Switch from assuming that "root" meant su to an explicit prepended
argument, to allow things like `gdbclient.py --user shell`.

Test: gdbclient.py --user shell -r /system/bin/ls
Change-Id: I9d02eea7c6d79898ed8b13817e009630b0f9536a
2017-05-24 18:32:25 -07:00
Christopher Ferris
f427655e47 Fix potential divide by zero.
If there are no bytes attributable to APP, then you get a divide
by zero. Modify the code to avoid doing a divide by zero.

This can happen when using logwrapper to enable malloc debug.

Test: Ran on a heap that had no APP bytest.
Change-Id: I48f0666a92b591e4537c493c56b136e517a36c25
2017-05-24 17:27:27 -07:00
Mathieu Chartier
ef15f7851f Merge "Script to view native allocations prettily." 2017-05-23 20:34:07 +00:00
Richard Uhler
a178732bcf Script to view native allocations prettily.
Usage:
1. Collect a native heap dump from the device. For example:
  $ adb shell stop
  $ adb shell setprop libc.debug.malloc.program app_process
  $ adb shell setprop libc.debug.malloc.options backtrace=64
  $ adb shell start
  (launch and use app)
  $ adb shell am dumpheap -n <pid> /data/local/tmp/native_heap.txt
  $ adb pull /data/local/tmp/native_heap.txt

2. Run the viewer:
$ python native_heapdump_viewer.py [options] native_heap.txt
  [--verbose]: verbose output
  [--html]: html output
  [--symbols SYMBOL_DIR]: SYMBOL_DIR is the directory containing the
  .so files with symbols. Defaults to $ANDROID_PRODUCT_OUT/symbols

This outputs a file with lines of the form:
5831776  29.09% 100.00%    10532     71b07bc0b0 /system/lib64/libandroid_runtime.so Typeface_createFromArray frameworks/base/core/jni/android/graphics/Typeface.cpp:68

5831776 is the total number of bytes allocated at this stack frame, which
is 29.09% of the total number of bytes allocated and 100.00% of the parent
frame's bytes allocated. 10532 is the total number of allocations at this
stack frame. 71b07bc0b0 is the address of the stack frame.

For generating interactive HTML output, use:
python native_heapdump_viewer.py --html [options] native_heap.txt > allocations.html
Then open allocations.html in a browser. Clicking on nodes will
expand the tree.

Test: Try script on an app following usage instructions.

Bug: 36457259
Change-Id: I18dfe9a00fc1d3e82673dbfb4b5be3dc10480cec
2017-05-23 10:23:29 -07:00
Andreas Gampe
46b00d66ac Stack: Add subprocess caching
Add subprocess caching to the stack tool. This caches open pipes for
commands, improving symbolization speed for (sets of) stack traces with
duplicated libraries.

Bug: 38226236
Test: m
Test: manual tests
Change-Id: Iadbd74255b9a40c86939be3a1b172275a0b34d54
2017-05-18 10:38:30 -07:00
Andreas Gampe
3d97a46124 Stack: Add symbol caching
Add symbol caching to the stack tool. This caches resolved symbols,
improving symbolization speed for (sets of) stack traces with duplicated
symbols.

Bug: 38226236
Test: m
Test: manual tests
Change-Id: Ia579234ba1bf227b12af0c5af5fa3955d0eed4fe
2017-05-17 15:14:07 -07:00
Keith Mok
e9549c1716 gdbclient: fix darwin sed problem
darwin does not takes \t for sed as tab.
Use [[:blank:]] instead

Change-Id: Ic6c08ceacf3918eb0da52a200c03e035c77a88ee
2017-01-25 21:06:21 -08:00
Christopher Ferris
5f1b4f0d9e Skip adding value lines for accidental matches.
If the value_line regex matches, and the symbol file happens to exist
as a directory, we'd call addr2line and crash. Fix this so that calling
addr2line on a directory doesn't happen.

There isn't an easy way to test this, but I added a single new unit test. The
real test was to use a tombstone file that used to crash, but no longer crashes.

Test: Wrote new unit test, ran over a tombstone file that used to crash.
Change-Id: I4331e3b032cee8d697d1b7f409638750c61971d6
2016-09-19 13:24:37 -07:00
Christopher Ferris
5b820ba6c9 Handle asan lines when determing abi.
Change-Id: I553bded15e76ecb1ffc7bc3eadcee198301e0a67
2016-09-09 10:54:45 -07:00
Treehugger Robot
784eace983 Merge "Stack: Fix tool for long stacks" 2016-07-27 00:36:57 +00:00
Colin Cross
1127df9e6f Stack: Fix libmemunreachable stack test
Manually count input stack trace lines that match the regexps instead of
relying on the output of addr2line.  Random changes to the libraries
listed in the test case could cause addr2line to land in an inlined
function and print multiple lines for each input stack frame.

Test: development/scripts/stack_core.py
Change-Id: I87f45466df4e814ec59a4c5f7e201fd1f3ee8419
2016-07-26 10:57:22 -07:00
Andreas Gampe
48068ac0b4 Stack: Fix tool for long stacks
To make the comparison meaningful, better compare integrals rather
than strings.

Test: ./stack_core.py
Change-Id: Ie24bea75d7c0bc57a1b7683b91e62fafead70341
2016-07-26 08:43:27 -07:00
Colin Cross
807ec0ec36 stack: support output from dumpsys meminfo --unreachable
Support unreachable memory reports in the form:

 Unreachable memory
  4307 bytes in 61 unreachable allocations
  ABI: 'arm64'

  112 bytes unreachable at 79352e38d0
   and 1904 similar unreachable bytes in 17 allocations
   first 32 bytes of contents:
   79352e38d0: 30 9c 83 52 79 00 00 00 00 00 00 00 00 00 00 00 0..Ry...........
   79352e38e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
          #00  pc 000000000006e218  /system/lib64/libc++.so (operator new(unsigned long)+36)
          #01  pc 000000000009171c  /system/lib64/libhwui.so
          #02  pc 0000000000093cc8  /system/lib64/libhwui.so (android::uirenderer::RecordingCanvas::drawText(unsigned short const*, float const*, int, SkPaint const&, float, float, float, float, float, float, float)+300)
          #03  pc 00000000000fbdd0  /system/lib64/libandroid_runtime.so (android::CanvasJNI::drawText(android::Canvas*, unsigned short const*, int, int, int, float, float, int, android::Paint const&, android::TypefaceImpl*)+2120)

Test: ./stack_core.py
Change-Id: I8075f3390f08972e57ec71f84dfe60adac110eed
2016-07-07 17:09:04 -07:00
Than McIntosh
6ae324144b Script to perform USB reset of Android device.
Given a serial number, applies correct ioctl()
to reset the USB device with that serial number.
Useful to avoid having to unplug/replug after
flashall + wipe of device.

Change-Id: I7402e1e53cabc19c423ef912a5dc7ade8221b08b
2016-04-12 14:25:27 -04:00
Christopher Ferris
abe22f4616 Fix how the script gets data from apks.
The previous code used unzip to get the offsets of the files in
the zip file. This was an estimate, and it turns out to be wrong
in many cases. Replace that with zipinfo -v which gives the exact
offset of the files in the zip.

Also update the tmp files so that they are in a dictionary of their
own by apk, instead of embedded in the offset list.

Change-Id: I8f5efd95f2d2e39e20cc0b6b6571b799be21ef32
2016-03-16 13:11:18 -07:00
Christopher Ferris
bf8a940234 Find abi before trying to decode the stack.
The CallStack function prints stacks to the log. Unfortunately, our
stack script defaults to arm, so if the data is actually arm64, we'll
do nothing. Modify the script to parse the input trying to determine
the abi before processing the rest of the lines. At the very least,
we'll be able to correctly choose between arm and arm64.

The only downside, is that, the old method could take dumps from different
abis, but no one I know does this.

Bug: 26569638
Change-Id: I5935b82fe0af1e788b0d3edc535b9f0cbb7d1b28
2016-03-15 16:25:19 -07:00
Alex Light
7c776a4fb3 Merge "Make gdbclient respect custom OUT_DIR settings" 2016-01-07 18:05:26 +00:00
Alex Light
35dd4d66b6 Make gdbclient respect custom OUT_DIR settings
Change-Id: Icb43798717f9b2aa6144f59624c2e3b7f59f42f8
2016-01-06 05:54:02 -08:00
Josh Gao
409ab9f212 Update gdbclient to use the multiarch gdb.
Bug: http://b/26224915
Change-Id: I9bfcc08e6c92c18f6c774ce7f9ad13c9b055fc68
2015-12-17 12:58:00 -08:00
Christopher Ferris
c14b612ba1 Modify the dso rule to allow spaces in [] names.
Some of the map names have spaces in them, but only the ones that look
like:

[anon:atexit handlers]

So allow spaces between a [ and a ].

Change-Id: I09f1b50533fcd2e79acda199dcc3fb99c6d8428f
2015-11-30 16:29:57 -08:00
Josh Gao
44b84a8e03 Don't throw when we fail to find a device.
Instead, set it to None and let the caller handle things.

Change-Id: Ic4f27fdb52ebd6bc5b4048e4e688ec7bd2509bfa
2015-10-28 14:21:59 -07:00
Josh Gao
66bb9fa2cd Merge "gdbclient.py: set directory for gdb." 2015-10-22 23:20:01 +00:00
Josh Gao
19f18ce06a gdbclient.py: set directory for gdb.
Make sure gdb knows where the source files are, even when gdbclient.py
isn't being run from the root directory.

Change-Id: I8f604ba58f4c06b26f2a1f8e917e2a1c1c137ccd
2015-10-22 16:19:02 -07:00
David Pursell
639d1c491a gdb: allow gdbclient.py to find local files.
gdbclient.py is always downloading the stripped version of executable
files from the device. This CL first tries to find the unstripped local
file before falling back to the stripped version.

Bug: http://b/24947939
Change-Id: I7a49d0d8b28590ee99ce892d3e3476921f4ae974
2015-10-21 10:25:25 -07:00
David Pursell
d1fe92f375 gdbclient.py: set PWD when querying makefiles.
Python's subprocess.check_output() cwd argument does not change the PWD
environmental variable, which is what dumpvar.mk uses to turn relative
paths into absolute paths. This led to incorrect symbol paths when
gdbclient was not run from the root directory.

This CL fixes the bug by manually setting PWD before calling the
makefile. It's possible that dumpvar.mk should be using a different
method to get the current directory, but I was scared to change any
core build logic and this approach seems to work just fine.

Change-Id: Ibe3db0bef6694934c512918f7562029313b1deae
2015-10-06 09:18:47 -07:00
David Pursell
320f881efe gdbclient.py: add gdb connect retry.
gdbclient.py can sometimes attempt to connect to the server before it's
ready, especially when debugging on an emulator. This CL adds
functionality to retry the connection for up to 5 seconds.

Bug: http://b/24671386
Change-Id: I65e77f918c3ea8433f992e67122cd48e3647c67b
2015-10-06 09:18:36 -07:00
Josh Gao
6382f1768a Make gdbclient.py work in directories other than the root.
Change-Id: I8e383052e15f41919c7107bf960092120d2c621c
2015-10-02 15:58:57 -07:00
Josh Gao
043bad746f Add python reimplementation of gdbclient.
Bug: http://b/23715403
Bug: http://b/22946322
Bug: http://b/22946705
Bug: http://b/22120411
Bug: http://b/22715953
Change-Id: I2391ec03be8d2487a4738455b6e934874c7f595f
2015-10-01 14:30:29 -07:00
Andreas Gampe
57acd5f7da Development/scripts: Update stack tool
The tool was broken for ASAN traces. Add a missing key to the
dictionary.

Bug: 24133462
Change-Id: I6e5b60441c9c602cd1381c1cb32947a1425c7069
2015-09-17 11:44:21 -07:00
Christopher Ferris
ece64c4bd5 Update the stack script for apk handling.
The dlopen of a shared library within an apk is not handled by
the stack tool. Modify to understand and search through the apk to
find the shared library associated with the offset. Then unzip
that shared library to use as the target of addr2line.

Change-Id: I404302f68dff45c35a1dc2a55547f42ea04f02bf
2015-09-04 10:51:22 -07:00
Andreas Gampe
d900d08d81 Development/scripts: Add sanitizer dump support to stack
Add trace parsing for sanitizer output. The output is different
from debuggerd output (and we do not have control over it). Use
two separate regexes and factor out the parsing into a method
returning a tuple of data.

Note: as we have no control over the prologue of the dump, we
cannot change it to include information like the ABI. Thus, this
functionality only works in a lunched tree, where the tool
implicitly uses the symbols directory.

Change-Id: Ic1189f4f65cf7728d1baec7055ecb549b0aa5f62
2015-08-21 17:29:47 -07:00
Elliott Hughes
ef3f1e2c1a Warn if you're trying to use gdbclient without "adb root".
Bug: http://b/22715953
Change-Id: If729fbc89ccd65407e8900bc27df8fa4174dd64e
2015-07-24 10:32:07 -07:00
Nikola Veljkovic
4efdec68b0 Fix gdbclient to work with emulator builds
gdbclient got broken by:
https://android-review.googlesource.com/156974

To fix, check for special case when device is actually an emulator,
and set the $DEVICE variable accordingly.

Change-Id: I85d0d520ae1e2ea022aa3e2d08a10cd0b1cb491f
2015-07-09 12:05:13 +02:00
Dmitriy Ivanov
91dcbe968b Use ro.hardware property to detect the device
Bug: http://b/22120411
Change-Id: Ida9bc157b560edbe8c2db67f5df5109c192fef9d
2015-06-29 11:27:30 -07:00
Andreas Gampe
172283617b Merge "Development: change gdbclient GDB selection" 2015-06-02 00:08:29 +00:00
Andreas Gampe
876b092025 Development: change gdbclient GDB selection
Mips now uses the 64-bit version in general. Also simplify the x86
selection.

Bug: 21467410
Bug: 21555893
Change-Id: If0477356d3c3dbf9e0dfbfcabcb098dc7b8aeba2
2015-06-01 15:57:25 -07:00
Andreas Gampe
820ca728db Development: Mips64 stack-core test
Add a test for Mips64 stack-core.

Bug: 21555893
Change-Id: I2d6feba9bde3977cabc5e771bf14c55de1fbff53
2015-06-01 15:43:52 -07:00
Andreas Gampe
7d4a83600f Merge "Add mips64 to stack tool" 2015-05-26 16:59:37 +00:00
Andreas Gampe
5521841a42 Add mips64 to stack tool
Add register definitions to stack_core.

Change-Id: I2d9d2ae075efe8d8c92fac387d2ae30f9cbb999c
2015-05-21 14:56:40 -07:00
Christopher Ferris
8981aee6a9 Add a conditional removal of \r\n from adb output.
Bug: 21338668
Change-Id: Iea8804c462f3bd1e5cc24c8f6d12e41b09a15d53
2015-05-20 19:36:54 -07:00
Brian Carlstrom
73cd247e45 Delete dbt command for dalvik
Change-Id: I177097f65a5b70d12f758c118710efca07c2a0a2
2015-05-18 08:42:58 -07:00
Dan Albert
f1d27e2c9a Allow acov --prep to succeed in a clean build.
Change-Id: I8f72da827d660f9aad051738a8287463dccd0619
2015-04-14 13:46:57 -07:00