In my world I don't use exit() at all, but sometimes a nasty error could happen inside a library func
which calls exit(). In the comp.c this function is implemented as this:
void _exit(int status)
{
// disable all interrupts, run infinite loop
__asm("cpsid i");
while(1);
}
What would be much nicer is if the sw could just enter the debugger. Do I have to patch the source, or is there a
non intrusive way of do this?
Solved! Go to Solution.
Hello,
I have checked the source code file and it is located in KSDK_1.1.0\rtos\mqx\mqx\source\psp\cortex_m\compiler\gcc_arm\comp.c, i.e. this program module is a part of MQX. It is a static source code file and you can modify it.
This issue is related to MQX software solution. I will move it.
Best Regards,
Marek Neuzil
Hello,
I have checked the source code file and it is located in KSDK_1.1.0\rtos\mqx\mqx\source\psp\cortex_m\compiler\gcc_arm\comp.c, i.e. this program module is a part of MQX. It is a static source code file and you can modify it.
This issue is related to MQX software solution. I will move it.
Best Regards,
Marek Neuzil
Ok,
If I may wish a solution with a function-pointer, weak-link would be better, as you then doesn't have to change the library source.
BTW:what is the assembly instruction for breakpoint?
__asm("bkpt 4"); | //DES example of using assembly code in "C" source to halt/break in the code. A debugger can then step over and the resume execution. |
Regards,
David
In some example code, I've seen this coded with a '0' instead of a '4'. ARM documentation says:
"The BKPT
instruction causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached.
In both ARM state and Thumb state,
is ignored by the ARM hardware. However, a debugger can use it to store additional information about the breakpoint." [ARM Information Center]imm
So I'm curious if there is any particular reason for using '4'?
I'm also curious about what happens if a bkpt instruction is executed when there is no debugger connected. I assume this acts similar to either a NOP or a HALT but haven't found a description of this yet.
Thanks,
James
Hi James,
No particular reason for "4" other than it works.
My testing without debugger has behavior of a HALT.
Regards,
David
Thanks. Just FYI, '0' seems to work too. Guess you COULD look at this value to take some action in the debugger.
Too bad about the behavior--guess that means can't leave bkpt instructions sprinkled in the code!!