diff --git a/stubs/gdb/METADATA.toml b/stubs/gdb/METADATA.toml index 475788246998..7e3ad5e22ca5 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 12e35708e867..093fecac24d7 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, TypeVar, final, overload, type_check_only @@ -12,6 +11,7 @@ from typing_extensions import TypeAlias, deprecated import gdb.FrameDecorator import gdb.types +from gdb.missing_debug import MissingDebugHandler # The following submodules are automatically imported from . import events as events, printing as printing, prompt as prompt, types as types @@ -46,7 +46,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 +108,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 +126,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 = ..., @@ -263,7 +267,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] @@ -271,7 +277,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): ... @@ -285,7 +291,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): @@ -312,14 +318,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.") @@ -366,6 +374,7 @@ class Record: function_call_history: list[RecordFunctionSegment] def goto(self, instruction: Instruction, /) -> None: ... + def clear(self) -> None: ... class Instruction: pc: int @@ -475,7 +484,7 @@ class Progspace: type_printers: list[gdb.types._TypePrinter] frame_filters: dict[str, _FrameFilter] frame_unwinders: list[_Unwinder] - missing_debug_handlers: Incomplete + missing_debug_handlers: Sequence[MissingDebugHandler] def block_for_pc(self, pc: int, /) -> Block | None: ... def find_pc_line(self, pc: int, /) -> Symtab_and_line: ... @@ -538,17 +547,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 @@ -594,6 +603,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: ... @@ -670,13 +680,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 = ..., @@ -811,7 +820,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 @@ -819,13 +828,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 @@ -912,7 +921,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: ... class _Window(Protocol): def close(self) -> None: ... @@ -934,18 +943,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 @@ -990,6 +1000,9 @@ class ConnectionEvent(Event): class ExecutableChangedEvent(Event): ... +class TuiEnabledEvent(Event): + enabled: bool + _ET = TypeVar("_ET", bound=Event | Breakpoint | None) @final @@ -1000,3 +1013,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 d4fe1ae0d511..8478cd215ac7 100644 --- a/stubs/gdb/gdb/disassembler.pyi +++ b/stubs/gdb/gdb/disassembler.pyi @@ -1,42 +1,56 @@ -from _typeshed import Incomplete -from typing import Final, final +import enum +from collections.abc import Sequence +from typing import Final, Protocol, 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: Style, 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: Style @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 +class Style(enum.IntEnum): + STYLE_TEXT = 0 + STYLE_MNEMONIC = 1 + STYLE_SUB_MNEMONIC = 2 + STYLE_ASSEMBLER_DIRECTIVE = 3 + STYLE_REGISTER = 4 + STYLE_IMMEDIATE = 5 + STYLE_ADDRESS = 6 + STYLE_ADDRESS_OFFSET = 7 + STYLE_SYMBOL = 8 + STYLE_COMMENT_START = 9 + STYLE_TEXT: Final = 0 STYLE_MNEMONIC: Final = 1 STYLE_SUB_MNEMONIC: Final = 2 @@ -48,7 +62,10 @@ STYLE_ADDRESS_OFFSET: Final = 7 STYLE_SYMBOL: Final = 8 STYLE_COMMENT_START: Final = 9 -def builtin_disassemble(INFO: DisassembleInfo, MEMORY_SOURCE: Incomplete | None = None) -> None: ... +class MemorySource(Protocol): + def read_memory(self, len: int, offset: int): ... + +def builtin_disassemble(info: DisassembleInfo, memory_source: MemorySource | None = None) -> 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 fab42e4fb73b..6160804bf485 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 81f716da27fa..1b9d5988f954 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 000000000000..fbc6f113167d --- /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: ...