I am looking at the STM32f4xx project template, generated by the GNU ARM Eclipse plugin, with semihosting enabled. The main
function is defined with both argc
and argv
parameters, which is pretty useless in a freestanding embedded program, but in case of semi-hosted debugged program they can be passed used some mechanism. So my question is how do I access this mechanism? Right now, without any changes to the template and the project settings, the argv[0]
equals to a string "foobar"
, which I have no idea where it came from. And I have no idea how to pass some other string to it.
Some more information:
- IDE: Eclipse + GNU Arm Eclipse plugin
- Toolchain: GCC ARM Embedded
- Debug: Eclipse + OpenOCD + GDB from the toolchain
- Hardware: STM32f401vC
Update:
I am starting to suspect the constant is buried deeply in the newlib
code. I can see where the args reading is triggered (it's in _syscals.c
) by call_host (SEMIHOSTING_SYS_GET_CMDLINE, &cmdBlock);
, but I can't figure out where it is handled. It is then transformed to a bkpt 0xAB
and from there I am lost.