diff options
Diffstat (limited to 'lldb/test/API/commands/frame')
8 files changed, 156 insertions, 17 deletions
diff --git a/lldb/test/API/commands/frame/select/TestFrameSelect.py b/lldb/test/API/commands/frame/select/TestFrameSelect.py index cb10105c0fe7..9e21495d4b53 100644 --- a/lldb/test/API/commands/frame/select/TestFrameSelect.py +++ b/lldb/test/API/commands/frame/select/TestFrameSelect.py @@ -23,12 +23,12 @@ class TestFrameSelect(TestBase): self.expect( "frame select -r -1", error=True, - substrs=["Already at the bottom of the stack."], + substrs=["already at the bottom of the stack"], ) self.expect( "frame select -r -2147483647", error=True, - substrs=["Already at the bottom of the stack."], + substrs=["already at the bottom of the stack"], ) self.expect( "frame select -r -2147483648", @@ -61,7 +61,7 @@ class TestFrameSelect(TestBase): self.expect( "frame select -r 1", error=True, - substrs=["Already at the top of the stack."], + substrs=["already at the top of the stack"], ) @no_debug_info_test diff --git a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py index 0f5605718939..f47e86266f47 100644 --- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py +++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py @@ -66,30 +66,27 @@ class TestFrameVarDILArraySubscript(TestBase): self.expect( "frame var 'int_arr[1.0]'", error=True, - substrs=["expected 'r_square', got: <'.'"], + substrs=["failed to parse integer constant: <'1.0' (float_constant)>"], ) - # Base should be a "pointer to T" and index should be of an integral type. - self.expect( - "frame var 'idx_1[0]'", - error=True, - substrs=["subscripted value is not an array or pointer"], - ) + # Test accessing bits in scalar types. + self.expect_var_path("idx_1[0]", value="1") + self.expect_var_path("idx_1[1]", value="0") + self.expect_var_path("1[0]", value="1") + + # Bit access not valid for a reference. self.expect( "frame var 'idx_1_ref[0]'", error=True, - substrs=["subscripted value is not an array or pointer"], + substrs=["bitfield range 0-0 is not valid"], ) + + # Base should be a "pointer to T" and index should be of an integral type. self.expect( "frame var 'int_arr[int_ptr]'", error=True, substrs=["failed to parse integer constant"], ) - self.expect( - "frame var '1[2]'", - error=True, - substrs=["Unexpected token"], - ) # Base should not be a pointer to void self.expect( @@ -105,6 +102,8 @@ class TestFrameVarDILArraySubscript(TestBase): ) self.runCmd("settings set target.experimental.use-DIL true") + self.runCmd("script from myArraySynthProvider import *") + self.runCmd("type synth add -l myArraySynthProvider myArray") # Test synthetic value subscription self.expect_var_path("vector[1]", value="2") @@ -113,3 +112,7 @@ class TestFrameVarDILArraySubscript(TestBase): error=True, substrs=["array index 100 is not valid"], ) + self.expect( + "frame var 'ma_ptr[0]'", + substrs=["(myArray) ma_ptr[0] = ([0] = 7, [1] = 8, [2] = 9, [3] = 10)"], + ) diff --git a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp index a9a3612dfae5..03ad3e872ca7 100644 --- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp +++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp @@ -1,5 +1,11 @@ #include <vector> +class myArray { +public: + int m_array[4] = {7, 8, 9, 10}; + int m_arr_size = 4; +}; + int main(int argc, char **argv) { int int_arr[] = {1, 2, 3}; int *int_ptr = int_arr; @@ -29,5 +35,8 @@ int main(int argc, char **argv) { std::vector<int> vector = {1, 2, 3}; + myArray ma; + myArray *ma_ptr = &ma; + return 0; // Set a breakpoint here } diff --git a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/myArraySynthProvider.py b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/myArraySynthProvider.py new file mode 100644 index 000000000000..167899bd3907 --- /dev/null +++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/myArraySynthProvider.py @@ -0,0 +1,33 @@ +import lldb + + +class myArraySynthProvider: + def __init__(self, valobj, dict): + self.valobj = valobj + + def num_children(self): + size_valobj = self.valobj.GetChildMemberWithName("m_arr_size") + if size_valobj: + return size_valobj.GetValueAsUnsigned(0) + return 0 + + def get_child_at_index(self, index): + size_valobj = self.valobj.GetChildMemberWithName("m_arr_size") + arr = self.valobj.GetChildMemberWithName("m_array") + if not size_valobj or not arr: + return None + max_idx = size_valobj.GetValueAsUnsigned(0) + if index >= max_idx: + return None + return arr.GetChildAtIndex(index) + + def get_child_index(self, name): + if name == "[0]": + return 0 + if name == "[1]": + return + if name == "[2]": + return 2 + if name == "[3]": + return 3 + return -1 diff --git a/lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py b/lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py index 38c72131d797..28eba4f1a70b 100644 --- a/lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py +++ b/lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py @@ -35,7 +35,7 @@ class TestFrameVarDILIndirection(TestBase): self.expect( "frame variable '*1'", error=True, - substrs=["Unexpected token: <'1' (numeric_constant)>"], + substrs=["dereference failed: not a pointer, reference or array type"], ) self.expect( "frame variable '*val'", diff --git a/lldb/test/API/commands/frame/var-dil/expr/Literals/Makefile b/lldb/test/API/commands/frame/var-dil/expr/Literals/Makefile new file mode 100644 index 000000000000..99998b20bcb0 --- /dev/null +++ b/lldb/test/API/commands/frame/var-dil/expr/Literals/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/commands/frame/var-dil/expr/Literals/TestFrameVarDILLiterals.py b/lldb/test/API/commands/frame/var-dil/expr/Literals/TestFrameVarDILLiterals.py new file mode 100644 index 000000000000..431ec2829bc7 --- /dev/null +++ b/lldb/test/API/commands/frame/var-dil/expr/Literals/TestFrameVarDILLiterals.py @@ -0,0 +1,88 @@ +""" +Test DIL literals. +""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test import lldbutil + + +class TestFrameVarDILLiterals(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + def test_literals(self): + self.build() + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp") + ) + + self.runCmd("settings set target.experimental.use-DIL true") + + # Check number literals parsing + self.expect_var_path("1.0", value="1", type="double") + self.expect_var_path("1.0f", value="1", type="float") + self.expect_var_path("0x1.2p+3f", value="9", type="float") + self.expect_var_path("1", value="1", type="int") + self.expect_var_path("1u", value="1", type="unsigned int") + self.expect_var_path("0b1l", value="1", type="long") + self.expect_var_path("01ul", value="1", type="unsigned long") + self.expect_var_path("01lu", value="1", type="unsigned long") + self.expect_var_path("0o1ll", value="1", type="long long") + self.expect_var_path("0x1ULL", value="1", type="unsigned long long") + self.expect_var_path("0x1llu", value="1", type="unsigned long long") + self.expect( + "frame var '1LLL'", + error=True, + substrs=["Failed to parse token as numeric-constant"], + ) + self.expect( + "frame var '1ullu'", + error=True, + substrs=["Failed to parse token as numeric-constant"], + ) + + # Check integer literal type edge cases (dil::Interpreter::PickIntegerType) + frame = thread.GetFrameAtIndex(0) + v = frame.GetValueForVariablePath("argc") + # Creating an SBType from a BasicType still requires any value from the frame + int_size = v.GetType().GetBasicType(lldb.eBasicTypeInt).GetByteSize() + long_size = v.GetType().GetBasicType(lldb.eBasicTypeLong).GetByteSize() + longlong_size = v.GetType().GetBasicType(lldb.eBasicTypeLongLong).GetByteSize() + + longlong_str = "0x" + "F" * longlong_size * 2 + longlong_str = str(int(longlong_str, 16)) + self.assert_literal_type(frame, longlong_str, lldb.eBasicTypeUnsignedLongLong) + toolong_str = "0x" + "F" * longlong_size * 2 + "F" + self.expect( + f"frame var '{toolong_str}'", + error=True, + substrs=[ + "integer literal is too large to be represented in any integer type" + ], + ) + + # These check only apply if adjacent types have different sizes + if int_size < long_size: + # For exmaple, 0xFFFFFFFF and 4294967295 will have different types + # even though the numeric value is the same + hex_str = "0x" + "F" * int_size * 2 + dec_str = str(int(hex_str, 16)) + self.assert_literal_type(frame, hex_str, lldb.eBasicTypeUnsignedInt) + self.assert_literal_type(frame, dec_str, lldb.eBasicTypeLong) + long_str = "0x" + "F" * int_size * 2 + "F" + ulong_str = long_str + "u" + self.assert_literal_type(frame, long_str, lldb.eBasicTypeLong) + self.assert_literal_type(frame, ulong_str, lldb.eBasicTypeUnsignedLong) + if long_size < longlong_size: + longlong_str = "0x" + "F" * long_size * 2 + "F" + ulonglong_str = longlong_str + "u" + self.assert_literal_type(frame, longlong_str, lldb.eBasicTypeLongLong) + self.assert_literal_type( + frame, ulonglong_str, lldb.eBasicTypeUnsignedLongLong + ) + + def assert_literal_type(self, frame, literal, expected_type): + value = frame.GetValueForVariablePath(literal) + basic_type = value.GetType().GetBasicType() + self.assertEqual(basic_type, expected_type) diff --git a/lldb/test/API/commands/frame/var-dil/expr/Literals/main.cpp b/lldb/test/API/commands/frame/var-dil/expr/Literals/main.cpp new file mode 100644 index 000000000000..c9bd8afb0d71 --- /dev/null +++ b/lldb/test/API/commands/frame/var-dil/expr/Literals/main.cpp @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; // Set a breakpoint here +} |
