source: trunk/third/librep/rep-debugger.el @ 17362

Revision 17362, 5.0 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17361, which included commits to RCS files with non-trunk default branches.
Line 
1;;; rep-debugger.el --- Rep hacks for Emacs' gud.el
2
3;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
4;; Author: John Harper <jsh@pixelslut.com>
5;; Keywords: unix, tools, rep
6
7;; Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
8
9;; This file is part of Librep.
10
11;; Librep is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
15
16;; Librep is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with Librep; see the file COPYING.  If not, write to the
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA.
25
26;; This file is the perldb portions of gud.el with trivial substitutions
27;; to make it work with rep..
28
29(require 'gud)
30
31;; ======================================================================
32;; rep functions
33
34;;; History of argument lists passed to rep.
35(defvar gud-rep-history nil)
36
37(defun gud-rep-massage-args (file args)
38  (cons "--debug" (cons (car args) (cons "--emacs-debug" (cdr args)))))
39
40;; There's no guarantee that Emacs will hand the filter the entire
41;; marker at once; it could be broken up across several strings.  We
42;; might even receive a big chunk with several markers in it.  If we
43;; receive a chunk of text which looks like it might contain the
44;; beginning of a marker, we save it here between calls to the
45;; filter.
46(defun gud-rep-marker-filter (string)
47  (setq gud-marker-acc (concat gud-marker-acc string))
48  (let ((output ""))
49
50    ;; Process all the complete markers in this chunk.
51    (while (string-match "\032\032\\(\\([a-zA-Z]:\\)?[^:\n]*\\):\\([0-9]*\\):.*\n"
52                         gud-marker-acc)
53      (setq
54
55       ;; Extract the frame position from the marker.
56       gud-last-frame
57       (cons (substring gud-marker-acc (match-beginning 1) (match-end 1))
58             (string-to-int (substring gud-marker-acc
59                                       (match-beginning 3)
60                                       (match-end 3))))
61
62       ;; Append any text before the marker to the output we're going
63       ;; to return - we don't include the marker in this text.
64       output (concat output
65                      (substring gud-marker-acc 0 (match-beginning 0)))
66
67       ;; Set the accumulator to the remaining text.
68       gud-marker-acc (substring gud-marker-acc (match-end 0))))
69
70    ;; Does the remaining text look like it might end with the
71    ;; beginning of another marker?  If it does, then keep it in
72    ;; gud-marker-acc until we receive the rest of it.  Since we
73    ;; know the full marker regexp above failed, it's pretty simple to
74    ;; test for marker starts.
75    (if (string-match "\032.*\\'" gud-marker-acc)
76        (progn
77          ;; Everything before the potential marker start can be output.
78          (setq output (concat output (substring gud-marker-acc
79                                                 0 (match-beginning 0))))
80
81          ;; Everything after, we save, to combine with later input.
82          (setq gud-marker-acc
83                (substring gud-marker-acc (match-beginning 0))))
84
85      (setq output (concat output gud-marker-acc)
86            gud-marker-acc ""))
87
88    output))
89
90(defun gud-rep-find-file (f)
91  (save-excursion
92    (let ((buf (find-file-noselect f)))
93      (set-buffer buf)
94      (gud-make-debug-menu)
95      buf)))
96
97(defcustom gud-rep-command-name "rep"
98  "File name for executing rep."
99  :type 'string
100  :group 'gud)
101
102;;;###autoload
103(defun rep-debugger (command-line)
104  "Run the rep debugger on program FILE in buffer *gud-FILE*.
105The directory containing FILE becomes the initial working directory
106and source-file directory for your debugger."
107  (interactive
108   (list (read-from-minibuffer "Run rep debugger (like this): "
109                               (if (consp gud-rep-history)
110                                   (car gud-rep-history)
111                                 (concat gud-rep-command-name
112                                         " "
113                                         (buffer-file-name)
114                                         " "))
115                               nil nil
116                               '(gud-rep-history . 1))))
117
118  (gud-common-init command-line 'gud-rep-massage-args
119                   'gud-rep-marker-filter 'gud-rep-find-file)
120
121;  (gud-def gud-break  "b %l"         "\C-b" "Set breakpoint at current line.")
122;  (gud-def gud-remove "d %l"         "\C-d" "Remove breakpoint at current line")
123  (gud-def gud-step   "s"            "\C-s" "Step one source line with display.")
124  (gud-def gud-next   "n"            "\C-n" "Step one line (skip functions).")
125  (gud-def gud-cont   "c"            "\C-r" "Continue with display.")
126;  (gud-def gud-finish "finish"       "\C-f" "Finish executing current function.")
127  (gud-def gud-up     "u %p"        "<" "Up N stack frames (numeric arg).")
128  (gud-def gud-down   "down %p"      ">" "Down N stack frames (numeric arg).")
129  (gud-def gud-print  "p %e"           "\C-p" "Evaluate perl expression at point.")
130
131  (setq comint-prompt-regexp "^rep-db> ")
132  (setq paragraph-start comint-prompt-regexp)
133  (run-hooks 'rep-debugger-mode-hook))
134
135(provide 'rep-debugger)
136
137;; rep-debugger.el ends here
Note: See TracBrowser for help on using the repository browser.