@@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str:
16
16
self .ci .HandleCommand (cmd , result )
17
17
return result .GetOutput ().rstrip ()
18
18
19
- VAR_IDENT = re .compile (r"(?:\$\d+|\w +) = " )
19
+ VAR_IDENT = re .compile (r"(?:\$\d+|[\w.] +) = " )
20
20
21
21
def _strip_result_var (self , string : str ) -> str :
22
22
"""
@@ -121,30 +121,39 @@ def test_empty_expression(self):
121
121
def test_nested_values (self ):
122
122
"""Test dwim-print with nested values (structs, etc)."""
123
123
self .build ()
124
- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
124
+ lldbutil .run_to_source_breakpoint (
125
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
126
+ )
125
127
self .runCmd ("settings set auto-one-line-summaries false" )
126
128
self ._expect_cmd (f"dwim-print s" , "frame variable" )
127
129
self ._expect_cmd (f"dwim-print (struct Structure)s" , "expression" )
128
130
129
131
def test_summary_strings (self ):
130
- """Test dwim-print with nested values (structs, etc) ."""
132
+ """Test dwim-print with type summaries ."""
131
133
self .build ()
132
- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
134
+ lldbutil .run_to_source_breakpoint (
135
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
136
+ )
133
137
self .runCmd ("settings set auto-one-line-summaries false" )
134
138
self .runCmd ("type summary add -e -s 'stub summary' Structure" )
135
139
self ._expect_cmd (f"dwim-print s" , "frame variable" )
136
140
self ._expect_cmd (f"dwim-print (struct Structure)s" , "expression" )
141
+ self .runCmd ("type summary delete Structure" )
137
142
138
143
def test_void_result (self ):
139
144
"""Test dwim-print does not surface an error message for void expressions."""
140
145
self .build ()
141
- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
146
+ lldbutil .run_to_source_breakpoint (
147
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
148
+ )
142
149
self .expect ("dwim-print (void)15" , matching = False , patterns = ["(?i)error" ])
143
150
144
151
def test_preserves_persistent_variables (self ):
145
152
"""Test dwim-print does not delete persistent variables."""
146
153
self .build ()
147
- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
154
+ lldbutil .run_to_source_breakpoint (
155
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
156
+ )
148
157
self .expect ("dwim-print int $i = 15" )
149
158
# Run the same expression twice and verify success. This ensures the
150
159
# first command does not delete the persistent variable.
@@ -154,5 +163,25 @@ def test_preserves_persistent_variables(self):
154
163
def test_missing_type (self ):
155
164
"""The expected output of po opaque is its address (no error)"""
156
165
self .build ()
157
- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
166
+ lldbutil .run_to_source_breakpoint (
167
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
168
+ )
158
169
self .expect ("dwim-print -O -- opaque" , substrs = ["0x" ])
170
+
171
+ def test_variable_expression_path (self ):
172
+ """Test dwim-print supports certain variable expression paths."""
173
+ self .build ()
174
+ lldbutil .run_to_source_breakpoint (
175
+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
176
+ )
177
+ self .runCmd ("settings set auto-one-line-summaries false" )
178
+ self ._expect_cmd ("dwim-print w.s" , "frame variable" )
179
+ self ._expect_cmd ("dwim-print wp->s" , "expression" )
180
+
181
+ def test_direct_child_access (self ):
182
+ """Test dwim-print supports accessing members/ivars without qualification."""
183
+ self .build ()
184
+ lldbutil .run_to_source_breakpoint (
185
+ self , "break inside" , lldb .SBFileSpec ("main.cpp" )
186
+ )
187
+ self ._expect_cmd ("dwim-print number" , "frame variable" )
0 commit comments