Skip to content

update GDB stubs to 16.3 #13923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/gdb/METADATA.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
72 changes: 44 additions & 28 deletions stubs/gdb/gdb/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

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
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
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand All @@ -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 = ...,
Expand Down Expand Up @@ -263,15 +267,17 @@ 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]

# Unwinding Frames

@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): ...
Expand All @@ -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):
Expand All @@ -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.")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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 = ...,
Expand Down Expand Up @@ -811,21 +820,21 @@ class Breakpoint:
temporary: bool
hit_count: int
location: str | None
locations: Incomplete
locations: Sequence[BreakpointLocation]
inferior: int | None
expression: str | None
condition: str | None
commands: str | None

@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
Expand Down Expand Up @@ -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: ...
Expand All @@ -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
Expand Down Expand Up @@ -990,6 +1000,9 @@ class ConnectionEvent(Event):

class ExecutableChangedEvent(Event): ...

class TuiEnabledEvent(Event):
enabled: bool

_ET = TypeVar("_ET", bound=Event | Breakpoint | None)

@final
Expand All @@ -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]: ...
47 changes: 32 additions & 15 deletions stubs/gdb/gdb/disassembler.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: ...
Expand Down
1 change: 1 addition & 0 deletions stubs/gdb/gdb/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
12 changes: 4 additions & 8 deletions stubs/gdb/gdb/missing_debug.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
13 changes: 13 additions & 0 deletions stubs/gdb/gdb/missing_files.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Loading