diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -1017,6 +1017,28 @@ error = lldb.SBError() process = target.Launch(launch_info, error) + if not process or error.Fail(): + return + + async_state = debugger.GetAsync() + debugger.SetAsync(False) + + run_options = lldb.SBCommandInterpreterRunOptions() + run_options.SetStopOnError(True) + run_options.SetStopOnCrash(True) + run_options.SetEchoCommands(True) + + commands_stream = lldb.SBStream() + commands_stream.Print("process status\n") + commands_stream.Print("thread backtrace\n") + error = debugger.SetInputString(commands_stream.GetData()) + if error.Success(): + local_results = debugger.RunCommandInterpreter(True, False, + run_options, 0, False, + True) + + debugger.SetAsync(async_state) + def CreateSymbolicateCrashLogOptions( command_name, description, diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test --- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test +++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test @@ -4,9 +4,17 @@ # RUN: cp %S/Inputs/scripted_crashlog.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 -i %t.crash' -o 'process status' 2>&1 | FileCheck %s +# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -i %t.crash' 2>&1 | FileCheck %s # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands -# CHECK: Process 92190 stopped -# CHECK: * thread #1, name = 'CrashLogScriptedThread.thread-0', stop reason = EXC_BAD_ACCESS -# CHECK: frame #0: 0x0000000104a23f68 scripted_crashlog_json.test.tmp.out`foo at test.c:3:6 [artificial] +# CHECK: (lldb) process status +# CHECK-NEXT: Process 92190 stopped +# CHECK-NEXT: * thread #1, name = 'CrashLogScriptedThread.thread-0', stop reason = EXC_BAD_ACCESS +# CHECK-NEXT: frame #0: 0x0000000104a23f68 scripted_crashlog_json.test.tmp.out`foo at test.c:3:6 [artificial] + +# CHECK: (lldb) thread backtrace +# CHECK-NEXT: * thread #1, name = 'CrashLogScriptedThread.thread-0', stop reason = EXC_BAD_ACCESS +# CHECK-NEXT: * frame #0: 0x0000000104a23f68 scripted_crashlog_json.test.tmp.out`foo at test.c:3:6 [artificial] +# CHECK-NEXT: frame #1: 0x0000000104a23f80 scripted_crashlog_json.test.tmp.out`bar at test.c:6:21 [artificial] +# CHECK-NEXT: frame #2: 0x0000000104a23fa0 scripted_crashlog_json.test.tmp.out`main(argc=, argv=) at test.c:8:35 [artificial] +# CHECK-NEXT: frame #3: 0x0000000104a6108c dyld`start(kernArgs=) at dyldMain.cpp:879:18 [opt] [artificial]