Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ccdric on May 20, 2022, 11:01:25 am

Title: [Solved] how to make program's argument dynamic for debug target (using gdb)
Post by: ccdric on May 20, 2022, 11:01:25 am
Hello all
here is my goal :
I have a script that provide different tests case for my codding programme.

I want code::block to adapte to the differents cases when using debbuger.

for exemple I want one parameter comming from the shell command :
Code
 basename -s .xml $(readlink tmp_simu/conf.xml)
this solution works when using the run button (green triangle):
Quote
<Option parameters="--csvin tmp_simu/in.csv --conf  \$(basename -s .xml $\(readlink tmp_simu/conf.xml\)\) ... />
the shell command is substitued by its value.
but if I use de Debug/continue button (red triangle) the shell command is not executed so its see as faulty parameters instead of the shell command value :
Quote
--conf 
\$(basename
-s
.xml
tmp_simu/conf.xml\)\)

anybody has an idee to solve my pb ?

(I use code::block on linux)

thanks reading me
hope my english is good enough  :)
Title: Re: how to make program's argument dynamic for debug target (using gdb)
Post by: BlueHazzard on May 25, 2022, 12:57:18 am
this is probably a bug and you should create a ticket for it.


One way i can think of is to use scripting instead of shell commands
https://wiki.codeblocks.org/index.php/Variable_expansion#Script_expansion

and something like https://wiki.codeblocks.org/index.php/Scripting_commands#IO_namespace the ExecuteAndGetOutput command:
Not tested, because not on a linux machine and to late but you should get an idea:
Code
<Option parameters="--csvin tmp_simu/in.csv --conf  [[print(IO.ExecuteAndGetOutput(wxT("basename -s .xml") +  IO.ExecuteAndGetOutput(wxT("readlink tmp_simu/conf.xml")))]] ... />
Title: [Solved] : how to make program's argument dynamic for debug target (using gdb)
Post by: ccdric on June 13, 2022, 02:02:35 pm
Hi BlueHazzard
Tanks a lot for your answer,
I didn't know before this possibility to use extension script.
I changes a bit my way : my simulations scripts put the full cmd Line in a file.
So this works for Option parameters :
Quote
[[print(IO.ReadFileContents(_T("tmp_simu/cmdLineArg.txt")))]]
The example you provide help me for syntaxe a possibility.
I had just to change (for me) the "WXT" whith "_T" and that's fine
 :)