Skip to content

Commit badb6e2

Browse files
committed
[lldb/crashlog] Fix scripted_crashlog_json.test failure
This patch should fix the test failure on scripted_crashlog_json.test. The failure is happening because crash reporter will obfuscate the executable path in the crashlog, if it is located inside the user's home directory and replace it with `/USER/*/` as a placeholder. To fix that, we can patch the placeholder with the executable path before loading the crashlog in lldb. This also fixes a bug where we would create another target when loading the crashlog in a scripted process, even if lldb already had a target for it. Now, crashlog will only create a target if there is none in lldb. Differential Revision: https://reviews.llvm.org/D120598 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent cb1654e commit badb6e2

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lldb/examples/python/crashlog.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,10 @@ def load_crashlog_in_scripted_process(debugger, crash_log_file):
989989
result.PutCString("error: python exception: %s" % e)
990990
return
991991

992-
target = crashlog.create_target()
992+
if debugger.GetNumTargets() > 0:
993+
target = debugger.GetTargetAtIndex(0)
994+
else:
995+
target = crashlog.create_target()
993996
if not target:
994997
result.PutCString("error: couldn't create target")
995998
return

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
2222
"pid" : 72932,
2323
"cpuType" : "X86-64",
24-
"procName" : "json.test.tmp.out",
25-
"procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
24+
"procName" : "@NAME@",
25+
"procPath" : "@EXEC@",
2626
"parentProc" : "fish",
2727
"parentPid" : 67002,
2828
"coalitionName" : "io.alacritty",

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/scripted_crashlog.ips

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"procExitAbsTime" : 6478056175721,
2222
"translated" : false,
2323
"cpuType" : "ARM-64",
24-
"procName" : "scripted_crashlog_json.test.tmp.out",
25-
"procPath" : "\/Users\/USER\/*\/scripted_crashlog_json.test.tmp.out",
24+
"procName" : "@NAME@",
25+
"procPath" : "@EXEC@",
2626
"parentProc" : "zsh",
2727
"parentPid" : 82132,
2828
"coalitionName" : "com.apple.Terminal",
@@ -47,8 +47,9 @@
4747
"base" : 4372692992,
4848
"size" : 16384,
4949
"uuid" : "b928ee77-9429-334f-ac88-41440bb3d4c7",
50-
"path" : "\/Users\/USER\/*\/scripted_crashlog_json.test.tmp.out",
51-
"name" : "scripted_crashlog_json.test.tmp.out"
50+
"uuid" : "@UUID@",
51+
"path" : "@EXEC@",
52+
"name" : "@NAME@"
5253
},
5354
{
5455
"source" : "P",

0 commit comments

Comments
 (0)