Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
1 parent
75e551e
commit ec48a0d
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lldbutil-tests/failed-to-hit-breakpoint/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CXX_SOURCES := main.cpp | ||
|
||
include Makefile.rules |
27 changes: 27 additions & 0 deletions
27
lldb/test/API/lldbutil-tests/failed-to-hit-breakpoint/TestLLDBUtilFailedToHitBreakpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Tests lldbutil's behavior when running to a source breakpoint fails. | ||
""" | ||
|
||
import lldb | ||
import lldbsuite.test.lldbutil as lldbutil | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
|
||
|
||
class LLDBUtilFailedToHitBreakpointTest(TestBase): | ||
|
||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
@expectedFailureAll(oslist=["windows"]) | ||
def test_error_message(self): | ||
""" | ||
Tests that run_to_source_breakpoint prints the right error message | ||
when failing to hit the wanted breakpoint. | ||
""" | ||
self.build() | ||
with self.assertRaisesRegex( | ||
AssertionError, | ||
"Test process is not stopped at breakpoint: state: exited, exit code: 0, stdout: 'stdout_needlestderr_needle'" | ||
): | ||
lldbutil.run_to_source_breakpoint(self, "// break here", | ||
lldb.SBFileSpec("main.cpp")) |
21 changes: 21 additions & 0 deletions
21
lldb/test/API/lldbutil-tests/failed-to-hit-breakpoint/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
#include <thread> | ||
|
||
int main(int argc, char **argv) { | ||
// Print the string that the test looks for to make sure stdout and stderr | ||
// got recorded. | ||
std::cout << "stdout_needle" << std::flush; | ||
std::cerr << "stderr_needle" << std::flush; | ||
|
||
// Work around a timing issue that sometimes prevents stderr from being | ||
// captured. | ||
std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
|
||
// This is unreachable during normal test execution as we don't pass any | ||
// (or +100) arguments. This still needs to be theoretically reachable code | ||
// so that the compiler will generate code for this (that we can set a | ||
// breakpoint on). | ||
if (argc > 100) | ||
return 1; // break here | ||
return 0; | ||
} |