File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
test/Shell/ScriptInterpreter/Python/Crashlog Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -415,8 +415,14 @@ def parse(self):
415
415
with open (self .path , 'r' ) as f :
416
416
buffer = f .read ()
417
417
418
- # First line is meta-data.
419
- buffer = buffer [buffer .index ('\n ' ) + 1 :]
418
+ # Skip the first line if it contains meta data.
419
+ head , _ , tail = buffer .partition ('\n ' )
420
+ try :
421
+ metadata = json .loads (head )
422
+ if 'app_name' in metadata and 'app_version' in metadata :
423
+ buffer = tail
424
+ except ValueError :
425
+ pass
420
426
421
427
try :
422
428
self .data = json .loads (buffer )
Original file line number Diff line number Diff line change 1
1
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
2
+
2
3
# RUN: cp %S/Inputs/a.out.ips %t.crash
3
4
# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
4
5
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
5
6
7
+ # RUN: cp %S/Inputs/a.out.ips %t.nometadata.crash
8
+ # RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.nometadata.crash --offsets '{"main":20, "bar":9, "foo":16}' --json --no-metadata
9
+ # RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.nometadata.crash' 2>&1 | FileCheck %s
10
+
6
11
# CHECK: Thread[0] Crashing Thread Name EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x0000000000000000)
7
12
# CHECK: [ 0] {{.*}}out`foo + 16 at test.c
8
13
# CHECK: [ 1] {{.*}}out`bar + 8 at test.c
Original file line number Diff line number Diff line change @@ -49,13 +49,17 @@ def patch_addresses(self):
49
49
self .data = self .data .replace (
50
50
"@{}@" .format (symbol ), str (representation (patch_addr )))
51
51
52
+ def remove_metadata (self ):
53
+ self .data = self .data [self .data .index ('\n ' ) + 1 :]
54
+
52
55
53
56
if __name__ == '__main__' :
54
57
parser = argparse .ArgumentParser (description = 'Crashlog Patcher' )
55
58
parser .add_argument ('--binary' , required = True )
56
59
parser .add_argument ('--crashlog' , required = True )
57
60
parser .add_argument ('--offsets' , required = True )
58
61
parser .add_argument ('--json' , default = False , action = 'store_true' )
62
+ parser .add_argument ('--no-metadata' , default = False , action = 'store_true' )
59
63
args = parser .parse_args ()
60
64
61
65
offsets = json .loads (args .offsets )
@@ -68,5 +72,8 @@ def patch_addresses(self):
68
72
p .patch_uuid ()
69
73
p .patch_addresses ()
70
74
75
+ if args .no_metadata :
76
+ p .remove_metadata ()
77
+
71
78
with open (args .crashlog , 'w' ) as file :
72
79
file .write (p .data )
You can’t perform that action at this time.
0 commit comments