| 1 |
""" |
| 2 |
Test DIL pointer arithmetic. |
| 3 |
""" |
| 4 |
|
| 5 |
import lldb |
| 6 |
from lldbsuite.test.lldbtest import * |
| 7 |
from lldbsuite.test.decorators import * |
| 8 |
from lldbsuite.test import lldbutil |
| 9 |
|
| 10 |
|
| 11 |
class TestFrameVarDILGlobalVariableLookup(TestBase): |
| 12 |
NO_DEBUG_INFO_TESTCASE = True |
| 13 |
|
| 14 |
def expect_var_path(self, expr, compare_to_framevar=False, value=None, type=None): |
| 15 |
value_dil = super().expect_var_path(expr, value=value, type=type) |
| 16 |
if compare_to_framevar: |
| 17 |
self.runCmd("settings set target.experimental.use-DIL false") |
| 18 |
value_frv = super().expect_var_path(expr, value=value, type=type) |
| 19 |
self.runCmd("settings set target.experimental.use-DIL true") |
| 20 |
self.assertEqual(value_dil.GetValue(), value_frv.GetValue()) |
| 21 |
|
| 22 |
def test_dereference(self): |
| 23 |
self.build() |
| 24 |
lldbutil.run_to_source_breakpoint( |
| 25 |
self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp") |
| 26 |
) |
| 27 |
|
| 28 |
self.runCmd("settings set target.experimental.use-DIL true") |
| 29 |
self.expect_var_path("*p_int0", True, value="0") |
| 30 |
self.expect_var_path("*cp_int5", True, value="5") |
| 31 |
self.expect_var_path("*rcp_int0", True, type="const int *") |
| 32 |
self.expect_var_path("*offset_p", True, value="5") |
| 33 |
self.expect_var_path("*offset_pref", True, type="int *") |
| 34 |
self.expect_var_path("**pp_int0", value="0") |
| 35 |
self.expect_var_path("&**pp_int0", type="int *") |
| 36 |
self.expect_var_path("*array", value="0") |
| 37 |
self.expect( |
| 38 |
"frame var '&*p_null'", |
| 39 |
error=True, |
| 40 |
substrs=["doesn't have a valid address"], |
| 41 |
) |
| 42 |
self.expect( |
| 43 |
"frame var '&*p_void'", |
| 44 |
error=True, |
| 45 |
substrs=["dereference failed: cannot dereference void *: (void *) p_void"], |
| 46 |
) |