4.4BSD/usr/src/contrib/emacs-18.57/lisp/gdb.elc


(require (quote shell))

(defvar gdb-prompt-pattern "^(.*gdb[+]?) *" "\
A regexp to recognize the prompt for gdb or gdb+.")

(defvar gdb-mode-map nil "\
Keymap for gdb-mode.")

(if gdb-mode-map nil (setq gdb-mode-map (copy-keymap shell-mode-map)) (define-key gdb-mode-map "" (quote gdb-refresh)))

(define-key ctl-x-map " " (quote gdb-break))

(define-key ctl-x-map "&" (quote send-gdb-command))

(defmacro def-gdb (name key &optional doc) (byte-code "	\"!	F	F
D&DFE*" [fun name cstr doc key intern format "gdb-%s" if (not (= 1 arg)) "%s %s" arg progn list defun (arg) "" (interactive "p") gdb-call define-key gdb-mode-map quote] 11))

(def-gdb "step" "" "Step one source line with display")

(def-gdb "stepi" "" "Step one instruction with display")

(def-gdb "next" "" "Step one source line (skip functions)")

(def-gdb "cont" "" "Continue with display")

(def-gdb "finish" "" "Finish executing current function")

(def-gdb "up" "" "Go up N stack frames (numeric arg) with display")

(def-gdb "down" "" "Go down N stack frames (numeric arg) with display")

(defun gdb-mode nil "\
Major mode for interacting with an inferior Gdb process.
The following commands are available:

\\{gdb-mode-map}

\\[gdb-display-frame] displays in the other window
the last line referred to in the gdb buffer.

\\[gdb-step],\\[gdb-next], and \\[gdb-nexti] in the gdb window,
call gdb to step,next or nexti and then update the other window
with the current file and position.

If you are in a source file, you may select a point to break
at, by doing \\[gdb-break].

Commands:
Many commands are inherited from shell mode. 
Additionally we have:

\\[gdb-display-frame] display frames file in other window
\\[gdb-step] advance one line in program
\\[gdb-next] advance one line in program (skip over calls).
\\[send-gdb-command] used for special printing of an arg at the current point.
C-x SPACE sets break point at current line." (interactive) (byte-code "Lj ωЉщ!! ! !lj!ɉ!lj
!lj!
\"" [major-mode mode-name mode-line-process gdb-mode-map last-input-start last-input-end gdb-last-frame nil gdb-last-frame-displayed-p t gdb-delete-prompt-marker gdb-filter-accumulator shell-prompt-pattern gdb-prompt-pattern kill-all-local-variables gdb-mode "Inferior Gdb" (": %s") use-local-map make-local-variable make-marker run-hooks shell-mode-hook gdb-mode-hook] 14))

(defvar current-gdb-buffer nil)

(defvar gdb-command-name "gdb" "\
Pathname for executing gdb.")

(defun gdb (path) "\
Run gdb on program FILE in buffer *gdb-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for GDB.  If you wish to change this, use
the GDB commands `cd DIR' and `directory'." (interactive "FRun gdb on file: ") (byte-code "Ĉ!!	Q!!n 
#	P
	& p!\"p!\" )" [path file default-directory gdb-command-name nil expand-file-name file-name-nondirectory switch-to-buffer "*gdb-" "*" file-name-directory newline insert "Current directory is " "
" make-shell "gdb-" "-fullname" "-cd" gdb-mode set-process-filter get-buffer-process gdb-filter set-process-sentinel gdb-sentinel gdb-set-buffer] 14))

(defun gdb-set-buffer nil (byte-code "=	p" [major-mode current-gdb-buffer gdb-mode] 2))

(defun gdb-filter (proc string) (byte-code "

P\"\")" [inhibit-quit t gdb-filter-accumulator proc string gdb-filter-accumulate-marker gdb-filter-scan-input] 4))

(defun gdb-filter-accumulate-marker (proc string) (byte-code "
GVc
HUR
\"K
#
T#
O
T
O!B*
TO\"N
)`\"
O\"f
" [gdb-filter-accumulator nil string end first-colon second-colon gdb-last-frame gdb-last-frame-displayed-p proc 1 26 string-match "
" ":" 2 string-to-int gdb-filter-scan-input gdb-filter-insert ""] 11))

(defun gdb-filter-scan-input (proc string) (byte-code "\"
‰-\"(O\"O\",\")" [string gdb-filter-accumulator nil start proc equal "" string-match "" gdb-filter-insert 0 gdb-filter-accumulate-marker] 8))

(defun gdb-filter-insert (proc string) (byte-code "`	!U`	!Wp	!qʎ	!b`
c	!`\" 
7p!?\"))D	!b," [moving proc output-after-point old-buffer start string t process-mark nil process-buffer ((byte-code "q" [old-buffer] 1)) set-marker gdb-maybe-delete-prompt gdb-display-frame get-buffer-window] 11))

(defun gdb-sentinel (proc msg) (byte-code "!!?‰\"X!>X‰!!PpΎ!q !mF
$Rdb
$)!))" [proc overlay-arrow-position nil mode-line-process obuf mode-name msg buffer-name process-buffer set-process-buffer process-status (signal exit) ": " symbol-name ((byte-code "q" [obuf] 1)) set-buffer-modified-p buffer-modified-p insert 10 " " delete-process] 15))

(defun gdb-refresh nil "\
Fix up a possibly garbled display, and redraw the arrow." (interactive) (byte-code "  " [nil redraw-display gdb-display-frame] 3))

(defun gdb-display-frame (&optional nodisplay noauto) "\
Find, obey and delete the last filename-and-line marker from GDB.
The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n.
Obeying it means displaying in another window the specified file and line." (interactive) (byte-code "ň \"	?\"
??\"@A\"ĉ" [gdb-last-frame nodisplay gdb-last-frame-displayed-p noauto t nil gdb-set-buffer gdb-display-line] 4))

(defun gdb-display-line (true-file line) (byte-code "	!\"q !`͉+ `p#)eW=dVE b)
\"+" [buffer true-file window t pos nil line overlay-arrow-string overlay-arrow-position find-file-noselect display-buffer widen goto-line "=>" make-marker set-marker set-window-point] 10))

(defun gdb-call (command) "\
Invoke gdb COMMAND displaying source in other window." (interactive) (byte-code "Èdb  	!
P\"" [gdb-delete-prompt-marker current-gdb-buffer command nil point-marker gdb-set-buffer send-string get-buffer-process "
"] 7))

(defun gdb-maybe-delete-prompt nil (byte-code "	d!V!b` `	\"‰)" [gdb-delete-prompt-marker start nil marker-position beginning-of-line delete-region] 5))

(defun gdb-break nil "\
Set GDB breakpoint at this source line." (interactive) (byte-code "Ĉ	! `\"T)!
%\"*" [file-name buffer-file-name line current-gdb-buffer nil file-name-nondirectory widen count-lines 1 send-string get-buffer-process concat "break " ":" "
"] 12))

(defun gdb-read-address nil "\
Return a string containing the core-address found in the buffer at point." (byte-code "`Z#`	.!	!!`\"J!!`!!!
`\"+)" [pt found begin t result nil search-backward "0x" 7 forward-char 2 buffer-substring re-search-forward "[^0-9a-f]" -1 re-search-backward "[^0-9]" 1] 13))

(defvar gdb-commands nil "\
List of strings or functions used by send-gdb-command.
It is for customization by you.")

(defun send-gdb-command (arg) "\
This command reads the number where the cursor is positioned.  It
 then inserts this ADDR at the end of the gdb buffer.  A numeric arg
 selects the ARG'th member COMMAND of the list gdb-print-command.  If
 COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise
 (funcall COMMAND ADDR) is inserted.  eg. \"p (rtx)%s->fld[0].rtint\"
 is a possible string to be a member of gdb-commands.  " (interactive "P") (byte-code "ƈ

8 p=`!8;/	\"3	\";	!db!*" [comm addr arg gdb-commands current-gdb-buffer t nil gdb-read-address set-mark format funcall switch-to-buffer insert-string] 7))