Code::Blocks

User forums => Embedded development => Topic started by: ZdenoQC on September 11, 2012, 05:24:35 pm

Title: Set remote debug option with Wizard script [SOLVED]
Post by: ZdenoQC on September 11, 2012, 05:24:35 pm
Hi,

I'm creating a wizard template for my board base on a freescale imx processor (armv7). I have set all compiler and librairie function but I haven't found a way to set gdb remote debugging option like IP address and pre-command.

Is this possible?

Thanks

William Deshaies
Title: Re: Set remote debug option with Wizard script
Post by: MortenMacFly on September 12, 2012, 07:30:50 am
Is this possible?
Yes.
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on September 13, 2012, 02:26:36 pm
Nice!

And how I do that? Is it with the read/write function and I look in the project XML to find the name of the parameter I want to change?

Thanks

William Deshaies
Title: Re: Set remote debug option with Wizard script
Post by: MortenMacFly on September 13, 2012, 02:51:25 pm
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.
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on September 13, 2012, 03:07:28 pm
Sorry I totally forgot. I'm using Ubuntu 11.04 and codeblocks 10.05 from synaptic (not svn), gcc 4.4.4 (gcc-4.4.4-glibc-2.11.1-multilib-1.0).

I'm not sure about the framework you are talking because I haven't add any plugin or addon.
Title: Re: Set remote debug option with Wizard script
Post by: MortenMacFly on September 13, 2012, 03:23:32 pm
codeblocks 10.05
I suppose you better use a nightly for this purpose. Then, within the debugger configuration you can setup the connectivity options using the GUI.
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on September 13, 2012, 03:24:53 pm
I already know how to setup those setting in the project with Properties->Debugger->Remote debugging, but I want this to be made by the wizard script I'm writing. Just like the function project.AddLinkLib(_T(""));.

I thought it was a codeblocks project thing and not compiler/debugger specific thing.
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on October 10, 2012, 04:35:39 pm
Hi,
 
After some days I found something interesting. The function project.AddToExtensions() add elements in the project xml file.

Code: [Select]
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"));

The problem is that it seems that the debugger option is ovewrite elsewhere. When I use de "+" in front of "debugger/.." , I see the the duplicate options, but the first is clear.

Do someone know what is the function that overwrite the debugger setting and how I can bypass that? Or is there an other way of writing theses settings?

Thanks
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on October 12, 2012, 04:12:23 pm
Hi,

I found a workaround for the previous method I found. I just find out that the debugger was a plugin in codeblocks. So I disable it first. I create the project with my wizard with the "AddToExtensions" lines and I close it. Finally, I enable the plugin and I open the project. Its the only way that my settings are not erase by the debugger plugin.

I guess the only way to avoid that is to modify the debugger plugin or disable and enable the plugin via the wizard.
Title: Re: Set remote debug option with Wizard script
Post by: oBFusCATed on October 15, 2012, 05:22:32 pm
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.
Title: Re: Set remote debug option with Wizard script
Post by: firew4lker on December 13, 2012, 03:40:59 pm
I have the same Issue.

@ZdenoQC. Did you fill a bug report?
Title: Re: Set remote debug option with Wizard script
Post by: tomjnx on January 10, 2013, 11:38:36 am
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...
Title: Re: Set remote debug option with Wizard script
Post by: firew4lker on January 10, 2013, 11:55:16 am
I will give it a try.
Title: Re: Set remote debug option with Wizard script
Post by: ZdenoQC on January 30, 2013, 04:59:27 pm
Wow I thought it would never work! Thanks a lot tomjnx for this patch!
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: Jungle on February 10, 2016, 12:24:11 pm
I apologize for reviving this topic, but I'm unable to set debugger options in the wizard.script. I've tried the following
Code: [Select]
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"));
and it doesn't work. I've also tried without "+" and without "scriptadd". No success.

C::B version is 16.01.
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: oBFusCATed on February 13, 2016, 05:48:20 pm
You need to apply this patch:
Code: [Select]
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").

And then use code like:
Code: [Select]
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);

I won't apply this patch in trunk, because there is a plan to replace the script bindings code with a newer binding library, so I don't want to cause conflicts.
Also I have plans to remove the whole project hooks in the future and thus I'll have to remove this call, which means I'll have to break users scripts.
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 22, 2017, 03:22:53 pm
Hi,

Sorry for reviving this topic again. I am doing this bcz my query is related to all the changes suggested here

I am facing sokme difficulties in project.AddtoExtension command in wizard.script file.
What I want is : (within cbp file of generated project from wizard)
Quote
                    <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>

To get this as output, I use one of the suggestion mentioned earlier - To use "scriptadd" in defining path, like this
Code: [Select]
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);


The problem is whenever I do this,
Quote
    project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
    project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
Above function replaces the below function
Quote
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands);
Now I can only see 1 of above.
Is there any method that I can used to get the desired output?

Outcome I am getting is
Quote
            <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>

Just for Reference, I tries to use this solution, available here only a few comments before
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...
* cb_dbgscradd.patch

