| 
在线时间0 小时
UID120069
注册时间2009-4-4
NXP金币0 
 该用户从未签到 新手上路 
 
 
	积分8 
最后登录1970-1-1 | 
 
 发表于 2012-4-3 22:22:18
|
显示全部楼层 
回复:为什么codewarrior中查看不了局部变量?
| 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).
 
 | 
 |