Skip to content

Commit 2dd1ef4

Browse files
authored
Update GDB stubs to 16.3 (#13923)
1 parent b88f4c1 commit 2dd1ef4

File tree

8 files changed

+94
-51
lines changed

8 files changed

+94
-51
lines changed

stubs/gdb/@tests/stubtest_allowlist.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ gdb.Progspace.xmethods
7373

7474
# stubtest thinks this can't be sub-classed at runtime, but it is
7575
gdb.disassembler.DisassemblerPart
76+
77+
gdb.TuiEnabledEvent
78+
gdb.events.tui_enabled
79+
80+
gdb.Progspace.missing_debug_handlers
81+
gdb.missing_debug_handlers
82+
gdb.missing_files
83+
gdb.missing_objfile

stubs/gdb/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "15.0.*"
1+
version = "16.3.*"
22
# This is the official web portal for the GDB Git repo,
33
# see https://sourceware.org/gdb/current/ for other ways of obtaining the source code.
44
upstream_repository = "https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree"

stubs/gdb/gdb/__init__.pyi

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
import _typeshed
66
import threading
7-
from _typeshed import Incomplete
87
from collections.abc import Callable, Iterator, Mapping, Sequence
98
from contextlib import AbstractContextManager
109
from typing import Any, Final, Generic, Literal, Protocol, TypedDict, TypeVar, final, overload, type_check_only
1110
from typing_extensions import TypeAlias, deprecated
1211

1312
import gdb.FrameDecorator
1413
import gdb.types
14+
from gdb.missing_debug import MissingDebugHandler
15+
from gdb.missing_files import MissingFileHandler
1516

1617
# The following submodules are automatically imported
1718
from . import events as events, printing as printing, prompt as prompt, types as types
@@ -46,7 +47,8 @@ def add_history(value: Value, /) -> int: ...
4647
def history_count() -> int: ...
4748
def convenience_variable(name: str, /) -> Value | None: ...
4849
def set_convenience_variable(name: str, value: _ValueOrNative | None, /) -> None: ...
49-
def parse_and_eval(expression: str, global_context: bool = False, /) -> Value: ...
50+
def parse_and_eval(expression: str, global_context: bool = False) -> Value: ...
51+
def format_address(address: int, progspace: Progspace = ..., architecture: Architecture = ...): ...
5052
def find_pc_line(pc: int | Value) -> Symtab_and_line: ...
5153
def post_event(event: Callable[[], object], /) -> None: ...
5254
def write(string: str, stream: int = ...) -> None: ...
@@ -107,7 +109,7 @@ class Value:
107109
def __ge__(self, other: _ValueOrNative, /) -> bool: ...
108110
def __getitem__(self, key: int | str | Field, /) -> Value: ...
109111
def __call__(self, *args: _ValueOrNative) -> Value: ...
110-
def __init__(self, val: _ValueOrNative) -> None: ...
112+
def __init__(self, val: _ValueOrNative, type: Type | None = None) -> None: ...
111113
def cast(self, type: Type) -> Value: ...
112114
def dereference(self) -> Value: ...
113115
def referenced_value(self) -> Value: ...
@@ -125,9 +127,12 @@ class Value:
125127
symbols: bool = ...,
126128
unions: bool = ...,
127129
address: bool = ...,
130+
styling: bool = ...,
131+
nibbles: bool = ...,
128132
deref_refs: bool = ...,
129133
actual_objects: bool = ...,
130134
static_members: bool = ...,
135+
max_characters: int = ...,
131136
max_elements: int = ...,
132137
max_depth: int = ...,
133138
repeat_threshold: int = ...,
@@ -265,15 +270,17 @@ class _FrameFilter(Protocol):
265270
enabled: bool
266271
priority: int
267272

268-
def filter(self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator]) -> Iterator[gdb.FrameDecorator.FrameDecorator]: ...
273+
def filter(
274+
self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]
275+
) -> Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]: ...
269276

270277
frame_filters: dict[str, _FrameFilter]
271278

