diff options
| author | Richard M. Stallman | 1993-06-15 16:31:24 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-15 16:31:24 +0000 |
| commit | 6496f3d2b05e27da80f63cc5f7d73738e6399901 (patch) | |
| tree | 4c26cb1e8f4da56180162373288236115be879ec | |
| parent | cfe89c4fa50b7f7e72c0e9d3c699f00ed17025db (diff) | |
| download | emacs-6496f3d2b05e27da80f63cc5f7d73738e6399901.tar.gz emacs-6496f3d2b05e27da80f63cc5f7d73738e6399901.zip | |
(xdb): New debugger supported (xdb under HPUX-PARISC).
(gud-xdb-debugger-startup): New function.
(gud-xdb-file-name, gud-xdb-accumulation): New functions.
(gud-xdb-marker-filter, gud-xdb-paths, gud-xdb-find-file): New.
| -rw-r--r-- | lisp/gud.el | 115 |
1 files changed, 106 insertions, 9 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 98b12af6b72..9bc4f6d00b5 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | ;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, or dbx under Emacs | 1 | ;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, dbx, or xdb |
| 2 | ;;; under Emacs | ||
| 2 | 3 | ||
| 3 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | 4 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
| 4 | ;; Version: 1.3 | 5 | ;; Version: 1.3 |
| @@ -28,7 +29,8 @@ | |||
| 28 | ;; It was later rewritten by rms. Some ideas were due to Masanobu. | 29 | ;; It was later rewritten by rms. Some ideas were due to Masanobu. |
| 29 | ;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com> | 30 | ;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com> |
| 30 | ;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>, | 31 | ;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>, |
| 31 | ;; who also hacked the mode to use comint.el. | 32 | ;; who also hacked the mode to use comint.el. Shane Hartman <shane@spr.com> |
| 33 | ;; added support for xdb (HPUX debugger). | ||
| 32 | 34 | ||
| 33 | ;;; Code: | 35 | ;;; Code: |
| 34 | 36 | ||
| @@ -316,6 +318,100 @@ and source-file directory for your debugger." | |||
| 316 | (run-hooks 'dbx-mode-hook) | 318 | (run-hooks 'dbx-mode-hook) |
| 317 | ) | 319 | ) |
| 318 | 320 | ||
| 321 | ;; ====================================================================== | ||
| 322 | ;; xdb (HP PARISC debugger) functions | ||
| 323 | |||
| 324 | (defun gud-xdb-debugger-startup (file args) | ||
| 325 | (apply 'make-comint (concat "gud-" file) "xdb" nil | ||
| 326 | (append (let ((paths gud-xdb-paths) | ||
| 327 | (result nil)) | ||
| 328 | (while paths | ||
| 329 | (setq result (cons (car paths) (cons "-d" result))) | ||
| 330 | (setq paths (cdr paths))) | ||
| 331 | (nreverse result)) | ||
| 332 | args))) | ||
| 333 | |||
| 334 | (defun gud-xdb-file-name (f) | ||
| 335 | "Transform a relative pathname to a full pathname in xdb mode" | ||
| 336 | (let ((result nil)) | ||
| 337 | (if (file-exists-p f) | ||
| 338 | (setq result (expand-file-name f)) | ||
| 339 | (let ((paths gud-xdb-paths)) | ||
| 340 | (while paths | ||
| 341 | (let ((path (concat (car paths) "/" f))) | ||
| 342 | (if (file-exists-p path) | ||
| 343 | (setq result (expand-file-name path) | ||
| 344 | paths nil))) | ||
| 345 | (setq paths (cdr paths))))) | ||
| 346 | result)) | ||
| 347 | |||
| 348 | ;; xdb does not print the lines all at once, so we have to accumulate them | ||
| 349 | (defvar gud-xdb-accumulation "") | ||
| 350 | |||
| 351 | (defun gud-xdb-marker-filter (string) | ||
| 352 | (let (result) | ||
| 353 | (if (or (string-match comint-prompt-regexp string) | ||
| 354 | (string-match ".*\012" string)) | ||
| 355 | (setq result (concat gud-xdb-accumulation string) | ||
| 356 | gud-xdb-accumulation "") | ||
| 357 | (setq gud-xdb-accumulation (concat gud-xdb-accumulation string))) | ||
| 358 | (if result | ||
| 359 | (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\):" result) | ||
| 360 | (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" | ||
| 361 | result)) | ||
| 362 | (let ((line (string-to-int | ||
| 363 | (substring result (match-beginning 2) (match-end 2)))) | ||
| 364 | (file (gud-xdb-file-name | ||
| 365 | (substring result (match-beginning 1) (match-end 1))))) | ||
| 366 | (if file | ||
| 367 | (setq gud-last-frame (cons file line)))))) | ||
| 368 | (or result ""))) | ||
| 369 | |||
| 370 | (defvar gud-xdb-paths nil | ||
| 371 | "*A list of directories containing source code that should be made known | ||
| 372 | to xdb on startup. If nil, only source files in the program directory | ||
| 373 | will be known to xdb. | ||
| 374 | |||
| 375 | The pathnames should be full, or relative to the program directory. | ||
| 376 | Program directory refers to the directory of the program that is being | ||
| 377 | debugged.") | ||
| 378 | |||
| 379 | (defun gud-xdb-find-file (f) | ||
| 380 | (let ((realf (gud-xdb-file-name f))) | ||
| 381 | (if realf (find-file-noselect realf)))) | ||
| 382 | |||
| 383 | ;;;###autoload | ||
| 384 | (defun xdb (args) | ||
| 385 | "Run xdb on program FILE in buffer *gud-FILE*. | ||
| 386 | The directory containing FILE becomes the initial working directory | ||
| 387 | and source-file directory for your debugger. | ||
| 388 | |||
| 389 | The variable 'gud-xdb-paths' can be set to a list of program source | ||
| 390 | directories if your program contains sources from more than one directory." | ||
| 391 | (interactive "sRun xdb (like this): xdb") | ||
| 392 | (gud-overload-functions '((gud-debugger-startup . gud-xdb-debugger-startup) | ||
| 393 | (gud-marker-filter . gud-xdb-marker-filter) | ||
| 394 | (gud-find-file . gud-xdb-find-file))) | ||
| 395 | |||
| 396 | (gud-common-init args) | ||
| 397 | |||
| 398 | (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.") | ||
| 399 | (gud-def gud-tbreak "b %f:%l\\t" "\C-t" | ||
| 400 | "Set temporary breakpoint at current line.") | ||
| 401 | (gud-def gud-remove "db" "\C-d" "Remove breakpoint at current line") | ||
| 402 | (gud-def gud-step "s %p" "\C-s" "Step one line with display.") | ||
| 403 | (gud-def gud-next "S %p" "\C-n" "Step one line (skip functions).") | ||
| 404 | (gud-def gud-cont "c" "\C-r" "Continue with display.") | ||
| 405 | (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.") | ||
| 406 | (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.") | ||
| 407 | (gud-def gud-finish "bu\\t" "\C-f" "Finish executing current function.") | ||
| 408 | (gud-def gud-print "p %e" "\C-p" "Evaluate C expression at point.") | ||
| 409 | |||
| 410 | (setq comint-prompt-regexp "^>") | ||
| 411 | (make-local-variable 'gud-xdb-accumulation) | ||
| 412 | (setq gud-xdb-accumulation "") | ||
| 413 | (run-hooks 'xdb-mode-hook)) | ||
| 414 | |||
| 319 | ;; | 415 | ;; |
| 320 | ;; End of debugger-specific information | 416 | ;; End of debugger-specific information |
| 321 | ;; | 417 | ;; |
| @@ -366,9 +462,9 @@ and source-file directory for your debugger." | |||
| 366 | (defun gud-mode () | 462 | (defun gud-mode () |
| 367 | "Major mode for interacting with an inferior debugger process. | 463 | "Major mode for interacting with an inferior debugger process. |
| 368 | 464 | ||
| 369 | You start it up with one of the commands M-x gdb, M-x sdb, or | 465 | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, |
| 370 | M-x dbx. Each entry point finishes by executing a hook; `gdb-mode-hook', | 466 | or M-x xdb. Each entry point finishes by executing a hook; `gdb-mode-hook', |
| 371 | `sdb-mode-hook' or `dbx-mode-hook' respectively. | 467 | `sdb-mode-hook', `dbx-mode-hook' or `xdb-mode-hook' respectively. |
| 372 | 468 | ||
| 373 | After startup, the following commands are available in both the GUD | 469 | After startup, the following commands are available in both the GUD |
| 374 | interaction buffer and any source buffer GUD visits due to a breakpoint stop | 470 | interaction buffer and any source buffer GUD visits due to a breakpoint stop |
| @@ -391,16 +487,17 @@ and then update the source window with the current file and position. | |||
| 391 | \\[gud-print] tries to find the largest C lvalue or function-call expression | 487 | \\[gud-print] tries to find the largest C lvalue or function-call expression |
| 392 | around point, and sends it to the debugger for value display. | 488 | around point, and sends it to the debugger for value display. |
| 393 | 489 | ||
| 394 | The above commands are common to all supported debuggers. | 490 | The above commands are common to all supported debuggers except xdb which |
| 491 | does not support stepping instructions. | ||
| 395 | 492 | ||
| 396 | Under gdb and sdb, \\[gud-tbreak] behaves exactly like \\[gud-break], | 493 | Under gdb, sdb and xdb, \\[gud-tbreak] behaves exactly like \\[gud-break], |
| 397 | except that the breakpoint is temporary; that is, it is removed when | 494 | except that the breakpoint is temporary; that is, it is removed when |
| 398 | execution stops on it. | 495 | execution stops on it. |
| 399 | 496 | ||
| 400 | Under gdb and dbx, \\[gud-up] pops up through an enclosing stack | 497 | Under gdb, dbx, and xdb, \\[gud-up] pops up through an enclosing stack |
| 401 | frame. \\[gud-down] drops back down through one. | 498 | frame. \\[gud-down] drops back down through one. |
| 402 | 499 | ||
| 403 | If you are using gdb, \\[gdb-finish] runs execution to the return from | 500 | If you are using gdb or xdb, \\[gud-finish] runs execution to the return from |
| 404 | the current function and stops. | 501 | the current function and stops. |
| 405 | 502 | ||
| 406 | All the keystrokes above are accessible in the GUD buffer | 503 | All the keystrokes above are accessible in the GUD buffer |