Mercurial > emacs
comparison lisp/gud.el @ 4729:fdbcbaea7296
(perldb): New function, plus subroutines.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 16 Sep 1993 20:02:25 +0000 |
parents | 820df40f1e8c |
children | 22e673b984fc |
comparison
equal
deleted
inserted
replaced
4728:49643e1db119 | 4729:fdbcbaea7296 |
---|---|
63 (defun gud-marker-filter (str) | 63 (defun gud-marker-filter (str) |
64 (error "GUD not properly entered.")) | 64 (error "GUD not properly entered.")) |
65 | 65 |
66 (defun gud-find-file (f) | 66 (defun gud-find-file (f) |
67 (error "GUD not properly entered.")) | 67 (error "GUD not properly entered.")) |
68 | 68 |
69 ;; ====================================================================== | 69 ;; ====================================================================== |
70 ;; command definition | 70 ;; command definition |
71 | 71 |
72 ;; This macro is used below to define some basic debugger interface commands. | 72 ;; This macro is used below to define some basic debugger interface commands. |
73 ;; Of course you may use `gud-def' with any other debugger command, including | 73 ;; Of course you may use `gud-def' with any other debugger command, including |
144 ;; the rest. | 144 ;; the rest. |
145 ;; | 145 ;; |
146 ;; The job of the find-file method is to visit and return the buffer indicated | 146 ;; The job of the find-file method is to visit and return the buffer indicated |
147 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or | 147 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or |
148 ;; something else. | 148 ;; something else. |
149 | 149 |
150 ;; ====================================================================== | 150 ;; ====================================================================== |
151 ;; gdb functions | 151 ;; gdb functions |
152 | 152 |
153 ;;; History of argument lists passed to gdb. | 153 ;;; History of argument lists passed to gdb. |
154 (defvar gud-gdb-history nil) | 154 (defvar gud-gdb-history nil) |
245 | 245 |
246 (setq comint-prompt-regexp "^(.*gdb[+]?) *") | 246 (setq comint-prompt-regexp "^(.*gdb[+]?) *") |
247 (run-hooks 'gdb-mode-hook) | 247 (run-hooks 'gdb-mode-hook) |
248 ) | 248 ) |
249 | 249 |
250 | 250 |
251 ;; ====================================================================== | 251 ;; ====================================================================== |
252 ;; sdb functions | 252 ;; sdb functions |
253 | 253 |
254 ;;; History of argument lists passed to sdb. | 254 ;;; History of argument lists passed to sdb. |
255 (defvar gud-sdb-history nil) | 255 (defvar gud-sdb-history nil) |
324 (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.") | 324 (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.") |
325 | 325 |
326 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") | 326 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") |
327 (run-hooks 'sdb-mode-hook) | 327 (run-hooks 'sdb-mode-hook) |
328 ) | 328 ) |
329 | 329 |
330 ;; ====================================================================== | 330 ;; ====================================================================== |
331 ;; dbx functions | 331 ;; dbx functions |
332 | 332 |
333 ;;; History of argument lists passed to dbx. | 333 ;;; History of argument lists passed to dbx. |
334 (defvar gud-dbx-history nil) | 334 (defvar gud-dbx-history nil) |
386 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") | 386 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") |
387 | 387 |
388 (setq comint-prompt-regexp "^[^)]*dbx) *") | 388 (setq comint-prompt-regexp "^[^)]*dbx) *") |
389 (run-hooks 'dbx-mode-hook) | 389 (run-hooks 'dbx-mode-hook) |
390 ) | 390 ) |
391 | 391 |
392 ;; ====================================================================== | 392 ;; ====================================================================== |
393 ;; xdb (HP PARISC debugger) functions | 393 ;; xdb (HP PARISC debugger) functions |
394 | 394 |
395 ;;; History of argument lists passed to xdb. | 395 ;;; History of argument lists passed to xdb. |
396 (defvar gud-xdb-history nil) | 396 (defvar gud-xdb-history nil) |
487 | 487 |
488 (setq comint-prompt-regexp "^>") | 488 (setq comint-prompt-regexp "^>") |
489 (make-local-variable 'gud-xdb-accumulation) | 489 (make-local-variable 'gud-xdb-accumulation) |
490 (setq gud-xdb-accumulation "") | 490 (setq gud-xdb-accumulation "") |
491 (run-hooks 'xdb-mode-hook)) | 491 (run-hooks 'xdb-mode-hook)) |
492 | |
493 ;; ====================================================================== | |
494 ;; perldb functions | |
495 | |
496 ;;; History of argument lists passed to perldb. | |
497 (defvar gud-perldb-history nil) | |
498 | |
499 (defun gud-perldb-massage-args (file args) | |
500 (cons "-fullname" (cons file args))) | |
501 | |
502 ;; There's no guarantee that Emacs will hand the filter the entire | |
503 ;; marker at once; it could be broken up across several strings. We | |
504 ;; might even receive a big chunk with several markers in it. If we | |
505 ;; receive a chunk of text which looks like it might contain the | |
506 ;; beginning of a marker, we save it here between calls to the | |
507 ;; filter. | |
508 (defvar gud-perldb-marker-acc "") | |
509 | |
510 (defun gud-perldb-marker-filter (string) | |
511 (save-match-data | |
512 (setq gud-perldb-marker-acc (concat gud-perldb-marker-acc string)) | |
513 (let ((output "")) | |
514 | |
515 ;; Process all the complete markers in this chunk. | |
516 (while (string-match "^\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" | |
517 gud-perldb-marker-acc) | |
518 (setq | |
519 | |
520 ;; Extract the frame position from the marker. | |
521 gud-last-frame | |
522 (cons (substring gud-perldb-marker-acc (match-beginning 1) (match-end 1)) | |
523 (string-to-int (substring gud-perldb-marker-acc | |
524 (match-beginning 2) | |
525 (match-end 2)))) | |
526 | |
527 ;; Append any text before the marker to the output we're going | |
528 ;; to return - we don't include the marker in this text. | |
529 output (concat output | |
530 (substring gud-perldb-marker-acc 0 (match-beginning 0))) | |
531 | |
532 ;; Set the accumulator to the remaining text. | |
533 gud-perldb-marker-acc (substring gud-perldb-marker-acc (match-end 0)))) | |
534 | |
535 ;; Does the remaining text look like it might end with the | |
536 ;; beginning of another marker? If it does, then keep it in | |
537 ;; gud-perldb-marker-acc until we receive the rest of it. Since we | |
538 ;; know the full marker regexp above failed, it's pretty simple to | |
539 ;; test for marker starts. | |
540 (if (string-match "^\032.*\\'" gud-perldb-marker-acc) | |
541 (progn | |
542 ;; Everything before the potential marker start can be output. | |
543 (setq output (concat output (substring gud-perldb-marker-acc | |
544 0 (match-beginning 0)))) | |
545 | |
546 ;; Everything after, we save, to combine with later input. | |
547 (setq gud-perldb-marker-acc | |
548 (substring gud-perldb-marker-acc (match-beginning 0)))) | |
549 | |
550 (setq output (concat output gud-perldb-marker-acc) | |
551 gud-perldb-marker-acc "")) | |
552 | |
553 output))) | |
554 | |
555 (defun gud-perldb-find-file (f) | |
556 (find-file-noselect f)) | |
557 | |
558 ;;;###autoload | |
559 (defun perldb (command-line) | |
560 "Run perldb on program FILE in buffer *gud-FILE*. | |
561 The directory containing FILE becomes the initial working directory | |
562 and source-file directory for your debugger." | |
563 (interactive | |
564 (list (read-from-minibuffer "Run perldb (like this): " | |
565 (if (consp gud-perldb-history) | |
566 (car gud-perldb-history) | |
567 "perldb ") | |
568 nil nil | |
569 '(gud-perldb-history . 1)))) | |
570 (gud-overload-functions '((gud-massage-args . gud-perldb-massage-args) | |
571 (gud-marker-filter . gud-perldb-marker-filter) | |
572 (gud-find-file . gud-perldb-find-file) | |
573 )) | |
574 | |
575 (gud-common-init command-line) | |
576 | |
577 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") | |
578 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.") | |
579 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") | |
580 (gud-def gud-step "step %p" "\C-s" "Step one source line with display.") | |
581 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") | |
582 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).") | |
583 (gud-def gud-cont "cont" "\C-r" "Continue with display.") | |
584 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.") | |
585 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") | |
586 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") | |
587 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") | |
588 | |
589 (setq comint-prompt-regexp "^(.*perldb[+]?) *") | |
590 (run-hooks 'gdb-mode-hook) | |
591 ) | |
492 | 592 |
493 ;; | 593 ;; |
494 ;; End of debugger-specific information | 594 ;; End of debugger-specific information |
495 ;; | 595 ;; |
496 | 596 |
597 | |
497 ;;; When we send a command to the debugger via gud-call, it's annoying | 598 ;;; When we send a command to the debugger via gud-call, it's annoying |
498 ;;; to see the command and the new prompt inserted into the debugger's | 599 ;;; to see the command and the new prompt inserted into the debugger's |
499 ;;; buffer; we have other ways of knowing the command has completed. | 600 ;;; buffer; we have other ways of knowing the command has completed. |
500 ;;; | 601 ;;; |
501 ;;; If the buffer looks like this: | 602 ;;; If the buffer looks like this: |