[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 5 15:26:00 PDT 2024
================
@@ -29,6 +29,9 @@ add_subdirectory(UnwindAssembly)
set(LLDB_STRIPPED_PLUGINS)
get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
+get_property(LLDB_EXTRA_PLUGINS GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS)
+list(APPEND LLDB_ALL_PLUGINS ${LLDB_EXTRA_PLUGINS})
----------------
bulbazord wrote:
I see why this doesn't work now. LLDB plugins are added to the `LLDB_PLUGINS` global property via the PLUGIN argument to `add_lldb_library`. You aren't adding the PLUGIN argument to the `add_lldb_library` invocation in `lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt`. This is how the build system knows the list of plugins.
But even if you were to remove this and add that `PLUGIN` argument, this still wouldn't work. I don't think we've explicitly documented this behavior, but LLDB expects each library to be one plugin, not three as you've done here. When LLDB creates a plugin, it's going to generate a `Plugins.def` file that LLDB uses to initialize and teardown all plugins. It has a list of entries that look like this:
`LLDB_PLUGIN(lldbPluginFooBar)`. There are some exceptions for the script interpreter plugins (not sure why, didn't check). It also expects the `LLDB_PLUGIN_DEFINE` argument to match the library name exactly (without the initial `lldbPlugin`, specifically).
The way I see it, you have three options:
1. Restructure the build so that there are 3 libraries, each one of them a plugin.
2. Change LLDB's CMake machinery to accept libraries that define multiple plugin interfaces. You'll need to modify `add_lldb_library` so that you can pass it a list of plugin interface names instead of assuming the plugin names matches the library's name.
3. Keep the workaround and document why it exists.
I would suggest (1) or (2). I think (3) is just kicking the can down the road. This is a solution that explicitly works around LLDB's existing plugin system, is difficult to discover without knowing its there, and could make future refactors more difficult.
https://github.com/llvm/llvm-project/pull/97273
More information about the lldb-commits
mailing list