Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

How to exclude the other plugins when debugging

(1/2) > >>

ollydbg:
Hi, if you would like to debug a single plugin, say you want to debug the clangd_client plugin, I think only two plugins are necessary, one is the clangd_client itself, the other is the compiler plugin, all the other plugins are not necessary. When debugging under Windows, you always need build the whole workspace, which includes all the plugins. While those plugins can be "Disabled" in the plugin manager, but please note that even they are disabled, the dlls are still loaded, which take a lot of time for the GDB to load those debug symbols.

So, to accelerate the debugging process, I would like to see a method to only keep one or two dlls. A simple method should that we can delete the un-needed dlls, but the bad thing is if you hit the build button, they will be built again.

My initial idea is that we can supply a command line option when the debugee(codeblocks.exe) starts, the command option specifies the plugins we needed.

Any ideas?

BTW: I think I have post a similar question several years ago, but I just can't find it when searching the forum.

stahta01:
Any reason why just using an separate CB "profile" will not work?

Tim S.

ollydbg:

--- Quote from: stahta01 on October 28, 2022, 01:41:44 am ---Any reason why just using an separate CB "profile" will not work?

Tim S.

--- End quote ---

Hi, Tim, we do use a "profile" named "debug" for debugging. (not the "default" profile)

But in the profile file, can we "disable" loading the plugins?

Please note that "disable the plugin" means the plugin is loaded, but not active. In this case, the dll includes its debug symbol are still loaded.

ollydbg:
I think this is the function we are going to hack:


--- Code: ---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;
}

--- End code ---

I think if we can add another option, such as:


--- Code: ---    if (batch or debugging_plugin_mode)
        bbplugins = cbReadBatchBuildPlugins();

--- End code ---

We can only load a minimal set of the plugins.
What do you think of this idea?

ollydbg:

--- Code: ---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();


--- End code ---

This is the patch to enable this feature.

Navigation

[0] Message Index

[#] Next page

Go to full version