mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
gdb/{testsuite,system-gdbinit}: import gdb module in Python scripts
Fix flake8 warnings like:
gdb/system-gdbinit/wrs-linux.py:21:5: F821 undefined name 'gdb'
These scripts get executed in a context where the gdb module is already
loaded, so this is not strictly necessary. However, adding these
imports removes a lot of red lines when editing these files in an IDE.
Without them, the code uses this `gdb` thing that appears to be
undefined. Pylance is able to pull the module definition from typeshed
[1] and provide a good experience with typings.
[1] https://github.com/python/typeshed/tree/main/stubs/gdb/gdb
Change-Id: I09c6ae1866ef66f10d8270457771687343c84e32
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
import os
|
||||
|
||||
import gdb
|
||||
|
||||
if "ENV_PREFIX" in os.environ:
|
||||
gdb.execute("set sysroot %s" % os.environ["ENV_PREFIX"])
|
||||
|
||||
|
||||
@@ -12,6 +12,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/>.
|
||||
import gdb
|
||||
|
||||
bp_modified_list = []
|
||||
|
||||
|
||||
@@ -12,6 +12,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/>.
|
||||
import gdb
|
||||
|
||||
|
||||
class Printer1:
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# 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
|
||||
|
||||
bp_modified_list = []
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# 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
|
||||
|
||||
# Breakpoint modification events will be recorded in this dictionary.
|
||||
# The keys are the b/p numbers, and the values are the number of
|
||||
# modification events seen.
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class BackTrace(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self, depth):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class Disassemble(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class SingleStep(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self, step):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class SkipCommand(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self, name, step):
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class SkipPrologue(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self, count):
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
from perftest import measure, perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class SolibLoadUnload1(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self, solib_count, measure_load):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
from perftest import perftest
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class TemplateBreakpoints(perftest.TestCaseWithBasicMeasurements):
|
||||
def __init__(self):
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class MytypePrinter:
|
||||
"""pretty print my type"""
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import re
|
||||
|
||||
import gdb
|
||||
|
||||
print("Entering f1.o auto-load script")
|
||||
|
||||
print("Current objfile is: %s" % gdb.current_objfile().filename)
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# This script is auto-loaded when the py-auto-load-chaining-f2.o
|
||||
# object is loaded.
|
||||
|
||||
import gdb
|
||||
|
||||
print("Entering f2.o auto-load script")
|
||||
|
||||
print("Current objfile is: %s" % gdb.current_objfile().filename)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
import gdb
|
||||
|
||||
# Avoid generating
|
||||
# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import pathlib
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class Mapping:
|
||||
def __init__(self, mapping, region):
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class MyFinishBreakpoint(gdb.FinishBreakpoint):
|
||||
def stop(self):
|
||||
print("stopped at MyFinishBreakpoint")
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
# Breakpoints.
|
||||
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class MyFinishBreakpoint(gdb.FinishBreakpoint):
|
||||
def __init__(self, val, frame):
|
||||
gdb.FinishBreakpoint.__init__(self, frame)
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# This file is part of the GDB testsuite. It tests python Finish
|
||||
# Breakpoints.
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class ExceptionFinishBreakpoint(gdb.FinishBreakpoint):
|
||||
def __init__(self, frame):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
import gdb
|
||||
|
||||
# Avoid generating
|
||||
# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
import re
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class pp_ss:
|
||||
def __init__(self, val):
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
import gdb
|
||||
|
||||
# Avoid generating
|
||||
# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
import re
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class pp_ss:
|
||||
def __init__(self, val):
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class MyBreakpoint(gdb.Breakpoint):
|
||||
def __init__(self):
|
||||
super().__init__("i", gdb.BP_WATCHPOINT)
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class TestWindow:
|
||||
def __init__(self, tui_win, msg):
|
||||
self.msg = msg
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
import os
|
||||
import stat
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
# Hex encode INPUT_STRING in the same way that GDB does. Each
|
||||
# character in INPUT_STRING is expanded to its two digit hex
|
||||
|
||||
Reference in New Issue
Block a user