diff options
| author | Nick Roberts | 2002-12-21 23:00:12 +0000 |
|---|---|---|
| committer | Nick Roberts | 2002-12-21 23:00:12 +0000 |
| commit | 02a0d085b2a6f5eae286a96559e052344ee24e48 (patch) | |
| tree | 3ec2636c8245602fbee37265684b82d3ef9dc437 | |
| parent | 7ffc9fcd67d407cbe6c68e23327b057034a76b9a (diff) | |
| download | emacs-02a0d085b2a6f5eae286a96559e052344ee24e48.tar.gz emacs-02a0d085b2a6f5eae286a96559e052344ee24e48.zip | |
Remove the concept of an instance. This means that a lot of functions have
been renamed. Accessors are prefixed with gdb-get, setters with gdb-set and
the word instance has been removed from many function and variable names.
(gdb-display-buffer): Protect source buffer as well
as GUD buffer when requesting new buffers.
(gdb-source-info): Two changes : Don't create display buffer
automatically, compute source window correctly.
| -rw-r--r-- | lisp/gdb-ui.el | 516 |
1 files changed, 250 insertions, 266 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el index 3a3aa023f76..a5aab59cce3 100644 --- a/lisp/gdb-ui.el +++ b/lisp/gdb-ui.el | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | 27 | ||
| 28 | ;; This file is based on gdba.el written by Jim Kingdon from GDB 5.0 and uses | 28 | ;; This file is based on gdba.el from GDB 5.0 written by Jim Kingdon and uses |
| 29 | ;; GDB's annotation interface. You don't need to know about annotations but | 29 | ;; GDB's annotation interface. You don't need to know about annotations but |
| 30 | ;; If you are interested developing this mode see the Annotations section in | 30 | ;; If you are interested developing this mode see the Annotations section in |
| 31 | ;; the GDB info manual). | 31 | ;; the GDB info manual). |
| @@ -33,7 +33,10 @@ | |||
| 33 | ;; It has been extended to use features of Emacs 21 such as the display | 33 | ;; It has been extended to use features of Emacs 21 such as the display |
| 34 | ;; margin for breakpoints and the toolbar. It also has new buffers and lots | 34 | ;; margin for breakpoints and the toolbar. It also has new buffers and lots |
| 35 | ;; of other new features such as formatted auto-display of arrays and | 35 | ;; of other new features such as formatted auto-display of arrays and |
| 36 | ;; structures (see the GDB-UI in the Emacs info manual). | 36 | ;; structures (see the GDB-UI section in the Emacs info manual). |
| 37 | ;; | ||
| 38 | ;; Known Bugs: Does not auto-display arrays of structures or structures | ||
| 39 | ;; containing arrays properly. | ||
| 37 | 40 | ||
| 38 | ;;; Code: | 41 | ;;; Code: |
| 39 | 42 | ||
| @@ -128,15 +131,15 @@ The following interactive lisp functions help control operation : | |||
| 128 | (setq gdb-display-in-progress nil) | 131 | (setq gdb-display-in-progress nil) |
| 129 | (setq gdb-dive nil) | 132 | (setq gdb-dive nil) |
| 130 | 133 | ||
| 131 | (mapc 'make-local-variable gdb-instance-variables) | 134 | (mapc 'make-local-variable gdb-variables) |
| 132 | (setq gdb-buffer-type 'gdba) | 135 | (setq gdb-buffer-type 'gdba) |
| 133 | 136 | ||
| 134 | (gdb-clear-inferior-io) | 137 | (gdb-clear-inferior-io) |
| 135 | 138 | ||
| 136 | ;; find source file and compilation directory here | 139 | ;; find source file and compilation directory here |
| 137 | (gdb-instance-enqueue-input (list "server list\n" 'ignore)) | 140 | (gdb-enqueue-input (list "server list\n" 'ignore)) |
| 138 | (gdb-instance-enqueue-input (list "server info source\n" | 141 | (gdb-enqueue-input (list "server info source\n" |
| 139 | 'gdb-source-info)) | 142 | 'gdb-source-info)) |
| 140 | 143 | ||
| 141 | (run-hooks 'gdba-mode-hook)) | 144 | (run-hooks 'gdba-mode-hook)) |
| 142 | 145 | ||
| @@ -145,16 +148,16 @@ The following interactive lisp functions help control operation : | |||
| 145 | (interactive) | 148 | (interactive) |
| 146 | (save-excursion | 149 | (save-excursion |
| 147 | (let ((expr (gud-find-c-expr))) | 150 | (let ((expr (gud-find-c-expr))) |
| 148 | (gdb-instance-enqueue-input | 151 | (gdb-enqueue-input |
| 149 | (list (concat "server whatis " expr "\n") | 152 | (list (concat "server whatis " expr "\n") |
| 150 | `(lambda () (gud-display1 ,expr))))))) | 153 | `(lambda () (gud-display1 ,expr))))))) |
| 151 | 154 | ||
| 152 | (defun gud-display1 (expr) | 155 | (defun gud-display1 (expr) |
| 153 | (goto-char (point-min)) | 156 | (goto-char (point-min)) |
| 154 | (if (re-search-forward "\*" nil t) | 157 | (if (re-search-forward "\*" nil t) |
| 155 | (gdb-instance-enqueue-input | 158 | (gdb-enqueue-input |
| 156 | (list (concat "server display* " expr "\n") 'ignore)) | 159 | (list (concat "server display* " expr "\n") 'ignore)) |
| 157 | (gdb-instance-enqueue-input | 160 | (gdb-enqueue-input |
| 158 | (list (concat "server display " expr "\n") 'ignore)))) | 161 | (list (concat "server display " expr "\n") 'ignore)))) |
| 159 | 162 | ||
| 160 | 163 | ||
| @@ -165,31 +168,23 @@ The following interactive lisp functions help control operation : | |||
| 165 | 168 | ||
| 166 | ;; ====================================================================== | 169 | ;; ====================================================================== |
| 167 | ;; | 170 | ;; |
| 168 | ;; In this world, there are gdb instance objects (of unspecified | 171 | ;; In this world, there are gdb variables (of unspecified |
| 169 | ;; representation) and buffers associated with those objects. | 172 | ;; representation) and buffers associated with those objects. |
| 170 | ;; | 173 | ;; The list of variables is built up by the expansions of |
| 171 | 174 | ;; def-gdb-variable | |
| 172 | ;; | ||
| 173 | ;; gdb-instance objects | ||
| 174 | ;; | ||
| 175 | |||
| 176 | (defvar gdb-instance-variables '() | ||
| 177 | "A list of variables that are local to the GUD buffer associated | ||
| 178 | with a gdb instance.") | ||
| 179 | 175 | ||
| 180 | ;;; The list of instance variables is built up by the expansions of | 176 | (defvar gdb-variables '() |
| 181 | ;;; DEF-GDB-VARIABLE | 177 | "A list of variables that are local to the GUD buffer.") |
| 182 | ;;; | ||
| 183 | 178 | ||
| 184 | (defmacro def-gdb-var (root-symbol &optional default doc) | 179 | (defmacro def-gdb-var (root-symbol &optional default doc) |
| 185 | (let* ((root (symbol-name root-symbol)) | 180 | (let* ((root (symbol-name root-symbol)) |
| 186 | (accessor (intern (concat "gdb-instance-" root))) | 181 | (accessor (intern (concat "gdb-get-" root))) |
| 187 | (setter (intern (concat "set-gdb-instance-" root))) | 182 | (setter (intern (concat "gdb-set-" root))) |
| 188 | (name (intern (concat "gdb-" root)))) | 183 | (name (intern (concat "gdb-" root)))) |
| 189 | `(progn | 184 | `(progn |
| 190 | (defvar ,name ,default ,doc) | 185 | (defvar ,name ,default ,doc) |
| 191 | (if (not (memq ',name gdb-instance-variables)) | 186 | (if (not (memq ',name gdb-variables)) |
| 192 | (push ',name gdb-instance-variables)) | 187 | (push ',name gdb-variables)) |
| 193 | (defun ,accessor () | 188 | (defun ,accessor () |
| 194 | (buffer-local-value ',name gud-comint-buffer)) | 189 | (buffer-local-value ',name gud-comint-buffer)) |
| 195 | (defun ,setter (val) | 190 | (defun ,setter (val) |
| @@ -197,7 +192,7 @@ with a gdb instance.") | |||
| 197 | (setq ,name val)))))) | 192 | (setq ,name val)))))) |
| 198 | 193 | ||
| 199 | (def-gdb-var buffer-type nil | 194 | (def-gdb-var buffer-type nil |
| 200 | "One of the symbols bound in gdb-instance-buffer-rules") | 195 | "One of the symbols bound in gdb-buffer-rules") |
| 201 | 196 | ||
| 202 | (def-gdb-var burst "" | 197 | (def-gdb-var burst "" |
| 203 | "A string of characters from gdb that have not yet been processed.") | 198 | "A string of characters from gdb that have not yet been processed.") |
| @@ -238,18 +233,15 @@ Possible values are these symbols: | |||
| 238 | "A list of trigger functions that have run later than their output | 233 | "A list of trigger functions that have run later than their output |
| 239 | handlers.") | 234 | handlers.") |
| 240 | 235 | ||
| 241 | ;; end of instance vars | 236 | ;; end of gdb variables |
| 242 | 237 | ||
| 243 | (defun gdb-instance-target-string () | 238 | (defun gdb-get-target-string () |
| 244 | (with-current-buffer gud-comint-buffer | 239 | (with-current-buffer gud-comint-buffer |
| 245 | gud-target-name)) | 240 | gud-target-name)) |
| 246 | 241 | ||
| 247 | 242 | ||
| 248 | ;; | 243 | ;; |
| 249 | ;; Instance Buffers. | 244 | ;; gdb buffers. |
| 250 | ;; | ||
| 251 | |||
| 252 | ;; More than one buffer can be associated with a gdb instance. | ||
| 253 | ;; | 245 | ;; |
| 254 | ;; Each buffer has a TYPE -- a symbol that identifies the function | 246 | ;; Each buffer has a TYPE -- a symbol that identifies the function |
| 255 | ;; of that particular buffer. | 247 | ;; of that particular buffer. |
| @@ -257,22 +249,22 @@ handlers.") | |||
| 257 | ;; The usual gdb interaction buffer is given the type `gdba' and | 249 | ;; The usual gdb interaction buffer is given the type `gdba' and |
| 258 | ;; is constructed specially. | 250 | ;; is constructed specially. |
| 259 | ;; | 251 | ;; |
| 260 | ;; Others are constructed by gdb-get-create-instance-buffer and | 252 | ;; Others are constructed by gdb-get-create-buffer and |
| 261 | ;; named according to the rules set forth in the gdb-instance-buffer-rules-assoc | 253 | ;; named according to the rules set forth in the gdb-buffer-rules-assoc |
| 262 | 254 | ||
| 263 | (defvar gdb-instance-buffer-rules-assoc '()) | 255 | (defvar gdb-buffer-rules-assoc '()) |
| 264 | 256 | ||
| 265 | (defun gdb-get-instance-buffer (key) | 257 | (defun gdb-get-buffer (key) |
| 266 | "Return the instance buffer tagged with type KEY. | 258 | "Return the gdb buffer tagged with type KEY. |
| 267 | The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | 259 | The key should be one of the cars in `gdb-buffer-rules-assoc'." |
| 268 | (save-excursion | 260 | (save-excursion |
| 269 | (gdb-look-for-tagged-buffer key (buffer-list)))) | 261 | (gdb-look-for-tagged-buffer key (buffer-list)))) |
| 270 | 262 | ||
| 271 | (defun gdb-get-create-instance-buffer (key) | 263 | (defun gdb-get-create-buffer (key) |
| 272 | "Create a new gdb instance buffer of the type specified by KEY. | 264 | "Create a new gdb buffer of the type specified by KEY. |
| 273 | The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | 265 | The key should be one of the cars in `gdb-buffer-rules-assoc'." |
| 274 | (or (gdb-get-instance-buffer key) | 266 | (or (gdb-get-buffer key) |
| 275 | (let* ((rules (assoc key gdb-instance-buffer-rules-assoc)) | 267 | (let* ((rules (assoc key gdb-buffer-rules-assoc)) |
| 276 | (name (funcall (gdb-rules-name-maker rules))) | 268 | (name (funcall (gdb-rules-name-maker rules))) |
| 277 | (new (get-buffer-create name))) | 269 | (new (get-buffer-create name))) |
| 278 | (with-current-buffer new | 270 | (with-current-buffer new |
| @@ -302,23 +294,23 @@ The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | |||
| 302 | ;; at least one and possible more functions. The functions have these | 294 | ;; at least one and possible more functions. The functions have these |
| 303 | ;; roles in defining a buffer type: | 295 | ;; roles in defining a buffer type: |
| 304 | ;; | 296 | ;; |
| 305 | ;; NAME - take an instance, return a name for this type buffer for that | 297 | ;; NAME - Return a name for this buffer type. |
| 306 | ;; instance. | 298 | ;; |
| 307 | ;; The remaining function(s) are optional: | 299 | ;; The remaining function(s) are optional: |
| 308 | ;; | 300 | ;; |
| 309 | ;; MODE - called in new new buffer with no arguments, should establish | 301 | ;; MODE - called in a new buffer with no arguments, should establish |
| 310 | ;; the proper mode for the buffer. | 302 | ;; the proper mode for the buffer. |
| 311 | ;; | 303 | ;; |
| 312 | 304 | ||
| 313 | (defun gdb-set-instance-buffer-rules (buffer-type &rest rules) | 305 | (defun gdb-set-buffer-rules (buffer-type &rest rules) |
| 314 | (let ((binding (assoc buffer-type gdb-instance-buffer-rules-assoc))) | 306 | (let ((binding (assoc buffer-type gdb-buffer-rules-assoc))) |
| 315 | (if binding | 307 | (if binding |
| 316 | (setcdr binding rules) | 308 | (setcdr binding rules) |
| 317 | (push (cons buffer-type rules) | 309 | (push (cons buffer-type rules) |
| 318 | gdb-instance-buffer-rules-assoc)))) | 310 | gdb-buffer-rules-assoc)))) |
| 319 | 311 | ||
| 320 | ;; GUD buffers are an exception to the rules | 312 | ;; GUD buffers are an exception to the rules |
| 321 | (gdb-set-instance-buffer-rules 'gdba 'error) | 313 | (gdb-set-buffer-rules 'gdba 'error) |
| 322 | 314 | ||
| 323 | ;; | 315 | ;; |
| 324 | ;; partial-output buffers | 316 | ;; partial-output buffers |
| @@ -327,22 +319,22 @@ The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | |||
| 327 | ;; behalf of emacs (rather than the user). | 319 | ;; behalf of emacs (rather than the user). |
| 328 | ;; | 320 | ;; |
| 329 | 321 | ||
| 330 | (gdb-set-instance-buffer-rules 'gdb-partial-output-buffer | 322 | (gdb-set-buffer-rules 'gdb-partial-output-buffer |
| 331 | 'gdb-partial-output-name) | 323 | 'gdb-partial-output-name) |
| 332 | 324 | ||
| 333 | (defun gdb-partial-output-name () | 325 | (defun gdb-partial-output-name () |
| 334 | (concat "*partial-output-" | 326 | (concat "*partial-output-" |
| 335 | (gdb-instance-target-string) | 327 | (gdb-get-target-string) |
| 336 | "*")) | 328 | "*")) |
| 337 | 329 | ||
| 338 | 330 | ||
| 339 | (gdb-set-instance-buffer-rules 'gdb-inferior-io | 331 | (gdb-set-buffer-rules 'gdb-inferior-io |
| 340 | 'gdb-inferior-io-name | 332 | 'gdb-inferior-io-name |
| 341 | 'gdb-inferior-io-mode) | 333 | 'gdb-inferior-io-mode) |
| 342 | 334 | ||
| 343 | (defun gdb-inferior-io-name () | 335 | (defun gdb-inferior-io-name () |
| 344 | (concat "*input/output of " | 336 | (concat "*input/output of " |
| 345 | (gdb-instance-target-string) | 337 | (gdb-get-target-string) |
| 346 | "*")) | 338 | "*")) |
| 347 | 339 | ||
| 348 | (defvar gdb-inferior-io-mode-map | 340 | (defvar gdb-inferior-io-mode-map |
| @@ -402,21 +394,17 @@ The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | |||
| 402 | 394 | ||
| 403 | ;; INPUT: things sent to gdb | 395 | ;; INPUT: things sent to gdb |
| 404 | ;; | 396 | ;; |
| 405 | ;; Each instance has a high and low priority | 397 | ;; There is a high and low priority input queue. Low priority input is sent |
| 406 | ;; input queue. Low priority input is sent only | 398 | ;; only when the high priority queue is idle. |
| 407 | ;; when the high priority queue is idle. | ||
| 408 | ;; | 399 | ;; |
| 409 | ;; The queues are lists. Each element is either | 400 | ;; The queues are lists. Each element is either a string (indicating user or |
| 410 | ;; a string (indicating user or user-like input) | 401 | ;; user-like input) or a list of the form: |
| 411 | ;; or a list of the form: | ||
| 412 | ;; | 402 | ;; |
| 413 | ;; (INPUT-STRING HANDLER-FN) | 403 | ;; (INPUT-STRING HANDLER-FN) |
| 414 | ;; | 404 | ;; |
| 415 | ;; | 405 | ;; The handler function will be called from the partial-output buffer when the |
| 416 | ;; The handler function will be called from the | 406 | ;; command completes. This is the way to write commands which invoke gdb |
| 417 | ;; partial-output buffer when the command completes. | 407 | ;; commands autonomously. |
| 418 | ;; This is the way to write commands which | ||
| 419 | ;; invoke gdb commands autonomously. | ||
| 420 | ;; | 408 | ;; |
| 421 | ;; These lists are consumed tail first. | 409 | ;; These lists are consumed tail first. |
| 422 | ;; | 410 | ;; |
| @@ -424,7 +412,7 @@ The key should be one of the cars in `gdb-instance-buffer-rules-assoc'." | |||
| 424 | (defun gdb-send (proc string) | 412 | (defun gdb-send (proc string) |
| 425 | "A comint send filter for gdb. | 413 | "A comint send filter for gdb. |
| 426 | This filter may simply queue output for a later time." | 414 | This filter may simply queue output for a later time." |
| 427 | (gdb-instance-enqueue-input (concat string "\n"))) | 415 | (gdb-enqueue-input (concat string "\n"))) |
| 428 | 416 | ||
| 429 | ;; Note: Stuff enqueued here will be sent to the next prompt, even if it | 417 | ;; Note: Stuff enqueued here will be sent to the next prompt, even if it |
| 430 | ;; is a query, or other non-top-level prompt. To guarantee stuff will get | 418 | ;; is a query, or other non-top-level prompt. To guarantee stuff will get |
| @@ -434,40 +422,40 @@ This filter may simply queue output for a later time." | |||
| 434 | ;; the user go first; it is not a bug. -t] | 422 | ;; the user go first; it is not a bug. -t] |
| 435 | ;; | 423 | ;; |
| 436 | 424 | ||
| 437 | (defun gdb-instance-enqueue-input (item) | 425 | (defun gdb-enqueue-input (item) |
| 438 | (if (gdb-instance-prompting) | 426 | (if (gdb-get-prompting) |
| 439 | (progn | 427 | (progn |
| 440 | (gdb-send-item item) | 428 | (gdb-send-item item) |
| 441 | (set-gdb-instance-prompting nil)) | 429 | (gdb-set-prompting nil)) |
| 442 | (set-gdb-instance-input-queue | 430 | (gdb-set-input-queue |
| 443 | (cons item (gdb-instance-input-queue))))) | 431 | (cons item (gdb-get-input-queue))))) |
| 444 | 432 | ||
| 445 | (defun gdb-instance-dequeue-input () | 433 | (defun gdb-dequeue-input () |
| 446 | (let ((queue (gdb-instance-input-queue))) | 434 | (let ((queue (gdb-get-input-queue))) |
| 447 | (and queue | 435 | (and queue |
| 448 | (if (not (cdr queue)) | 436 | (if (not (cdr queue)) |
| 449 | (let ((answer (car queue))) | 437 | (let ((answer (car queue))) |
| 450 | (set-gdb-instance-input-queue '()) | 438 | (gdb-set-input-queue '()) |
| 451 | answer) | 439 | answer) |
| 452 | (gdb-take-last-elt queue))))) | 440 | (gdb-take-last-elt queue))))) |
| 453 | 441 | ||
| 454 | (defun gdb-instance-enqueue-idle-input (item) | 442 | (defun gdb-enqueue-idle-input (item) |
| 455 | (if (and (gdb-instance-prompting) | 443 | (if (and (gdb-get-prompting) |
| 456 | (not (gdb-instance-input-queue))) | 444 | (not (gdb-get-input-queue))) |
| 457 | (progn | 445 | (progn |
| 458 | (gdb-send-item item) | 446 | (gdb-send-item item) |
| 459 | (set-gdb-instance-prompting nil)) | 447 | (gdb-set-prompting nil)) |
| 460 | (set-gdb-instance-idle-input-queue | 448 | (gdb-set-idle-input-queue |
| 461 | (cons item (gdb-instance-idle-input-queue))))) | 449 | (cons item (gdb-get-idle-input-queue))))) |
| 462 | 450 | ||
| 463 | (defun gdb-instance-dequeue-idle-input () | 451 | (defun gdb-dequeue-idle-input () |
| 464 | (let ((queue (gdb-instance-idle-input-queue))) | 452 | (let ((queue (gdb-get-idle-input-queue))) |
| 465 | (and queue | 453 | (and queue |
| 466 | (if (not (cdr queue)) | 454 | (if (not (cdr queue)) |
| 467 | (let ((answer (car queue))) | 455 | (let ((answer (car queue))) |
| 468 | (set-gdb-instance-idle-input-queue '()) | 456 | (gdb-set-idle-input-queue '()) |
| 469 | answer) | 457 | answer) |
| 470 | (gdb-take-last-elt queue))))) | 458 | (gdb-take-last-elt queue))))) |
| 471 | 459 | ||
| 472 | ;; Don't use this in general. | 460 | ;; Don't use this in general. |
| 473 | (defun gdb-take-last-elt (l) | 461 | (defun gdb-take-last-elt (l) |
| @@ -496,8 +484,8 @@ This filter may simply queue output for a later time." | |||
| 496 | 484 | ||
| 497 | (defcustom gud-gdba-command-name "gdb -annotate=2" | 485 | (defcustom gud-gdba-command-name "gdb -annotate=2" |
| 498 | "Default command to execute an executable under the GDB-UI debugger." | 486 | "Default command to execute an executable under the GDB-UI debugger." |
| 499 | :type 'string | 487 | :type 'string |
| 500 | :group 'gud) | 488 | :group 'gud) |
| 501 | 489 | ||
| 502 | (defvar gdb-annotation-rules | 490 | (defvar gdb-annotation-rules |
| 503 | '(("frames-invalid" gdb-invalidate-frame-and-assembler) | 491 | '(("frames-invalid" gdb-invalidate-frame-and-assembler) |
| @@ -550,97 +538,97 @@ This filter may simply queue output for a later time." | |||
| 550 | (defun gdb-prompt (ignored) | 538 | (defun gdb-prompt (ignored) |
| 551 | "An annotation handler for `prompt'. | 539 | "An annotation handler for `prompt'. |
| 552 | This sends the next command (if any) to gdb." | 540 | This sends the next command (if any) to gdb." |
| 553 | (let ((sink (gdb-instance-output-sink))) | 541 | (let ((sink (gdb-get-output-sink))) |
| 554 | (cond | 542 | (cond |
| 555 | ((eq sink 'user) t) | 543 | ((eq sink 'user) t) |
| 556 | ((eq sink 'post-emacs) | 544 | ((eq sink 'post-emacs) |
| 557 | (set-gdb-instance-output-sink 'user)) | 545 | (gdb-set-output-sink 'user)) |
| 558 | (t | 546 | (t |
| 559 | (set-gdb-instance-output-sink 'user) | 547 | (gdb-set-output-sink 'user) |
| 560 | (error "Phase error in gdb-prompt (got %s)" sink)))) | 548 | (error "Phase error in gdb-prompt (got %s)" sink)))) |
| 561 | (let ((highest (gdb-instance-dequeue-input))) | 549 | (let ((highest (gdb-dequeue-input))) |
| 562 | (if highest | 550 | (if highest |
| 563 | (gdb-send-item highest) | 551 | (gdb-send-item highest) |
| 564 | (let ((lowest (gdb-instance-dequeue-idle-input))) | 552 | (let ((lowest (gdb-dequeue-idle-input))) |
| 565 | (if lowest | 553 | (if lowest |
| 566 | (gdb-send-item lowest) | 554 | (gdb-send-item lowest) |
| 567 | (progn | 555 | (progn |
| 568 | (set-gdb-instance-prompting t) | 556 | (gdb-set-prompting t) |
| 569 | (gud-display-frame))))))) | 557 | (gud-display-frame))))))) |
| 570 | 558 | ||
| 571 | (defun gdb-subprompt (ignored) | 559 | (defun gdb-subprompt (ignored) |
| 572 | "An annotation handler for non-top-level prompts." | 560 | "An annotation handler for non-top-level prompts." |
| 573 | (let ((highest (gdb-instance-dequeue-input))) | 561 | (let ((highest (gdb-dequeue-input))) |
| 574 | (if highest | 562 | (if highest |
| 575 | (gdb-send-item highest) | 563 | (gdb-send-item highest) |
| 576 | (set-gdb-instance-prompting t)))) | 564 | (gdb-set-prompting t)))) |
| 577 | 565 | ||
| 578 | (defun gdb-send-item (item) | 566 | (defun gdb-send-item (item) |
| 579 | (set-gdb-instance-current-item item) | 567 | (gdb-set-current-item item) |
| 580 | (if (stringp item) | 568 | (if (stringp item) |
| 581 | (progn | 569 | (progn |
| 582 | (set-gdb-instance-output-sink 'user) | 570 | (gdb-set-output-sink 'user) |
| 583 | (process-send-string (get-buffer-process gud-comint-buffer) item)) | 571 | (process-send-string (get-buffer-process gud-comint-buffer) item)) |
| 584 | (progn | 572 | (progn |
| 585 | (gdb-clear-partial-output) | 573 | (gdb-clear-partial-output) |
| 586 | (set-gdb-instance-output-sink 'pre-emacs) | 574 | (gdb-set-output-sink 'pre-emacs) |
| 587 | (process-send-string (get-buffer-process gud-comint-buffer) | 575 | (process-send-string (get-buffer-process gud-comint-buffer) |
| 588 | (car item))))) | 576 | (car item))))) |
| 589 | 577 | ||
| 590 | (defun gdb-pre-prompt (ignored) | 578 | (defun gdb-pre-prompt (ignored) |
| 591 | "An annotation handler for `pre-prompt'. This terminates the collection of | 579 | "An annotation handler for `pre-prompt'. This terminates the collection of |
| 592 | output from a previous command if that happens to be in effect." | 580 | output from a previous command if that happens to be in effect." |
| 593 | (let ((sink (gdb-instance-output-sink))) | 581 | (let ((sink (gdb-get-output-sink))) |
| 594 | (cond | 582 | (cond |
| 595 | ((eq sink 'user) t) | 583 | ((eq sink 'user) t) |
| 596 | ((eq sink 'emacs) | 584 | ((eq sink 'emacs) |
| 597 | (set-gdb-instance-output-sink 'post-emacs) | 585 | (gdb-set-output-sink 'post-emacs) |
| 598 | (let ((handler | 586 | (let ((handler |
| 599 | (car (cdr (gdb-instance-current-item))))) | 587 | (car (cdr (gdb-get-current-item))))) |
| 600 | (save-excursion | 588 | (save-excursion |
| 601 | (set-buffer (gdb-get-create-instance-buffer | 589 | (set-buffer (gdb-get-create-buffer |
| 602 | 'gdb-partial-output-buffer)) | 590 | 'gdb-partial-output-buffer)) |
| 603 | (funcall handler)))) | 591 | (funcall handler)))) |
| 604 | (t | 592 | (t |
| 605 | (set-gdb-instance-output-sink 'user) | 593 | (gdb-set-output-sink 'user) |
| 606 | (error "Output sink phase error 1"))))) | 594 | (error "Output sink phase error 1"))))) |
| 607 | 595 | ||
| 608 | (defun gdb-starting (ignored) | 596 | (defun gdb-starting (ignored) |
| 609 | "An annotation handler for `starting'. This says that I/O for the | 597 | "An annotation handler for `starting'. This says that I/O for the |
| 610 | subprocess is now the program being debugged, not GDB." | 598 | subprocess is now the program being debugged, not GDB." |
| 611 | (let ((sink (gdb-instance-output-sink))) | 599 | (let ((sink (gdb-get-output-sink))) |
| 612 | (cond | 600 | (cond |
| 613 | ((eq sink 'user) | 601 | ((eq sink 'user) |
| 614 | (progn | 602 | (progn |
| 615 | (setq gud-running t) | 603 | (setq gud-running t) |
| 616 | (set-gdb-instance-output-sink 'inferior))) | 604 | (gdb-set-output-sink 'inferior))) |
| 617 | (t (error "Unexpected `starting' annotation"))))) | 605 | (t (error "Unexpected `starting' annotation"))))) |
| 618 | 606 | ||
| 619 | (defun gdb-stopping (ignored) | 607 | (defun gdb-stopping (ignored) |
| 620 | "An annotation handler for `exited' and other annotations which say that I/O | 608 | "An annotation handler for `exited' and other annotations which say that I/O |
| 621 | for the subprocess is now GDB, not the program being debugged." | 609 | for the subprocess is now GDB, not the program being debugged." |
| 622 | (let ((sink (gdb-instance-output-sink))) | 610 | (let ((sink (gdb-get-output-sink))) |
| 623 | (cond | 611 | (cond |
| 624 | ((eq sink 'inferior) | 612 | ((eq sink 'inferior) |
| 625 | (set-gdb-instance-output-sink 'user)) | 613 | (gdb-set-output-sink 'user)) |
| 626 | (t (error "Unexpected stopping annotation"))))) | 614 | (t (error "Unexpected stopping annotation"))))) |
| 627 | 615 | ||
| 628 | (defun gdb-stopped (ignored) | 616 | (defun gdb-stopped (ignored) |
| 629 | "An annotation handler for `stopped'. It is just like gdb-stopping, except | 617 | "An annotation handler for `stopped'. It is just like gdb-stopping, except |
| 630 | that if we already set the output sink to 'user in gdb-stopping, that is fine." | 618 | that if we already set the output sink to 'user in gdb-stopping, that is fine." |
| 631 | (setq gud-running nil) | 619 | (setq gud-running nil) |
| 632 | (let ((sink (gdb-instance-output-sink))) | 620 | (let ((sink (gdb-get-output-sink))) |
| 633 | (cond | 621 | (cond |
| 634 | ((eq sink 'inferior) | 622 | ((eq sink 'inferior) |
| 635 | (set-gdb-instance-output-sink 'user)) | 623 | (gdb-set-output-sink 'user)) |
| 636 | ((eq sink 'user) t) | 624 | ((eq sink 'user) t) |
| 637 | (t (error "Unexpected stopped annotation"))))) | 625 | (t (error "Unexpected stopped annotation"))))) |
| 638 | 626 | ||
| 639 | (defun gdb-frame-begin (ignored) | 627 | (defun gdb-frame-begin (ignored) |
| 640 | (let ((sink (gdb-instance-output-sink))) | 628 | (let ((sink (gdb-get-output-sink))) |
| 641 | (cond | 629 | (cond |
| 642 | ((eq sink 'inferior) | 630 | ((eq sink 'inferior) |
| 643 | (set-gdb-instance-output-sink 'user)) | 631 | (gdb-set-output-sink 'user)) |
| 644 | ((eq sink 'user) t) | 632 | ((eq sink 'user) t) |
| 645 | ((eq sink 'emacs) t) | 633 | ((eq sink 'emacs) t) |
| 646 | (t (error "Unexpected frame-begin annotation (%S)" sink))))) | 634 | (t (error "Unexpected frame-begin annotation (%S)" sink))))) |
| @@ -648,40 +636,37 @@ that if we already set the output sink to 'user in gdb-stopping, that is fine." | |||
| 648 | (defun gdb-post-prompt (ignored) | 636 | (defun gdb-post-prompt (ignored) |
| 649 | "An annotation handler for `post-prompt'. This begins the collection of | 637 | "An annotation handler for `post-prompt'. This begins the collection of |
| 650 | output from the current command if that happens to be appropriate." | 638 | output from the current command if that happens to be appropriate." |
| 651 | (if (not (gdb-instance-pending-triggers)) | 639 | (if (not (gdb-get-pending-triggers)) |
| 652 | (progn | 640 | (progn |
| 653 | (gdb-invalidate-registers ignored) | 641 | (gdb-invalidate-registers ignored) |
| 654 | (gdb-invalidate-locals ignored) | 642 | (gdb-invalidate-locals ignored) |
| 655 | (gdb-invalidate-display ignored))) | 643 | (gdb-invalidate-display ignored))) |
| 656 | (let ((sink (gdb-instance-output-sink))) | 644 | (let ((sink (gdb-get-output-sink))) |
| 657 | (cond | 645 | (cond |
| 658 | ((eq sink 'user) t) | 646 | ((eq sink 'user) t) |
| 659 | ((eq sink 'pre-emacs) | 647 | ((eq sink 'pre-emacs) |
| 660 | (set-gdb-instance-output-sink 'emacs)) | 648 | (gdb-set-output-sink 'emacs)) |
| 661 | (t | 649 | (t |
| 662 | (set-gdb-instance-output-sink 'user) | 650 | (gdb-set-output-sink 'user) |
| 663 | (error "Output sink phase error 3"))))) | 651 | (error "Output sink phase error 3"))))) |
| 664 | 652 | ||
| 665 | ;; If we get an error whilst evaluating one of the expressions | 653 | ;; If we get an error whilst evaluating one of the expressions |
| 666 | ;; we won't get the display-end annotation. Set the sink back to | 654 | ;; we won't get the display-end annotation. Set the sink back to |
| 667 | ;; user to make sure that the error message is seen | 655 | ;; user to make sure that the error message is seen |
| 668 | (defun gdb-error-begin (ignored) | 656 | (defun gdb-error-begin (ignored) |
| 669 | (set-gdb-instance-output-sink 'user)) | 657 | (gdb-set-output-sink 'user)) |
| 670 | 658 | ||
| 671 | (defun gdb-display-begin (ignored) | 659 | (defun gdb-display-begin (ignored) |
| 672 | (if (gdb-get-instance-buffer 'gdb-display-buffer) | 660 | (gdb-set-output-sink 'emacs) |
| 673 | (progn | 661 | (gdb-clear-partial-output) |
| 674 | (set-gdb-instance-output-sink 'emacs) | 662 | (setq gdb-display-in-progress t)) |
| 675 | (gdb-clear-partial-output) | ||
| 676 | (setq gdb-display-in-progress t)) | ||
| 677 | (set-gdb-instance-output-sink 'user))) | ||
| 678 | 663 | ||
| 679 | (defvar gdb-expression-buffer-name) | 664 | (defvar gdb-expression-buffer-name) |
| 680 | (defvar gdb-display-number) | 665 | (defvar gdb-display-number) |
| 681 | (defvar gdb-dive-display-number) | 666 | (defvar gdb-dive-display-number) |
| 682 | 667 | ||
| 683 | (defun gdb-display-number-end (ignored) | 668 | (defun gdb-display-number-end (ignored) |
| 684 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 669 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 685 | (setq gdb-display-number (buffer-string)) | 670 | (setq gdb-display-number (buffer-string)) |
| 686 | (setq gdb-expression-buffer-name | 671 | (setq gdb-expression-buffer-name |
| 687 | (concat "*display " gdb-display-number "*")) | 672 | (concat "*display " gdb-display-number "*")) |
| @@ -707,7 +692,7 @@ output from the current command if that happens to be appropriate." | |||
| 707 | (tool-bar-lines . nil) | 692 | (tool-bar-lines . nil) |
| 708 | (menu-bar-lines . nil) | 693 | (menu-bar-lines . nil) |
| 709 | (minibuffer . nil))))))) | 694 | (minibuffer . nil))))))) |
| 710 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 695 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 711 | (setq gdb-dive nil)) | 696 | (setq gdb-dive nil)) |
| 712 | 697 | ||
| 713 | (defvar gdb-current-frame nil) | 698 | (defvar gdb-current-frame nil) |
| @@ -721,7 +706,7 @@ output from the current command if that happens to be appropriate." | |||
| 721 | (delete-region (line-beginning-position) (line-beginning-position 2))) | 706 | (delete-region (line-beginning-position) (line-beginning-position 2))) |
| 722 | 707 | ||
| 723 | (defun gdb-display-end (ignored) | 708 | (defun gdb-display-end (ignored) |
| 724 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 709 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 725 | (goto-char (point-min)) | 710 | (goto-char (point-min)) |
| 726 | (search-forward ": ") | 711 | (search-forward ": ") |
| 727 | (looking-at "\\(.*?\\) =") | 712 | (looking-at "\\(.*?\\) =") |
| @@ -750,7 +735,7 @@ output from the current command if that happens to be appropriate." | |||
| 750 | (setq buffer-read-only nil) | 735 | (setq buffer-read-only nil) |
| 751 | (delete-region (point-min) (point-max)) | 736 | (delete-region (point-min) (point-max)) |
| 752 | (insert-buffer-substring | 737 | (insert-buffer-substring |
| 753 | (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 738 | (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 754 | (setq buffer-read-only t))) | 739 | (setq buffer-read-only t))) |
| 755 | ;; display expression name... | 740 | ;; display expression name... |
| 756 | (goto-char (point-min)) | 741 | (goto-char (point-min)) |
| @@ -760,7 +745,7 @@ output from the current command if that happens to be appropriate." | |||
| 760 | (set-buffer gdb-expression-buffer-name) | 745 | (set-buffer gdb-expression-buffer-name) |
| 761 | (setq buffer-read-only nil) | 746 | (setq buffer-read-only nil) |
| 762 | (delete-region (point-min) (point-max)) | 747 | (delete-region (point-min) (point-max)) |
| 763 | (insert-buffer-substring (gdb-get-instance-buffer | 748 | (insert-buffer-substring (gdb-get-buffer |
| 764 | 'gdb-partial-output-buffer) | 749 | 'gdb-partial-output-buffer) |
| 765 | start end) | 750 | start end) |
| 766 | (insert "\n"))) | 751 | (insert "\n"))) |
| @@ -777,16 +762,16 @@ output from the current command if that happens to be appropriate." | |||
| 777 | (setq gdb-annotation-arg (match-string 1)) | 762 | (setq gdb-annotation-arg (match-string 1)) |
| 778 | (gdb-field-format-begin)))) | 763 | (gdb-field-format-begin)))) |
| 779 | (save-excursion | 764 | (save-excursion |
| 780 | (set-buffer gdb-expression-buffer-name) | 765 | (set-buffer gdb-expression-buffer-name) |
| 781 | (if gdb-dive-display-number | 766 | (if gdb-dive-display-number |
| 782 | (progn | 767 | (progn |
| 783 | (setq buffer-read-only nil) | 768 | (setq buffer-read-only nil) |
| 784 | (goto-char (point-max)) | 769 | (goto-char (point-max)) |
| 785 | (insert "\n") | 770 | (insert "\n") |
| 786 | (insert-text-button "[back]" 'type 'gdb-display-back) | 771 | (insert-text-button "[back]" 'type 'gdb-display-back) |
| 787 | (setq buffer-read-only t)))) | 772 | (setq buffer-read-only t)))) |
| 788 | (gdb-clear-partial-output) | 773 | (gdb-clear-partial-output) |
| 789 | (set-gdb-instance-output-sink 'user) | 774 | (gdb-set-output-sink 'user) |
| 790 | (setq gdb-display-in-progress nil)) | 775 | (setq gdb-display-in-progress nil)) |
| 791 | 776 | ||
| 792 | (define-button-type 'gdb-display-back | 777 | (define-button-type 'gdb-display-back |
| @@ -796,7 +781,7 @@ output from the current command if that happens to be appropriate." | |||
| 796 | (defun gdb-display-go-back () | 781 | (defun gdb-display-go-back () |
| 797 | ;; delete display so they don't accumulate and delete buffer | 782 | ;; delete display so they don't accumulate and delete buffer |
| 798 | (let ((number gdb-display-number)) | 783 | (let ((number gdb-display-number)) |
| 799 | (gdb-instance-enqueue-input | 784 | (gdb-enqueue-input |
| 800 | (list (concat "server delete display " number "\n") 'ignore)) | 785 | (list (concat "server delete display " number "\n") 'ignore)) |
| 801 | (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) | 786 | (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) |
| 802 | (kill-buffer (get-buffer (concat "*display " number "*"))))) | 787 | (kill-buffer (get-buffer (concat "*display " number "*"))))) |
| @@ -810,7 +795,7 @@ output from the current command if that happens to be appropriate." | |||
| 810 | (if gdb-display-in-progress | 795 | (if gdb-display-in-progress |
| 811 | (progn | 796 | (progn |
| 812 | (save-excursion | 797 | (save-excursion |
| 813 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 798 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 814 | (goto-char (point-max)) | 799 | (goto-char (point-max)) |
| 815 | (insert (concat "\n##array-section-begin " args "\n")))))) | 800 | (insert (concat "\n##array-section-begin " args "\n")))))) |
| 816 | 801 | ||
| @@ -818,7 +803,7 @@ output from the current command if that happens to be appropriate." | |||
| 818 | (if gdb-display-in-progress | 803 | (if gdb-display-in-progress |
| 819 | (progn | 804 | (progn |
| 820 | (save-excursion | 805 | (save-excursion |
| 821 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 806 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 822 | (goto-char (point-max)) | 807 | (goto-char (point-max)) |
| 823 | (insert "\n##array-section-end\n"))))) | 808 | (insert "\n##array-section-end\n"))))) |
| 824 | 809 | ||
| @@ -826,7 +811,7 @@ output from the current command if that happens to be appropriate." | |||
| 826 | (if gdb-display-in-progress | 811 | (if gdb-display-in-progress |
| 827 | (progn | 812 | (progn |
| 828 | (save-excursion | 813 | (save-excursion |
| 829 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 814 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 830 | (goto-char (point-max)) | 815 | (goto-char (point-max)) |
| 831 | (insert (concat "\n##field-begin " args "\n")))))) | 816 | (insert (concat "\n##field-begin " args "\n")))))) |
| 832 | 817 | ||
| @@ -834,7 +819,7 @@ output from the current command if that happens to be appropriate." | |||
| 834 | (if gdb-display-in-progress | 819 | (if gdb-display-in-progress |
| 835 | (progn | 820 | (progn |
| 836 | (save-excursion | 821 | (save-excursion |
| 837 | (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) | 822 | (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer)) |
| 838 | (goto-char (point-max)) | 823 | (goto-char (point-max)) |
| 839 | (insert "\n##field-end\n"))))) | 824 | (insert "\n##field-end\n"))))) |
| 840 | 825 | ||
| @@ -904,7 +889,7 @@ output from the current command if that happens to be appropriate." | |||
| 904 | (setq gdb-full-expression (substring gdb-full-expression 1 nil))) | 889 | (setq gdb-full-expression (substring gdb-full-expression 1 nil))) |
| 905 | (setq gdb-full-expression | 890 | (setq gdb-full-expression |
| 906 | (concat gdb-full-expression gdb-part-expression "." gdb-last-field)) | 891 | (concat gdb-full-expression gdb-part-expression "." gdb-last-field)) |
| 907 | (gdb-instance-enqueue-input | 892 | (gdb-enqueue-input |
| 908 | (list (concat "server display" gdb-display-char | 893 | (list (concat "server display" gdb-display-char |
| 909 | " " gdb-full-expression "\n") | 894 | " " gdb-full-expression "\n") |
| 910 | 'ignore))))) | 895 | 'ignore))))) |
| @@ -920,7 +905,7 @@ output from the current command if that happens to be appropriate." | |||
| 920 | (while (<= num gdb-nesting-level) | 905 | (while (<= num gdb-nesting-level) |
| 921 | (insert "\t") | 906 | (insert "\t") |
| 922 | (setq num (+ num 1))) | 907 | (setq num (+ num 1))) |
| 923 | (insert-buffer-substring (gdb-get-instance-buffer | 908 | (insert-buffer-substring (gdb-get-buffer |
| 924 | 'gdb-partial-output-buffer) | 909 | 'gdb-partial-output-buffer) |
| 925 | start end) | 910 | start end) |
| 926 | (put-text-property (- (point) (- end start)) (- (point) 1) | 911 | (put-text-property (- (point) (- end start)) (- (point) 1) |
| @@ -1057,12 +1042,11 @@ output from the current command if that happens to be appropriate." | |||
| 1057 | (setq buffer-read-only t)) | 1042 | (setq buffer-read-only t)) |
| 1058 | 1043 | ||
| 1059 | (defun gud-gdba-marker-filter (string) | 1044 | (defun gud-gdba-marker-filter (string) |
| 1060 | "A gud marker filter for gdb. Handle a burst of output from a gdb instance. | 1045 | "A gud marker filter for gdb. Handle a burst of output from GDB." |
| 1061 | It must return output (if any) to be insterted in the gdb buffer." | ||
| 1062 | (save-match-data | 1046 | (save-match-data |
| 1063 | (let ( | 1047 | (let ( |
| 1064 | ;; Recall the left over burst from last time | 1048 | ;; Recall the left over burst from last time |
| 1065 | (burst (concat (gdb-instance-burst) string)) | 1049 | (burst (concat (gdb-get-burst) string)) |
| 1066 | ;; Start accumulating output for the GUD buffer | 1050 | ;; Start accumulating output for the GUD buffer |
| 1067 | (output "")) | 1051 | (output "")) |
| 1068 | 1052 | ||
| @@ -1104,7 +1088,7 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1104 | ;; Everything before the potential marker start can be output. | 1088 | ;; Everything before the potential marker start can be output. |
| 1105 | (setq output | 1089 | (setq output |
| 1106 | (gdb-concat-output output | 1090 | (gdb-concat-output output |
| 1107 | (substring burst 0 (match-beginning 0)))) | 1091 | (substring burst 0 (match-beginning 0)))) |
| 1108 | 1092 | ||
| 1109 | ;; Everything after, we save, to combine with later input. | 1093 | ;; Everything after, we save, to combine with later input. |
| 1110 | (setq burst (substring burst (match-beginning 0)))) | 1094 | (setq burst (substring burst (match-beginning 0)))) |
| @@ -1115,11 +1099,11 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1115 | (setq burst ""))) | 1099 | (setq burst ""))) |
| 1116 | 1100 | ||
| 1117 | ;; Save the remaining burst for the next call to this function. | 1101 | ;; Save the remaining burst for the next call to this function. |
| 1118 | (set-gdb-instance-burst burst) | 1102 | (gdb-set-burst burst) |
| 1119 | output))) | 1103 | output))) |
| 1120 | 1104 | ||
| 1121 | (defun gdb-concat-output (so-far new) | 1105 | (defun gdb-concat-output (so-far new) |
| 1122 | (let ((sink (gdb-instance-output-sink ))) | 1106 | (let ((sink (gdb-get-output-sink ))) |
| 1123 | (cond | 1107 | (cond |
| 1124 | ((eq sink 'user) (concat so-far new)) | 1108 | ((eq sink 'user) (concat so-far new)) |
| 1125 | ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) | 1109 | ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) |
| @@ -1134,44 +1118,43 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1134 | (defun gdb-append-to-partial-output (string) | 1118 | (defun gdb-append-to-partial-output (string) |
| 1135 | (save-excursion | 1119 | (save-excursion |
| 1136 | (set-buffer | 1120 | (set-buffer |
| 1137 | (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) | 1121 | (gdb-get-create-buffer 'gdb-partial-output-buffer)) |
| 1138 | (goto-char (point-max)) | 1122 | (goto-char (point-max)) |
| 1139 | (insert string))) | 1123 | (insert string))) |
| 1140 | 1124 | ||
| 1141 | (defun gdb-clear-partial-output () | 1125 | (defun gdb-clear-partial-output () |
| 1142 | (save-excursion | 1126 | (save-excursion |
| 1143 | (set-buffer | 1127 | (set-buffer |
| 1144 | (gdb-get-create-instance-buffer 'gdb-partial-output-buffer)) | 1128 | (gdb-get-create-buffer 'gdb-partial-output-buffer)) |
| 1145 | (delete-region (point-min) (point-max)))) | 1129 | (delete-region (point-min) (point-max)))) |
| 1146 | 1130 | ||
| 1147 | (defun gdb-append-to-inferior-io (string) | 1131 | (defun gdb-append-to-inferior-io (string) |
| 1148 | (save-excursion | 1132 | (save-excursion |
| 1149 | (set-buffer | 1133 | (set-buffer |
| 1150 | (gdb-get-create-instance-buffer 'gdb-inferior-io)) | 1134 | (gdb-get-create-buffer 'gdb-inferior-io)) |
| 1151 | (goto-char (point-max)) | 1135 | (goto-char (point-max)) |
| 1152 | (insert-before-markers string)) | 1136 | (insert-before-markers string)) |
| 1153 | (if (not (string-equal string "")) | 1137 | (if (not (string-equal string "")) |
| 1154 | (gdb-display-buffer | 1138 | (gdb-display-buffer |
| 1155 | (gdb-get-create-instance-buffer 'gdb-inferior-io)))) | 1139 | (gdb-get-create-buffer 'gdb-inferior-io)))) |
| 1156 | 1140 | ||
| 1157 | (defun gdb-clear-inferior-io () | 1141 | (defun gdb-clear-inferior-io () |
| 1158 | (save-excursion | 1142 | (save-excursion |
| 1159 | (set-buffer | 1143 | (set-buffer |
| 1160 | (gdb-get-create-instance-buffer 'gdb-inferior-io)) | 1144 | (gdb-get-create-buffer 'gdb-inferior-io)) |
| 1161 | (delete-region (point-min) (point-max)))) | 1145 | (delete-region (point-min) (point-max)))) |
| 1162 | 1146 | ||
| 1163 | 1147 | ||
| 1164 | ;; One trick is to have a command who's output is always available in | 1148 | ;; One trick is to have a command who's output is always available in a buffer |
| 1165 | ;; a buffer of it's own, and is always up to date. We build several | 1149 | ;; of it's own, and is always up to date. We build several buffers of this |
| 1166 | ;; buffers of this type. | 1150 | ;; type. |
| 1167 | ;; | 1151 | ;; |
| 1168 | ;; There are two aspects to this: gdb has to tell us when the output | 1152 | ;; There are two aspects to this: gdb has to tell us when the output for that |
| 1169 | ;; for that command might have changed, and we have to be able to run | 1153 | ;; command might have changed, and we have to be able to run the command |
| 1170 | ;; the command behind the user's back. | 1154 | ;; behind the user's back. |
| 1171 | ;; | 1155 | ;; |
| 1172 | ;; The idle input queue and the output phasing associated with | 1156 | ;; The idle input queue and the output phasing associated with the variable |
| 1173 | ;; the instance variable `(gdb-instance-output-sink)' help | 1157 | ;; gdb-output-sink help us to run commands behind the user's back. |
| 1174 | ;; us to run commands behind the user's back. | ||
| 1175 | ;; | 1158 | ;; |
| 1176 | ;; Below is the code for specificly managing buffers of output from one | 1159 | ;; Below is the code for specificly managing buffers of output from one |
| 1177 | ;; command. | 1160 | ;; command. |
| @@ -1191,38 +1174,38 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1191 | `(defun ,name (&optional ignored) | 1174 | `(defun ,name (&optional ignored) |
| 1192 | (if (and (,demand-predicate) | 1175 | (if (and (,demand-predicate) |
| 1193 | (not (member ',name | 1176 | (not (member ',name |
| 1194 | (gdb-instance-pending-triggers)))) | 1177 | (gdb-get-pending-triggers)))) |
| 1195 | (progn | 1178 | (progn |
| 1196 | (gdb-instance-enqueue-idle-input | 1179 | (gdb-enqueue-idle-input |
| 1197 | (list ,gdb-command ',output-handler)) | 1180 | (list ,gdb-command ',output-handler)) |
| 1198 | (set-gdb-instance-pending-triggers | 1181 | (gdb-set-pending-triggers |
| 1199 | (cons ',name | 1182 | (cons ',name |
| 1200 | (gdb-instance-pending-triggers))))))) | 1183 | (gdb-get-pending-triggers))))))) |
| 1201 | 1184 | ||
| 1202 | (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) | 1185 | (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) |
| 1203 | `(defun ,name () | 1186 | `(defun ,name () |
| 1204 | (set-gdb-instance-pending-triggers | 1187 | (gdb-set-pending-triggers |
| 1205 | (delq ',trigger | 1188 | (delq ',trigger |
| 1206 | (gdb-instance-pending-triggers))) | 1189 | (gdb-get-pending-triggers))) |
| 1207 | (let ((buf (gdb-get-instance-buffer ',buf-key))) | 1190 | (let ((buf (gdb-get-buffer ',buf-key))) |
| 1208 | (and buf | 1191 | (and buf |
| 1209 | (save-excursion | 1192 | (save-excursion |
| 1210 | (set-buffer buf) | 1193 | (set-buffer buf) |
| 1211 | (let ((p (point)) | 1194 | (let ((p (point)) |
| 1212 | (buffer-read-only nil)) | 1195 | (buffer-read-only nil)) |
| 1213 | (delete-region (point-min) (point-max)) | 1196 | (delete-region (point-min) (point-max)) |
| 1214 | (insert-buffer-substring (gdb-get-create-instance-buffer | 1197 | (insert-buffer-substring (gdb-get-create-buffer |
| 1215 | 'gdb-partial-output-buffer)) | 1198 | 'gdb-partial-output-buffer)) |
| 1216 | (goto-char p))))) | 1199 | (goto-char p))))) |
| 1217 | ;; put customisation here | 1200 | ;; put customisation here |
| 1218 | (,custom-defun))) | 1201 | (,custom-defun))) |
| 1219 | 1202 | ||
| 1220 | (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command | 1203 | (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command |
| 1221 | output-handler-name custom-defun) | 1204 | output-handler-name custom-defun) |
| 1222 | `(progn | 1205 | `(progn |
| 1223 | (def-gdb-auto-update-trigger ,trigger-name | 1206 | (def-gdb-auto-update-trigger ,trigger-name |
| 1224 | ;; The demand predicate: | 1207 | ;; The demand predicate: |
| 1225 | (lambda () (gdb-get-instance-buffer ',buffer-key)) | 1208 | (lambda () (gdb-get-buffer ',buffer-key)) |
| 1226 | ,gdb-command | 1209 | ,gdb-command |
| 1227 | ,output-handler-name) | 1210 | ,output-handler-name) |
| 1228 | (def-gdb-auto-update-handler ,output-handler-name | 1211 | (def-gdb-auto-update-handler ,output-handler-name |
| @@ -1235,9 +1218,9 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1235 | ;; These display the output of `info breakpoints'. | 1218 | ;; These display the output of `info breakpoints'. |
| 1236 | ;; | 1219 | ;; |
| 1237 | 1220 | ||
| 1238 | (gdb-set-instance-buffer-rules 'gdb-breakpoints-buffer | 1221 | (gdb-set-buffer-rules 'gdb-breakpoints-buffer |
| 1239 | 'gdb-breakpoints-buffer-name | 1222 | 'gdb-breakpoints-buffer-name |
| 1240 | 'gdb-breakpoints-mode) | 1223 | 'gdb-breakpoints-mode) |
| 1241 | 1224 | ||
| 1242 | (def-gdb-auto-updated-buffer gdb-breakpoints-buffer | 1225 | (def-gdb-auto-updated-buffer gdb-breakpoints-buffer |
| 1243 | ;; This defines the auto update rule for buffers of type | 1226 | ;; This defines the auto update rule for buffers of type |
| @@ -1254,7 +1237,7 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1254 | ;; from the command above. That function will copy the output into | 1237 | ;; from the command above. That function will copy the output into |
| 1255 | ;; the appropriately typed buffer. That function will be called: | 1238 | ;; the appropriately typed buffer. That function will be called: |
| 1256 | gdb-info-breakpoints-handler | 1239 | gdb-info-breakpoints-handler |
| 1257 | ;; buffer specific functions | 1240 | ;; buffer specific functions |
| 1258 | gdb-info-breakpoints-custom) | 1241 | gdb-info-breakpoints-custom) |
| 1259 | 1242 | ||
| 1260 | (defvar gdb-cdir nil "Compilation directory.") | 1243 | (defvar gdb-cdir nil "Compilation directory.") |
| @@ -1278,7 +1261,7 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1278 | (setq buffers (cdr buffers))))) | 1261 | (setq buffers (cdr buffers))))) |
| 1279 | 1262 | ||
| 1280 | (save-excursion | 1263 | (save-excursion |
| 1281 | (set-buffer (gdb-get-instance-buffer 'gdb-breakpoints-buffer)) | 1264 | (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)) |
| 1282 | (save-excursion | 1265 | (save-excursion |
| 1283 | (goto-char (point-min)) | 1266 | (goto-char (point-min)) |
| 1284 | (while (< (point) (- (point-max) 1)) | 1267 | (while (< (point) (- (point-max) 1)) |
| @@ -1335,17 +1318,17 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1335 | 1318 | ||
| 1336 | (defun gdb-breakpoints-buffer-name () | 1319 | (defun gdb-breakpoints-buffer-name () |
| 1337 | (with-current-buffer gud-comint-buffer | 1320 | (with-current-buffer gud-comint-buffer |
| 1338 | (concat "*breakpoints of " (gdb-instance-target-string) "*"))) | 1321 | (concat "*breakpoints of " (gdb-get-target-string) "*"))) |
| 1339 | 1322 | ||
| 1340 | (defun gdb-display-breakpoints-buffer () | 1323 | (defun gdb-display-breakpoints-buffer () |
| 1341 | (interactive) | 1324 | (interactive) |
| 1342 | (gdb-display-buffer | 1325 | (gdb-display-buffer |
| 1343 | (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) | 1326 | (gdb-get-create-buffer 'gdb-breakpoints-buffer))) |
| 1344 | 1327 | ||
| 1345 | (defun gdb-frame-breakpoints-buffer () | 1328 | (defun gdb-frame-breakpoints-buffer () |
| 1346 | (interactive) | 1329 | (interactive) |
| 1347 | (switch-to-buffer-other-frame | 1330 | (switch-to-buffer-other-frame |
| 1348 | (gdb-get-create-instance-buffer 'gdb-breakpoints-buffer))) | 1331 | (gdb-get-create-buffer 'gdb-breakpoints-buffer))) |
| 1349 | 1332 | ||
| 1350 | (defvar gdb-breakpoints-mode-map | 1333 | (defvar gdb-breakpoints-mode-map |
| 1351 | (let ((map (make-sparse-keymap)) | 1334 | (let ((map (make-sparse-keymap)) |
| @@ -1372,13 +1355,13 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1372 | (gdb-invalidate-breakpoints)) | 1355 | (gdb-invalidate-breakpoints)) |
| 1373 | 1356 | ||
| 1374 | (defun gdb-toggle-bp-this-line () | 1357 | (defun gdb-toggle-bp-this-line () |
| 1375 | "Enable/disable the breakpoint of the current line." | 1358 | "Enable/disable the breakpoint of the current line." |
| 1376 | (interactive) | 1359 | (interactive) |
| 1377 | (save-excursion | 1360 | (save-excursion |
| 1378 | (beginning-of-line 1) | 1361 | (beginning-of-line 1) |
| 1379 | (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | 1362 | (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) |
| 1380 | (error "Not recognized as break/watchpoint line") | 1363 | (error "Not recognized as break/watchpoint line") |
| 1381 | (gdb-instance-enqueue-input | 1364 | (gdb-enqueue-input |
| 1382 | (list | 1365 | (list |
| 1383 | (concat | 1366 | (concat |
| 1384 | (if (eq ?y (char-after (match-beginning 2))) | 1367 | (if (eq ?y (char-after (match-beginning 2))) |
| @@ -1389,13 +1372,13 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1389 | 'ignore))))) | 1372 | 'ignore))))) |
| 1390 | 1373 | ||
| 1391 | (defun gdb-delete-bp-this-line () | 1374 | (defun gdb-delete-bp-this-line () |
| 1392 | "Delete the breakpoint of the current line." | 1375 | "Delete the breakpoint of the current line." |
| 1393 | (interactive) | 1376 | (interactive) |
| 1394 | (beginning-of-line 1) | 1377 | (beginning-of-line 1) |
| 1395 | (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) | 1378 | (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) |
| 1396 | (error "Not recognized as break/watchpoint line") | 1379 | (error "Not recognized as break/watchpoint line") |
| 1397 | (gdb-instance-enqueue-input | 1380 | (gdb-enqueue-input |
| 1398 | (list (concat "server delete " (match-string 1) "\n") 'ignore)))) | 1381 | (list (concat "server delete " (match-string 1) "\n") 'ignore)))) |
| 1399 | 1382 | ||
| 1400 | (defvar gdb-source-window nil) | 1383 | (defvar gdb-source-window nil) |
| 1401 | 1384 | ||
| @@ -1424,9 +1407,9 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1424 | ;; Alas, if your stack is deep, they are costly. | 1407 | ;; Alas, if your stack is deep, they are costly. |
| 1425 | ;; | 1408 | ;; |
| 1426 | 1409 | ||
| 1427 | (gdb-set-instance-buffer-rules 'gdb-stack-buffer | 1410 | (gdb-set-buffer-rules 'gdb-stack-buffer |
| 1428 | 'gdb-stack-buffer-name | 1411 | 'gdb-stack-buffer-name |
| 1429 | 'gdb-frames-mode) | 1412 | 'gdb-frames-mode) |
| 1430 | 1413 | ||
| 1431 | (def-gdb-auto-updated-buffer gdb-stack-buffer | 1414 | (def-gdb-auto-updated-buffer gdb-stack-buffer |
| 1432 | gdb-invalidate-frames | 1415 | gdb-invalidate-frames |
| @@ -1436,7 +1419,7 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1436 | 1419 | ||
| 1437 | (defun gdb-info-frames-custom () | 1420 | (defun gdb-info-frames-custom () |
| 1438 | (save-excursion | 1421 | (save-excursion |
| 1439 | (set-buffer (gdb-get-instance-buffer 'gdb-stack-buffer)) | 1422 | (set-buffer (gdb-get-buffer 'gdb-stack-buffer)) |
| 1440 | (let ((buffer-read-only nil)) | 1423 | (let ((buffer-read-only nil)) |
| 1441 | (goto-char (point-min)) | 1424 | (goto-char (point-min)) |
| 1442 | (looking-at "\\S-*\\s-*\\(\\S-*\\)") | 1425 | (looking-at "\\S-*\\s-*\\(\\S-*\\)") |
| @@ -1450,17 +1433,17 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1450 | (defun gdb-stack-buffer-name () | 1433 | (defun gdb-stack-buffer-name () |
| 1451 | (with-current-buffer gud-comint-buffer | 1434 | (with-current-buffer gud-comint-buffer |
| 1452 | (concat "*stack frames of " | 1435 | (concat "*stack frames of " |
| 1453 | (gdb-instance-target-string) "*"))) | 1436 | (gdb-get-target-string) "*"))) |
| 1454 | 1437 | ||
| 1455 | (defun gdb-display-stack-buffer () | 1438 | (defun gdb-display-stack-buffer () |
| 1456 | (interactive) | 1439 | (interactive) |
| 1457 | (gdb-display-buffer | 1440 | (gdb-display-buffer |
| 1458 | (gdb-get-create-instance-buffer 'gdb-stack-buffer))) | 1441 | (gdb-get-create-buffer 'gdb-stack-buffer))) |
| 1459 | 1442 | ||
| 1460 | (defun gdb-frame-stack-buffer () | 1443 | (defun gdb-frame-stack-buffer () |
| 1461 | (interactive) | 1444 | (interactive) |
| 1462 | (switch-to-buffer-other-frame | 1445 | (switch-to-buffer-other-frame |
| 1463 | (gdb-get-create-instance-buffer 'gdb-stack-buffer))) | 1446 | (gdb-get-create-buffer 'gdb-stack-buffer))) |
| 1464 | 1447 | ||
| 1465 | (defvar gdb-frames-mode-map | 1448 | (defvar gdb-frames-mode-map |
| 1466 | (let ((map (make-sparse-keymap))) | 1449 | (let ((map (make-sparse-keymap))) |
| @@ -1485,7 +1468,7 @@ It must return output (if any) to be insterted in the gdb buffer." | |||
| 1485 | n))) | 1468 | n))) |
| 1486 | 1469 | ||
| 1487 | (defun gdb-frames-mouse-select (e) | 1470 | (defun gdb-frames-mouse-select (e) |
| 1488 | "Make the selected frame become the current frame and | 1471 | "Make the selected frame become the current frame and |
| 1489 | display the source in the source buffer." | 1472 | display the source in the source buffer." |
| 1490 | (interactive "e") | 1473 | (interactive "e") |
| 1491 | (let (selection) | 1474 | (let (selection) |
| @@ -1497,10 +1480,10 @@ display the source in the source buffer." | |||
| 1497 | (select-window (posn-window (event-end e))) | 1480 | (select-window (posn-window (event-end e))) |
| 1498 | (save-excursion | 1481 | (save-excursion |
| 1499 | (set-buffer gud-comint-buffer) | 1482 | (set-buffer gud-comint-buffer) |
| 1500 | (gdb-instance-enqueue-input | 1483 | (gdb-enqueue-input |
| 1501 | (list (gud-format-command "server frame %p\n" selection) | 1484 | (list (gud-format-command "server frame %p\n" selection) |
| 1502 | 'ignore)) | 1485 | 'ignore)) |
| 1503 | (gud-display-frame)))) | 1486 | (gud-display-frame)))) |
| 1504 | 1487 | ||
| 1505 | 1488 | ||
| 1506 | ;; | 1489 | ;; |
| @@ -1515,9 +1498,9 @@ display the source in the source buffer." | |||
| 1515 | 1498 | ||
| 1516 | (defun gdb-info-registers-custom ()) | 1499 | (defun gdb-info-registers-custom ()) |
| 1517 | 1500 | ||
| 1518 | (gdb-set-instance-buffer-rules 'gdb-registers-buffer | 1501 | (gdb-set-buffer-rules 'gdb-registers-buffer |
| 1519 | 'gdb-registers-buffer-name | 1502 | 'gdb-registers-buffer-name |
| 1520 | 'gdb-registers-mode) | 1503 | 'gdb-registers-mode) |
| 1521 | 1504 | ||
| 1522 | (defvar gdb-registers-mode-map | 1505 | (defvar gdb-registers-mode-map |
| 1523 | (let ((map (make-sparse-keymap))) | 1506 | (let ((map (make-sparse-keymap))) |
| @@ -1536,17 +1519,17 @@ display the source in the source buffer." | |||
| 1536 | 1519 | ||
| 1537 | (defun gdb-registers-buffer-name () | 1520 | (defun gdb-registers-buffer-name () |
| 1538 | (with-current-buffer gud-comint-buffer | 1521 | (with-current-buffer gud-comint-buffer |
| 1539 | (concat "*registers of " (gdb-instance-target-string) "*"))) | 1522 | (concat "*registers of " (gdb-get-target-string) "*"))) |
| 1540 | 1523 | ||
| 1541 | (defun gdb-display-registers-buffer () | 1524 | (defun gdb-display-registers-buffer () |
| 1542 | (interactive) | 1525 | (interactive) |
| 1543 | (gdb-display-buffer | 1526 | (gdb-display-buffer |
| 1544 | (gdb-get-create-instance-buffer 'gdb-registers-buffer))) | 1527 | (gdb-get-create-buffer 'gdb-registers-buffer))) |
| 1545 | 1528 | ||
| 1546 | (defun gdb-frame-registers-buffer () | 1529 | (defun gdb-frame-registers-buffer () |
| 1547 | (interactive) | 1530 | (interactive) |
| 1548 | (switch-to-buffer-other-frame | 1531 | (switch-to-buffer-other-frame |
| 1549 | (gdb-get-create-instance-buffer 'gdb-registers-buffer))) | 1532 | (gdb-get-create-buffer 'gdb-registers-buffer))) |
| 1550 | 1533 | ||
| 1551 | ;; | 1534 | ;; |
| 1552 | ;; Locals buffers | 1535 | ;; Locals buffers |
| @@ -1561,9 +1544,9 @@ display the source in the source buffer." | |||
| 1561 | 1544 | ||
| 1562 | ;;Abbreviate for arrays and structures. These can be expanded using gud-display | 1545 | ;;Abbreviate for arrays and structures. These can be expanded using gud-display |
| 1563 | (defun gdb-info-locals-handler nil | 1546 | (defun gdb-info-locals-handler nil |
| 1564 | (set-gdb-instance-pending-triggers (delq 'gdb-invalidate-locals | 1547 | (gdb-set-pending-triggers (delq 'gdb-invalidate-locals |
| 1565 | (gdb-instance-pending-triggers))) | 1548 | (gdb-get-pending-triggers))) |
| 1566 | (let ((buf (gdb-get-instance-buffer 'gdb-partial-output-buffer))) | 1549 | (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer))) |
| 1567 | (save-excursion | 1550 | (save-excursion |
| 1568 | (set-buffer buf) | 1551 | (set-buffer buf) |
| 1569 | (goto-char (point-min)) | 1552 | (goto-char (point-min)) |
| @@ -1575,23 +1558,23 @@ display the source in the source buffer." | |||
| 1575 | (goto-char (point-min)) | 1558 | (goto-char (point-min)) |
| 1576 | (while (re-search-forward "{.*=.*\n" nil t) | 1559 | (while (re-search-forward "{.*=.*\n" nil t) |
| 1577 | (replace-match "(structure);\n" nil nil)))) | 1560 | (replace-match "(structure);\n" nil nil)))) |
| 1578 | (let ((buf (gdb-get-instance-buffer 'gdb-locals-buffer))) | 1561 | (let ((buf (gdb-get-buffer 'gdb-locals-buffer))) |
| 1579 | (and buf (save-excursion | 1562 | (and buf (save-excursion |
| 1580 | (set-buffer buf) | 1563 | (set-buffer buf) |
| 1581 | (let ((p (point)) | 1564 | (let ((p (point)) |
| 1582 | (buffer-read-only nil)) | 1565 | (buffer-read-only nil)) |
| 1583 | (delete-region (point-min) (point-max)) | 1566 | (delete-region (point-min) (point-max)) |
| 1584 | (insert-buffer-substring (gdb-get-create-instance-buffer | 1567 | (insert-buffer-substring (gdb-get-create-buffer |
| 1585 | 'gdb-partial-output-buffer)) | 1568 | 'gdb-partial-output-buffer)) |
| 1586 | (goto-char p))))) | 1569 | (goto-char p))))) |
| 1587 | (run-hooks 'gdb-info-locals-hook)) | 1570 | (run-hooks 'gdb-info-locals-hook)) |
| 1588 | 1571 | ||
| 1589 | (defun gdb-info-locals-custom () | 1572 | (defun gdb-info-locals-custom () |
| 1590 | nil) | 1573 | nil) |
| 1591 | 1574 | ||
| 1592 | (gdb-set-instance-buffer-rules 'gdb-locals-buffer | 1575 | (gdb-set-buffer-rules 'gdb-locals-buffer |
| 1593 | 'gdb-locals-buffer-name | 1576 | 'gdb-locals-buffer-name |
| 1594 | 'gdb-locals-mode) | 1577 | 'gdb-locals-mode) |
| 1595 | 1578 | ||
| 1596 | (defvar gdb-locals-mode-map | 1579 | (defvar gdb-locals-mode-map |
| 1597 | (let ((map (make-sparse-keymap))) | 1580 | (let ((map (make-sparse-keymap))) |
| @@ -1610,23 +1593,23 @@ display the source in the source buffer." | |||
| 1610 | 1593 | ||
| 1611 | (defun gdb-locals-buffer-name () | 1594 | (defun gdb-locals-buffer-name () |
| 1612 | (with-current-buffer gud-comint-buffer | 1595 | (with-current-buffer gud-comint-buffer |
| 1613 | (concat "*locals of " (gdb-instance-target-string) "*"))) | 1596 | (concat "*locals of " (gdb-get-target-string) "*"))) |
| 1614 | 1597 | ||
| 1615 | (defun gdb-display-locals-buffer () | 1598 | (defun gdb-display-locals-buffer () |
| 1616 | (interactive) | 1599 | (interactive) |
| 1617 | (gdb-display-buffer | 1600 | (gdb-display-buffer |
| 1618 | (gdb-get-create-instance-buffer 'gdb-locals-buffer))) | 1601 | (gdb-get-create-buffer 'gdb-locals-buffer))) |
| 1619 | 1602 | ||
| 1620 | (defun gdb-frame-locals-buffer () | 1603 | (defun gdb-frame-locals-buffer () |
| 1621 | (interactive) | 1604 | (interactive) |
| 1622 | (switch-to-buffer-other-frame | 1605 | (switch-to-buffer-other-frame |
| 1623 | (gdb-get-create-instance-buffer 'gdb-locals-buffer))) | 1606 | (gdb-get-create-buffer 'gdb-locals-buffer))) |
| 1624 | ;; | 1607 | ;; |
| 1625 | ;; Display expression buffers (just allow one to start with) | 1608 | ;; Display expression buffers (just allow one to start with) |
| 1626 | ;; | 1609 | ;; |
| 1627 | (gdb-set-instance-buffer-rules 'gdb-display-buffer | 1610 | (gdb-set-buffer-rules 'gdb-display-buffer |
| 1628 | 'gdb-display-buffer-name | 1611 | 'gdb-display-buffer-name |
| 1629 | 'gdb-display-mode) | 1612 | 'gdb-display-mode) |
| 1630 | 1613 | ||
| 1631 | (def-gdb-auto-updated-buffer gdb-display-buffer | 1614 | (def-gdb-auto-updated-buffer gdb-display-buffer |
| 1632 | ;; `gdb-display-buffer'. | 1615 | ;; `gdb-display-buffer'. |
| @@ -1665,26 +1648,26 @@ display the source in the source buffer." | |||
| 1665 | 1648 | ||
| 1666 | (defun gdb-display-buffer-name () | 1649 | (defun gdb-display-buffer-name () |
| 1667 | (with-current-buffer gud-comint-buffer | 1650 | (with-current-buffer gud-comint-buffer |
| 1668 | (concat "*Displayed expressions of " (gdb-instance-target-string) "*"))) | 1651 | (concat "*Displayed expressions of " (gdb-get-target-string) "*"))) |
| 1669 | 1652 | ||
| 1670 | (defun gdb-display-display-buffer () | 1653 | (defun gdb-display-display-buffer () |
| 1671 | (interactive) | 1654 | (interactive) |
| 1672 | (gdb-display-buffer | 1655 | (gdb-display-buffer |
| 1673 | (gdb-get-create-instance-buffer 'gdb-display-buffer))) | 1656 | (gdb-get-create-buffer 'gdb-display-buffer))) |
| 1674 | 1657 | ||
| 1675 | (defun gdb-frame-display-buffer () | 1658 | (defun gdb-frame-display-buffer () |
| 1676 | (interactive) | 1659 | (interactive) |
| 1677 | (switch-to-buffer-other-frame | 1660 | (switch-to-buffer-other-frame |
| 1678 | (gdb-get-create-instance-buffer 'gdb-display-buffer))) | 1661 | (gdb-get-create-buffer 'gdb-display-buffer))) |
| 1679 | 1662 | ||
| 1680 | (defun gdb-toggle-disp-this-line () | 1663 | (defun gdb-toggle-disp-this-line () |
| 1681 | "Enable/disable the displayed expression of the current line." | 1664 | "Enable/disable the displayed expression of the current line." |
| 1682 | (interactive) | 1665 | (interactive) |
| 1683 | (save-excursion | 1666 | (save-excursion |
| 1684 | (beginning-of-line 1) | 1667 | (beginning-of-line 1) |
| 1685 | (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | 1668 | (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) |
| 1686 | (error "No expression on this line") | 1669 | (error "No expression on this line") |
| 1687 | (gdb-instance-enqueue-input | 1670 | (gdb-enqueue-input |
| 1688 | (list | 1671 | (list |
| 1689 | (concat | 1672 | (concat |
| 1690 | (if (eq ?y (char-after (match-beginning 2))) | 1673 | (if (eq ?y (char-after (match-beginning 2))) |
| @@ -1695,16 +1678,16 @@ display the source in the source buffer." | |||
| 1695 | 'ignore))))) | 1678 | 'ignore))))) |
| 1696 | 1679 | ||
| 1697 | (defun gdb-delete-disp-this-line () | 1680 | (defun gdb-delete-disp-this-line () |
| 1698 | "Delete the displayed expression of the current line." | 1681 | "Delete the displayed expression of the current line." |
| 1699 | (interactive) | 1682 | (interactive) |
| 1700 | (save-excursion | 1683 | (save-excursion |
| 1701 | (set-buffer | 1684 | (set-buffer |
| 1702 | (gdb-get-instance-buffer 'gdb-display-buffer)) | 1685 | (gdb-get-buffer 'gdb-display-buffer)) |
| 1703 | (beginning-of-line 1) | 1686 | (beginning-of-line 1) |
| 1704 | (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) | 1687 | (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) |
| 1705 | (error "No expression on this line") | 1688 | (error "No expression on this line") |
| 1706 | (let ((number (match-string 1))) | 1689 | (let ((number (match-string 1))) |
| 1707 | (gdb-instance-enqueue-input | 1690 | (gdb-enqueue-input |
| 1708 | (list (concat "server delete display " number "\n") | 1691 | (list (concat "server delete display " number "\n") |
| 1709 | 'ignore)) | 1692 | 'ignore)) |
| 1710 | (if (not (display-graphic-p)) | 1693 | (if (not (display-graphic-p)) |
| @@ -1780,7 +1763,8 @@ display the source in the source buffer." | |||
| 1780 | (progn | 1763 | (progn |
| 1781 | (walk-windows | 1764 | (walk-windows |
| 1782 | '(lambda (win) | 1765 | '(lambda (win) |
| 1783 | (if (gdb-protected-buffer-p (window-buffer win)) | 1766 | (if (or (eq gud-comint-buffer (window-buffer win)) |
| 1767 | (eq gdb-source-window win)) | ||
| 1784 | (set-window-dedicated-p win t)))) | 1768 | (set-window-dedicated-p win t)))) |
| 1785 | (setq answer (get-buffer-window buf)) | 1769 | (setq answer (get-buffer-window buf)) |
| 1786 | (if (not answer) | 1770 | (if (not answer) |
| @@ -1792,7 +1776,8 @@ display the source in the source buffer." | |||
| 1792 | (setq must-split t))))) | 1776 | (setq must-split t))))) |
| 1793 | (walk-windows | 1777 | (walk-windows |
| 1794 | '(lambda (win) | 1778 | '(lambda (win) |
| 1795 | (if (gdb-protected-buffer-p (window-buffer win)) | 1779 | (if (or (eq gud-comint-buffer (window-buffer win)) |
| 1780 | (eq gdb-source-window win)) | ||
| 1796 | (set-window-dedicated-p win nil))))) | 1781 | (set-window-dedicated-p win nil))))) |
| 1797 | (if must-split | 1782 | (if must-split |
| 1798 | (let* ((largest (get-largest-window)) | 1783 | (let* ((largest (get-largest-window)) |
| @@ -1811,7 +1796,7 @@ display the source in the source buffer." | |||
| 1811 | (defun gdb-display-gdb-buffer () | 1796 | (defun gdb-display-gdb-buffer () |
| 1812 | (interactive) | 1797 | (interactive) |
| 1813 | (gdb-display-buffer | 1798 | (gdb-display-buffer |
| 1814 | (gdb-get-create-instance-buffer 'gdba))) | 1799 | (gdb-get-create-buffer 'gdba))) |
| 1815 | 1800 | ||
| 1816 | (let ((menu (make-sparse-keymap "GDB-Windows"))) | 1801 | (let ((menu (make-sparse-keymap "GDB-Windows"))) |
| 1817 | (define-key gud-menu-map [displays] | 1802 | (define-key gud-menu-map [displays] |
| @@ -1827,7 +1812,7 @@ display the source in the source buffer." | |||
| 1827 | (defun gdb-frame-gdb-buffer () | 1812 | (defun gdb-frame-gdb-buffer () |
| 1828 | (interactive) | 1813 | (interactive) |
| 1829 | (switch-to-buffer-other-frame | 1814 | (switch-to-buffer-other-frame |
| 1830 | (gdb-get-create-instance-buffer 'gdba))) | 1815 | (gdb-get-create-buffer 'gdba))) |
| 1831 | 1816 | ||
| 1832 | (let ((menu (make-sparse-keymap "GDB-Frames"))) | 1817 | (let ((menu (make-sparse-keymap "GDB-Frames"))) |
| 1833 | (define-key gud-menu-map [frames] | 1818 | (define-key gud-menu-map [frames] |
| @@ -1916,7 +1901,7 @@ static char *magick[] = { | |||
| 1916 | \"+++ +++\", | 1901 | \"+++ +++\", |
| 1917 | \"+++++ +++++\" | 1902 | \"+++++ +++++\" |
| 1918 | };" | 1903 | };" |
| 1919 | "XPM file used for breakpoint icon.") | 1904 | "XPM file used for breakpoint icon.") |
| 1920 | 1905 | ||
| 1921 | (defvar breakpoint-enabled-icon | 1906 | (defvar breakpoint-enabled-icon |
| 1922 | (find-image `((:type xpm :data ,breakpoint-xpm-data))) | 1907 | (find-image `((:type xpm :data ,breakpoint-xpm-data))) |
| @@ -1927,7 +1912,7 @@ static char *magick[] = { | |||
| 1927 | "Icon for disabled breakpoint in display margin") | 1912 | "Icon for disabled breakpoint in display margin") |
| 1928 | 1913 | ||
| 1929 | (defun gdb-quit () | 1914 | (defun gdb-quit () |
| 1930 | "Kill the GUD and instance buffers and reset variables. | 1915 | "Kill the GUD interaction and gdb buffers and reset variables. |
| 1931 | Use this command to exit a debugging session cleanly and reset | 1916 | Use this command to exit a debugging session cleanly and reset |
| 1932 | things like the toolbar and margin in the source buffers." | 1917 | things like the toolbar and margin in the source buffers." |
| 1933 | (interactive) | 1918 | (interactive) |
| @@ -1973,14 +1958,13 @@ buffers." | |||
| 1973 | (if gdb-many-windows | 1958 | (if gdb-many-windows |
| 1974 | (gdb-setup-windows) | 1959 | (gdb-setup-windows) |
| 1975 | (gdb-display-breakpoints-buffer) | 1960 | (gdb-display-breakpoints-buffer) |
| 1976 | (gdb-display-display-buffer) | ||
| 1977 | (gdb-display-stack-buffer) | 1961 | (gdb-display-stack-buffer) |
| 1978 | (delete-other-windows) | 1962 | (delete-other-windows) |
| 1979 | (split-window) | 1963 | (split-window) |
| 1980 | (other-window 1) | 1964 | (other-window 1) |
| 1981 | (switch-to-buffer (gud-find-file gdb-main-file)) | 1965 | (switch-to-buffer (gud-find-file gdb-main-file)) |
| 1982 | (other-window 1) | 1966 | (setq gdb-source-window (get-buffer-window (current-buffer)))) |
| 1983 | (setq gdb-source-window (get-buffer-window (current-buffer)))))) | 1967 | (other-window 1))) |
| 1984 | 1968 | ||
| 1985 | ;;from put-image | 1969 | ;;from put-image |
| 1986 | (defun put-string (putstring pos &optional string area) | 1970 | (defun put-string (putstring pos &optional string area) |
| @@ -2081,7 +2065,7 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2081 | (defun gdb-delete-display () | 2065 | (defun gdb-delete-display () |
| 2082 | "Delete displayed expression and its frame." | 2066 | "Delete displayed expression and its frame." |
| 2083 | (interactive) | 2067 | (interactive) |
| 2084 | (gdb-instance-enqueue-input | 2068 | (gdb-enqueue-input |
| 2085 | (list (concat "server delete display " gdb-display-number "\n") | 2069 | (list (concat "server delete display " gdb-display-number "\n") |
| 2086 | 'ignore)) | 2070 | 'ignore)) |
| 2087 | (kill-buffer nil) | 2071 | (kill-buffer nil) |
| @@ -2098,7 +2082,7 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2098 | gdb-assembler-custom) | 2082 | gdb-assembler-custom) |
| 2099 | 2083 | ||
| 2100 | (defun gdb-assembler-custom () | 2084 | (defun gdb-assembler-custom () |
| 2101 | (let ((buffer (gdb-get-instance-buffer 'gdb-assembler-buffer)) | 2085 | (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer)) |
| 2102 | (gdb-arrow-position) (address) (flag)) | 2086 | (gdb-arrow-position) (address) (flag)) |
| 2103 | (if gdb-current-address | 2087 | (if gdb-current-address |
| 2104 | (progn | 2088 | (progn |
| @@ -2117,7 +2101,7 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2117 | (remove-images (point-min) (point-max)) | 2101 | (remove-images (point-min) (point-max)) |
| 2118 | (remove-strings (point-min) (point-max)))) | 2102 | (remove-strings (point-min) (point-max)))) |
| 2119 | (save-excursion | 2103 | (save-excursion |
| 2120 | (set-buffer (gdb-get-instance-buffer 'gdb-breakpoints-buffer)) | 2104 | (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)) |
| 2121 | (goto-char (point-min)) | 2105 | (goto-char (point-min)) |
| 2122 | (while (< (point) (- (point-max) 1)) | 2106 | (while (< (point) (- (point-max) 1)) |
| 2123 | (forward-line 1) | 2107 | (forward-line 1) |
| @@ -2152,9 +2136,9 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2152 | (if gdb-current-address | 2136 | (if gdb-current-address |
| 2153 | (set-window-point (get-buffer-window buffer) gdb-arrow-position)))) | 2137 | (set-window-point (get-buffer-window buffer) gdb-arrow-position)))) |
| 2154 | 2138 | ||
| 2155 | (gdb-set-instance-buffer-rules 'gdb-assembler-buffer | 2139 | (gdb-set-buffer-rules 'gdb-assembler-buffer |
| 2156 | 'gdb-assembler-buffer-name | 2140 | 'gdb-assembler-buffer-name |
| 2157 | 'gdb-assembler-mode) | 2141 | 'gdb-assembler-mode) |
| 2158 | 2142 | ||
| 2159 | (defvar gdb-assembler-mode-map | 2143 | (defvar gdb-assembler-mode-map |
| 2160 | (let ((map (make-sparse-keymap))) | 2144 | (let ((map (make-sparse-keymap))) |
| @@ -2175,17 +2159,17 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2175 | 2159 | ||
| 2176 | (defun gdb-assembler-buffer-name () | 2160 | (defun gdb-assembler-buffer-name () |
| 2177 | (with-current-buffer gud-comint-buffer | 2161 | (with-current-buffer gud-comint-buffer |
| 2178 | (concat "*Machine Code " (gdb-instance-target-string) "*"))) | 2162 | (concat "*Machine Code " (gdb-get-target-string) "*"))) |
| 2179 | 2163 | ||
| 2180 | (defun gdb-display-assembler-buffer () | 2164 | (defun gdb-display-assembler-buffer () |
| 2181 | (interactive) | 2165 | (interactive) |
| 2182 | (gdb-display-buffer | 2166 | (gdb-display-buffer |
| 2183 | (gdb-get-create-instance-buffer 'gdb-assembler-buffer))) | 2167 | (gdb-get-create-buffer 'gdb-assembler-buffer))) |
| 2184 | 2168 | ||
| 2185 | (defun gdb-frame-assembler-buffer () | 2169 | (defun gdb-frame-assembler-buffer () |
| 2186 | (interactive) | 2170 | (interactive) |
| 2187 | (switch-to-buffer-other-frame | 2171 | (switch-to-buffer-other-frame |
| 2188 | (gdb-get-create-instance-buffer 'gdb-assembler-buffer))) | 2172 | (gdb-get-create-buffer 'gdb-assembler-buffer))) |
| 2189 | 2173 | ||
| 2190 | (defun gdb-invalidate-frame-and-assembler (&optional ignored) | 2174 | (defun gdb-invalidate-frame-and-assembler (&optional ignored) |
| 2191 | (gdb-invalidate-frames) | 2175 | (gdb-invalidate-frames) |
| @@ -2200,9 +2184,9 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2200 | ;; modified because if gdb-main-or-pc has changed value a new command | 2184 | ;; modified because if gdb-main-or-pc has changed value a new command |
| 2201 | ;; must be enqueued to update the buffer with the new output | 2185 | ;; must be enqueued to update the buffer with the new output |
| 2202 | (defun gdb-invalidate-assembler (&optional ignored) | 2186 | (defun gdb-invalidate-assembler (&optional ignored) |
| 2203 | (if (and (gdb-get-instance-buffer 'gdb-assembler-buffer) | 2187 | (if (and (gdb-get-buffer 'gdb-assembler-buffer) |
| 2204 | (or (not (member 'gdb-invalidate-assembler | 2188 | (or (not (member 'gdb-invalidate-assembler |
| 2205 | (gdb-instance-pending-triggers))) | 2189 | (gdb-get-pending-triggers))) |
| 2206 | (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc)))) | 2190 | (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc)))) |
| 2207 | (progn | 2191 | (progn |
| 2208 | 2192 | ||
| @@ -2216,12 +2200,12 @@ BUFFER nil or omitted means use the current buffer." | |||
| 2216 | (delete item gdb-idle-input-queue)) | 2200 | (delete item gdb-idle-input-queue)) |
| 2217 | (setq queue (cdr queue))))) | 2201 | (setq queue (cdr queue))))) |
| 2218 | 2202 | ||
| 2219 | (gdb-instance-enqueue-idle-input | 2203 | (gdb-enqueue-idle-input |
| 2220 | (list (concat "server disassemble " gdb-main-or-pc "\n") | 2204 | (list (concat "server disassemble " gdb-main-or-pc "\n") |
| 2221 | 'gdb-assembler-handler)) | 2205 | 'gdb-assembler-handler)) |
| 2222 | (set-gdb-instance-pending-triggers | 2206 | (gdb-set-pending-triggers |
| 2223 | (cons 'gdb-invalidate-assembler | 2207 | (cons 'gdb-invalidate-assembler |
| 2224 | (gdb-instance-pending-triggers))) | 2208 | (gdb-get-pending-triggers))) |
| 2225 | (setq gdb-prev-main-or-pc gdb-main-or-pc)))) | 2209 | (setq gdb-prev-main-or-pc gdb-main-or-pc)))) |
| 2226 | 2210 | ||
| 2227 | (provide 'gdb-ui) | 2211 | (provide 'gdb-ui) |