teemperor created this revision. teemperor added a reviewer: JDevlieghere. teemperor added a project: LLDB. teemperor requested review of this revision. Herald added a subscriber: lldb-commits.
At the moment if a test fails to hits the breakpoint we set in `run_to_source_breakpoint` the test suite just prints: AssertionError: 0 != 1 : Expected 1 thread to stop at breakpoint, 0 did Often these errors happen because the debuggee crashed before that breakpoint is being hit or the process failed to launch but it's hard to tell what happened from the current error. This patch adds that we now print the backtrace of all threads in case the test failed because we didn't hit the right breakpoint Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103439 Files: lldb/packages/Python/lldbsuite/test/lldbutil.py Index: lldb/packages/Python/lldbsuite/test/lldbutil.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -840,6 +840,12 @@ threads.append(thread) return threads +def get_thread_overview(test): + """Returns a string providing an overview over all current threads. + Should be used for making test errors more expressive.""" + test.runCmd("thread backtrace all") + return "Current threads:\n" + test.res.GetOutput() + # Helper functions for run_to_{source,name}_breakpoint: def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True): @@ -897,9 +903,13 @@ num_threads = len(threads) if only_one_thread: - test.assertEqual(num_threads, 1, "Expected 1 thread to stop at breakpoint, %d did."%(num_threads)) + test.assertEqual(num_threads, 1, + "Expected 1 thread to stop at breakpoint, %d did.\n%s" + % (num_threads, get_thread_overview(test))) else: - test.assertGreater(num_threads, 0, "No threads stopped at breakpoint") + test.assertGreater(num_threads, 0, + "No threads stopped at breakpoint.\n%s" % + (get_thread_overview(test))) thread = threads[0] return (target, process, thread, bkpt)
Index: lldb/packages/Python/lldbsuite/test/lldbutil.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -840,6 +840,12 @@ threads.append(thread) return threads +def get_thread_overview(test): + """Returns a string providing an overview over all current threads. + Should be used for making test errors more expressive.""" + test.runCmd("thread backtrace all") + return "Current threads:\n" + test.res.GetOutput() + # Helper functions for run_to_{source,name}_breakpoint: def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True): @@ -897,9 +903,13 @@ num_threads = len(threads) if only_one_thread: - test.assertEqual(num_threads, 1, "Expected 1 thread to stop at breakpoint, %d did."%(num_threads)) + test.assertEqual(num_threads, 1, + "Expected 1 thread to stop at breakpoint, %d did.\n%s" + % (num_threads, get_thread_overview(test))) else: - test.assertGreater(num_threads, 0, "No threads stopped at breakpoint") + test.assertGreater(num_threads, 0, + "No threads stopped at breakpoint.\n%s" % + (get_thread_overview(test))) thread = threads[0] return (target, process, thread, bkpt)
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits