aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-07-25 07:04:45 -0600
committerTom Tromey <tromey@adacore.com>2023-08-01 12:54:44 -0600
commite982d96cd601b1d4cb1bb23b3f3611ac42cca3e3 (patch)
tree209f08a312e452b87f6d73a93f1e02974c72b931
parent65403bd0ed22f7c26f972449403c97ff5e998b04 (diff)
downloadgdb-e982d96cd601b1d4cb1bb23b3f3611ac42cca3e3.zip
gdb-e982d96cd601b1d4cb1bb23b3f3611ac42cca3e3.tar.gz
gdb-e982d96cd601b1d4cb1bb23b3f3611ac42cca3e3.tar.bz2
Move DAP breakpoint event code to breakpoint.py
A subsequent patch will add the ability to suppress breakpoint events to DAP. My first attempt at this ended up with recurse imports, causing Python failures. So, this patch moves all the DAP breakpoint event code to breakpoint.py in preparation for the change. I've renamed breakpoint_descriptor here as well, because it can now be private to breakpoint.py.
-rw-r--r--gdb/python/lib/gdb/dap/breakpoint.py42
-rw-r--r--gdb/python/lib/gdb/dap/events.py37
2 files changed, 40 insertions, 39 deletions
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 27745eb..4a1c98e 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -25,6 +25,44 @@ from .startup import send_gdb_with_response, in_gdb_thread, log_stack
from .typecheck import type_check
+@in_gdb_thread
+def _bp_modified(event):
+ send_event(
+ "breakpoint",
+ {
+ "reason": "changed",
+ "breakpoint": _breakpoint_descriptor(event),
+ },
+ )
+
+
+@in_gdb_thread
+def _bp_created(event):
+ send_event(
+ "breakpoint",
+ {
+ "reason": "new",
+ "breakpoint": _breakpoint_descriptor(event),
+ },
+ )
+
+
+@in_gdb_thread
+def _bp_deleted(event):
+ send_event(
+ "breakpoint",
+ {
+ "reason": "removed",
+ "breakpoint": _breakpoint_descriptor(event),
+ },
+ )
+
+
+gdb.events.breakpoint_created.connect(_bp_created)
+gdb.events.breakpoint_modified.connect(_bp_modified)
+gdb.events.breakpoint_deleted.connect(_bp_deleted)
+
+
# Map from the breakpoint "kind" (like "function") to a second map, of
# breakpoints of that type. The second map uses the breakpoint spec
# as a key, and the gdb.Breakpoint itself as a value. This is used to
@@ -34,7 +72,7 @@ breakpoint_map = {}
@in_gdb_thread
-def breakpoint_descriptor(bp):
+def _breakpoint_descriptor(bp):
"Return the Breakpoint object descriptor given a gdb Breakpoint."
result = {
"id": bp.number,
@@ -115,7 +153,7 @@ def _set_breakpoints_callback(kind, specs, creator):
# Reaching this spot means success.
breakpoint_map[kind][keyspec] = bp
- result.append(breakpoint_descriptor(bp))
+ result.append(_breakpoint_descriptor(bp))
# Exceptions other than gdb.error are possible here.
except Exception as e:
log_stack()
diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index ab36dc5..10c8a34 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -18,7 +18,6 @@ import gdb
from .server import send_event
from .startup import in_gdb_thread, Invoker, log
-from .breakpoint import breakpoint_descriptor
from .modules import is_module, make_module
@@ -36,28 +35,6 @@ def _on_exit(event):
@in_gdb_thread
-def _bp_modified(event):
- send_event(
- "breakpoint",
- {
- "reason": "changed",
- "breakpoint": breakpoint_descriptor(event),
- },
- )
-
-
-@in_gdb_thread
-def _bp_created(event):
- send_event(
- "breakpoint",
- {
- "reason": "new",
- "breakpoint": breakpoint_descriptor(event),
- },
- )
-
-
-@in_gdb_thread
def thread_event(event, reason):
send_event(
"thread",
@@ -79,17 +56,6 @@ def _thread_exited(event):
@in_gdb_thread
-def _bp_deleted(event):
- send_event(
- "breakpoint",
- {
- "reason": "removed",
- "breakpoint": breakpoint_descriptor(event),
- },
- )
-
-
-@in_gdb_thread
def _new_objfile(event):
if is_module(event.new_objfile):
send_event(
@@ -179,9 +145,6 @@ def _on_stop(event):
gdb.events.stop.connect(_on_stop)
gdb.events.exited.connect(_on_exit)
-gdb.events.breakpoint_created.connect(_bp_created)
-gdb.events.breakpoint_modified.connect(_bp_modified)
-gdb.events.breakpoint_deleted.connect(_bp_deleted)
gdb.events.new_thread.connect(_new_thread)
gdb.events.thread_exited.connect(_thread_exited)
gdb.events.cont.connect(_cont)