User forums > Embedded development

Set remote debug option with Wizard script [SOLVED]

<< < (4/7) > >>

oBFusCATed:
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").

--- End code ---

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);

--- End code ---

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.

anandamu16:
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>
--- End quote ---

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);


--- End code ---

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);
--- End quote ---
Above function replaces the below function

--- Quote --- project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands);
--- End quote ---
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>
--- End quote ---

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
--- End quote ---

Is anyone can help me with this? Any possible solution?

anandamu16:
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

BlueHazzard:
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);
--- End quote ---

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

Does

--- Code: ---project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));

--- End code ---
overwrites

--- Code: --- project.AddToExtensions(_T("debugger/scriptadd/remote_debugging/options:additional_cmds=") + additional_commands1);

--- End code ---
??

What is the desired outcome of this:

--- Code: ---project.AddToExtensions(_T("debugger/scriptadd/remote_debugging:target=Release"));

--- End code ---
?

thank you for the patience

anandamu16:
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);


--- End code ---

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>

--- End quote ---

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>

--- End quote ---


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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version