Fix debugging with GDB when a breakpoint has multiple locations

* lisp/progmodes/gdb-mi.el (gdb-breakpoints--add-breakpoint-row):
New function, extracted from 'gdb-breakpoints-list-handler-custom'.
Don't print "in <unknown>" for header-rows of breakpoints with
multiple locations that don't have a function name attached.
(gdb-breakpoints-list-handler-custom): Add to the breakpoint table
also any locations in multiple-location breakpoints, which are
supported since GDB 6.8.
This commit is contained in:
Eli Zaretskii 2022-06-07 16:01:04 +03:00
parent 25e53e9391
commit 7f778c6943

View file

@ -3076,6 +3076,45 @@ See `def-gdb-auto-update-handler'."
'gdb-breakpoints-mode
'gdb-invalidate-breakpoints)
(defun gdb-breakpoints--add-breakpoint-row (tbl bkpt)
(let ((at (gdb-mi--field bkpt 'at))
(pending (gdb-mi--field bkpt 'pending))
(addr (gdb-mi--field bkpt 'addr))
(func (gdb-mi--field bkpt 'func))
(type (gdb-mi--field bkpt 'type)))
(if (and (not func) (string-equal addr "<MULTIPLE>"))
(setq func ""))
(gdb-table-add-row tbl
(list
(gdb-mi--field bkpt 'number)
(or type "")
(or (gdb-mi--field bkpt 'disp) "")
(let ((flag (gdb-mi--field bkpt 'enabled)))
(if (string-equal flag "y")
(eval-when-compile
(propertize "y" 'font-lock-face
font-lock-warning-face))
(eval-when-compile
(propertize "n" 'font-lock-face
font-lock-comment-face))))
addr
(or (gdb-mi--field bkpt 'times) "")
(if (and type (string-match ".*watchpoint" type))
(gdb-mi--field bkpt 'what)
(or (and (equal func "") "")
pending at
(concat "in "
(propertize (or func "unknown")
'font-lock-face
font-lock-function-name-face)
(gdb-frame-location bkpt)))))
;; Add clickable properties only for
;; breakpoints with file:line information
(append (list 'gdb-breakpoint bkpt)
(when func
'(help-echo "mouse-2, RET: visit breakpoint"
mouse-face highlight))))))
(defun gdb-breakpoints-list-handler-custom ()
(let ((breakpoints-list (gdb-mi--field
(gdb-mi--field (gdb-mi--partial-output 'bkpt)
@ -3088,37 +3127,14 @@ See `def-gdb-auto-update-handler'."
(add-to-list 'gdb-breakpoints-list
(cons (gdb-mi--field breakpoint 'number)
breakpoint))
(let ((at (gdb-mi--field breakpoint 'at))
(pending (gdb-mi--field breakpoint 'pending))
(func (gdb-mi--field breakpoint 'func))
(type (gdb-mi--field breakpoint 'type)))
(gdb-table-add-row table
(list
(gdb-mi--field breakpoint 'number)
(or type "")
(or (gdb-mi--field breakpoint 'disp) "")
(let ((flag (gdb-mi--field breakpoint 'enabled)))
(if (string-equal flag "y")
(eval-when-compile
(propertize "y" 'font-lock-face
font-lock-warning-face))
(eval-when-compile
(propertize "n" 'font-lock-face
font-lock-comment-face))))
(gdb-mi--field breakpoint 'addr)
(or (gdb-mi--field breakpoint 'times) "")
(if (and type (string-match ".*watchpoint" type))
(gdb-mi--field breakpoint 'what)
(or pending at
(concat "in "
(propertize (or func "unknown")
'font-lock-face font-lock-function-name-face)
(gdb-frame-location breakpoint)))))
;; Add clickable properties only for breakpoints with file:line
;; information
(append (list 'gdb-breakpoint breakpoint)
(when func '(help-echo "mouse-2, RET: visit breakpoint"
mouse-face highlight))))))
;; Add the breakpoint/header row to the table.
(gdb-breakpoints--add-breakpoint-row table breakpoint)
;; If this breakpoint has multiple locations, add them as well.
(when-let ((locations (gdb-mi--field breakpoint 'locations)))
(dolist (loc locations)
(add-to-list 'gdb-breakpoints-list
(cons (gdb-mi--field loc 'number) loc))
(gdb-breakpoints--add-breakpoint-row table loc))))
(insert (gdb-table-string table " "))
(gdb-place-breakpoints)))