Is anyone can help me with this? Any possible solution?
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 24, 2017, 01:10:37 pm
Anyone can provide any solution or any way to achieve the desired possibility in codeblocks?

It seems I need to make a few modifications in debuggergdb.cpp
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: BlueHazzard on May 24, 2017, 04:30:28 pm
Hmm, i don't quire understand your question:

Quote
    project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
    project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);

can you replay exactly what the outcome is, and what you want?

Does
Code: [Select]
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
overwrites
Code: [Select]
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
??

What is the desired outcome of this:
Code: [Select]
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
?

thank you for the patience
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 24, 2017, 07:15:25 pm
Code I am using in wizard script file:
Code: [Select]
                     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);


Expected Outcome:
Quote
<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>

Actual Outcome:
Quote
<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>


Sorry for posting unclear query earlier. I hope this will be concise and clear  :)

It seems that we can add only 1 Extension line to cbp file corresponding to each parameter. Incase, I try to write multiple extension lines, only the information corresponding to last "project.AddtoExtension" gets reflected.
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: BlueHazzard on May 24, 2017, 08:07:31 pm
i tried your code and it does not work for me...
can you post more code?
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: BlueHazzard on May 24, 2017, 08:18:21 pm
i looked into the code of
Code: [Select]
void cbProject::AddToExtensions(const wxString& stringDesc)
and i have to tell you with this code it will not work... The problem is that the code does not look for attributes of the xml nodes. For the current code
Code: [Select]
<remote_debugging target="Debug">
</remote_debugging>
is the same as
Code: [Select]
<remote_debugging target="Release">
</remote_debugging>
so if the code comes to the first remote_debugging target node it will use it. The code needs modifications... Can you open a ticket on sourceforge? Probably i find time today to fix this and post a patch, but you have to find a dev who applies it ;)


Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 25, 2017, 07:08:59 am
Quote
i tried your code and it does not work for me...
can you post more code?
It will not work today, I applied a hack in debuggergdb.cpp file to make it work.
Kindly refer the reply of tomjnx in this same thread, he introduced a patch, I applied it and it worked.
Quote
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...

I have added my modified debuggergdb.cpp file for reference. Kindly search for 'scriptadd' in this file.
Also I modified the code, I posted in last comment by adding /scriptadd/ in path.
If you will make the changes as stated in debuggergdb.cpp and use the above code in wizard.script, you can actualkly see the output
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: oBFusCATed on May 25, 2017, 08:24:47 am
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) (http://wiki.codeblocks.org/index.php/Creating_a_patch_to_submit_(Patch_Tracker))

EDIT:
fixed link
jens
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 26, 2017, 08:36:03 am
Hi oBFusCATed

I am not giving any patch here. I find this solution by someone here on this thread only.
Quote
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 :)

My query is there any way in current codeblocks to get this (in cbp file)
Quote
<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>
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?
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: oBFusCATed on May 26, 2017, 09:12:10 am
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.
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: jens on May 26, 2017, 09:12:24 am
Hi oBFusCATed

I am not giving any patch here. I find this solution by someone here on this thread only.
Quote
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 :)
I fixed the link in oBFusCATed's post.
The automatic link-recognition of the forum software does not recognize the closing parenthesis as part of the link and omits it therefore.
My query is there any way in current codeblocks to get this (in cbp file)
Quote
<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>
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?
You can create a stub project with all settings you need and save it as user template: "File -> Save project as template ..".
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 26, 2017, 10:25:12 am
Quote
You can create a stub project with all settings you need and save it as user template: "File -> Save project as template ..".

In my project some setiings required the name of project like
In Remote debugging:          load bin/Debug/ptojectName.elf

For these kind of settings, I wish to set all these settings through wizard script file. Setting a template will not be of help

Pls clear my doubt: In today's scenario, Can we add multiple remote debugging commands through wizard script like this:??
Quote
<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>
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: BlueHazzard on May 26, 2017, 09:26:52 pm
Ok, i have created a patch with this codeblocks would be able to do what you want.
https://sourceforge.net/p/codeblocks/tickets/513/

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... But if you use this api provided by my patch only from the scripted wizard this should be ok..
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: anandamu16 on May 29, 2017, 01:10:35 pm
Hi BlueHazzard,

Your code looks good, but alas nothing gets displayed/reflected in cbp file of the project..?
As per your patch, I modified cbproject.h and cbproject.cpp. I keep all other files such as debuggergdb.cpp same as available in nighty build. But still I am not able to see debugger options in cbp file.
I checked my cbp file, and it has no information about debugger.

In wizard.script file, I used this command -
project.AddToExtensions(_T("debugger/remote_debugging/options:conn_type=0/sub_conn:baudrate=32000"));
project.AddToExtensions(_T("debugger/remote_debugging/options:conn_type=0/sub_conn:+interface=COM1"));

Any comments? Am I missing anything?

Even I tried disabling the debugger plugin, before creating the project, even that didn't work. Also please clear, whether disabling a plugin is mandatorystep or not required?
Title: Re: Set remote debug option with Wizard script [SOLVED]
Post by: BlueHazzard on May 29, 2017, 05:16:33 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.

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