Skip to content

Commit

Permalink
Fix #125 Configure GDB to report absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sakhnik committed Jan 20, 2021
1 parent 1bee59e commit a2c7994
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
8 changes: 0 additions & 8 deletions doc/nvimgdb.txt
Expand Up @@ -298,14 +298,6 @@ Section 7.1 GDB *NvimgdbGDB*
program that launches gdb in a pseudo terminal, listens a unix socket for
commands, and processes the output of GDB to filter out service commands.

- The compiler may embed relative paths to the source code files. Thus, the
plugin may struggle to find them on the file system when identifying
breakpoints. So consider working from within the same directory that was
used to compile. Or alternatively, configure GCC to embed full paths: >
gcc -fdebug-prefix-map=..=$(readlink -f ..)
<

==============================================================================
Section 8: Limitations *NvimgdbLimitations*

Expand Down
1 change: 1 addition & 0 deletions lib/gdb_wrap.sh
Expand Up @@ -27,6 +27,7 @@ gdb_init=$(mktemp /tmp/gdb_init.XXXXXX)
cat >"$gdb_init" <<EOF
set confirm off
set pagination off
set filename-display absolute
python gdb.prompt_hook = lambda p: p + ("" if p.endswith("\x1a\x1a\x1a") else "\x1a\x1a\x1a")
EOF

Expand Down
17 changes: 1 addition & 16 deletions rplugin/python3/gdb/backend/gdb.py
Expand Up @@ -34,27 +34,12 @@ def __init__(self, proxy):
self.proxy = proxy
self.logger = logging.getLogger("Gdb.Breakpoint")

def _resolve_file(self, fname):
"""Resolve filename full path into its debugger presentation."""
resp = self.proxy.query(f"handle-command info source {fname}")
self.logger.debug(resp)
pattern = re.compile(r"Current source file is ([^\r\n]+)")
match = pattern.search(resp)
if match:
self.logger.info(match.group(1))
return match.group(1)
return fname

def query(self, fname: str):
self.logger.info("Query breakpoints for %s", fname)
fname_sym = self._resolve_file(fname)
if fname != fname_sym:
self.logger.info("Map file path %s to %s", fname, fname_sym)
response = self.proxy.query("handle-command info breakpoints")
if not response:
return {}

return self._parse_response(response, fname_sym)
return self._parse_response(response, fname)

def _parse_response(self, response: str, fname_sym: str):
# Select lines in the current file with enabled breakpoints.
Expand Down

0 comments on commit a2c7994

Please sign in to comment.