From: oltolm Date: Sat, 10 May 2025 08:56:12 +0000 (+0200) Subject: gdb/dap: fix decode_source X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b33b677beadcb40369b1942169a3cdda636755c4;p=thirdparty%2Fbinutils-gdb.git gdb/dap: fix decode_source The documentation for the Source interface says * The path of the source to be shown in the UI. * It is only used to locate and load the content of the source if no * `sourceReference` is specified (or its value is 0). but the code used `path` first. I fixed it to use `sourceReference` first. Approved-By: Tom Tromey --- diff --git a/gdb/python/lib/gdb/dap/sources.py b/gdb/python/lib/gdb/dap/sources.py index 625c01f5d12..efcd7995e4c 100644 --- a/gdb/python/lib/gdb/dap/sources.py +++ b/gdb/python/lib/gdb/dap/sources.py @@ -64,9 +64,9 @@ def decode_source(source): """Decode a Source object. Finds and returns the filename of a given Source object.""" - if "path" in source: - return source["path"] - if "sourceReference" not in source: + if "sourceReference" not in source or source["sourceReference"] <= 0: + if "path" in source: + return source["path"] raise DAPException("either 'path' or 'sourceReference' must appear in Source") ref = source["sourceReference"] if ref not in _id_map: