We've got a task (MQX for KSDK 1.2) that stops executing, and we have yet to figure out why. It only occurs one in a blue moon, so it is hard to solve. The current solution is to use _task_set_exit_handler and _task_set_exception_handler to trap the MQX task error number, if any. Hopefully, this will give us more information about what's going wrong.
However, at the moment I'm not able to get _task_set_exit_handler to work. I've implemented like this in os_tasks.cpp:
TASK_EXIT_FPTR _task_set_exit_handler( _task_id id, TASK_EXIT_FPTR f)
// get info for the active task when this handler is called
_task_id active_task_id = _task_get_id();
_mqx_uint active_task_error = _task_get_error();
// don't really need this since we already have the error code
TD_STRUCT_PTR ptd_active = (TD_STRUCT_PTR)_task_get_td( active_task_error);
// now get info for the ID that was passed in -- I suppose this is for the failed task...
TD_STRUCT_PTR ptd_passed = (TD_STRUCT_PTR)_task_get_td( id);
_mqx_uint passed_task_error = ptd_passed->TASK_ERROR_CODE;
Here I'm basically checking the active task at the time the exiting task exits to see if they are the same. I then get the error code from each one, also for the purpose of comparison.
The problem I have is that when this code is executed with a breakpoint set (or if a breakpoint is added after execution), the debugger crashes:
This behavior is consistent with the known behavior where GDB crashes if a breakpoint is set in code that never gets called by the application. This implies that I'm not setting something up properly, but I do have the preprocessor setting "MQX_EXIT_ENABLED=1" in my project settings.
Has anyone else tried to use these functions and have gotten them to work?