public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Farre <simon.farre.cx@gmail.com>
To: gdb-patches@sourceware.org
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: [PATCH 4/5] [dap & linetable]: Add breakpointLocations request
Date: Tue, 16 Jan 2024 20:13:04 +0100	[thread overview]
Message-ID: <20240116191305.126345-4-simon.farre.cx@gmail.com> (raw)
In-Reply-To: <20240116191305.126345-1-simon.farre.cx@gmail.com>

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).
---
 gdb/python/lib/gdb/dap/breakpoint.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 9cbd7ae0c47..fe3c209051d 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -437,3 +437,29 @@ 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],
+):
+    # for now we don't support column, endLine, endColumn. We just return per line
+    return {"breakpoints": _get_logical_bp_locations(source["path"], line)}
-- 
2.43.0


  parent reply	other threads:[~2024-01-16 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 19:13 [PATCH 1/5] [dap & linetable]: Add column to linetable entry Simon Farre
2024-01-16 19:13 ` [PATCH 2/5] [dap & linetable]: Add column to maint info linetable output Simon Farre
2024-01-16 19:13 ` [PATCH 3/5] [dap & linetable]: Change gdb.LineTableEntry & Add gdb.lookup_linetable Simon Farre
2024-01-16 19:13 ` Simon Farre [this message]
2024-01-16 19:13 ` [PATCH 5/5] [dap & linetable]: Added docs Simon Farre
2024-01-16 19:27   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116191305.126345-4-simon.farre.cx@gmail.com \
    --to=simon.farre.cx@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).