[2/3] Clean up suppress_new_breakpoint_event

Message ID 20240124-dap-launch-fix-v1-2-0d47f87fa9f0@adacore.com
State New
Headers
Series Fix ordering of configurationDone and launch |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Jan. 24, 2024, 3:48 p.m. UTC
  Kévin pointed out that suppress_new_breakpoint_event would do the
wrong thing if it happened to be used reentrantly.  While I don't
think this can happen, it's also easy and clearly better to make it
robust.
---
 gdb/python/lib/gdb/dap/breakpoint.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 9cbd7ae0c47..87e746472fb 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -47,11 +47,12 @@  _suppress_bp = False
 def suppress_new_breakpoint_event():
     """Return a new context manager that suppresses new breakpoint events."""
     global _suppress_bp
+    saved = _suppress_bp
     _suppress_bp = True
     try:
         yield None
     finally:
-        _suppress_bp = False
+        _suppress_bp = saved
 
 
 @in_gdb_thread