Permalink
Browse files

delete interface now more closely follows rb-trepanning code (and gdb…

… better).

Other sync with rb-trepanning. Undisplay completion of display numbers added.
  • Loading branch information...
rocky committed Oct 15, 2011
1 parent 05a9186 commit 080824fcccbd2bc04fbf118435a77509d50b55e1
Showing with 48 additions and 27 deletions.
  1. +4 −0 app/display.rb
  2. +32 −19 processor/command/delete.rb
  3. +12 −8 processor/command/undisplay.rb
View
@@ -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
@@ -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
@@ -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

0 comments on commit 080824f

Please sign in to comment.