[Lldb-commits] [lldb] [lldb] Add `scripting extension list --instances` (PR #226043)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 6 17:58:59 PDT 2026
================
@@ -416,6 +416,43 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
m_object_instance_sp = StructuredData::GenericSP(
new StructuredPythonObject(std::move(result)));
+
+ // An object handed over by the script wasn't built from the metadata,
+ // which may even describe its creator, so describe it from the object
+ // itself and don't attribute the metadata's arguments to it.
+ std::string qualified_class_name = script_obj ? "" : class_name.str();
+ FileSpec source_path =
+ script_obj ? FileSpec() : m_scripted_metadata->GetSourcePath();
+ PythonString obj_module_name =
+ obj_class.GetAttributeValue("__module__").AsType<PythonString>();
+ if (obj_module_name.IsValid()) {
+ if (qualified_class_name.empty())
+ qualified_class_name =
+ llvm::formatv("{0}.{1}", obj_module_name.GetString(),
+ obj_class_name.GetString())
+ .str();
+ if (!source_path) {
+ source_path =
+ m_interpreter.GetImportedModulePath(obj_module_name.GetString());
----------------
JDevlieghere wrote:
Does this mean that if someone did a `command script import /a/foo.py` and then later reloaded it from a different path (for example by modifying `sys.path`) that this will ignore the actual `__file__` and continue using the old one?
https://github.com/llvm/llvm-project/pull/226043
More information about the lldb-commits
mailing list