* [PATCH: gdb/mi] gdb-mi.el
@ 2005-03-02 8:18 Nick Roberts
2005-03-19 3:56 ` Nick Roberts
0 siblings, 1 reply; 6+ messages in thread
From: Nick Roberts @ 2005-03-02 8:18 UTC (permalink / raw)
To: gdb-patches
This patch updates gdb-mi.el so that it works again with Emacs in the CVS
repository at Savannah (Emacs 22.0.50) which, hopefully, will be released, one
day, as Emacs 22. I plan to update this file to reflect the current and future
changes I make for MI in GDB. The slow release cycle of Emacs makes it
impossible to track these changes from the Emacs side.
Nick
Comment from gdb-mi.el:
;; This file uses GDB/MI as the primary interface to GDB. It is still under
;; development and is part of a process to migrate Emacs from annotations
;; (as used in gdb-ui.el) to GDB/MI.
*** /home/nick/src/gdb/mi/gdb-mi.el.~1.1.~ 2004-07-27 09:52:34.000000000 +1200
--- /home/nick/src/gdb/mi/gdb-mi.el 2005-03-02 20:53:40.000000000 +1300
***************
*** 1,4 ****
! ;;; gdb-mi.el (internally gdbmi6.el) - (24th May 2004)
;; Run gdb with GDB/MI (-interp=mi) and access CLI using "cli-command"
;; (could use "-interpreter-exec console cli-command")
--- 1,4 ----
! ;;; gdb-mi.el
;; Run gdb with GDB/MI (-interp=mi) and access CLI using "cli-command"
;; (could use "-interpreter-exec console cli-command")
***************
*** 7,13 ****
;; Maintainer: Nick Roberts <nickrob@gnu.org>
;; Keywords: unix, tools
! ;; Copyright (C) 2004 Free Software Foundation, Inc.
;; This file is part of GNU GDB.
--- 7,13 ----
;; Maintainer: Nick Roberts <nickrob@gnu.org>
;; Keywords: unix, tools
! ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
;; This file is part of GNU GDB.
***************
*** 23,36 ****
;;; Commentary:
! ;; This mode acts as a graphical user interface to GDB and requires GDB 6.1
! ;; onwards. You can interact with GDB through the GUD buffer in the usual way,
! ;; but there are also buffers which control the execution and describe the
! ;; state of your program. It separates the input/output of your program from
! ;; that of GDB and displays expressions and their current values in their own
! ;; buffers. It also uses features of Emacs 21 such as the fringe/display
! ;; margin for breakpoints, and the toolbar (see the GDB Graphical Interface
! ;; section in the Emacs info manual).
;; Start the debugger with M-x gdbmi.
--- 23,37 ----
;;; Commentary:
! ;; This mode acts as a graphical user interface to GDB and should work with
! ;; Emacs 22.0 and the version of GDB with which it is distributed. You can
! ;; interact with GDB through the GUD buffer in the usual way, but there are
! ;; also buffers which control the execution and describe the state of your
! ;; program. It separates the input/output of your program from that of GDB and
! ;; displays expressions and their current values in their own buffers. It also
! ;; uses features of Emacs 21 such as the fringe/display margin for
! ;; breakpoints, and the toolbar (see the GDB Graphical Interface section in
! ;; the Emacs info manual).
;; Start the debugger with M-x gdbmi.
***************
*** 40,46 ****
;; Known Bugs:
;;
!
;;; Code:
(require 'gud)
--- 41,53 ----
;; Known Bugs:
;;
! ;; 1) You cannot use run, step, next or continue in the GUD buffer but
! ;; must use their MI counterparts by clicking on the appropriate icon
! ;; in the toolbar.
! ;;
! ;; 2) Cannot display correct frame with gdb-frames-select (mouse-2 in Frames
! ;; buffer) or up/down in GUD buffer. Needs event notification in MI.
! ;;
;;; Code:
(require 'gud)
***************
*** 106,111 ****
--- 113,129 ----
(set (make-local-variable 'gud-minor-mode) 'gdbmi)
(set (make-local-variable 'gud-marker-filter) 'gud-gdbmi-marker-filter)
;;
+ (gud-def gud-step "-exec-step %p" "\C-s"
+ "Step one source line with display.")
+ (gud-def gud-stepi "-exec-step-instruction %p" "\C-i"
+ "Step one instruction with display.")
+ (gud-def gud-next "-exec-next %p" "\C-n"
+ "Step one line (skip functions).")
+ (gud-def gud-cont "-exec-continue" "\C-r"
+ "Continue with display.")
+ (gud-def gud-finish "-exec-finish" "\C-f"
+ "Finish executing current function.")
+ (gud-def gud-run "-exec-run" nil "Run the program.")
(gud-def gud-break (if (not (string-equal mode-name "Machine"))
(gud-call "-break-insert %f:%l" arg)
(save-excursion
***************
*** 152,157 ****
--- 170,179 ----
(setq gdb-pending-triggers nil)
(setq gdb-output-sink 'user)
(setq gdb-server-prefix nil)
+ (setq gdb-flush-pending-output nil)
+ (setq gdb-location-list nil)
+ (setq gdb-find-file-unhook nil)
+ (setq gdb-source-file-list nil)
;;
(setq gdb-buffer-type 'gdbmi)
;;
***************
*** 160,187 ****
;;
(if (eq window-system 'w32)
(gdb-enqueue-input (list "-gdb-set new-console off\n" 'ignore)))
;; find source file and compilation directory here
! (gdb-enqueue-input (list "list main\n" 'ignore)) ; C program
! (gdb-enqueue-input (list "list MAIN__\n" 'ignore)) ; Fortran program
! (gdb-enqueue-input (list "info source\n" 'gdbmi-source-info))
;;
(run-hooks 'gdbmi-mode-hook))
; Force nil till fixed.
(defconst gdbmi-use-inferior-io-buffer nil)
! ; uses --all-values Needs GDB 6.1 onwards.
(defun gdbmi-var-list-children (varnum)
(gdb-enqueue-input
(list (concat "-var-update " varnum "\n") 'ignore))
(gdb-enqueue-input
! (list (concat "-var-list-children --all-values "
varnum "\n")
`(lambda () (gdbmi-var-list-children-handler ,varnum)))))
(defconst gdbmi-var-list-children-regexp
! "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",value=\"\\(.*?\\)\""
! )
(defun gdbmi-var-list-children-handler (varnum)
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
--- 182,211 ----
;;
(if (eq window-system 'w32)
(gdb-enqueue-input (list "-gdb-set new-console off\n" 'ignore)))
+ (gdb-enqueue-input (list "-gdb-set height 0\n" 'ignore))
;; find source file and compilation directory here
! (gdb-enqueue-input
! (list "-file-list-exec-source-files\n" 'gdb-get-source-file-list))
! (gdb-enqueue-input
! (list "-file-list-exec-source-file\n" 'gdb-get-source-file))
;;
(run-hooks 'gdbmi-mode-hook))
; Force nil till fixed.
(defconst gdbmi-use-inferior-io-buffer nil)
! ; uses -var-list-children 1 (= --with-values) Needs GDB 6.1 onwards.
(defun gdbmi-var-list-children (varnum)
(gdb-enqueue-input
(list (concat "-var-update " varnum "\n") 'ignore))
(gdb-enqueue-input
! (list (concat "-var-list-children 1 "
varnum "\n")
`(lambda () (gdbmi-var-list-children-handler ,varnum)))))
(defconst gdbmi-var-list-children-regexp
! "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",\
! value=\"\\(.*?\\)\"")
(defun gdbmi-var-list-children-handler (varnum)
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
***************
*** 226,233 ****
:type 'string
:group 'gud)
! (defconst gdb-stopped-regexp
! "\\((gdb) \n\\*stopped\\|^\\^done\\),reason=.*,file=\"\\(.*\\)\",line=\"\\(.*\\)\".*")
(defconst gdb-console-regexp "~\"\\(.*\\)\\\\n\"")
--- 250,257 ----
:type 'string
:group 'gud)
! (defconst gdb-stopped-regexp
! "\\(\\*stopped\\|^\\^done\\),reason=.*,file=\"\\(.*\\)\",line=\"\\(.*\\)\".*")
(defconst gdb-console-regexp "~\"\\(.*\\)\\\\n\"")
***************
*** 245,256 ****
(gdbmi-invalidate-frames)
(gdbmi-invalidate-breakpoints)
(gdbmi-invalidate-locals)
! (dolist (frame (frame-list))
! (when (string-equal (frame-parameter frame 'name) "Speedbar")
! (setq gdb-var-changed t) ; force update
! (dolist (var gdb-var-list)
! (setcar (nthcdr 5 var) nil))))
! (gdb-var-update))
(let ((sink gdb-output-sink))
(when (eq sink 'emacs)
(let ((handler
--- 269,279 ----
(gdbmi-invalidate-frames)
(gdbmi-invalidate-breakpoints)
(gdbmi-invalidate-locals)
! (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
! (setq gdb-var-changed t) ; force update
! (dolist (var gdb-var-list)
! (setcar (nthcdr 5 var) nil))
! (gdb-var-update)))
(let ((sink gdb-output-sink))
(when (eq sink 'emacs)
(let ((handler
***************
*** 267,325 ****
(defun gud-gdbmi-marker-filter (string)
"Filter GDB/MI output."
! (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
! ;; Recall the left over gud-marker-acc from last time
! (setq gud-marker-acc (concat gud-marker-acc string))
! ;; Start accumulating output for the GUD buffer
! (let ((output ""))
!
! (if (string-match gdb-running-regexp gud-marker-acc)
! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))
! gud-running t))
!
! ;; Remove the trimmings from the console stream.
! (while (string-match gdb-console-regexp gud-marker-acc)
! (setq
! gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
! (match-string 1 gud-marker-acc)
! (substring gud-marker-acc (match-end 0)))))
!
! ;; Remove log stream containing debugging messages being produced by GDB's
! ;; internals.
! (while (string-match gdb-internals-regexp gud-marker-acc)
! (setq
gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
(substring gud-marker-acc (match-end 0)))))
! (if (string-match gdb-stopped-regexp gud-marker-acc)
! (setq
! ;; Extract the frame position from the marker.
! gud-last-frame (cons (match-string 2 gud-marker-acc)
! (string-to-int (match-string 3 gud-marker-acc)))
!
! ;; Append any text before the marker to the output we're going
! ;; to return - we don't include the marker in this text.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (match-beginning 0)))
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0))))
!
! (while (string-match gdb-gdb-regexp gud-marker-acc)
! (setq
! ;; Append any text up to and including prompt less \n to the output.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (- (match-end 0) 1)))
!
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0)))
! (gdbmi-prompt))
!
! (setq output (gdbmi-concat-output output gud-marker-acc))
! (setq gud-marker-acc "")
! output))
(defun gdbmi-concat-output (so-far new)
(let ((sink gdb-output-sink))
--- 290,351 ----
(defun gud-gdbmi-marker-filter (string)
"Filter GDB/MI output."
! (if gdb-flush-pending-output
! nil
! (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
! ;; Recall the left over gud-marker-acc from last time
! (setq gud-marker-acc (concat gud-marker-acc string))
! ;; Start accumulating output for the GUD buffer
! (let ((output ""))
!
! (if (string-match gdb-running-regexp gud-marker-acc)
! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))
! gud-running t))
!
! ;; Remove the trimmings from the console stream.
! (while (string-match gdb-console-regexp gud-marker-acc)
! (setq
gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
+ (match-string 1 gud-marker-acc)
(substring gud-marker-acc (match-end 0)))))
! ;; Remove log stream containing debugging messages being produced by GDB's
! ;; internals.
! (while (string-match gdb-internals-regexp gud-marker-acc)
! (setq
! gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
! (substring gud-marker-acc (match-end 0)))))
! (if (string-match gdb-stopped-regexp gud-marker-acc)
! (setq
! ;; Extract the frame position from the marker.
! gud-last-frame (cons (match-string 2 gud-marker-acc)
! (string-to-int (match-string 3 gud-marker-acc)))
!
! ;; Append any text before the marker to the output we're going
! ;; to return - we don't include the marker in this text.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (match-beginning 0)))
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0))))
!
! (if (string-match gdb-gdb-regexp gud-marker-acc)
! (progn
! (setq
!
! ;; Append any text up to and including prompt less \n to the output.
! output (gdbmi-concat-output
! output (substring gud-marker-acc 0 (- (match-end 0) 1)))
!
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0)))
! (gdbmi-prompt))
!
! (setq output (gdbmi-concat-output output gud-marker-acc))
! (setq gud-marker-acc ""))
! output)))
(defun gdbmi-concat-output (so-far new)
(let ((sink gdb-output-sink))
***************
*** 354,366 ****
gdb-break-list-custom)
(defconst gdb-break-list-regexp
! "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-break-list-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints
gdb-pending-triggers))
! (let ((breakpoint nil)
! (breakpoints-list nil))
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
(while (re-search-forward gdb-break-list-regexp nil t)
--- 380,392 ----
gdb-break-list-custom)
(defconst gdb-break-list-regexp
! "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",\
! addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-break-list-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints
gdb-pending-triggers))
! (let ((breakpoint) (breakpoints-list))
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
(while (re-search-forward gdb-break-list-regexp nil t)
***************
*** 393,399 ****
;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
(defun gdb-break-list-custom ()
! (let ((flag)(address))
;;
;; remove all breakpoint-icons in source buffers but not assembler buffer
(dolist (buffer (buffer-list))
--- 419,425 ----
;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
(defun gdb-break-list-custom ()
! (let ((flag) (bptno))
;;
;; remove all breakpoint-icons in source buffers but not assembler buffer
(dolist (buffer (buffer-list))
***************
*** 406,434 ****
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
! (if (looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)")
(progn
! (setq flag (char-after (match-beginning 1)))
! (let ((line (match-string 3)) (buffer-read-only nil)
! (file (match-string 2)))
(add-text-properties (point-at-bol) (point-at-eol)
! '(mouse-face highlight
! help-echo "mouse-2, RET: visit breakpoint"))
! (with-current-buffer
! (find-file-noselect
! (if (file-exists-p file) file
! (expand-file-name file gdb-cdir)))
! (save-current-buffer
! (set (make-local-variable 'gud-minor-mode) 'gdbmi)
! (set (make-local-variable 'tool-bar-map)
! gud-tool-bar-map))
! ;; only want one breakpoint icon at each location
! (save-excursion
! (goto-line (string-to-number line))
! (gdb-put-breakpoint-icon (eq flag ?y)))))))))
! (end-of-line)))
(if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
;; Frames buffer. This displays a perpetually correct bactrack trace.
;;
(def-gdb-auto-updated-buffer gdb-stack-buffer
--- 432,492 ----
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
! (if (looking-at
! "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\
! \\(\\S-+\\):\\([0-9]+\\)")
(progn
! (setq bptno (match-string 1))
! (setq flag (char-after (match-beginning 2)))
! (let ((line (match-string 4)) (buffer-read-only nil)
! (file (match-string 3)))
(add-text-properties (point-at-bol) (point-at-eol)
! '(mouse-face highlight
! help-echo "mouse-2, RET: visit breakpoint"))
! (unless (file-exists-p file)
! (setq file (cdr (assoc bptno gdb-location-list))))
! (unless (string-equal file "File not found")
! (if file
! (with-current-buffer (find-file-noselect file)
! (set (make-local-variable 'gud-minor-mode)
! 'gdbmi)
! (set (make-local-variable 'tool-bar-map)
! gud-tool-bar-map)
! ;; only want one breakpoint icon at each location
! (save-excursion
! (goto-line (string-to-number line))
! (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
! (gdb-enqueue-input
! (list (concat "list "
! (match-string-no-properties 3) ":1\n")
! 'ignore))
! (gdb-enqueue-input
! (list "-file-list-exec-source-file\n"
! `(lambda () (gdbmi-get-location
! ,bptno ,line ,flag)))))))))))
! (end-of-line)))
(if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
+ (defun gdbmi-get-location (bptno line flag)
+ "Find the directory containing the relevant source file.
+ Put in buffer and place breakpoint icon."
+ (goto-char (point-min))
+ (if (re-search-forward gdb-source-file-regexp nil t)
+ (push (cons bptno (match-string 1)) gdb-location-list)
+ (gdb-resync)
+ (push (cons bptno "File not found") gdb-location-list)
+ (error "Cannot find source file for breakpoint location.
+ Add directory to search path for source files using the GDB command, dir."))
+ (with-current-buffer
+ (find-file-noselect (match-string 0))
+ (save-current-buffer
+ (set (make-local-variable 'gud-minor-mode) 'gdbmi)
+ (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
+ ;; only want one breakpoint icon at each location
+ (save-excursion
+ (goto-line (string-to-number line))
+ (gdb-put-breakpoint-icon (eq flag ?y) bptno))))
+
;; Frames buffer. This displays a perpetually correct bactrack trace.
;;
(def-gdb-auto-updated-buffer gdb-stack-buffer
***************
*** 438,444 ****
gdb-stack-list-frames-custom)
(defconst gdb-stack-list-frames-regexp
! "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-stack-list-frames-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-frames
--- 496,503 ----
gdb-stack-list-frames-custom)
(defconst gdb-stack-list-frames-regexp
! "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",\
! file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-stack-list-frames-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-frames
***************
*** 564,568 ****
--- 623,654 ----
(gdb-get-create-buffer 'gdb-assembler-buffer)))
(other-window 1))))
+ \f
+ ;; these functions/variables may go into gdb-ui.el in the near future
+ ;; (from gdb-nui.el)
+
+ (defvar gdb-source-file-list nil)
+ (defvar gdb-source-file-regexp "fullname=\"\\(.*?\\)\"")
+
+ (defun gdb-get-source-file ()
+ "Find the source file where the program starts and display it with related
+ buffers, if required."
+ (goto-char (point-min))
+ (if (re-search-forward gdb-source-file-regexp nil t)
+ (setq gdb-main-file (match-string 1)))
+ (if gdb-many-windows
+ (gdb-setup-windows)
+ (gdb-get-create-buffer 'gdb-breakpoints-buffer)
+ (if gdb-show-main
+ (let ((pop-up-windows t))
+ (display-buffer (gud-find-file gdb-main-file))))))
+
+ (defun gdb-get-source-file-list ()
+ "Create list of source files for current GDB session."
+ (goto-char (point-min))
+ (while (re-search-forward gdb-source-file-regexp nil t)
+ (push (match-string 1) gdb-source-file-list)))
+
+
(provide 'gdb-mi)
;;; gdbmi.el ends here
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH: gdb/mi] gdb-mi.el
2005-03-02 8:18 [PATCH: gdb/mi] gdb-mi.el Nick Roberts
@ 2005-03-19 3:56 ` Nick Roberts
2005-04-30 19:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Nick Roberts @ 2005-03-19 3:56 UTC (permalink / raw)
To: gdb-patches
Nick Roberts (2 Mar 2005) writes:
> This patch updates gdb-mi.el so that it works again with Emacs in the CVS
> repository at Savannah (Emacs 22.0.50) which, hopefully, will be released,
> one day, as Emacs 22. I plan to update this file to reflect the current and
> future changes I make for MI in GDB. The slow release cycle of Emacs makes
> it impossible to track these changes from the Emacs side.
>
> Nick
>
> Comment from gdb-mi.el:
> ;; This file uses GDB/MI as the primary interface to GDB. It is still under
> ;; development and is part of a process to migrate Emacs from annotations
> ;; (as used in gdb-ui.el) to GDB/MI.
I've updated this patch to include the new option to the MI command,
-var-update, that I've described in my previous post.
As this file is separate code, it can't break GDB. Could a global maintainer
please authorise this commit.
Nick
*** /home/nick/src/gdb/mi/gdb-mi.el.~1.1.~ 2004-07-27 09:52:34.000000000 +1200
--- /home/nick/src/gdb/mi/gdb-mi.el 2005-03-08 19:05:59.000000000 +1300
***************
*** 1,4 ****
! ;;; gdb-mi.el (internally gdbmi6.el) - (24th May 2004)
;; Run gdb with GDB/MI (-interp=mi) and access CLI using "cli-command"
;; (could use "-interpreter-exec console cli-command")
--- 1,4 ----
! ;;; gdb-mi.el
;; Run gdb with GDB/MI (-interp=mi) and access CLI using "cli-command"
;; (could use "-interpreter-exec console cli-command")
***************
*** 7,13 ****
;; Maintainer: Nick Roberts <nickrob@gnu.org>
;; Keywords: unix, tools
! ;; Copyright (C) 2004 Free Software Foundation, Inc.
;; This file is part of GNU GDB.
--- 7,13 ----
;; Maintainer: Nick Roberts <nickrob@gnu.org>
;; Keywords: unix, tools
! ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
;; This file is part of GNU GDB.
***************
*** 23,36 ****
;;; Commentary:
! ;; This mode acts as a graphical user interface to GDB and requires GDB 6.1
! ;; onwards. You can interact with GDB through the GUD buffer in the usual way,
! ;; but there are also buffers which control the execution and describe the
! ;; state of your program. It separates the input/output of your program from
! ;; that of GDB and displays expressions and their current values in their own
! ;; buffers. It also uses features of Emacs 21 such as the fringe/display
! ;; margin for breakpoints, and the toolbar (see the GDB Graphical Interface
! ;; section in the Emacs info manual).
;; Start the debugger with M-x gdbmi.
--- 23,37 ----
;;; Commentary:
! ;; This mode acts as a graphical user interface to GDB and should work with
! ;; Emacs 22.0 and the version of GDB with which it is distributed. You can
! ;; interact with GDB through the GUD buffer in the usual way, but there are
! ;; also buffers which control the execution and describe the state of your
! ;; program. It separates the input/output of your program from that of GDB and
! ;; displays expressions and their current values in their own buffers. It also
! ;; uses features of Emacs 21 such as the fringe/display margin for
! ;; breakpoints, and the toolbar (see the GDB Graphical Interface section in
! ;; the Emacs info manual).
;; Start the debugger with M-x gdbmi.
***************
*** 40,46 ****
;; Known Bugs:
;;
!
;;; Code:
(require 'gud)
--- 41,57 ----
;; Known Bugs:
;;
! ;; 1) You CANNOT use run, step, next or continue in the GUD buffer but
! ;; MUST use their MI counterparts through gud-run, gud-step etc,
! ;; e.g clicking on the appropriate icon in the toolbar.
! ;;
! ;; 2) Cannot display correct frame with gdb-frames-select (mouse-2 in Frames
! ;; buffer) or up/down in GUD buffer. Needs event notification in MI.
! ;;
! ;; TODO:
! ;;
! ;; Lots of things.
! ;;
;;; Code:
(require 'gud)
***************
*** 106,111 ****
--- 117,133 ----
(set (make-local-variable 'gud-minor-mode) 'gdbmi)
(set (make-local-variable 'gud-marker-filter) 'gud-gdbmi-marker-filter)
;;
+ (gud-def gud-step "-exec-step %p" "\C-s"
+ "Step one source line with display.")
+ (gud-def gud-stepi "-exec-step-instruction %p" "\C-i"
+ "Step one instruction with display.")
+ (gud-def gud-next "-exec-next %p" "\C-n"
+ "Step one line (skip functions).")
+ (gud-def gud-cont "-exec-continue" "\C-r"
+ "Continue with display.")
+ (gud-def gud-finish "-exec-finish" "\C-f"
+ "Finish executing current function.")
+ (gud-def gud-run "-exec-run" nil "Run the program.")
(gud-def gud-break (if (not (string-equal mode-name "Machine"))
(gud-call "-break-insert %f:%l" arg)
(save-excursion
***************
*** 142,150 ****
(setq gdb-current-address "main")
(setq gdb-previous-address nil)
(setq gdb-previous-frame nil)
! (setq gdb-current-frame "main")
! (setq gdb-view-source t)
! (setq gdb-selected-view 'source)
(setq gdb-var-list nil)
(setq gdb-var-changed nil)
(setq gdb-prompting nil)
--- 164,171 ----
(setq gdb-current-address "main")
(setq gdb-previous-address nil)
(setq gdb-previous-frame nil)
! (setq gdb-current-frame nil)
! (setq gdb-current-stack-level nil)
(setq gdb-var-list nil)
(setq gdb-var-changed nil)
(setq gdb-prompting nil)
***************
*** 152,157 ****
--- 173,182 ----
(setq gdb-pending-triggers nil)
(setq gdb-output-sink 'user)
(setq gdb-server-prefix nil)
+ (setq gdb-flush-pending-output nil)
+ (setq gdb-location-list nil)
+ (setq gdb-find-file-unhook nil)
+ (setq gdb-source-file-list nil)
;;
(setq gdb-buffer-type 'gdbmi)
;;
***************
*** 160,187 ****
;;
(if (eq window-system 'w32)
(gdb-enqueue-input (list "-gdb-set new-console off\n" 'ignore)))
;; find source file and compilation directory here
! (gdb-enqueue-input (list "list main\n" 'ignore)) ; C program
! (gdb-enqueue-input (list "list MAIN__\n" 'ignore)) ; Fortran program
! (gdb-enqueue-input (list "info source\n" 'gdbmi-source-info))
;;
(run-hooks 'gdbmi-mode-hook))
; Force nil till fixed.
(defconst gdbmi-use-inferior-io-buffer nil)
! ; uses --all-values Needs GDB 6.1 onwards.
(defun gdbmi-var-list-children (varnum)
(gdb-enqueue-input
(list (concat "-var-update " varnum "\n") 'ignore))
(gdb-enqueue-input
! (list (concat "-var-list-children --all-values "
varnum "\n")
`(lambda () (gdbmi-var-list-children-handler ,varnum)))))
(defconst gdbmi-var-list-children-regexp
! "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",value=\"\\(.*?\\)\""
! )
(defun gdbmi-var-list-children-handler (varnum)
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
--- 185,214 ----
;;
(if (eq window-system 'w32)
(gdb-enqueue-input (list "-gdb-set new-console off\n" 'ignore)))
+ (gdb-enqueue-input (list "-gdb-set height 0\n" 'ignore))
;; find source file and compilation directory here
! (gdb-enqueue-input
! (list "-file-list-exec-source-files\n" 'gdb-get-source-file-list))
! (gdb-enqueue-input
! (list "-file-list-exec-source-file\n" 'gdb-get-source-file))
;;
(run-hooks 'gdbmi-mode-hook))
; Force nil till fixed.
(defconst gdbmi-use-inferior-io-buffer nil)
! ; uses -var-list-children 1 (= --with-values) Needs GDB 6.1 onwards.
(defun gdbmi-var-list-children (varnum)
(gdb-enqueue-input
(list (concat "-var-update " varnum "\n") 'ignore))
(gdb-enqueue-input
! (list (concat "-var-list-children 1 "
varnum "\n")
`(lambda () (gdbmi-var-list-children-handler ,varnum)))))
(defconst gdbmi-var-list-children-regexp
! "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",\
! value=\"\\(.*?\\)\"")
(defun gdbmi-var-list-children-handler (varnum)
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
***************
*** 208,213 ****
--- 235,273 ----
(push var var-list)))
(setq gdb-var-changed t)
(setq gdb-var-list (nreverse var-list))))))
+
+ ; uses -var-update --with-values Needs CVS GDB (6.4+).
+ (defun gdbmi-var-update ()
+ (unless (member 'gdbmi-var-update gdb-pending-triggers)
+ (gdb-enqueue-input
+ (list "-var-update --with-values *\n" 'gdbmi-var-update-handler))
+ (push 'gdbmi-var-update gdb-pending-triggers)))
+
+ (defconst gdbmi-var-update-regexp "name=\"\\(.*?\\)\",value=\"\\(.*?\\)\"")
+
+ (defun gdbmi-var-update-handler ()
+ (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
+ (goto-char (point-min))
+ (while (re-search-forward gdbmi-var-update-regexp nil t)
+ (let ((varnum (match-string 1)))
+ (catch 'var-found1
+ (let ((num 0))
+ (dolist (var gdb-var-list)
+ (if (string-equal varnum (cadr var))
+ (progn
+ (setcar (nthcdr 5 var) t)
+ (setcar (nthcdr 4 var) (match-string 2))
+ (setcar (nthcdr num gdb-var-list) var)
+ (throw 'var-found1 nil)))
+ (setq num (+ num 1))))))
+ (setq gdb-var-changed t)))
+ (setq gdb-pending-triggers
+ (delq 'gdbmi-var-update gdb-pending-triggers))
+ (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
+ ;; dummy command to update speedbar at right time
+ (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn))
+ ;; keep gdb-pending-triggers non-nil till end
+ (push 'gdb-speedbar-timer gdb-pending-triggers)))
\f
;(defun gdbmi-send (proc string)
; "A comint send filter for gdb."
***************
*** 219,224 ****
--- 279,286 ----
"A comint send filter for gdb."
(setq gdb-output-sink 'user)
(setq gdb-prompting nil)
+ (if gdb-enable-debug-log
+ (push (cons 'mi-send (concat string "\n")) gdb-debug-log))
(process-send-string proc (concat string "\n")))
(defcustom gud-gdbmi-command-name "~/gdb/gdb/gdb -interp=mi"
***************
*** 226,233 ****
:type 'string
:group 'gud)
! (defconst gdb-stopped-regexp
! "\\((gdb) \n\\*stopped\\|^\\^done\\),reason=.*,file=\"\\(.*\\)\",line=\"\\(.*\\)\".*")
(defconst gdb-console-regexp "~\"\\(.*\\)\\\\n\"")
--- 288,295 ----
:type 'string
:group 'gud)
! (defconst gdb-stopped-regexp
! "\\(\\*stopped\\|^\\^done\\),reason=.*,file=\"\\(.*\\)\",line=\"\\(.*\\)\".*")
(defconst gdb-console-regexp "~\"\\(.*\\)\\\\n\"")
***************
*** 235,241 ****
(defconst gdb-gdb-regexp "(gdb) \n")
! (defconst gdb-running-regexp "^\\^running")
(defun gdbmi-prompt ()
"This handler terminates the any collection of output. It also
--- 297,303 ----
(defconst gdb-gdb-regexp "(gdb) \n")
! (defconst gdb-running-regexp "^\\^running\n(gdb) ")
(defun gdbmi-prompt ()
"This handler terminates the any collection of output. It also
***************
*** 245,256 ****
(gdbmi-invalidate-frames)
(gdbmi-invalidate-breakpoints)
(gdbmi-invalidate-locals)
! (dolist (frame (frame-list))
! (when (string-equal (frame-parameter frame 'name) "Speedbar")
! (setq gdb-var-changed t) ; force update
! (dolist (var gdb-var-list)
! (setcar (nthcdr 5 var) nil))))
! (gdb-var-update))
(let ((sink gdb-output-sink))
(when (eq sink 'emacs)
(let ((handler
--- 307,317 ----
(gdbmi-invalidate-frames)
(gdbmi-invalidate-breakpoints)
(gdbmi-invalidate-locals)
! (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
! (setq gdb-var-changed t) ; force update
! (dolist (var gdb-var-list)
! (setcar (nthcdr 5 var) nil))
! (gdbmi-var-update)))
(let ((sink gdb-output-sink))
(when (eq sink 'emacs)
(let ((handler
***************
*** 267,325 ****
(defun gud-gdbmi-marker-filter (string)
"Filter GDB/MI output."
! (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
! ;; Recall the left over gud-marker-acc from last time
! (setq gud-marker-acc (concat gud-marker-acc string))
! ;; Start accumulating output for the GUD buffer
! (let ((output ""))
!
! (if (string-match gdb-running-regexp gud-marker-acc)
! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))
! gud-running t))
!
! ;; Remove the trimmings from the console stream.
! (while (string-match gdb-console-regexp gud-marker-acc)
! (setq
! gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
! (match-string 1 gud-marker-acc)
! (substring gud-marker-acc (match-end 0)))))
!
! ;; Remove log stream containing debugging messages being produced by GDB's
! ;; internals.
! (while (string-match gdb-internals-regexp gud-marker-acc)
! (setq
gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
(substring gud-marker-acc (match-end 0)))))
! (if (string-match gdb-stopped-regexp gud-marker-acc)
! (setq
! ;; Extract the frame position from the marker.
! gud-last-frame (cons (match-string 2 gud-marker-acc)
! (string-to-int (match-string 3 gud-marker-acc)))
!
! ;; Append any text before the marker to the output we're going
! ;; to return - we don't include the marker in this text.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (match-beginning 0)))
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0))))
! (while (string-match gdb-gdb-regexp gud-marker-acc)
! (setq
!
! ;; Append any text up to and including prompt less \n to the output.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (- (match-end 0) 1)))
!
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0)))
! (gdbmi-prompt))
!
! (setq output (gdbmi-concat-output output gud-marker-acc))
! (setq gud-marker-acc "")
! output))
(defun gdbmi-concat-output (so-far new)
(let ((sink gdb-output-sink))
--- 328,390 ----
(defun gud-gdbmi-marker-filter (string)
"Filter GDB/MI output."
! (if gdb-flush-pending-output
! nil
! (if gdb-enable-debug-log (push (cons 'recv (list string gdb-output-sink))
! gdb-debug-log))
! ;; Recall the left over gud-marker-acc from last time
! (setq gud-marker-acc (concat gud-marker-acc string))
! ;; Start accumulating output for the GUD buffer
! (let ((output ""))
!
! (if (string-match gdb-running-regexp gud-marker-acc)
! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))
! gud-running t))
!
! ;; Remove the trimmings from the console stream.
! (while (string-match gdb-console-regexp gud-marker-acc)
! (setq
! gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
! (match-string 1 gud-marker-acc)
! (substring gud-marker-acc (match-end 0)))))
!
! ;; Remove log stream containing debugging messages being produced by GDB's
! ;; internals.
! (while (string-match gdb-internals-regexp gud-marker-acc)
! (setq
gud-marker-acc (concat (substring gud-marker-acc 0 (match-beginning 0))
(substring gud-marker-acc (match-end 0)))))
! (if (string-match gdb-stopped-regexp gud-marker-acc)
! (setq
! ;; Extract the frame position from the marker.
! gud-last-frame (cons (match-string 2 gud-marker-acc)
! (string-to-int (match-string 3 gud-marker-acc)))
!
! ;; Append any text before the marker to the output we're going
! ;; to return - we don't include the marker in this text.
! output (gdbmi-concat-output output
! (substring gud-marker-acc 0 (match-beginning 0)))
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0))))
! (if (string-match gdb-gdb-regexp gud-marker-acc)
! (progn
! (setq
!
! ;; Append any text up to and including prompt less \n to the output.
! output (gdbmi-concat-output
! output (substring gud-marker-acc 0 (- (match-end 0) 1)))
!
! ;; Set the accumulator to the remaining text.
! gud-marker-acc (substring gud-marker-acc (match-end 0)))
! (gdbmi-prompt))
!
! (setq output (gdbmi-concat-output output gud-marker-acc))
! (setq gud-marker-acc ""))
! output)))
(defun gdbmi-concat-output (so-far new)
(let ((sink gdb-output-sink))
***************
*** 354,366 ****
gdb-break-list-custom)
(defconst gdb-break-list-regexp
! "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-break-list-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints
gdb-pending-triggers))
! (let ((breakpoint nil)
! (breakpoints-list nil))
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
(while (re-search-forward gdb-break-list-regexp nil t)
--- 419,431 ----
gdb-break-list-custom)
(defconst gdb-break-list-regexp
! "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",\
! addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-break-list-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints
gdb-pending-triggers))
! (let ((breakpoint) (breakpoints-list))
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
(while (re-search-forward gdb-break-list-regexp nil t)
***************
*** 393,399 ****
;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
(defun gdb-break-list-custom ()
! (let ((flag)(address))
;;
;; remove all breakpoint-icons in source buffers but not assembler buffer
(dolist (buffer (buffer-list))
--- 458,464 ----
;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
(defun gdb-break-list-custom ()
! (let ((flag) (bptno))
;;
;; remove all breakpoint-icons in source buffers but not assembler buffer
(dolist (buffer (buffer-list))
***************
*** 406,434 ****
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
! (if (looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)")
(progn
! (setq flag (char-after (match-beginning 1)))
! (let ((line (match-string 3)) (buffer-read-only nil)
! (file (match-string 2)))
(add-text-properties (point-at-bol) (point-at-eol)
! '(mouse-face highlight
! help-echo "mouse-2, RET: visit breakpoint"))
! (with-current-buffer
! (find-file-noselect
! (if (file-exists-p file) file
! (expand-file-name file gdb-cdir)))
! (save-current-buffer
! (set (make-local-variable 'gud-minor-mode) 'gdbmi)
! (set (make-local-variable 'tool-bar-map)
! gud-tool-bar-map))
! ;; only want one breakpoint icon at each location
! (save-excursion
! (goto-line (string-to-number line))
! (gdb-put-breakpoint-icon (eq flag ?y)))))))))
! (end-of-line)))
(if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
;; Frames buffer. This displays a perpetually correct bactrack trace.
;;
(def-gdb-auto-updated-buffer gdb-stack-buffer
--- 471,531 ----
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
! (if (looking-at
! "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\
! \\(\\S-+\\):\\([0-9]+\\)")
(progn
! (setq bptno (match-string 1))
! (setq flag (char-after (match-beginning 2)))
! (let ((line (match-string 4)) (buffer-read-only nil)
! (file (match-string 3)))
(add-text-properties (point-at-bol) (point-at-eol)
! '(mouse-face highlight
! help-echo "mouse-2, RET: visit breakpoint"))
! (unless (file-exists-p file)
! (setq file (cdr (assoc bptno gdb-location-list))))
! (unless (string-equal file "File not found")
! (if file
! (with-current-buffer (find-file-noselect file)
! (set (make-local-variable 'gud-minor-mode)
! 'gdbmi)
! (set (make-local-variable 'tool-bar-map)
! gud-tool-bar-map)
! ;; only want one breakpoint icon at each location
! (save-excursion
! (goto-line (string-to-number line))
! (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
! (gdb-enqueue-input
! (list (concat "list "
! (match-string-no-properties 3) ":1\n")
! 'ignore))
! (gdb-enqueue-input
! (list "-file-list-exec-source-file\n"
! `(lambda () (gdbmi-get-location
! ,bptno ,line ,flag)))))))))))
! (end-of-line)))
(if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
+ (defun gdbmi-get-location (bptno line flag)
+ "Find the directory containing the relevant source file.
+ Put in buffer and place breakpoint icon."
+ (goto-char (point-min))
+ (if (re-search-forward gdb-source-file-regexp nil t)
+ (push (cons bptno (match-string 1)) gdb-location-list)
+ (gdb-resync)
+ (push (cons bptno "File not found") gdb-location-list)
+ (error "Cannot find source file for breakpoint location.
+ Add directory to search path for source files using the GDB command, dir."))
+ (with-current-buffer
+ (find-file-noselect (match-string 0))
+ (save-current-buffer
+ (set (make-local-variable 'gud-minor-mode) 'gdbmi)
+ (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
+ ;; only want one breakpoint icon at each location
+ (save-excursion
+ (goto-line (string-to-number line))
+ (gdb-put-breakpoint-icon (eq flag ?y) bptno))))
+
;; Frames buffer. This displays a perpetually correct bactrack trace.
;;
(def-gdb-auto-updated-buffer gdb-stack-buffer
***************
*** 438,444 ****
gdb-stack-list-frames-custom)
(defconst gdb-stack-list-frames-regexp
! "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-stack-list-frames-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-frames
--- 535,542 ----
gdb-stack-list-frames-custom)
(defconst gdb-stack-list-frames-regexp
! "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",\
! file=\"\\(.*?\\)\",line=\"\\(.*?\\)\"")
(defun gdb-stack-list-frames-handler ()
(setq gdb-pending-triggers (delq 'gdbmi-invalidate-frames
***************
*** 532,568 ****
(defun gdb-stack-list-locals-custom ()
nil)
! (defun gdbmi-source-info ()
! "Find the source file where the program starts and displays it with related
! buffers."
! (goto-char (point-min))
! (if (search-forward "source file is " nil t)
! (if (looking-at "\\S-*")
! (setq gdb-main-file (match-string 0)))
! (setq gdb-view-source nil))
! (if (search-forward "directory is " nil t)
! (if (looking-at "\\S-*:\\(\\S-*\\)")
! (setq gdb-cdir (match-string 1))
! (looking-at "\\S-*")
! (setq gdb-cdir (match-string 0))))
!
! ;temporary heuristic
! (if gdb-main-file
! (setq gdb-main-file (expand-file-name gdb-main-file gdb-cdir)))
! (if gdb-many-windows
(gdb-setup-windows)
! (gdb-get-create-buffer 'gdb-breakpoints-buffer)
! (when gdb-show-main
! (switch-to-buffer gud-comint-buffer)
! (delete-other-windows)
! (split-window)
! (other-window 1)
! (switch-to-buffer
! (if gdb-view-source
! (gud-find-file gdb-main-file)
! (gdb-get-create-buffer 'gdb-assembler-buffer)))
! (other-window 1))))
(provide 'gdb-mi)
;;; gdbmi.el ends here
--- 630,661 ----
(defun gdb-stack-list-locals-custom ()
nil)
! \f
! ;; these functions/variables may go into gdb-ui.el in the near future
! ;; (from gdb-nui.el)
!
! (defvar gdb-source-file-list nil)
! (defvar gdb-source-file-regexp "fullname=\"\\(.*?\\)\"")
! (defun gdb-get-source-file ()
! "Find the source file where the program starts and display it with related
! buffers, if required."
! (goto-char (point-min))
! (if (re-search-forward gdb-source-file-regexp nil t)
! (setq gdb-main-file (match-string 1)))
! (if gdb-many-windows
(gdb-setup-windows)
! (gdb-get-create-buffer 'gdb-breakpoints-buffer)
! (if gdb-show-main
! (let ((pop-up-windows t))
! (display-buffer (gud-find-file gdb-main-file))))))
!
! (defun gdb-get-source-file-list ()
! "Create list of source files for current GDB session."
! (goto-char (point-min))
! (while (re-search-forward gdb-source-file-regexp nil t)
! (push (match-string 1) gdb-source-file-list)))
!
(provide 'gdb-mi)
;;; gdbmi.el ends here
Diff finished. Sat Mar 19 16:51:33 2005
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH: gdb/mi] gdb-mi.el
2005-03-19 3:56 ` Nick Roberts
@ 2005-04-30 19:53 ` Daniel Jacobowitz
2005-05-01 8:12 ` Nick Roberts
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2005-04-30 19:53 UTC (permalink / raw)
To: Nick Roberts; +Cc: gdb-patches
On Sat, Mar 19, 2005 at 04:54:11PM +1300, Nick Roberts wrote:
> Nick Roberts (2 Mar 2005) writes:
>
> > This patch updates gdb-mi.el so that it works again with Emacs in the CVS
> > repository at Savannah (Emacs 22.0.50) which, hopefully, will be released,
> > one day, as Emacs 22. I plan to update this file to reflect the current and
> > future changes I make for MI in GDB. The slow release cycle of Emacs makes
> > it impossible to track these changes from the Emacs side.
> >
> > Nick
> >
> > Comment from gdb-mi.el:
> > ;; This file uses GDB/MI as the primary interface to GDB. It is still under
> > ;; development and is part of a process to migrate Emacs from annotations
> > ;; (as used in gdb-ui.el) to GDB/MI.
>
> I've updated this patch to include the new option to the MI command,
> -var-update, that I've described in my previous post.
>
> As this file is separate code, it can't break GDB. Could a global maintainer
> please authorise this commit.
Could you please include a ChangeLog entry for the pdate?
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH: gdb/mi] gdb-mi.el
2005-04-30 19:53 ` Daniel Jacobowitz
@ 2005-05-01 8:12 ` Nick Roberts
2005-05-01 15:02 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Nick Roberts @ 2005-05-01 8:12 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> Could you please include a ChangeLog entry for the pdate?
2005-05-01 Nick Roberts <nickrob@snap.net.nz>
* mi/gdb-mi.el: Update for changes in Emacs 22.0.50.
Use "-var-update --with-values" for faster re-display of
watch expressions.
Please note that I have submitted a patch for "-var-update --with-values"
which is also waiting approval.
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH: gdb/mi] gdb-mi.el
2005-05-01 8:12 ` Nick Roberts
@ 2005-05-01 15:02 ` Daniel Jacobowitz
2005-05-02 4:38 ` Nick Roberts
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2005-05-01 15:02 UTC (permalink / raw)
To: Nick Roberts; +Cc: gdb-patches
On Sun, May 01, 2005 at 08:12:26PM +1200, Nick Roberts wrote:
> > Could you please include a ChangeLog entry for the pdate?
>
> 2005-05-01 Nick Roberts <nickrob@snap.net.nz>
>
> * mi/gdb-mi.el: Update for changes in Emacs 22.0.50.
> Use "-var-update --with-values" for faster re-display of
> watch expressions.
>
> Please note that I have submitted a patch for "-var-update --with-values"
> which is also waiting approval.
The last message in the thread was comments from Bob. Are you going to
respond to them, or would you rather I review it first?
Does this patch require that one?
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH: gdb/mi] gdb-mi.el
2005-05-01 15:02 ` Daniel Jacobowitz
@ 2005-05-02 4:38 ` Nick Roberts
0 siblings, 0 replies; 6+ messages in thread
From: Nick Roberts @ 2005-05-02 4:38 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> > > Could you please include a ChangeLog entry for the pdate?
> >
> > 2005-05-01 Nick Roberts <nickrob@snap.net.nz>
> >
> > * mi/gdb-mi.el: Update for changes in Emacs 22.0.50.
> > Use "-var-update --with-values" for faster re-display of
> > watch expressions.
> >
> > Please note that I have submitted a patch for "-var-update --with-values"
> > which is also waiting approval.
>
> The last message in the thread was comments from Bob. Are you going to
> respond to them, or would you rather I review it first?
I have just replied to him.
> Does this patch require that one?
Yes. Since it's in several posts and I've followed some of Bob's suggestions,
I am attaching all the up-to-date source code patches for that change.
Thanks
Nick
2005-05-02 Nick Roberts <nickrob@snap.net.nz>
* mi/mi-cmds.h: Add extern declarations for string constants for
MI command options.
* mi/mi-cmd-var.c: Define string constants for MI command options.
(mi_cmd_var_list_children): : Use string constants instead of
literals for MI command options.
(mi_cmd_var_update): New option --with-values for -var-update.
(varobj_update_one): Add argument for new option.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Use string
constants instead of literals for MI command options.
*** /home/nick/src/gdb/mi/mi-cmds.h.~1.15.~ 2005-01-25 22:30:39.000000000 +1300
--- /home/nick/src/gdb/mi/mi-cmds.h 2005-02-26 19:44:02.000000000 +1300
***************
*** 50,55 ****
--- 50,60 ----
PRINT_SIMPLE_VALUES
};
+ extern const char novalues[];
+ extern const char withvalues[];
+ extern const char simplevalues[];
+ extern const char allvalues[];
+
typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc);
/* Older MI commands have this interface. Retained until all old
*** /home/nick/src/gdb/mi/mi-cmd-var.c.~1.21.~ 2005-02-13 00:36:20.000000000 +1300
--- /home/nick/src/gdb/mi/mi-cmd-var.c 2005-05-02 15:48:51.000000000 +1200
***************
*** 30,38 ****
#include <ctype.h>
#include "gdb_string.h"
extern int varobjdebug; /* defined in varobj.c */
! static int varobj_update_one (struct varobj *var);
/* VAROBJ operations */
--- 30,44 ----
#include <ctype.h>
#include "gdb_string.h"
+ const char novalues[] = "--no-values";
+ const char withvalues[] = "--with-values";
+ const char simplevalues[] = "--simple-values";
+ const char allvalues[] = "--all-values";
+
extern int varobjdebug; /* defined in varobj.c */
! static int varobj_update_one (struct varobj *var,
! enum print_values print_values);
/* VAROBJ operations */
***************
*** 262,284 ****
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
/* Get varobj handle, if a valid var obj name was specified */
! if (argc == 1) var = varobj_get_handle (argv[0]);
! else var = varobj_get_handle (argv[1]);
if (var == NULL)
error (_("Variable object not found"));
numchild = varobj_list_children (var, &childlist);
ui_out_field_int (uiout, "numchild", numchild);
if (argc == 2)
! if (strcmp (argv[0], "0") == 0
! || strcmp (argv[0], "--no-values") == 0)
! print_values = PRINT_NO_VALUES;
! else if (strcmp (argv[0], "1") == 0
! || strcmp (argv[0], "--all-values") == 0)
! print_values = PRINT_ALL_VALUES;
! else
! error (_("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\""));
! else print_values = PRINT_NO_VALUES;
if (numchild <= 0)
return MI_CMD_DONE;
--- 268,296 ----
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
/* Get varobj handle, if a valid var obj name was specified */
! if (argc == 1)
! var = varobj_get_handle (argv[0]);
! else
! var = varobj_get_handle (argv[1]);
if (var == NULL)
error (_("Variable object not found"));
numchild = varobj_list_children (var, &childlist);
ui_out_field_int (uiout, "numchild", numchild);
if (argc == 2)
! {
! if (strcmp (argv[0], "0") == 0
! || strcmp (argv[0], novalues) == 0)
! print_values = PRINT_NO_VALUES;
! else if (strcmp (argv[0], "1") == 0
! || strcmp (argv[0], withvalues) == 0)
! print_values = PRINT_ALL_VALUES;
! else
! error (_("Unknown value for PRINT_VALUES: \
! must be: 0 or \"%s\", 1 or \"%s\""), novalues, withvalues);
! }
! else
! print_values = PRINT_NO_VALUES;
if (numchild <= 0)
return MI_CMD_DONE;
***************
*** 426,436 ****
struct cleanup *cleanup;
char *name;
int nv;
! if (argc != 1)
! error (_("mi_cmd_var_update: Usage: NAME."));
! name = argv[0];
/* Check if the parameter is a "*" which means that we want
to update all variables */
--- 438,467 ----
struct cleanup *cleanup;
char *name;
int nv;
+ enum print_values print_values;
! if (argc != 1 && argc != 2)
! error (_("mi_cmd_var_update: Usage: [PRINT_VALUES] NAME."));
! if (argc == 1)
! name = argv[0];
! else
! name = (argv[1]);
!
! if (argc == 2)
! {
! if (strcmp (argv[0], "0") == 0
! || strcmp (argv[0], novalues) == 0)
! print_values = PRINT_NO_VALUES;
! else if (strcmp (argv[0], "1") == 0
! || strcmp (argv[0], withvalues) == 0)
! print_values = PRINT_ALL_VALUES;
! else
! error (_("Unknown value for PRINT_VALUES: \
! must be: 0 or \"%s\", 1 or \"%s\""), novalues, withvalues);
! }
! else
! print_values = PRINT_NO_VALUES;
/* Check if the parameter is a "*" which means that we want
to update all variables */
***************
*** 450,456 ****
cr = rootlist;
while (*cr != NULL)
{
! varobj_update_one (*cr);
cr++;
}
xfree (rootlist);
--- 481,487 ----
cr = rootlist;
while (*cr != NULL)
{
! varobj_update_one (*cr, print_values);
cr++;
}
xfree (rootlist);
***************
*** 467,473 ****
cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
else
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
! varobj_update_one (var);
do_cleanups (cleanup);
}
return MI_CMD_DONE;
--- 498,504 ----
cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
else
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
! varobj_update_one (var, print_values);
do_cleanups (cleanup);
}
return MI_CMD_DONE;
***************
*** 478,484 ****
scope), and 1 if it succeeds. */
static int
! varobj_update_one (struct varobj *var)
{
struct varobj **changelist;
struct varobj **cc;
--- 509,515 ----
scope), and 1 if it succeeds. */
static int
! varobj_update_one (struct varobj *var, enum print_values print_values)
{
struct varobj **changelist;
struct varobj **cc;
***************
*** 524,529 ****
--- 555,562 ----
if (mi_version (uiout) > 1)
cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
+ if (print_values)
+ ui_out_field_string (uiout, "value", varobj_get_value (*cc));
ui_out_field_string (uiout, "in_scope", "true");
ui_out_field_string (uiout, "type_changed", "false");
if (mi_version (uiout) > 1)
*** /home/nick/src/gdb/mi/mi-cmd-stack.c.~1.25.~ 2005-02-13 00:36:20.000000000 +1300
--- /home/nick/src/gdb/mi/mi-cmd-stack.c 2005-05-02 16:01:43.000000000 +1200
***************
*** 142,157 ****
frame = get_selected_frame (NULL);
if (strcmp (argv[0], "0") == 0
! || strcmp (argv[0], "--no-values") == 0)
print_values = PRINT_NO_VALUES;
else if (strcmp (argv[0], "1") == 0
! || strcmp (argv[0], "--all-values") == 0)
print_values = PRINT_ALL_VALUES;
else if (strcmp (argv[0], "2") == 0
! || strcmp (argv[0], "--simple-values") == 0)
print_values = PRINT_SIMPLE_VALUES;
else
! error (_("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\", 2 or \"--simple-values\""));
list_args_or_locals (1, print_values, frame);
return MI_CMD_DONE;
}
--- 142,158 ----
frame = get_selected_frame (NULL);
if (strcmp (argv[0], "0") == 0
! || strcmp (argv[0], novalues) == 0)
print_values = PRINT_NO_VALUES;
else if (strcmp (argv[0], "1") == 0
! || strcmp (argv[0], allvalues) == 0)
print_values = PRINT_ALL_VALUES;
else if (strcmp (argv[0], "2") == 0
! || strcmp (argv[0], simplevalues) == 0)
print_values = PRINT_SIMPLE_VALUES;
else
! error (_("Unknown value for PRINT_VALUES: must be: \
! 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), novalues, allvalues, simplevalues);
list_args_or_locals (1, print_values, frame);
return MI_CMD_DONE;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-05-02 4:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-02 8:18 [PATCH: gdb/mi] gdb-mi.el Nick Roberts
2005-03-19 3:56 ` Nick Roberts
2005-04-30 19:53 ` Daniel Jacobowitz
2005-05-01 8:12 ` Nick Roberts
2005-05-01 15:02 ` Daniel Jacobowitz
2005-05-02 4:38 ` Nick Roberts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox