From b461398f1ce307ec80708b7eb50f3bc82b76ed3f Mon Sep 17 00:00:00 2001 From: Jeffrey Tan Date: Fri, 3 Feb 2023 17:09:09 -0800 Subject: 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 --- lldb/test/API/python_api/debugger/TestDebuggerAPI.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lldb/test/API/python_api/debugger/TestDebuggerAPI.py') diff --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py index 6bc6b3bcbba8..dcc8e2477468 100644 --- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py +++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py @@ -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) -- cgit v1.2.3