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ΠˆÏ‰ˆÐ‰ˆÑ‰ˆÒ!ˆÓÄ!ˆÔ ‰ˆÓÅ!ˆÔ ‰ˆÓÆ!ˆÇ‰ˆÓÈ!ˆÉ‰ˆÓÊ!ˆÇ‰
ˆÓË!ˆÇ‰ˆÓÌ!ˆ
‰ˆÕÖ×\"‡" [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 "Á‰ˆ
GÉVƒc
ÉHÊUƒRËÌ
\"ƒKËÍ
Î#ËÍ
T#
ÎOÏ
T
O!B‰*ˆÁ‰ˆÐ
TÁO\"‚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ˆËÇ	!`\"ˆÌ ˆÍ
†7Îp!?Æ\"))ˆ…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‰ˆÌÍÊ!!P‰ˆpÎŽÈ!qˆÏÐ !ˆmƒFÑÒ
Ó$‚RŠdbˆÑÒ
Ó$)ˆÔ!))‡" [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†=dV…EË ˆ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))