From ec48a0df9151a5192381e44bee6a48a08ed8932b Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 7 Jul 2022 09:53:05 -0700 Subject: [lldb] Improve the error message in run_to_breakpoint_do_run Improve the error message when we fail to hit the initial breakpoint in run_to_breakpoint_do_run. In addition to the process state, we now also report the exit code and reason (if the process exited) as well as the inferior's output. Differential revision: https://reviews.llvm.org/D111978 --- lldb/packages/Python/lldbsuite/test/lldbutil.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/lldbutil.py') diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py index 74ca7dd0..7863e64 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -235,7 +235,7 @@ def state_type_to_str(enum): elif enum == lldb.eStateSuspended: return "suspended" else: - raise Exception("Unknown StateType enum") + raise Exception("Unknown StateType enum: " + str(enum)) def stop_reason_to_str(enum): @@ -945,7 +945,22 @@ def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None, test.assertFalse(error.Fail(), "Process launch failed: %s" % (error.GetCString())) - test.assertState(process.GetState(), lldb.eStateStopped) + def processStateInfo(process): + info = "state: {}".format(state_type_to_str(process.state)) + if process.state == lldb.eStateExited: + info += ", exit code: {}".format(process.GetExitStatus()) + if process.exit_description: + info += ", exit description: '{}'".format(process.exit_description) + stdout = process.GetSTDOUT(999) + if stdout: + info += ", stdout: '{}'".format(stdout) + stderr = process.GetSTDERR(999) + if stderr: + info += ", stderr: '{}'".format(stderr) + return info + + if process.state != lldb.eStateStopped: + test.fail("Test process is not stopped at breakpoint: {}".format(processStateInfo(process))) # Frame #0 should be at our breakpoint. threads = get_threads_stopped_at_breakpoint( -- cgit v1.1