Permalink
Browse files

Merge branch 'master' of github.com:rocky/rb-trepanning

  • Loading branch information...
rocky committed Sep 5, 2011
2 parents 75eef6a + fb4fcbf commit bdacc6dc5c04a547958c2072554f4484e3537094
View
@@ -2,8 +2,6 @@
# The main "driver" class for a command processor. Other parts of the
# command class and debugger command objects are pulled in from here.
require 'set'
%w(default breakpoint display eventbuf eval load_cmds location frame hook msg
running validate).each do
|mod_str|
@@ -3,7 +3,7 @@
require_relative '../command'
class Trepan::Command::DisplayCommand < Trepan::Command
unless defined?(HELP)
NAME = File.basename(__FILE__, '.rb')
HELP = <<-HELP
@@ -24,39 +24,44 @@ class Trepan::Command::DisplayCommand < Trepan::Command
requests previously made.
HELP
CATEGORY = 'data'
NEED_STACK = false
SHORT_HELP = 'Display expressions when entering debugger'
end
def run(args)
CATEGORY = 'data'
NEED_STACK = false
SHORT_HELP = 'Display expressions when entering debugger'
end
if args.size == 1
# Display anything active
@proc.run_eval_display
else
if %w(/c /x /o /f /s).member?(args[1])
if 2 == args.size
errmsg("Expecting an expression after the format")
return
end
format = args[1]
expr = args[2..-1].join(' ')
else
format = nil
expr = args[1..-1].join(' ')
end
def save_command
val = settings[subcmd_setting_key] ? 'on' : 'off'
["#{subcmd_prefix_string} #{val}"]
end
dp = @proc.displays.add(@proc.frame, expr, format)
unless dp
errmsg('Error evaluating "%s" in the current frame' % expr)
def run(args)
if args.size == 1
# Display anything active
@proc.run_eval_display
else
if %w(/c /x /o /f /s).member?(args[1])
if 2 == args.size
errmsg("Expecting an expression after the format")
return
end
msg(dp.to_s(@proc.frame))
@proc.cmdloop_prehooks.insert_if_new(5, *@proc.display_hook)
format = args[1]
expr = args[2..-1].join(' ')
else
format = nil
expr = args[1..-1].join(' ')
end
dp = @proc.displays.add(@proc.frame, expr, format)
unless dp
errmsg('Error evaluating "%s" in the current frame' % expr)
return
end
msg(dp.to_s(@proc.frame))
@proc.cmdloop_prehooks.insert_if_new(5, *@proc.display_hook)
end
end
end
if __FILE__ == $0
# Demo it.
@@ -74,10 +74,10 @@ def list_categories
Type "help aliases" for a list of current aliases.
Type "help macros" for a list of current macros.
Type "help *" for the list of all commands, macros and aliases.
Type "help all" for the list of all commands.
Type "help all" for a brief description of all commands.
Type "help REGEXP" for the list of commands matching /^#{REGEXP}/.
Type "help CLASS *" for the list of all commands in class CLASS.
Type "help" followed by command name for full documentation.
Type "help" followed by a command name for full documentation.
'
msg(final_msg)
end
@@ -100,6 +100,7 @@ def run(args) # :nodoc
elsif cmd_name =~ /^all$/i
CATEGORIES.sort.each do |category|
show_category(category[0], [])
msg('')
end
elsif CATEGORIES.member?(cmd_name)
show_category(args[1], args[2..-1])
@@ -157,9 +158,7 @@ def show_category(category, args)
return
end
msg('')
section "Command class: %s" % category
msg('')
@proc.commands.keys.sort.each do |name|
next if category != @proc.commands[name].category
msg("%-13s -- %s" % [name, @proc.commands[name].short_help])
@@ -4,6 +4,7 @@
require 'columnize'
require_relative '../base/subcmd'
require_relative '../../../app/run'
require_relative '../../../app/util'
class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
Trepan::Util::suppress_warnings {
@@ -52,9 +53,10 @@ class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
include Trepanning
def file_list
(LineCache.class_variable_get('@@file_cache').keys +
(LineCache.cached_files +
LineCache.class_variable_get('@@file2file_remap').keys).uniq
end
def complete(prefix)
completions = ['.'] + file_list
Trepan::Complete.complete_token(completions, prefix)
@@ -60,7 +60,6 @@ def run(args)
if __FILE__ == $0
# Demo it.
require_relative '../../mock'
dbgr, cmd = MockDebugger::setup('info')
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFrame, false)
cmd.run(cmd.prefix)
end
@@ -2,7 +2,7 @@
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
require_relative '../base/subcmd'
class Trepan::Subcommand::ShowAlias < Trepan::Subcommand
class Trepan::Subcommand::ShowAliases < Trepan::Subcommand
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
unless defined?(HELP)
HELP = <<-EOH
@@ -31,7 +31,7 @@ def run(args)
elsif @proc.aliases.empty?
msg "No aliases defined."
else
section "List of aliases names currently defined:"
section "List of alias names currently defined:"
msg columnize_commands(@proc.aliases.keys.sort)
end
end
@@ -4,13 +4,13 @@
class Trepan::Command::UnaliasCommand < Trepan::Command
unless defined?(HELP)
HELP =
"unalias COMMAND
HELP = <<-HELP
unalias ALIAS
Remove alias for COMMAND
Remove alias ALIAS
See also 'alias'.
"
HELP
CATEGORY = 'support'
MIN_ARGS = 1
View
@@ -92,7 +92,7 @@ def sub_setup(sub_class, run=true)
dbgr, cmd = setup(sub_name[0], false)
cmd.proc.frame_setup(RubyVM::ThreadFrame::current.prev)
cmd.proc.event = 'debugger-call'
sub_cmd = sub_class.new(cmd.proc, cmd)
sub_cmd = sub_class.new(cmd)
sub_cmd.summary_help(sub_cmd)
puts
sub_cmd.run([cmd.name]) if run

0 comments on commit bdacc6d

Please sign in to comment.