Is this possible?Yes.
And how I do that?I can't tell because it depends on you platform, version of C::;B and compiler/debugger version / framework you are using. Unfortunately you didn't provide any of these information.
codeblocks 10.05I suppose you better use a nightly for this purpose. Then, within the debugger configuration you can setup the connectivity options using the GUI.
project.AddToExtensions(_T("debugger/remote_debugging/options:conn_type=0"));
project.AddToExtensions(_T("debugger/remote_debugging/options:serial_baud=115200"));
project.AddToExtensions(_T("debugger/remote_debugging/options:ip_address=192.168.0.1"));
project.AddToExtensions(_T("debugger/remote_debugging/options:ip_port=2222"));
project.AddToExtensions(_T("debugger/remote_debugging:target=Debug"));
I guess the only way to avoid that is to modify the debugger plugin or disable and enable the plugin via the wizard.Modify the plugin and provide a patch, but please use the latest SVN HEAD sources as reference.
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging"));
project.AddToExtensions(_T("+debugger/scriptadd/remote_debugging:target=Debug"));
project.AddToExtensions(_T("+debugger/scriptadd/remote_debugging/options:conn_type=0"));
project.AddToExtensions(_T("+debugger/scriptadd/remote_debugging/options:serial_baud=115200"));
project.AddToExtensions(_T("+debugger/scriptadd/remote_debugging/options:ip_address=127.0.0.1"));
project.AddToExtensions(_T("+debugger/scriptadd/remote_debugging/options:ip_port=3333"));
Index: src/sdk/scripting/bindings/scriptbindings.cpp
===================================================================
--- src/sdk/scripting/bindings/scriptbindings.cpp (revision 10780)
+++ src/sdk/scripting/bindings/scriptbindings.cpp (working copy)
@@ -26,6 +26,7 @@
#include "scriptbindings.h"
#include <cbexception.h>
#include "sc_base_types.h"
+#include "projectloader_hooks.h"
namespace ScriptBindings
{
@@ -265,6 +266,24 @@ namespace ScriptBindings
}
return sa.ThrowError("Invalid arguments to \"cbProject::ExportTargetAsProject\"");
}
+
+ SQInteger cbProject_CallHooks(HSQUIRRELVM v)
+ {
+ StackHandler sa(v);
+ int paramCount = sa.GetParamCount();
+ if (paramCount == 2)
+ {
+ cbProject* prj = SqPlus::GetInstance<cbProject,false>(v, 1);
+ if (!prj)
+ return sa.ThrowError("Null project in \"cbProject::CallHooks\"");
+ bool isLoading = (sa.GetBool(2) != 0);
+
+ ProjectLoaderHooks::CallHooks(prj, prj->GetExtensionsNode()->ToElement(), isLoading);
+ return 1;
+ }
+ return sa.ThrowError("Invalid arguments to \"cbProject::CallHooks\"");
+ }
+
SQInteger ProjectManager_AddFileToProject(HSQUIRRELVM v)
{
StackHandler sa(v);
@@ -582,6 +601,7 @@ namespace ScriptBindings
func(&cbProject::GetCheckForExternallyModifiedFiles, "GetCheckForExternallyModifiedFiles").
func(&cbProject::ShowNotes, "ShowNotes").
func(&cbProject::AddToExtensions, "AddToExtensions").
+ staticFuncVarArgs(cbProject_CallHooks, "CallHooks", "*").
func(&cbProject::DefineVirtualBuildTarget, "DefineVirtualBuildTarget").
func(&cbProject::HasVirtualBuildTarget, "HasVirtualBuildTarget").
func(&cbProject::RemoveVirtualBuildTarget, "RemoveVirtualBuildTarget").
project.AddToExtensions(_T("debugger/remote_debugging:target=Debug"));
project.AddToExtensions(_T("debugger/remote_debugging/options:conn_type=0"));
project.AddToExtensions(_T("debugger/remote_debugging/options:serial_baud=115200"));
project.AddToExtensions(_T("debugger/remote_debugging/options:ip_address=127.0.0.1"));
project.AddToExtensions(_T("debugger/remote_debugging/options:ip_port=3333"));
project.CallHooks(true);
<remote_debugging>
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Debug">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
local additional_commands = _T("monitor halt\n") +
_T("monitor flash erase_address 0x0 0x10000\n") +
_T("load bin/Debug/") + projectName + _T(".elf\n") + // load /bin/debug/ will not work
_T("file bin/Debug/") + projectName + _T(".elf\n") +
_T("monitor halt\n");
local additional_commands1 = _T("monitor halt\n") +
_T("monitor flash erase_address 0x0 0x10000\n") +
_T("load bin/Release/") + projectName + _T(".elf\n") + // load /bin/debug/ will not work
_T("file bin/Release/") + projectName + _T(".elf\n") +
_T("monitor halt\n");
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));Above function replaces the below function
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands);Now I can only see 1 of above.
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
Something like this?
You could then add something to "debugger/scriptadd/x", which would then be converted to "debugger/x" on first save (or load)
Yes it's a hack, but minimally intrusive, and the whole AddToExtension interface seems a bit q&d to me...
* cb_dbgscradd.patch
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Debug"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:conn_type=0"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:serial_baud=115200"));
local additional_commands1 = _T("monitor halt\n") +
_T("monitor flash erase_address 0x0 0x10000\n") +
_T("load bin/Debug/\n") + projectName + _T(".elf\n") +
_T("file bin/Debug/") + projectName + _T(".elf\n") +
_T("monitor halt\n");
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:conn_type=0"));
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:serial_baud=115200"));
local additional_commands2 = _T("monitor halt\n") +
_T("monitor flash erase_address 0x0 0x10000\n") +
_T("load bin/Release/\n") + projectName + _T(".elf\n") +
_T("file bin/Release/") + projectName + _T(".elf\n") +
_T("monitor halt\n");
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands2);
<remote_debugging target="Debug">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
void cbProject::AddToExtensions(const wxString& stringDesc)
<remote_debugging target="Debug">
</remote_debugging>
<remote_debugging target="Release">
</remote_debugging>
i tried your code and it does not work for me...It will not work today, I applied a hack in debuggergdb.cpp file to make it work.
can you post more code?
tomjnx
Multiple posting newcomer
Re: Set remote debug option with Wizard script
« Reply #11 on: January 10, 2013, 11:38:36 am »
Quote
Something like this?
You could then add something to "debugger/scriptadd/x", which would then be converted to "debugger/x" on first save (or load)
Yes it's a hack, but minimally intrusive, and the whole AddToExtension interface seems a bit q&d to me...
If you want to provide a patch please follow this procedure described here: http://wiki.codeblocks.org/index.php/Creating_a_patch_to_submit_(Patch_Tracker)Anyway, I tried to follow the link, its an empty page :)
<remote_debugging target="Debug">I want this to be automatic part of new project created by wizard, for this, I am writing the wizard.script file but don't know how to achieve this. Any help will be of great value?
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
Anyway, I tried to follow the link, its an empty page :)The link in my post works fine at least in Firefox on linux. To fix it just add a closing bracket at the end.
Hi oBFusCATedI fixed the link in oBFusCATed's post.
I am not giving any patch here. I find this solution by someone here on this thread only.QuoteIf you want to provide a patch please follow this procedure described here: http://wiki.codeblocks.org/index.php/Creating_a_patch_to_submit_(Patch_Tracker)Anyway, I tried to follow the link, its an empty page :)
My query is there any way in current codeblocks to get this (in cbp file)You can create a stub project with all settings you need and save it as user template: "File -> Save project as template ..".Quote<remote_debugging target="Debug">I want this to be automatic part of new project created by wizard, for this, I am writing the wizard.script file but don't know how to achieve this. Any help will be of great value?
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
You can create a stub project with all settings you need and save it as user template: "File -> Save project as template ..".
<remote_debugging target="Debug">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Debug/rth.elf;file bin/Debug/rth.elf;monitor halt; />
</remote_debugging>
<remote_debugging target="Release">
<options conn_type="0" serial_baud="115200" additional_cmds="monitor halt;monitor flash erase_address 0x0 0x10000;load bin/Release/rth.elf;file bin/Release/rth.elf;monitor halt; />
</remote_debugging>
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.
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")));