trepanning 0.1.6 → 1.93.32
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/COPYING +57 -0
- data/ChangeLog +585 -736
- data/NEWS +26 -12
- data/README.md +62 -0
- data/Rakefile +15 -9
- data/app/breakpoint.rb +11 -12
- data/app/complete.rb +14 -14
- data/app/core.rb +34 -30
- data/app/default.rb +8 -7
- data/app/markdown.rb +191 -0
- data/app/options.rb +104 -99
- data/app/run.rb +9 -1
- data/app/util.rb +7 -7
- data/bin/trepan +7 -7
- data/interface.rb +0 -4
- data/interface/user.rb +11 -11
- data/io/input.rb +13 -13
- data/lib/trepanning.rb +30 -29
- data/processor.rb +40 -40
- data/processor/command.rb +13 -9
- data/processor/command/alias.rb +21 -15
- data/processor/command/backtrace.rb +27 -19
- data/processor/command/break.rb +24 -21
- data/processor/command/complete.rb +5 -2
- data/processor/command/condition.rb +14 -9
- data/processor/command/debug.rb +8 -8
- data/processor/command/down.rb +6 -6
- data/processor/command/edit.rb +4 -0
- data/processor/command/eval.rb +2 -2
- data/processor/command/exit.rb +12 -9
- data/processor/command/finish.rb +25 -23
- data/processor/command/frame.rb +30 -26
- data/processor/command/help.rb +203 -185
- data/processor/command/help/{command.txt → command.md} +21 -18
- data/processor/command/help/examples.md +20 -0
- data/processor/command/help/filename.md +46 -0
- data/processor/command/help/location.md +34 -0
- data/processor/command/help/suffixes.md +19 -0
- data/processor/command/info.rb +6 -4
- data/processor/command/info_subcmd/breakpoints.rb +13 -13
- data/processor/command/info_subcmd/files.rb +35 -31
- data/processor/command/info_subcmd/frame.rb +82 -33
- data/processor/command/info_subcmd/macro.rb +1 -1
- data/processor/command/info_subcmd/program.rb +8 -5
- data/processor/command/info_subcmd/registers.rb +15 -13
- data/processor/command/kill.rb +23 -17
- data/processor/command/list.rb +63 -56
- data/processor/command/macro.rb +45 -28
- data/processor/command/next.rb +29 -23
- data/processor/command/pp.rb +11 -9
- data/processor/command/pr.rb +10 -8
- data/processor/command/ps.rb +5 -5
- data/processor/command/quit.rb +24 -17
- data/processor/command/raise.rb +6 -6
- data/processor/command/reload.rb +9 -2
- data/processor/command/reload_subcmd/command.rb +4 -4
- data/processor/command/restart.rb +9 -4
- data/processor/command/save.rb +9 -9
- data/processor/command/server.rb +18 -17
- data/processor/command/set.rb +8 -6
- data/processor/command/set_subcmd/confirm.rb +15 -2
- data/processor/command/set_subcmd/different.rb +7 -5
- data/processor/command/set_subcmd/highlight.rb +14 -3
- data/processor/command/set_subcmd/pc.rb +62 -0
- data/processor/command/set_subcmd/sp.rb +8 -2
- data/processor/command/shell.rb +25 -23
- data/processor/command/show.rb +9 -7
- data/processor/command/show_subcmd/confirm.rb +12 -1
- data/processor/command/show_subcmd/highlight.rb +13 -3
- data/processor/command/source.rb +27 -26
- data/processor/command/step.rb +52 -43
- data/processor/command/tbreak.rb +9 -4
- data/processor/command/unalias.rb +9 -7
- data/processor/command/undisplay.rb +11 -7
- data/processor/command/up.rb +18 -13
- data/processor/command/watchg.rb +20 -17
- data/processor/complete.rb +120 -0
- data/processor/default.rb +47 -43
- data/processor/list.rb +23 -6
- data/processor/load_cmds.rb +25 -105
- data/processor/location.rb +104 -96
- data/processor/mock.rb +12 -12
- data/processor/msg.rb +61 -52
- data/processor/validate.rb +36 -27
- data/test/data/fname-with-blank.right +0 -1
- data/test/data/trace-mingw.right +28 -0
- data/test/data/trace.right +0 -2
- data/test/functional/test-raise.rb +3 -0
- data/test/integration/helper.rb +16 -16
- data/test/integration/test-debugger-stop.rb +8 -2
- data/test/integration/test-quit.rb +16 -15
- data/test/integration/test-trace.rb +19 -10
- data/test/unit/cmd-helper.rb +4 -1
- data/test/unit/test-app-complete.rb +3 -1
- data/test/unit/test-app-options.rb +7 -1
- data/test/unit/test-app-run.rb +9 -1
- data/test/unit/test-cmd-alias.rb +1 -1
- data/test/unit/test-cmd-edit.rb +2 -0
- data/test/unit/test-cmd-help.rb +10 -5
- data/test/unit/test-cmd-parse_list_cmd.rb +3 -3
- data/test/unit/test-completion.rb +2 -2
- data/test/unit/test-proc-default.rb +34 -0
- data/trepanning.gemspec +15 -14
- metadata +70 -44
- data/README.textile +0 -50
- data/processor/command/help/examples.txt +0 -16
- data/processor/command/help/filename.txt +0 -40
- data/processor/command/help/location.txt +0 -37
- data/processor/command/help/suffixes.txt +0 -17
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +0 -28
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +0 -47
- data/processor/command/nocache.rb +0 -32
- data/processor/command/parsetree.rb +0 -56
data/app/run.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010-
|
2
|
+
# Copyright (C) 2010-2013 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rbconfig'
|
4
4
|
module Trepanning
|
5
5
|
|
@@ -60,6 +60,14 @@ module Trepanning
|
|
60
60
|
# Do a shell-like path lookup for prog_script and return the results.
|
61
61
|
# If we can't find anything return prog_script.
|
62
62
|
def whence_file(prog_script)
|
63
|
+
if RbConfig::CONFIG['target_os'].start_with?('mingw')
|
64
|
+
if (prog_script =~ /^[a-zA-Z][:]/)
|
65
|
+
start = prog_script[2..2]
|
66
|
+
if [File::ALT_SEPARATOR, File::SEPARATOR].member?(start)
|
67
|
+
return prog_script
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
63
71
|
if prog_script.start_with?(File::SEPARATOR) || prog_script.start_with?('.')
|
64
72
|
# Don't search since this name has path is explicitly absolute or
|
65
73
|
# relative.
|
data/app/util.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
class Trepan
|
4
4
|
module Util
|
5
5
|
|
6
|
-
module_function
|
6
|
+
module_function
|
7
7
|
def safe_repr(str, max, elipsis='... ')
|
8
8
|
if str.is_a?(String) && max > 0 && str.size > max && !str.index("\n")
|
9
9
|
"%s%s%s" % [ str[0...max/2], elipsis, str[str.size-max/2..str.size]]
|
@@ -16,20 +16,20 @@ class Trepan
|
|
16
16
|
# If name is a unique leading prefix of one of the entries of list,
|
17
17
|
# then return that. Otherwise return name.
|
18
18
|
def uniq_abbrev(list, name)
|
19
|
-
candidates = list.select do |try_name|
|
19
|
+
candidates = list.select do |try_name|
|
20
20
|
try_name.start_with?(name)
|
21
21
|
end
|
22
22
|
candidates.size == 1 ? candidates.first : name
|
23
23
|
end
|
24
24
|
|
25
25
|
# extract the "expression" part of a line of source code.
|
26
|
-
#
|
26
|
+
#
|
27
27
|
def extract_expression(text)
|
28
28
|
if text =~ /^\s*(?:if|elsif|unless)\s+/
|
29
|
-
text.gsub!(/^\s*(?:if|elsif|unless)\s+/,'')
|
29
|
+
text.gsub!(/^\s*(?:if|elsif|unless)\s+/,'')
|
30
30
|
text.gsub!(/\s+then\s*$/, '')
|
31
31
|
elsif text =~ /^\s*(?:until|while)\s+/
|
32
|
-
text.gsub!(/^\s*(?:until|while)\s+/,'')
|
32
|
+
text.gsub!(/^\s*(?:until|while)\s+/,'')
|
33
33
|
text.gsub!(/\s+do\s*$/, '')
|
34
34
|
elsif text =~ /^\s*return\s+/
|
35
35
|
# EXPRESION in: return EXPRESSION
|
@@ -54,7 +54,7 @@ class Trepan
|
|
54
54
|
result = yield
|
55
55
|
$VERBOSE = original_verbosity
|
56
56
|
return result
|
57
|
-
end
|
57
|
+
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -68,7 +68,7 @@ if __FILE__ == $0
|
|
68
68
|
puts safe_repr(string.inspect, 17, '')
|
69
69
|
# ------------------------------------
|
70
70
|
# extract_expression
|
71
|
-
['if condition("if")',
|
71
|
+
['if condition("if")',
|
72
72
|
'until until_termination',
|
73
73
|
'return return_value',
|
74
74
|
'nothing_to_be.done'
|
data/bin/trepan
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
# Invoke debugger from the command line.
|
3
|
+
# Invoke debugger from the command line.
|
4
4
|
require 'rbconfig' # For RbConfig.ruby
|
5
5
|
require_relative '../app/run'
|
6
6
|
require_relative '../app/options'
|
@@ -12,12 +12,12 @@ if File.basename(__FILE__) == File.basename($0)
|
|
12
12
|
include Trepanning
|
13
13
|
|
14
14
|
# One way to get local variables is to create a block which is run
|
15
|
-
# once.
|
16
|
-
#
|
15
|
+
# once.
|
16
|
+
#
|
17
17
|
# Note however that since there are constants below, we can't
|
18
18
|
# wrap all of this in a procedure as that would be defining
|
19
19
|
# constants dynamically.
|
20
|
-
1.times do
|
20
|
+
1.times do
|
21
21
|
| ; trepan_path, program_to_debug |
|
22
22
|
# options = DEFAULT_CMDLINE_SETTINGS.merge({}) seems to change up
|
23
23
|
# DEFAULT_CMDLINE_SETTINGS when options[:key] is changed. The
|
@@ -32,7 +32,7 @@ if File.basename(__FILE__) == File.basename($0)
|
|
32
32
|
trepan_path += '.cmd' unless trepan_path =~ /\.cmd$/i
|
33
33
|
end
|
34
34
|
|
35
|
-
# FIXME: do we need to test defined?
|
35
|
+
# FIXME: do we need to test defined?
|
36
36
|
# FIXME: Should (some of) these be instance variables?
|
37
37
|
Trepan::TREPAN_PATH = trepan_path
|
38
38
|
|
@@ -49,12 +49,12 @@ if File.basename(__FILE__) == File.basename($0)
|
|
49
49
|
end
|
50
50
|
|
51
51
|
program_to_debug = (Trepan::PROG_UNRESOLVED_SCRIPT = ARGV.shift).dup
|
52
|
-
program_to_debug = whence_file(Trepan::PROG_UNRESOLVED_SCRIPT) unless
|
52
|
+
program_to_debug = whence_file(Trepan::PROG_UNRESOLVED_SCRIPT) unless
|
53
53
|
File.exist?(Trepan::PROG_UNRESOLVED_SCRIPT)
|
54
54
|
Trepan::PROG_SCRIPT = program_to_debug
|
55
55
|
|
56
56
|
opts = {}
|
57
|
-
%w(cmdfiles highlight initial_dir host nx port post_mortem
|
57
|
+
%w(basename cmdfiles highlight initial_dir host nx port post_mortem
|
58
58
|
readline server traceprint
|
59
59
|
).each do |opt|
|
60
60
|
opts[opt.to_sym] = options[opt.to_sym]
|
data/interface.rb
CHANGED
data/interface/user.rb
CHANGED
@@ -12,12 +12,12 @@ class Trepan::UserInterface < Trepan::Interface
|
|
12
12
|
|
13
13
|
DEFAULT_USER_OPTS = {
|
14
14
|
:readline => true, # Try to use GNU Readline?
|
15
|
-
|
15
|
+
|
16
16
|
# The below are only used if we want and have readline support.
|
17
17
|
# See method Trepan::GNU_readline? below.
|
18
18
|
:histsize => 256, # Use gdb's default setting
|
19
19
|
:file_history => '.trepan_hist', # where history file lives
|
20
|
-
# Note a directory will
|
20
|
+
# Note a directory will
|
21
21
|
# be appended
|
22
22
|
:history_save => true # do we save the history?
|
23
23
|
} unless defined?(DEFAULT_USER_OPTS)
|
@@ -49,14 +49,14 @@ class Trepan::UserInterface < Trepan::Interface
|
|
49
49
|
def confirm(prompt, default)
|
50
50
|
default_str = default ? 'Y/n' : 'N/y'
|
51
51
|
while true do
|
52
|
-
begin
|
52
|
+
begin
|
53
53
|
response = readline('%s (%s) ' % [prompt, default_str])
|
54
54
|
rescue EOFError
|
55
55
|
return default
|
56
56
|
end
|
57
57
|
response = response.strip.downcase
|
58
58
|
|
59
|
-
# We don't catch "Yes, I'm sure" or "NO!", but I leave that
|
59
|
+
# We don't catch "Yes, I'm sure" or "NO!", but I leave that
|
60
60
|
# as an exercise for the reader.
|
61
61
|
break if YES_OR_NO.member?(response)
|
62
62
|
msg "Please answer 'yes' or 'no'. Try again."
|
@@ -67,7 +67,7 @@ class Trepan::UserInterface < Trepan::Interface
|
|
67
67
|
# Read a saved Readline history file into Readline. The history
|
68
68
|
# file will be created if it doesn't already exist.
|
69
69
|
# Much of this code follows what's done in ruby-debug.
|
70
|
-
def read_history
|
70
|
+
def read_history
|
71
71
|
unless @histfile
|
72
72
|
dirname = ENV['HOME'] || ENV['HOMEPATH'] || File.expand_path('~')
|
73
73
|
@histfile = File.join(dirname, @opts[:file_history])
|
@@ -75,8 +75,8 @@ class Trepan::UserInterface < Trepan::Interface
|
|
75
75
|
@histsize ||= (ENV['HISTSIZE'] ? ENV['HISTSIZE'].to_i : @opts[:histsize])
|
76
76
|
Readline.completion_proc = @opts[:complete]
|
77
77
|
if File.exists?(@histfile)
|
78
|
-
lines = IO::readlines(@histfile).last(@histsize).collect do
|
79
|
-
|line| line.chomp
|
78
|
+
lines = IO::readlines(@histfile).last(@histsize).collect do
|
79
|
+
|line| line.chomp
|
80
80
|
end
|
81
81
|
Readline::HISTORY.push(*lines)
|
82
82
|
@history_io = File.new(@histfile, "a")
|
@@ -87,7 +87,7 @@ class Trepan::UserInterface < Trepan::Interface
|
|
87
87
|
@history_save = @opts[:history_save]
|
88
88
|
end
|
89
89
|
|
90
|
-
def save_history
|
90
|
+
def save_history
|
91
91
|
if @histfile
|
92
92
|
lines = Readline::HISTORY.to_a
|
93
93
|
lines = lines[-@histsize, @histsize] if lines.size > @histsize
|
@@ -95,7 +95,7 @@ class Trepan::UserInterface < Trepan::Interface
|
|
95
95
|
open(@histfile, 'w') do |file|
|
96
96
|
Readline::HISTORY.to_a.last(@histsize).each do |line|
|
97
97
|
file.puts line
|
98
|
-
end
|
98
|
+
end
|
99
99
|
end if defined?(@history_save) and @history_save
|
100
100
|
rescue
|
101
101
|
end
|
@@ -105,7 +105,7 @@ class Trepan::UserInterface < Trepan::Interface
|
|
105
105
|
def finalize(last_wishes=nil)
|
106
106
|
# ?? print gdb-style exit annotation if annotate = 2?
|
107
107
|
if Trepan::GNU_readline? && @history_save
|
108
|
-
save_history
|
108
|
+
save_history
|
109
109
|
end
|
110
110
|
super
|
111
111
|
end
|
@@ -113,7 +113,7 @@ class Trepan::UserInterface < Trepan::Interface
|
|
113
113
|
def interactive? ; @input.interactive? end
|
114
114
|
|
115
115
|
def read_command(prompt='')
|
116
|
-
readline(prompt)
|
116
|
+
readline(prompt)
|
117
117
|
end
|
118
118
|
|
119
119
|
def readline(prompt='')
|
data/io/input.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# Debugger user/command-oriented input possibly attached to IO-style
|
5
5
|
# input or GNU Readline.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
|
8
8
|
require_relative '../io'
|
9
9
|
|
@@ -28,20 +28,20 @@ class Trepan
|
|
28
28
|
def closed?; @input.closed? end
|
29
29
|
def eof?; @eof end
|
30
30
|
|
31
|
-
def interactive?
|
31
|
+
def interactive?
|
32
32
|
@input.respond_to?(:isatty) && @input.isatty
|
33
33
|
end
|
34
|
-
# Read a line of input. EOFError will be raised on EOF.
|
34
|
+
# Read a line of input. EOFError will be raised on EOF.
|
35
35
|
def readline(prompt='')
|
36
36
|
raise EOFError if eof?
|
37
|
-
begin
|
37
|
+
begin
|
38
38
|
if @line_edit && @use_readline
|
39
39
|
line = Readline.readline(prompt, true)
|
40
40
|
else
|
41
|
-
# Prompt should be empty and should have been
|
41
|
+
# Prompt should be empty and should have been
|
42
42
|
# handled by caller.
|
43
43
|
unless prompt.empty?
|
44
|
-
raise RuntimeError,
|
44
|
+
raise RuntimeError,
|
45
45
|
"Internal error: prompt '#{prompt}' should have been handled by caller" unless prompt.empty?
|
46
46
|
end
|
47
47
|
line = @input.gets
|
@@ -58,28 +58,28 @@ class Trepan
|
|
58
58
|
raise EOFError if eof?
|
59
59
|
return line
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
class << self
|
63
|
-
# Use this to set where to read from.
|
63
|
+
# Use this to set where to read from.
|
64
64
|
#
|
65
65
|
# Set opts[:line_edit] if you want this input to interact with
|
66
66
|
# GNU-like readline library. By default, we will assume to try
|
67
|
-
# using readline.
|
67
|
+
# using readline.
|
68
68
|
def open(inp=nil, opts={})
|
69
69
|
inp ||= STDIN
|
70
70
|
inp = File.new(inp, 'r') if inp.is_a?(String)
|
71
|
-
opts[:line_edit] = @line_edit =
|
71
|
+
opts[:line_edit] = @line_edit =
|
72
72
|
inp.respond_to?(:isatty) && inp.isatty && Trepan::GNU_readline?
|
73
73
|
self.new(inp, opts)
|
74
74
|
end
|
75
75
|
|
76
76
|
def finalize
|
77
77
|
if defined?(RbReadline) && !@@readline_finalized
|
78
|
-
begin
|
78
|
+
begin
|
79
79
|
RbReadline.rl_cleanup_after_signal()
|
80
80
|
rescue
|
81
81
|
end
|
82
|
-
begin
|
82
|
+
begin
|
83
83
|
RbReadline.rl_deprep_terminal()
|
84
84
|
rescue
|
85
85
|
end
|
@@ -101,7 +101,7 @@ def Trepan::GNU_readline?
|
|
101
101
|
return false
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
# Demo
|
106
106
|
if __FILE__ == $0
|
107
107
|
puts 'Have GNU is: %s' % Trepan::GNU_readline?
|
data/lib/trepanning.rb
CHANGED
@@ -18,10 +18,10 @@ require_relative '../interface/server' # server interface (remote debugging)
|
|
18
18
|
# "filename" parameter when the instruction sequence was
|
19
19
|
# generated. Each value is an array of instruction sequences that
|
20
20
|
# share that name.
|
21
|
-
SCRIPT_ISEQS__ = {} unless
|
22
|
-
|
23
|
-
ISEQS__ = {} unless
|
24
|
-
|
21
|
+
SCRIPT_ISEQS__ = {} unless
|
22
|
+
defined?(SCRIPT_ISEQS__) && SCRIPT_ISEQS__.is_a?(Hash)
|
23
|
+
ISEQS__ = {} unless
|
24
|
+
defined?(ISEQS__) && ISEQS__.is_a?(Hash)
|
25
25
|
|
26
26
|
class Trepan
|
27
27
|
|
@@ -40,7 +40,7 @@ class Trepan
|
|
40
40
|
def initialize(settings={})
|
41
41
|
|
42
42
|
# FIXME: Tracing through intialization code is slow. Need to figure
|
43
|
-
# out better ways to do this.
|
43
|
+
# out better ways to do this.
|
44
44
|
th = Thread.current
|
45
45
|
th.exec_event_tracing = true
|
46
46
|
|
@@ -50,7 +50,7 @@ class Trepan
|
|
50
50
|
|
51
51
|
@completion_proc = method(:completion_method)
|
52
52
|
|
53
|
-
@intf =
|
53
|
+
@intf =
|
54
54
|
if @settings[:server]
|
55
55
|
@completion_proc = nil
|
56
56
|
opts = Trepan::ServerInterface::DEFAULT_INIT_CONNECTION_OPTS.dup
|
@@ -79,9 +79,10 @@ class Trepan
|
|
79
79
|
@settings[:core_opts][:cmdproc_opts] ||= {}
|
80
80
|
@settings[:core_opts][:cmdproc_opts][:highlight] ||= settings[:highlight]
|
81
81
|
@settings[:core_opts][:cmdproc_opts][:traceprint] = settings[:traceprint]
|
82
|
+
@settings[:core_opts][:cmdproc_opts][:basename] = settings[:basename]
|
82
83
|
|
83
84
|
@core = Core.new(self, @settings[:core_opts])
|
84
|
-
|
85
|
+
|
85
86
|
if @settings[:initial_dir]
|
86
87
|
Dir.chdir(@settings[:initial_dir])
|
87
88
|
else
|
@@ -92,11 +93,11 @@ class Trepan
|
|
92
93
|
|
93
94
|
unless @settings[:client]
|
94
95
|
@trace_filter = Trace::Filter.new
|
95
|
-
%w(debugger start stop).each do |m|
|
96
|
+
%w(debugger start stop).each do |m|
|
96
97
|
@trace_filter << self.method(m.to_sym)
|
97
98
|
end
|
98
|
-
%w(debugger event_processor trace_var_processor).each do
|
99
|
-
|m|
|
99
|
+
%w(debugger event_processor trace_var_processor).each do
|
100
|
+
|m|
|
100
101
|
@trace_filter << @core.method(m)
|
101
102
|
end
|
102
103
|
@trace_filter << @trace_filter.method(:add_trace_func)
|
@@ -107,9 +108,9 @@ class Trepan
|
|
107
108
|
# Run user debugger command startup files.
|
108
109
|
add_startup_files unless @settings[:nx]
|
109
110
|
|
110
|
-
at_exit do
|
111
|
+
at_exit do
|
111
112
|
clear_trace_func
|
112
|
-
@intf[-1].close
|
113
|
+
@intf[-1].close
|
113
114
|
end
|
114
115
|
th.exec_event_tracing = false
|
115
116
|
end
|
@@ -118,10 +119,10 @@ class Trepan
|
|
118
119
|
# such as called from GNU Readline with <TAB>.
|
119
120
|
def completion_method(last_token, leading=Readline.line_buffer)
|
120
121
|
completion = @core.processor.complete(leading, last_token)
|
121
|
-
if 1 == completion.size
|
122
|
+
if 1 == completion.size
|
122
123
|
completion_token = completion[0]
|
123
124
|
if last_token.end_with?(' ')
|
124
|
-
if last_token.rstrip == completion_token
|
125
|
+
if last_token.rstrip == completion_token
|
125
126
|
# There is nothing more to complete
|
126
127
|
[]
|
127
128
|
else
|
@@ -137,7 +138,7 @@ class Trepan
|
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
140
|
-
# To call from inside a Ruby program, there is one-time setup that
|
141
|
+
# To call from inside a Ruby program, there is one-time setup that
|
141
142
|
# needs to be done first:
|
142
143
|
# require 'trepanning'
|
143
144
|
# mydbg = Trepan.new()
|
@@ -151,9 +152,9 @@ class Trepan
|
|
151
152
|
# mydbg.debugger(:immediate=>true) # enter debugger here
|
152
153
|
# ... work, work, work
|
153
154
|
#
|
154
|
-
# However to enter the debugger on the next event after the
|
155
|
+
# However to enter the debugger on the next event after the
|
155
156
|
# debugger() call:
|
156
|
-
#
|
157
|
+
#
|
157
158
|
# ... work, work, work
|
158
159
|
# mydbg.debugger # Don't stop here...
|
159
160
|
# work # but stop here.
|
@@ -170,7 +171,7 @@ class Trepan
|
|
170
171
|
#
|
171
172
|
# :hide_stack - boolean. If true, omit stack frames before the
|
172
173
|
# debugger call
|
173
|
-
#
|
174
|
+
#
|
174
175
|
# :debugme - boolean. Allow tracing into this routine. You
|
175
176
|
# generally won't want this. It slows things
|
176
177
|
# down horribly.
|
@@ -178,7 +179,7 @@ class Trepan
|
|
178
179
|
def debugger(opts={}, &block)
|
179
180
|
# FIXME: one option we may want to pass is the initial trace filter.
|
180
181
|
if opts[:hide_stack]
|
181
|
-
@core.processor.hidelevels[Thread.current] =
|
182
|
+
@core.processor.hidelevels[Thread.current] =
|
182
183
|
RubyVM::Frame.current.stack_size
|
183
184
|
end
|
184
185
|
# unless defined?(PROG_UNRESOLVED_SCRIPT)
|
@@ -195,9 +196,9 @@ class Trepan
|
|
195
196
|
# Stop immediately after this method returns. But if opts[:debugme]
|
196
197
|
# is set, we can stop in this method.
|
197
198
|
RubyVM::Frame::current.trace_off = true unless opts[:debugme]
|
198
|
-
@trace_filter.set_trace_func(@core.event_proc)
|
199
|
+
@trace_filter.set_trace_func(@core.event_proc)
|
199
200
|
Trace.event_masks[0] |= @core.step_events
|
200
|
-
@core.debugger(1)
|
201
|
+
@core.debugger(1)
|
201
202
|
else
|
202
203
|
RubyVM::Frame::current.trace_off = true unless opts[:debugme]
|
203
204
|
|
@@ -213,7 +214,7 @@ class Trepan
|
|
213
214
|
def start
|
214
215
|
@trace_filter.add_trace_func(@core.event_proc)
|
215
216
|
end
|
216
|
-
|
217
|
+
|
217
218
|
# Remove all of our trace events
|
218
219
|
def stop(opts={})
|
219
220
|
# FIXME: should do something in the middle when
|
@@ -249,7 +250,7 @@ class Trepan
|
|
249
250
|
|
250
251
|
def process_cmdfile_setting(settings)
|
251
252
|
settings[:cmdfiles].each do |item|
|
252
|
-
cmdfile, opts =
|
253
|
+
cmdfile, opts =
|
253
254
|
if item.kind_of?(Array)
|
254
255
|
item
|
255
256
|
else
|
@@ -262,10 +263,10 @@ class Trepan
|
|
262
263
|
# As a simplification for creating a debugger object, and then
|
263
264
|
# calling using the object to invoke the debugger, we allow this
|
264
265
|
# two-step process in one step. That is, instead of
|
265
|
-
#
|
266
|
+
#
|
266
267
|
# require 'trepanning'
|
267
268
|
# mydbg = Trepan.new()
|
268
|
-
# ...
|
269
|
+
# ...
|
269
270
|
# mydbg.debugger
|
270
271
|
|
271
272
|
# You can run:
|
@@ -275,7 +276,7 @@ class Trepan
|
|
275
276
|
#
|
276
277
|
# See debugger for options that can be passed. By default :hide_stack is
|
277
278
|
# set.
|
278
|
-
#
|
279
|
+
#
|
279
280
|
# Likewise for mydbg.debugger{ ... }
|
280
281
|
|
281
282
|
def self.debug(opts={}, &block)
|
@@ -289,16 +290,16 @@ class Trepan
|
|
289
290
|
end
|
290
291
|
|
291
292
|
def self.debug_str(string, opts = DEFAULT_DEBUG_STR_SETTINGS)
|
292
|
-
$trepanning = Trepan.new(opts) unless
|
293
|
+
$trepanning = Trepan.new(opts) unless
|
293
294
|
$trepanning && $trepanning.is_a?(Trepan)
|
294
295
|
$trepanning.core.processor.settings[:different] = false
|
295
|
-
# Perhaps we should do a remap file to string right here?
|
296
|
+
# Perhaps we should do a remap file to string right here?
|
296
297
|
$trepanning.debugger(opts) { eval(string) }
|
297
298
|
end
|
298
299
|
end
|
299
300
|
|
300
301
|
module Kernel
|
301
|
-
# Same as Trepan.debug.
|
302
|
+
# Same as Trepan.debug.
|
302
303
|
# FIXME figure out a way to remove duplication.
|
303
304
|
def debugger(opts={}, &block)
|
304
305
|
opts = {:hide_stack => false}.merge(opts)
|