debugger2 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +65 -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 +108 -0
- data/Rakefile +78 -0
- data/bin/rdebug +397 -0
- data/debugger2.gemspec +29 -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/breakpoint.c +630 -0
- data/ext/ruby_debug/extconf.rb +11 -0
- data/ext/ruby_debug/ruby_debug.c +2203 -0
- data/ext/ruby_debug/ruby_debug.h +151 -0
- data/lib/debugger.rb +5 -0
- data/lib/debugger/version.rb +5 -0
- data/lib/debugger2.rb +6 -0
- data/lib/ruby-debug-base.rb +307 -0
- data/lib/ruby-debug.rb +176 -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 +39 -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/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 +366 -0
- data/test/conditions_test.rb +77 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +143 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +94 -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 +49 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +51 -0
- data/test/info_test.rb +326 -0
- data/test/irb_test.rb +82 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +49 -0
- data/test/list_test.rb +147 -0
- data/test/method_test.rb +72 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +56 -0
- data/test/reload_test.rb +47 -0
- data/test/restart_test.rb +145 -0
- data/test/save_test.rb +94 -0
- data/test/set_test.rb +183 -0
- data/test/show_test.rb +294 -0
- data/test/source_test.rb +46 -0
- data/test/stepping_test.rb +122 -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 +206 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +9 -0
- data/test/thread_test.rb +124 -0
- data/test/tmate_test.rb +45 -0
- data/test/trace_test.rb +156 -0
- data/test/variables_test.rb +116 -0
- metadata +319 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
class TestInterface < Debugger::Interface
|
2
|
+
attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue
|
3
|
+
attr_accessor :command_queue, :test_block, :print_queue
|
4
|
+
attr_accessor :restart_file, :history_save, :history_length, :readline_support, :histfile
|
5
|
+
def initialize
|
6
|
+
@input_queue = []
|
7
|
+
@output_queue = []
|
8
|
+
@error_queue = []
|
9
|
+
@confirm_queue = []
|
10
|
+
@command_queue = []
|
11
|
+
@print_queue = []
|
12
|
+
@readline_support = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def errmsg(*args)
|
16
|
+
@error_queue << format(args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_command(*args)
|
20
|
+
if @input_queue.empty? && test_block
|
21
|
+
test_block.call
|
22
|
+
self.test_block = nil
|
23
|
+
end
|
24
|
+
result = @input_queue.shift
|
25
|
+
result.is_a?(Proc) ? result.call : result
|
26
|
+
end
|
27
|
+
|
28
|
+
def print(*args)
|
29
|
+
@output_queue << format(args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def confirm(message)
|
33
|
+
@confirm_queue << message
|
34
|
+
read_command message
|
35
|
+
end
|
36
|
+
|
37
|
+
def readline_support?
|
38
|
+
@readline_support
|
39
|
+
end
|
40
|
+
|
41
|
+
def finalize
|
42
|
+
end
|
43
|
+
|
44
|
+
def close
|
45
|
+
end
|
46
|
+
|
47
|
+
def inspect
|
48
|
+
[
|
49
|
+
"input_queue: #{input_queue.inspect}",
|
50
|
+
"output_queue: #{output_queue.inspect}",
|
51
|
+
"error_queue: #{error_queue.inspect}",
|
52
|
+
"confirm_queue: #{confirm_queue.inspect}",
|
53
|
+
"print_queue: #{print_queue.inspect}"
|
54
|
+
].join("\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def format(args)
|
60
|
+
if args.size > 1
|
61
|
+
args.first % args[1..-1]
|
62
|
+
else
|
63
|
+
args.first
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/thread_test.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Thread Command" do
|
4
|
+
include TestDsl
|
5
|
+
let(:release) { 'eval Thread.main[:should_break] = true' }
|
6
|
+
|
7
|
+
describe "list" do
|
8
|
+
it "must show current thread by 'plus' sign" do
|
9
|
+
thnum = nil
|
10
|
+
enter 'break 8', 'cont', 'thread list', release
|
11
|
+
debug_file('thread') { thnum = Debugger.contexts.first.thnum }
|
12
|
+
check_output_includes '+', thnum.to_s, /#<Thread:\S+ run>/, "#{fullpath('thread')}:8"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must work with shortcut" do
|
16
|
+
thnum = nil
|
17
|
+
enter 'break 8', 'cont', 'th list', release
|
18
|
+
debug_file('thread') { thnum = Debugger.contexts.first.thnum }
|
19
|
+
check_output_includes '+', thnum.to_s, /#<Thread:\S+ run>/, "#{fullpath('thread')}:8"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it "must show 3 available threads" do
|
24
|
+
enter 'break 21', 'cont', 'thread list', release
|
25
|
+
debug_file 'thread'
|
26
|
+
check_output_includes /#<Thread:\S+ (sleep|run)>/, /#<Thread:\S+ (sleep|run)>/, /#<Thread:\S+ (sleep|run)>/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "stop" do
|
32
|
+
it "must stop one of the threads" do
|
33
|
+
thnum = nil
|
34
|
+
enter 'break 21', 'cont', ->{"thread stop #{Debugger.contexts.last.thnum}"}, release
|
35
|
+
debug_file('thread') { thnum = Debugger.contexts.last.thnum }
|
36
|
+
check_output_includes "$", thnum.to_s, /#<Thread:/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must show error message if thread number is not specified" do
|
40
|
+
enter 'break 8', 'cont', "thread stop", release
|
41
|
+
debug_file 'thread'
|
42
|
+
check_output_includes "'thread stop' needs a thread number", interface.error_queue
|
43
|
+
end
|
44
|
+
|
45
|
+
it "must show error message when trying to stop current thread" do
|
46
|
+
enter 'break 8', 'cont', ->{"thread stop #{Debugger.contexts.first.thnum}"}, release
|
47
|
+
debug_file 'thread'
|
48
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
describe "resume" do
|
54
|
+
|
55
|
+
# TODO: This test sometimes causes Segmentation Fault. No idea how to fix it...
|
56
|
+
it "must resume one of the threads"# do
|
57
|
+
# thnum = nil
|
58
|
+
# # If we don't put some sleep before 'thread resume', it may not change its status yet... :(
|
59
|
+
# enter(
|
60
|
+
# 'break 21',
|
61
|
+
# 'cont',
|
62
|
+
# -> do
|
63
|
+
# thnum = Debugger.contexts.last.thnum
|
64
|
+
# "thread stop #{thnum}"
|
65
|
+
# end,
|
66
|
+
# -> { puts; "thread resume #{thnum}" },
|
67
|
+
# -> { puts; release }
|
68
|
+
# )
|
69
|
+
# debug_file('thread') { Debugger.contexts.last.suspended?.must_equal false }
|
70
|
+
# check_output_includes "", thnum.to_s, /#<Thread:/
|
71
|
+
#end
|
72
|
+
|
73
|
+
it "must show error message if thread number is not specified" do
|
74
|
+
enter 'break 8', 'cont', "thread resume", release
|
75
|
+
debug_file 'thread'
|
76
|
+
check_output_includes "'thread resume' needs a thread number", interface.error_queue
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must show error message when trying to resume current thread" do
|
80
|
+
enter 'break 8', 'cont', ->{"thread resume #{Debugger.contexts.first.thnum}"}, release
|
81
|
+
debug_file 'thread'
|
82
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
83
|
+
end
|
84
|
+
|
85
|
+
it "must show error message if it is not stopped" do
|
86
|
+
thnum = nil
|
87
|
+
enter 'break 21', 'cont', ->{"thread resume #{Debugger.contexts.last.thnum}"}, release
|
88
|
+
debug_file('thread') { thnum = Debugger.contexts.last.thnum }
|
89
|
+
check_output_includes "Already running."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
describe "switch" do
|
95
|
+
it "must switch to another thread"# do
|
96
|
+
# enter 'break 21', 'cont', ->{"thread #{Debugger.contexts.last.thnum}"}, release
|
97
|
+
# debug_file('thread') { state.line.must_equal 16 }
|
98
|
+
#end
|
99
|
+
|
100
|
+
it "must show error message if thread number is not specified" do
|
101
|
+
enter 'break 8', 'cont', "thread switch", release
|
102
|
+
debug_file 'thread'
|
103
|
+
check_output_includes "thread thread switch argument 'switch' needs to be a number."
|
104
|
+
end
|
105
|
+
|
106
|
+
it "must show error message when trying to switch current thread" do
|
107
|
+
enter 'break 8', 'cont', ->{"thread switch #{Debugger.contexts.first.thnum}"}, release
|
108
|
+
debug_file 'thread'
|
109
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
describe "Post Mortem" do
|
115
|
+
it "must work in post-mortem mode"
|
116
|
+
|
117
|
+
0.times do
|
118
|
+
enter 'cont', 'thread list'
|
119
|
+
debug_file('post_mortem')
|
120
|
+
check_output_includes "+", /\d+/, /#<Thread:(\S+) run/
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
data/test/tmate_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
if RUBY_PLATFORM =~ /darwin/
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
describe "Tmate Command" do
|
5
|
+
include TestDsl
|
6
|
+
|
7
|
+
it "must open a current file with current frame in Textmate" do
|
8
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with("open 'txmt://open?url=file://#{fullpath('tmate')}&line=7'")
|
9
|
+
enter 'break 7', 'cont', 'tmate'
|
10
|
+
debug_file 'tmate'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "must open a current file with specified frame in Textmate" do
|
14
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with("open 'txmt://open?url=file://#{fullpath('tmate')}&line=4'")
|
15
|
+
enter 'break 7', 'cont', 'tmate 2'
|
16
|
+
debug_file 'tmate'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "errors" do
|
20
|
+
it "must show an error message if frame == 0" do
|
21
|
+
enter 'tmate 0'
|
22
|
+
debug_file 'tmate'
|
23
|
+
check_output_includes "Wrong frame number"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must show an error message if frame > max frame" do
|
27
|
+
enter 'tmate 10'
|
28
|
+
debug_file 'tmate'
|
29
|
+
check_output_includes "Wrong frame number"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "Post Mortem" do
|
34
|
+
it "must work in post-mortem mode"
|
35
|
+
|
36
|
+
0.times do
|
37
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with(
|
38
|
+
"open 'txmt://open?url=file://#{fullpath('post_mortem')}&line=8'"
|
39
|
+
)
|
40
|
+
enter 'cont', 'tmate'
|
41
|
+
debug_file 'post_mortem'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/trace_test.rb
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Trace Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace'))
|
6
|
+
temporary_change_hash_value(Debugger::Command.settings, :basename, false)
|
7
|
+
temporary_change_method_value(Debugger, :tracing, false)
|
8
|
+
before { untrace_var(:$bla) if defined?($bla) }
|
9
|
+
|
10
|
+
describe "tracing on the current thread" do
|
11
|
+
describe "enabling" do
|
12
|
+
it "must trace execution by setting trace to on" do
|
13
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
14
|
+
thnum = nil
|
15
|
+
enter 'trace on'
|
16
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
17
|
+
check_output_includes(
|
18
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:4 @break1 = false",
|
19
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:5 @break2 = false"
|
20
|
+
)
|
21
|
+
check_output_doesnt_include /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "must show a message it is on" do
|
26
|
+
enter 'trace on'
|
27
|
+
debug_file 'trace'
|
28
|
+
check_output_includes "Tracing on on current thread."
|
29
|
+
end
|
30
|
+
|
31
|
+
it "must be able to use a shortcut" do
|
32
|
+
enter 'tr on'
|
33
|
+
debug_file 'trace'
|
34
|
+
check_output_includes "Tracing on on current thread."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must show an error message if given subcommand is incorrect" do
|
39
|
+
enter 'trace bla'
|
40
|
+
debug_file 'trace'
|
41
|
+
check_output_includes "expecting 'on', 'off', 'var' or 'variable'; got: bla", interface.error_queue
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "disabling" do
|
45
|
+
it "must stop tracing by setting trace to off" do
|
46
|
+
thnum = nil
|
47
|
+
enter 'trace on', 'next', 'trace off'
|
48
|
+
debug_file('trace') { thnum = context.thnum }
|
49
|
+
check_output_includes "Tracing(#{thnum}):#{fullpath('trace')}:4 $bla = 4"
|
50
|
+
check_output_doesnt_include "Tracing(#{thnum}):#{fullpath('trace')}:5 $bla = 5"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "must show a message it is off" do
|
54
|
+
enter 'trace off'
|
55
|
+
debug_file 'trace'
|
56
|
+
check_output_includes "Tracing off on current thread."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe "tracing on all thread" do
|
63
|
+
describe "enabling" do
|
64
|
+
it "must trace execution by setting trace to on" do
|
65
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
66
|
+
thnum = nil
|
67
|
+
enter 'trace on all'
|
68
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
69
|
+
check_output_includes(
|
70
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:4 @break1 = false",
|
71
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:5 @break2 = false"
|
72
|
+
)
|
73
|
+
check_output_includes /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it "must show a message it is on" do
|
78
|
+
enter 'trace on all'
|
79
|
+
debug_file 'trace'
|
80
|
+
check_output_includes "Tracing on all threads."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "disabling" do
|
85
|
+
it "must stop tracing by setting trace to off" do
|
86
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
87
|
+
thnum = nil
|
88
|
+
enter 'trace on all', 'break 19', 'cont', 'trace off all'
|
89
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
90
|
+
check_output_includes /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
91
|
+
check_output_includes "Tracing(#{thnum}):#{fullpath('trace_threads')}:19 t1.join"
|
92
|
+
check_output_doesnt_include "Tracing(#{thnum}):#{fullpath('trace_threads')}:20 t1"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "must show a message it is off" do
|
97
|
+
enter 'trace off'
|
98
|
+
debug_file 'trace'
|
99
|
+
check_output_includes "Tracing off on current thread."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
describe "tracing global variables" do
|
106
|
+
it "must track global variable" do
|
107
|
+
enter 'trace variable $bla'
|
108
|
+
debug_file 'trace'
|
109
|
+
check_output_includes(
|
110
|
+
"traced variable $bla has value 3",
|
111
|
+
"traced variable $bla has value 7",
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "must be able to use a shortcut" do
|
116
|
+
enter 'trace var $bla'
|
117
|
+
debug_file 'trace'
|
118
|
+
check_output_includes "traced variable $bla has value 3"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "must track global variable with stop" do
|
122
|
+
enter 'trace variable $bla stop', 'break 7', 'cont'
|
123
|
+
debug_file('trace') { state.line.must_equal 4 }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "must track global variable with nostop" do
|
127
|
+
enter 'trace variable $bla nostop', 'break 7', 'cont'
|
128
|
+
debug_file('trace') { state.line.must_equal 7 }
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "errors" do
|
132
|
+
it "must show an error message if there is no such global variable" do
|
133
|
+
enter 'trace variable $foo'
|
134
|
+
debug_file 'trace'
|
135
|
+
check_output_includes "$foo is not a global variable.", interface.error_queue
|
136
|
+
end
|
137
|
+
|
138
|
+
it "must show an error message if subcommand is invalid" do
|
139
|
+
enter 'trace variable $bla foo'
|
140
|
+
debug_file 'trace'
|
141
|
+
check_output_includes "expecting 'stop' or 'nostop'; got foo", interface.error_queue
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "Post Mortem" do
|
147
|
+
it "must work in post-mortem mode"
|
148
|
+
|
149
|
+
0.times do
|
150
|
+
enter 'cont', 'trace on'
|
151
|
+
debug_file 'post_mortem'
|
152
|
+
check_output_includes "Tracing on on current thread."
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Variables Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_change_hash_value(Debugger::Command.settings, :width, 40)
|
6
|
+
|
7
|
+
describe "class variables" do
|
8
|
+
it "must show variables" do
|
9
|
+
enter 'break 19', 'cont', 'var class'
|
10
|
+
debug_file 'variables'
|
11
|
+
check_output_includes "@@class_c = 3"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must be able to use shortcut" do
|
15
|
+
enter 'break 19', 'cont', 'v cl'
|
16
|
+
debug_file 'variables'
|
17
|
+
check_output_includes "@@class_c = 3"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "constants" do
|
22
|
+
it "must show constants" do
|
23
|
+
enter 'break 25', 'cont', 'var const VariablesExample'
|
24
|
+
debug_file 'variables'
|
25
|
+
check_output_includes 'SOMECONST => "foo"'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must be able to use shortcut" do
|
29
|
+
enter 'break 25', 'cont', 'v co VariablesExample'
|
30
|
+
debug_file 'variables'
|
31
|
+
check_output_includes 'SOMECONST => "foo"'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must show an error message if the given object is not a Class or Module" do
|
35
|
+
enter 'break 25', 'cont', 'var const v'
|
36
|
+
debug_file 'variables'
|
37
|
+
check_output_includes "Should be Class/Module: v"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "globals" do
|
42
|
+
it "must show global variables" do
|
43
|
+
enter 'break 25', 'cont', 'var global'
|
44
|
+
debug_file 'variables'
|
45
|
+
check_output_includes '$glob = 100'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must be able to use shortcut" do
|
49
|
+
enter 'break 25', 'cont', 'v g'
|
50
|
+
debug_file 'variables'
|
51
|
+
check_output_includes '$glob = 100'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "instance variables" do
|
56
|
+
it "must show instance variables of the given object" do
|
57
|
+
enter 'break 25', 'cont', 'var instance v'
|
58
|
+
debug_file 'variables'
|
59
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "must show instance variables of self" do
|
63
|
+
enter 'break 11', 'cont', 'var instance'
|
64
|
+
debug_file 'variables'
|
65
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "must show instance variables" do
|
69
|
+
enter 'break 25', 'cont', 'var instance v'
|
70
|
+
debug_file 'variables'
|
71
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "must be able to use shortcut" do
|
75
|
+
enter 'break 25', 'cont', 'v ins v'
|
76
|
+
debug_file 'variables'
|
77
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "must cut long variable values according to :width setting" do
|
81
|
+
temporary_change_hash_value(Debugger::Command.settings, :width, 20) do
|
82
|
+
enter 'break 25', 'cont', 'var instance v'
|
83
|
+
debug_file 'variables'
|
84
|
+
check_output_includes '@inst_c = "1111111111111111...'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "must show fallback message if value doesn't have #to_s or #inspect methods" do
|
89
|
+
enter 'break 25', 'cont', 'var instance v'
|
90
|
+
debug_file 'variables'
|
91
|
+
check_output_includes '@inst_d = *Error in evaluation*'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "local variables" do
|
96
|
+
it "must show local variables" do
|
97
|
+
enter 'break 17', 'cont', 'var local'
|
98
|
+
debug_file 'variables'
|
99
|
+
check_output_includes "a => 4", "b => nil", "i => 1"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# TODO: Need to write tests for 'var ct' command, but I can't install the 'ruby-internal' gem
|
104
|
+
# on my machine, it fails to build gem native extension.
|
105
|
+
|
106
|
+
describe "Post Mortem" do
|
107
|
+
it "must work in post-mortem mode"
|
108
|
+
|
109
|
+
0.times do
|
110
|
+
enter 'cont', 'var local'
|
111
|
+
debug_file 'post_mortem'
|
112
|
+
check_output_includes "x => nil", "z => 4"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|