[v2,4/5,dap,&,linetable] : Add breakpointLocations request
Commit Message
This adds the breakpointLocations request.
Testing might strictly not be possible for this feature. Users are going
to have wildly varying compilers and compiler versions that outputs
wildly different debug symbol information. So unless we can restrain the
tests to some specific toolchain that I can handroll the tests for, this
will not be useful (and handrolling for a specific compiler defeats the
purpose - as one can just use the eyes then to verify).
v2:
Fixed type check issue
Forgot the obligatory **args at the end of breakpoint_locations
---
gdb/python/lib/gdb/dap/breakpoint.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
@@ -437,3 +437,30 @@ def set_exception_breakpoints(
return {
"breakpoints": _set_exception_catchpoints(options),
}
+
+
+@in_gdb_thread
+def _get_logical_bp_locations(name: str, line: int):
+ linetable = gdb.lookup_linetable(name)
+ if linetable is not None:
+ return [
+ {"line": lte.line, "column": lte.column} for lte in linetable.line(line)
+ ]
+ else:
+ return []
+
+
+@request("breakpointLocations")
+@capability("supportsBreakpointLocationsRequest")
+def breakpoint_locations(
+ *,
+ # This is a Source but we don't type-check it.
+ source,
+ line: int,
+ column: Optional[int],
+ endLine: Optional[int],
+ endColumn: Optional[int],
+ **args,
+):
+ # for now we don't support column, endLine, endColumn. We just return per line
+ return {"breakpoints": _get_logical_bp_locations(source["path"], line)}