]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix debugging with GDB when a breakpoint has multiple locations
authorEli Zaretskii <eliz@gnu.org>
Tue, 7 Jun 2022 13:01:04 +0000 (16:01 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 7 Jun 2022 13:01:04 +0000 (16:01 +0300)
* 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.

lisp/progmodes/gdb-mi.el

index 66fc4b1a4ce531e371ba8b3ac0e003b190f31652..a1385b0dea88bfdcde9b9b3e84d8aab77a3e48a3 100644 (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)))