Hi,Master:
Question:
When the finished product cannot be debugged with jlink, I want to save and trace the function stack information through the firmware. When there are some accidental exceptions, I need to use the function stack to more delicately locate the problem.
My way of implementation:
foo_1 ()
{
FUNC_TRACK_PUSH (foo_1); // Push the function address into the stack structure
...// dosome thing
FUNC_TRACK_POP (foo_1); // Pop this function address from the stack structure
}
foo_2 ()
{
FUNC_TRACK_PUSH (foo_2);
...// dosome thing
FUNC_TRACK_POP (foo_2);
}
.
.
.
foo_x ()
{
FUNC_TRACK_PUSH (foo_x);
...// dosome thing
FUNC_TRACK_POP (foo_x);
}
When an exception occurs during use, the current function stack call information can be obtained through the stack structure to assist in analysis.
Disadvantages:
This FUNC_TRACK_PUSH / FUNC_TRACK_POP macro must be added to the entrance and exit of all functions to record the current function stack call, which is complicated and coupled. Is there a more elegant way to achieve it?
Forgive me for poor English. Thank you!
regards