[Lldb-commits] [lldb] [lldb-dap] Adding exception handling for dap server disconnect and terminations in lldbdap_testcase.py (PR #155335)

David Peixotto via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 29 15:09:53 PDT 2025


================
@@ -450,6 +450,20 @@ def disassemble(self, threadId=None, frameIndex=None):
 
         return disassembled_instructions, disassembled_instructions[memoryReference]
 
+    def dapCleanup(self, disconnectAutomatically):
+        if disconnectAutomatically:
+            try:
----------------
dmpots wrote:

This is swallowing any exceptions that can occur in either `request_disconnect` or `terminate`, which is different behavior than the version originally approved by @walter-erquinigo  and @ashgti. 

@piyushjaiswal98 says that the teardown hooks are actually processed in LIFO order instead of FIFO order as expected which is why he changed it to catching them. Is there a better way to handle the exceptions here?

Can we use try-finally instead?
```
def dapCleanup(self, disconnectAutomatically):
    try:
        if disconnectAutomatically:
            self.dap_server.request_disconnect(terminateDebuggee=True)
    finally:
        self.dap_server.terminate()
```

https://github.com/llvm/llvm-project/pull/155335


More information about the lldb-commits mailing list