(setq gdb-display-in-progress nil)
(setq gdb-dive nil)
(setq gud-last-last-frame nil)
+ (setq gdb-running nil)
(run-hooks 'gdb-mode-hook)
(setq gdb-proc (get-buffer-process (current-buffer)))
(defconst gdb-source-spec-regexp
"\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
-;; Do not use this except as an annotation handler."
+;; Do not use this except as an annotation handler.
(defun gdb-source (args)
(string-match gdb-source-spec-regexp args)
;; Extract the frame position from the marker.
;update with new frame for machine code if necessary
(gdb-invalidate-assembler))
-;; An annotation handler for `prompt'.
-;; This sends the next command (if any) to gdb.
(defun gdb-prompt (ignored)
+ "An annotation handler for `prompt'.
+This sends the next command (if any) to gdb."
(let ((sink (gdb-instance-output-sink)))
(cond
((eq sink 'user) t)
(set-gdb-instance-prompting t)
(gud-display-frame)))))))
-;; An annotation handler for non-top-level prompts.
(defun gdb-subprompt (ignored)
+ "An annotation handler for non-top-level prompts."
(let ((highest (gdb-instance-dequeue-input)))
(if highest
(gdb-send-item highest)
(set-gdb-instance-output-sink 'pre-emacs)
(process-send-string gdb-proc (car item)))))
-;; An annotation handler for `pre-prompt'.
-;; This terminates the collection of output from a previous
-;; command if that happens to be in effect.
(defun gdb-pre-prompt (ignored)
+ "An annotation handler for `pre-prompt'. This terminates the collection of
+output from a previous command if that happens to be in effect."
(let ((sink (gdb-instance-output-sink)))
(cond
((eq sink 'user) t)
(set-gdb-instance-output-sink 'user)
(error "Output sink phase error 1")))))
-;; An annotation handler for `starting'. This says that I/O for the subprocess
-;; is now the program being debugged, not GDB.
(defun gdb-starting (ignored)
+ "An annotation handler for `starting'. This says that I/O for the
+subprocess is now the program being debugged, not GDB."
(let ((sink (gdb-instance-output-sink)))
(cond
((eq sink 'user)
- (set-gdb-instance-output-sink 'inferior))
+ (progn
+ (setq gdb-running t)
+ (set-gdb-instance-output-sink 'inferior)))
(t (error "Unexpected `starting' annotation")))))
-;; An annotation handler for `exited' and other annotations which say that
-;; I/O for the subprocess is now GDB, not the program being debugged.
(defun gdb-stopping (ignored)
+ "An annotation handler for `exited' and other annotations which say that I/O
+for the subprocess is now GDB, not the program being debugged."
(let ((sink (gdb-instance-output-sink)))
(cond
((eq sink 'inferior)
(set-gdb-instance-output-sink 'user))
(t (error "Unexpected stopping annotation")))))
-;; An annotation handler for `stopped'. It is just like gdb-stopping, except
-;; that if we already set the output sink to 'user in gdb-stopping, that is
-;; fine.
(defun gdb-stopped (ignored)
+ "An annotation handler for `stopped'. It is just like gdb-stopping, except
+that if we already set the output sink to 'user in gdb-stopping, that is fine."
+ (setq gdb-running nil)
(let ((sink (gdb-instance-output-sink)))
(cond
((eq sink 'inferior)
((eq sink 'emacs) t)
(t (error "Unexpected frame-begin annotation (%S)" sink)))))
-;; An annotation handler for `post-prompt'.
-;; This begins the collection of output from the current
-;; command if that happens to be appropriate."
(defun gdb-post-prompt (ignored)
+ "An annotation handler for `post-prompt'. This begins the collection of
+output from the current command if that happens to be appropriate."
(if (not (gdb-instance-pending-triggers))
(progn
(gdb-invalidate-registers ignored)
((eq sink 'user) t)
((eq sink 'pre-emacs)
(set-gdb-instance-output-sink 'emacs))
-
(t
(set-gdb-instance-output-sink 'user)
(error "Output sink phase error 3")))))
;; If we get an error whilst evaluating one of the expressions
;; we won't get the display-end annotation. Set the sink back to
;; user to make sure that the error message is seen
-
(defun gdb-error-begin (ignored)
(set-gdb-instance-output-sink 'user))
'gdb-partial-output-buffer)
start end)
(insert "\n")))
-
(goto-char (point-min))
(re-search-forward "##" nil t)
(setq gdb-nesting-level 0)
(concat indices-string "\t" gdb-display-value "\n"))))
(setq indices-string "")
(setq flag t)
- ; 0<= index < depth, start at right : (- depth 1)
+ ; 0<= index < depth, start at right : (- depth 1)
(setq index (- (- depth 1)
(- (match-end 2) (match-beginning 2))))
;don't set for very last brackets
;; Handle a burst of output from a gdb instance.
;; This function is (indirectly) used as a gud-marker-filter.
-;; It must return output (if any) to be insterted in the gdb
+;; It must return output (if any) to be inserted in the gdb
;; buffer.
(defun gdb-output-burst (string)
This function is (indirectly) used as a gud-marker-filter.
It must return output (if any) to be insterted in the gdb
buffer."
-
(save-match-data
(let (
;; Recall the left over burst from last time
(output ""))
;; Process all the complete markers in this chunk.
-
(while (string-match "\n\032\032\\(.*\\)\n" burst)
(let ((annotation (substring burst
(match-beginning 1)
;; It is either concatenated to OUTPUT or directed
;; elsewhere.
(setq output
- (gdb-concat-output output
+ (gdb-concat-output
+ output
(substring burst 0 (match-beginning 0))))
;; Take that stuff off the burst.
;; us to blow up.
))))
-
;; Does the remaining text end in a partial line?
;; If it does, then keep part of the burst until we get more.
(if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
(delete-region (point-min) (point-max))))
\f
-
;; One trick is to have a command who's output is always available in
;; a buffer of it's own, and is always up to date. We build several
;; buffers of this type.
;; command.
;;
-
;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
;; It adds an idle input for the command we are tracking. It should be the
;; annotation rule binding of whatever gdb sends to tell us this command
;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
;; input in the input queue (see comment about ``gdb communications'' above).
-(defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command output-handler)
+
+(defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command
+ output-handler)
`(defun ,name (&optional ignored)
(if (and (,demand-predicate)
(not (member ',name
;; These display the output of `info breakpoints'.
;;
-
(gdb-set-instance-buffer-rules 'gdb-breakpoints-buffer
'gdb-breakpoints-buffer-name
'gdb-breakpoints-mode)
(gdb-invalidate-breakpoints))
(defun gdb-toggle-bp-this-line ()
+"Enable/disable the breakpoint on this line."
(interactive)
(save-excursion
(beginning-of-line 1)
'(lambda () nil))))))
(defun gdb-delete-bp-this-line ()
+"Delete the breakpoint on this line."
(interactive)
(beginning-of-line 1)
(if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
(defvar gdb-source-window nil)
(defun gdb-goto-bp-this-line ()
-"Display the file at the breakpoint specified."
+"Display the file at the specified breakpoint."
(interactive)
(save-excursion
(beginning-of-line 1)
'gdb-display-mode)
(def-gdb-auto-updated-buffer gdb-display-buffer
- ;; This defines the auto update rule for buffers of type
;; `gdb-display-buffer'.
- ;;
- ;; It defines a function to serve as the annotation handler that
- ;; handles the `foo-invalidated' message. That function is called:
gdb-invalidate-display
-
- ;; To update the buffer, this command is sent to gdb.
"server info display\n"
-
- ;; This also defines a function to be the handler for the output
- ;; from the command above. That function will copy the output into
- ;; the appropriately typed buffer. That function will be called:
gdb-info-display-handler
-; buffer specific functions
gdb-info-display-custom)
(defun gdb-info-display-custom ()
(gdb-get-create-instance-buffer 'gdb-display-buffer)))
(defun gdb-toggle-disp-this-line ()
+"Enable/disable the displayed expression on this line."
(interactive)
(save-excursion
(beginning-of-line 1)
'(lambda () nil))))))
(defun gdb-delete-disp-this-line ()
+"Delete the displayed expression on this line."
(interactive)
(save-excursion
(set-buffer
(remove-images (point-min) (point-max))
(remove-strings (point-min) (point-max)))
(setq left-margin-width 0)
+ (setq gud-minor-mode nil)
+ (kill-local-variable 'tool-bar-map)
+ (setq gdb-running nil)
(if (get-buffer-window (current-buffer))
(set-window-margins (get-buffer-window
(current-buffer))
(delete-other-windows))
(defun gdb-source-info ()
+"Finds the source file where the program starts and displays it with related
+buffers."
(goto-char (point-min))
(re-search-forward "directory is ")
(looking-at "\\(\\S-*\\)")
(setq gdb-prev-main-or-pc gdb-main-or-pc))))
(defun gdb-delete-line ()
-"Delete current line."
+ "Delete the current line."
(interactive)
(let ((start (progn (beginning-of-line) (point)))
(end (progn (end-of-line) (+ (point) 1))))