mirror of
https://github.com/tromey/gdb-gui.git
synced 2025-12-16 07:10:04 +01:00
add frame support
if you have a gdb that can wrap commands (not yet upstream) then up/down/frame commands will update the source window when a selected-frame event is available, we can change the code to use that instead
This commit is contained in:
@@ -19,6 +19,7 @@ import gui.source
|
||||
import gui.logwindow
|
||||
import gui.toplevel
|
||||
import gui.dprintf
|
||||
import gui.events
|
||||
import re
|
||||
|
||||
class GuiCommand(gdb.Command):
|
||||
@@ -153,3 +154,42 @@ GuiOutputCommand()
|
||||
GuiPrintfCommand()
|
||||
InfoWindowsCommand()
|
||||
DeleteWindowsCommand()
|
||||
|
||||
_can_override = False
|
||||
|
||||
# A temporary test to see if you have a gdb that supports this.
|
||||
class TestCommand(gdb.Command):
|
||||
"""A temporary test command created for the GUI.
|
||||
This does nothing, the GUI startup code uses it to see if
|
||||
your copy of gdb has some command-overriding support."""
|
||||
|
||||
def __init__(self, set_it):
|
||||
super(TestCommand, self).__init__('maint gui-test', gdb.COMMAND_DATA)
|
||||
self.set_it = set_it
|
||||
|
||||
def invoke(self, arg, from_tty):
|
||||
if self.set_it:
|
||||
global _can_override
|
||||
_can_override = True
|
||||
else:
|
||||
try:
|
||||
super(TestCommand, self).invoke(arg, from_tty)
|
||||
except:
|
||||
pass
|
||||
|
||||
TestCommand(True)
|
||||
TestCommand(False).invoke('', 0)
|
||||
|
||||
if _can_override:
|
||||
class Overrider(gdb.Command):
|
||||
def __init__(self, name, event):
|
||||
super(Overrider, self).__init__(name, gdb.COMMAND_DATA)
|
||||
self.event = event
|
||||
|
||||
def invoke(self, arg, from_tty):
|
||||
super(Overrider, self).invoke(arg, from_tty)
|
||||
self.event.post()
|
||||
|
||||
Overrider('up', gui.events.frame_changed)
|
||||
Overrider('down', gui.events.frame_changed)
|
||||
Overrider('frame', gui.events.frame_changed)
|
||||
|
||||
32
gui/events.py
Normal file
32
gui/events.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2013 Tom Tromey <tom@trolley.com>
|
||||
|
||||
# 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
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import gdb
|
||||
|
||||
class _Event(object):
|
||||
def __init__(self):
|
||||
self.funcs = []
|
||||
|
||||
def connect(self, callback):
|
||||
self.funcs.append(callback)
|
||||
|
||||
def disconnect(self, callback):
|
||||
self.funcs.remove(callback)
|
||||
|
||||
def post(self):
|
||||
for fun in self.funcs:
|
||||
fun()
|
||||
|
||||
frame_changed = _Event()
|
||||
@@ -20,6 +20,7 @@ from gui.invoker import Invoker
|
||||
from gui.toplevel import Toplevel
|
||||
import gui.startup
|
||||
import gui.toplevel
|
||||
import gui.events
|
||||
|
||||
from gi.repository import Gtk, GtkSource, GObject, Gdk
|
||||
|
||||
@@ -83,7 +84,7 @@ class LRUHandler:
|
||||
# These functions must run in the gdb thread.
|
||||
#
|
||||
|
||||
def on_event(self, event):
|
||||
def on_event(self, *args):
|
||||
(frame, filename, lineno) = get_current_location()
|
||||
if filename is not None:
|
||||
gui.startup.send_to_gtk(lambda: self.show_source(frame,
|
||||
@@ -95,9 +96,11 @@ class LRUHandler:
|
||||
# ... and thread-changed
|
||||
# really just pre-prompt would be good enough
|
||||
gdb.events.stop.connect(self.on_event)
|
||||
gui.events.frame_changed.connect(self.on_event)
|
||||
|
||||
def _disconnect_events(self):
|
||||
gdb.events.stop.disconnect(self.on_event)
|
||||
gui.event.frame_changed.disconnect(self.on_event)
|
||||
|
||||
#
|
||||
# These functions must run in the Gtk thread.
|
||||
|
||||
Reference in New Issue
Block a user