How to get PC, LR and other information of all threads in a multi threading system?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to get PC, LR and other information of all threads in a multi threading system?

1,006 次查看
preetmehta
Contributor III

Hello All,

I am trying to capture all the possible information for all the threads from a "so called monitor" thread, like PC, SP, LR or whole TD.

I am able to get SP_BASE and SP and SP Limit from the TD_STRUCT of MQX.

But I am not able to find PC and LR.

Let me clarify my motive behind my active which is to gather all such information of TD while Watchdog is going to trigger.

So in my system I am using api to get TD and accessing it's info.

Does anyone know how can I get value of last PC of all the threads?

Preet...

标记 (1)
0 项奖励
回复
1 回复

695 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Preet

Please refer to the following code,

        uint32_t                    psp, msp, i;
        printf("\n\r*** UNHANDLED INTERRUPT ***\n\r");
        printf("Vector #: 0x%02x Task Id: 0x%0x Td_ptr 0x%x\n\r",
        (uint32_t)parameter, (uint32_t)td_ptr->TASK_ID, (uint32_t)td_ptr);

        psp = __get_PSP();
        msp = __get_MSP();
        printf("PC: 0x%08x LR: 0x%08x PSP: 0x%08x MSP: 0x%08x PSR: 0x%08x\n\r", __get_PC(), __get_LR(), psp, msp, __get_PSR());

        printf("\n\r\n\rMemory dump:\n\r");
        for (i = 0; i < 32; i += 4) {
            printf("0x%08x : 0x%08x 0x%08x 0x%08x 0x%08x\n\r", psp + i * 4, ((uint32_t*)psp)[i], ((uint32_t*)psp)[i + 1], ((uint32_t*)psp)[i + 2], ((uint32_t*)psp)[i + 3]);
        }

        printf("\n\r\n\rMemory dump:\n\r");
        for (i = 0; i < 32; i += 4) {
            printf("0x%08x : 0x%08x 0x%08x 0x%08x 0x%08x\n\r", msp + i * 4, ((uint32_t*)msp)[i], ((uint32_t*)msp)[i + 1], ((uint32_t*)msp)[i + 2], ((uint32_t*)msp)[i + 3]);
        }

You also can find this code in mqx/source/psp/cortex_m/int_unx.c

Regards

Daniel

0 项奖励
回复