We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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); }
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 cumbersome and inelegant.Is there another more beautiful way to achieve it?