================
@@ -660,6 +670,61 @@ class ScriptedPythonInterface : virtual public
ScriptedInterface {
return python::SWIGBridge::ToSWIGWrapper(arg);
}
+ python::PythonObject Transform(const ModuleSpec &arg) {
+ // Build an SBModuleSpec using public API setters since the constructor
+ // from ModuleSpec is private.
+ lldb::SBModuleSpec sb_module_spec;
+
+ const UUID &uuid = arg.GetUUID();
+ if (uuid.IsValid())
+ sb_module_spec.SetUUIDBytes(uuid.GetBytes().data(),
+ uuid.GetBytes().size());
+
+ const FileSpec &file = arg.GetFileSpec();
+ if (file)
+ sb_module_spec.SetFileSpec(
+ lldb::SBFileSpec(file.GetPath().c_str(), false));
+
+ const FileSpec &platform_file = arg.GetPlatformFileSpec();
+ if (platform_file)
+ sb_module_spec.SetPlatformFileSpec(
+ lldb::SBFileSpec(platform_file.GetPath().c_str(), false));
+
+ const FileSpec &symbol_file = arg.GetSymbolFileSpec();
+ if (symbol_file)
+ sb_module_spec.SetSymbolFileSpec(
+ lldb::SBFileSpec(symbol_file.GetPath().c_str(), false));
+
+ const ArchSpec &arch = arg.GetArchitecture();
+ if (arch.IsValid())
+ sb_module_spec.SetTriple(arch.GetTriple().getTriple().c_str());
+
+ ConstString object_name = arg.GetObjectName();
+ if (object_name)
+ sb_module_spec.SetObjectName(object_name.GetCString());
+
+ sb_module_spec.SetObjectOffset(arg.GetObjectOffset());
+ sb_module_spec.SetObjectSize(arg.GetObjectSize());
+
+ return python::SWIGBridge::ToSWIGWrapper(
+ std::make_unique<lldb::SBModuleSpec>(sb_module_spec));
+ }
+
+ python::PythonObject Transform(const FileSpecList &arg) {
+ python::PythonList py_list(arg.GetSize());
+ for (size_t i = 0; i < arg.GetSize(); i++) {
+ const FileSpec &fs = arg.GetFileSpecAtIndex(i);
+ py_list.SetItemAtIndex(i, python::SWIGBridge::ToSWIGWrapper(
+ std::make_unique<lldb::SBFileSpec>(
+ fs.GetPath().c_str(), false)));
+ }
+ return py_list;
+ }
----------------
medismailben wrote:
We're making extra work just to convert a C++ type to a python type. Please use
the same approach an other `Transform` methods and implement to `ToSWIGWrapper`
for ModuleSpec and FileSpecList. Thanks.
https://github.com/llvm/llvm-project/pull/181334
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits