[PATCH] gdb-mi.el

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] gdb-mi.el

Nick Roberts

Here's another patch for gdb-mi.el.  OK to commit to mainline and release
branch?

Nick


2005-11-14  Nick Roberts  <[hidden email]>

        * mi/gdb-mi.el (gdb-source-file-list): Declare.
        (gdbmi): Bind new functions.
        (gdbmi-var-list-children-handler, gdbmi-var-list-children-regexp):
        Handle string expressions properly.  Move "type" field into regexp.
        (gdbmi-var-update-regexp, gdbmi-var-update-handler): Handle string
        expressions properly.  Update speedbar.
        (gdbmi-breakpoints-buffer, gdb-stack-buffer, gdb-locals-buffer)
        (gdb-registers-buffer): Use def-gdb-auto-update-trigger instead of
        def-gdb-auto-updated-buffer as handlers is defined explicitly.
        (gdb-stack-list-locals-handler): Handle string expressions properly.
        (gdb-data-list-register-values-handler)
        (gdb-data-list-register-values-custom): Fontify buffer.


*** gdb-mi.el 27 Oct 2005 22:35:38 +1300 1.3
--- gdb-mi.el 14 Nov 2005 16:28:37 +1300
***************
*** 58,63 ****
--- 58,64 ----
  (require 'gud)
  (require 'gdb-ui)
 
+ (defvar gdb-source-file-list nil)
  (defvar gdb-register-names nil "List of register names.")
  (defvar gdb-changed-registers nil
    "List of changed register numbers (strings).")
***************
*** 81,87 ****
 
  Watch expressions appear in the speedbar/slowbar.
 
! The following interactive lisp functions help control operation :
 
  `gdb-many-windows'    - Toggle the number of windows gdb uses.
  `gdb-restore-windows' - To restore the window layout.
--- 82,88 ----
 
  Watch expressions appear in the speedbar/slowbar.
 
! The following commands help control operation :
 
  `gdb-many-windows'    - Toggle the number of windows gdb uses.
  `gdb-restore-windows' - To restore the window layout.
***************
*** 90,118 ****
  detailed description of this mode.
 
 
! ---------------------------------------------------------------------
!                                GDB Toolbar
! ---------------------------------------------------------------------
! GUD buffer (I/O of GDB)           | Locals buffer
!                                   |
!                                   |
!                                   |
! ---------------------------------------------------------------------
!  Source buffer                    | Input/Output (of inferior) buffer
!                                   | (comint-mode)
!                                   |
!                                   |
!                                   |
!                                   |
!                                   |
!                                   |
! ---------------------------------------------------------------------
!  Stack buffer                     | Breakpoints buffer
!  RET      gdb-frames-select       | SPC    gdb-toggle-breakpoint
!                                   | RET    gdb-goto-breakpoint
!                                   |   d    gdb-delete-breakpoint
! ---------------------------------------------------------------------
! "
    ;;
    (interactive (list (gud-query-cmdline 'gdbmi)))
    ;;
--- 91,118 ----
  detailed description of this mode.
 
 
! +--------------------------------------------------------------+
! |                           GDB Toolbar                        |
! +-------------------------------+------------------------------+
! | GUD buffer (I/O of GDB)       | Locals buffer                |
! |                               |                              |
! |                               |                              |
! |                               |                              |
! +-------------------------------+------------------------------+
! | Source buffer                 | I/O buffer (of inferior)     |
! |                               | (comint-mode)                |
! |                               |                              |
! |                               |                              |
! |                               |                              |
! |                               |                              |
! |                               |                              |
! |                               |                              |
! +-------------------------------+------------------------------+
! | Stack buffer                  | Breakpoints buffer           |
! | RET      gdb-frames-select    | SPC    gdb-toggle-breakpoint |
! |                               | RET    gdb-goto-breakpoint   |
! |                               | d      gdb-delete-breakpoint |
! +-------------------------------+------------------------------+"
    ;;
    (interactive (list (gud-query-cmdline 'gdbmi)))
    ;;
***************
*** 162,169 ****
      'gdb-mouse-set-clear-breakpoint)
    (define-key gud-minor-mode-map [left-fringe mouse-1]
      'gdb-mouse-set-clear-breakpoint)
    (define-key gud-minor-mode-map [left-margin mouse-3]
!     'gdb-mouse-toggle-breakpoint)
 
    (setq comint-input-sender 'gdbmi-send)
    ;;
--- 162,175 ----
      'gdb-mouse-set-clear-breakpoint)
    (define-key gud-minor-mode-map [left-fringe mouse-1]
      'gdb-mouse-set-clear-breakpoint)
+   (define-key gud-minor-mode-map [left-fringe mouse-2]
+     'gdb-mouse-until)
+   (define-key gud-minor-mode-map [left-fringe drag-mouse-1]
+     'gdb-mouse-until)
    (define-key gud-minor-mode-map [left-margin mouse-3]
!     'gdb-mouse-toggle-breakpoint-margin)
!   (define-key gud-minor-mode-map [left-fringe mouse-3]
!     'gdb-mouse-toggle-breakpoint-fringe)
 
    (setq comint-input-sender 'gdbmi-send)
    ;;
***************
*** 223,230 ****
      `(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)
--- 229,236 ----
      `(lambda () (gdbmi-var-list-children-handler ,varnum)))))
 
  (defconst gdbmi-var-list-children-regexp
!   "name=\"\\(.+?\\)\",exp=\"\\(.+?\\)\",numchild=\"\\(.+?\\)\",\
! value=\\(\".*?\"\\),type=\"\\(.+?\\)\"}")
 
  (defun gdbmi-var-list-children-handler (varnum)
    (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
***************
*** 239,249 ****
  (let ((varchild (list (match-string 2)
        (match-string 1)
        (match-string 3)
!       nil
!       (match-string 4)
        nil)))
-   (if (looking-at ",type=\"\\(.*?\\)\"")
-       (setcar (nthcdr 3 varchild) (match-string 1)))
    (dolist (var1 gdb-var-list)
      (if (string-equal (cadr var1) (cadr varchild))
  (throw 'child-already-watched nil)))
--- 245,253 ----
  (let ((varchild (list (match-string 2)
        (match-string 1)
        (match-string 3)
!       (match-string 5)
!       (read (match-string 4))
        nil)))
    (dolist (var1 gdb-var-list)
      (if (string-equal (cadr var1) (cadr varchild))
  (throw 'child-already-watched nil)))
***************
*** 257,280 ****
    (gdb-enqueue-input
     (list "-var-update --all-values *\n" 'gdbmi-var-update-handler)))
 
! (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))))
 
  (defun gdbmi-send (proc string)
    "A comint send filter for gdb."
--- 261,286 ----
    (gdb-enqueue-input
     (list "-var-update --all-values *\n" 'gdbmi-var-update-handler)))
 
! (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-found-1
     (let ((num 0))
       (dolist (var gdb-var-list)
  (if (string-equal varnum (cadr var))
     (progn
       (setcar (nthcdr 5 var) t)
!      (setcar (nthcdr 4 var) (read (match-string 2)))
       (setcar (nthcdr num gdb-var-list) var)
!      (throw 'var-found-1 nil)))
  (setq num (+ num 1))))))
! (setq gdb-var-changed t)))
!   (with-current-buffer gud-comint-buffer
!     (speedbar-timer-fn)))
 
  (defun gdbmi-send (proc string)
    "A comint send filter for gdb."
***************
*** 454,476 ****
 
  ;; Breakpoint buffer : This displays the output of `-break-list'.
  ;;
! (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
!   ;; This defines the auto update rule for buffers of type
!   ;; `gdb-breakpoints-buffer'.
!   ;;
!   ;; It defines a function that queues the command below.  That function is
!   ;; called:
!   gdbmi-invalidate-breakpoints
!   ;;
!   ;; To update the buffer, this command is sent to gdb.
    "-break-list\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-break-list-handler
!   ;; buffer specific functions
!   gdb-break-list-custom)
 
  (defconst gdb-break-list-regexp
  "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",\
--- 460,469 ----
 
  ;; Breakpoint buffer : This displays the output of `-break-list'.
  ;;
! (def-gdb-auto-update-trigger gdbmi-invalidate-breakpoints
!   (gdb-get-buffer 'gdb-breakpoints-buffer)
    "-break-list\n"
!   gdb-break-list-handler)
 
  (defconst gdb-break-list-regexp
  "number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",\
***************
*** 560,565 ****
--- 553,560 ----
        (end-of-line)))
    (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
 
+ (defvar gdb-source-file-regexp "fullname=\"\\(.*?\\)\"")
+
  (defun gdbmi-get-location (bptno line flag)
    "Find the directory containing the relevant source file.
  Put in buffer and place breakpoint icon."
***************
*** 586,596 ****
 
  ;; Frames buffer.  This displays a perpetually correct bactrack trace.
  ;;
! (def-gdb-auto-updated-buffer gdb-stack-buffer
!   gdbmi-invalidate-frames
    "-stack-list-frames\n"
!   gdb-stack-list-frames-handler
!   gdb-stack-list-frames-custom)
 
  (defconst gdb-stack-list-frames-regexp
  "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",\
--- 581,591 ----
 
  ;; Frames buffer.  This displays a perpetually correct bactrack trace.
  ;;
! (def-gdb-auto-update-trigger gdbmi-invalidate-frames
!   (gdb-get-buffer 'gdb-stack-buffer)
    "-stack-list-frames\n"
!   gdb-stack-list-frames-handler)
!
 
  (defconst gdb-stack-list-frames-regexp
  "level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",\
***************
*** 644,654 ****
 
  ;; Locals buffer.
  ;; uses "-stack-list-locals --simple-values". Needs GDB 6.1 onwards.
! (def-gdb-auto-updated-buffer gdb-locals-buffer
!   gdbmi-invalidate-locals
    "-stack-list-locals --simple-values\n"
!   gdb-stack-list-locals-handler
!   gdb-stack-list-locals-custom)
 
  (defconst gdb-stack-list-locals-regexp
    (concat "name=\"\\(.*?\\)\",type=\"\\(.*?\\)\""))
--- 639,648 ----
 
  ;; Locals buffer.
  ;; uses "-stack-list-locals --simple-values". Needs GDB 6.1 onwards.
! (def-gdb-auto-update-trigger gdbmi-invalidate-locals
!   (gdb-get-buffer 'gdb-locals-buffer)
    "-stack-list-locals --simple-values\n"
!   gdb-stack-list-locals-handler)
 
  (defconst gdb-stack-list-locals-regexp
    (concat "name=\"\\(.*?\\)\",type=\"\\(.*?\\)\""))
***************
*** 666,677 ****
  (let ((local (list (match-string 1)
    (match-string 2)
    nil)))
!  (if (looking-at ",value=\"\\(.*?\\)\"")
!      (setcar (nthcdr 2 local) (match-string 1)))
  (push local locals-list))))
      (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
        (and buf (with-current-buffer buf
! (let ((p (window-point (get-buffer-window buf 0)))
        (buffer-read-only nil))
    (erase-buffer)
    (dolist (local locals-list)
--- 660,672 ----
  (let ((local (list (match-string 1)
    (match-string 2)
    nil)))
!  (if (looking-at ",value=\\(\".*\"\\)}")
!      (setcar (nthcdr 2 local) (read (match-string 1))))
  (push local locals-list))))
      (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
        (and buf (with-current-buffer buf
!      (let* ((window (get-buffer-window buf 0))
!     (p (window-point window))
        (buffer-read-only nil))
    (erase-buffer)
    (dolist (local locals-list)
***************
*** 682,700 ****
       "(structure)"
     "(array)"))
       "\n")))
!   (set-window-point (get-buffer-window buf 0) p)))))))
!
! (defun gdb-stack-list-locals-custom ()
!   nil)
 
 
  ;; Registers buffer.
  ;;
! (def-gdb-auto-updated-buffer gdb-registers-buffer
!   gdbmi-invalidate-registers
    "-data-list-register-values x\n"
!   gdb-data-list-register-values-handler
!   gdb-data-list-register-values-custom)
 
  (defconst gdb-data-list-register-values-regexp
    "number=\"\\(.*?\\)\",value=\"\\(.*?\\)\"")
--- 677,691 ----
       "(structure)"
     "(array)"))
       "\n")))
!   (set-window-point window p)))))))
 
 
  ;; Registers buffer.
  ;;
! (def-gdb-auto-update-trigger gdbmi-invalidate-registers
!   (gdb-get-buffer 'gdb-registers-buffer)
    "-data-list-register-values x\n"
!   gdb-data-list-register-values-handler)
 
  (defconst gdb-data-list-register-values-regexp
    "number=\"\\(.*?\\)\",value=\"\\(.*?\\)\"")
***************
*** 731,739 ****
   (buffer-read-only nil))
       (erase-buffer)
       (insert register-values)
!      (set-window-point (get-buffer-window buf 0) p))))))))
 
! (defun gdb-data-list-register-values-custom ())
 
  (defun gdb-get-changed-registers ()
    (if (and (gdb-get-buffer 'gdb-registers-buffer)
--- 722,742 ----
   (buffer-read-only nil))
       (erase-buffer)
       (insert register-values)
!      (set-window-point (get-buffer-window buf 0) p)))))))
!   (gdb-data-list-register-values-custom))
 
! (defun gdb-data-list-register-values-custom ()
!   (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
!     (save-excursion
!       (let ((buffer-read-only nil)
!    bl)
! (goto-char (point-min))
! (while (< (point) (point-max))
!  (setq bl (line-beginning-position))
!  (when (looking-at "^[^\t]+")
!    (put-text-property bl (match-end 0)
!       'face font-lock-variable-name-face))
!  (forward-line 1))))))
 
  (defun gdb-get-changed-registers ()
    (if (and (gdb-get-buffer 'gdb-registers-buffer)
***************
*** 745,750 ****
--- 748,755 ----
   'gdb-get-changed-registers-handler))
  (push 'gdb-get-changed-registers gdb-pending-triggers))))
 
+ (defconst gdb-data-list-register-names-regexp "\"\\(.*?\\)\"")
+
  (defun gdb-get-changed-registers-handler ()
    (setq gdb-pending-triggers
  (delq 'gdb-get-changed-registers gdb-pending-triggers))
***************
*** 754,762 ****
      (while (re-search-forward gdb-data-list-register-names-regexp nil t)
        (push (match-string 1) gdb-changed-registers))))
 
-
- (defconst gdb-data-list-register-names-regexp "\"\\(.*?\\)\"")
-
  (defun gdb-get-register-names ()
    "Create a list of register names."
    (goto-char (point-min))
--- 759,764 ----
***************
*** 767,775 ****
  ;; 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."
--- 769,774 ----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gdb-mi.el

Daniel Jacobowitz-2
On Mon, Nov 14, 2005 at 05:09:30PM +1300, Nick Roberts wrote:
>
> Here's another patch for gdb-mi.el.  OK to commit to mainline and release
> branch?

Yes, please do.


--
Daniel Jacobowitz
CodeSourcery, LLC