@@ -296,14 +296,14 @@ def test_version(self):
296296 self .assertEqual (class_str , property_str )
297297
298298 def test_find_target_with_unique_id (self ):
299- """Test SBDebugger.FindTargetWithUniqueID () functionality."""
299+ """Test SBDebugger.FindTargetByGloballyUniqueID () functionality."""
300300
301301 # Test with invalid ID - should return invalid target
302- invalid_target = self .dbg .FindTargetWithUniqueID (999999 )
302+ invalid_target = self .dbg .FindTargetByGloballyUniqueID (999999 )
303303 self .assertFalse (invalid_target .IsValid ())
304304
305305 # Test with ID 0 - should return invalid target
306- zero_target = self .dbg .FindTargetWithUniqueID (0 )
306+ zero_target = self .dbg .FindTargetByGloballyUniqueID (0 )
307307 self .assertFalse (zero_target .IsValid ())
308308
309309 # Build a real executable and create target with it
@@ -314,8 +314,8 @@ def test_find_target_with_unique_id(self):
314314
315315 # Find the target using its unique ID
316316 unique_id = target .GetGloballyUniqueID ()
317- self .assertNotEqual (unique_id , 0 )
318- found_target = self .dbg .FindTargetWithUniqueID (unique_id )
317+ self .assertNotEqual (unique_id , lldb . LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID )
318+ found_target = self .dbg .FindTargetByGloballyUniqueID (unique_id )
319319 self .assertTrue (found_target .IsValid ())
320320 self .assertEqual (
321321 self .dbg .GetIndexOfTarget (target ), self .dbg .GetIndexOfTarget (found_target )
@@ -349,7 +349,7 @@ def test_target_unique_id_uniqueness(self):
349349 # Verify all targets can still be found by their IDs
350350 for target in targets :
351351 unique_id = target .GetGloballyUniqueID ()
352- found = self .dbg .FindTargetWithUniqueID (unique_id )
352+ found = self .dbg .FindTargetByGloballyUniqueID (unique_id )
353353 self .assertTrue (found .IsValid ())
354354 self .assertEqual (found .GetGloballyUniqueID (), unique_id )
355355
@@ -370,8 +370,8 @@ def test_target_unique_id_uniqueness_after_deletion(self):
370370 self .assertNotEqual (unique_id1 , unique_id2 )
371371
372372 # Verify we can find them initially
373- found_target1 = self .dbg .FindTargetWithUniqueID (unique_id1 )
374- found_target2 = self .dbg .FindTargetWithUniqueID (unique_id2 )
373+ found_target1 = self .dbg .FindTargetByGloballyUniqueID (unique_id1 )
374+ found_target2 = self .dbg .FindTargetByGloballyUniqueID (unique_id2 )
375375 self .assertTrue (found_target1 .IsValid ())
376376 self .assertTrue (found_target2 .IsValid ())
377377 target2_index = self .dbg .GetIndexOfTarget (target2 )
@@ -381,7 +381,7 @@ def test_target_unique_id_uniqueness_after_deletion(self):
381381 self .assertTrue (deleted )
382382
383383 # Try to find the deleted target - should not be found
384- not_found_target = self .dbg .FindTargetWithUniqueID (unique_id2 )
384+ not_found_target = self .dbg .FindTargetByGloballyUniqueID (unique_id2 )
385385 self .assertFalse (not_found_target .IsValid ())
386386
387387 # Create a new target
@@ -395,7 +395,9 @@ def test_target_unique_id_uniqueness_after_deletion(self):
395395 self .assertNotEqual (unique_id3 , unique_id2 )
396396 self .assertNotEqual (unique_id3 , unique_id1 )
397397 # Make sure we can find the new target
398- found_target3 = self .dbg .FindTargetWithUniqueID (target3 .GetGloballyUniqueID ())
398+ found_target3 = self .dbg .FindTargetByGloballyUniqueID (
399+ target3 .GetGloballyUniqueID ()
400+ )
399401 self .assertTrue (found_target3 .IsValid ())
400402
401403 def test_target_globally_unique_id_across_debuggers (self ):
@@ -406,6 +408,8 @@ def test_target_globally_unique_id_across_debuggers(self):
406408 # Create two debuggers with targets each
407409 debugger1 = lldb .SBDebugger .Create ()
408410 debugger2 = lldb .SBDebugger .Create ()
411+ self .addTearDownHook (lambda : lldb .SBDebugger .Destroy (debugger1 ))
412+ self .addTearDownHook (lambda : lldb .SBDebugger .Destroy (debugger2 ))
409413
410414 # Create 2 targets per debugger
411415 targets_d1 = [debugger1 .CreateTarget (exe ), debugger1 .CreateTarget (exe )]
@@ -417,22 +421,23 @@ def test_target_globally_unique_id_across_debuggers(self):
417421 self .assertEqual (
418422 len (set (ids )), len (ids ), f"IDs should be globally unique: { ids } "
419423 )
420- self .assertTrue (all (uid > 0 for uid in ids ), "All IDs should be non-zero" )
424+ self .assertTrue (
425+ all (uid != lldb .LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID for uid in ids ),
426+ "All IDs should be valid" ,
427+ )
421428
422429 # Verify targets can be found by their IDs in respective debuggers
423430 for debugger , target_pair in [
424431 (debugger1 , targets [:2 ]),
425432 (debugger2 , targets [2 :]),
426433 ]:
427434 for target in target_pair :
428- found = debugger .FindTargetWithUniqueID (target .GetGloballyUniqueID ())
435+ found = debugger .FindTargetByGloballyUniqueID (
436+ target .GetGloballyUniqueID ()
437+ )
429438 self .assertTrue (
430439 found .IsValid (), "Target should be found by its unique ID"
431440 )
432441 self .assertEqual (
433442 found .GetGloballyUniqueID (), target .GetGloballyUniqueID ()
434443 )
435-
436- # Clean up
437- lldb .SBDebugger .Destroy (debugger1 )
438- lldb .SBDebugger .Destroy (debugger2 )
0 commit comments