Skip to content

Commit

Permalink
delete interface now more closely follows rb-trepanning code (and gdb…
Browse files Browse the repository at this point in the history
… better).

Other sync with rb-trepanning. Undisplay completion of display numbers added.
  • Loading branch information
rocky committed Oct 15, 2011
1 parent 05a9186 commit 080824f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
4 changes: 4 additions & 0 deletions app/display.rb
Expand Up @@ -95,6 +95,10 @@ def max
@list.map{|disp| disp.number}.max
end

def nums
@list.map{|disp| disp.number}
end

def size
@list.size
end
Expand Down
51 changes: 32 additions & 19 deletions processor/command/delete.rb
Expand Up @@ -3,28 +3,41 @@
require_relative '../command'

class Trepan::Command::DeleteBreakpontCommand < Trepan::Command
CATEGORY = 'breakpoints'
NAME = File.basename(__FILE__, '.rb')
SHORT_HELP = 'Delete a breakpoint'
HELP = <<-HELP
Specify the breakpoint by number, use 'info break' to see the numbers
HELP

def run(args)
if args.size != 2
errmsg 'Please specify which breakpoint by number'
return
end
unless defined?(HELP)
NAME = File.basename(__FILE__, '.rb')
HELP = <<-HELP
#{NAME} [bpnumber [bpnumber...]]
Delete some breakpoints.
Arguments are breakpoint numbers with spaces in between. To delete
all breakpoints, give no argument. those breakpoints. Without
argument, clear all breaks (but first ask confirmation).
begin
i = Integer(args[1])
rescue ArgumentError
errmsg "'#{args}' is not a number"
return
See also the "clear" command which clears breakpoints by line/file
number.
HELP

CATEGORY = 'breakpoints'
SHORT_HELP = 'Delete some breakpoints'
end

def run(args)
if args.size == 1
if confirm('Delete all breakpoints?', false)
@proc.brkpts.reset
return
end
end

if @proc.delete_breakpoint_by_number(i)
msg('Deleted breakpoint %d.' % i)
first = args.shift
args.each do |num_str|
opts = {:msg_on_error => '%s must be a number' % num_str}
i = @proc.get_an_int(num_str, opts)
if i
success = @proc.delete_breakpoint_by_number(num_str.to_i, false) if i
msg('Deleted breakpoint %d.' % i) if success
end
end
end
end
Expand Down
20 changes: 12 additions & 8 deletions processor/command/undisplay.rb
Expand Up @@ -9,37 +9,41 @@ class Trepan::Command::UndisplayCommand < Trepan::Command
unless defined?(HELP)
NAME = File.basename(__FILE__, '.rb')
HELP = <<EOH
undisplay DISPLAY_NUMBER ...
#{NAME} DISPLAY_NUMBER ...
Cancel some expressions to be displayed when program stops.
Arguments are the code numbers of the expressions to stop displaying.
No argument means cancel all automatic-display expressions.
"delete display" has the same effect as this command.
Do "info display" to see current list of code numbers.
Use "info display" to see current list of display numbers.
EOH

ALIASES = %w(und)
CATEGORY = 'data'
NEED_STACK = false
SHORT_HELP = 'Cancel some expressions to be displayed when program stops'
end

def complete(prefix)
@proc.displays.nums.map{|disp| disp.to_s}
end

def run(args)

if args.size == 1
@proc.displays.clear
return
if confirm('Delete all displays?', false)
@proc.displays.clear
return
end
end
opts = {}
args[1..-1].each do |arg|
opts[:msg_on_error] = '%s must be a display number' % arg
opts = {:msg_on_error => '%s must be a display number' % arg}
i = @proc.get_an_int(arg, opts)
if i
unless @proc.displays.delete_index(i)
errmsg("no display number %d." % i)
errmsg("No display number %d." % i)
return
end
end
return false
end
end
end
Expand Down

0 comments on commit 080824f

Please sign in to comment.