@@ -13,11 +13,11 @@
# 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 os
import signal
+import sys
import threading
import traceback
-import os
-import sys
from contextlib import contextmanager
# Python 3 moved "reload"
@@ -27,11 +27,13 @@ else:
from imp import reload
# Note that two indicators are needed here to silence flake8.
-# isort: split
from _gdb import * # noqa: F401,F403
+# isort: split
+
# Historically, gdb.events was always available, so ensure it's
# still available without an explicit import.
+# isort: split
import _gdbevents as events
sys.modules["gdb.events"] = events
@@ -63,8 +65,8 @@ class _GdbFile(object):
write(s, stream=self.stream) # noqa: F405
-sys.stdout = _GdbFile(STDOUT) # noqa: F405
-sys.stderr = _GdbFile(STDERR) # noqa: F405
+sys.stdout = _GdbFile(STDOUT) # noqa: F405
+sys.stderr = _GdbFile(STDERR) # noqa: F405
# Default prompt hook does nothing.
prompt_hook = None
@@ -17,6 +17,7 @@
"""GDB commands for working with frame-filters."""
import sys
+
import gdb
import gdb.frames
@@ -15,9 +15,10 @@
# 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
import re
+import gdb
+
def validate_regexp(exp, idstring):
"""Compile exp into a compiler regular expression object.
@@ -17,9 +17,10 @@
"""GDB commands for working with pretty-printers."""
import copy
-import gdb
import re
+import gdb
+
def parse_printer_regexps(arg):
"""Internal utility to parse a pretty-printer command argv.
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import copy
+
import gdb
"""GDB commands for working with type-printers."""
@@ -14,9 +14,10 @@
# 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
import re
+import gdb
+
def validate_regexp(exp, idstring):
try:
@@ -14,9 +14,10 @@
# 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
import re
+import gdb
+
"""GDB commands for working with xmethods."""
@@ -16,26 +16,27 @@
import os
# This must come before other DAP imports.
-# isort: split
from . import startup
+# isort: split
+
# Load modules that define commands. These imports intentionally
# ignore the unused import warning, as these modules are being loaded
# for their side effects -- namely, registering DAP commands with the
# server object. "F401" is the flake8 "imported but unused" code.
-from . import breakpoint # noqa: F401
-from . import bt # noqa: F401
-from . import disassemble # noqa: F401
-from . import evaluate # noqa: F401
-from . import launch # noqa: F401
-from . import locations # noqa: F401
-from . import memory # noqa: F401
-from . import modules # noqa: F401
-from . import next # noqa: F401
-from . import pause # noqa: F401
-from . import scopes # noqa: F401
-from . import sources # noqa: F401
-from . import threads # noqa: F401
+from . import breakpoint # noqa: F401
+from . import bt # noqa: F401
+from . import disassemble # noqa: F401
+from . import evaluate # noqa: F401
+from . import launch # noqa: F401
+from . import locations # noqa: F401
+from . import memory # noqa: F401
+from . import modules # noqa: F401
+from . import next # noqa: F401
+from . import pause # noqa: F401
+from . import scopes # noqa: F401
+from . import sources # noqa: F401
+from . import threads # noqa: F401
# isort: split
from .server import Server
@@ -13,21 +13,20 @@
# 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
import os
import re
-
from contextlib import contextmanager
# These are deprecated in 3.9, but required in older versions.
from typing import Optional, Sequence
-from .server import request, capability, send_event
+import gdb
+
+from .server import capability, request, send_event
from .sources import make_source
-from .startup import in_gdb_thread, log_stack, parse_and_eval, LogLevel, DAPException
+from .startup import DAPException, LogLevel, in_gdb_thread, log_stack, parse_and_eval
from .typecheck import type_check
-
# True when suppressing new breakpoint events.
_suppress_bp = False
@@ -13,16 +13,17 @@
# 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
import os
# This is deprecated in 3.9, but required in older versions.
from typing import Optional
+import gdb
+
from .frames import dap_frame_generator
from .modules import module_id
from .scopes import symbol_value
-from .server import request, capability
+from .server import capability, request
from .sources import make_source
from .startup import in_gdb_thread
from .state import set_thread
@@ -15,7 +15,7 @@
import gdb
-from .server import request, capability
+from .server import capability, request
@request("disassemble")
@@ -13,15 +13,15 @@
# 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
-
# This is deprecated in 3.9, but required in older versions.
from typing import Optional
+import gdb
+
from .frames import select_frame
-from .server import capability, request, client_bool_capability
-from .startup import in_gdb_thread, parse_and_eval, DAPException
-from .varref import find_variable, VariableReference, apply_format
+from .server import capability, client_bool_capability, request
+from .startup import DAPException, in_gdb_thread, parse_and_eval
+from .varref import VariableReference, apply_format, find_variable
class EvaluateResult(VariableReference):
@@ -15,11 +15,10 @@
import gdb
+from .modules import is_module, make_module
from .scopes import set_finish_value
from .server import send_event
from .startup import exec_and_log, in_gdb_thread, log
-from .modules import is_module, make_module
-
# True when the inferior is thought to be running, False otherwise.
# This may be accessed from any thread, which can be racy. However,
@@ -13,14 +13,13 @@
# 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
import itertools
+import gdb
from gdb.frames import frame_iterator
from .startup import in_gdb_thread
-
# A list of all the frames we've reported. A frame's index in the
# list is its ID. We don't use a hash here because frames are not
# hashable.
@@ -15,7 +15,7 @@
import json
-from .startup import start_thread, log, log_stack, LogLevel
+from .startup import LogLevel, log, log_stack, start_thread
def read_json(stream):
@@ -13,14 +13,14 @@
# 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
-
# These are deprecated in 3.9, but required in older versions.
from typing import Mapping, Optional, Sequence
+import gdb
+
from .events import exec_and_expect_stop, expect_process, expect_stop
-from .server import request, capability
-from .startup import exec_and_log, DAPException
+from .server import capability, request
+from .startup import DAPException, exec_and_log
# Any parameters here are necessarily extensions -- DAP requires this
@@ -13,11 +13,11 @@
# 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
-
# This is deprecated in 3.9, but required in older versions.
from typing import Optional
+import gdb
+
from .server import capability, request
from .sources import decode_source
@@ -14,9 +14,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import base64
+
import gdb
-from .server import request, capability
+from .server import capability, request
@request("readMemory")
@@ -16,11 +16,10 @@
import gdb
from .frames import frame_for_id
-from .startup import in_gdb_thread
from .server import request
+from .startup import in_gdb_thread
from .varref import BaseReference
-
# Map DAP frame IDs to scopes. This ensures that scopes are re-used.
frame_to_scope = {}
@@ -14,29 +14,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import functools
-import gdb
import heapq
import inspect
import json
import threading
from contextlib import contextmanager
-from .io import start_json_writer, read_json
+import gdb
+
+from .io import read_json, start_json_writer
from .startup import (
- exec_and_log,
DAPException,
DAPQueue,
+ LogLevel,
+ exec_and_log,
in_dap_thread,
in_gdb_thread,
- start_thread,
log,
log_stack,
- LogLevel,
+ start_thread,
thread_log,
)
from .typecheck import type_check
-
# Map capability names to values.
_capabilities = {}
@@ -17,9 +17,8 @@ import os
import gdb
-from .server import request, capability
-from .startup import in_gdb_thread, DAPException
-
+from .server import capability, request
+from .startup import DAPException, in_gdb_thread
# The next available source reference ID. Must be greater than 0.
_next_source = 1
@@ -16,14 +16,14 @@
# Do not import other gdbdap modules here -- this module must come
# first.
import functools
-import gdb
import queue
+import sys
import threading
import traceback
-import sys
-
from enum import IntEnum, auto
+import gdb
+
# Adapt to different Queue types. This is exported for use in other
# modules as well.
if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from .startup import in_gdb_thread, exec_and_log, log
+from .startup import exec_and_log, in_gdb_thread, log
@in_gdb_thread
@@ -13,13 +13,14 @@
# 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
-from .startup import in_gdb_thread, DAPException
-from .server import client_bool_capability
from abc import ABC, abstractmethod
from collections import defaultdict
from contextlib import contextmanager
+import gdb
+
+from .server import client_bool_capability
+from .startup import DAPException, in_gdb_thread
# A list of all the variable references created during this pause.
all_variables = []
@@ -15,7 +15,6 @@
"""Disassembler related module."""
-import gdb
import _gdb.disassembler
# Re-export everything from the _gdb.disassembler module, which is
@@ -23,6 +22,8 @@ import _gdb.disassembler
# here to silence flake8.
from _gdb.disassembler import * # noqa: F401,F403
+import gdb
+
# Module global dictionary of gdb.disassembler.Disassembler objects.
# The keys of this dictionary are bfd architecture names, or the
# special value None.
@@ -16,11 +16,12 @@
"""Internal functions for working with frame-filters."""
+import collections
+import itertools
+
import gdb
+from gdb.FrameDecorator import DAPFrameDecorator, FrameDecorator
from gdb.FrameIterator import FrameIterator
-from gdb.FrameDecorator import FrameDecorator, DAPFrameDecorator
-import itertools
-import collections
def get_priority(filter_item):
@@ -14,9 +14,10 @@
# 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
import re
+import gdb
+
class CallerIs(gdb.Function):
"""Check the calling function's name.
@@ -16,9 +16,10 @@
"""$_memeq, $_strlen, $_streq, $_regex"""
-import gdb
import re
+import gdb
+
class _MemEq(gdb.Function):
"""$_memeq - compare bytes of memory.
@@ -17,9 +17,10 @@
MissingDebugHandler base class, and register_handler function.
"""
-import gdb
import sys
+import gdb
+
if sys.version_info >= (3, 7):
# Functions str.isascii() and str.isalnum are available starting Python
# 3.7.
@@ -32,7 +33,7 @@ if sys.version_info >= (3, 7):
else:
# Fall back to curses.ascii.isascii() and curses.ascii.isalnum() for
# earlier versions.
- from curses.ascii import isascii, isalnum
+ from curses.ascii import isalnum, isascii
def _validate_name(name):
@@ -16,11 +16,12 @@
"""Utilities for working with pretty-printers."""
-import gdb
-import gdb.types
import itertools
import re
+import gdb
+import gdb.types
+
class PrettyPrinter(object):
"""A basic pretty-printer.
@@ -16,9 +16,10 @@
""" Extended prompt library functions."""
-import gdb
import os
+import gdb
+
def _prompt_pwd(ignore):
"The current working directory."
@@ -19,9 +19,9 @@
import gdb
try:
- from pygments import formatters, lexers, highlight
- from pygments.token import Error, Comment, Text
+ from pygments import formatters, highlight, lexers
from pygments.filters import TokenMergeFilter
+ from pygments.token import Comment, Error, Text
_formatter = None
@@ -16,9 +16,10 @@
"""Utilities for defining xmethods"""
-import gdb
import re
+import gdb
+
class XMethod(object):
"""Base class (or a template) for an xmethod description.
@@ -1,9 +1,9 @@
# Program to fetch python compilation parameters.
# Copied from python-config of the 2.7 release.
-import sys
-import os
import getopt
+import os
+import sys
import sysconfig
valid_opts = ["prefix", "exec-prefix", "includes", "libs", "cflags", "ldflags", "help"]
@@ -5,8 +5,8 @@
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
-import sys
import re
+import sys
import time
infname = sys.argv[1]
@@ -15,8 +15,9 @@
"""Configure GDB using the ELinOS environment."""
-import os
import glob
+import os
+
import gdb
@@ -29,9 +29,9 @@
# This program is invoked when the user runs "make check" and
# specifies the RACY_ITER environment variable.
-import sys
import os
import re
+import sys
# The (global) dictionary that stores the associations between a *.sum
# file and its results. The data inside it will be stored as:
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from time import asctime, gmtime
+
import gdb # silence pyflakes
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import gdb
-from gdb.unwinder import Unwinder, FrameId
+from gdb.unwinder import FrameId, Unwinder
# Cached FrameId. See set_break_bt_here_frame_id for details.
break_bt_here_frame_id = None
@@ -14,9 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import gdb
import itertools
+import gdb
from gdb.FrameDecorator import DAPFrameDecorator
@@ -16,6 +16,7 @@
# Test the type checker.
import typing
+
from gdb.dap.typecheck import type_check
@@ -17,9 +17,7 @@
# Efficient handling of this case is important, and not just for typos.
# Sometimes the debug info for the needed object isn't present.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class NullLookup(perftest.TestCaseWithBasicMeasurements):
@@ -17,9 +17,7 @@
# typedef used pervasively. This exercises the perf regression introduced by
# the original patch to pr 16253.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class PervasiveTypedef(perftest.TestCaseWithBasicMeasurements):
@@ -25,9 +25,7 @@
# is that here we do not pre-expand the symtab: we don't want include
# GDB's slowness in searching expanded symtabs first to color these results.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class PrintCerr(perftest.TestCaseWithBasicMeasurements):
@@ -19,9 +19,7 @@
# these before it searches the index (there is work-in-progress to fix this),
# this test helps measure the issue.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class GmonsterPtypeString(perftest.TestCaseWithBasicMeasurements):
@@ -15,9 +15,7 @@
# Measure performance of running to main.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class GmonsterRuntoMain(perftest.TestCaseWithBasicMeasurements):
@@ -15,9 +15,7 @@
# Measure performance of selecting a file to debug.
-from perftest import perftest
-from perftest import measure
-from perftest import utils
+from perftest import measure, perftest, utils
class GmonsterSelectFile(perftest.TestCaseWithBasicMeasurements):
@@ -13,10 +13,10 @@
# 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 time
-import os
import gc
+import os
import sys
+import time
# time.perf_counter() and time.process_time() were added in Python
# 3.3, time.clock() was removed in Python 3.8.
@@ -15,13 +15,15 @@
from __future__ import absolute_import
-import perftest.testresult as testresult
import perftest.reporter as reporter
-from perftest.measure import Measure
-from perftest.measure import MeasurementPerfCounter
-from perftest.measure import MeasurementProcessTime
-from perftest.measure import MeasurementWallTime
-from perftest.measure import MeasurementVmSize
+import perftest.testresult as testresult
+from perftest.measure import (
+ Measure,
+ MeasurementPerfCounter,
+ MeasurementProcessTime,
+ MeasurementVmSize,
+ MeasurementWallTime,
+)
class TestCase(object):
@@ -16,8 +16,7 @@
# This test case is to test the speed of GDB when it is handling the
# shared libraries of inferior are loaded and unloaded.
-from perftest import perftest
-from perftest import measure
+from perftest import measure, perftest
class SolibLoadUnload1(perftest.TestCaseWithBasicMeasurements):
@@ -18,9 +18,10 @@
# registered when a custom event handler for the new_objfile event
# is called.
-import gdb
import os
+import gdb
+
def new_objfile_handler(event):
assert isinstance(event, gdb.NewObjFileEvent)
@@ -19,6 +19,7 @@
# Test a printer with a bad children iterator.
import re
+
import gdb.printing
@@ -13,11 +13,11 @@
# 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
-import gdb.disassembler
import struct
import sys
+import gdb
+import gdb.disassembler
from gdb.disassembler import Disassembler, DisassemblerResult
# A global, holds the program-counter address at which we should
@@ -17,7 +17,6 @@
import gdb
-
freed_objfile = None
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
+
import gdb
@@ -13,10 +13,11 @@
# 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
+import copy
import itertools
+
+import gdb
from gdb.FrameDecorator import FrameDecorator
-import copy
# A FrameDecorator that just returns gdb.Frame.pc () from 'function'.
@@ -13,10 +13,11 @@
# 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 itertools
+
# This file is part of the GDB testsuite. It tests Python-based
# frame-filters.
import gdb
-import itertools
from gdb.FrameDecorator import FrameDecorator
@@ -13,10 +13,11 @@
# 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 itertools
+
# This file is part of the GDB testsuite. It tests Python-based
# frame-filters.
import gdb
-import itertools
from gdb.FrameDecorator import FrameDecorator
@@ -13,12 +13,13 @@
# 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 copy
+import itertools
+
# This file is part of the GDB testsuite. It tests Python-based
# frame-filters.
import gdb
-import itertools
from gdb.FrameDecorator import FrameDecorator
-import copy
class Reverse_Function(FrameDecorator):
@@ -13,12 +13,13 @@
# 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 copy
+import itertools
+
# This file is part of the GDB testsuite. It tests Python-based
# frame-filters.
import gdb
-import itertools
from gdb.FrameDecorator import FrameDecorator
-import copy
class Reverse_Function(FrameDecorator):
@@ -13,9 +13,10 @@
# 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 re
import tracemalloc
+
import gdb
-import re
# A global variable in which we store a reference to the gdb.Inferior
# object sent to us in the new_inferior event.
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
+
import gdb
import gdb.types
@@ -13,10 +13,11 @@
# 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 os
+from enum import Enum
+
import gdb
from gdb.missing_debug import MissingDebugHandler
-from enum import Enum
-import os
# A global log that is filled in by instances of the LOG_HANDLER class
# when they are called.
@@ -17,6 +17,7 @@
# nested map like structures.
import re
+
import gdb
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from time import asctime, gmtime
+
import gdb # silence pyflakes
@@ -17,8 +17,9 @@
# printers.
import re
-import gdb.types
+
import gdb.printing
+import gdb.types
def lookup_function_lookup_test(val):
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from time import asctime, gmtime
+
import gdb # silence pyflakes
@@ -17,8 +17,9 @@
# printer registration.
import re
-import gdb.types
+
import gdb.printing
+import gdb.types
def lookup_function_lookup_test(val):
@@ -17,6 +17,7 @@
# printers.
import re
+
import gdb
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import xml.etree.ElementTree as ET
+
import gdb
@@ -16,6 +16,7 @@
# This file is part of the GDB testsuite. It tests python unwinders.
import re
+
import gdb.types
from gdb.unwinder import Unwinder, register_unwinder
@@ -14,8 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import gdb
-from gdb.unwinder import Unwinder, FrameId
-
+from gdb.unwinder import FrameId, Unwinder
# These are set to test whether invalid register names cause an error.
add_saved_register_errors = {}
@@ -16,12 +16,10 @@
# This file is part of the GDB testsuite. It test the xmethods support
# in the Python extension language.
-import gdb
import re
-from gdb.xmethod import XMethod
-from gdb.xmethod import XMethodMatcher, XMethodWorker
-from gdb.xmethod import SimpleXMethodMatcher
+import gdb
+from gdb.xmethod import SimpleXMethodMatcher, XMethod, XMethodMatcher, XMethodWorker
def A_plus_A(obj, opr):
@@ -17,6 +17,7 @@
# printers.
import re
+
import gdb
@@ -30,10 +30,10 @@
# FORMAT must be a string compatible with "strftime". If nothing is
# provided, we choose a reasonable format.
-import fileinput
import datetime
-import sys
+import fileinput
import os
+import sys
if len(sys.argv) > 1:
fmt = sys.argv[1]