From 63baaf9c821c871909d39cc4c1a305f681d79b12 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 16 May 2015 13:18:34 -0600 Subject: [PATCH] allow breakpoint deletion from source window --- gui/bpcache.py | 6 ++++++ gui/source.py | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gui/bpcache.py b/gui/bpcache.py index e1fb02a..4af6c6d 100644 --- a/gui/bpcache.py +++ b/gui/bpcache.py @@ -50,6 +50,12 @@ def _breakpoint_deleted(bp): if len(_breakpoint_source_map[entry]) == 0: gui.events.location_changed.post(entry, False) +def any_breakpoint_at(filename, lineno): + entry = (filename, lineno) + if entry not in _breakpoint_source_map: + return False + return len(_breakpoint_source_map[entry]) > 0 + if not hasattr(gdb.events, 'breakpoint_created'): gui.adapt.notify_bug(15620) else: diff --git a/gui/source.py b/gui/source.py index 7a488ee..848c0a3 100644 --- a/gui/source.py +++ b/gui/source.py @@ -313,8 +313,12 @@ class SourceWindow(gui.updatewindow.UpdateWindow): return if event.button.get_button()[1] != 1: return - fun = Invoker("break %s:%d" % (self.view.get_buffer().filename, - textiter.get_line() + 1)) + filename = self.view.get_buffer().filename + line = textiter.get_line() + 1 + if gui.bpcache.any_breakpoint_at(filename, line): + fun = Invoker("clear %s:%d" % (filename,line)) + else: + fun = Invoker("break %s:%d" % (filename, line)) fun() def _do_scroll(self, buff, srcline):