272279
# Unwinding Frames
273280

274281
@final
275282
class PendingFrame:
276-
def read_register(self, reg: str | RegisterDescriptor | int, /) -> Value: ...
283+
def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
277284
def create_unwind_info(self, frame_id: object, /) -> UnwindInfo: ...
278285
def architecture(self) -> Architecture: ...
279286
def language(self): ...
@@ -287,7 +294,7 @@ class PendingFrame:
287294

288295
@final
289296
class UnwindInfo:
290-
def add_saved_register(self, reg: str | RegisterDescriptor | int, value: Value, /) -> None: ...
297+
def add_saved_register(self, register: str | RegisterDescriptor | int, value: Value) -> None: ...
291298

292299
@type_check_only
293300
class _Unwinder(Protocol):
@@ -314,14 +321,16 @@ class Inferior:
314321
pid: int
315322
was_attached: bool
316323
progspace: Progspace
317-
main_name: Incomplete
318-
arguments: Incomplete
319-
324+
main_name: str | None
325+
@property
326+
def arguments(self) -> str | None: ...
327+
@arguments.setter
328+
def arguments(self, args: str | Sequence[str]) -> None: ...
320329
def is_valid(self) -> bool: ...
321330
def threads(self) -> tuple[InferiorThread, ...]: ...
322331
def architecture(self) -> Architecture: ...
323332
def read_memory(self, address: _ValueOrInt, length: int) -> memoryview: ...
324-
def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> memoryview: ...
333+
def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> None: ...
325334
def search_memory(self, address: _ValueOrInt, length: int, pattern: _BufferType) -> int | None: ...
326335
def thread_from_handle(self, handle: Value) -> InferiorThread: ...
327336
@deprecated("Use gdb.thread_from_handle() instead.")
@@ -368,6 +377,7 @@ class Record:
368377
function_call_history: list[RecordFunctionSegment]
369378

370379
def goto(self, instruction: Instruction, /) -> None: ...
380+
def clear(self) -> None: ...
371381

372382
class Instruction:
373383
pc: int
@@ -477,7 +487,7 @@ class Progspace:
477487
type_printers: list[gdb.types._TypePrinter]
478488
frame_filters: dict[str, _FrameFilter]
479489
frame_unwinders: list[_Unwinder]
480-
missing_debug_handlers: Incomplete
490+
missing_file_handlers: Sequence[tuple[Literal["debug"], MissingDebugHandler] | tuple[Literal["file"], MissingFileHandler]]
481491

482492
def block_for_pc(self, pc: int, /) -> Block | None: ...
483493
def find_pc_line(self, pc: int, /) -> Symtab_and_line: ...
@@ -540,17 +550,17 @@ class Frame:
540550
def architecture(self) -> Architecture: ...
541551
def type(self) -> int: ...
542552
def unwind_stop_reason(self) -> int: ...
543-
def pc(self) -> Value: ...
553+
def pc(self) -> int: ...
544554
def block(self) -> Block: ...
545555
def function(self) -> Symbol: ...
546556
def older(self) -> Frame | None: ...
547557
def newer(self) -> Frame | None: ...
548558
def find_sal(self) -> Symtab_and_line: ...
549-
def read_register(self, register: str | RegisterDescriptor | int, /) -> Value: ...
550-
def read_var(self, variable: str | Symbol, /, block: Block | None = ...) -> Value: ...
559+
def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
560+
def read_var(self, variable: str | Symbol, block: Block | None = ...) -> Value: ...
551561
def select(self) -> None: ...
552562
def level(self) -> int: ...
553-
def static_link(self) -> Incomplete | None: ...
563+
def static_link(self) -> Frame | None: ...
554564
def language(self): ...
555565

556566
# Blocks
@@ -596,6 +606,7 @@ class Symbol:
596606
is_constant: bool
597607
is_function: bool
598608
is_variable: bool
609+
is_artificial: bool
599610

