Skip to content

Commit 89451e3

Browse files
committed
update GDB stubs to 16.3
1 parent a46eea7 commit 89451e3

File tree

5 files changed

+94
-51
lines changed

5 files changed

+94
-51
lines changed

stubs/gdb/gdb/__init__.pyi

+44-28
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
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, 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
1515

1616
# The following submodules are automatically imported
1717
from . import events as events, printing as printing, prompt as prompt, types as types
@@ -46,7 +46,8 @@ def add_history(value: Value, /) -> int: ...
4646
def history_count() -> int: ...
4747
def convenience_variable(name: str, /) -> Value | None: ...
4848
def set_convenience_variable(name: str, value: _ValueOrNative | None, /) -> None: ...
49-
def parse_and_eval(expression: str, global_context: bool = False, /) -> Value: ...
49+
def parse_and_eval(expression: str, global_context: bool = False) -> Value: ...
50+
def format_address(address: int, progspace: Progspace = ..., architecture: Architecture = ...): ...
5051
def find_pc_line(pc: int | Value) -> Symtab_and_line: ...
5152
def post_event(event: Callable[[], object], /) -> None: ...
5253
def write(string: str, stream: int = ...) -> None: ...
@@ -107,7 +108,7 @@ class Value:
107108
def __ge__(self, other: _ValueOrNative) -> bool: ...
108109
def __getitem__(self, key: int | str | Field) -> Value: ...
109110
def __call__(self, *args: _ValueOrNative) -> Value: ...
110-
def __init__(self, val: _ValueOrNative) -> None: ...
111+
def __init__(self, val: _ValueOrNative, type: Type | None = None) -> None: ...
111112
def cast(self, type: Type) -> Value: ...
112113
def dereference(self) -> Value: ...
113114
def referenced_value(self) -> Value: ...
@@ -125,9 +126,12 @@ class Value:
125126
symbols: bool = ...,
126127
unions: bool = ...,
127128
address: bool = ...,
129+
styling: bool = ...,
130+
nibbles: bool = ...,
128131
deref_refs: bool = ...,
129132
actual_objects: bool = ...,
130133
static_members: bool = ...,
134+
max_characters: int = ...,
131135
max_elements: int = ...,
132136
max_depth: int = ...,
133137
repeat_threshold: int = ...,
@@ -263,15 +267,17 @@ class _FrameFilter(Protocol):
263267
enabled: bool
264268
priority: int
265269

266-
def filter(self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator]) -> Iterator[gdb.FrameDecorator.FrameDecorator]: ...
270+
def filter(
271+
self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]
272+
) -> Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]: ...
267273

268274
frame_filters: dict[str, _FrameFilter]
269275

270276
# Unwinding Frames
271277

272278
@final
273279
class PendingFrame:
274-
def read_register(self, reg: str | RegisterDescriptor | int, /) -> Value: ...
280+
def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
275281
def create_unwind_info(self, frame_id: object, /) -> UnwindInfo: ...
276282
def architecture(self) -> Architecture: ...
277283
def language(self): ...
@@ -285,7 +291,7 @@ class PendingFrame:
285291

286292
@final
287293
class UnwindInfo:
288-
def add_saved_register(self, reg: str | RegisterDescriptor | int, value: Value, /) -> None: ...
294+
def add_saved_register(self, register: str | RegisterDescriptor | int, value: Value) -> None: ...
289295

290296
@type_check_only
291297
class _Unwinder(Protocol):
@@ -312,14 +318,16 @@ class Inferior:
312318
pid: int
313319
was_attached: bool
314320
progspace: Progspace
315-
main_name: Incomplete
316-
arguments: Incomplete
317-
321+
main_name: str | None
322+
@property
323+
def arguments(self) -> str | None: ...
324+
@arguments.setter
325+
def arguments(self, args: str | Sequence[str]) -> None: ...
318326
def is_valid(self) -> bool: ...
319327
def threads(self) -> tuple[InferiorThread, ...]: ...
320328
def architecture(self) -> Architecture: ...
321329
def read_memory(self, address: _ValueOrInt, length: int) -> memoryview: ...
322-
def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> memoryview: ...
330+
def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> None: ...
323331
def search_memory(self, address: _ValueOrInt, length: int, pattern: _BufferType) -> int | None: ...
324332
def thread_from_handle(self, handle: Value) -> InferiorThread: ...
325333
@deprecated("Use gdb.thread_from_handle() instead.")
@@ -366,6 +374,7 @@ class Record:
366374
function_call_history: list[RecordFunctionSegment]
367375

