From: Simon Marchi Date: Wed, 29 Oct 2025 17:49:17 +0000 (-0400) Subject: gdb/testsuite: remove unused "global" statements in Python files X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de9f1c1bb22e1024813e523a36f458455cdcf7c7;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: remove unused "global" statements in Python files Fix the flake8 warnings of this type: gdb/testsuite/gdb.python/py-disasm.py:855:9: F824 `global current_pc` is unused: name is never assigned in scope Change-Id: If492c69553cebea932cfb21e6fea26529761254c Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py index 4ab725761aa..4eeb8985e1b 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py @@ -46,9 +46,6 @@ class TestUnwinder(Unwinder): Unwinder.__init__(self, "stop at level") def __call__(self, pending_frame): - global stop_at_level - global stack_adjust - if stop_at_level is None or pending_frame.level() != stop_at_level: return None diff --git a/gdb/testsuite/gdb.base/pc-not-saved.py b/gdb/testsuite/gdb.base/pc-not-saved.py index b8bc361712e..e08f3c452b5 100644 --- a/gdb/testsuite/gdb.base/pc-not-saved.py +++ b/gdb/testsuite/gdb.base/pc-not-saved.py @@ -60,7 +60,6 @@ class break_unwinding(Unwinder): if str(func) != "break_bt_here": return None - global break_bt_here_frame_id if break_bt_here_frame_id is None: return None diff --git a/gdb/testsuite/gdb.base/shlib-unload.py b/gdb/testsuite/gdb.base/shlib-unload.py index 66ff7a594e3..464852b2acd 100644 --- a/gdb/testsuite/gdb.base/shlib-unload.py +++ b/gdb/testsuite/gdb.base/shlib-unload.py @@ -24,7 +24,6 @@ bp_modified_counts = {} # Record breakpoint modification events into the global # bp_modified_counts dictionary. def bp_modified(bp): - global bp_modified_counts if bp.number not in bp_modified_counts: bp_modified_counts[bp.number] = 1 else: diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py index 9761337550a..5ebc51f652a 100644 --- a/gdb/testsuite/gdb.python/py-disasm.py +++ b/gdb/testsuite/gdb.python/py-disasm.py @@ -62,16 +62,12 @@ class TestDisassembler(Disassembler): disassembly wrapping for the global CURRENT_PC.""" def __init__(self): - global current_pc - super().__init__("TestDisassembler") self.__info = None if current_pc == None: raise gdb.GdbError("no current_pc set") def __call__(self, info): - global current_pc - if info.address != current_pc: return None self.__info = info @@ -618,8 +614,6 @@ class Build_Result_Using_All_Parts(TestDisassembler): text and address parts.""" def disassemble(self, info): - global current_pc - parts = [] parts.append(info.text_part(gdb.disassembler.STYLE_MNEMONIC, "fake")) parts.append(info.text_part(gdb.disassembler.STYLE_TEXT, "\t")) @@ -852,7 +846,6 @@ class InvalidDisassembleInfo(gdb.disassembler.DisassembleInfo): @property def address(self): - global current_pc return current_pc @property diff --git a/gdb/testsuite/gdb.python/py-missing-debug.py b/gdb/testsuite/gdb.python/py-missing-debug.py index c018d4dc9b8..18d37ce0996 100644 --- a/gdb/testsuite/gdb.python/py-missing-debug.py +++ b/gdb/testsuite/gdb.python/py-missing-debug.py @@ -38,7 +38,6 @@ class handler(MissingDebugHandler): self._mode = Mode.RETURN_NONE def __call__(self, objfile): - global handler_call_log handler_call_log.append(self.name) self._call_count += 1 if self._mode == Mode.RETURN_NONE: @@ -95,7 +94,6 @@ class exception_handler(MissingDebugHandler): self.exception_type = None def __call__(self, objfile): - global handler_call_log handler_call_log.append(self.name) assert self.exception_type is not None raise self.exception_type("message") @@ -103,7 +101,6 @@ class exception_handler(MissingDebugHandler): class log_handler(MissingDebugHandler): def __call__(self, objfile): - global handler_call_log handler_call_log.append(self.name) return None diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.py b/gdb/testsuite/gdb.python/py-missing-objfile.py index 5efc36a2a92..bdd7a599b63 100644 --- a/gdb/testsuite/gdb.python/py-missing-objfile.py +++ b/gdb/testsuite/gdb.python/py-missing-objfile.py @@ -65,7 +65,7 @@ class handler(MissingObjfileHandler): self._mode = Mode.RETURN_NONE def __call__(self, pspace, buildid, filename): - global handler_call_log, handler_last_buildid, handler_last_filename + global handler_last_buildid, handler_last_filename check_args(pspace, buildid, filename) handler_call_log.append(self.name) handler_last_buildid = buildid @@ -135,7 +135,6 @@ class exception_handler(MissingObjfileHandler): self.exception_type = None def __call__(self, pspace, buildid, filename): - global handler_call_log check_args(pspace, buildid, filename) handler_call_log.append(self.name) assert self.exception_type is not None @@ -148,7 +147,6 @@ class exception_handler(MissingObjfileHandler): # then be checked from the test script. class log_handler(MissingObjfileHandler): def __call__(self, pspace, buildid, filename): - global handler_call_log check_args(pspace, buildid, filename) handler_call_log.append(self.name) return None diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py index 0faccf2ca13..183c6b1eb67 100644 --- a/gdb/testsuite/gdb.python/py-unwind.py +++ b/gdb/testsuite/gdb.python/py-unwind.py @@ -106,7 +106,6 @@ class TestUnwinder(Unwinder): unwind_info.add_saved_register(value=previous_ip, register="rip") unwind_info.add_saved_register(register="rsp", value=previous_sp) - global add_saved_register_errors try: unwind_info.add_saved_register("nosuchregister", previous_sp) except ValueError as ve: @@ -230,7 +229,6 @@ def capture_all_frame_information(): # Assert that every entry in the global ALL_FRAME_INFORMATION list was # matched by the validating_unwinder. def check_all_frame_information_matched(): - global all_frame_information for entry in all_frame_information: assert entry["matched"] @@ -245,8 +243,6 @@ class validating_unwinder(Unwinder): def __call__(self, pending_frame): info = capture_frame_information(pending_frame) level = info["level"] - - global all_frame_information old_info = all_frame_information[level] assert old_info is not None diff --git a/gdb/testsuite/gdb.python/tui-window-disabled.py b/gdb/testsuite/gdb.python/tui-window-disabled.py index 8d140c4e2fe..2adde773ce8 100644 --- a/gdb/testsuite/gdb.python/tui-window-disabled.py +++ b/gdb/testsuite/gdb.python/tui-window-disabled.py @@ -46,9 +46,6 @@ class EventWindow: self._win.write("Hello world...") def close(self): - global cleanup_properly - global titles_at_the_close - # Ensure that window properties can be read within the close method. titles_at_the_close[self._win.title] = dict( width=self._win.width, height=self._win.height @@ -70,9 +67,6 @@ class EventWindow: self._exit_listener = None def _event(self, type, event): - global perform_valid_check - global update_title - self._count += 1 self._events.insert(0, type) if not perform_valid_check or self._win.is_valid():