aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1993-12-23 02:56:37 +0000
committerRichard M. Stallman1993-12-23 02:56:37 +0000
commit13eaa0261c2dc97cf242e33a40f7a61acbfd68fc (patch)
treecf63e95b6a0589ac3a9979ee0a5242538b769ead /lisp
parent7d847440c564abb8fa6d3b99508e559be8adeda0 (diff)
downloademacs-13eaa0261c2dc97cf242e33a40f7a61acbfd68fc.tar.gz
emacs-13eaa0261c2dc97cf242e33a40f7a61acbfd68fc.zip
(gud-format-command): Rewrite.
(gud-format-command): Use gud-last-last-frame if gud-last-frame is nil. (gud-mipsdbx-massage-args, gud-mipsdbx-marker-filter): New functions for dbx support on Mips under Ultrix. (gud-dbx-mips-p, gud-mipsdbx-marker-acc): New variables. (dbx) If gud-dbx-mips-p is non-nil, overload above two functions and initialize appropriate command strings for dbx. (gud-common-init): Call substitute-in-file-name. (dbx): Let `comint-prompt-regexp' not match more than one line.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gud.el171
1 files changed, 119 insertions, 52 deletions
diff --git a/lisp/gud.el b/lisp/gud.el
index 33534c293e3..d8544e8d878 100644
--- a/lisp/gud.el
+++ b/lisp/gud.el
@@ -351,6 +351,70 @@ and source-file directory for your debugger."
351 (substring string (match-beginning 1) (match-end 1)))))) 351 (substring string (match-beginning 1) (match-end 1))))))
352 string) 352 string)
353 353
354;; Functions for dbx on Mips/Ultrix.
355;; This is very similar to the code for gdb. The trick is to start dbx
356;; with the (undocumented) option `-emacs'.
357
358;; Are we running on a Mips system under Ultrix?
359(defvar gud-dbx-mips-p (file-exists-p "/usr/include/mips"))
360
361(defun gud-mipsdbx-massage-args (file args)
362 (cons "-emacs" (cons file args)))
363
364;; There's no guarantee that Emacs will hand the filter the entire
365;; marker at once; it could be broken up across several strings. We
366;; might even receive a big chunk with several markers in it. If we
367;; receive a chunk of text which looks like it might contain the
368;; beginning of a marker, we save it here between calls to the
369;; filter.
370(defvar gud-mipsdbx-marker-acc "")
371
372(defun gud-mipsdbx-marker-filter (string)
373 (save-match-data
374 (setq gud-mipsdbx-marker-acc (concat gud-mipsdbx-marker-acc string))
375 (let ((output ""))
376
377 ;; Process all the complete markers in this chunk.
378 (while (string-match
379 "^[] [0-9]*\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
380 gud-mipsdbx-marker-acc)
381 (setq
382
383 ;; Extract the frame position from the marker.
384 gud-last-frame (cons
385 (substring gud-mipsdbx-marker-acc
386 (match-beginning 1) (match-end 1))
387 (string-to-int
388 (substring gud-mipsdbx-marker-acc
389 (match-beginning 2) (match-end 2))))
390
391 ;; Append any text before the marker to the output we're going
392 ;; to return - we don't include the marker in this text.
393 output (concat output (substring gud-mipsdbx-marker-acc
394 0 (match-beginning 0)))
395
396 ;; Set the accumulator to the remaining text.
397 gud-mipsdbx-marker-acc (substring gud-mipsdbx-marker-acc
398 (match-end 0))))
399
400 ;; Does the remaining text look like it might end with the
401 ;; beginning of another marker? If it does, then keep it in
402 ;; gud-mipsdbx-marker-acc until we receive the rest of it.
403 ;; Since we know the full marker regexp above failed, it's pretty
404 ;; simple to test for marker starts.
405 (if (string-match "^[] [0-9]*\032.*\\'" gud-mipsdbx-marker-acc)
406 (setq
407 ;; Everything before the potential marker start can be output.
408 output (concat output (substring gud-mipsdbx-marker-acc
409 0 (match-beginning 0)))
410 ;; Everything after, we save, to combine with later input.
411 gud-mipsdbx-marker-acc (substring gud-mipsdbx-marker-acc
412 (match-beginning 0)))
413 (setq output (concat output gud-mipsdbx-marker-acc)
414 gud-mipsdbx-marker-acc ""))
415
416 output)))
417
354(defun gud-dbx-find-file (f) 418(defun gud-dbx-find-file (f)
355 (find-file-noselect f)) 419 (find-file-noselect f))
356 420
@@ -366,17 +430,29 @@ and source-file directory for your debugger."
366 "dbx ") 430 "dbx ")
367 nil nil 431 nil nil
368 '(gud-dbx-history . 1)))) 432 '(gud-dbx-history . 1))))
369 (gud-overload-functions '((gud-massage-args . gud-dbx-massage-args) 433
370 (gud-marker-filter . gud-dbx-marker-filter) 434 (gud-overload-functions
371 (gud-find-file . gud-dbx-find-file) 435 (cond
372 )) 436 (gud-dbx-mips-p
437 '((gud-massage-args . gud-mipsdbx-massage-args)
438 (gud-marker-filter . gud-mipsdbx-marker-filter)
439 (gud-find-file . gud-dbx-find-file)))
440 (t
441 '((gud-massage-args . gud-dbx-massage-args)
442 (gud-marker-filter . gud-dbx-marker-filter)
443 (gud-find-file . gud-dbx-find-file)))))
373 444
374 (gud-common-init command-line) 445 (gud-common-init command-line)
375 446
376 (gud-def gud-break "file \"%d%f\"\nstop at %l" 447 (cond
377 "\C-b" "Set breakpoint at current line.") 448 (gud-dbx-mips-p
378;; (gud-def gud-break "stop at \"%f\":%l" 449 (gud-def gud-break "stop at \"%f\":%l"
379;; "\C-b" "Set breakpoint at current line.") 450 "\C-b" "Set breakpoint at current line.")
451 (gud-def gud-finish "return" "\C-f" "Finish executing current function."))
452 (t
453 (gud-def gud-break "file \"%d%f\"\nstop at %l"
454 "\C-b" "Set breakpoint at current line.")))
455
380 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") 456 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
381 (gud-def gud-step "step %p" "\C-s" "Step one line with display.") 457 (gud-def gud-step "step %p" "\C-s" "Step one line with display.")
382 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") 458 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
@@ -386,7 +462,7 @@ and source-file directory for your debugger."
386 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.") 462 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.")
387 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") 463 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
388 464
389 (setq comint-prompt-regexp "^[^)]*dbx) *") 465 (setq comint-prompt-regexp "^[^)\n]*dbx) *")
390 (run-hooks 'dbx-mode-hook) 466 (run-hooks 'dbx-mode-hook)
391 ) 467 )
392 468
@@ -733,7 +809,7 @@ comint mode, which see."
733 (setq w (cdr w))) 809 (setq w (cdr w)))
734 (car w))) 810 (car w)))
735 (args (delq file-word (cdr words))) 811 (args (delq file-word (cdr words)))
736 (file (expand-file-name file-word)) 812 (file (expand-file-name (substitute-in-file-name file-word)))
737 (filepart (file-name-nondirectory file))) 813 (filepart (file-name-nondirectory file)))
738 (switch-to-buffer (concat "*gud-" filepart "*")) 814 (switch-to-buffer (concat "*gud-" filepart "*"))
739 (setq default-directory (file-name-directory file)) 815 (setq default-directory (file-name-directory file))
@@ -863,49 +939,40 @@ Obeying it means displaying in another window the specified file and line."
863;;; gud-last-frame. Here's how we do it: 939;;; gud-last-frame. Here's how we do it:
864 940
865(defun gud-format-command (str arg) 941(defun gud-format-command (str arg)
866 (let ((insource (not (eq (current-buffer) gud-comint-buffer)))) 942 (let ((insource (not (eq (current-buffer) gud-comint-buffer)))
867 (if (string-match "\\(.*\\)%f\\(.*\\)" str) 943 (frame (or gud-last-frame gud-last-last-frame))
868 (setq str (concat 944 result)
869 (substring str (match-beginning 1) (match-end 1)) 945 (while (and str (string-match "\\([^%]*\\)%\\([adeflp]\\)" str))
870 (file-name-nondirectory (if insource 946 (let ((key (string-to-char (substring str (match-beginning 2))))
947 subst)
948 (cond
949 ((eq key ?f)
950 (setq subst (file-name-nondirectory (if insource
951 (buffer-file-name)
952 (car frame)))))
953 ((eq key ?d)
954 (setq subst (file-name-directory (if insource
871 (buffer-file-name) 955 (buffer-file-name)
872 (car gud-last-frame))) 956 (car frame)))))
873 (substring str (match-beginning 2) (match-end 2))))) 957 ((eq key ?l)
874 (if (string-match "\\(.*\\)%d\\(.*\\)" str) 958 (setq subst (if insource
875 (setq str (concat 959 (save-excursion
876 (substring str (match-beginning 1) (match-end 1)) 960 (beginning-of-line)
877 (file-name-directory (if insource 961 (save-restriction (widen)
878 (buffer-file-name) 962 (1+ (count-lines 1 (point)))))
879 (car gud-last-frame))) 963 (cdr frame))))
880 (substring str (match-beginning 2) (match-end 2))))) 964 ((eq key ?e)
881 (if (string-match "\\(.*\\)%l\\(.*\\)" str) 965 (setq subst (find-c-expr)))
882 (setq str (concat 966 ((eq key ?a)
883 (substring str (match-beginning 1) (match-end 1)) 967 (setq subst (gud-read-address)))
884 (if insource 968 ((eq key ?p)
885 (save-excursion 969 (setq subst (if arg (int-to-string arg) ""))))
886 (beginning-of-line) 970 (setq result (concat result
887 (save-restriction (widen) 971 (substring str (match-beginning 1) (match-end 1))
888 (1+ (count-lines 1 (point))))) 972 subst)))
889 (cdr gud-last-frame)) 973 (setq str (substring str (match-end 2))))
890 (substring str (match-beginning 2) (match-end 2))))) 974 ;; There might be text left in STR when the loop ends.
891 (if (string-match "\\(.*\\)%e\\(.*\\)" str) 975 (concat result str)))
892 (setq str (concat
893 (substring str (match-beginning 1) (match-end 1))
894 (find-c-expr)
895 (substring str (match-beginning 2) (match-end 2)))))
896 (if (string-match "\\(.*\\)%a\\(.*\\)" str)
897 (setq str (concat
898 (substring str (match-beginning 1) (match-end 1))
899 (gud-read-address)
900 (substring str (match-beginning 2) (match-end 2)))))
901 (if (string-match "\\(.*\\)%p\\(.*\\)" str)
902 (setq str (concat
903 (substring str (match-beginning 1) (match-end 1))
904 (if arg (int-to-string arg) "")
905 (substring str (match-beginning 2) (match-end 2)))))
906 )
907 str
908 )
909 976
910(defun gud-read-address () 977(defun gud-read-address ()
911 "Return a string containing the core-address found in the buffer at point." 978 "Return a string containing the core-address found in the buffer at point."