In KDS, is there a way to view all MQX tasks' debug program stack?

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

In KDS, is there a way to view all MQX tasks' debug program stack?

跳至解决方案
3,699 次查看
mjohn
Contributor III

In Kinetis Design Studio, I've been using MQX with multiple tasks. The Task Aware Debugger has been a very useful tool when debugging, but I am curious if it is possible to see the current program stack for all the tasks whenever I pause the debugger?

This is what I'm referring to below. I am only able to see one task's program stack.

program_stack.png

Thanks,

Matt

1 解答
2,697 次查看
matthewkendall
Contributor V

This has come up before, e.g.: How to view call stack which task is not actived in KDS

There isn't a solution. The answer appears to be that you can only see the stack for the currently active task. It seems KDS is not really ready for serious usage in this regard.

在原帖中查看解决方案

9 回复数
2,697 次查看
ironsean
Contributor V

This is a feature sorely missed by myself as well. I would continue using Codewarrior for this reason alone if they were continuing support for MQX and Kinetis K series with it...

2,698 次查看
matthewkendall
Contributor V

This has come up before, e.g.: How to view call stack which task is not actived in KDS

There isn't a solution. The answer appears to be that you can only see the stack for the currently active task. It seems KDS is not really ready for serious usage in this regard.

2,697 次查看
RadekS
NXP Employee
NXP Employee

Thank you for your note.

The true is that you get it for what you paid for.

KDS is built on open source components and therefore it is offered for free.

You can anytime create/modify your implementation of GDB server and add support for this feature.

I just discover that one of our engineers already made some modifications in OpenOCD  debugger, but this change is still not released.

For more details, you can look at: http://openocd.zylin.com/#/c/2599/

So, if you have time for debugging debugger, you could apply this patch to OpenOCD and try it.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,697 次查看
mjohn
Contributor III

Radek, do you know if there is a way to get the program counter of a currently inactive task when debugging? Or if there is perhaps an API function call that could return this information? If I was able to simply retrieve the program counter of another task, I could find what part of code it has stopped at easily. It would help out a lot when debugging.

Thank you

Matt

0 项奖励
回复
2,697 次查看
matthewkendall
Contributor V

I have previously modified MQX/mqx/source/tad/tad.c so that the shell "tad stack" command includes the PC in its output. This might help you.

-- 336/tad.c Wed Mar 18 13:16:29 2015

+++ 337/tad.c Wed Mar 18 13:16:16 2015

@@ -323,7 +323,7 @@

    char_ptr                 task_name;

    printf ("\nStack Usage:\n");

-   printf ("Task   Stack Base   Stack Limit   Stack Used   %% Used   Overflow?\n");

+   printf ("Task   PC   Stack Base   Stack Limit   Stack Used   %% Used   Overflow?\n");

    size = _QUEUE_GET_SIZE(&kernel_data_ptr->TD_LIST);

@@ -352,7 +352,7 @@

       {

          percent = ((_mqx_uint_ptr)td_ptr->STACK_BASE - stack_used) * 100 / ((_mqx_uint_ptr)td_ptr->STACK_BASE - (_mqx_uint_ptr)td_ptr->STACK_LIMIT);

       }

-      printf ("%s   0x%lx   0x%lx   0x%lx   %ld %%   %s\n", task_name, td_ptr->STACK_BASE, td_ptr->STACK_LIMIT, stack_used, percent,percent>=100?"Yes":"No");

+      printf ("%s   0x%lx   0x%lx   0x%lx   0x%lx   %ld %%   %s\n", task_name, *(uint_32*)(td_ptr->STACK_PTR + 64)-1, td_ptr->STACK_BASE, td_ptr->STACK_LIMIT, stack_used, percent,percent>=100?"Yes":"No");

       size--;

       td_ptr = (TD_STRUCT_PTR)((uchar_ptr)(td_ptr->TD_LIST_INFO.NEXT) - FIELD_OFFSET(TD_STRUCT,TD_LIST_INFO));

That patch applies to MQX 4.0.1 rather than the latest, but it looks like the source hasn't changed much since then.

0 项奖励
回复
2,697 次查看
DavidS
NXP Employee
NXP Employee

Hi Matt,

Attached is an example I did using MQX back in 2011 to find PC of a task descriptor.  I started with the mqx/examples/lwevent project.

Hope it helps.

Regards,

David

0 项奖励
回复
2,697 次查看
matthewkendall
Contributor V

Hi Radek,

It is true this is a really nice feature of CodeWarrior that is not present in the open source implementations. I came across the same issue a couple of years ago when I was doing a project with FreeRTOS on an NXP Cortex-M with the LPCXpresso toolchain, which is also based on Eclipse and OpenOCD if I remember correctly. At that time I looked in to whether it would be possible to add this feature but did not have the time to get anywhere with it. If one of your engineers has been working on OpenOCD towards this goal that would be great. I will take a look.

Regards,

Matthew

0 项奖励
回复
2,697 次查看
mjohn
Contributor III

Thank you, I will have to try this out when I have more time.

0 项奖励
回复
2,697 次查看
RadekS
NXP Employee
NXP Employee

Unfortunately we are not able manage it by TAD.

This information (current program stack for all the tasks) could be obtained only by debugger who deeply know elf file and who know how data are stored on stack.

Theoretically we can read it from task stacks, however structure of information in stack is inconsistent and we do not know any fix point where we can read PC value.

Information about current program stack for all the tasks is one of CodeWarrior debugger features, however it seems that open source debuggers doesn’t offer such feature. Maybe I am wrong and there is any option, but unfortunately I do not know about it. I am sorry.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复