needy_debugger 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +14 -0
- data/.travis.yml +8 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +68 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/OLDER_CHANGELOG +334 -0
- data/OLD_CHANGELOG +5655 -0
- data/OLD_README +122 -0
- data/README.md +141 -0
- data/Rakefile +78 -0
- data/bin/rdebug +397 -0
- data/doc/.cvsignore +42 -0
- data/doc/Makefile.am +63 -0
- data/doc/emacs-notes.txt +38 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/ruby-debug.texi +3791 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/emacs/Makefile.am +130 -0
- data/emacs/rdebug-annotate.el +385 -0
- data/emacs/rdebug-breaks.el +407 -0
- data/emacs/rdebug-cmd.el +92 -0
- data/emacs/rdebug-core.el +502 -0
- data/emacs/rdebug-dbg.el +62 -0
- data/emacs/rdebug-error.el +79 -0
- data/emacs/rdebug-fns.el +111 -0
- data/emacs/rdebug-frames.el +230 -0
- data/emacs/rdebug-gud.el +242 -0
- data/emacs/rdebug-help.el +104 -0
- data/emacs/rdebug-info.el +83 -0
- data/emacs/rdebug-layouts.el +180 -0
- data/emacs/rdebug-locring.el +118 -0
- data/emacs/rdebug-output.el +106 -0
- data/emacs/rdebug-regexp.el +118 -0
- data/emacs/rdebug-secondary.el +260 -0
- data/emacs/rdebug-shortkey.el +175 -0
- data/emacs/rdebug-source.el +568 -0
- data/emacs/rdebug-track.el +392 -0
- data/emacs/rdebug-varbuf.el +150 -0
- data/emacs/rdebug-vars.el +125 -0
- data/emacs/rdebug-watch.el +132 -0
- data/emacs/rdebug.el +326 -0
- data/emacs/test/elk-test.el +242 -0
- data/emacs/test/test-annotate.el +103 -0
- data/emacs/test/test-cmd.el +116 -0
- data/emacs/test/test-core.el +104 -0
- data/emacs/test/test-fns.el +65 -0
- data/emacs/test/test-frames.el +62 -0
- data/emacs/test/test-gud.el +35 -0
- data/emacs/test/test-indent.el +58 -0
- data/emacs/test/test-regexp.el +144 -0
- data/emacs/test/test-shortkey.el +61 -0
- data/ext/ruby_debug/192/breakpoint.c +586 -0
- data/ext/ruby_debug/192/ruby_debug.c +2645 -0
- data/ext/ruby_debug/192/ruby_debug.h +148 -0
- data/ext/ruby_debug/193/breakpoint.c +586 -0
- data/ext/ruby_debug/193/ruby_debug.c +2626 -0
- data/ext/ruby_debug/193/ruby_debug.h +148 -0
- data/ext/ruby_debug/200/breakpoint.c +586 -0
- data/ext/ruby_debug/200/ruby_debug.c +2692 -0
- data/ext/ruby_debug/200/ruby_debug.h +148 -0
- data/ext/ruby_debug/extconf.rb +94 -0
- data/lib/debugger.rb +5 -0
- data/lib/debugger/version.rb +5 -0
- data/lib/ruby-debug-base.rb +305 -0
- data/lib/ruby-debug.rb +177 -0
- data/lib/ruby-debug/command.rb +227 -0
- data/lib/ruby-debug/commands/breakpoints.rb +153 -0
- data/lib/ruby-debug/commands/catchpoint.rb +55 -0
- data/lib/ruby-debug/commands/condition.rb +49 -0
- data/lib/ruby-debug/commands/continue.rb +38 -0
- data/lib/ruby-debug/commands/control.rb +107 -0
- data/lib/ruby-debug/commands/display.rb +120 -0
- data/lib/ruby-debug/commands/edit.rb +48 -0
- data/lib/ruby-debug/commands/enable.rb +202 -0
- data/lib/ruby-debug/commands/eval.rb +176 -0
- data/lib/ruby-debug/commands/finish.rb +42 -0
- data/lib/ruby-debug/commands/frame.rb +301 -0
- data/lib/ruby-debug/commands/help.rb +56 -0
- data/lib/ruby-debug/commands/info.rb +467 -0
- data/lib/ruby-debug/commands/irb.rb +123 -0
- data/lib/ruby-debug/commands/jump.rb +66 -0
- data/lib/ruby-debug/commands/kill.rb +51 -0
- data/lib/ruby-debug/commands/list.rb +94 -0
- data/lib/ruby-debug/commands/method.rb +84 -0
- data/lib/ruby-debug/commands/quit.rb +50 -0
- data/lib/ruby-debug/commands/reload.rb +40 -0
- data/lib/ruby-debug/commands/save.rb +90 -0
- data/lib/ruby-debug/commands/set.rb +223 -0
- data/lib/ruby-debug/commands/show.rb +247 -0
- data/lib/ruby-debug/commands/skip.rb +35 -0
- data/lib/ruby-debug/commands/source.rb +36 -0
- data/lib/ruby-debug/commands/stepping.rb +81 -0
- data/lib/ruby-debug/commands/threads.rb +189 -0
- data/lib/ruby-debug/commands/tmate.rb +36 -0
- data/lib/ruby-debug/commands/trace.rb +57 -0
- data/lib/ruby-debug/commands/variables.rb +199 -0
- data/lib/ruby-debug/debugger.rb +5 -0
- data/lib/ruby-debug/helper.rb +69 -0
- data/lib/ruby-debug/interface.rb +232 -0
- data/lib/ruby-debug/processor.rb +474 -0
- data/man/rdebug.1 +241 -0
- data/needy_debugger.gemspec +31 -0
- data/old_scripts/Makefile.am +14 -0
- data/old_scripts/README.md +2 -0
- data/old_scripts/autogen.sh +4 -0
- data/old_scripts/configure.ac +12 -0
- data/old_scripts/rdbg.rb +33 -0
- data/old_scripts/runner.sh +7 -0
- data/old_scripts/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/breakpoints_test.rb +365 -0
- data/test/conditions_test.rb +76 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +141 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +92 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +48 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +50 -0
- data/test/info_test.rb +325 -0
- data/test/irb_test.rb +81 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +47 -0
- data/test/list_test.rb +145 -0
- data/test/method_test.rb +70 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +55 -0
- data/test/reload_test.rb +43 -0
- data/test/restart_test.rb +143 -0
- data/test/save_test.rb +92 -0
- data/test/set_test.rb +177 -0
- data/test/show_test.rb +292 -0
- data/test/source_test.rb +44 -0
- data/test/stepping_test.rb +118 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +205 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +8 -0
- data/test/thread_test.rb +122 -0
- data/test/tmate_test.rb +43 -0
- data/test/trace_test.rb +154 -0
- data/test/variables_test.rb +114 -0
- metadata +352 -0
data/doc/test-tri2.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "test/unit"
|
3
|
+
require "tri2.rb"
|
4
|
+
require "rubygems"
|
5
|
+
require "ruby-debug"
|
6
|
+
Debugger.start
|
7
|
+
|
8
|
+
class TestTri < Test::Unit::TestCase
|
9
|
+
def test_basic
|
10
|
+
debugger
|
11
|
+
solutions = []
|
12
|
+
0.upto(5) do |i|
|
13
|
+
solutions << triangle(i)
|
14
|
+
end
|
15
|
+
assert_equal([0, 1, 3, 6, 10, 15], solutions,
|
16
|
+
"Testing the first 5 triangle numbers")
|
17
|
+
end
|
18
|
+
end
|
data/doc/tri3.rb
ADDED
data/doc/triangle.rb
ADDED
data/emacs/Makefile.am
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Copyright (C) 2007, 2008 Rocky Bernstein rocky@gnu.org
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify it under
|
4
|
+
# the terms of the GNU General Public License as published by the Free
|
5
|
+
# Software Foundation; either version 2, or (at your option) any later
|
6
|
+
# version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
9
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
11
|
+
# for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with Bash; see the file COPYING. If not, write to the Free Software
|
15
|
+
# Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
16
|
+
#$Id: Makefile.am,v 1.10 2007/04/13 00:59:33 rockyb Exp $
|
17
|
+
|
18
|
+
lisp_files = rdebug.el \
|
19
|
+
rdebug-annotate.el \
|
20
|
+
rdebug-breaks.el \
|
21
|
+
rdebug-cmd.el \
|
22
|
+
rdebug-core.el \
|
23
|
+
rdebug-dbg.el \
|
24
|
+
rdebug-error.el \
|
25
|
+
rdebug-fns.el \
|
26
|
+
rdebug-frames.el \
|
27
|
+
rdebug-gud.el \
|
28
|
+
rdebug-help.el \
|
29
|
+
rdebug-info.el \
|
30
|
+
rdebug-layouts.el \
|
31
|
+
rdebug-locring.el \
|
32
|
+
rdebug-output.el \
|
33
|
+
rdebug-regexp.el \
|
34
|
+
rdebug-secondary.el\
|
35
|
+
rdebug-shortkey.el \
|
36
|
+
rdebug-source.el \
|
37
|
+
rdebug-track.el \
|
38
|
+
rdebug-varbuf.el \
|
39
|
+
rdebug-vars.el \
|
40
|
+
rdebug-watch.el
|
41
|
+
check_DATA = test/elk-test.el \
|
42
|
+
test/test-annotate.el \
|
43
|
+
test/test-cmd.el \
|
44
|
+
test/test-core.el \
|
45
|
+
test/test-fns.el \
|
46
|
+
test/test-gud.el \
|
47
|
+
test/test-indent.el \
|
48
|
+
test/test-regexp.el \
|
49
|
+
test/test-shortkey.el
|
50
|
+
|
51
|
+
EXTRA_DIST = $(lisp_files) $(check_DATA)
|
52
|
+
ELCFILES = rdebug.elc \
|
53
|
+
rdebug-annotate.elc \
|
54
|
+
rdebug-breaks.elc \
|
55
|
+
rdebug-cmd.elc \
|
56
|
+
rdebug-core.elc \
|
57
|
+
rdebug-dbg.elc \
|
58
|
+
rdebug-error.elc \
|
59
|
+
rdebug-fns.elc \
|
60
|
+
rdebug-gud.elc \
|
61
|
+
rdebug-frames.elc \
|
62
|
+
rdebug-help.elc \
|
63
|
+
rdebug-info.elc \
|
64
|
+
rdebug-layouts.elc \
|
65
|
+
rdebug-locring.elc \
|
66
|
+
rdebug-output.elc \
|
67
|
+
rdebug-regexp.elc \
|
68
|
+
rdebug-secondary.elc \
|
69
|
+
rdebug-shortkey.elc \
|
70
|
+
rdebug-source.elc \
|
71
|
+
rdebug-track.elc \
|
72
|
+
rdebug-varbuf.elc \
|
73
|
+
rdebug-vars.elc \
|
74
|
+
rdebug-watch.elc
|
75
|
+
if INSTALL_EMACS_LISP
|
76
|
+
lisp_LISP = $(lisp_files)
|
77
|
+
CHECK_FILES = \
|
78
|
+
check-annotate \
|
79
|
+
check-cmd \
|
80
|
+
check-core \
|
81
|
+
check-fns \
|
82
|
+
check-frames \
|
83
|
+
check-gud \
|
84
|
+
check-indent \
|
85
|
+
check-regexp \
|
86
|
+
check-shortkey
|
87
|
+
|
88
|
+
check: $(CHECK_FILES)
|
89
|
+
|
90
|
+
check-annotate: rdebug-annotate.el
|
91
|
+
(cd $(srcdir)/test && \
|
92
|
+
$(EMACS) -batch -q -l test-annotate.el )
|
93
|
+
|
94
|
+
check-cmd: rdebug-gud.el
|
95
|
+
(cd $(srcdir)/test && \
|
96
|
+
$(EMACS) -batch -q -l test-cmd.el )
|
97
|
+
|
98
|
+
check-core: rdebug-core.el
|
99
|
+
(cd $(srcdir)/test && \
|
100
|
+
$(EMACS) -batch -q -l test-core.el )
|
101
|
+
|
102
|
+
check-fns: rdebug-fns.el
|
103
|
+
(cd $(srcdir)/test && \
|
104
|
+
$(EMACS) -batch -q -l test-fns.el )
|
105
|
+
|
106
|
+
check-frames: rdebug-frames.el
|
107
|
+
(cd $(srcdir)/test && \
|
108
|
+
$(EMACS) -batch -q -l test-frames.el )
|
109
|
+
|
110
|
+
check-gud: rdebug-gud.el
|
111
|
+
(cd $(srcdir)/test && \
|
112
|
+
$(EMACS) -batch -q -l test-gud.el )
|
113
|
+
|
114
|
+
check-indent: $(lisp_files)
|
115
|
+
(cd $(srcdir)/test && \
|
116
|
+
$(EMACS) -batch -q -l test-indent.el )
|
117
|
+
|
118
|
+
check-regexp: rdebug-regexp.el
|
119
|
+
(cd $(srcdir)/test && \
|
120
|
+
$(EMACS) -batch -q -l test-regexp.el )
|
121
|
+
|
122
|
+
check-shortkey: rdebug-shortkey.el
|
123
|
+
(cd $(srcdir)/test && \
|
124
|
+
$(EMACS) -batch -q -l test-shortkey.el )
|
125
|
+
endif
|
126
|
+
|
127
|
+
PHONY = $(CHECK_FILES)
|
128
|
+
|
129
|
+
test: check
|
130
|
+
|
@@ -0,0 +1,385 @@
|
|
1
|
+
;;; rdebug-annotate.el --- Ruby debugger output filtering - which
|
2
|
+
;;; includes annotation handling.
|
3
|
+
|
4
|
+
;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
|
5
|
+
;; Copyright (C) 2008 Anders Lindgren
|
6
|
+
|
7
|
+
;; $Id: rdebug-annotate.el 786 2008-04-02 00:50:27Z rockyb $
|
8
|
+
|
9
|
+
;; This program is free software; you can redistribute it and/or modify
|
10
|
+
;; it under the terms of the GNU General Public License as published by
|
11
|
+
;; the Free Software Foundation; either version 2, or (at your option)
|
12
|
+
;; any later version.
|
13
|
+
|
14
|
+
;; This program is distributed in the hope that it will be useful,
|
15
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
;; GNU General Public License for more details.
|
18
|
+
|
19
|
+
;; You should have received a copy of the GNU General Public License
|
20
|
+
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
21
|
+
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
22
|
+
;; Boston, MA 02111-1307, USA.
|
23
|
+
|
24
|
+
;;; Commentary:
|
25
|
+
|
26
|
+
;; This file contains code dealing with filter of debugger output a large
|
27
|
+
;; part of which may contain annotations.
|
28
|
+
|
29
|
+
;;; Code:
|
30
|
+
|
31
|
+
(require 'gud)
|
32
|
+
(require 'gdb-ui)
|
33
|
+
(require 'rdebug-dbg)
|
34
|
+
(require 'rdebug-error)
|
35
|
+
(require 'rdebug-fns)
|
36
|
+
(require 'rdebug-info)
|
37
|
+
(require 'rdebug-layouts)
|
38
|
+
(require 'rdebug-locring)
|
39
|
+
(require 'rdebug-regexp)
|
40
|
+
(require 'rdebug-shortkey)
|
41
|
+
(require 'rdebug-source)
|
42
|
+
(require 'rdebug-vars)
|
43
|
+
|
44
|
+
(defvar rdebug-non-annotated-text-kind nil
|
45
|
+
"Represent what non-annotated text is.
|
46
|
+
|
47
|
+
This can be:
|
48
|
+
* nil -- plain shell output
|
49
|
+
* :output -- output from the command being debugged
|
50
|
+
* :info -- text for the \"info\" secondary window.
|
51
|
+
* :message -- message the text to the echo area.
|
52
|
+
* :cmd -- a command + result, which might go into the \"info\" window.
|
53
|
+
|
54
|
+
See the function `rdebug-cmd-process' for details on :cmd.")
|
55
|
+
|
56
|
+
(defvar rdebug-annotation-setup-map
|
57
|
+
(progn
|
58
|
+
(define-hash-table-test 'str-hash 'string= 'sxhash)
|
59
|
+
(let ((map (make-hash-table :test 'str-hash)))
|
60
|
+
(puthash "breakpoints" 'rdebug-setup-breakpoints-buffer map)
|
61
|
+
;;(puthash "error" 'rdebug-setup-error-buffer map)
|
62
|
+
(puthash "frame" 'rdebug-setup-frame-buffer map)
|
63
|
+
(puthash "variables" 'rdebug-setup-variables-buffer map)
|
64
|
+
(puthash "watch" 'rdebug-setup-watch-buffer map)
|
65
|
+
(puthash "output" 'rdebug-setup-output-buffer map)
|
66
|
+
(puthash "info" 'rdebug-setup-info-buffer map)
|
67
|
+
(puthash "help" 'rdebug-setup-secondary-window-help-buffer map)
|
68
|
+
map)))
|
69
|
+
|
70
|
+
(defun rdebug-temp-show (text)
|
71
|
+
"Arrange to show string as in sort of temporary way. Perhaps like a tooltip"
|
72
|
+
(tooltip-show text))
|
73
|
+
|
74
|
+
(defun rdebug-marker-filter-next-item (string)
|
75
|
+
"The next item for the rdebug marker filter to process.
|
76
|
+
|
77
|
+
Return (item . rest) or nil."
|
78
|
+
(rdebug-debug-message "ACC: %S" string)
|
79
|
+
(cond
|
80
|
+
;; Empty line, we're done.
|
81
|
+
((equal (length string) 0)
|
82
|
+
nil)
|
83
|
+
;; A single ^Z, this could become a new annotation, so lets stop here.
|
84
|
+
((string= string "\032")
|
85
|
+
nil)
|
86
|
+
;; A half-baked annotation, lets stop here.
|
87
|
+
((and (string-match "^\032\032" string)
|
88
|
+
(not (string-match "\n" string)))
|
89
|
+
nil)
|
90
|
+
(t
|
91
|
+
(let ((split-point
|
92
|
+
(cond ((string-match "\032\032" string)
|
93
|
+
(let ((beg (match-beginning 0)))
|
94
|
+
(if (equal beg 0)
|
95
|
+
(if (string-match "^\032\032" string 2)
|
96
|
+
(match-beginning 0)
|
97
|
+
(length string))
|
98
|
+
beg)))
|
99
|
+
((eq (elt string (- (length string) 1)) ?\32)
|
100
|
+
-1)
|
101
|
+
(t
|
102
|
+
(length string)))))
|
103
|
+
(cons (substring string 0 split-point) (substring string split-point))))))
|
104
|
+
|
105
|
+
;; There's no guarantee that Emacs will hand the filter the entire
|
106
|
+
;; marker at once; it could be broken up across several strings. We
|
107
|
+
;; might even receive a big chunk with several markers in it. If we
|
108
|
+
;; receive a chunk of text which looks like it might contain the
|
109
|
+
;; beginning of a marker, we save it here between calls to the
|
110
|
+
;; filter.
|
111
|
+
(defun gud-rdebug-marker-filter (string)
|
112
|
+
"Filter function for process output of the rdebug Ruby debugger."
|
113
|
+
(rdebug-debug-enter "gud-rdebug-marker-filter:"
|
114
|
+
(rdebug-debug-message "GOT: %S" string)
|
115
|
+
(if rdebug-non-annotated-text-kind
|
116
|
+
(rdebug-debug-message " Text is %S" rdebug-non-annotated-text-kind))
|
117
|
+
(setq gud-marker-acc (concat gud-marker-acc string))
|
118
|
+
(rdebug-debug-message "TOT: %S" gud-marker-acc)
|
119
|
+
(let ((shell-output "") ; Output to debugger shell window.
|
120
|
+
(done nil)
|
121
|
+
item)
|
122
|
+
;; The following loop peels of one "item" at a time. An item is
|
123
|
+
;; a un-annotated section or an annotation. (This is taken care
|
124
|
+
;; of by the `rdebug-marker-filter-next-item' function.)
|
125
|
+
;;
|
126
|
+
;; An Annotation can be a one-liner (where anything following
|
127
|
+
;; the annotation is treated as un-annotated text) or a full
|
128
|
+
;; annotation (which stretches to the next annotation).
|
129
|
+
;;
|
130
|
+
;; The concept of one-liners (no phun intended) is to allow
|
131
|
+
;; continuous output, a "starting" annotation simply sets up the
|
132
|
+
;; environment for sending lines to the output window, any text
|
133
|
+
;; following it right now, or in later chunks of data, is
|
134
|
+
;; redirected to the output window.
|
135
|
+
(while (and (not done)
|
136
|
+
(let ((pair (rdebug-marker-filter-next-item gud-marker-acc)))
|
137
|
+
(rdebug-debug-message "Next item: %S" pair)
|
138
|
+
(and pair
|
139
|
+
(progn
|
140
|
+
(setq item (car pair))
|
141
|
+
(setq gud-marker-acc (cdr pair))
|
142
|
+
t))))
|
143
|
+
;; Note: Regexp:s are greedy, i.e. the char parts wins over
|
144
|
+
;; the .* part.
|
145
|
+
(if (not (string-match "^\032\032\\([-a-z]*\\).*\n" item))
|
146
|
+
;; Non-annotated text (or the content of one-liners) goes
|
147
|
+
;; straight into the debugger shell window, or to the
|
148
|
+
;; output window.
|
149
|
+
(cond ((and (eq rdebug-non-annotated-text-kind :output)
|
150
|
+
rdebug-use-separate-io-buffer)
|
151
|
+
(rdebug-process-annotation "starting" item))
|
152
|
+
((eq rdebug-non-annotated-text-kind :info)
|
153
|
+
(rdebug-process-annotation "info" item))
|
154
|
+
(t
|
155
|
+
(if (eq rdebug-non-annotated-text-kind :cmd)
|
156
|
+
(rdebug-cmd-process item))
|
157
|
+
(setq shell-output (concat shell-output item))))
|
158
|
+
;; Handle annotation.
|
159
|
+
(let* ((line-end (match-end 0))
|
160
|
+
(name (match-string 1 item))
|
161
|
+
;; "prompt" is needed to handle "quit" in the shell correctly.
|
162
|
+
(one-liner
|
163
|
+
(member name
|
164
|
+
'("" "exited" "source" "prompt" "starting")))
|
165
|
+
(next-annotation (string-match "\032\032"
|
166
|
+
gud-marker-acc)))
|
167
|
+
;; For one-liners, shuffle some text back to the accumulator.
|
168
|
+
(when one-liner
|
169
|
+
(setq gud-marker-acc (concat (substring item line-end)
|
170
|
+
gud-marker-acc))
|
171
|
+
(setq item (substring item 0 line-end)))
|
172
|
+
(if (or next-annotation
|
173
|
+
one-liner)
|
174
|
+
;; ok, annotation complete, process it and remove it
|
175
|
+
(let* ((contents (substring item line-end))
|
176
|
+
(old-kind rdebug-non-annotated-text-kind))
|
177
|
+
(rdebug-debug-message "Name: %S Content: %S Kind: %S"
|
178
|
+
name contents
|
179
|
+
rdebug-non-annotated-text-kind)
|
180
|
+
|
181
|
+
;; This is a global state flag, this allows us to
|
182
|
+
;; redirect any further text to the output buffer.
|
183
|
+
(set
|
184
|
+
(make-local-variable 'rdebug-non-annotated-text-kind)
|
185
|
+
(cond ((string= name "starting")
|
186
|
+
:output)
|
187
|
+
((string= name "prompt")
|
188
|
+
(rdebug-cmd-clear)
|
189
|
+
:cmd)
|
190
|
+
((string= name "exited")
|
191
|
+
;; Create a fake command whose output we
|
192
|
+
;; handle in the cmd system. (We might not
|
193
|
+
;; receive all of the message at once, we we
|
194
|
+
;; need some kind of accumukator, which the
|
195
|
+
;; cmd system provides.)
|
196
|
+
(setq rdebug-inferior-status "exited")
|
197
|
+
(rdebug-cmd-clear)
|
198
|
+
(setq rdebug-call-queue
|
199
|
+
(cons '("***exited***" :message)
|
200
|
+
rdebug-call-queue))
|
201
|
+
:cmd)
|
202
|
+
(t nil)))
|
203
|
+
|
204
|
+
(when (and (eq old-kind :cmd)
|
205
|
+
(not (eq rdebug-non-annotated-text-kind :cmd)))
|
206
|
+
(rdebug-debug-message
|
207
|
+
"New kind: %S" rdebug-non-annotated-text-kind)
|
208
|
+
(rdebug-cmd-done))
|
209
|
+
|
210
|
+
;; Process the annotation.
|
211
|
+
(cond ((string= name "starting")
|
212
|
+
(setq rdebug-inferior-status "running"))
|
213
|
+
((string= name "stopped")
|
214
|
+
(setq rdebug-inferior-status "stopped"))
|
215
|
+
((string= name "exited")
|
216
|
+
(setq rdebug-inferior-status "exited"))
|
217
|
+
((string= name "pre-prompt")
|
218
|
+
;; Strip of the trailing \n (this is probably
|
219
|
+
;; a bug in processor.rb).
|
220
|
+
(if (string= (substring contents -1) "\n")
|
221
|
+
(setq contents (substring contents 0 -1)))
|
222
|
+
(if (string-match "post-mortem" contents)
|
223
|
+
(setq rdebug-inferior-status "crashed"))
|
224
|
+
(setq shell-output (concat shell-output contents)))
|
225
|
+
((string= name "source")
|
226
|
+
(if (string-match gud-rdebug-marker-regexp item)
|
227
|
+
;; Extract the frame position from the marker.
|
228
|
+
(setq gud-last-frame
|
229
|
+
(cons (match-string 1 item)
|
230
|
+
(string-to-number
|
231
|
+
(match-string 2 item))))))
|
232
|
+
(t (rdebug-process-annotation name contents))))
|
233
|
+
;; This is not a one-liner, and we haven't seen the next
|
234
|
+
;; annotation, so we have to treat this as a partial
|
235
|
+
;; annotation. Save it and hope that the we can process
|
236
|
+
;; it the next time we're called.
|
237
|
+
(setq gud-marker-acc (concat item gud-marker-acc))
|
238
|
+
(setq done t)))))
|
239
|
+
|
240
|
+
(when gud-last-frame
|
241
|
+
;; Display the source file where we want it, gud will only pick
|
242
|
+
;; an arbitrary window.
|
243
|
+
(rdebug-pick-source-window)
|
244
|
+
(rdebug-set-frame-arrow (gud-find-file (car gud-last-frame)))
|
245
|
+
(if (equal 0 rdebug-frames-current-frame-number)
|
246
|
+
(rdebug-locring-add gud-last-frame
|
247
|
+
rdebug-source-location-ring)))
|
248
|
+
(rdebug-short-key-mode-maybe-activate)
|
249
|
+
|
250
|
+
(unless (string= shell-output "")
|
251
|
+
(rdebug-debug-message "Output: %S" shell-output))
|
252
|
+
(rdebug-debug-message "REM: %S" gud-marker-acc)
|
253
|
+
|
254
|
+
shell-output)))
|
255
|
+
|
256
|
+
(defun rdebug-process-annotation (name contents)
|
257
|
+
"Called after `gud-rdebug-marker-filter' found a complete
|
258
|
+
`name' annotation with string `contents'. Send it to the right
|
259
|
+
place for processing."
|
260
|
+
(rdebug-debug-enter (format "rdebug-process-annotation %s" name)
|
261
|
+
;; Ruby-debug uses the name "starting" for process output (just like
|
262
|
+
;; GDB). However, it's better to present the buffer as "output" to
|
263
|
+
;; the user. Ditto for "display" and "watch".
|
264
|
+
(cond ((string= name "starting")
|
265
|
+
(setq name "output"))
|
266
|
+
((string= name "display")
|
267
|
+
(setq name "watch"))
|
268
|
+
((string= name "stack")
|
269
|
+
(setq name "frame"))
|
270
|
+
((string= name "error-begin")
|
271
|
+
(setq name "error")))
|
272
|
+
;; New "info"
|
273
|
+
(if (string= name "exited")
|
274
|
+
(setq name "info"))
|
275
|
+
(if (string= name "error")
|
276
|
+
(rdebug-errmsg contents))
|
277
|
+
(let ((setup-func (gethash name rdebug-annotation-setup-map)))
|
278
|
+
(when setup-func
|
279
|
+
(let ((buf (rdebug-get-buffer name gud-target-name))
|
280
|
+
;; Buffer local, doesn't survive the buffer change.
|
281
|
+
(comint-buffer gud-comint-buffer))
|
282
|
+
(with-current-buffer buf
|
283
|
+
(setq buffer-read-only t)
|
284
|
+
(let ((inhibit-read-only t))
|
285
|
+
(set (make-local-variable 'rdebug-current-line-number)
|
286
|
+
(line-number-at-pos))
|
287
|
+
(set (make-local-variable 'gud-last-frame) gud-last-frame)
|
288
|
+
(if rdebug-accumulative-buffer
|
289
|
+
(goto-char (point-max))
|
290
|
+
(erase-buffer))
|
291
|
+
(insert contents)
|
292
|
+
(funcall setup-func buf comint-buffer))))))
|
293
|
+
(cond ((and (string= name "info")
|
294
|
+
(not (string= contents "")))
|
295
|
+
(save-selected-window
|
296
|
+
(rdebug-display-info-buffer))))))
|
297
|
+
|
298
|
+
|
299
|
+
;; ------------------------------------------------------------
|
300
|
+
;; Mode line displayer.
|
301
|
+
;;
|
302
|
+
|
303
|
+
;; The variable rdebug-mode-line-process uses this to generate the
|
304
|
+
;; actual string to display.
|
305
|
+
(defun rdebug-display-inferior-status ()
|
306
|
+
"Return a (propertized) string, or nil, to be displayed in the mode line."
|
307
|
+
(if (and gud-comint-buffer
|
308
|
+
(buffer-name gud-comint-buffer)
|
309
|
+
(get-buffer-process gud-comint-buffer)
|
310
|
+
rdebug-inferior-status)
|
311
|
+
(let ((s rdebug-inferior-status))
|
312
|
+
(cond ((string= rdebug-inferior-status "running")
|
313
|
+
(setq s (propertize s 'face font-lock-type-face)))
|
314
|
+
(t
|
315
|
+
(setq s (propertize s 'face font-lock-warning-face))))
|
316
|
+
(concat ":" s))
|
317
|
+
;; No process, don't display anything.
|
318
|
+
nil))
|
319
|
+
|
320
|
+
;; ------------------------------------------------------------
|
321
|
+
;; Command output parser.
|
322
|
+
;;
|
323
|
+
|
324
|
+
(defvar rdebug-cmd-acc ""
|
325
|
+
"The accumulated output of the current command.
|
326
|
+
|
327
|
+
Note, on some systems the external process echoes the command,
|
328
|
+
which is included in the output.")
|
329
|
+
|
330
|
+
;; Called when a new command starts.
|
331
|
+
(defun rdebug-cmd-clear ()
|
332
|
+
"Called when the Rdebug filter find the start of a new commands."
|
333
|
+
(rdebug-debug-enter "rdebug-cmd-clear"
|
334
|
+
(setq rdebug-cmd-acc "")))
|
335
|
+
|
336
|
+
;; Called with command output, this can be called any number of times.
|
337
|
+
(defun rdebug-cmd-process (s)
|
338
|
+
"Called when the Rdebug filter find the command output.
|
339
|
+
This may be called any number of times."
|
340
|
+
(rdebug-debug-enter (format "rdebug-cmd-process %S" s)
|
341
|
+
(setq rdebug-cmd-acc (concat rdebug-cmd-acc s))))
|
342
|
+
|
343
|
+
;; Called when command has finished.
|
344
|
+
(defun rdebug-cmd-done ()
|
345
|
+
"Called when the Rdebug filter find the end of a commands."
|
346
|
+
(rdebug-debug-enter "rdebug-cmd-done"
|
347
|
+
;; car-safe is used since rdebug-call-queue can be empty.
|
348
|
+
(let ((entry (car-safe rdebug-call-queue))
|
349
|
+
(text rdebug-cmd-acc))
|
350
|
+
(when entry
|
351
|
+
(rdebug-debug-message "Entry: %S Acc:%S" rdebug-call-queue rdebug-cmd-acc)
|
352
|
+
(setq rdebug-call-queue (cdr rdebug-call-queue))
|
353
|
+
(let ((saved-cmd (car entry))
|
354
|
+
(options (cdr entry)))
|
355
|
+
;; In cast the external process echoed the actual command,
|
356
|
+
;; remove it.
|
357
|
+
(when (and (>= (length text)
|
358
|
+
(length saved-cmd))
|
359
|
+
(string= saved-cmd (substring text 0 (length saved-cmd))))
|
360
|
+
(setq text (substring text (+ 1 (length saved-cmd)))))
|
361
|
+
(rdebug-debug-message "Text: %S" text)
|
362
|
+
;; Optionally display the result.
|
363
|
+
(if (memq :tooltip options)
|
364
|
+
(rdebug-temp-show text))
|
365
|
+
(if (memq :info options)
|
366
|
+
(rdebug-process-annotation "info" text))
|
367
|
+
(when (memq :message options)
|
368
|
+
;; Remove trailing newlines (chomp).
|
369
|
+
(while (and (> (length text) 0)
|
370
|
+
(eq (elt text (- (length text) 1)) ?\n))
|
371
|
+
(setq text (substring text 0 -1)))
|
372
|
+
(message text)))))))
|
373
|
+
|
374
|
+
|
375
|
+
;; -------------------------------------------------------------------
|
376
|
+
;; The end.
|
377
|
+
;;
|
378
|
+
|
379
|
+
(provide 'rdebug-annotate)
|
380
|
+
|
381
|
+
;;; Local variables:
|
382
|
+
;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
|
383
|
+
;;; End:
|
384
|
+
|
385
|
+
;;; rdebug-annotate.el ends here
|