Commit Graph

45 Commits

Author SHA1 Message Date
Christopher Ferris
a47d6d090f Add missing changes from ARCH removal.
I somehow didn't upload these fixes from the review. So doing that
now.

Test: Unit tests pass.
Change-Id: Ia17e480eb972db4f7be6947c0e6567632c65431f
2023-03-13 15:22:47 -07:00
Christopher Ferris
f62a3be63d Remove all ARCH references.
Replaced with ARCH_IS_32BIT since that's the only thing truly
necessary to work.

This also makes the register regex much more lenient, but it appears
to be strict enough that it doesn't seem to capture arbitrary lines
when run through logcat.

Removed the StripPC function and verified that an arm crash that
ends in 1 still works.

Removed the architecture.py script, it is old and I don't see anyone
using it.

Modify the reading of the lines to ignore any errors in the input.

Test: All unit tests pass.
Test: Symbolized arm and arm64 tombstones
Test: Symbolized x86 and x86_64 tombstones
Test: Ran through a logcat and verified it caught the bug but
Test: didn't print any extra information.
Change-Id: I6a65ecaad68da1d56864db32ff434512e4df0d89
2023-03-09 18:44:59 -08:00
Elliott Hughes
c94cb65f21 Remove mips.
We aren't going to support riscv32, so we won't even need to reuse any
of this.

Test: treehugger
Change-Id: I80d6285ecbd0dfdeeb496be39ba63e06cbb30acd
2023-03-09 00:36:31 +00:00
Prashanth Swaminathan
01fd4185b1 Support riscv64 in stack tool, remove mips64
Test: atest python-stack_core_test
Test: Manual validation against a crash stack on aosp_riscv64.
Change-Id: Ifc3646486fda9120c30c987f9623e134d3491a9a
2023-03-08 13:21:47 -08:00
Christopher Ferris
e6e02b0e22 Only add files in GlobSymbolsDir.
I previously skipped directories, but that can still lead to problems.
So instead, only add paths that are files.

Test: Ran over a stack that failed when trying to run llvm-readelf
Test: on a directory. After this fix, everything get line numbers.
Change-Id: Ide39c5a118d78a822057cc3977d0f532595f798b
2022-11-08 17:47:37 -08:00
Christopher Ferris
29fcc84e82 Fix build id check for libraries.
The current build id check uses the file utility. Unfortunately, it
doesn't work on all systems. Replace with a call to llvm-readelf and
get the bitness and build id using that data.

Other small modifications:
- Only attempt to get the full path for a library once for each library.
- Do not add directories into the symbol libraries.

Test: Unit tests pass.
Test: Running using a libart.so that file doesn't understand and
Test: verifying the line numbers are correct.
Change-Id: I12c3d3c4599d201c3c01feeb48448fee6c633d71
2022-11-02 17:55:57 -07:00
Christopher Ferris
7d4d527a1c Modify any lines with libc.so!libc.so to libc.so.
I had made this change if there was an offset on the line,
but I didn't make if there is no offset present. Add the
no offset present case.

Bug: 206463081

Test: Ran unit tests.
Test: Modified a normal stack line with libart.so to be
Test: libart.so!libart.so and verified the line numbers
Test: are still present.
Change-Id: I75e3fbe5eaa3a5419a2dca2c4542731c61c7b971
2022-05-05 15:14:01 -07:00
Christopher Ferris
598cc3607b Allow fixup of apex directories.
For some reason, apex directory structure in the symbols directory
is not the same as on device.

This means that a directory on device like:

  /apex/com.android.art/lib64/libart.so

Is really found in symbols as:

  /apex/com.google.android.art/lib64/libart.so

Modify the script to look in both places for libraries.

Bug: 206463081

Test: Verified that libart.so in a backtrace now finds the symbols
Test: libart.so.
Change-Id: I67610e3a236765cc92397c70a769c4aa705f13ce
2022-04-22 14:37:56 -07:00
Christopher Ferris
27bee5adfa Fix exception when path not found.
Add a default return value in a call in the GetLibraryByBuildId()
function to avoid an exception if a file cannot be found in the
symbol directory.

Bug: 216232380

Test: Ran the input from the bug. Verified without the change, the
Test: exception occurs and with the fix, no exception.
Test: Ran unit tests of stack_core.py.
Change-Id: I015982eb835f5a3d7f03dcc3e0b1627b0c1a7cfe
2022-01-25 13:10:24 -08:00
David Srbecky
80547ae39d Remove parameters from symbolized stack traces.
The expanded parameters take a lot horizontal space
and almost always push the file:line of the screen,
or text-wrap generating multiple lines per frame.

This CL tries to make the output less cluttered by
removing parameters from the unmangled method names.

It is possible to add the parameters back using
the --verbose command line argument.

Test: Add unit tests, investigate crashes from logcat
Change-Id: I42d1e26dbc2fa9db8b7bd95ce449cb2bd93f93f8
2021-12-23 14:09:11 +00:00
David Srbecky
df6d482c25 Stack symbolization: Replace functools.cache
Use lru_cache(maxsize=None) instead which is equivalent,
and is available on older python versions as well.

Also fix a bug where null "lib" variable was dereferenced.

Bug: 204507951
Bug: 171980804
Test: Run script with python3.7
Change-Id: I922ee48451ad3c60c2237fb0554e1838c1bf81af
2021-10-29 10:45:23 +00:00
David Srbecky
3a3349eeeb Try to locate symbols using build-id.
If the parsed backtrace has ELF build-ids, use them to
brute-force search for files in the symbols directory.

The search only considers files with the same basename,
so the number of candidates to check is very small.

This fixes issues when compile time directory does not
match the runtime directory on device (e.g. for apex).

Bug: 171980804
Test: ART crashes can be symbolized again
Change-Id: I0311a10c1e2eab92ee44f1b32c523d4763a54ee1
2021-10-28 22:53:46 +01:00
Christopher Ferris
7ea56f02c8 Small script fixes.
Fix a problem with python3 and the zipinfo processing of an apk.

Add sorting of the zipinfo data since it's not guaranteed that
the zip entries will be in sorted order, so sort them.

Bug: https://github.com/android/ndk/issues/1587

Test: Ran a apk stack line through the script.
Test: Ran the stack core unit tests.
Change-Id: Ie5ea67ad54a6b2de077e53740c82265f6bf783c6
2021-10-21 00:35:13 +00:00
Christopher Ferris
1f2051de9a Modify the library fix up code.
Modify the library lookup code to try and find the various places
that a library might really exist in the symbols directory. This
is for atest which can run executables in different locations
than the actual where the symbolized file exists.

Test: Ran using /data/local/tmp, /data/local/tests,
Test: /data/local/tests/vendor, /data/local/tests/unrestricted and
Test: verified the correct library was found.
Test: Used tombstones crash data and verified all libraries
Test: still found properly.
Test: Ran atest CtsBionicTestCases and verified the symbolized
Test: binary could be found using a real tombstone crash.
Test: Did the same as above, but changed the path in the tombstone
Test: crash data from /data/local/tmp to /data/local/tests and
Test: /data/local/tests/unrestricted.
Change-Id: Iaa121823ef6142eaf9f7de3232b147bd7389bea5
2021-09-10 15:28:51 -07:00
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