diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..a6f727b --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore = E501, W503 diff --git a/gui/adapt.py b/gui/adapt.py index 606a94f..350b86e 100644 --- a/gui/adapt.py +++ b/gui/adapt.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015, 2016 Tom Tromey +# Copyright (C) 2015, 2016, 2023 Tom Tromey # 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 @@ -15,8 +15,6 @@ # Adapt to gdb issues. -import gdb - import gui.params # The rule for adding a new entry here is that the bug must have some diff --git a/gui/commands.py b/gui/commands.py index 217ee87..d600e97 100644 --- a/gui/commands.py +++ b/gui/commands.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012, 2013, 2015, 2016 Tom Tromey +# Copyright (C) 2012, 2013, 2015, 2016, 2023 Tom Tromey # 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,6 @@ import gui.source import gui.stack import gui.startup import gui.toplevel -from gui.startup import in_gtk_thread class GuiCommand(gdb.Command): @@ -110,7 +109,7 @@ class GuiShowCommand(gdb.Command): self.dont_repeat() try: (symbol, ignore) = gdb.lookup_symbol(arg) - except gdb.error as e: + except gdb.error: if gui.gdbutil.is_running(): raise symbol = gdb.lookup_global_symbol(arg) @@ -222,7 +221,6 @@ class GuiDprintfCommand(GuiPrintBase): def invoke(self, arg, from_tty): (window, arg) = self._parse_arg(arg, False) - orig_arg = arg (ignore, arg) = gdb.decode_line(arg) if arg is None: raise gdb.GdbError("no printf arguments to 'gui dprintf'") @@ -230,8 +228,8 @@ class GuiDprintfCommand(GuiPrintBase): if not arg.startswith(","): raise gdb.GdbError("comma expected after linespec") arg = arg[1:] - spec = arg[0 : -len(arg)] - DPrintfBreakpoint(spec, window, arg) + spec = arg[0:-len(arg)] + gui.dprintf.DPrintfBreakpoint(spec, window, arg) class GuiDisplayCommand(gdb.Command): @@ -309,6 +307,7 @@ 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. diff --git a/gui/display.py b/gui/display.py index 8eff762..f8a6ee6 100644 --- a/gui/display.py +++ b/gui/display.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013, 2015 Tom Tromey +# Copyright (C) 2013, 2015, 2023 Tom Tromey # 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 @@ -15,11 +15,10 @@ # Log window. -import functools -from difflib import Differ, SequenceMatcher +from difflib import Differ import gdb -from gi.repository import Gtk, Pango +from gi.repository import Pango import gui.events import gui.startup diff --git a/gui/events.py b/gui/events.py index 2d95bd6..7c04f6a 100644 --- a/gui/events.py +++ b/gui/events.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013, 2015 Tom Tromey +# Copyright (C) 2013, 2015, 2023 Tom Tromey # 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 @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import gdb - class _Event(object): def __init__(self): diff --git a/gui/gdbutil.py b/gui/gdbutil.py index 2ba7a3a..09a7f81 100644 --- a/gui/gdbutil.py +++ b/gui/gdbutil.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Tom Tromey +# Copyright (C) 2015, 2023 Tom Tromey # 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 @@ -37,6 +37,7 @@ def _prompt_window(attr): gui_prompt_substitutions["W"] = _prompt_window + # GDB's API should do this... def substitute_prompt_with_window(prompt, window): global _current_window_for_prompt diff --git a/gui/logwindow.py b/gui/logwindow.py index a8c6ec7..cfd3aa4 100644 --- a/gui/logwindow.py +++ b/gui/logwindow.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013, 2015 Tom Tromey +# Copyright (C) 2013, 2015, 2023 Tom Tromey # 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 @@ -17,9 +17,6 @@ import functools -import gdb -from gi.repository import Gtk, Pango - import gui.startup import gui.toplevel from gui.startup import in_gtk_thread @@ -47,12 +44,13 @@ class LogWindow(gui.toplevel.Toplevel): self.view.modify_font(gui.params.font_manager.get_font()) self.buffer = builder.get_object("buffer") - @in_gtk_thread - def set_font(self, font): - self.view.modify_font(Pango.FontDescription(font_name)) + # @in_gtk_thread + # def set_font(self, font): + # self.view.modify_font(Pango.FontDescription(font_name)) @in_gtk_thread def deleted(self, *args): + global default_log_window if default_log_window == self: default_log_window = None for window in gui.toplevel.state.windows(): diff --git a/gui/params.py b/gui/params.py index 4cf2352..2de74f6 100644 --- a/gui/params.py +++ b/gui/params.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Tom Tromey +# Copyright (C) 2015, 2023 Tom Tromey # 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 @@ -74,7 +74,7 @@ class _StoredParameter(gdb.Parameter): elif p_kind is gdb.PARAM_ZINTEGER: val = storage.getint(self.storage_name) else: - raise Error("missing case in gdb gui code") + raise gdb.error("missing case in gdb gui code") # Don't record the first setting. self.storage = None if val is None: @@ -214,29 +214,6 @@ class _Missing(_StoredParameter): return "Whether to warn about missing gdb features: " + v -class _Lines(_StoredParameter): - # Silly gdb requirement. - """""" - - set_doc = "Set whether to display line numbers in the source window." - show_doc = "Show whether to display line numbers in the source window." - - def __init__(self): - super(_Lines, self).__init__( - "%s", "line-numbers", False, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN - ) - - @in_gdb_thread - def get_show_string(self, pvalue): - return "The current title format for the %s is: %s" % (self.name, self.value) - - @in_gdb_thread - def get_set_string(self): - super(_Lines, self).get_set_string() - gui.toplevel.state.set_line_numbers(self.value) - return "" - - class _Lines(_StoredParameter): # Silly gdb requirement. """""" diff --git a/gui/source.py b/gui/source.py index 38e5bec..f423d97 100644 --- a/gui/source.py +++ b/gui/source.py @@ -18,7 +18,7 @@ import os.path import gdb -from gi.repository import Gdk, GdkPixbuf, GObject, Gtk, GtkSource, Pango +from gi.repository import Gdk, GdkPixbuf, GObject, GtkSource import gui import gui.bpcache @@ -152,6 +152,7 @@ class BufferManager: buffer_manager = BufferManager() + # Return (FRAME, SYMTAB, FILE, LINE) for the selected frame, or, if # there is no frame, for "main". @in_gdb_thread