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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10403
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: [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.
<debugger plugin maintainer>
(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: 97
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: [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?
« Last Edit: May 22, 2017, 03:30:37 pm by anandamu16 »

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 97
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

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1583
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: [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

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 97
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: [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.
« Last Edit: May 25, 2017, 07:24:05 am by anandamu16 »

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1583
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?

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1583
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: [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 ;)



Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 97
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: 10403
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 »
<debugger plugin maintainer>
(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: 97
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: 10403
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.
<debugger plugin maintainer>
(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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7222
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
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: 97
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>

Online BlueHazzard

  • Lives here!
  • ****
  • Posts: 1583
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: 97
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 »