aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Python/Crashlog
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2021-10-05 12:12:04 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2021-10-05 12:15:54 -0700
commit730fca46fc87dad09040cb0b27ede10ae2c7c9d7 (patch)
treea3223ad42bc43e581a79a85275cac4b976413b9e /lldb/test/Shell/ScriptInterpreter/Python/Crashlog
parentf92961d238efdfeccce27f9bb7b0a6629c376d4a (diff)
downloadllvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.zip
llvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.tar.gz
llvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.tar.bz2
[lldb] Improve meta data stripping from JSON crashlogs
JSON crashlogs normally start with a single line of meta data that we strip unconditionally. Some producers started omitting the meta data which tripped up crashlog. Be more resilient by only removing the first line when we know it really is meta data. rdar://82641662
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Python/Crashlog')
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test5
-rw-r--r--lldb/test/Shell/ScriptInterpreter/Python/Crashlog/patch-crashlog.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
index a514b07..0c522e9 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -1,8 +1,13 @@
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
+
# RUN: cp %S/Inputs/a.out.ips %t.crash
# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
+# RUN: cp %S/Inputs/a.out.ips %t.nometadata.crash
+# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.nometadata.crash --offsets '{"main":20, "bar":9, "foo":16}' --json --no-metadata
+# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.nometadata.crash' 2>&1 | FileCheck %s
+
# CHECK: Thread[0] Crashing Thread Name EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/patch-crashlog.py b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/patch-crashlog.py
index 28396c5..56558bc 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/patch-crashlog.py
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/patch-crashlog.py
@@ -49,6 +49,9 @@ class CrashLogPatcher:
self.data = self.data.replace(
"@{}@".format(symbol), str(representation(patch_addr)))
+ def remove_metadata(self):
+ self.data= self.data[self.data.index('\n') + 1:]
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Crashlog Patcher')
@@ -56,6 +59,7 @@ if __name__ == '__main__':
parser.add_argument('--crashlog', required=True)
parser.add_argument('--offsets', required=True)
parser.add_argument('--json', default=False, action='store_true')
+ parser.add_argument('--no-metadata', default=False, action='store_true')
args = parser.parse_args()
offsets = json.loads(args.offsets)
@@ -68,5 +72,8 @@ if __name__ == '__main__':
p.patch_uuid()
p.patch_addresses()
+ if args.no_metadata:
+ p.remove_metadata()
+
with open(args.crashlog, 'w') as file:
file.write(p.data)