600611
def is_valid(self) -> bool: ...
601612
def value(self, frame: Frame = ..., /) -> Value: ...
@@ -672,13 +683,12 @@ class LineTable:
672683
# Breakpoints
673684

674685
class Breakpoint:
675-
676686
# The where="spec" form of __init__(). See py-breakpoints.c:bppy_init():keywords for the positional order.
677687
@overload
678688
def __init__(
679689
self,
680690
# where
681-
spec: str,
691+
spec: str = ...,
682692
# options
683693
type: int = ...,
684694
wp_class: int = ...,
@@ -813,21 +823,21 @@ class Breakpoint:
813823
temporary: bool
814824
hit_count: int
815825
location: str | None
816-
locations: Incomplete
826+
locations: Sequence[BreakpointLocation]
817827
inferior: int | None
818828
expression: str | None
819829
condition: str | None
820830
commands: str | None
821831

822832
@final
823833
class BreakpointLocation:
824-
address: Incomplete
834+
address: int
825835
enabled: bool
826836
fullname: str
827-
function: Incomplete
828-
owner: Incomplete
829-
source: Incomplete
830-
thread_groups: Incomplete
837+
function: str | None
838+
owner: Breakpoint
839+
source: tuple[str, int]
840+
thread_groups: Sequence[int]
831841

832842
BP_NONE: int
833843
BP_BREAKPOINT: int
@@ -920,7 +930,7 @@ class TuiWindow:
920930

921931
def is_valid(self) -> bool: ...
922932
def erase(self) -> None: ...
923-
def write(self, string: str, full_window: bool = ..., /) -> None: ...
933+
def write(self, string: str, full_window: bool = ...) -> None: ...
924934

925935
@type_check_only
926936
class _Window(Protocol):
@@ -943,18 +953,19 @@ class ExitedEvent(Event):
943953
inferior: Inferior
944954

945955
class ThreadExitedEvent(Event): ...
946-
class StopEvent(ThreadEvent): ...
956+
957+
class StopEvent(ThreadEvent):
958+
details: dict[str, object]
947959

948960
class BreakpointEvent(StopEvent):
949961
breakpoints: Sequence[Breakpoint]
950962
breakpoint: Breakpoint
951963

952-
missing_debug_handlers: list[Incomplete]
953-
954964
class NewObjFileEvent(Event):
955965
new_objfile: Objfile
956966

957-
class FreeObjFileEvent(Event): ...
967+
class FreeObjFileEvent(Event):
968+
objfile: Objfile
958969

959970
class ClearObjFilesEvent(Event):
960971
progspace: Progspace
@@ -1000,6 +1011,9 @@ class ConnectionEvent(Event):
10001011

10011012
class ExecutableChangedEvent(Event): ...
10021013

1014+
class TuiEnabledEvent(Event):
1015+
enabled: bool
1016+
10031017
_ET = TypeVar("_ET", bound=Event | Breakpoint | None)
10041018

10051019
@final
@@ -1010,3 +1024,6 @@ class EventRegistry(Generic[_ET]):
10101024
class ValuePrinter: ...
10111025

10121026
def blocked_signals(): ...
1027+
def notify_mi(name: str, data: dict[str, object] | None = None): ...
1028+
def interrupt(): ...
1029+
def execute_mi(command: str, *args: str) -> dict[str, object]: ...

stubs/gdb/gdb/disassembler.pyi

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1-
from _typeshed import Incomplete
1+
from collections.abc import Sequence
22
from typing import Final, final
33

44
import gdb
5+
from gdb import Architecture, Progspace
56

67
class Disassembler:
78
def __init__(self, name: str) -> None: ...
89
def __call__(self, info): ...
910

1011
class DisassembleInfo:
11-
address: Incomplete
12-
architecture: Incomplete
13-
progspace: Incomplete
14-
def __init__(self, /, *args, **kwargs) -> None: ...
15-
def address_part(self, address) -> DisassemblerAddressPart: ...
12+
address: int
13+
architecture: Architecture
14+
progspace: Progspace
15+
def __init__(self, info: DisassembleInfo) -> None: ...
16+
def address_part(self, address: int) -> DisassemblerAddressPart: ...
1617
def is_valid(self) -> bool: ...
17-
def read_memory(self, len, offset: int = 0): ...
18-
def text_part(self, string, style) -> DisassemblerTextPart: ...
18+
def read_memory(self, len: int, offset: int = 0): ...
19+
def text_part(self, style: int, string: str) -> DisassemblerTextPart: ...
1920

2021
class DisassemblerPart:
2122
def __init__(self, /, *args, **kwargs) -> None: ...
2223

2324
@final
2425
class DisassemblerAddressPart(DisassemblerPart):
25-
address: Incomplete
26+
address: int
2627
string: str
2728

2829
@final
2930
class DisassemblerTextPart(DisassemblerPart):
3031
string: str
31-
style: Incomplete
32+
style: int
3233

3334
@final
3435
class DisassemblerResult:
35-
def __init__(self, /, *args, **kwargs) -> None: ...
36-
length: Incomplete
37-
parts: Incomplete
36+
def __init__(self, length: int, string: str | None = None, parts: Sequence[DisassemblerPart] | None = None) -> None: ...
37+
length: int
38+
parts: Sequence[DisassemblerPart]
3839
string: str
3940

4041
STYLE_TEXT: Final = 0
@@ -48,7 +49,7 @@ STYLE_ADDRESS_OFFSET: Final = 7
4849
STYLE_SYMBOL: Final = 8
4950
STYLE_COMMENT_START: Final = 9
5051

51-
def builtin_disassemble(INFO: DisassembleInfo, MEMORY_SOURCE=None) -> None: ...
52+
def builtin_disassemble(info: DisassembleInfo) -> None: ...
5253

5354
class maint_info_py_disassemblers_cmd(gdb.Command):
5455
def __init__(self) -> None: ...

stubs/gdb/gdb/events.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ new_thread: gdb.EventRegistry[gdb.NewThreadEvent]
2222
gdb_exiting: gdb.EventRegistry[gdb.GdbExitingEvent]
2323
connection_removed: gdb.EventRegistry[gdb.ConnectionEvent]
2424
executable_changed: gdb.EventRegistry[gdb.ExecutableChangedEvent]
25+
tui_enabled: gdb.EventRegistry[gdb.TuiEnabledEvent]

stubs/gdb/gdb/missing_debug.pyi

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
from _typeshed import Incomplete
2-
31
import gdb
2+
from gdb import Progspace
3+
from gdb.missing_files import MissingFileHandler
44

5-
class MissingDebugHandler:
6-
@property
7-
def name(self) -> str: ...
8-
enabled: bool
9-
def __init__(self, name: str) -> None: ...
5+
class MissingDebugHandler(MissingFileHandler):
106
def __call__(self, objfile: gdb.Objfile) -> bool | str | None: ...
117

12-
def register_handler(locus: Incomplete | None, handler: MissingDebugHandler, replace: bool = False) -> None: ...
8+
def register_handler(locus: Progspace | None, handler: MissingDebugHandler, replace: bool = False) -> None: ...

stubs/gdb/gdb/missing_files.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Literal
2+
3+
from gdb import Progspace
4+
5+
class MissingFileHandler:
6+
@property
7+
def name(self) -> str: ...
8+
enabled: bool
9+
def __init__(self, name: str) -> None: ...
10+
11+
def register_handler(
12+
handler_type: Literal["debug", "objfile"], locus: Progspace | None, handler: MissingFileHandler, replace: bool = False
13+
) -> None: ...

stubs/gdb/gdb/missing_objfile.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from gdb import Progspace
2+
from gdb.missing_files import MissingFileHandler
3+
4+
class MissingObjfileHandler(MissingFileHandler):
5+
def __call__(self, buildid: str, filename: str) -> bool | str | None: ...
6+
7+
def register_handler(locus: Progspace | None, handler: MissingObjfileHandler, replace: bool = False) -> None: ...

0 commit comments

Comments
 (0)