Closed Akuli closed 7 months ago
Good idea
λ gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
...
λ gdb --quiet --nx --batch --ex 'pi import gdb; import mypy.stubtest as s; s.test_stubs(s.parse_options(["gdb", "--concise"]))'
gdb.Architecture cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Architecture.integer_type is not present at runtime
gdb.Architecture.register_groups is not present at runtime
gdb.Architecture.registers is not present at runtime
gdb.BP_CATCHPOINT is not present at runtime
gdb.BP_HARDWARE_BREAKPOINT is not present at runtime
gdb.BP_NONE is not present in stub
gdb.Block cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.BlockIterator cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Breakpoint.stop is not present at runtime
gdb.BreakpointEvent is not present in stub
gdb.COMMAND_TUI is not present at runtime
gdb.ClearObjFilesEvent is not present in stub
gdb.Command.complete is not present at runtime
gdb.Command.invoke is not present at runtime
gdb.ContinueEvent is not present in stub
gdb.DUMMY_FRAME is not present in stub
gdb.Event is not present in stub
gdb.EventRegistry is not present in stub
gdb.ExitedEvent is not present in stub
gdb.FRAME_UNWIND_FIRST_ERROR is not present at runtime
gdb.Field cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.FinishBreakpoint.out_of_scope is not present at runtime
gdb.Frame cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Frame.level is not present at runtime
gdb.Function.invoke is not present at runtime
gdb.GdbSetPythonDirectory is not present in stub
gdb.HOST_CONFIG is not present in stub
gdb.Inferior cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Inferior.thread_from_thread_handle is not present in stub
gdb.InferiorCallPostEvent is not present in stub
gdb.InferiorCallPreEvent is not present in stub
gdb.InferiorDeletedEvent is not present in stub
gdb.InferiorThread cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Instruction is not present at runtime
gdb.LazyString is not present at runtime
gdb.LineTable cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.LineTable.__next__ is not present at runtime
gdb.LineTable.is_valid is not present in stub
gdb.LineTable.source_lines is not present in stub
gdb.LineTable.source_lnes is not present at runtime
gdb.LineTableEntry cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.LineTableIterator is not present in stub
gdb.MICommand is not present at runtime
gdb.Membuf is not present in stub
gdb.MemoryChangedEvent is not present in stub
gdb.NewInferiorEvent is not present in stub
gdb.NewObjFileEvent is not present in stub
gdb.NewThreadEvent is not present in stub
gdb.Objfile cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Objfile.frame_unwinders is not present in stub
gdb.Objfile.lookup_static_method is not present at runtime
gdb.Objfile.lookup_static_symbol is not present in stub
gdb.Objfile.xmethods is not present in stub
gdb.Parameter.get_set_string is not present at runtime
gdb.Parameter.get_show_string is not present at runtime
gdb.PendingFrame cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.PendingFrame.architecture is not present at runtime
gdb.PendingFrame.level is not present at runtime
gdb.Progspace cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Progspace.frame_unwinders is not present in stub
gdb.Progspace.xmethods is not present in stub
gdb.Record is not present at runtime
gdb.RecordFunctionSegment is not present at runtime
gdb.RecordGap is not present at runtime
gdb.RecordInstruction is not present at runtime
gdb.RegisterChangedEvent is not present in stub
gdb.RegisterDescriptor is not present at runtime
gdb.RegisterDescriptorIterator is not present at runtime
gdb.RegisterGroup is not present at runtime
gdb.RegisterGroupsIterator is not present at runtime
gdb.RemoteTargetConnection is not present at runtime
gdb.SYMBOL_FUNCTIONS_DOMAIN is not present in stub
gdb.SYMBOL_LABEL_DOMAIN is not present at runtime
gdb.SYMBOL_TYPES_DOMAIN is not present in stub
gdb.SYMBOL_VARIABLES_DOMAIN is not present in stub
gdb.SignalEvent is not present in stub
gdb.StopEvent is not present in stub
gdb.Symbol cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Symtab cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Symtab_and_line cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.TARGET_CONFIG is not present in stub
gdb.TargetConnection is not present at runtime
gdb.ThreadEvent is not present in stub
gdb.TuiWindow is not present at runtime
gdb.Type cannot be subclassed at runtime, but isn't marked with @final in the stub
gdb.Type.__contains__ is not present in stub
gdb.Type.get is not present in stub
gdb.Type.has_key is not present in stub
gdb.Type.items is not present in stub
gdb.Type.iteritems is not present in stub
gdb.Type.iterkeys is not present in stub
gdb.Type.itervalues is not present in stub
gdb.Type.keys is not present in stub
gdb.Type.values is not present in stub
gdb.TypeIterator is not present in stub
gdb.Unwinder is not present at runtime
gdb.VERSION is not present in stub
gdb.Value.rvalue_reference_value is not present in stub
gdb.add_history is not present at runtime
gdb.architecture_names is not present at runtime
gdb.connections is not present at runtime
gdb.frame_filters is not present in stub
gdb.frame_unwinders is not present in stub
gdb.history_count is not present at runtime
gdb.host_charset is not present at runtime
gdb.packages is not present in stub
gdb.prompt_hook is not a function
gdb.register_window_type is not present at runtime
gdb.set_parameter is not present at runtime
gdb.solib_name is inconsistent, stub argument "address" differs from runtime argument "addr"
gdb.type_printers is not present in stub
gdb.with_parameter is not present at runtime
gdb.xmethods is not present in stub
gdb.events failed to import. Maybe install the runtime package or alter PYTHONPATH? ModuleNotFoundError: No module named 'gdb.events'
gdb.printing.RegexpCollectionPrettyPrinter.RegexpSubprinter is not present in stub
gdb.printing.add_builtin_pretty_printer is not present in stub
gdb.prompt.prompt_help is not present in stub
gdb.prompt.prompt_substitutions is not present in stub
gdb.prompt.substitute_prompt is inconsistent, stub argument "string" differs from runtime argument "prompt"
gdb.types.TypePrinter.instantiate is not present in stub
gdb.types.make_enum_dict is inconsistent, stub argument "type_" differs from runtime argument "enum_type"
gdb.unwinder.Unwinder is not present in stub
gdb.xmethod.SimpleXMethodMatcher is not present in stub
gdb.xmethod.XMethodMatcher.__init__ is inconsistent, stub does not have argument "name"
gdb.xmethod.XMethodMatcher.match is not present in stub
gdb.xmethod.XMethodWorker.__call__ is not present in stub
gdb.xmethod.XMethodWorker.get_arg_types is not present in stub
gdb.xmethod.XMethodWorker.get_result_type is not present in stub
gdb.FrameDecorator failed to find stubs
gdb.FrameIterator failed to find stubs
gdb.command failed to find stubs
gdb.command.explore failed to find stubs
gdb.command.frame_filters failed to find stubs
gdb.command.pretty_printers failed to find stubs
gdb.command.prompt failed to find stubs
gdb.command.type_printers failed to find stubs
gdb.command.unwinders failed to find stubs
gdb.command.xmethods failed to find stubs
gdb.frames failed to find stubs
gdb.function failed to find stubs
gdb.function.as_string failed to find stubs
gdb.function.caller_is failed to find stubs
gdb.function.strfns failed to find stubs
gdb.printer failed to find stubs
gdb.printer.bound_registers failed to find stubs
I modified your command a bit to make it work for me:
MYPYPATH=./stubs/gdb PYTHONPATH=./env/lib/python3.11/site-packages/ gdb --quiet --nx --batch --ex 'pi import gdb; import mypy.stubtest as s; s.test_stubs(s.parse_options(["gdb", "--concise"]))'
You could also try to do what I did to get stubtest running in uWSGI, so there's already a special case here: https://github.com/python/typeshed/blob/6fcd37456d37fddeeb5b0dc091409fc85bb6b1ce/tests/stubtest_third_party.py#L110-L113
This looks actually more simple than the uWSGI case, so I don't see why you wouldn't just generate quick wrapper script for it.
I've implemented a helper to run stubtest under gdb similar to the uWSGI special casing: https://github.com/python/typeshed/commit/cf881c29c9f16199315beef98d69f5d0f27ae863
There are numerous problems as shown in a previous comment which are flagged. What is the usual way forward now? Fix all problems at once or have incremental improvements which are easier to review? I went through the C code implementing the python bindings in gdb 12.1, which is the current version in Ubuntu 22.04, and updated the types accordingly here: https://github.com/python/typeshed/compare/main...peace-maker:typeshed:gdb-12.1-stubs I'd be happy to contribute!
Awesome! Just make a big stubtest allowlist for the first PR, so that we can focus on how the stubtest running works when reviewing.
The
gdb
"package" is a bit special. Thegdb
module only exists if you run gdb's built-in Python. You can't install it from pypi, for example.11208 contains commands to run arbitrary code in
gdb
's python interpreter. I used them to get an interactive prompt in #11209. It might be also possible to trick gdb's python into running stubtest on thegdb
stubs. It is currently skipped in CI.It might be best to just run stubtest manually once, fix all errors, and then put the commands into a comment in the stubs so we can run it later if we want to. Adding special-casing to stubtest one small and stable library doesn't sound worth the effort to me.