Commit Graph

227 Commits

Author SHA1 Message Date
Christopher Ferris
ad7d5fb378 Detect if num field is valid on v1.0 version.
In Android P, the version field did not get incremented properly in
all places. So if a file with a v1.0 version is found, do a further check
to verify if the num field is really valid.

Test: Verified that a file with v1.0 gets checked and the valid num field
Test: is set correctly.
Test: Verified that a file with v1.1 automatically gets num field set to
Test: valid.
Change-Id: I7f828294c833e334cad76a866bbaa1d78ac02cfb
Merged-In: I7f828294c833e334cad76a866bbaa1d78ac02cfb
(cherry picked from commit b558fe4d53)
2018-07-10 12:25:33 -07:00
Dan Albert
d124bc7562 Allow restart in gdbclient.
Switching from remote to extended-remote allows the program being
debugged to be restarted like a normal non-remote program.

Test: Used gdbclient debugging ICU things for a while, restarted often
Bug: None
Change-Id: Ia295749b9aa86727479d760d7c743f98a06fa6d4
2018-06-26 11:15:16 -07:00
Treehugger Robot
759a6f75ff Merge changes from topic "stacks_envsetup"
* changes:
  stacks: match exactly before matching nonexactly.
  Add return code support to `pid`.
  Move pid, stacks from envsetup.sh to dedicated scripts.
2018-06-15 15:43:37 +00:00
Josh Gao
91ba53c4b9 stacks: match exactly before matching nonexactly.
`pid zygote` will match zygote64 as well, but someone using `stacks
zygote` clearly wants the 32-bit version. Attempt an exact match before
we try a nonexact one.

Test: stacks zygote
Test: stacks zygote64
Change-Id: I5fd75cdbe4982c7ea831749c9ba823a2451e5490
2018-06-14 16:36:12 -07:00
Josh Gao
4df6279c71 Add return code support to pid.
Test: pid nonexistent; echo $?
Test: pid --exact nonexistent; echo $?
Change-Id: If8efb1ca27ae3ed7b5be1c51179fae387c56e305
2018-06-14 16:36:12 -07:00
Josh Gao
3dffb8438d Move pid, stacks from envsetup.sh to dedicated scripts.
Make it so that these can be used in other scripts by moving them from
functions defined in envsetup.sh to standalone scripts.

Test: stacks zygote64
Change-Id: I55ba76b248c54d9193fb019b7f4aca2f4c3a05bd
2018-06-14 16:36:12 -07:00
Andreas Gampe
64676442d4 Script: Fix disassemble_tombstone.py
Update for newer debuggerd output marking the memory dump around
the currently executed code.

Add a hack for ARM assembly: override the assembler-emitted $d
symbol marking all our .byte data, so that objdump will disassemble
as instructions.

Test: manual
Change-Id: I100ed9e0ce39c073d5885cc430d78c24fef38882
2018-06-13 14:32:54 -07:00
Christopher Ferris
fbd84e9255 Add descriptive text describing html interaction.
Test: Ran and verified html output is viewable.
Change-Id: I54771bc9b536ff8fbc62dc7e5aac2caa22765e30
2018-06-05 08:46:23 -07:00
Christopher Ferris
bede9f3b3c Handle num fields that aren't one.
The new version of malloc debug supports using a num field that is more
than one. Modify the parser to handle this case.

Bug: 74361929

Test: Ran on a file that contained non-one numbers and verified the output.
Change-Id: I158922e51ce99afff88f20a80df414d653f95e65
2018-05-22 19:02:41 -07:00
Andreas Gampe
5bec21433e Scripts: Export symbol.py
Export symbol.py in a python host library called python-symbol.

Bug: 73175642
Test: m
Change-Id: I9503efd339b69f0655db6a3a5cf04a94dac72489
2018-05-09 15:11:06 -07:00
Elliott Hughes
70b4c54934 Add scripts OWNERS.
Bug: N/A
Test: N/A
Change-Id: I54cfaff7b8f94475692b62394e8da3d866308509
2017-12-14 13:19:30 -08:00
Dan Willemsen
d3fc8faff6 Switch to new soong_ui dumpvar-mode
Stop using make directly.

Test: manual tests
Test: development/scripts/symbol.py
Change-Id: I9f75776251b693dbe979989942d2db49768224d2
2017-10-17 14:10:51 -07:00
Josh Gao
bc82e81e21 Merge "gdbclient.py: don't use make to dump target info."
am: c57aaaf57c

