User forums > Embedded development

Set remote debug option with Wizard script [SOLVED]

<< < (7/7)

BlueHazzard:

--- Quote from: BlueHazzard on May 26, 2017, 09:26:52 pm ---there is a other problem with codeblocks. The debugger deletes all configuration done outside from the plugin. I would like to know form a dev why this was done... The configuration should only be overwritten when you change the options.

--- End quote ---

This is the problem, so there is still missing a part to fix your problem...

oBFusCATed:
The changes to the ProjectLoadingHooks are in trunk/master now.
There is also new scripting api for modifying the extensions. It is a lot more capable.

Here is an example what is possible now. You can uncomment some parts to test different functions:

--- Code: ---function doListAll(project, extension)
{
    print("  " + extension + "\n");
    local listAttrs = project.ExtensionListNodeAttributes(extension);
    for (local jj=0; jj<listAttrs.GetCount(); ++jj)
    {
        local value = project.ExtensionGetNodeAttribute(extension, listAttrs.Item(jj));
        print(_T("    attr -> ") + listAttrs.Item(jj) + _T(" : ") + value + _T("\n"));
    }

    local list = project.ExtensionListNodes(extension);
    for (local ii=0; ii<list.GetCount(); ++ii)
    {
        doListAll(project, list.Item(ii));
    }
}

function listAll(project, extension)
{
    print("\n=== listAll for " + extension + "!\n");
    doListAll(project, extension);
    print("=== listAll end.\n");
}


