SourceManager::GetDefaultFileAndLine locates the executable's main to pick a default source file, used for input like "break set -l N" with no file specified. It searched for main by full name, but a function's linkage name can differ from its source name, in which case a full-name search for "main" does not find it and no default file is chosen. For example, wasi-libc renames main to __main_argc_argv, so on WebAssembly the debug function for main was never matched and "break set -l N" failed with "no default file available". When we can't find "main", fall back to searching by base name.
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class DefaultSourceFileTestCase(TestBase):
|
|
def test_default_source_file_is_entry_point(self):
|
|
"""The default file for a line breakpoint is main's file, not Foo::main's."""
|
|
self.build()
|
|
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
entry_line = line_number("main.cpp", "BREAK: entry point")
|
|
|
|
# "break set -l" with no file picks the default source file: the one
|
|
# containing the entry point. Foo::main in other.cpp shares the base
|
|
# name "main" and must not be chosen instead.
|
|
lldbutil.run_break_set_by_file_and_line(
|
|
self, None, entry_line, num_expected_locations=1, loc_exact=True
|
|
)
|
|
|
|
bp = target.GetBreakpointAtIndex(0)
|
|
loc = bp.GetLocationAtIndex(0)
|
|
line_entry = loc.GetAddress().GetLineEntry()
|
|
self.assertEqual(line_entry.GetFileSpec().GetFilename(), "main.cpp")
|
|
self.assertEqual(line_entry.GetLine(), entry_line)
|