Skip to content

Commit d7fdf3f

Browse files
committed
Remove unit tests, add Python tests
1 parent 36d4f95 commit d7fdf3f

File tree

20 files changed

+133
-1839
lines changed

20 files changed

+133
-1839
lines changed

lldb/include/lldb/API/SBFrame.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ class LLDB_API SBFrame {
182182
// variable value.
183183
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr,
184184
DynamicValueType use_dynamic);
185-
lldb::SBValue TestGetValueForVariablePath(const char *var_expr_cstr,
186-
DynamicValueType use_dynamic,
187-
bool use_DIL = false);
188185

189186
/// The version that doesn't supply a 'use_dynamic' value will use the
190187
/// target's default.

lldb/include/lldb/Target/StackFrame.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ class StackFrame : public ExecutionContextScope,
308308
lldb::ValueObjectSP GetValueForVariableExpressionPath(
309309
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
310310
uint32_t options, lldb::VariableSP &var_sp, Status &error);
311-
lldb::ValueObjectSP GetValueForVariableExpressionPath(
312-
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
313-
uint32_t options, lldb::VariableSP &var_sp, Status &error, bool use_DIL);
314311

315312
/// Determine whether this StackFrame has debug information available or not.
316313
///

lldb/source/API/SBFrame.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -492,41 +492,6 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path,
492492
return sb_value;
493493
}
494494

495-
lldb::SBValue SBFrame::TestGetValueForVariablePath(const char *var_path,
496-
DynamicValueType use_dynamic,
497-
bool use_DIL) {
498-
LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
499-
500-
SBValue sb_value;
501-
if (var_path == nullptr || var_path[0] == '\0') {
502-
return sb_value;
503-
}
504-
505-
std::unique_lock<std::recursive_mutex> lock;
506-
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
507-
508-
StackFrame *frame = nullptr;
509-
Target *target = exe_ctx.GetTargetPtr();
510-
Process *process = exe_ctx.GetProcessPtr();
511-
if (target && process) {
512-
Process::StopLocker stop_locker;
513-
if (stop_locker.TryLock(&process->GetRunLock())) {
514-
frame = exe_ctx.GetFramePtr();
515-
if (frame) {
516-
VariableSP var_sp;
517-
Status error;
518-
ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
519-
var_path, eNoDynamicValues,
520-
StackFrame::eExpressionPathOptionCheckPtrVsMember |
521-
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
522-
var_sp, error, use_DIL));
523-
sb_value.SetSP(value_sp, use_dynamic);
524-
}
525-
}
526-
}
527-
return sb_value;
528-
}
529-
530495
SBValue SBFrame::FindVariable(const char *name) {
531496
LLDB_INSTRUMENT_VA(this, name);
532497

lldb/source/Target/StackFrame.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -523,17 +523,6 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
523523
var_sp, error);
524524
}
525525

526-
ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
527-
llvm::StringRef var_expr, DynamicValueType use_dynamic, uint32_t options,
528-
VariableSP &var_sp, Status &error, bool use_DIL) {
529-
if (use_DIL)
530-
return DILGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
531-
var_sp, error);
532-
533-
return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
534-
var_sp, error);
535-
}
536-
537526
ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
538527
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
539528
uint32_t options, lldb::VariableSP &var_sp, Status &error) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Test DIL address calculation.
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_frame_var(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("&x", True, type="int *")
30+
self.expect_var_path("r", True, type="int &")
31+
self.expect_var_path("&r", True, type="int &*")
32+
self.expect_var_path("pr", True, type="int *&")
33+
self.expect_var_path("&pr", True, type="int *&*")
34+
self.expect_var_path("my_pr", True)
35+
self.expect_var_path("&my_pr", True, type="mypr *")
36+
self.expect_var_path("&globalVar", True, type="int *")
37+
self.expect_var_path("&s_str", True, type="const char **")
38+
self.expect_var_path("&argc", True, type="int *")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
int globalVar = 0xDEADBEEF;
2+
3+
int main(int argc, char **argv) {
4+
int x = 42;
5+
int &r = x;
6+
int *p = &x;
7+
int *&pr = p;
8+
9+
typedef int *&mypr;
10+
mypr my_pr = p;
11+
12+
const char *s_str = "hello";
13+
14+
char c = 1;
15+
return 0; // Set a breakpoint here
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
is_32bit = self.process().GetAddressByteSize() == 4
28+
29+
self.runCmd("settings set target.experimental.use-DIL true")
30+
self.expect_var_path("*p_int0", True, value="0")
31+
self.expect_var_path("*cp_int5", True, value="5")
32+
self.expect_var_path("*rcp_int0", True, type="const int *")
33+
self.expect_var_path("*array", value="0")
34+
self.expect_var_path(
35+
"&*p_null", value="0x00000000" if is_32bit else "0x0000000000000000"
36+
)
37+
self.expect_var_path("**pp_int0", value="0")
38+
self.expect_var_path("&**pp_int0", type="int *")
39+
self.expect(
40+
"frame var '&*p_void'",
41+
error=True,
42+
substrs=["indirection not permitted on operand of type 'void *'"],
43+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
int main(int argc, char **argv) {
2+
int *p_null = nullptr;
3+
const char *p_char1 = "hello";
4+
5+
typedef const char *my_char_ptr;
6+
my_char_ptr my_p_char1 = p_char1;
7+
8+
int offset = 5;
9+
int array[10];
10+
array[0] = 0;
11+
array[offset] = offset;
12+
13+
int(&array_ref)[10] = array;
14+
15+
int *p_int0 = &array[0];
16+
int **pp_int0 = &p_int0;
17+
const int *cp_int0 = &array[0];
18+
const int *cp_int5 = &array[offset];
19+
const int *&rcp_int0 = cp_int0;
20+
21+
typedef int *td_int_ptr_t;
22+
td_int_ptr_t td_int_ptr0 = &array[0];
23+
24+
void *p_void = (void *)p_char1;
25+
void **pp_void0 = &p_void;
26+
void **pp_void1 = pp_void0 + 1;
27+
28+
return 0; // Set a breakpoint here
29+
}

0 commit comments

Comments
 (0)