True-time Simulator & Real-time Debugger

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

True-time Simulator & Real-time Debugger

跳至解决方案
1,667 次查看
leesp
Contributor I

I am using this with P&E multilink, and MC9S08JM32 controller.

How can I watch a variable in real time?

eg. I have a function xyz() in source file abc.c, and I want to watch how a variable volatile Bool myVar changes in real time.

I used the debugger Component -> Open -> Data but only the global variables are viewable. I do not know how to view the local variables within each function.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
745 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

the debugger can read from the memory while the target is running (using BDM background cycles). This works only for memory (with an address), but not for CPU core registers.

So with global memory you are ok.

But local variables are on the stack, and the address of it is not always the same. Even more: the scope of the function might not be 'alive', so the debugger cannot read that variable, so this won't work for local variables.

 

What you can do is: make the variable a 'static local':

void foo(void) {

  static int myStaticLocal;

...

}

and that way it will be in global memory, so you can watch it (but: it won't bee reentrant).

 

If you think your variable is always at a certain address on the stack (what usually is not the case), then you simply could watch that address on the stack too (e.g. in the memory view).

 

Hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
回复
1 回复
746 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

the debugger can read from the memory while the target is running (using BDM background cycles). This works only for memory (with an address), but not for CPU core registers.

So with global memory you are ok.

But local variables are on the stack, and the address of it is not always the same. Even more: the scope of the function might not be 'alive', so the debugger cannot read that variable, so this won't work for local variables.

 

What you can do is: make the variable a 'static local':

void foo(void) {

  static int myStaticLocal;

...

}

and that way it will be in global memory, so you can watch it (but: it won't bee reentrant).

 

If you think your variable is always at a certain address on the stack (what usually is not the case), then you simply could watch that address on the stack too (e.g. in the memory view).

 

Hope this helps,

Erich

0 项奖励
回复