Commit 807ec0ec authored by Colin Cross's avatar Colin Cross
Browse files

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
parent 59a4978c
......@@ -185,3 +185,17 @@ backtrace:
#07 pc 000000000001d3eb /system/lib64/libc.so (__start_thread+11)
#08 pc 00000000000138f5 /system/lib64/libc.so (__bionic_clone+53)
"""
libmemunreachable = """
Unreachable memory
48 bytes in 2 unreachable allocations
ABI: 'arm'
24 bytes unreachable at a11e6748
and 24 similar unreachable bytes in 1 allocation
contents:
a11e6748: 63 6f 6d 2e 61 6e 64 72 6f 69 64 2e 73 79 73 74 com.android.syst
a11e6758: 65 6d 75 69 00 00 00 00 emui....
#00 pc 000076ae /system/lib/libcutils.so (set_process_name+45)
#01 pc 000989d6 /system/lib/libandroid_runtime.so (android_os_Process_setArgV0(_JNIEnv*, _jobject*, _jstring*)+125)
"""
......@@ -47,6 +47,10 @@ class TraceConverter:
zipinfo_central_info_match = re.compile(
"^\s*(\S+)$\s*offset of local header from start of archive:\s*(\d+)"
".*^\s*compressed size:\s+(\d+)", re.M | re.S)
unreachable_line = re.compile("((\d+ bytes in \d+ unreachable allocations)|"+\
"(\d+ bytes unreachable at [0-9a-f]+)|"+\
"(referencing \d+ unreachable bytes in \d+ allocation(s)?)|"+\
"(and \d+ similar unreachable bytes in \d+ allocation(s)?))")
trace_lines = []
value_lines = []
last_frame = -1
......@@ -306,8 +310,11 @@ class TraceConverter:
revision_header = self.revision_line.search(line)
dalvik_jni_thread_header = self.dalvik_jni_thread_line.search(line)
dalvik_native_thread_header = self.dalvik_native_thread_line.search(line)
unreachable_header = self.unreachable_line.search(line)
if process_header or signal_header or abort_message_header or thread_header or \
register_header or dalvik_jni_thread_header or dalvik_native_thread_header or revision_header:
register_header or dalvik_jni_thread_header or dalvik_native_thread_header or \
revision_header or unreachable_header:
ret = True
if self.trace_lines or self.value_lines:
self.PrintOutput(self.trace_lines, self.value_lines)
self.PrintDivider()
......@@ -330,6 +337,8 @@ class TraceConverter:
print dalvik_native_thread_header.group(1)
if revision_header:
print revision_header.group(1)
if unreachable_header:
print unreachable_header.group(1)
return True
trace_line_dict = self.MatchTraceLine(line)
if trace_line_dict is not None:
......@@ -448,6 +457,24 @@ class RegisterPatternTests(unittest.TestCase):
def test_x86_64_registers(self):
self.assert_register_matches("x86_64", example_crashes.x86_64, '\\b(rax|rsi|r8|r12|cs|rip)\\b')
class LibmemunreachablePatternTests(unittest.TestCase):
def test_libmemunreachable(self):
tc = TraceConverter()
lines = example_crashes.libmemunreachable.split('\n')
symbol.SetAbi(lines)
self.assertEquals(symbol.ARCH, "arm")
tc.UpdateAbiRegexes()
header_lines = 0
for line in lines:
tc.ProcessLine(line)
if re.search(tc.unreachable_line, line) is not None:
header_lines += 1
self.assertEquals(header_lines, 3)
self.assertEquals(len(tc.trace_lines), 2)
tc.PrintOutput(tc.trace_lines, tc.value_lines)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment