Skip to content

Commit 0bb1ebf

Browse files
committed
Re-enable gdb stubtest
1 parent 4d46730 commit 0bb1ebf

12 files changed

Lines changed: 116 additions & 28 deletions

File tree

‎stubs/gdb/@tests/stubtest_allowlist.txt‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ gdb.TuiWindow
2929
gdb.command
3030
gdb.command.explore
3131
gdb.command.frame_filters
32-
gdb.command.missing_debug
32+
gdb.command.missing_files
3333
gdb.command.pretty_printers
3434
gdb.command.prompt
3535
gdb.command.type_printers
@@ -55,7 +55,6 @@ gdb.prompt.prompt_substitutions
5555

5656
# internal module to register a printer for mpx_bound128 type
5757
gdb.printer
58-
gdb.printer.bound_registers
5958

6059
gdb.printing.RegexpCollectionPrettyPrinter.RegexpSubprinter
6160
gdb.printing.add_builtin_pretty_printer
@@ -74,10 +73,35 @@ gdb.Progspace.xmethods
7473
# stubtest thinks this can't be sub-classed at runtime, but it is
7574
gdb.disassembler.DisassemblerPart
7675

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
76+
# internal sequence type returned by btrace recordings (e.g. Record.instruction_history)
77+
gdb.BtraceObjectList
78+
79+
# internal compatibility wrappers around str.isalnum() and str.isascii()
80+
gdb.missing_files.isalnum
81+
gdb.missing_files.isascii
82+
83+
# Added in GDB 17, but the stubs are for GDB 16.3
84+
gdb.COLORSPACE_AIXTERM_16COLOR
85+
gdb.COLORSPACE_ANSI_8COLOR
86+
gdb.COLORSPACE_MONOCHROME
87+
gdb.COLORSPACE_RGB_24BIT
88+
gdb.COLORSPACE_XTERM_256COLOR
89+
gdb.Color
90+
gdb.PARAM_COLOR
91+
gdb.ParameterPrefix
92+
gdb.Value.is_unavailable
93+
gdb.dap.completions
94+
gdb.dap.server.DeferredRequest.defer_events
95+
gdb.dap.server.Server.emit_pending_events
96+
gdb.dap.server.Server.set_defer_events
97+
gdb.dap.server.export_column
98+
gdb.dap.server.import_column
99+
100+
# Removed or changed in GDB 17, but the stubs are for GDB 16.3
101+
gdb.dap.server.Server.send_event
102+
gdb.dap.server.Server.send_event_later
103+
gdb.dap.server.request
104+
105+
# TODO: add stubs for these modules
106+
gdb.dap.globalvars
107+
gdb.ptwrite

‎stubs/gdb/METADATA.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ extra-description = """\
1111
"""
1212

1313
[tool.stubtest]
14-
skip = true # https://github.com/python/typeshed/issues/15236
1514
ci-platforms = ["linux"]
1615
apt-dependencies = ["gdb"]

‎stubs/gdb/gdb/__init__.pyi‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,17 @@ class Value:
9898
def __mod__(self, other: _ValueOrNative, /) -> Value: ...
9999
def __rmod__(self, other: _ValueOrNative, /) -> Value: ...
100100
def __pow__(self, other: _ValueOrNative, mod: None = None, /) -> Value: ...
101+
def __rpow__(self, other: _ValueOrNative, mod: None = None, /) -> Value: ...
101102
def __and__(self, other: _ValueOrNative, /) -> Value: ...
103+
def __rand__(self, other: _ValueOrNative, /) -> Value: ...
102104
def __or__(self, other: _ValueOrNative, /) -> Value: ...
105+
def __ror__(self, other: _ValueOrNative, /) -> Value: ...
103106
def __xor__(self, other: _ValueOrNative, /) -> Value: ...
107+
def __rxor__(self, other: _ValueOrNative, /) -> Value: ...
104108
def __lshift__(self, other: _ValueOrNative, /) -> Value: ...
109+
def __rlshift__(self, other: _ValueOrNative, /) -> Value: ...
105110
def __rshift__(self, other: _ValueOrNative, /) -> Value: ...
111+
def __rrshift__(self, other: _ValueOrNative, /) -> Value: ...
106112
def __eq__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
107113
def __ne__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
108114
def __lt__(self, other: _ValueOrNative, /) -> bool: ...
@@ -403,8 +409,13 @@ class RecordInstruction(Instruction):
403409

404410
class RecordGap(Instruction):
405411
number: int
406-
error_code: int
407-
error_string: str
412+
reason_code: int
413+
reason_string: str
414+
415+
@final
416+
class RecordAuxiliary:
417+
number: int
418+
data: str
408419

