mirror of
https://github.com/tromey/gdb-gui.git
synced 2025-08-24 19:40:07 +02:00
make gui show and gui list commands
This commit is contained in:
@@ -41,7 +41,48 @@ windows can be created."""
|
|||||||
|
|
||||||
def invoke(self, arg, from_tty):
|
def invoke(self, arg, from_tty):
|
||||||
self.dont_repeat()
|
self.dont_repeat()
|
||||||
gui.source.SourceWindow()
|
gui.source.lru_handler.new_source_window()
|
||||||
|
|
||||||
|
class GuiListCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super(GuiListCommand, self).__init__('gui list',
|
||||||
|
gdb.COMMAND_SUPPORT)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
self.dont_repeat()
|
||||||
|
(extra, sals) = gdb.decode_line(arg)
|
||||||
|
if extra is not None:
|
||||||
|
raise gdb.GdbError('unrecognized junk at end of command: ' + extra)
|
||||||
|
if sals is None:
|
||||||
|
raise gdb.GdbError('not found')
|
||||||
|
if len(sals) > 1:
|
||||||
|
print "Ambiguous linespec, only showing first result"
|
||||||
|
sal = sals[0]
|
||||||
|
if sal.symtab is None or sal.symtab.filename is None:
|
||||||
|
raise gdb.GdbError('could not find file for symbol')
|
||||||
|
gui.source.lru_handler.show_source_gdb(None, sal.symtab,
|
||||||
|
sal.symtab.fullname(),
|
||||||
|
sal.line)
|
||||||
|
|
||||||
|
class GuiShowCommand(gdb.Command):
|
||||||
|
def __init__(self):
|
||||||
|
super(GuiShowCommand, self).__init__('gui show',
|
||||||
|
gdb.COMMAND_SUPPORT)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
self.dont_repeat()
|
||||||
|
# Unfortunately gdb.lookup_symbol can't be used
|
||||||
|
# when the inferior isn't running.
|
||||||
|
# There's a bug for this.
|
||||||
|
# FIXME - this isn't really working at all anyway.
|
||||||
|
symbol = gdb.lookup_global_symbol(arg)
|
||||||
|
if symbol is None:
|
||||||
|
raise gdb.GdbError('not found')
|
||||||
|
if symbol.symtab is None or symbol.symtab.filename is None:
|
||||||
|
raise gdb.GdbError('could not find file for symbol')
|
||||||
|
gui.source.lru_handler.show_source_gdb(None, symbol.symtab,
|
||||||
|
symbol.symtab.fullname(),
|
||||||
|
symbol.line)
|
||||||
|
|
||||||
class GuiLogWindowCommand(gdb.Command):
|
class GuiLogWindowCommand(gdb.Command):
|
||||||
"""Create a new log window.
|
"""Create a new log window.
|
||||||
@@ -211,6 +252,8 @@ GuiOutputCommand()
|
|||||||
GuiPrintfCommand()
|
GuiPrintfCommand()
|
||||||
GuiDprintfCommand()
|
GuiDprintfCommand()
|
||||||
GuiDisplayCommand()
|
GuiDisplayCommand()
|
||||||
|
GuiListCommand()
|
||||||
|
GuiShowCommand()
|
||||||
InfoWindowsCommand()
|
InfoWindowsCommand()
|
||||||
DeleteWindowsCommand()
|
DeleteWindowsCommand()
|
||||||
|
|
||||||
|
@@ -148,6 +148,25 @@ def get_current_location():
|
|||||||
class LRUHandler:
|
class LRUHandler:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.windows = []
|
self.windows = []
|
||||||
|
self.work_location = None
|
||||||
|
|
||||||
|
# What a lame name.
|
||||||
|
@in_gdb_thread
|
||||||
|
def show_source_gdb(self, frame, symtab, srcfile, srcline):
|
||||||
|
if len(self.windows) == 0:
|
||||||
|
self.work_location = (frame, symtab, srcfile, srcline)
|
||||||
|
SourceWindow()
|
||||||
|
gui.startup.send_to_gtk(lambda: self.show_source(frame,
|
||||||
|
symtab,
|
||||||
|
srcfile,
|
||||||
|
srcline))
|
||||||
|
|
||||||
|
@in_gdb_thread
|
||||||
|
def new_source_window(self):
|
||||||
|
loc = get_current_location()
|
||||||
|
if loc[2] is not None:
|
||||||
|
self.work_location = loc
|
||||||
|
SourceWindow()
|
||||||
|
|
||||||
@in_gdb_thread
|
@in_gdb_thread
|
||||||
def on_event(self, *args):
|
def on_event(self, *args):
|
||||||
@@ -207,7 +226,13 @@ class LRUHandler:
|
|||||||
if len(self.windows) == 1:
|
if len(self.windows) == 1:
|
||||||
gdb.post_event(self._connect_events)
|
gdb.post_event(self._connect_events)
|
||||||
# Show something.
|
# Show something.
|
||||||
gdb.post_event(lambda: self.on_event(None))
|
if self.work_location is not None:
|
||||||
|
(frame, symtab, filename, lineno) = self.work_location
|
||||||
|
self.work_location = None
|
||||||
|
gui.startup.send_to_gtk(lambda: self.show_source(frame,
|
||||||
|
symtab,
|
||||||
|
filename,
|
||||||
|
lineno))
|
||||||
|
|
||||||
lru_handler = LRUHandler()
|
lru_handler = LRUHandler()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user