From 2dd1ef46276562729baf775ccbbaa0eda6b06193 Mon Sep 17 00:00:00 2001 From: oltolm Date: Mon, 11 Aug 2025 12:54:47 +0200 Subject: [PATCH] Update GDB stubs to 16.3 (#13923) --- stubs/gdb/@tests/stubtest_allowlist.txt | 8 +++ stubs/gdb/METADATA.toml | 2 +- stubs/gdb/gdb/__init__.pyi | 73 +++++++++++++++---------- stubs/gdb/gdb/disassembler.pyi | 29 +++++----- stubs/gdb/gdb/events.pyi | 1 + stubs/gdb/gdb/missing_debug.pyi | 12 ++-- stubs/gdb/gdb/missing_files.pyi | 13 +++++ stubs/gdb/gdb/missing_objfile.pyi | 7 +++ 8 files changed, 94 insertions(+), 51 deletions(-) create mode 100644 stubs/gdb/gdb/missing_files.pyi create mode 100644 stubs/gdb/gdb/missing_objfile.pyi diff --git a/stubs/gdb/@tests/stubtest_allowlist.txt b/stubs/gdb/@tests/stubtest_allowlist.txt index 45f7643f0..0defd3d50 100644 --- a/stubs/gdb/@tests/stubtest_allowlist.txt +++ b/stubs/gdb/@tests/stubtest_allowlist.txt @@ -73,3 +73,11 @@ gdb.Progspace.xmethods # stubtest thinks this can't be sub-classed at runtime, but it is gdb.disassembler.DisassemblerPart + +gdb.TuiEnabledEvent +gdb.events.tui_enabled + +gdb.Progspace.missing_debug_handlers +gdb.missing_debug_handlers +gdb.missing_files +gdb.missing_objfile diff --git a/stubs/gdb/METADATA.toml b/stubs/gdb/METADATA.toml index cea97d694..6dca8b4d7 100644 --- a/stubs/gdb/METADATA.toml +++ b/stubs/gdb/METADATA.toml @@ -1,4 +1,4 @@ -version = "15.0.*" +version = "16.3.*" # This is the official web portal for the GDB Git repo, # see https://sourceware.org/gdb/current/ for other ways of obtaining the source code. upstream_repository = "https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree" diff --git a/stubs/gdb/gdb/__init__.pyi b/stubs/gdb/gdb/__init__.pyi index 4dc8f1994..4f4a67b28 100644 --- a/stubs/gdb/gdb/__init__.pyi +++ b/stubs/gdb/gdb/__init__.pyi @@ -4,7 +4,6 @@ import _typeshed import threading -from _typeshed import Incomplete from collections.abc import Callable, Iterator, Mapping, Sequence from contextlib import AbstractContextManager from typing import Any, Final, Generic, Literal, Protocol, TypedDict, TypeVar, final, overload, type_check_only @@ -12,6 +11,8 @@ from typing_extensions import TypeAlias, deprecated import gdb.FrameDecorator import gdb.types +from gdb.missing_debug import MissingDebugHandler +from gdb.missing_files import MissingFileHandler # The following submodules are automatically imported from . import events as events, printing as printing, prompt as prompt, types as types @@ -46,7 +47,8 @@ def add_history(value: Value, /) -> int: ... def history_count() -> int: ... def convenience_variable(name: str, /) -> Value | None: ... def set_convenience_variable(name: str, value: _ValueOrNative | None, /) -> None: ... -def parse_and_eval(expression: str, global_context: bool = False, /) -> Value: ... +def parse_and_eval(expression: str, global_context: bool = False) -> Value: ... +def format_address(address: int, progspace: Progspace = ..., architecture: Architecture = ...): ... def find_pc_line(pc: int | Value) -> Symtab_and_line: ... def post_event(event: Callable[[], object], /) -> None: ... def write(string: str, stream: int = ...) -> None: ... @@ -107,7 +109,7 @@ class Value: def __ge__(self, other: _ValueOrNative, /) -> bool: ... def __getitem__(self, key: int | str | Field, /) -> Value: ... def __call__(self, *args: _ValueOrNative) -> Value: ... - def __init__(self, val: _ValueOrNative) -> None: ... + def __init__(self, val: _ValueOrNative, type: Type | None = None) -> None: ... def cast(self, type: Type) -> Value: ... def dereference(self) -> Value: ... def referenced_value(self) -> Value: ... @@ -125,9 +127,12 @@ class Value: symbols: bool = ..., unions: bool = ..., address: bool = ..., + styling: bool = ..., + nibbles: bool = ..., deref_refs: bool = ..., actual_objects: bool = ..., static_members: bool = ..., + max_characters: int = ..., max_elements: int = ..., max_depth: int = ..., repeat_threshold: int = ..., @@ -265,7 +270,9 @@ class _FrameFilter(Protocol): enabled: bool priority: int - def filter(self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator]) -> Iterator[gdb.FrameDecorator.FrameDecorator]: ... + def filter( + self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator] + ) -> Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]: ... frame_filters: dict[str, _FrameFilter] @@ -273,7 +280,7 @@ frame_filters: dict[str, _FrameFilter] @final class PendingFrame: - def read_register(self, reg: str | RegisterDescriptor | int, /) -> Value: ... + def read_register(self, register: str | RegisterDescriptor | int) -> Value: ... def create_unwind_info(self, frame_id: object, /) -> UnwindInfo: ... def architecture(self) -> Architecture: ... def language(self): ... @@ -287,7 +294,7 @@ class PendingFrame: @final class UnwindInfo: - def add_saved_register(self, reg: str | RegisterDescriptor | int, value: Value, /) -> None: ... + def add_saved_register(self, register: str | RegisterDescriptor | int, value: Value) -> None: ... @type_check_only class _Unwinder(Protocol): @@ -314,14 +321,16 @@ class Inferior: pid: int was_attached: bool progspace: Progspace - main_name: Incomplete - arguments: Incomplete - + main_name: str | None + @property + def arguments(self) -> str | None: ... + @arguments.setter + def arguments(self, args: str | Sequence[str]) -> None: ... def is_valid(self) -> bool: ... def threads(self) -> tuple[InferiorThread, ...]: ... def architecture(self) -> Architecture: ... def read_memory(self, address: _ValueOrInt, length: int) -> memoryview: ... - def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> memoryview: ... + def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> None: ... def search_memory(self, address: _ValueOrInt, length: int, pattern: _BufferType) -> int | None: ... def thread_from_handle(self, handle: Value) -> InferiorThread: ... @deprecated("Use gdb.thread_from_handle() instead.") @@ -368,6 +377,7 @@ class Record: function_call_history: list[RecordFunctionSegment] def goto(self, instruction: Instruction, /) -> None: ... + def clear(self) -> None: ... class Instruction: pc: int @@ -477,7 +487,7 @@ class Progspace: type_printers: list[gdb.types._TypePrinter] frame_filters: dict[str, _FrameFilter] frame_unwinders: list[_Unwinder] - missing_debug_handlers: Incomplete + missing_file_handlers: Sequence[tuple[Literal["debug"], MissingDebugHandler] | tuple[Literal["file"], MissingFileHandler]] def block_for_pc(self, pc: int, /) -> Block | None: ... def find_pc_line(self, pc: int, /) -> Symtab_and_line: ... @@ -540,17 +550,17 @@ class Frame: def architecture(self) -> Architecture: ... def type(self) -> int: ... def unwind_stop_reason(self) -> int: ... - def pc(self) -> Value: ... + def pc(self) -> int: ... def block(self) -> Block: ... def function(self) -> Symbol: ... def older(self) -> Frame | None: ... def newer(self) -> Frame | None: ... def find_sal(self) -> Symtab_and_line: ... - def read_register(self, register: str | RegisterDescriptor | int, /) -> Value: ... - def read_var(self, variable: str | Symbol, /, block: Block | None = ...) -> Value: ... + def read_register(self, register: str | RegisterDescriptor | int) -> Value: ... + def read_var(self, variable: str | Symbol, block: Block | None = ...) -> Value: ... def select(self) -> None: ... def level(self) -> int: ... - def static_link(self) -> Incomplete | None: ... + def static_link(self) -> Frame | None: ... def language(self): ... # Blocks @@ -596,6 +606,7 @@ class Symbol: is_constant: bool is_function: bool is_variable: bool + is_artificial: bool def is_valid(self) -> bool: ... def value(self, frame: Frame = ..., /) -> Value: ... @@ -672,13 +683,12 @@ class LineTable: # Breakpoints class Breakpoint: - # The where="spec" form of __init__(). See py-breakpoints.c:bppy_init():keywords for the positional order. @overload def __init__( self, # where - spec: str, + spec: str = ..., # options type: int = ..., wp_class: int = ..., @@ -813,7 +823,7 @@ class Breakpoint: temporary: bool hit_count: int location: str | None - locations: Incomplete + locations: Sequence[BreakpointLocation] inferior: int | None expression: str | None condition: str | None @@ -821,13 +831,13 @@ class Breakpoint: @final class BreakpointLocation: - address: Incomplete + address: int enabled: bool fullname: str - function: Incomplete - owner: Incomplete - source: Incomplete - thread_groups: Incomplete + function: str | None + owner: Breakpoint + source: tuple[str, int] + thread_groups: Sequence[int] BP_NONE: int BP_BREAKPOINT: int @@ -920,7 +930,7 @@ class TuiWindow: def is_valid(self) -> bool: ... def erase(self) -> None: ... - def write(self, string: str, full_window: bool = ..., /) -> None: ... + def write(self, string: str, full_window: bool = ...) -> None: ... @type_check_only class _Window(Protocol): @@ -943,18 +953,19 @@ class ExitedEvent(Event): inferior: Inferior class ThreadExitedEvent(Event): ... -class StopEvent(ThreadEvent): ... + +class StopEvent(ThreadEvent): + details: dict[str, object] class BreakpointEvent(StopEvent): breakpoints: Sequence[Breakpoint] breakpoint: Breakpoint -missing_debug_handlers: list[Incomplete] - class NewObjFileEvent(Event): new_objfile: Objfile -class FreeObjFileEvent(Event): ... +class FreeObjFileEvent(Event): + objfile: Objfile class ClearObjFilesEvent(Event): progspace: Progspace @@ -1000,6 +1011,9 @@ class ConnectionEvent(Event): class ExecutableChangedEvent(Event): ... +class TuiEnabledEvent(Event): + enabled: bool + _ET = TypeVar("_ET", bound=Event | Breakpoint | None) @final @@ -1010,3 +1024,6 @@ class EventRegistry(Generic[_ET]): class ValuePrinter: ... def blocked_signals(): ... +def notify_mi(name: str, data: dict[str, object] | None = None): ... +def interrupt(): ... +def execute_mi(command: str, *args: str) -> dict[str, object]: ... diff --git a/stubs/gdb/gdb/disassembler.pyi b/stubs/gdb/gdb/disassembler.pyi index a1560c154..9310e3823 100644 --- a/stubs/gdb/gdb/disassembler.pyi +++ b/stubs/gdb/gdb/disassembler.pyi @@ -1,40 +1,41 @@ -from _typeshed import Incomplete +from collections.abc import Sequence from typing import Final, final import gdb +from gdb import Architecture, Progspace class Disassembler: def __init__(self, name: str) -> None: ... def __call__(self, info): ... class DisassembleInfo: - address: Incomplete - architecture: Incomplete - progspace: Incomplete - def __init__(self, /, *args, **kwargs) -> None: ... - def address_part(self, address) -> DisassemblerAddressPart: ... + address: int + architecture: Architecture + progspace: Progspace + def __init__(self, info: DisassembleInfo) -> None: ... + def address_part(self, address: int) -> DisassemblerAddressPart: ... def is_valid(self) -> bool: ... - def read_memory(self, len, offset: int = 0): ... - def text_part(self, string, style) -> DisassemblerTextPart: ... + def read_memory(self, len: int, offset: int = 0): ... + def text_part(self, style: int, string: str) -> DisassemblerTextPart: ... class DisassemblerPart: def __init__(self, /, *args, **kwargs) -> None: ... @final class DisassemblerAddressPart(DisassemblerPart): - address: Incomplete + address: int string: str @final class DisassemblerTextPart(DisassemblerPart): string: str - style: Incomplete + style: int @final class DisassemblerResult: - def __init__(self, /, *args, **kwargs) -> None: ... - length: Incomplete - parts: Incomplete + def __init__(self, length: int, string: str | None = None, parts: Sequence[DisassemblerPart] | None = None) -> None: ... + length: int + parts: Sequence[DisassemblerPart] string: str STYLE_TEXT: Final = 0 @@ -48,7 +49,7 @@ STYLE_ADDRESS_OFFSET: Final = 7 STYLE_SYMBOL: Final = 8 STYLE_COMMENT_START: Final = 9 -def builtin_disassemble(INFO: DisassembleInfo, MEMORY_SOURCE=None) -> None: ... +def builtin_disassemble(info: DisassembleInfo) -> None: ... class maint_info_py_disassemblers_cmd(gdb.Command): def __init__(self) -> None: ... diff --git a/stubs/gdb/gdb/events.pyi b/stubs/gdb/gdb/events.pyi index fab42e4fb..6160804bf 100644 --- a/stubs/gdb/gdb/events.pyi +++ b/stubs/gdb/gdb/events.pyi @@ -22,3 +22,4 @@ new_thread: gdb.EventRegistry[gdb.NewThreadEvent] gdb_exiting: gdb.EventRegistry[gdb.GdbExitingEvent] connection_removed: gdb.EventRegistry[gdb.ConnectionEvent] executable_changed: gdb.EventRegistry[gdb.ExecutableChangedEvent] +tui_enabled: gdb.EventRegistry[gdb.TuiEnabledEvent] diff --git a/stubs/gdb/gdb/missing_debug.pyi b/stubs/gdb/gdb/missing_debug.pyi index 81f716da2..1b9d5988f 100644 --- a/stubs/gdb/gdb/missing_debug.pyi +++ b/stubs/gdb/gdb/missing_debug.pyi @@ -1,12 +1,8 @@ -from _typeshed import Incomplete - import gdb +from gdb import Progspace +from gdb.missing_files import MissingFileHandler -class MissingDebugHandler: - @property - def name(self) -> str: ... - enabled: bool - def __init__(self, name: str) -> None: ... +class MissingDebugHandler(MissingFileHandler): def __call__(self, objfile: gdb.Objfile) -> bool | str | None: ... -def register_handler(locus: Incomplete | None, handler: MissingDebugHandler, replace: bool = False) -> None: ... +def register_handler(locus: Progspace | None, handler: MissingDebugHandler, replace: bool = False) -> None: ... diff --git a/stubs/gdb/gdb/missing_files.pyi b/stubs/gdb/gdb/missing_files.pyi new file mode 100644 index 000000000..fbc6f1131 --- /dev/null +++ b/stubs/gdb/gdb/missing_files.pyi @@ -0,0 +1,13 @@ +from typing import Literal + +from gdb import Progspace + +class MissingFileHandler: + @property + def name(self) -> str: ... + enabled: bool + def __init__(self, name: str) -> None: ... + +def register_handler( + handler_type: Literal["debug", "objfile"], locus: Progspace | None, handler: MissingFileHandler, replace: bool = False +) -> None: ... diff --git a/stubs/gdb/gdb/missing_objfile.pyi b/stubs/gdb/gdb/missing_objfile.pyi new file mode 100644 index 000000000..8e50b1c1b --- /dev/null +++ b/stubs/gdb/gdb/missing_objfile.pyi @@ -0,0 +1,7 @@ +from gdb import Progspace +from gdb.missing_files import MissingFileHandler + +class MissingObjfileHandler(MissingFileHandler): + def __call__(self, buildid: str, filename: str) -> bool | str | None: ... + +def register_handler(locus: Progspace | None, handler: MissingObjfileHandler, replace: bool = False) -> None: ...