function test_dbg()
{
    print("Started testing script!\n");
    local pm = GetProjectManager();
    local project = pm.GetActiveProject();
    if (!project)
        return;
/*
    listAll(project, _T("debugger"));
    listAll(project, _T("debugger/remote_debugging"));
    listAll(project, _T("debugger/remote_debugging[1]"));
    listAll(project, _T("debugger/remote_debugging(target=Debug)"));

    print("\n\nSetting attribute - ip_address\n");
    print("---> project modified: " + project.GetModified() + "\n");
    local modifyExtension = _T("debugger/remote_debugging(target=Debug)/options[0]");
    project.ExtensionSetNodeAttribute(modifyExtension, _T("ip_address"), _T("192.168.0.2"));
    local newValue = project.ExtensionGetNodeAttribute(modifyExtension, _T("ip_address"));

    listAll(project, _T("debugger/remote_debugging(target=Debug)"));
    print("---> new value read: " + newValue + "\n");
    print("---> project modified: " + project.GetModified() + "\n");

    print("\n\nAdding node - debugger/test\n");
    project.SetModified(false); // just reset modified flag to test if mutating function really change it!
    project.ExtensionAddNode(_T("debugger"), _T("test"));
    listAll(project, _T("debugger/test"));
    print("---> project modified: " + project.GetModified() + "\n");

    project.ExtensionSetNodeAttribute(_T("debugger/test"), _T("testAttr"), _T("testValue"));
    listAll(project, _T("debugger/test"));

    print("\n\nRemoving node - debugger/test\n");
    project.SetModified(false); // just reset modified flag to test if mutating function really change it!
    project.ExtensionRemoveNode(_T("debugger/test"));
    listAll(project, _T("debugger"));
    print("---> project modified: " + project.GetModified() + "\n");

    print("\n\nRemoving node - debugger/test\n");
    project.SetModified(false); // just reset modified flag to test if mutating function really change it!
    local modifiedExtension = _T("debugger/remote_debugging[2]/options[0]");
    project.ExtensionRemoveNodeAttribute(modifiedExtension, _T("additional_cmds"));
    listAll(project, modifiedExtension);
    print("---> project modified: " + project.GetModified() + "\n");
*/
/*
    print("\n\nRemoving node - debugger\n");
    project.SetModified(false); // just reset modified flag to test if mutating function really change it!
    project.ExtensionRemoveNode(_T("debugger"));
    project.ExtensionAddNode(_T(""), _T("debugger"));
    local extRD0 = project.ExtensionAddNode(_T("debugger"), _T("remote_debugging"));
    print("extRD0 = " + extRD0 + "\n");
    local extRD0Options = project.ExtensionAddNode(extRD0, _T("options"));
    print("extRD0Options = " + extRD0Options + "\n");
    project.ExtensionSetNodeAttribute(extRD0Options, _T("conn_type"), _T("1"));

    local extRD1 = project.ExtensionAddNode(_T("debugger"), _T("remote_debugging"));
    print("extRD1 = " + extRD1 + "\n");
    project.ExtensionSetNodeAttribute(extRD1, _T("target"), _T("Debug"));
    local extRD1Options = project.ExtensionAddNode(extRD1, _T("options"));
    print("extRD1Options = " + extRD1Options + "\n");
    project.ExtensionSetNodeAttribute(extRD1Options, _T("conn_type"), _T("0"));

    listAll(project, _T("debugger"));
    print("---> project modified: " + project.GetModified() + "\n");

    print("--> conn_type: " + project.ExtensionGetNodeAttribute(extRD0Options, _T("conn_type")) + "\n");
    project.ExtensionSetNodeAttribute(extRD0Options, _T("conn_type"), _T("0"));
    print("--> modified conn_type: " + project.ExtensionGetNodeAttribute(extRD0Options, _T("conn_type")) + "\n");

    listAll(project, _T("debugger"));
    */

    for (local ii = 0; ii < 500; ++ii)
    {
        local name = _T("Debug" + ii);
        print("Duplicate: " + name + "\n");
        project.DuplicateBuildTarget(0, name);
    }

    project.ExtensionRemoveNode(_T("debugger"));
    project.ExtensionAddNode(_T(""), _T("debugger"));

    for (local ii = 0; ii < 500; ++ii)
    {
        local name = _T("Debug" + ii);
        local rd = project.ExtensionAddNode(_T("debugger"), _T("remote_debugging"));
        project.ExtensionSetNodeAttribute(rd, _T("target"), name);
        local rdOpt = project.ExtensionAddNode(rd, _T("options"));

        project.ExtensionSetNodeAttribute(rdOpt, _T("conn_type"), _T("0"));
        project.ExtensionSetNodeAttribute(rdOpt, _T("ip_address"), _T("192.168.0.12"));
        project.ExtensionSetNodeAttribute(rdOpt, _T("ip_port"), _T("1223"));
        project.ExtensionSetNodeAttribute(rdOpt, _T("additional_cmds"), _T("asdf"));
        project.ExtensionSetNodeAttribute(rdOpt, _T("additional_cmds_before"), _T("asdf"));
        project.ExtensionSetNodeAttribute(rdOpt, _T("extended_remote"), _T("1"));
    }

    //project.ExtensionRemoveNode(_T("debugger"));
    //project.ExtensionAddNode(_T(""), _T("debugger"));

    for (local ii = 0; ii < 1000; ++ii)
    {
        local path = project.ExtensionAddNode(_T("debugger"), _T("search_path"));
        project.ExtensionSetNodeAttribute(path, _T("add"), _T("some strange path" + ii));
    }


    //listAll(project, _T("debugger"));
}

test_dbg();

// print(GetProjectManager().GetActiveProject().ExtensionGetNodeAttribute(_T("debugger[0]remote_debugging[1]"), _T("target")));

--- End code ---

Note: that this version could create many targets in your project, which is quite slow currently... So you could lower the limit values of the for loops.

BlueHazzard:
Can you add a test to the test scripts for this new functionality?

How does the "new" project loading works? Load the plugin data on activating a project?

oBFusCATed:
I'm not sure if creating a project from a test is a good idea. If you have time you can write some, this way you'll test what I've done, I'm sure I've missed/messed something.

The loading works by parsing the xml data when the plugin needs it - just before starting a debug session, when showing the project options and so on. This means that if something external modifies the settings they would be respected. In the past the parsing happened only on project load or if the project loading hooks have been executed manually.

Unfortunately the autoversion and wxsmith plugins use these hooks in a complex manner, so I couldn't remove them easily and I've postponed this task. :( The idea is to remove project loading hooks.

jimbo:
Thanks for this, in my limited testing it does the job well.

Navigation

[0] Message Index

[*] Previous page

Go to full version