diff options
| author | Tom Tromey <tromey@adacore.com> | 2023-07-24 13:28:58 -0600 |
|---|---|---|
| committer | Tom Tromey <tromey@adacore.com> | 2023-08-01 12:54:52 -0600 |
| commit | 8a8a5ccadd18b9f1ecb7943bf56fad29c6f529bc (patch) | |
| tree | 05b33251ca2c3b9de1d24e19d820e7ca6a0f2064 /gdb/python | |
| parent | e982d96cd601b1d4cb1bb23b3f3611ac42cca3e3 (diff) | |
| download | binutils-8a8a5ccadd18b9f1ecb7943bf56fad29c6f529bc.zip binutils-8a8a5ccadd18b9f1ecb7943bf56fad29c6f529bc.tar.gz binutils-8a8a5ccadd18b9f1ecb7943bf56fad29c6f529bc.tar.bz2 | |
Do not send "new breakpoint" event when breakpoint is set
When the DAP client sets a breakpoint, gdb currently sends a "new
breakpoint" event. However, Vladimir Makaev discovered that this
causes VSCode to think there are two breakpoints.
This patch changes gdb to suppress the event in this case.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30678
Diffstat (limited to 'gdb/python')
| -rw-r--r-- | gdb/python/lib/gdb/dap/breakpoint.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 4a1c98e..e612c51 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -17,6 +17,8 @@ import gdb import os import re +from contextlib import contextmanager + # These are deprecated in 3.9, but required in older versions. from typing import Optional, Sequence @@ -36,15 +38,32 @@ def _bp_modified(event): ) +# True when suppressing new breakpoint events. +_suppress_bp = False + + +@contextmanager +def suppress_new_breakpoint_event(): + """Return a new context manager that suppresses new breakpoint events.""" + global _suppress_bp + _suppress_bp = True + try: + yield None + finally: + _suppress_bp = False + + @in_gdb_thread def _bp_created(event): - send_event( - "breakpoint", - { - "reason": "new", - "breakpoint": _breakpoint_descriptor(event), - }, - ) + global _suppress_bp + if not _suppress_bp: + send_event( + "breakpoint", + { + "reason": "new", + "breakpoint": _breakpoint_descriptor(event), + }, + ) @in_gdb_thread @@ -141,7 +160,8 @@ def _set_breakpoints_callback(kind, specs, creator): if keyspec in saved_map: bp = saved_map.pop(keyspec) else: - bp = creator(**spec) + with suppress_new_breakpoint_event(): + bp = creator(**spec) bp.condition = condition if hit_condition is None: |
