Skip to content

Commit df99e15

Browse files
committed
[lldb] [disassembler] chore: enhance VariableAnnotator to return structured data: update TestVariableAnnotationsDisassembler.py formatting with darker
Signed-off-by: Nikita B <[email protected]>
1 parent 00e12a6 commit df99e15

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed

lldb/test/API/functionalities/disassembler-variables/TestVariableAnnotationsDisassembler.py

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ def test_structured_annotations_api(self):
125125
target = self._create_target(obj)
126126

127127
main_symbols = target.FindSymbols("main")
128-
self.assertTrue(main_symbols.IsValid() and main_symbols.GetSize() > 0,
129-
"Could not find 'main' symbol")
128+
self.assertTrue(
129+
main_symbols.IsValid() and main_symbols.GetSize() > 0,
130+
"Could not find 'main' symbol",
131+
)
130132

131133
main_symbol = main_symbols.GetContextAtIndex(0).GetSymbol()
132134
start_addr = main_symbol.GetStartAddress()
@@ -136,7 +138,9 @@ def test_structured_annotations_api(self):
136138
self.assertGreater(instructions.GetSize(), 0, "No instructions read")
137139

138140
if self.TraceOn():
139-
print(f"\nTesting GetVariableAnnotations() API on {instructions.GetSize()} instructions")
141+
print(
142+
f"\nTesting GetVariableAnnotations() API on {instructions.GetSize()} instructions"
143+
)
140144

141145
expected_vars = ["argc", "argv", "i"]
142146
found_variables = set()
@@ -148,50 +152,63 @@ def test_structured_annotations_api(self):
148152

149153
annotations = inst.GetVariableAnnotations()
150154

151-
self.assertIsInstance(annotations, lldb.SBStructuredData,
152-
"GetVariableAnnotations should return SBStructuredData")
155+
self.assertIsInstance(
156+
annotations,
157+
lldb.SBStructuredData,
158+
"GetVariableAnnotations should return SBStructuredData",
159+
)
153160

154-
self.assertTrue(annotations.GetSize() > 0,
155-
"GetVariableAnnotations should return non empty array")
161+
self.assertTrue(
162+
annotations.GetSize() > 0,
163+
"GetVariableAnnotations should return non empty array",
164+
)
156165

157166
if annotations.GetSize() > 0:
158167
# Validate each annotation.
159168
for j in range(annotations.GetSize()):
160169
ann = annotations.GetItemAtIndex(j)
161170
self.assertTrue(ann.IsValid(), f"Invalid annotation at index {j}")
162171

163-
self.assertEqual(ann.GetType(), lldb.eStructuredDataTypeDictionary,
164-
"Each annotation should be a dictionary")
172+
self.assertEqual(
173+
ann.GetType(),
174+
lldb.eStructuredDataTypeDictionary,
175+
"Each annotation should be a dictionary",
176+
)
165177

166178
var_name_obj = ann.GetValueForKey("variable_name")
167-
self.assertTrue(var_name_obj.IsValid(),
168-
"Missing 'variable_name' field")
179+
self.assertTrue(
180+
var_name_obj.IsValid(), "Missing 'variable_name' field"
181+
)
169182

170183
location_obj = ann.GetValueForKey("location_description")
171-
self.assertTrue(location_obj.IsValid(),
172-
"Missing 'location_description' field")
184+
self.assertTrue(
185+
location_obj.IsValid(), "Missing 'location_description' field"
186+
)
173187

174188
is_live_obj = ann.GetValueForKey("is_live")
175-
self.assertTrue(is_live_obj.IsValid(),
176-
"Missing 'is_live' field")
189+
self.assertTrue(is_live_obj.IsValid(), "Missing 'is_live' field")
177190

178191
start_addr_obj = ann.GetValueForKey("start_address")
179-
self.assertTrue(start_addr_obj.IsValid(),
180-
"Missing 'start_address' field")
192+
self.assertTrue(
193+
start_addr_obj.IsValid(), "Missing 'start_address' field"
194+
)
181195

182196
end_addr_obj = ann.GetValueForKey("end_address")
183-
self.assertTrue(end_addr_obj.IsValid(),
184-
"Missing 'end_address' field")
197+
self.assertTrue(
198+
end_addr_obj.IsValid(), "Missing 'end_address' field"
199+
)
185200

186201
register_kind_obj = ann.GetValueForKey("register_kind")
187-
self.assertTrue(register_kind_obj.IsValid(),
188-
"Missing 'register_kind' field")
202+
self.assertTrue(
203+
register_kind_obj.IsValid(), "Missing 'register_kind' field"
204+
)
189205

190206
var_name = var_name_obj.GetStringValue(1024)
191207

192208
# Check for expected variables in this function.
193-
self.assertIn(var_name, expected_vars,
194-
f"Unexpected variable name: {var_name}")
209+
self.assertIn(
210+
var_name, expected_vars, f"Unexpected variable name: {var_name}"
211+
)
195212

196213
found_variables.add(var_name)
197214

0 commit comments

Comments
 (0)