diff options
author | Pavel Labath <pavel@labath.sk> | 2024-11-13 09:56:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-13 09:56:00 +0100 |
commit | 39b2979a434e70a4ce76d4adf91572dcfc9662ff (patch) | |
tree | f46f999c984e0bea1e21bb2c1a77ba22573a7944 /lldb/test/API/source-manager/TestSourceManager.py | |
parent | 12dcaa2e1e6c46d8a1b440d8a836d6b81ab92efb (diff) | |
download | llvm-39b2979a434e70a4ce76d4adf91572dcfc9662ff.zip llvm-39b2979a434e70a4ce76d4adf91572dcfc9662ff.tar.gz llvm-39b2979a434e70a4ce76d4adf91572dcfc9662ff.tar.bz2 |
[lldb] Fix source display for artificial locations (#115876)
When retrieving the location of the function declaration, we were
dropping the file component on the floor, which resulted in an amusingly
confusing situation were we displayed the file containing the
implementation of the function, but used the line number of the
declaration. This patch fixes that.
It required a small refactor Function::GetStartLineSourceLineInfo to
return a SupportFile (instead of just the file spec), which in turn
necessitated changes in a couple of other places as well.
Diffstat (limited to 'lldb/test/API/source-manager/TestSourceManager.py')
-rw-r--r-- | lldb/test/API/source-manager/TestSourceManager.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lldb/test/API/source-manager/TestSourceManager.py b/lldb/test/API/source-manager/TestSourceManager.py index ad7c85a..7071f09 100644 --- a/lldb/test/API/source-manager/TestSourceManager.py +++ b/lldb/test/API/source-manager/TestSourceManager.py @@ -314,19 +314,28 @@ class SourceManagerTestCase(TestBase): ) def test_artificial_source_location(self): - src_file = "artificial_location.c" - d = {"C_SOURCES": src_file} + src_file = "artificial_location.cpp" + d = {"C_SOURCES": "", "CXX_SOURCES": src_file} self.build(dictionary=d) - lldbutil.run_to_source_breakpoint( - self, "main", lldb.SBFileSpec(src_file, False) - ) + target = lldbutil.run_to_breakpoint_make_target(self) + + # Find the instruction with line=0 and put a breakpoint there. + sc_list = target.FindFunctions("A::foo") + self.assertEqual(len(sc_list), 1) + insns = sc_list[0].function.GetInstructions(target) + insn0 = next(filter(lambda insn: insn.addr.line_entry.line == 0, insns)) + bkpt = target.BreakpointCreateBySBAddress(insn0.addr) + self.assertGreater(bkpt.GetNumLocations(), 0) + + lldbutil.run_to_breakpoint_do_run(self, target, bkpt) self.expect( "process status", substrs=[ "stop reason = breakpoint", f"{src_file}:0", + "static int foo();", "Note: this address is compiler-generated code in function", "that has no source code associated with it.", ], |