368376
def goto(self, instruction: Instruction, /) -> None: ...
377+
def clear(self) -> None: ...
369378

370379
class Instruction:
371380
pc: int
@@ -475,7 +484,7 @@ class Progspace:
475484
type_printers: list[gdb.types._TypePrinter]
476485
frame_filters: dict[str, _FrameFilter]
477486
frame_unwinders: list[_Unwinder]
478-
missing_debug_handlers: Incomplete
487+
missing_debug_handlers: Sequence[MissingDebugHandler]
479488

480489
def block_for_pc(self, pc: int, /) -> Block | None: ...
481490
def find_pc_line(self, pc: int, /) -> Symtab_and_line: ...
@@ -538,17 +547,17 @@ class Frame:
538547
def architecture(self) -> Architecture: ...
539548
def type(self) -> int: ...
540549
def unwind_stop_reason(self) -> int: ...
541-
def pc(self) -> Value: ...
550+
def pc(self) -> int: ...
542551
def block(self) -> Block: ...
543552
def function(self) -> Symbol: ...
544553
def older(self) -> Frame | None: ...
545554
def newer(self) -> Frame | None: ...
546555
def find_sal(self) -> Symtab_and_line: ...
547-
def read_register(self, register: str | RegisterDescriptor | int, /) -> Value: ...
548-
def read_var(self, variable: str | Symbol, /, block: Block | None = ...) -> Value: ...
556+
def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
557+
def read_var(self, variable: str | Symbol, block: Block | None = ...) -> Value: ...
549558
def select(self) -> None: ...
550559
def level(self) -> int: ...
551-
def static_link(self) -> Incomplete | None: ...
560+
def static_link(self) -> Frame | None: ...
552561
def language(self): ...
553562

554563
# Blocks
@@ -594,6 +603,7 @@ class Symbol:
594603
is_constant: bool
595604
is_function: bool
596605
is_variable: bool
606+
is_artificial: bool
597607

598608
def is_valid(self) -> bool: ...
599609
def value(self, frame: Frame = ..., /) -> Value: ...
@@ -670,13 +680,12 @@ class LineTable:
670680
# Breakpoints
671681

