llvm-c166/lldb/test/Shell/Commands/command-scripting-extension-list.test
Med Ismail Bennani 514b75bbc5
[lldb/script] Improve scripting extension list output and filtering (#209400)
This patch improves `scripting extension list` in three ways.

First, it groups the output by `ScriptedExtension`: instead of one row
per registered plugin instance, one entry per extension is printed with
a combined `Language` field.

Second, it colorizes and visually separates the output. Each entry is
preceded by a dimmed dashed separator; field labels are printed in bold
green, the extension name value in bold cyan as a mini-heading, and
`None` usage values are dimmed, all via the same
`ansi::FormatAnsiTerminalCodes(..., use_color)` idiom
`Breakpoint::GetDescription` uses elsewhere, gracefully no-op when color
is disabled or unsupported. `ScriptedInterfaceUsages::Dump` takes an
optional `use_color` parameter so its own `API Usages:` / `Command
Interpreter Usages:` labels can match.

Third, it adds `-j`/`--json` to emit a JSON array of `{name,
description, languages, api_usages, command_interpreter_usages}` per
extension, mirroring `plugin list`'s existing `-j`. `DoExecute` now
computes the extension grouping once and branches into
`OutputJsonFormat` or `OutputTextFormat`, sharing a
`GetLanguagesForExtension` helper. It also accepts optional positional
`<extension-name>` arguments to filter the listing to specific
extensions (matched via the same case-insensitive
`ScriptInterpreter::StringToExtension` used by `scripting extension
generate`), with completion wired up via `eScriptedExtensionCompletion`.

Also fix a latent lifetime bug in the shared language-collection helper
so it owns its `std::string` values instead of holding `StringRef`s to
temporaries; the JSON path made it observable.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2026-07-14 15:38:47 -07:00

61 lines
2.6 KiB
Text

# REQUIRES: python
# RUN: %lldb -s %s -o exit | FileCheck %s
scripting extension list
# CHECK: Available scripted extension templates:
# The extensions are grouped by lldb::ScriptedExtension in a hash map, so
# groups are not printed in a fixed order across builds. Match each group's
# fields with CHECK-DAG instead of CHECK-NEXT.
# CHECK-DAG: Name: OperatingSystem
# CHECK-DAG: Language: Python
# CHECK-DAG: Description: Mock thread state
# CHECK-DAG: settings set target.process.python-os-plugin-path <script-path>
# CHECK-DAG: settings set process.experimental.os-plugin-reports-all-threads [0/1]
# CHECK-DAG: Name: ScriptedPlatform
# CHECK-DAG: Description: Mock platform and interact with its processes.
# CHECK-DAG: Name: ScriptedProcess
# CHECK-DAG: Description: Mock process state
# CHECK-DAG: SBAttachInfo.SetScriptedProcessClassName
# CHECK-DAG: SBAttachInfo.SetScriptedProcessDictionary
# CHECK-DAG: SBTarget.Attach
# CHECK-DAG: SBLaunchInfo.SetScriptedProcessClassName
# CHECK-DAG: SBLaunchInfo.SetScriptedProcessDictionary
# CHECK-DAG: SBTarget.Launch
# CHECK-DAG: process attach -C <script-name> [-k key -v value ...]
# CHECK-DAG: process launch -C <script-name> [-k key -v value ...]
# CHECK-DAG: Name: ScriptedThreadPlan
# CHECK-DAG: Description: Alter thread stepping logic and stop reason
# CHECK-DAG: SBThread.StepUsingScriptedThreadPlan
# CHECK-DAG: thread step-scripted -C <script-name> [-k key -v value ...]
# CHECK-DAG: Name: ScriptedBreakpointResolver
# CHECK-DAG: Description: Create a breakpoint that chooses locations based on user-created callbacks
# CHECK-DAG: SBTarget.BreakpointCreateFromScript
# CHECK-DAG: breakpoint set -P classname [-k key -v value ...]
# CHECK-DAG: Name: ScriptedFrameProvider
# CHECK-DAG: Description: Provide scripted stack frames for threads
# CHECK-DAG: SBTarget.RegisterScriptedFrameProvider
# CHECK-DAG: SBTarget.RemoveScriptedFrameProvider
# CHECK-DAG: SBTarget.ClearScriptedFrameProvider
# CHECK-DAG: target frame-provider register -C <script-name> [-k key -v value ...]
# CHECK-DAG: target frame-provider list
# CHECK-DAG: target frame-provider remove <provider-name>
# CHECK-DAG: target frame-provider clear
# CHECK-DAG: Name: ScriptedHook
# CHECK-DAG: Description: Perform actions on target lifecycle events (module load/unload, process stop).
# CHECK-DAG: target hook add -P <script-name> [-k key -v value ...]
# CHECK-DAG: Name: ScriptedThread
# CHECK-DAG: Description: Provide thread state for a scripted process.
# CHECK-DAG: Name: ScriptedFrame
# CHECK-DAG: Description: Provide frame state for scripted threads and frame providers.
scripting extension list -l lua
# CHECK: Available scripted extension templates: None