Add a new SBDebugger::SetDestroyCallback() API

Adding a new SBDebugger::SetDestroyCallback() API.
This API can be used by any client to query for statistics/metrics before
exiting debug sessions.

Differential Revision: https://reviews.llvm.org/D143520
This commit is contained in:
Jeffrey Tan
2023-02-03 17:09:09 -08:00
parent 6e2ade23c7
commit b461398f1c
9 changed files with 96 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ class DebuggerAPITestCase(TestBase):
self.dbg.SetPrompt(None)
self.dbg.SetCurrentPlatform(None)
self.dbg.SetCurrentPlatformSDKRoot(None)
fresh_dbg = lldb.SBDebugger()
self.assertEquals(len(fresh_dbg), 0)
@@ -146,3 +146,16 @@ class DebuggerAPITestCase(TestBase):
self.assertEqual(platform2.GetName(), expected_platform)
self.assertTrue(platform2.GetWorkingDirectory().endswith("bar"),
platform2.GetWorkingDirectory())
def test_SetDestroyCallback(self):
destroy_dbg_id = None
def foo(dbg_id):
# Need nonlocal to modify closure variable.
nonlocal destroy_dbg_id
destroy_dbg_id = dbg_id
self.dbg.SetDestroyCallback(foo)
original_dbg_id = self.dbg.GetID()
self.dbg.Destroy(self.dbg)
self.assertEqual(destroy_dbg_id, original_dbg_id)