trepanning 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4422 -0
- data/LICENSE +23 -0
- data/NEWS +12 -0
- data/README.textile +56 -0
- data/Rakefile +171 -0
- data/app/Makefile +7 -0
- data/app/breakpoint.rb +157 -0
- data/app/brkptmgr.rb +149 -0
- data/app/condition.rb +22 -0
- data/app/core.rb +203 -0
- data/app/default.rb +54 -0
- data/app/disassemble.rb +61 -0
- data/app/display.rb +148 -0
- data/app/file.rb +135 -0
- data/app/frame.rb +275 -0
- data/app/irb.rb +112 -0
- data/app/mock.rb +22 -0
- data/app/options.rb +122 -0
- data/app/run.rb +95 -0
- data/app/thread.rb +24 -0
- data/app/util.rb +32 -0
- data/bin/trepan +63 -0
- data/data/custom_require.rb +44 -0
- data/data/irbrc +55 -0
- data/data/prelude.rb +38 -0
- data/interface/base_intf.rb +95 -0
- data/interface/script.rb +103 -0
- data/interface/user.rb +90 -0
- data/io/base_io.rb +92 -0
- data/io/input.rb +111 -0
- data/io/string_array.rb +155 -0
- data/lib/Makefile +7 -0
- data/lib/trepanning.rb +277 -0
- data/processor/breakpoint.rb +108 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +95 -0
- data/processor/command/base/cmd.rb +97 -0
- data/processor/command/base/subcmd.rb +207 -0
- data/processor/command/base/submgr.rb +178 -0
- data/processor/command/base/subsubcmd.rb +102 -0
- data/processor/command/base/subsubmgr.rb +182 -0
- data/processor/command/break.rb +85 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/debug.rb +85 -0
- data/processor/command/delete.rb +54 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disable.rb +65 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/display.rb +81 -0
- data/processor/command/down.rb +56 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/exit.rb +54 -0
- data/processor/command/finish.rb +81 -0
- data/processor/command/frame.rb +117 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/args.rb +56 -0
- data/processor/command/info_subcmd/breakpoints.rb +162 -0
- data/processor/command/info_subcmd/file.rb +162 -0
- data/processor/command/info_subcmd/frame.rb +39 -0
- data/processor/command/info_subcmd/iseq.rb +83 -0
- data/processor/command/info_subcmd/locals.rb +88 -0
- data/processor/command/info_subcmd/program.rb +54 -0
- data/processor/command/info_subcmd/registers.rb +72 -0
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +38 -0
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +40 -0
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +54 -0
- data/processor/command/info_subcmd/registers_subcmd/pc.rb +44 -0
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +75 -0
- data/processor/command/info_subcmd/return.rb +40 -0
- data/processor/command/info_subcmd/thread.rb +106 -0
- data/processor/command/irb.rb +106 -0
- data/processor/command/kill.rb +58 -0
- data/processor/command/list.rb +327 -0
- data/processor/command/macro.rb +65 -0
- data/processor/command/next.rb +89 -0
- data/processor/command/nocache.rb +33 -0
- data/processor/command/print.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/quit.rb +62 -0
- data/processor/command/raise.rb +47 -0
- data/processor/command/reload.rb +28 -0
- data/processor/command/reload_subcmd/command.rb +34 -0
- data/processor/command/restart.rb +57 -0
- data/processor/command/save.rb +60 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +67 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +49 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +51 -0
- data/processor/command/set_subcmd/basename.rb +39 -0
- data/processor/command/set_subcmd/debug.rb +27 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +49 -0
- data/processor/command/set_subcmd/debug_subcmd/except.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/macro.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/stack.rb +45 -0
- data/processor/command/set_subcmd/different.rb +67 -0
- data/processor/command/set_subcmd/events.rb +71 -0
- data/processor/command/set_subcmd/max.rb +35 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +60 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +53 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +50 -0
- data/processor/command/set_subcmd/return.rb +66 -0
- data/processor/command/set_subcmd/sp.rb +62 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/eval.rb +98 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +55 -0
- data/processor/command/set_subcmd/substitute_subcmd/string.rb +72 -0
- data/processor/command/set_subcmd/timer.rb +68 -0
- data/processor/command/set_subcmd/trace.rb +43 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +56 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +54 -0
- data/processor/command/set_subcmd/trace_subcmd/var.rb +61 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +50 -0
- data/processor/command/show_subcmd/args.rb +50 -0
- data/processor/command/show_subcmd/auto.rb +27 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +38 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +36 -0
- data/processor/command/show_subcmd/basename.rb +28 -0
- data/processor/command/show_subcmd/debug.rb +27 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +31 -0
- data/processor/command/show_subcmd/debug_subcmd/except.rb +33 -0
- data/processor/command/show_subcmd/debug_subcmd/macro.rb +32 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +33 -0
- data/processor/command/show_subcmd/debug_subcmd/stack.rb +32 -0
- data/processor/command/show_subcmd/different.rb +37 -0
- data/processor/command/show_subcmd/events.rb +40 -0
- data/processor/command/show_subcmd/macro.rb +45 -0
- data/processor/command/show_subcmd/max.rb +31 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +39 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +35 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +41 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +36 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +84 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +74 -0
- data/processor/command/step.rb +139 -0
- data/processor/command/stepi.rb +63 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +92 -0
- data/processor/default.rb +45 -0
- data/processor/display.rb +17 -0
- data/processor/eval.rb +88 -0
- data/processor/eventbuf.rb +131 -0
- data/processor/frame.rb +230 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +128 -0
- data/processor/load_cmds.rb +102 -0
- data/processor/location.rb +126 -0
- data/processor/main.rb +364 -0
- data/processor/mock.rb +100 -0
- data/processor/msg.rb +26 -0
- data/processor/running.rb +170 -0
- data/processor/subcmd.rb +159 -0
- data/processor/validate.rb +395 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-xx.rb +18 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/gcd1.rb +24 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/fn_helper.rb +119 -0
- data/test/functional/test-break.rb +87 -0
- data/test/functional/test-condition.rb +59 -0
- data/test/functional/test-debugger-call-bug.rb +31 -0
- data/test/functional/test-delete.rb +71 -0
- data/test/functional/test-finish.rb +44 -0
- data/test/functional/test-immediate-step-bug.rb +35 -0
- data/test/functional/test-next.rb +77 -0
- data/test/functional/test-raise.rb +73 -0
- data/test/functional/test-return.rb +100 -0
- data/test/functional/test-step.rb +274 -0
- data/test/functional/test-stepbug.rb +40 -0
- data/test/functional/test-trace-var.rb +40 -0
- data/test/functional/tmp/b1.rb +5 -0
- data/test/functional/tmp/s1.rb +9 -0
- data/test/functional/tmp/t2.rb +6 -0
- data/test/integration/file-diff.rb +88 -0
- data/test/integration/helper.rb +52 -0
- data/test/integration/test-fname-with-blank.rb +11 -0
- data/test/integration/test-quit.rb +11 -0
- data/test/integration/try-test-enable.rb +11 -0
- data/test/unit/cmd-helper.rb +44 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +56 -0
- data/test/unit/test-app-disassemble.rb +60 -0
- data/test/unit/test-app-file.rb +46 -0
- data/test/unit/test-app-frame.rb +49 -0
- data/test/unit/test-app-options.rb +60 -0
- data/test/unit/test-app-run.rb +19 -0
- data/test/unit/test-app-thread.rb +25 -0
- data/test/unit/test-app-util.rb +17 -0
- data/test/unit/test-base-subcmd.rb +59 -0
- data/test/unit/test-bin-trepan.rb +48 -0
- data/test/unit/test-cmd-alias.rb +50 -0
- data/test/unit/test-cmd-break.rb +80 -0
- data/test/unit/test-cmd-endisable.rb +59 -0
- data/test/unit/test-cmd-help.rb +100 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-quit.rb +26 -0
- data/test/unit/test-cmd-step.rb +45 -0
- data/test/unit/test-intf-user.rb +45 -0
- data/test/unit/test-io-input.rb +26 -0
- data/test/unit/test-proc-eval.rb +26 -0
- data/test/unit/test-proc-frame.rb +77 -0
- data/test/unit/test-proc-help.rb +15 -0
- data/test/unit/test-proc-hook.rb +29 -0
- data/test/unit/test-proc-load_cmds.rb +40 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +90 -0
- data/test/unit/test-subcmd-help.rb +48 -0
- metadata +358 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative 'base/submgr'
|
4
|
+
|
5
|
+
class Trepan::Command::ReloadCommand < Trepan::SubcommandMgr
|
6
|
+
ALIASES = %w(rel)
|
7
|
+
HELP = 'Reload information'
|
8
|
+
CATEGORY = 'data'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
NEED_STACK = false
|
11
|
+
SHORT_HELP = 'Reload information'
|
12
|
+
def initialize(proc)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
if __FILE__ == $0
|
19
|
+
require_relative '../mock'
|
20
|
+
name = File.basename(__FILE__, '.rb')
|
21
|
+
dbgr, cmd = MockDebugger::setup(name)
|
22
|
+
|
23
|
+
# require 'trepanning'
|
24
|
+
# Trepan.debug(:set_restart => true)
|
25
|
+
xx = Trepan::Command::ReloadCommand.new(cmd)
|
26
|
+
cmd.run([name])
|
27
|
+
cmd.run([name, 'command'])
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subcmd'
|
4
|
+
|
5
|
+
class Trepan::Subcommand::ReloadCommand < Trepan::Subcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'Reload debugger commmands from debugger directories'
|
8
|
+
MIN_ABBREV = 'co'.size # Note we have "info file"
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
NEED_STACK = true
|
11
|
+
PREFIX = %w(reload command)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(args)
|
15
|
+
@proc.load_cmds_initialize
|
16
|
+
msg('Debugger commands reloaded.')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
if __FILE__ == $0
|
22
|
+
# Demo it.
|
23
|
+
require_relative '../../mock'
|
24
|
+
require_relative '../../subcmd'
|
25
|
+
name = File.basename(__FILE__, '.rb')
|
26
|
+
|
27
|
+
# FIXME: DRY the below code
|
28
|
+
dbgr, cmd = MockDebugger::setup('reload')
|
29
|
+
subcommand = Trepan::Subcommand::ReloadCommand.new(cmd)
|
30
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
31
|
+
|
32
|
+
name = File.basename(__FILE__, '.rb')
|
33
|
+
subcommand.summary_help(name)
|
34
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
require_relative '../../app/run'
|
5
|
+
class Trepan::Command::RestartCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
ALIASES = %w(R run)
|
9
|
+
HELP =
|
10
|
+
'restart - Restart debugger and program via an exec
|
11
|
+
call. All state is lost, and new copy of the debugger is used.'
|
12
|
+
|
13
|
+
CATEGORY = 'running'
|
14
|
+
MAX_ARGS = 0 # Need at most this many
|
15
|
+
NAME = File.basename(__FILE__, '.rb')
|
16
|
+
SHORT_HELP = '(Hard) restart of program via exec()'
|
17
|
+
end
|
18
|
+
|
19
|
+
# This method runs the command
|
20
|
+
def run(args) # :nodoc
|
21
|
+
|
22
|
+
dbgr = @proc.dbgr
|
23
|
+
argv = dbgr.restart_argv
|
24
|
+
if argv and argv.size > 0
|
25
|
+
unless File.executable?(argv[0])
|
26
|
+
msg(["File #{argv[0]} not executable.",
|
27
|
+
"Adding Ruby interpreter."])
|
28
|
+
argv.unshift Trepanning::ruby_path
|
29
|
+
end
|
30
|
+
@proc.run_cmd(%w(show args))
|
31
|
+
if not confirm('Restart (exec)?', false)
|
32
|
+
msg "Restart not confirmed"
|
33
|
+
else
|
34
|
+
msg 'Restarting...'
|
35
|
+
@proc.run_cmd(%w(save))
|
36
|
+
argv.unshift
|
37
|
+
# FIXME: Run atexit finalize routines?
|
38
|
+
Dir.chdir(dbgr.initial_dir) if dbgr.initial_dir
|
39
|
+
exec(*argv)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
errmsg("No executable file and command options recorded.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if __FILE__ == $0
|
48
|
+
exit if ARGV[0] == 'exit'
|
49
|
+
|
50
|
+
require_relative '../mock'
|
51
|
+
name = File.basename(__FILE__, '.rb')
|
52
|
+
dbgr, cmd = MockDebugger::setup(name)
|
53
|
+
dbgr.restart_argv = []
|
54
|
+
cmd.run([name])
|
55
|
+
dbgr.restart_argv = [File.expand_path($0), 'exit']
|
56
|
+
cmd.run([name])
|
57
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'tmpdir'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
class Trepan::Command::SaveCommand < Trepan::Command
|
5
|
+
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP =
|
8
|
+
"Save settings to a file"
|
9
|
+
|
10
|
+
CATEGORY = 'running'
|
11
|
+
MAX_ARGS = 1 # Need at most this many
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
SHORT_HELP = 'Send debugger state to a file'
|
14
|
+
end
|
15
|
+
|
16
|
+
# This method runs the command
|
17
|
+
def run(args) # :nodoc
|
18
|
+
save_filename =
|
19
|
+
if args.size > 1
|
20
|
+
args[1]
|
21
|
+
else
|
22
|
+
@proc.settings[:save_cmdfile] ||
|
23
|
+
File.join(Dir.tmpdir,
|
24
|
+
Dir::Tmpname.make_tmpname(['trepanning-save', '.txt'], nil))
|
25
|
+
end
|
26
|
+
begin
|
27
|
+
save_file = File.open(save_filename, 'w')
|
28
|
+
rescue => exc
|
29
|
+
errmsg("Can't open #{save_filename} for writing.")
|
30
|
+
errmsg("System reports: #{exc.inspect}")
|
31
|
+
return
|
32
|
+
end
|
33
|
+
save_file.puts "#\n# Commands to restore trepanning environment\n#\n"
|
34
|
+
@proc.commands.each do |cmd_name, cmd_obj|
|
35
|
+
cmd_obj.save_command if cmd_obj.respond_to?(:save_command)
|
36
|
+
next unless cmd_obj.is_a?(Trepan::SubcommandMgr)
|
37
|
+
cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj|
|
38
|
+
save_file.puts subcmd_obj.save_command if
|
39
|
+
subcmd_obj.respond_to?(:save_command)
|
40
|
+
next unless subcmd_obj.is_a?(Trepan::SubSubcommandMgr)
|
41
|
+
subcmd_obj.subcmds.subcmds.each do |subsubcmd_name, subsubcmd_obj|
|
42
|
+
save_file.puts subsubcmd_obj.save_command if
|
43
|
+
subsubcmd_obj.respond_to?(:save_command)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
save_file.close
|
48
|
+
msg "Debugger commands written to file: #{save_file.to_path}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if __FILE__ == $0
|
53
|
+
require_relative '../mock'
|
54
|
+
name = File.basename(__FILE__, '.rb')
|
55
|
+
dbgr, cmd = MockDebugger::setup(name)
|
56
|
+
require 'tmpdir'
|
57
|
+
cmd.run([name, Dir.tmpdir])
|
58
|
+
cmd.run([name])
|
59
|
+
cmd.run([name, File.join(Dir.tmpdir, 'save_file.txt')])
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative 'base/submgr'
|
4
|
+
|
5
|
+
class Trepan::Command::SetCommand < Trepan::SubcommandMgr
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP =
|
8
|
+
'Modifies parts of the debugger environment.
|
9
|
+
|
10
|
+
You can give unique prefix of the name of a subcommand to get
|
11
|
+
information about just that subcommand.
|
12
|
+
|
13
|
+
Type "set" for a list of "set" subcommands and what they do.
|
14
|
+
Type "help set *" for just the list of "set" subcommands.
|
15
|
+
|
16
|
+
For compatability with older ruby-debug "set auto..." is the
|
17
|
+
same as "set auto ...". For example "set autolist" is the same
|
18
|
+
as "set auto list".
|
19
|
+
'
|
20
|
+
|
21
|
+
CATEGORY = 'support'
|
22
|
+
NAME = File.basename(__FILE__, '.rb')
|
23
|
+
NEED_STACK = false
|
24
|
+
SHORT_HELP = 'Modify parts of the debugger environment'
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(args)
|
28
|
+
if args.size > 1
|
29
|
+
first = args[1].downcase
|
30
|
+
alen = 'auto'.size
|
31
|
+
args[1..1] = ['auto', first[alen..-1]] if
|
32
|
+
first.start_with?('auto') && first.size > alen
|
33
|
+
end
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
if __FILE__ == $0
|
40
|
+
require_relative '../mock'
|
41
|
+
name = File.basename(__FILE__, '.rb')
|
42
|
+
dbgr, cmd = MockDebugger::setup(name)
|
43
|
+
cmd.run([name])
|
44
|
+
cmd.run([name, 'autolist'])
|
45
|
+
cmd.run([name, 'autoeval', 'off'])
|
46
|
+
cmd.run([name, 'basename'])
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subsubcmd'
|
4
|
+
require_relative '../base/subsubmgr'
|
5
|
+
|
6
|
+
class Trepan::SubSubcommand::SetAuto < Trepan::SubSubcommandMgr
|
7
|
+
unless defined?(HELP)
|
8
|
+
HELP = 'Set controls for things with some sort of "automatic" default behavior'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set auto)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $0
|
15
|
+
require_relative '../../mock'
|
16
|
+
dbgr, cmd = MockDebugger::setup('set')
|
17
|
+
cmds = dbgr.core.processor.commands
|
18
|
+
set_cmd = cmds['set']
|
19
|
+
command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
20
|
+
set_cmd)
|
21
|
+
name = File.basename(__FILE__, '.rb')
|
22
|
+
cmd_args = ['set', name]
|
23
|
+
set_cmd.instance_variable_set('@last_args', cmd_args)
|
24
|
+
# require_relative '../../../lib/trepanning'
|
25
|
+
# Trepan.debug(:set_restart => true)
|
26
|
+
command.run(cmd_args)
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::SubSubcommand::SetAutoEval < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = "Evaluate unrecognized debugger commands.
|
8
|
+
|
9
|
+
Often inside the debugger, one would like to be able to run arbitrary
|
10
|
+
Ruby commands without having to preface Python expressions with \"print\" or
|
11
|
+
\"eval\". Setting \"auto eval\" on will cause unrecognized debugger
|
12
|
+
commands to be eval'd as a Ruby expression.
|
13
|
+
|
14
|
+
Note that if this is set, on error the message shown on type a bad
|
15
|
+
debugger command changes from:
|
16
|
+
|
17
|
+
Undefined command: \"fdafds\". Try \"help\".
|
18
|
+
|
19
|
+
to something more Ruby-eval-specific such as:
|
20
|
+
|
21
|
+
NameError: name 'fdafds' is not defined
|
22
|
+
|
23
|
+
One other thing that trips people up is when setting auto eval is that
|
24
|
+
there are some short debugger commands that sometimes one wants to use
|
25
|
+
as a variable, such as in an assignment statement. For example:
|
26
|
+
|
27
|
+
s = 5
|
28
|
+
|
29
|
+
which produce when 'auto eval' is on:
|
30
|
+
*** Command 'step' can take at most 1 argument(s); got 2.
|
31
|
+
|
32
|
+
because by default, 's' is an alias for the debugger 'step'
|
33
|
+
command. It is possible to remove that alias if this causes constant
|
34
|
+
problem. Another possibility is to go into a real Ruby shell via the
|
35
|
+
'irb' command.
|
36
|
+
"
|
37
|
+
MIN_ABBREV = 'ev'.size
|
38
|
+
NAME = File.basename(__FILE__, '.rb')
|
39
|
+
PREFIX = %w(set auto eval)
|
40
|
+
SHORT_HELP = "Set evaluation of unrecognized debugger commands"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
if __FILE__ == $0
|
46
|
+
# Demo it.
|
47
|
+
require_relative '../../../mock'
|
48
|
+
name = File.basename(__FILE__, '.rb')
|
49
|
+
|
50
|
+
# FIXME: DRY the below code
|
51
|
+
dbgr, set_cmd = MockTrepan::setup('set')
|
52
|
+
auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
53
|
+
set_cmd)
|
54
|
+
|
55
|
+
# FIXME: remove the 'join' below
|
56
|
+
cmd_name = Trepan::SubSubcommand::SetAutoEval::PREFIX.join('')
|
57
|
+
subcmd = Trepan::SubSubcommand::SetAutoEval.new(set_cmd.proc,
|
58
|
+
auto_cmd,
|
59
|
+
cmd_name)
|
60
|
+
# require_relative '../../../../lib/trepanning'
|
61
|
+
# Trepan.debug(:set_restart => true)
|
62
|
+
|
63
|
+
subcmd.run([cmd_name])
|
64
|
+
%w(off on 0 1).each { |arg| subcmd.run([cmd_name, arg]) }
|
65
|
+
puts '-' * 10
|
66
|
+
puts subcmd.save_command.join("\n")
|
67
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::Subcommand::SetAutoIrb < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = "Set to automatically go into irb each time we enter the debugger"
|
8
|
+
MIN_ABBREV = 'ir'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set auto irb)
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(args)
|
14
|
+
super
|
15
|
+
if @proc.settings[:autoirb]
|
16
|
+
@proc.cmdloop_prehooks.insert_if_new(-1, *@proc.autoirb_hook)
|
17
|
+
else
|
18
|
+
@proc.cmdloop_prehooks.delete_by_name('autoirb')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
if __FILE__ == $0
|
25
|
+
# Demo it.
|
26
|
+
require_relative '../../../mock'
|
27
|
+
require_relative '../../../subcmd'
|
28
|
+
require_relative '../../../hook'
|
29
|
+
name = File.basename(__FILE__, '.rb')
|
30
|
+
|
31
|
+
# FIXME: DRY the below code
|
32
|
+
dbgr, set_cmd = MockTrepan::setup('set')
|
33
|
+
auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
34
|
+
set_cmd)
|
35
|
+
# FIXME: remove the 'join' below
|
36
|
+
cmd_name = Trepan::Subcommand::SetAutoIrb::PREFIX.join('')
|
37
|
+
autox_cmd = Trepan::SubSubcommand::SetAutoIrb.new(set_cmd.proc,
|
38
|
+
auto_cmd,
|
39
|
+
cmd_name)
|
40
|
+
# require_relative '../../../../lib/trepanning'
|
41
|
+
# dbgr = Trepan.new(:set_restart => true)
|
42
|
+
# dbgr.debugger
|
43
|
+
set_cmd.proc.hook_initialize(set_cmd.proc.commands)
|
44
|
+
subcmd_name = Trepan::Subcommand::SetAutoIrb::PREFIX[1..-1].join('')
|
45
|
+
autox_cmd.run([subcmd_name])
|
46
|
+
autox_cmd.run([subcmd_name, 'off'])
|
47
|
+
puts autox_cmd.save_command.join("\n")
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::Subcommand::SetAutoList < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = "Set to run a 'list' command each time we enter the debugger"
|
8
|
+
MIN_ABBREV = 'l'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set auto list)
|
11
|
+
SHORT_HELP = "Set running a 'list' command each time we enter the debugger"
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(args)
|
15
|
+
super
|
16
|
+
if @proc.settings[:autolist]
|
17
|
+
@proc.cmdloop_prehooks.insert_if_new(10, *@proc.autolist_hook)
|
18
|
+
else
|
19
|
+
@proc.cmdloop_prehooks.delete_by_name('autolist')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
if __FILE__ == $0
|
26
|
+
# Demo it.
|
27
|
+
require_relative '../../../mock'
|
28
|
+
require_relative '../../../subcmd'
|
29
|
+
require_relative '../../../hook'
|
30
|
+
name = File.basename(__FILE__, '.rb')
|
31
|
+
|
32
|
+
# FIXME: DRY the below code
|
33
|
+
dbgr, set_cmd = MockDebugger::setup('set')
|
34
|
+
testcmdMgr = Trepan::Subcmd.new(set_cmd)
|
35
|
+
auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
36
|
+
set_cmd)
|
37
|
+
# FIXME: remove the 'join' below
|
38
|
+
cmd_name = Trepan::Subcommand::SetAutoList::PREFIX.join('')
|
39
|
+
autox_cmd = Trepan::SubSubcommand::SetAutoList.new(set_cmd.proc,
|
40
|
+
auto_cmd,
|
41
|
+
cmd_name)
|
42
|
+
# require_relative '../../../../lib/trepanning'
|
43
|
+
# dbgr = Trepan.new(:set_restart => true)
|
44
|
+
# dbgr.debugger
|
45
|
+
set_cmd.proc.hook_initialize(set_cmd.proc.commands)
|
46
|
+
subcmd_name = Trepan::Subcommand::SetAutoList::PREFIX[1..-1].join('')
|
47
|
+
autox_cmd.run([subcmd_name])
|
48
|
+
autox_cmd.run([subcmd_name, 'off'])
|
49
|
+
puts '-' * 10
|
50
|
+
puts autox_cmd.save_command
|
51
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subcmd'
|
4
|
+
|
5
|
+
class Trepan::Subcommand::SetBasename < Trepan::SetBoolSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = "Set to show only file basename in showing file names"
|
8
|
+
IN_LIST = true
|
9
|
+
MIN_ABBREV = 'ba'.size
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
PREFIX = %w(set basename)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
if __FILE__ == $0
|
17
|
+
# Demo it.
|
18
|
+
require_relative '../../mock'
|
19
|
+
name = File.basename(__FILE__, '.rb')
|
20
|
+
|
21
|
+
# FIXME: DRY the below code
|
22
|
+
dbgr, cmd = MockDebugger::setup('set')
|
23
|
+
subcommand = Trepan::Subcommand::SetBasename.new(cmd)
|
24
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
25
|
+
|
26
|
+
subcommand.run_show_bool
|
27
|
+
subcommand.summary_help(name)
|
28
|
+
|
29
|
+
# require 'trepanning'
|
30
|
+
# Trepan.debug(:set_restart => true)
|
31
|
+
subcommand.run(['set', name])
|
32
|
+
subcommand.run(['set', name, 'off'])
|
33
|
+
subcommand.run(['set', name, 'on'])
|
34
|
+
subcommand.summary_help(name)
|
35
|
+
puts
|
36
|
+
puts '-' * 20
|
37
|
+
puts subcommand.save_command
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subsubcmd'
|
4
|
+
require_relative '../base/subsubmgr'
|
5
|
+
|
6
|
+
class Trepan::SubSubcommand::SetDebug < Trepan::SubSubcommandMgr
|
7
|
+
unless defined?(HELP)
|
8
|
+
HELP = 'Set internal debugger settings'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set debug)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $0
|
15
|
+
require_relative '../../mock'
|
16
|
+
dbgr = MockDebugger::MockDebugger.new
|
17
|
+
cmds = dbgr.core.processor.commands
|
18
|
+
set_cmd = cmds['set']
|
19
|
+
command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
20
|
+
set_cmd)
|
21
|
+
name = File.basename(__FILE__, '.rb')
|
22
|
+
cmd_args = ['set', name]
|
23
|
+
set_cmd.instance_variable_set('@last_args', cmd_args)
|
24
|
+
# require_relative '../../../lib/trepanning'
|
25
|
+
# Trepan.debug(:set_restart => true)
|
26
|
+
command.run(cmd_args)
|
27
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::SubSubcommand::SetDebugDbgr < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'set debug dbgr [on|off]
|
8
|
+
|
9
|
+
Facilitates debugging the debugger. Global variables $trepan_cmdproc
|
10
|
+
and $trepan_frame are set to the current values of @frame and self
|
11
|
+
when the command processor was entered. '
|
12
|
+
|
13
|
+
MIN_ABBREV = 'db'.size
|
14
|
+
NAME = File.basename(__FILE__, '.rb')
|
15
|
+
PREFIX = %w(set debug dbgr)
|
16
|
+
SHORT_HELP = 'Set debugging debugger'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run(args)
|
20
|
+
super
|
21
|
+
@proc.cmdloop_prehooks.insert_if_new(-1, *@proc.debug_dbgr_hook)
|
22
|
+
@proc.debug_dbgr_hook[1].call
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
if __FILE__ == $0
|
28
|
+
# Demo it.
|
29
|
+
require_relative '../../../mock'
|
30
|
+
name = File.basename(__FILE__, '.rb')
|
31
|
+
|
32
|
+
# FIXME: DRY the below code
|
33
|
+
dbgr, dbg_cmd = MockDebugger::setup('set')
|
34
|
+
debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
|
35
|
+
dbg_cmd)
|
36
|
+
# FIXME: remove the 'join' below
|
37
|
+
cmd_name = Trepan::SubSubcommand::SetDebugDbgr::PREFIX.join('')
|
38
|
+
debugx_cmd = Trepan::SubSubcommand::SetDebugDbgr.new(dbg_cmd.proc,
|
39
|
+
debug_cmd,
|
40
|
+
cmd_name)
|
41
|
+
# require_relative '../.././../lib/trepanning'
|
42
|
+
# dbgr = Trepan.new(:set_restart => true)
|
43
|
+
# dbgr.debugger
|
44
|
+
debugx_cmd.run([name])
|
45
|
+
debugx_cmd.run([name, 'on'])
|
46
|
+
debugx_cmd.run([name, 'off'])
|
47
|
+
puts '-' * 10
|
48
|
+
puts debugx_cmd.save_command
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::SubSubcommand::SetDebugExcept < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'Set to show execution traceback on debugger command exception'
|
8
|
+
MIN_ABBREV = 'sk'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set debug except)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $0
|
15
|
+
# Demo it.
|
16
|
+
require_relative '../../../mock'
|
17
|
+
require_relative '../../../subcmd'
|
18
|
+
name = File.basename(__FILE__, '.rb')
|
19
|
+
|
20
|
+
# FIXME: DRY the below code
|
21
|
+
dbgr, dbg_cmd = MockDebugger::setup('set')
|
22
|
+
debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
|
23
|
+
dbg_cmd)
|
24
|
+
# FIXME: remove the 'join' below
|
25
|
+
cmd_name = Trepan::SubSubcommand::SetDebugExcept::PREFIX.join('')
|
26
|
+
debugx_cmd = Trepan::SubSubcommand::SetDebugExcept.new(dbg_cmd.proc,
|
27
|
+
debug_cmd,
|
28
|
+
cmd_name)
|
29
|
+
# require_relative '../../../../lib/trepan'
|
30
|
+
# dbgr = Trepan.new(:set_restart => true)
|
31
|
+
# dbgr.debugger
|
32
|
+
debugx_cmd.run([name, 'off'])
|
33
|
+
debugx_cmd.run([name])
|
34
|
+
debugx_cmd.run([name, 'on'])
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::SubSubcommand::SetDebugMacro < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = "Set macro debugging"
|
8
|
+
MIN_ABBREV = 'macro'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set debug macro)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $0
|
15
|
+
# Demo it.
|
16
|
+
require_relative '../../../mock'
|
17
|
+
require_relative '../../../subcmd'
|
18
|
+
name = File.basename(__FILE__, '.rb')
|
19
|
+
|
20
|
+
# FIXME: DRY the below code
|
21
|
+
dbgr, set_cmd = MockTrepan::setup('set')
|
22
|
+
debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
|
23
|
+
set_cmd)
|
24
|
+
# FIXME: remove the 'join' below
|
25
|
+
cmd_name = Trepan::SubSubcommand::SetDebugMacro::PREFIX.join('')
|
26
|
+
debugx_cmd = Trepan::SubSubcommand::SetDebugMacro.new(set_cmd.proc,
|
27
|
+
debug_cmd,
|
28
|
+
cmd_name)
|
29
|
+
# require_relative '../../../../lib/trepanning'
|
30
|
+
# dbgr = Trepan.new(:set_restart => true)
|
31
|
+
# dbgr.debugger
|
32
|
+
debugx_cmd.run([name])
|
33
|
+
debugx_cmd.run([name, 'off'])
|
34
|
+
debugx_cmd.run([name, 'on'])
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::SubSubcommand::SetDebugSkip < Trepan::SetBoolSubSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'Set debugging of statement skip logic'
|
8
|
+
MIN_ABBREV = 'sk'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(set debug skip)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $0
|
15
|
+
# Demo it.
|
16
|
+
require_relative '../../../mock'
|
17
|
+
require_relative '../../../subcmd'
|
18
|
+
name = File.basename(__FILE__, '.rb')
|
19
|
+
|
20
|
+
# FIXME: DRY the below code
|
21
|
+
dbgr, dbg_cmd = MockDebugger::setup('set')
|
22
|
+
debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
|
23
|
+
dbg_cmd)
|
24
|
+
# FIXME: remove the 'join' below
|
25
|
+
cmd_name = Trepan::SubSubcommand::SetDebugSkip::PREFIX.join('')
|
26
|
+
debugx_cmd = Trepan::SubSubcommand::SetDebugSkip.new(dbg_cmd.proc,
|
27
|
+
debug_cmd,
|
28
|
+
cmd_name)
|
29
|
+
# require_relative '../../../../lib/trepanning'
|
30
|
+
# dbgr = Trepan.new(:set_restart => true)
|
31
|
+
# dbgr.debugger
|
32
|
+
debugx_cmd.run([name])
|
33
|
+
debugx_cmd.run([name, 'on'])
|
34
|
+
debugx_cmd.run([name, 'off'])
|
35
|
+
end
|