This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

finding top and bottom of Bios task stack

Other Parts Discussed in Thread: SYSBIOS

We are using C66x compiler v.7.3.

The C66x compiler can generate link time symbols for stack bottom and stack size. But if we run a function in SysBios, is there a programatical way for us to determine the  stack top/bottom of the task the function is running with?

thanks

Weichun

  • Hi Weichun,

    You can find a particular task's stack base address and stack size from the Task view in ROV. Here's a screenshot showing the same:

    Zoomed Out View

    Zoomed In View

    Best,
    Ashish

  • Thanks, Ashish,

    I do not want to use the ROV. I am adding debug feature that if something happens, I will dump the core registers and the stack automatically. Therefore, I would like a way to do it using the sysBios c-API itself.

    Is there a way to do that?

    thanks

    Weichun

  • Hi Weichun,

    We do not provide any public APIs to access a task stack's base address and size. That said, you can still access this info using the following code snippet:

    ==================================

    #define ti_sysbios_knl_Task__internalaccess
    #include <ti/sysbios/knl/Task.h>

    Void taskFunc(UArg arg0, UArg arg1)
    {
        Task_Handle tsk = Task_self();
        System_printf("Stack Base: %x Stack Size: %d", tsk->stack, tsk->stackSize);
    }

    ==================================

    Please note that since this method of accessing a task stack's attributes is not officially supported, the internal structure definitions may change over time and I cannot guarantee this code will always work.

    Weichun Yuan said:

    I am adding debug feature that if something happens, I will dump the core registers and the stack automatically. Therefore, I would like a way to do it using the sysBios c-API itself.

    I would also like to point out that you can use the Exception module to get a register dump in case an exception occurs. You can read more about this module in the Sys/Bios documentation.

    Best,

    Ashish

  • Ashish Kapania said:

    Hi Weichun,

    We do not provide any public APIs to access a task stack's base address and size. That said, you can still access this info using the following code snippet:

    ==================================

    #define ti_sysbios_knl_Task__internalaccess
    #include <ti/sysbios/knl/Task.h>

    Void taskFunc(UArg arg0, UArg arg1)
    {
        Task_Handle tsk = Task_self();
        System_printf("Stack Base: %x Stack Size: %d", tsk->stack, tsk->stackSize);
    }

    ==================================

    Please note that since this method of accessing a task stack's attributes is not officially supported, the internal structure definitions may change over time and I cannot guarantee this code will always work.

    I am adding debug feature that if something happens, I will dump the core registers and the stack automatically. Therefore, I would like a way to do it using the sysBios c-API itself.

    I would also like to point out that you can use the Exception module to get a register dump in case an exception occurs. You can read more about this module in the Sys/Bios documentation.

    Best,

    Ashish

    [/quote]

    hello, Ashish

    I face the same issue in sysbios 6.34.02.18 and CGT 7.4.1,.

    As your forcasted, the workaround for above env would not work .

    so, would you have the new plan for the programmer accessing task's stack member in runtime?

    thanks in advance!

    B.R

    WEI Xuan 

  • Hi WEI Xuan,

    I would expect this code to work for 6.34.02.18 also. Have you tried using it with 6.34.02.18 ?

    Best,

    Ashish

  • Ashish Kapania said:

    Hi WEI Xuan,

    I would expect this code to work for 6.34.02.18 also. Have you tried using it with 6.34.02.18 ?

    Best,

    Ashish

    Hello, Ashish

    currently, I am using 6.34.02.18 , but the code woud not work. the error code is "error #395: pointer to incomplete class type is not allowed"

  • Hi WEI Xuan,

    Are you defining this macro ->  #define ti_sysbios_knl_Task__internalaccess ?

    The error you are getting should not be generated if this macro is defined. Also, when you add the macro make sure you are placing the macro before including Task.h header.

    =============

    #define ti_sysbios_knl_Task__internalaccess
    #include <ti/sysbios/knl/Task.h>

    =============

    Best,

    Ashish

  • Ashish Kapania said:

    Hi WEI Xuan,

    Are you defining this macro ->  #define ti_sysbios_knl_Task__internalaccess ?

    The error you are getting should not be generated if this macro is defined. Also, when you add the macro make sure you are placing the macro before including Task.h header.

    =============

    #define ti_sysbios_knl_Task__internalaccess
    #include <ti/sysbios/knl/Task.h>

    =============

    Best,

    Ashish

    Hello, Ashish

    You are right.

    Thanks a lot.