branch: externals/realgud
commit 690385d91259ea8420ea0b01957e3a0631743c8f
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
gdb: handle ANSI escape codes, relative paths, blacklist, and doc fix
1. track.el: gdb will generate ANSI escape sequences (emacs 25, Debian 9,
gdb 7.12) into the comint
buffer which was causing the regex matches to fail resulting in no
location tracking. Fix by
stripping the ANSI escape sequences when we extract the buffer text from
the comint buffer.
2. gdb.el: When setting a breakpoint to a function, gdb by default displays
a relative path, e.g.
(gdb) b functionName
Breakpoint 1 at 0x7fff607e4dd6: file dir/file.cpp, line 273.
where dir/file.cpp is relative which occurs when you compile using a
relative path,
g++ -c dir/file.cpp
We want it to display
(gdb) b functionName
Breakpoint 1 at 0x7fff607e4dd6: file /abs/path/to/file.cpp, line 273.
which is achieved by setting "set filename-display absolute" at gdb
startup.
3. file.el: Improve the prompt on file blacklist to indicate why
blacklisting is occurring, i.e. the
file is not found. (Also fix typo, black-list is spelled blacklist).
4. Minor doc fixes on how to use ./configure.
---
INSTALL.md | 10 +++++++++-
configure.ac | 2 +-
realgud/common/file.el | 4 ++--
realgud/common/track.el | 14 +++++++++++++-
realgud/debugger/gdb/gdb.el | 8 ++++++++
5 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/INSTALL.md b/INSTALL.md
index 0bfc18e..ec7b524 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -7,9 +7,17 @@ Have `test-simple`, `loc-changes`, `cl-lib` and
`load-relative` installed.
From inside emacs, evaluate:
```lisp
- (compile (format "EMACSLOADPATH=:%s:%s:%s:%s ./autogen.sh"
(file-name-directory (locate-library "test-simple.elc")) (file-name-directory
(locate-library "load-relative.elc")) (file-name-directory (locate-library
"loc-changes.elc")) (file-name-directory (locate-library "realgud.elc")) ))
+ (compile (format "EMACSLOADPATH=:%s:%s:%s:%s ./autogen.sh"
(file-name-directory (locate-library "test-simple.elc")) (file-name-directory
(locate-library "load-relative.elc")) (file-name-directory (locate-library
"loc-changes.elc")) default-directory) )
```
+
+Optional: if you want to install to a custom location, use ./configure as
shown.
+Note, that --prefix does not prefix the lispdir, you must use --with-lispdir in
+addition to --prefix.
+
+ ./configure --prefix=INSTALL_DIR
--with-lispdir=INSTALL_DIR/share/emacs/site-lisp
+
+
After this you should be able to run:
$ make # byte compile everything
diff --git a/configure.ac b/configure.ac
index 944513e..b0a1804 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
AC_PATH_PROG([EMACS], [emacs], [emacs])
-AC_ARG_WITH(emacs, AC_HELP_STRING([--with-emacs],
+AC_ARG_WITH(emacs, AC_HELP_STRING([--with-emacs=VALUE],
[location of emacs program]), EMACS=$withval)
AC_MSG_NOTICE("Checking emacs version")
diff --git a/realgud/common/file.el b/realgud/common/file.el
index a542e89..dd923f5 100644
--- a/realgud/common/file.el
+++ b/realgud/common/file.el
@@ -122,8 +122,8 @@ problem as best as we can determine."
(setq matching-file-list (realgud--file-matching-suffix buffer-files
filename))
(car matching-file-list)))
- ;; Do we want to black-list this?
- ((y-or-n-p (format "Black-list file %s for location tracking?"
filename))
+ ;; Do we want to blacklist this?
+ ((y-or-n-p (format "Unable to locate %s\nBlacklist it for location
tracking?" filename))
;; FIXME: there has to be a simpler way to set ignore-file-list
(with-current-buffer cmdbuf
(push filename ignore-re-file-list)
diff --git a/realgud/common/track.el b/realgud/common/track.el
index fe4f3a2..483b672 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -228,7 +228,19 @@ evaluating (realgud-cmdbuf-info-loc-regexp
realgud-cmdbuf-info)"
(interactive "r")
(if (> from to) (cl-psetq to from from to))
- (let* ((text (buffer-substring-no-properties from to))
+ (let* ((text (replace-regexp-in-string
+ ;; Strip ANSI escape codes, e.g. gdb produces ^[[?2004h and
^[[?2004l before
+ ;; prompts. This regex handles these sequences, colors, and
more. However, it
+ ;; doesn't cover all. To cover all, we'd need something like
+ ;; "\033\\[\\??[0-9;]*[a-zA-Z]" but this covers non-defined
escape sequences and is
+ ;; missing sequences that have multiple ending letters. The
multi-letter ending
+ ;; escape sequences probably won't occur because these are
cursor movement
+ ;; sequences. Examining the escape code spec, this regex
should cover all cases
+ ;; we'd hit from a debugger.
+ ;; https://github.com/realgud/realgud/issues/257
+ ;; https://en.wikipedia.org/wiki/ANSI_escape_code
+ "\033\\[\\??[0-9;]*[CDGKJhlm]" ""
+ (buffer-substring-no-properties from to)))
(loc (realgud-track-loc text cmd-mark))
;; If we see a selected frame number, it is stored
;; in frame-num. Otherwise, nil.
diff --git a/realgud/debugger/gdb/gdb.el b/realgud/debugger/gdb/gdb.el
index 6f410e5..dbbf247 100644
--- a/realgud/debugger/gdb/gdb.el
+++ b/realgud/debugger/gdb/gdb.el
@@ -134,6 +134,14 @@ fringe and marginal icons.
(if (and process (eq 'run (process-status process)))
(with-current-buffer cmd-buf
(realgud-command "set annotate 1" nil nil nil)
+ ;; In gdb, when setting breakpoint on function, we want it to
produce an absolute
+ ;; path, so set filename-display to absolute. We want:
+ ;; (gdb) b functionName
+ ;; Breakpoint 1 at 0x7fff607e4dd6: file
/abs/path/to/file.cpp, line 273.
+ ;; Without this, gdb will display the path supplied when the
code was compiled, i.e.
+ ;; if a relative path is supplied to gcc, gdb will display the
relative path
+ ;; tripping up realgud, causing it to ask if you want to
blacklist the file.
+ (realgud-command "set filename-display absolute" nil nil nil)
)))
)
))