diff --git a/trepan/lib/breakpoint.py b/trepan/lib/breakpoint.py index 0337b20b..9c4006c0 100644 --- a/trepan/lib/breakpoint.py +++ b/trepan/lib/breakpoint.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2015 Rocky Bernstein +# Copyright (C) 2015, 2017 Rocky Bernstein """Breakpoints as used in a debugger. This code is a rewrite of the stock python bdb.Breakpoint""" @@ -68,14 +68,16 @@ def add_breakpoint(self, filename, lineno, temporary=False, condition=None, return brkpt def delete_all_breakpoints(self): - count = 0 + bp_list = [] for bp in self.bpbynumber: - count += 1 - if bp: self.delete_breakpoint(bp) - if 0 == count: + if bp: + bp_list.append(str(bp.number)) + self.delete_breakpoint(bp) + pass + if not bp_list: return 'There are no breakpoints' else: - return '%d breakpoints deleted' % count + return 'Deleted breakpoints %s' % ', '.join(bp_list) return def delete_breakpoint(self, bp): @@ -98,6 +100,23 @@ def delete_breakpoint_by_number(self, bpnum): self.delete_breakpoint(bp) return (True, '') + def en_disable_all_breakpoints(self, do_enable=True): + "Enable or disable all breakpoints." + bp_list = [bp for bp in self.bpbynumber if bp] + bp_nums = [] + if do_enable: + endis = 'en' + else: + endis = 'dis' + pass + if not bp_list: + return "No breakpoints to %sable" % endis + for bp in bp_list: + bp.enabled = do_enable + bp_nums.append(str(bp.number)) + pass + return ("Breakpoints %sabled: %s" % (endis, ", ".join(bp_nums))) + def en_disable_breakpoint_by_number(self, bpnum, do_enable=True): "Enable or disable a breakpoint given its breakpoint number." success, msg, bp = self.get_breakpoint(bpnum) diff --git a/trepan/processor/command/delete.py b/trepan/processor/command/delete.py index e0c9b581..484d4e73 100644 --- a/trepan/processor/command/delete.py +++ b/trepan/processor/command/delete.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2009, 2013, 2015 Rocky Bernstein +# Copyright (C) 2009, 2013, 2015, 2017 Rocky Bernstein # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ class DeleteCommand(Mbase_cmd.DebuggerCommand): `clear` """ category = 'breakpoints' + aliases = ('delete!',) min_args = 0 max_args = None name = os.path.basename(__file__).split('.')[0] @@ -45,8 +46,13 @@ class DeleteCommand(Mbase_cmd.DebuggerCommand): def run(self, args): if len(args) <= 1: - if self.confirm('Delete all breakpoints', False): - self.core.bpmgr.delete_all_breakpoints() + if '!' != args[0][-1]: + confirmed = self.confirm('Delete all breakpoints', False) + else: + confirmed = True + + if confirmed: + self.msg(self.core.bpmgr.delete_all_breakpoints()) return for arg in args[1:]: diff --git a/trepan/processor/command/disable.py b/trepan/processor/command/disable.py index 8f337455..bc75f5b1 100644 --- a/trepan/processor/command/disable.py +++ b/trepan/processor/command/disable.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2009, 2013-2015 Rocky Bernstein +# Copyright (C) 2009, 2013-2015, 2017 Rocky Bernstein # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ class DisableCommand(Mbase_cmd.DebuggerCommand): """**disable** *bpnumber* [*bpnumber* ...] Disables the breakpoints given as a space separated list of breakpoint -numbers. See also `info break` to get a list. +numbers. To disable all breakpoints, give no argument. See also `info break` to get a list. See also: --------- @@ -42,7 +42,7 @@ class DisableCommand(Mbase_cmd.DebuggerCommand): def run(self, args): if len(args) == 1: - self.errmsg('No breakpoint number given.') + self.msg(self.core.bpmgr.en_disable_all_breakpoints(do_enable=False)) return # if args[1] == 'display': # self.display_enable(args[2:], 0) diff --git a/trepan/processor/command/enable.py b/trepan/processor/command/enable.py index df25a4ac..191cd111 100644 --- a/trepan/processor/command/enable.py +++ b/trepan/processor/command/enable.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2009, 2013, 2015 Rocky Bernstein +# Copyright (C) 2009, 2013, 2015, 2017 Rocky Bernstein # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ class EnableCommand(Mbase_cmd.DebuggerCommand): """**enable** *bpnumber* [*bpnumber* ...] Enables the breakpoints given as a space separated list of breakpoint -numbers. See also `info break` to get a list. +numbers. To enable all breakpoints, give no argument. See also `info break` to get a list. See also: --------- @@ -46,14 +46,14 @@ class EnableCommand(Mbase_cmd.DebuggerCommand): def run(self, args): if len(args) == 1: - self.errmsg('No breakpoint number given.') + self.msg(self.core.bpmgr.en_disable_all_breakpoints(do_enable=True)) return # if args[1] == 'display': # self.display_enable(args[2:], 0) # return for i in args[1:]: success, msg = \ - self.core.bpmgr.en_disable_breakpoint_by_number(i, True) + self.core.bpmgr.en_disable_breakpoint_by_number(i, do_enable=True) if not success: self.errmsg(msg) else: