Anyone successful with _task_set_exit_handler and _task_set_exception_handler?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Anyone successful with _task_set_exit_handler and _task_set_exception_handler?

1,064 Views
dave408
Senior Contributor II

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;
    return NULL;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

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:

pastedImage_2.png

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?

0 Kudos
5 Replies

616 Views
dave408
Senior Contributor II

Here's my sample project.  Sorry, I had forgotten to attach it earlier.  This is for the FRDM-K22F development board.

0 Kudos

616 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Dave:

Do you use MQX4.2 or MQX for KSDK1.3?

Regards

Daniel

0 Kudos

616 Views
dave408
Senior Contributor II

Ah, sorry for missing that level of detail! MQX for KSDK 1.2.

0 Kudos

616 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Dave:

I did a quick check with TWR-K65F180M and KSDK1.2.

I enabled MQX_EXIT_ENABLED in user_config.h , add add _mqx_exit(1) in hello task.

My observation is , when _mqx_exit is executed,  I can see system jump to _bsp_exit_handler successfully. It is a correct result because in init_bsp.c. the exit handler is set.

#if MQX_EXIT_ENABLED
    extern void  _bsp_exit_handler(void);
    /* Set the bsp exit handler, called by _mqx_exit */
    _mqx_set_exit_handler(_bsp_exit_handler);
#endif

Regards

Daniel

0 Kudos

616 Views
dave408
Senior Contributor II

Hi Daniel, I do not think what you have posted is what I am looking for.  I'm curious to determine why a specific task has stopped executing, not that the OS itself has stopped running.

0 Kudos