Author Topic: Set remote debug option with Wizard script [SOLVED]  (Read 79225 times)

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Set remote debug option with Wizard script [SOLVED]
« 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
« Last Edit: January 30, 2013, 05:00:23 pm by ZdenoQC »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Set remote debug option with Wizard script
« Reply #1 on: September 12, 2012, 07:30:50 am »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #2 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Set remote debug option with Wizard script
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #4 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Set remote debug option with Wizard script
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #6 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.

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #7 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
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

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #8 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script
« Reply #9 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline firew4lker

  • Single posting newcomer
  • *
  • Posts: 7
Re: Set remote debug option with Wizard script
« Reply #10 on: December 13, 2012, 03:40:59 pm »
I have the same Issue.

@ZdenoQC. Did you fill a bug report?

Offline tomjnx

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Set remote debug option with Wizard script
« Reply #11 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...

Offline firew4lker

  • Single posting newcomer
  • *
  • Posts: 7
Re: Set remote debug option with Wizard script
« Reply #12 on: January 10, 2013, 11:55:16 am »
I will give it a try.

Offline ZdenoQC

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script
« Reply #13 on: January 30, 2013, 04:59:27 pm »
Wow I thought it would never work! Thanks a lot tomjnx for this patch!

Offline Jungle

  • Single posting newcomer
  • *
  • Posts: 9
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #14 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
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #15 on: February 13, 2016, 05:48:20 pm »
You need to apply this patch:
Code
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
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #16 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
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?
« Last Edit: May 22, 2017, 03:30:37 pm by anandamu16 »

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #17 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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #18 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
project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));
overwrites
Code
 project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);
??

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

thank you for the patience

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #19 on: May 24, 2017, 07:15:25 pm »
Code I am using in wizard script file:
Code
                     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.
« Last Edit: May 25, 2017, 07:24:05 am by anandamu16 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #20 on: May 24, 2017, 08:07:31 pm »
i tried your code and it does not work for me...
can you post more code?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #21 on: May 24, 2017, 08:18:21 pm »
i looked into the code of
Code
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
<remote_debugging target="Debug">
</remote_debugging>
is the same as
Code
<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 ;)



Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #22 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
« Last Edit: May 25, 2017, 07:26:20 am by anandamu16 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #23 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)

EDIT:
fixed link
jens
« Last Edit: May 26, 2017, 09:05:43 am by jens »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #24 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #25 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #26 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 ..".

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #27 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>

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #28 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..

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #29 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?
« Last Edit: May 29, 2017, 01:13:45 pm by anandamu16 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #30 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...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #31 on: September 29, 2019, 03:19:53 pm »
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")));

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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #32 on: September 29, 2019, 10:19:03 pm »
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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #33 on: September 30, 2019, 12:59:10 am »
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: Set remote debug option with Wizard script [SOLVED]
« Reply #34 on: December 11, 2019, 06:20:42 pm »
Thanks for this, in my limited testing it does the job well.