mirror-llvm-project/lldb/unittests
Med Ismail Bennani 1ac9b999f8
[lldb] Reimplement PythonCallable::GetArgInfo without executing Python code (#213378)
`b05a5d0a` added an arity-trimming step to the shared
`ScriptedPythonInterface::Dispatch`: extensions are now allowed to
define methods with trailing parameters as optional
(`num_children(self)` vs. `num_children(self, max_count)`), so before
calling into a method, `Dispatch` needs to know how many positional
arguments it actually accepts and drop any trailing ones we'd otherwise
pass.

That check calls `PythonCallable::GetArgInfo`, which ran a whole
embedded Python script through `inspect.signature` on every call, since
every scripted-extension dispatch goes through it.

For the common case `GetArgInfo()` actually needs to handle fast (plain
Python functions/methods, classes used as constructors, and callable
instances defining `__call__`, i.e. everything `Dispatch<T>()` and
`CreatePluginObject()` ever pass it), the answer is available as plain
data attributes, with no Python bytecode execution required:
`__func__`/`__self__` to unwrap bound methods, and `__code__`'s
`co_argcount`/`co_flags` for the actual positional-argument count and
varargs bit. For a class, that means `__init__` -- except a class may
customize `__new__` instead and leave `__init__` untouched, in which
case `object.__init__` becomes lenient about extra arguments.

Anything else still lacking `__code__` can fall back to the original
`inspect.signature()`-based implementation, now exposed as
`PythonCallable::GetArgInfoFromInspectSignature()` so it can be used
separately.

rdar://183776556

---------

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2026-08-01 16:23:21 -07:00
..
ABI [lldb] Implement LLDB_REGNUM_GENERIC_TP conversion for Aarch64 (#208643) 2026-07-10 10:35:14 +01:00
API [lldb] Add SBProtocolServer to start protocol servers programmatically (#209923) 2026-07-17 13:06:03 -05:00
Architecture [RISCV][LLDB] Add RISC-V Architecture plugin for trap validation (#207675) 2026-07-07 13:39:44 +05:30
Breakpoint [lldb] Remove unnecessary LINK_LIBS in LLDBBreakpointTests (NFC) 2025-10-08 13:59:51 -07:00
Callback [lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583) 2025-06-04 11:33:37 +02:00
Core [lldb] Fix Unicode code point formatting to use proper notation (#211131) 2026-07-22 09:39:02 -07:00
DAP [lldb-dap] Fix typo in StepInTarget serialization (#199907) 2026-05-27 17:08:38 +03:00
DataFormatter [lldb][test] Reinforce formatter bytecode unit tests (#211042) 2026-07-22 14:55:39 -07:00
debugserver [lldb] Gracefully handle sockets being unavailable (#194712) 2026-04-28 16:27:10 -07:00
Disassembler [lldb] Don't build an opcode from a failed disassembly (#208279) 2026-07-13 12:53:40 +01:00
Editline [lldb] Apply pending terminal resize before repainting the prompt (#203045) 2026-06-18 16:24:41 -07:00
Expression [lldb][NFC] Explicitly list unsupported DWARF expression opcodes (#210363) 2026-07-29 20:05:10 +08:00
Highlighter [lldb] Add tree-sitter based Rust syntax highlighting (#181282) 2026-02-18 13:54:14 -08:00
Host [lldb] Reply to malformed requests and use JSON-RPC error codes (#212678) 2026-07-29 11:12:30 -07:00
Instruction [lldb] Fix ARM STR T1 encoding using subtract instead of add, add test (#188614) 2026-04-07 13:02:15 -05:00
Interpreter [lldb] Assert that CommandObject::DoExecute sets a return status (#197796) 2026-05-15 10:15:19 -07:00
Language [lldb] Support MS style struct/class in C++ name parser (#196525) 2026-07-07 21:47:33 +02:00
ObjectContainer [lldb][Mach-O] Bounds-check GetArchitectureAtIndex against m_fat_archs (#205289) 2026-06-24 14:41:38 -07:00
ObjectFile [lldb][Mach-O] Fix null __LINKEDIT deref in ParseSymtab for shared cache images (#207448) 2026-07-27 16:20:24 +01:00
OperatingSystem [lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583) 2025-06-04 11:33:37 +02:00
Platform [lldb] Gracefully handle sockets being unavailable (#194712) 2026-04-28 16:27:10 -07:00
Process [lldb] Contribute the GDB-remote packet history to diagnostics bundles (#210418) 2026-07-17 18:35:26 -05:00
Protocol [lldb] Add MCP tools to create and destroy debugger instances (#209288) 2026-07-14 16:43:53 -07:00
SBTestingSupport [LLDB] Add SB API test helpers in separate library (#185866) 2026-03-12 19:18:47 +01:00
ScriptInterpreter [lldb] Reimplement PythonCallable::GetArgInfo without executing Python code (#213378) 2026-08-01 16:23:21 -07:00
Signals [lldb] Show signal number description (#164176) 2025-11-24 11:59:05 +00:00
Symbol [lldb][NFC] Use make_shared when creating Sections (#210196) 2026-07-20 14:04:07 -07:00
SymbolFile [lldb] Fix SymbolFilePDBTests build for StringRef FileSpec getters (#208857) 2026-07-10 23:56:07 +00:00
Target [lldb] Fix stale L1 memory cache read after memory write (#208347) 2026-07-30 10:10:28 +01:00
TestingSupport [lldb] Add an MCP client and asynchronous request binding (#208371) 2026-07-09 17:06:22 -07:00
Thread [lldb] Keep the unexpected b/p state for suspended threads (#174264) 2026-01-08 14:11:35 -08:00
tools Revert "[lldb] Remove ConstString from FileSpec" (#211927) 2026-07-24 21:24:12 +00:00
UnwindAssembly [lldb] Handle backwards branches in UnwindAssemblyInstEmulation (#169633) 2025-12-03 10:43:48 +00:00
Utility [lldb] Add a unit test for Wasm architecture compatibility (#213070) 2026-07-30 13:29:28 -07:00
ValueObject Reapply "[LLDB] Add ScalarLiteralNode and literal parsing in DIL" (#155610) 2025-08-27 17:49:55 +05:00
CMakeLists.txt [RISCV][LLDB] Add RISC-V Architecture plugin for trap validation (#207675) 2026-07-07 13:39:44 +05:30
gtest_common.h