Commit Graph

31 Commits

Author SHA1 Message Date
Krzysztof Kosiński
b136111f17 Upgrade the 'stack' script to python3.
Also hook up the test to Android.bp.

Test: unit test
Test: Ran with a tombstone file as parameter.
Test: Ran pasting in stack to stdin.
Change-Id: I25f40569cc49b7487553611bcc25d061179bfa8d
2021-04-09 13:21:32 -07:00
Krzysztof Kosiński
dd45e18f94 Make the "stack" script work for device tests.
The path where the tests are uploaded by atest differs from the
path to unstripped binaries in the out directory. As a result,
the script can't symbolize the parts of the stack trace that
correspond to code in the test binary. Add a fixup to use the
correct path.

Test: Used the script on example crashes in framework and vendor
device tests - appears to work and give correct line numbers.

Change-Id: I5470e6342afb801ac596cbc0c0bf067850b1e09a
2021-03-11 18:09:15 -08:00
Christopher Ferris
49eda0e908 Remove gcc tools from script.
Replace all references to gcc tools with llvm tools. This change still
uses c++filt until llvm-cxxfilt is put in the prebuilts.

Test: Ran a backtrace through this script and the old script and verified
Test: no major differences.
Test: Ran unittests for symbol.py and stack_core.py.
Change-Id: Ic31c1a0707dae11c5037f9637943cd7932badf46
2020-12-09 14:34:01 -08:00
Christopher Ferris
5e4b37213d Add support for xxx.so!xxx.so lines.
When seeing a line like:
  #01 pc 0012ea14  /system/lib/libart.so!libart.so (offset 0x134000)

Treat it like this line instead:
  #01 pc 0012ea14  /system/lib/libart.so

This will allow the symbolizer to properly figure out the line numbers.

Bug: 148657674

Test: Ran lines with xxx.so!xxx.so lines and verified that they decode.
Change-Id: Ieea516b46a00b414c740d0b4302a5cc73da2b0a8
2020-01-31 14:38:07 -08:00
Christopher Ferris
ac90d1da7e Really fix support for soname in apk.
Bug: 29218999

Test: Run a stack through vendor/google/tools/stack --auto with this change.
Change-Id: I0d650f30d37bb0dfa9db011d7624c0c74a98f2df
2019-03-15 12:21:57 -07:00
Christopher Ferris
55a9699db3 Add support for soname display in apk.
Bug: 29218999

Test: Verified unwind through an apk works with both formats.
Change-Id: I20dba918e94024902968ab320dc03e1e343d8a31
2019-03-13 17:08:40 -07: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
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
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
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
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
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
5521841a42 Add mips64 to stack tool
Add register definitions to stack_core.

Change-Id: I2d9d2ae075efe8d8c92fac387d2ae30f9cbb999c
2015-05-21 14:56:40 -07:00
Elliott Hughes
c3c8619579 Make 'stack' able to find toolchains regardless of lunch.
This is needed by the internal stack decoding website, which
will be pulling symbols from the build servers anyway (so doesn't
need to be correctly lunched).

Bug: 16734486
Change-Id: I9190065148c0d4bb4eacec28bcc062fa95798917
2014-08-29 13:49:57 -07:00
Brigid Smith
15142f793a Stack tool 32/64 bit compatibility fixes.
Left the default symbol.ARCH value intact and changed stack_core instead
so that it will assume the ABI is arm until it sees an ABI line.  This
allows compatibility for people who are used to pasting portions of a
tombstone instead of the whole thing (assuming said tombstone is arm)
while additionally supporting other architectures if a whole tombstone
  is pasted in.

Change-Id: Ib8b5754920d2e2aa5017c29daeca59abcf4b547d
2014-07-16 15:56:46 -07:00
Elliott Hughes
be4de46d09 Add the arm64 pstate register to the stack tool.
Also take into account the fact that the arm pcsr register is the
fifth entry on its line, so the stack tool previously stripped that
off.

Change-Id: I1dd2d11060e572b4d8ffd8710cf1df4d970671e4
2014-07-14 17:16:30 -07:00
Elliott Hughes
c3166bec1c Fix symbol.py's toolchain detection for x86.
x86 uses the x86_64 toolchain. There's no separate 32-bit toolchain.

I started to refactor so we could add FindToolchain tests, but that doesn't
work because FindToolchain depends on environment variables set up by 'lunch'.

Change-Id: I264b95e1e83a7e795f8cac49bc9e1cf497514029
2014-07-07 15:18:01 -07:00
Brigid Smith
9c2192a26e stack_core ProcessLine now returns a boolean.
The value corresponds to whether or not the line has matched one of the
detected formats (registers, header, backtrace, etc.) and can be used to
identify what logcat lines don't correspond to one of these formats.

Change-Id: Ibd7bc5a211dcfe86ea2f92d7e7941091afff4fc4
2014-07-07 14:53:18 -07:00
Brigid Smith
0b30940003 stack_core now also detects the "Revision: #" line.
Change-Id: I474602eca37964e412acf8cb5f2441cd223852e4
2014-07-07 14:34:00 -07:00
Elliott Hughes
a9e34173b9 Fix 'stack' register matching for all architectures.
Every architecture was at least slightly wrong. Rather than try to
tune the heuristics, let's just keep lists of all the registers.

Also start adding some unit tests.

Change-Id: I490dcc9855f7af1e3529734711400f366ffc4e0f
2014-07-01 14:56:22 -07:00
Brigid Smith
ea0a835d4d Turning stack_core into a class to make it compatible with adbs.
This includes the fairly large change of refactoring stack_core.py into
a class so that its behavior is compatible with adbs.  Additionally, if
the ABI line does not come before lines that require it to determine
proper widths (registers, stack), then it will assume that the ABI is
32 bit and not 64.

Change-Id: I6ad84a55337d86d25f7f8197048dc93868b0a01a
2014-07-01 11:25:44 -07:00
Elliott Hughes
d2471c871f Add the "Abort message:" line to the preserved stack output.
When QA paste a stack in to the decoder, we don't want to lose the
abort message.

Bug: 15701333
Change-Id: I538aab6b5cb6c20534b1b7027aec32bd78ee060c
2014-06-17 16:55:10 -07:00
Brigid Smith
45a46c6138 Updating stack_core.py to recognize new ABI output from debuggerd.
Change-Id: Ib9736a0509edb97be15f5e89dbc3a5188e744416
2014-06-13 17:43:38 -07:00
Narayan Kamath
9649700787 Fix the stack/ tool for 64 bit archs.
pc values might now be 16 bytes wide. Also add support
for the arm64 architecture switch.

Change-Id: Ia2e0282f3bee03ef6092de285b0c32fa6da07cb0
2014-04-14 11:07:37 +01:00
Ben Cheng
b42dad0dee Clean up the stack trace symbolization tool.
Change-Id: Id71cacde653a5c1c92a028ee80f5aa8264e1963a
2013-04-25 15:34:14 -07:00