/[emacs]/emacs/lisp/progmodes/gdb-ui.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/gdb-ui.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7.2.7 by miles, Wed Oct 27 05:42:02 2004 UTC revision 1.7.2.8 by miles, Thu Nov 4 08:55:37 2004 UTC
# Line 25  Line 25 
25    
26  ;;; Commentary:  ;;; Commentary:
27    
28  ;; This mode acts as a graphical user interface to GDB. You can interact with  ;; This mode acts as a graphical user interface to GDB.  You can interact with
29  ;; GDB through the GUD buffer in the usual way, but there are also further  ;; GDB through the GUD buffer in the usual way, but there are also further
30  ;; buffers which control the execution and describe the state of your program.  ;; buffers which control the execution and describe the state of your program.
31  ;; It separates the input/output of your program from that of GDB, if  ;; It separates the input/output of your program from that of GDB, if
32  ;; required, and watches expressions in the speedbar. It also uses features of  ;; required, and watches expressions in the speedbar.  It also uses features of
33  ;; Emacs 21 such as the fringe/display margin for breakpoints, and the toolbar  ;; Emacs 21 such as the fringe/display margin for breakpoints, and the toolbar
34  ;; (see the GDB Graphical Interface section in the Emacs info manual).  ;; (see the GDB Graphical Interface section in the Emacs info manual).
35    
36  ;; Start the debugger with M-x gdba.  ;; Start the debugger with M-x gdba.
37    
38  ;; This file has evolved from gdba.el from GDB 5.0 written by Tom Lord and Jim  ;; This file has evolved from gdba.el from GDB 5.0 written by Tom Lord and Jim
39  ;; Kingdon and uses GDB's annotation interface. You don't need to know about  ;; Kingdon and uses GDB's annotation interface.  You don't need to know about
40  ;; annotations to use this mode as a debugger, but if you are interested  ;; annotations to use this mode as a debugger, but if you are interested
41  ;; developing the mode itself, then see the Annotations section in the GDB  ;; developing the mode itself, then see the Annotations section in the GDB
42  ;; info manual.  ;; info manual.
43  ;;  ;;
44  ;; GDB developers plan to make the annotation interface obsolete. A new  ;; GDB developers plan to make the annotation interface obsolete.  A new
45  ;; interface called GDB/MI (machine interface) has been designed to replace  ;; interface called GDB/MI (machine interface) has been designed to replace
46  ;; it. Some GDB/MI commands are used in this file through the CLI command  ;; it.  Some GDB/MI commands are used in this file through the CLI command
47  ;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included in the  ;; 'interpreter mi <mi-command>'.  A file called gdb-mi.el is included in the
48  ;; GDB repository for future releases (6.2 onwards) that uses GDB/MI as the  ;; GDB repository for future releases (6.2 onwards) that uses GDB/MI as the
49  ;; primary interface to GDB. It is still under development and is part of a  ;; primary interface to GDB.  It is still under development and is part of a
50  ;; process to migrate Emacs from annotations to GDB/MI.  ;; process to migrate Emacs from annotations to GDB/MI.
51  ;;  ;;
52  ;; Known Bugs:  ;; Known Bugs:
# Line 63  Line 63 
63  (defvar gdb-current-language nil)  (defvar gdb-current-language nil)
64  (defvar gdb-view-source t "Non-nil means that source code can be viewed.")  (defvar gdb-view-source t "Non-nil means that source code can be viewed.")
65  (defvar gdb-selected-view 'source "Code type that user wishes to view.")  (defvar gdb-selected-view 'source "Code type that user wishes to view.")
66  (defvar gdb-var-list nil "List of variables in watch window")  (defvar gdb-var-list nil "List of variables in watch window.")
67  (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")  (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
68  (defvar gdb-buffer-type nil)  (defvar gdb-buffer-type nil)
69  (defvar gdb-overlay-arrow-position nil)  (defvar gdb-overlay-arrow-position nil)
# Line 85  other with the source file with the main Line 85  other with the source file with the main
85  If `gdb-many-windows' is t, regardless of the value of  If `gdb-many-windows' is t, regardless of the value of
86  `gdb-show-main', the layout below will appear unless  `gdb-show-main', the layout below will appear unless
87  `gdb-use-inferior-io-buffer' is nil when the source buffer  `gdb-use-inferior-io-buffer' is nil when the source buffer
88  occupies the full width of the frame. Keybindings are given in  occupies the full width of the frame.  Keybindings are given in
89  relevant buffer.  relevant buffer.
90    
91  Watch expressions appear in the speedbar/slowbar.  Watch expressions appear in the speedbar/slowbar.
92    
93  The following interactive lisp functions help control operation :  The following commands help control operation :
94    
95  `gdb-many-windows'    - Toggle the number of windows gdb uses.  `gdb-many-windows'    - Toggle the number of windows gdb uses.
96  `gdb-restore-windows' - To restore the window layout.  `gdb-restore-windows' - To restore the window layout.
# Line 120  detailed description of this mode. Line 120  detailed description of this mode.
120   RET      gdb-frames-select       | SPC    gdb-toggle-breakpoint   RET      gdb-frames-select       | SPC    gdb-toggle-breakpoint
121                                    | RET    gdb-goto-breakpoint                                    | RET    gdb-goto-breakpoint
122                                    |   d    gdb-delete-breakpoint                                    |   d    gdb-delete-breakpoint
123  ---------------------------------------------------------------------  ---------------------------------------------------------------------"
 "  
124    ;;    ;;
125    (interactive (list (gud-query-cmdline 'gdba)))    (interactive (list (gud-query-cmdline 'gdba)))
126    ;;    ;;
# Line 134  detailed description of this mode. Line 133  detailed description of this mode.
133  (defcustom gdb-enable-debug-log nil  (defcustom gdb-enable-debug-log nil
134   "Non-nil means record the process input and output in `gdb-debug-log'."   "Non-nil means record the process input and output in `gdb-debug-log'."
135    :type 'boolean    :type 'boolean
136    :group 'gud)    :group 'gud
137      :version "21.4")
138    
139  (defcustom gdb-use-inferior-io-buffer nil  (defcustom gdb-use-inferior-io-buffer nil
140   "Non-nil means display output from the inferior in a separate buffer."   "Non-nil means display output from the inferior in a separate buffer."
141    :type 'boolean    :type 'boolean
142    :group 'gud)    :group 'gud
143      :version "21.4")
144    
145  (defun gdb-ann3 ()  (defun gdb-ann3 ()
146    (setq gdb-debug-log nil)    (setq gdb-debug-log nil)
# Line 210  detailed description of this mode. Line 211  detailed description of this mode.
211    (run-hooks 'gdba-mode-hook))    (run-hooks 'gdba-mode-hook))
212    
213  (defcustom gdb-use-colon-colon-notation nil  (defcustom gdb-use-colon-colon-notation nil
214    "Non-nil means use FUNCTION::VARIABLE format to display variables in the    "If non-nil use FUN::VAR format to display variables in the speedbar." ;
 speedbar."  
215    :type 'boolean    :type 'boolean
216    :group 'gud)    :group 'gud
217      :version "21.4")
218    
219  (defun gud-watch ()  (defun gud-watch ()
220    "Watch expression at point."    "Watch expression at point."
# Line 376  speedbar." Line 377  speedbar."
377              (setq gdb-var-changed t))))))              (setq gdb-var-changed t))))))
378    
379  (defun gdb-edit-value (text token indent)  (defun gdb-edit-value (text token indent)
380    "Assign a value to a variable displayed in the speedbar"    "Assign a value to a variable displayed in the speedbar."
381    (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list))    (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list))
382           (varnum (cadr var)) (value))           (varnum (cadr var)) (value))
383      (setq value (read-string "New value: "))      (setq value (read-string "New value: "))
# Line 389  speedbar." Line 390  speedbar."
390             'ignore))))             'ignore))))
391    
392  (defcustom gdb-show-changed-values t  (defcustom gdb-show-changed-values t
393    "Non-nil means use font-lock-warning-face to display values that have    "If non-nil highlight values that have recently changed in the speedbar.
394  recently changed in the speedbar."  The highlighting is done with `font-lock-warning-face'."
395    :type 'boolean    :type 'boolean
396    :group 'gud)    :group 'gud)
397    
# Line 422  INDENT is the current indentation depth. Line 423  INDENT is the current indentation depth.
423    "The disposition of the output of the current gdb command.    "The disposition of the output of the current gdb command.
424  Possible values are these symbols:  Possible values are these symbols:
425    
426      user -- gdb output should be copied to the GUD buffer      `user' -- gdb output should be copied to the GUD buffer
427              for the user to see.                for the user to see.
428    
429      inferior -- gdb output should be copied to the inferior-io buffer      `inferior' -- gdb output should be copied to the inferior-io buffer
430    
431      pre-emacs -- output should be ignored util the post-prompt      `pre-emacs' -- output should be ignored util the post-prompt
432                   annotation is received.  Then the output-sink                     annotation is received.  Then the output-sink
433                   becomes:...                     becomes:...
434      emacs -- output should be collected in the partial-output-buffer      `emacs' -- output should be collected in the partial-output-buffer
435               for subsequent processing by a command.  This is the                 for subsequent processing by a command.  This is the
436               disposition of output generated by commands that                 disposition of output generated by commands that
437               gdb mode sends to gdb on its own behalf.                 gdb mode sends to gdb on its own behalf.
438      post-emacs -- ignore output until the prompt annotation is      `post-emacs' -- ignore output until the prompt annotation is
439                    received, then go to USER disposition.                      received, then go to USER disposition.
440    
441  gdba (gdb-ui.el) uses all five values,  gdbmi (gdb-mi.el) only two  gdba (gdb-ui.el) uses all five values,  gdbmi (gdb-mi.el) only two
442  (user and emacs).")  \(`user' and `emacs').")
443    
444  (defvar gdb-current-item nil  (defvar gdb-current-item nil
445    "The most recent command item sent to gdb.")    "The most recent command item sent to gdb.")
# Line 619  The key should be one of the cars in `gd Line 620  The key should be one of the cars in `gd
620    
621  (defun gdb-send (proc string)  (defun gdb-send (proc string)
622    "A comint send filter for gdb.    "A comint send filter for gdb.
623  This filter may simply queue output for a later time."  This filter may simply queue input for a later time."
624    (if gud-running    (if gud-running
625        (process-send-string proc (concat string "\n"))        (process-send-string proc (concat string "\n"))
626      (gdb-enqueue-input (concat string "\n"))))      (gdb-enqueue-input (concat string "\n"))))
# Line 660  This filter may simply queue output for Line 661  This filter may simply queue output for
661  (defcustom gud-gdba-command-name "gdb -annotate=3"  (defcustom gud-gdba-command-name "gdb -annotate=3"
662    "Default command to execute an executable under the GDB-UI debugger."    "Default command to execute an executable under the GDB-UI debugger."
663    :type 'string    :type 'string
664    :group 'gud)    :group 'gud
665      :version "21.4")
666    
667  (defvar gdb-annotation-rules  (defvar gdb-annotation-rules
668    '(("pre-prompt" gdb-pre-prompt)    '(("pre-prompt" gdb-pre-prompt)
# Line 705  This filter may simply queue output for Line 707  This filter may simply queue output for
707    (setq gdb-current-item item)    (setq gdb-current-item item)
708    (with-current-buffer gud-comint-buffer    (with-current-buffer gud-comint-buffer
709      (if (eq gud-minor-mode 'gdba)      (if (eq gud-minor-mode 'gdba)
710          (progn          (if (stringp item)
           (if (stringp item)  
               (progn  
                 (setq gdb-output-sink 'user)  
                 (process-send-string (get-buffer-process gud-comint-buffer) item))  
711              (progn              (progn
712                (gdb-clear-partial-output)                (setq gdb-output-sink 'user)
713                (setq gdb-output-sink 'pre-emacs)                (process-send-string (get-buffer-process gud-comint-buffer) item))
714                (process-send-string (get-buffer-process gud-comint-buffer)            (progn
715                                     (car item)))))              (gdb-clear-partial-output)
716        ; case: eq gud-minor-mode 'gdbmi              (setq gdb-output-sink 'pre-emacs)
717                (process-send-string (get-buffer-process gud-comint-buffer)
718                                     (car item))))
719          ;; case: eq gud-minor-mode 'gdbmi
720        (gdb-clear-partial-output)        (gdb-clear-partial-output)
721        (setq gdb-output-sink 'emacs)        (setq gdb-output-sink 'emacs)
722        (process-send-string (get-buffer-process gud-comint-buffer)        (process-send-string (get-buffer-process gud-comint-buffer)
723                           (car item)))))                             (car item)))))
724    
725  (defun gdb-pre-prompt (ignored)  (defun gdb-pre-prompt (ignored)
726    "An annotation handler for `pre-prompt'. This terminates the collection of    "An annotation handler for `pre-prompt'.
727  output from a previous command if that happens to be in effect."  This terminates the collection of output from a previous command if that
728    happens to be in effect."
729    (let ((sink gdb-output-sink))    (let ((sink gdb-output-sink))
730      (cond      (cond
731       ((eq sink 'user) t)       ((eq sink 'user) t)
# Line 761  This sends the next command (if any) to Line 763  This sends the next command (if any) to
763    (setq gdb-prompting t))    (setq gdb-prompting t))
764    
765  (defun gdb-starting (ignored)  (defun gdb-starting (ignored)
766    "An annotation handler for `starting'.  This says that I/O for the    "An annotation handler for `starting'.
767  subprocess is now the program being debugged, not GDB."  This says that I/O for the subprocess is now the program being debugged,
768    not GDB."
769    (let ((sink gdb-output-sink))    (let ((sink gdb-output-sink))
770      (cond      (cond
771       ((eq sink 'user)       ((eq sink 'user)
# Line 773  subprocess is now the program being debu Line 776  subprocess is now the program being debu
776       (t (error "Unexpected `starting' annotation")))))       (t (error "Unexpected `starting' annotation")))))
777    
778  (defun gdb-stopping (ignored)  (defun gdb-stopping (ignored)
779    "An annotation handler for `exited' and other annotations which say that I/O    "An annotation handler for `exited' and other annotations.
780  for the subprocess is now GDB, not the program being debugged."  They say that I/O for the subprocess is now GDB, not the program
781    being debugged."
782    (if gdb-use-inferior-io-buffer    (if gdb-use-inferior-io-buffer
783        (let ((sink gdb-output-sink))        (let ((sink gdb-output-sink))
784          (cond          (cond
# Line 792  for the subprocess is now GDB, not the p Line 796  for the subprocess is now GDB, not the p
796       (t (error "Unexpected frame-begin annotation (%S)" sink)))))       (t (error "Unexpected frame-begin annotation (%S)" sink)))))
797    
798  (defun gdb-stopped (ignored)  (defun gdb-stopped (ignored)
799    "An annotation handler for `stopped'.  It is just like gdb-stopping, except    "An annotation handler for `stopped'.
800  that if we already set the output sink to 'user in gdb-stopping, that is fine."  It is just like `gdb-stopping', except that if we already set the output
801    sink to `user' in `gdb-stopping', that is fine."
802    (setq gud-running nil)    (setq gud-running nil)
803    (let ((sink gdb-output-sink))    (let ((sink gdb-output-sink))
804      (cond      (cond
# Line 803  that if we already set the output sink t Line 808  that if we already set the output sink t
808       (t (error "Unexpected stopped annotation")))))       (t (error "Unexpected stopped annotation")))))
809    
810  (defun gdb-post-prompt (ignored)  (defun gdb-post-prompt (ignored)
811    "An annotation handler for `post-prompt'. This begins the collection of    "An annotation handler for `post-prompt'.
812  output from the current command if that happens to be appropriate."  This begins the collection of output from the current command if that
813    happens to be appropriate."
814    (if (not gdb-pending-triggers)    (if (not gdb-pending-triggers)
815        (progn        (progn
816          (gdb-get-current-frame)          (gdb-get-current-frame)
# Line 832  output from the current command if that Line 838  output from the current command if that
838        (error "Phase error in gdb-post-prompt (got %s)" sink)))))        (error "Phase error in gdb-post-prompt (got %s)" sink)))))
839    
840  (defun gud-gdba-marker-filter (string)  (defun gud-gdba-marker-filter (string)
841    "A gud marker filter for gdb. Handle a burst of output from GDB."    "A gud marker filter for gdb.  Handle a burst of output from GDB."
842    (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))    (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
843    ;; Recall the left over gud-marker-acc from last time    ;; Recall the left over gud-marker-acc from last time
844    (setq gud-marker-acc (concat gud-marker-acc string))    (setq gud-marker-acc (concat gud-marker-acc string))
# Line 1065  static char *magick[] = { Line 1071  static char *magick[] = {
1071    "PBM data used for disabled breakpoint icon.")    "PBM data used for disabled breakpoint icon.")
1072    
1073  (defvar breakpoint-enabled-icon nil  (defvar breakpoint-enabled-icon nil
1074    "Icon for enabled breakpoint in display margin")    "Icon for enabled breakpoint in display margin.")
1075    
1076  (defvar breakpoint-disabled-icon nil  (defvar breakpoint-disabled-icon nil
1077    "Icon for disabled breakpoint in display margin")    "Icon for disabled breakpoint in display margin.")
1078    
1079  ;; Bitmap for breakpoint in fringe  ;; Bitmap for breakpoint in fringe
1080  (define-fringe-bitmap 'breakpoint  (define-fringe-bitmap 'breakpoint
# Line 1133  static char *magick[] = { Line 1139  static char *magick[] = {
1139    (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))    (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
1140    
1141  (defun gdb-mouse-toggle-breakpoint (event)  (defun gdb-mouse-toggle-breakpoint (event)
1142    "Toggle breakpoint in left fringe/margin with mouse click"    "Toggle breakpoint in left fringe/margin with mouse click."
1143    (interactive "e")    (interactive "e")
1144    (mouse-minibuffer-check event)    (mouse-minibuffer-check event)
1145    (let ((posn (event-end event)))    (let ((posn (event-end event)))
# Line 1683  static char *magick[] = { Line 1689  static char *magick[] = {
1689  (defcustom gdb-show-main nil  (defcustom gdb-show-main nil
1690    "Nil means don't display source file containing the main routine."    "Nil means don't display source file containing the main routine."
1691    :type 'boolean    :type 'boolean
1692    :group 'gud)    :group 'gud
1693      :version "21.4")
1694    
1695  (defun gdb-setup-windows ()  (defun gdb-setup-windows ()
1696    "Layout the window pattern for gdb-many-windows."    "Layout the window pattern for gdb-many-windows."
# Line 1718  static char *magick[] = { Line 1725  static char *magick[] = {
1725    (other-window 1))    (other-window 1))
1726    
1727  (defcustom gdb-many-windows nil  (defcustom gdb-many-windows nil
1728    "Nil (the default value) means just pop up the GUD buffer    "Nil means just pop up the GUD buffer unless `gdb-show-main' is t.
1729  unless `gdb-show-main' is t. In this case it starts with two  In this case it starts with two windows: one displaying the GUD
1730  windows: one displaying the GUD buffer and the other with the  buffer and the other with the source file with the main routine
1731  source file with the main routine of the inferior. Non-nil means  of the inferior.  Non-nil means display the layout shown for
1732  display the layout shown for `gdba'."  `gdba'."
1733    :type 'boolean    :type 'boolean
1734    :group 'gud)    :group 'gud
1735      :version "21.4")
1736    
1737  (defun gdb-many-windows (arg)  (defun gdb-many-windows (arg)
1738  "Toggle the number of windows in the basic arrangement."  "Toggle the number of windows in the basic arrangement."
# Line 1760  This arrangement depends on the value of Line 1768  This arrangement depends on the value of
1768      (other-window 1)))      (other-window 1)))
1769    
1770  (defun gdb-reset ()  (defun gdb-reset ()
1771    "Exit a debugging session cleanly by killing the gdb buffers and resetting    "Exit a debugging session cleanly.
1772   the source buffers."  Kills the gdb buffers and resets the source buffers."
1773    (dolist (buffer (buffer-list))    (dolist (buffer (buffer-list))
1774      (unless (eq buffer gud-comint-buffer)      (unless (eq buffer gud-comint-buffer)
1775        (with-current-buffer buffer        (with-current-buffer buffer

Legend:
Removed from v.1.7.2.7  
changed lines
  Added in v.1.7.2.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26