672682
class Breakpoint:
673-
674683
# The where="spec" form of __init__(). See py-breakpoints.c:bppy_init():keywords for the positional order.
675684
@overload
676685
def __init__(
677686
self,
678687
# where
679-
spec: str,
688+
spec: str = ...,
680689
# options
681690
type: int = ...,
682691
wp_class: int = ...,
@@ -811,21 +820,21 @@ class Breakpoint:
811820
temporary: bool
812821
hit_count: int
813822
location: str | None
814-
locations: Incomplete
823+
locations: Sequence[BreakpointLocation]
815824
inferior: int | None
816825
expression: str | None
817826
condition: str | None
818827
commands: str | None
819828

820829
@final
821830
class BreakpointLocation:
822-
address: Incomplete
831+
address: int
823832
enabled: bool
824833
fullname: str
825-
function: Incomplete
826-
owner: Incomplete
827-
source: Incomplete
828-
thread_groups: Incomplete
834+
function: str | None
835+
owner: Breakpoint
836+
source: tuple[str, int]
837+
thread_groups: Sequence[int]
829838

830839
BP_NONE: int
831840
BP_BREAKPOINT: int
@@ -912,7 +921,7 @@ class TuiWindow:
912921

913922
def is_valid(self) -> bool: ...
914923
def erase(self) -> None: ...
915-
def write(self, string: str, full_window: bool = ..., /) -> None: ...
924+
def write(self, string: str, full_window: bool = ...) -> None: ...
916925

917926
class _Window(Protocol):
918927
def close(self) -> None: ...
@@ -934,18 +943,19 @@ class ExitedEvent(Event):
934943
inferior: Inferior
935944

936945
class ThreadExitedEvent(Event): ...
937-
class StopEvent(ThreadEvent): ...
946+
947+
class StopEvent(ThreadEvent):
948+
details: dict[str, object]
938949

939950
class BreakpointEvent(StopEvent):
940951
breakpoints: Sequence[Breakpoint]
941952
breakpoint: Breakpoint
942953

943-
missing_debug_handlers: list[Incomplete]
944-
945954
class NewObjFileEvent(Event):
946955
new_objfile: Objfile
947956

948-
class FreeObjFileEvent(Event): ...
957+
class FreeObjFileEvent(Event):
958+
objfile: Objfile
949959

950960
class ClearObjFilesEvent(Event):
951961
progspace: Progspace
@@ -990,6 +1000,9 @@ class ConnectionEvent(Event):
9901000

9911001
class ExecutableChangedEvent(Event): ...
9921002

1003+
class TuiEnabledEvent(Event):
1004+
enabled: bool
1005+
9931006
_ET = TypeVar("_ET", bound=Event | Breakpoint | None)
9941007

9951008
@final
@@ -1000,3 +1013,6 @@ class EventRegistry(Generic[_ET]):
10001013
class ValuePrinter: ...
10011014

10021015
def blocked_signals(): ...
1016+
def notify_mi(name: str, data: dict[str, object] | None = None): ...
1017+
def interrupt(): ...
1018+
def execute_mi(command: str, *args: str) -> dict[str, object]: ...

stubs/gdb/gdb/disassembler.pyi

+32-15
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,56 @@
1-
from _typeshed import Incomplete
2-
from typing import Final, final
1+
import enum
2+
from collections.abc import Sequence
3+
from typing import Final, Protocol, final
34

45
import gdb
6+
from gdb import Architecture, Progspace
57

68
class Disassembler:
79
def __init__(self, name: str) -> None: ...
810
def __call__(self, info): ...
911

1012
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: ...
13+
address: int
14+
architecture: Architecture
15+
progspace: Progspace
16+
def __init__(self, info: DisassembleInfo) -> None: ...
17+
def address_part(self, address: int) -> DisassemblerAddressPart: ...
1618
def is_valid(self) -> bool: ...
17-
def read_memory(self, len, offset: int = 0): ...
18-
def text_part(self, string, style) -> DisassemblerTextPart: ...
19+
def read_memory(self, len: int, offset: int = 0): ...
20+
def text_part(self, style: Style, string: str) -> DisassemblerTextPart: ...
1921

2022
class DisassemblerPart:
2123
def __init__(self, /, *args, **kwargs) -> None: ...
2224

2325
@final
2426
class DisassemblerAddressPart(DisassemblerPart):
25-
address: Incomplete
27+
address: int
2628
string: str
2729

2830
@final
2931
class DisassemblerTextPart(DisassemblerPart):
3032
string: str
31-
style: Incomplete
33+
style: Style
3234

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

42+
class Style(enum.IntEnum):
43+
STYLE_TEXT = 0
44+
STYLE_MNEMONIC = 1
45+
STYLE_SUB_MNEMONIC = 2
46+
STYLE_ASSEMBLER_DIRECTIVE = 3
47+
STYLE_REGISTER = 4
48+
STYLE_IMMEDIATE = 5
49+
STYLE_ADDRESS = 6
50+
STYLE_ADDRESS_OFFSET = 7
51+
STYLE_SYMBOL = 8
52+
STYLE_COMMENT_START = 9
53+
4054
STYLE_TEXT: Final = 0
4155
STYLE_MNEMONIC: Final = 1
4256
STYLE_SUB_MNEMONIC: Final = 2
@@ -48,7 +62,10 @@ STYLE_ADDRESS_OFFSET: Final = 7
4862
STYLE_SYMBOL: Final = 8
4963
STYLE_COMMENT_START: Final = 9
5064

51-
def builtin_disassemble(INFO: DisassembleInfo, MEMORY_SOURCE: Incomplete | None = None) -> None: ...
65+
class MemorySource(Protocol):
66+
def read_memory(self, len: int, offset: int): ...
67+
68+
def builtin_disassemble(info: DisassembleInfo, memory_source: MemorySource | None = None) -> None: ...
5269

5370
class maint_info_py_disassemblers_cmd(gdb.Command):
5471
def __init__(self) -> None: ...

stubs/gdb/gdb/events.pyi

+1
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

+4-8
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

+13
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: ...

0 commit comments

Comments
 (0)