aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2023-09-01 16:02:17 -0500
committerTom Tromey <tromey@adacore.com>2023-09-20 10:59:32 -0600
commit155f5df517c962f1317e119a6a5ca317e1202996 (patch)
treea059ad9901fc19f17c476c132d5cde33c3fac5f0 /gdb/python
parent4abf53c99115dad84720be64432ab4bd933b9df7 (diff)
downloadgdb-155f5df517c962f1317e119a6a5ca317e1202996.zip
gdb-155f5df517c962f1317e119a6a5ca317e1202996.tar.gz
gdb-155f5df517c962f1317e119a6a5ca317e1202996.tar.bz2
gdb/dap: check for breakpoint source before unpacking
Not all breakpoints have a source location. For example, a breakpoint set on a raw address will have only the "address" field populated, but "source" will be None, which leads to a RuntimeError when attempting to unpack the filename and line number. Before attempting to unpack the filename and line number from the breakpoint, ensure that the source information is not None. Also populate the source and line information separately from the "instructionReference" field, so that breakpoints that include only an address are still included. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/dap/breakpoint.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 1622ae6..bf06298 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -106,14 +106,18 @@ def _breakpoint_descriptor(bp):
# multiple locations. See
# https://github.com/microsoft/debug-adapter-protocol/issues/13
loc = bp.locations[0]
- (filename, line) = loc.source
- result.update(
- {
- "source": make_source(filename, os.path.basename(filename)),
- "line": line,
- "instructionReference": hex(loc.address),
- }
- )
+ if loc.source:
+ (filename, line) = loc.source
+ result.update(
+ {
+ "source": make_source(filename, os.path.basename(filename)),
+ "line": line,
+ }
+ )
+
+ if loc.address:
+ result["instructionReference"] = hex(loc.address),
+
path = loc.fullname
if path is not None:
result["source"]["path"] = path