@@ -135,7 +135,8 @@ def test_structured_annotations_api(self):
135135 instructions = target .ReadInstructions (start_addr , 16 )
136136 self .assertGreater (instructions .GetSize (), 0 , "No instructions read" )
137137
138- print (f"\n Testing GetVariableAnnotations() API on { instructions .GetSize ()} instructions" )
138+ if self .TraceOn ():
139+ print (f"\n Testing GetVariableAnnotations() API on { instructions .GetSize ()} instructions" )
139140
140141 # Track what we find.
141142 found_annotations = False
@@ -265,17 +266,18 @@ def test_structured_annotations_api(self):
265266 elif var_name == "i" :
266267 self .assertEqual (type_name , "int" , "i should be type 'int'" )
267268
268- # Only print if something happened (location changed or variable appeared/disappeared)
269- if should_print or len (current_locations ) != len (prev_locations ):
270- print (f"\n Instruction { i } at { inst .GetAddress ()} : { annotations .GetSize ()} annotations" )
271- for var_name , location in current_locations .items ():
272- change_marker = " <- CHANGED" if var_name in prev_locations and prev_locations [var_name ] != location else ""
273- new_marker = " <- NEW" if var_name not in prev_locations else ""
274- print (f" { var_name } = { location } { change_marker } { new_marker } " )
275- # Check for disappeared variables
276- for var_name in prev_locations :
277- if var_name not in current_locations :
278- print (f" { var_name } <- GONE" )
269+ if self .TraceOn ():
270+ # Only print if something happened (location changed or variable appeared/disappeared)
271+ if should_print or len (current_locations ) != len (prev_locations ):
272+ print (f"\n Instruction { i } at { inst .GetAddress ()} : { annotations .GetSize ()} annotations" )
273+ for var_name , location in current_locations .items ():
274+ change_marker = " <- CHANGED" if var_name in prev_locations and prev_locations [var_name ] != location else ""
275+ new_marker = " <- NEW" if var_name not in prev_locations else ""
276+ print (f" { var_name } = { location } { change_marker } { new_marker } " )
277+ # Check for disappeared variables
278+ for var_name in prev_locations :
279+ if var_name not in current_locations :
280+ print (f" { var_name } <- GONE" )
279281
280282 # Update tracking
281283 prev_locations = current_locations .copy ()
@@ -286,4 +288,5 @@ def test_structured_annotations_api(self):
286288 self .assertGreater (len (found_variables ), 0 ,
287289 "Should find at least one variable" )
288290
289- print (f"\n Test complete. Found variables: { found_variables } " )
291+ if self .TraceOn ():
292+ print (f"\n Test complete. Found variables: { found_variables } " )
0 commit comments