Change-Id: I15177dbcb47333fd2b9b8a713bc3a5a2c1991f09
2017-08-09 21:33:11 +00:00
Treehugger Robot
c57aaaf57c Merge "gdbclient.py: don't use make to dump target info." 2017-08-09 21:18:04 +00:00
Greg Hartman
8697036e17 Merge "Provide a way to disassemble code in a tombstone."
am: d98a584a6d

Change-Id: Ia8c1ae3cb29bab9a147f5d05aa54d50e745eb96a
2017-07-21 02:04:08 +00:00
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
Josh Gao
466e289dc8 gdbclient.py: don't use make to dump target info.
make dumpvar takes forever (~0.45s per variable on my machine), and the
information we want from it is already available in the environment.
Construct the paths we need ourselves, instead of relying on make to do
it for us, shaving off about a second from a gdbclient.py invocation.

Test: gdbclient.py -r ls
Change-Id: I8c563da726c8f61a23e2eb701f2f272a4c71d713
2017-07-13 15:42:48 -07:00
Kevin Rocard
aef6b1d246 Merge "Resolve gdbclient.py -r executable from target"
am: f45395cec0

Change-Id: I7f38016c99f748f4641cedbbaa045a547db7f8f4
2017-07-13 18:44:42 +00: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
82a266c27b Merge "Fix gdbclient.py -p."
am: 37c32c3162

Change-Id: I051679423bdff53539c4455faa5d73fed2d4c0a8
2017-06-30 23:29:09 +00: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
cd0f76d772 Merge "Warn that gdbclient is deprecated in favor of gdbclient.py" am: 4a419534fe
am: b23457b4be

Change-Id: Ie7c06875fb8edd37c8a11c14a11bff63f3c28511
2017-06-22 17:19:03 +00: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
acf1fb1c63 Merge "Fix potential divide by zero in display_html" am: 524311b26d
am: 41e721028a

Change-Id: Iac24401f1c8370f80824b56d63dffebd36081f13
2017-06-13 20:06:45 +00: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
14a8c9175b Merge "Fix potential divide by zero." am: 8d3f61724d
am: 4642158940

Change-Id: Ie3fe2c70a0cc3713cb47c78a10c020e29c42e42f
2017-06-09 22:24:29 +00:00
Christopher Ferris
8d3f61724d Merge "Fix potential divide by zero." 2017-06-09 22:12:22 +00:00
Elliott Hughes
c739b9e711 Merge "Move away from device.get_props." am: 904e475fbd am: 4d8dffffa6
am: 8c19ebd28d

Change-Id: I328be35af1e211412b105345b3d1ca78d24b7528
2017-06-03 01:43:58 +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
Josh Gao
8ce1c18ba8 Merge "gdbrunner: take a run-as/su command instead of a user." am: 3099f0c89d am: 83c5325987
am: 3aa3d5814e

Change-Id: Ib2538d9c996958228ceb6359994035789a507b02
2017-05-31 00:49:44 +00: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
e81fe437e3 Merge "Script to view native allocations prettily." am: ef15f7851f am: 17e01f282d
am: 4838d5f12b

Change-Id: I8eefe00e4806027a87f0bd0e06ebcdcd4add874a
2017-05-23 21:02:35 +00: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
15dff040ca Merge "Stack: Add subprocess caching" am: a1b14a7357 am: db19bc4e39
am: 6500b6e163

Change-Id: If163fa03e2d9bec003e57a88fbac3cd45781c843
2017-05-18 21:01:21 +00: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
a031d64eb9 Merge "Stack: Add symbol caching" am: b60fce019d am: 698998afca
am: eace70430e

Change-Id: Ib567614af9ddff4e358a8661b55f5aed016ea754
2017-05-18 16:52:34 +00: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
Po-Chien Hsueh
748f1a11ff Merge "Count framework usage of BOARD variables" 2017-02-09 02:51:50 +00:00
Po-Chien Hsueh
f86af51d2f Count framework usage of BOARD variables
This script analyses variables defined in BoardConfig*.mk and used
by framework modules.

Bug: 33122247
Test: run the script and check output
Change-Id: Ice533b4d59775eab1660214933393fb987786fdc
Signed-off-by: Po-Chien Hsueh <pchsueh@google.com>
2017-02-07 11:49:35 +08: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