[3/4] gdb/dap: use breakpoint fullname to resolve source

Message ID 20230901180323.22328-9-greg@gpanders.com
State New
Headers
Series DAP fixups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Gregory Anders Sept. 1, 2023, 5:55 p.m. UTC
  If the breakpoint has a fullname, use that as the source path when
resolving the breakpoint source information. This is consistent with
other callers of make_source which also use "fullname" if it exists (see
e.g. DAPFrameDecorator which returns the symtab's fullname).
---
 gdb/python/lib/gdb/dap/breakpoint.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Tom Tromey Sept. 1, 2023, 7:08 p.m. UTC | #1
>>>>> Gregory Anders via Gdb-patches <gdb-patches@sourceware.org> writes:

> If the breakpoint has a fullname, use that as the source path when
> resolving the breakpoint source information. This is consistent with
> other callers of make_source which also use "fullname" if it exists (see
> e.g. DAPFrameDecorator which returns the symtab's fullname).

Thank you.

How did you find this?  I'm wondering if a test case is possible.

Tom
  
Gregory Anders Sept. 5, 2023, 2:08 p.m. UTC | #2
On Fri, 01 Sep 2023 13:08 -0600, Tom Tromey wrote:
>How did you find this?  I'm wondering if a test case is possible.

I use the 'substitute-path' option, and noticed that the path in
source.path uses the "compiled" source path (before translating with
'substitute-path') while loc.fullname contains the path after
translating.

Any hints or ideas on how to include a test case for that?
  

Patch

diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 0ebb9597..49efff10 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -108,6 +108,9 @@  def _breakpoint_descriptor(bp):
         loc = bp.locations[0]
         if loc.source:
             (filename, line) = loc.source
+            if loc.fullname is not None:
+                filename = loc.fullname
+
             result.update(
                 {
                     "source": make_source(filename, os.path.basename(filename)),
@@ -118,9 +121,6 @@  def _breakpoint_descriptor(bp):
         if loc.address:
             result["instructionReference"] = hex(loc.address),
 
-        path = loc.fullname
-        if path is not None:
-            result["source"]["path"] = path
     return result