1"""Test that lldb picks the correct DWARF location list entry with a return-pc out of bounds."""
2
3import lldb
4from lldbsuite.test.decorators import *
5from lldbsuite.test.lldbtest import *
6from lldbsuite.test import lldbutil
7
8
9class LocationListLookupTestCase(TestBase):
10
11    def setUp(self):
12        # Call super's setUp().
13        TestBase.setUp(self)
14
15    @skipIf(oslist=["linux"], archs=["arm"])
16    def test_loclist(self):
17        self.build()
18        exe = self.getBuildArtifact("a.out")
19
20        # Create a target by the debugger.
21        target = self.dbg.CreateTarget(exe)
22        self.assertTrue(target, VALID_TARGET)
23        self.dbg.SetAsync(False)
24
25        li = lldb.SBLaunchInfo(["a.out"])
26        error = lldb.SBError()
27        process = target.Launch(li, error)
28        self.assertTrue(process.IsValid())
29        self.assertTrue(process.is_stopped)
30
31        # Find `main` on the stack, then
32        # find `argv` local variable, then
33        # check that we can read the c-string in argv[0]
34        for f in process.GetSelectedThread().frames:
35            if f.GetDisplayFunctionName() == "main":
36                argv = f.GetValueForVariablePath("argv").GetChildAtIndex(0)
37                strm = lldb.SBStream()
38                argv.GetDescription(strm)
39                self.assertNotEqual(strm.GetData().find('a.out'), -1)
40