I think this is the function we are going to hack:
int PluginManager::ScanForPlugins(const wxString& path)
{
static const wxString PluginsMask = platform::windows ? _T("*.dll")
: (platform::darwin || platform::macosx) ? _T("*.dylib")
: _T("*.so");
int count = 0;
if (!wxDirExists(path))
return count;
wxDir dir(path);
if (!dir.IsOpened())
return count;
bool batch = Manager::IsBatchBuild();
wxArrayString bbplugins;
if (batch)
bbplugins = cbReadBatchBuildPlugins();
wxString filename;
wxString failed;
bool ok = dir.GetFirst(&filename, PluginsMask, wxDIR_FILES);
while (ok)
{
if (batch)
{
// for batch builds, we will load only those plugins that the
// user has set (default only compiler.dll)
bool matched = false;
for (size_t i = 0; i < bbplugins.GetCount(); ++i)
{
if (bbplugins[i] == filename)
{
matched = true;
break;
}
}
if (!matched)
{
ok = dir.GetNext(&filename);
continue;
}
}
// load manifest
m_pCurrentlyLoadingManifestDoc = nullptr;
if (ReadManifestFile(filename))
{
if (LoadPlugin(path + wxFILE_SEP_PATH + filename))
++count;
else
failed << _T('\n') << filename;
}
if (m_pCurrentlyLoadingManifestDoc)
{
delete m_pCurrentlyLoadingManifestDoc;
m_pCurrentlyLoadingManifestDoc = nullptr;
}
ok = dir.GetNext(&filename);
}
Manager::Get()->GetLogManager()->Log(F(_("Loaded %d plugins"), count));
if (!failed.IsEmpty())
{
InfoWindow::Display(_("Warning"),
_("One or more plugins were not loaded.\n"
"This usually happens when a plugin is built for\n"
"a different version of the Code::Blocks SDK.\n"
"Check the application log for more info.\n\n"
"List of failed plugins:\n") + failed,
15000, 3000);
}
return count;
}
I think if we can add another option, such as:
if (batch or debugging_plugin_mode)
bbplugins = cbReadBatchBuildPlugins();
We can only load a minimal set of the plugins.
What do you think of this idea?
From cf00e61a5c44ff1ecdb1e1b4a58d840d5364c3a0 Mon Sep 17 00:00:00 2001
From: asmwarrior <a@b.com>
Date: Fri, 28 Oct 2022 16:02:25 +0800
Subject: When the personality is "debug-plugin", we only load limited plugins
diff --git a/src/sdk/pluginmanager.cpp b/src/sdk/pluginmanager.cpp
index 559df706..04d93aa9 100644
--- a/src/sdk/pluginmanager.cpp
+++ b/src/sdk/pluginmanager.cpp
@@ -971,6 +971,14 @@ int PluginManager::ScanForPlugins(const wxString& path)
return count;
bool batch = Manager::IsBatchBuild();
+
+ // when debugging a single plugin, we need to loaded very limited dlls
+ // because if we load a lot of dlls and their debug symbols will make GDB slow
+ // only enable this option if the personality name is "debug-plugin"
+ wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality());
+ if (personality == "debug-plugin")
+ batch = true;
+
wxArrayString bbplugins;
if (batch)
bbplugins = cbReadBatchBuildPlugins();
This is the patch to enable this feature.
I committed this change in svn repo now, rev 13048.
EDIT
If you want to debug both compiler plugin and codecompletion plugin, you need to specify this section of the "debug-plugin.conf" like below:
<BATCH_BUILD_PLUGINS>
<astr>
<s>
<![CDATA[compiler.dll]]>
</s>
<s>
<![CDATA[codecompletion.dll]]>
</s>
</astr>
</BATCH_BUILD_PLUGINS>