[Lldb-commits] [lldb] 7897d92 - [lldb][CommandObjectType] Print name of Python class when emitting warning about invalid synthetic provider (#181829)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 18 00:47:19 PST 2026
Author: Michael Buch
Date: 2026-02-18T08:47:14Z
New Revision: 7897d928be14089870469342d497a822befaf39d
URL: https://github.com/llvm/llvm-project/commit/7897d928be14089870469342d497a822befaf39d
DIFF: https://github.com/llvm/llvm-project/commit/7897d928be14089870469342d497a822befaf39d.diff
LOG: [lldb][CommandObjectType] Print name of Python class when emitting warning about invalid synthetic provider (#181829)
Before:
```
(lldb) type synthetic add -l blah foo
warning: The provided class does not exist - please define it before attempting to use this synthetic provider
```
After:
```
(lldb) type synthetic add -l blah foo
warning: The provided class 'blah' does not exist - please define it before attempting to use this synthetic provider
```
Useful when many of these registration commands happen as part of
`~/.lldbinit`. Previously it wasn't immediately obvious which of those
commands failed.
Added:
lldb/test/Shell/Commands/command-type-synthetic-add.test
Modified:
lldb/source/Commands/CommandObjectType.cpp
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 6e79d69b5a0a6..bd03cb8fe6516 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2181,10 +2181,12 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass(
ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
- if (interpreter &&
- !interpreter->CheckObjectExists(impl->GetPythonClassName()))
- result.AppendWarning("The provided class does not exist - please define it "
- "before attempting to use this synthetic provider");
+ const char *python_class_name = impl->GetPythonClassName();
+ if (interpreter && !interpreter->CheckObjectExists(python_class_name))
+ result.AppendWarningWithFormatv(
+ "The provided class '{0}' does not exist - please define it "
+ "before attempting to use this synthetic provider",
+ llvm::StringRef(python_class_name));
// now I have a valid provider, let's add it to every type
diff --git a/lldb/test/Shell/Commands/command-type-synthetic-add.test b/lldb/test/Shell/Commands/command-type-synthetic-add.test
new file mode 100644
index 0000000000000..3b1c8458e48e1
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-type-synthetic-add.test
@@ -0,0 +1,6 @@
+# REQUIRES: python
+
+# RUN: %lldb -b -o 'type synthetic add --python-class blah blah-name' 2>&1 | FileCheck %s
+
+# CHECK: (lldb) type synthetic
+# CHECK-NEXT: The provided class 'blah' does not exist
More information about the lldb-commits
mailing list