409420
class RecordFunctionSegment:
410421
number: int
@@ -493,6 +504,8 @@ class Function:
493504
def current_progspace() -> Progspace | None: ...
494505
def progspaces() -> Sequence[Progspace]: ...
495506

507+
missing_file_handlers: Sequence[tuple[Literal["debug"], MissingDebugHandler] | tuple[Literal["file"], MissingFileHandler]]
508+
496509
@final
497510
class Progspace:
498511
executable_filename: str | None
@@ -593,6 +606,7 @@ class Block:
593606
static_block: Block | None
594607
is_global: bool
595608
is_static: bool
609+
subblocks: list[Block]
596610

597611
def is_valid(self) -> bool: ...
598612
def __iter__(self) -> BlockIterator: ...
@@ -625,6 +639,7 @@ class Symbol:
625639
is_function: bool
626640
is_variable: bool
627641
is_artificial: bool
642+
domain: int
628643

629644
def is_valid(self) -> bool: ...
630645
def value(self, frame: Frame = ..., /) -> Value: ...
@@ -903,6 +918,7 @@ class Architecture:
903918
def name(self) -> str: ...
904919
def disassemble(self, start_pc: int, end_pc: int = ..., count: int = ...) -> list[_Instruction]: ...
905920
def integer_type(self, size: int, signed: bool = ...) -> Type: ...
921+
def void_type(self) -> Type: ...
906922
def registers(self, reggroup: str = ...) -> RegisterDescriptorIterator: ...
907923
def register_groups(self) -> RegisterGroupsIterator: ...
908924

‎stubs/gdb/gdb/dap/events.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def send_process_event_once() -> None: ...
66
def expect_process(reason: str) -> None: ...
77
def thread_event(event: gdb.ThreadEvent, reason: str) -> None: ...
88
def expect_stop(reason: str) -> None: ...
9-
def exec_and_expect_stop(cmd: str, expected_pause: bool = False) -> None: ...
9+
def exec_and_expect_stop(cmd: str, expected_pause: bool = False, propagate_exception: bool = False) -> None: ...
1010

1111
# Map from gdb stop reasons to DAP stop reasons.
1212
stop_reason_map: dict[str, str]

‎stubs/gdb/gdb/dap/frames.pyi‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ from collections.abc import Generator
22

33
import gdb
44

5+
thread_ids: dict[int, int] = {}
6+
57
def frame_for_id(id: int) -> gdb.Frame: ...
68
def select_frame(id: int) -> None: ...
79
def dap_frame_generator(frame_low: int, levels: int, include_all: bool) -> Generator[tuple[int, gdb.Frame]]: ...

‎stubs/gdb/gdb/dap/launch.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ def launch(
1212
): ...
1313
def attach(*, program: str | None = None, pid: int | None = None, target: str | None = None, **args: Unused) -> None: ...
1414
def config_done(**args: Unused) -> None: ...
15+
def file_command(program: str) -> None: ...

