branch: externals/realgud
commit 8a521c561738fa0bf1c702bda0c9908dcb8e72f1
Author: rocky <[email protected]>
Commit: rocky <[email protected]>
gdb support for detecting deleted breakpoints
This code was provided by Lennart Rittel (lrittel)
---
realgud/common/track.el | 14 ++++++++++----
realgud/debugger/gdb/gdb.el | 3 +++
realgud/debugger/gdb/init.el | 4 ++--
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/realgud/common/track.el b/realgud/common/track.el
index c057017b9f..2339cd24ff 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2020 Free Software Foundation, Inc
+;; Copyright (C) 2015-2020, 2025 Free Software Foundation, Inc
;; Author: Rocky Bernstein <[email protected]>
@@ -659,7 +659,9 @@ of the breakpoints found in command buffer."
(when loc-pat
(let ((bp-num-group (realgud-loc-pat-num loc-pat))
(loc-regexp (realgud-loc-pat-regexp loc-pat)))
- (when (and loc-regexp (string-match loc-regexp text))
+ (found-locs nil)
+ (current-pos 0))
+ (while (and loc-regexp current-pos (string-match loc-regexp text
current-pos))
(let* ((bp-nums-str (match-string bp-num-group text))
(bp-num-strs (split-string bp-nums-str "[^0-9]+" t))
(bp-nums (mapcar #'string-to-number bp-num-strs))
@@ -672,8 +674,12 @@ of the breakpoints found in command buffer."
;; Remove loc from breakpoint list
(realgud-cmdbuf-info-bp-list=
(remove loc (realgud-cmdbuf-info-bp-list info)))))
- ;; return the locations
- found-locs))))))))
+ (setq current-pos (match-end 0))))
+ ;; Match-end returns 0 when the whole string was matched.
+ ;; Setting current-pos to nil exits the loop
+ (if (= current-pos 0) (setq current-pos nil))
+ ;; return the locations
+ found-locs)))))
(defun realgud-track-bp-enable-disable(text loc-pat enable? &optional cmdbuf)
"Do regular-expression matching see if a breakpoint has been enabled or
disabled inside
diff --git a/realgud/debugger/gdb/gdb.el b/realgud/debugger/gdb/gdb.el
index 1de92f24c6..c3eb111a36 100644
--- a/realgud/debugger/gdb/gdb.el
+++ b/realgud/debugger/gdb/gdb.el
@@ -64,6 +64,9 @@ This should be an executable on your path, or an absolute
file name."
;; 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.
"set filename-display absolute"
+ ;; gdb doesn't print a confirmation that a breakpoint was deleted
successfully by default.
+ ;; This event listener adds a status message for every deleted breakpoint.
+ (realgud-command "python gdb.events.breakpoint_deleted.connect(lambda b:
print(f\"Deleted breakpoint {b.number}\"))" nil nil nil)
)
"List of commands to be executed right after command buffer setup.")
diff --git a/realgud/debugger/gdb/init.el b/realgud/debugger/gdb/init.el
index 062846ddbf..7f04a7510d 100644
--- a/realgud/debugger/gdb/init.el
+++ b/realgud/debugger/gdb/init.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2017, 2019 Free Software Foundation, Inc
+;; Copyright (C) 2015-2017, 2019, 2025 Free Software Foundation, Inc
;; Author: Rocky Bernstein <[email protected]>
@@ -82,7 +82,7 @@ realgud-loc-pat struct")
;; Deleted breakpoints 1 2 3 4
(setf (gethash "brkpt-del" realgud:gdb-pat-hash)
(make-realgud-loc-pat
- :regexp "^Deleted breakpoints? \\(\\([0-9]+ *\\)+\\)\n"
+ :regexp "^\\(?:Deleted breakpoints? \\(\\([0-9]+ *\\)+\\)
*\\)\\{1,2\\}\n"
:num 1))
(defconst realgud:gdb-frame-start-regexp