‎stubs/gdb/gdb/dap/scopes.pyi‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,19 @@ def symbol_value(sym: SymValueWrapper, frame: FrameDecorator) -> tuple[str, gdb.
2727

2828
class _ScopeReference(BaseReference):
2929
hint: str
30-
frame: FrameDecorator
31-
inf_frame: gdb.Frame
32-
function: str | None
33-
line: int | None
30+
frameId: int
3431
var_list: tuple[SymValueWrapper, ...]
35-
def __init__(self, name: str, hint: str, frame: FrameDecorator, var_list: Iterable[SymValueWrapper]) -> None: ...
32+
def __init__(self, name: str, hint: str, frameId: int, var_list: Iterable[SymValueWrapper]) -> None: ...
3633
def to_object(self) -> _ScopeReferenceDescriptor: ...
3734
def has_children(self) -> bool: ...
3835
def child_count(self) -> int: ...
3936
# note: parameter named changed from 'index' to 'idx'
4037
def fetch_one_child(self, idx: int) -> tuple[str, gdb.Value]: ...
4138

42-
class _FinishScopeReference(_ScopeReference): ...
39+
class _FinishScopeReference(_ScopeReference):
40+
def __init__(self, frameId: int) -> None: ...
4341

4442
class _RegisterReference(_ScopeReference):
45-
def __init__(self, name: str, frame: FrameDecorator) -> None: ...
43+
def __init__(self, name: str, frameId: int) -> None: ...
4644

4745
def scopes(*, frameId: int, **extra: Unused) -> _ScopesResult: ...

‎stubs/gdb/gdb/dap/server.pyi‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ _RequestID: TypeAlias = int
1414
_EventBody: TypeAlias = Any # arbitrary object, implicitly constrained by the event being sent
1515
_JSONValue: TypeAlias = Any # any object that can be handled by json.dumps/json.loads
1616

17+
class DeferredRequest:
18+
def set_request(self, req: _RequestID, result: dict[str, Any]) -> None: ...
19+
def invoke(self) -> _JSONValue | None: ...
20+
def reschedule(self) -> None: ...
21+
1722
class NotStoppedException(Exception): ...
1823

1924
class CancellationHandler:
20-
lock: threading.Lock
25+
lock: threading.RLock
2126
reqs: list[_RequestID]
2227
in_flight_dap_thread: _RequestID | None
2328
in_flight_gdb_thread: _RequestID | None
24-
def starting(self, req: _RequestID) -> None: ...
25-
def done(self, req: _RequestID) -> None: ... # req argument is not used
29+
deferred_ids: set[_RequestID]
30+
def current_request(self, req: _RequestID) -> AbstractContextManager[None]: ...
31+
def defer_request(self, req: _RequestID) -> None: ...
32+
def request_finished(self, req: _RequestID) -> None: ...
33+
def check_cancel(self, req: _RequestID) -> None: ...
2634
def cancel(self, req: _RequestID) -> None: ...
2735
def interruptable_region(self, req: _RequestID | None) -> AbstractContextManager[None]: ...
2836

@@ -42,20 +50,26 @@ class Server:
4250
out_stream: _SupportsWriteAndFlushBytes,
4351
child_stream: SupportsReadline[str],
4452
) -> None: ...
53+
def call_function_later(self, fn: Callable[[], DeferredRequest | _JSONValue | None]) -> None: ...
54+
def invoke_request(self, req: _RequestID, result: dict[str, Any], fn: Callable[[], object]) -> None: ...
4555
def main_loop(self) -> None: ...
4656
def send_event(self, event: str, body: _EventBody | None = None) -> None: ...
4757
def send_event_later(self, event: str, body: _EventBody | None = None) -> None: ...
58+
def send_event_maybe_later(self, event: str, body: _EventBody | None = None) -> None: ...
4859
def shutdown(self) -> None: ...
4960

5061
def send_event(event: str, body: _EventBody | None = None) -> None: ...
62+
def call_function_later(fn: Callable[[], object]) -> None: ...
63+
def export_line(line: int) -> int: ...
64+
def import_line(line: int) -> int: ...
5165

5266
@type_check_only
5367
class _Wrapper:
5468
def __call__(self, func: _F) -> _F: ...
5569

5670
def request(name: str, *, response: bool = True, on_dap_thread: bool = False, expect_stopped: bool = True) -> _Wrapper: ...
5771
def capability(name: str, value: bool = True) -> _Wrapper: ...
58-
def client_bool_capability(name: str) -> bool: ...
72+
def client_bool_capability(name: str, default: bool = False) -> bool: ...
5973
def initialize(**args) -> dict[str, bool]: ... # args is arbitrary values for Server.config
6074
def terminate(**args: Unused) -> None: ...
6175
def disconnect(*, terminateDebuggee: bool = False, **args: Unused): ...

‎stubs/gdb/gdb/dap/sources.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class _LoadSourcesResult(TypedDict):
1717
class _SourceResult(TypedDict):
1818
content: str
1919

20-
def make_source(fullname: str, filename: str | None) -> Source: ...
20+
def make_source(fullname: str, filename: str | None = None) -> Source: ...
2121
def decode_source(source: Source) -> _SourceReferenceID: ...
2222
def loaded_sources(**extra: Unused) -> _LoadSourcesResult: ...
2323
def source(*, source: Source | None = None, sourceReference: _SourceReferenceID, **extra: Unused) -> _SourceResult: ...

‎stubs/gdb/gdb/dap/startup.pyi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ dap_log: LoggingParam
4040
def log(something: object, level: LogLevel = LogLevel.DEFAULT) -> None: ...
4141
def thread_log(something: object, level: LogLevel = LogLevel.DEFAULT) -> None: ...
4242
def log_stack(level: LogLevel = LogLevel.DEFAULT) -> None: ...
43-
def exec_and_log(cmd: str) -> None: ...
43+
def exec_and_log(cmd: str, propagate_exception: bool = False) -> None: ...
44+
def exec_mi_and_log(*args: str) -> dict[str, object]: ...

0 commit comments

Comments
 (0)