查看: 10386|回复: 4

[CodeWarrior] 为什么codewarrior中查看不了局部变量?

[复制链接]

该用户从未签到

1

主题

1

帖子

0

新手上路

Rank: 1

积分
20
最后登录
1970-1-1
发表于 2009-1-20 10:47:50 | 显示全部楼层 |阅读模式
我用的是codewarrior 7.0,在调试的时候,函数内部的局部变量在变量查看视图中,总是提示“unknown error”,除非我在局部变量前加上volatile,或者让这个变量成为全局变量,才能看到值,真奇怪,有哪位高手能告诉我,非常感谢!
我知道答案 目前已有4人回答
回复

使用道具 举报

该用户从未签到

0

主题

5

帖子

0

新手上路

Rank: 1

积分
20
最后登录
1970-1-1
发表于 2009-1-21 08:13:40 | 显示全部楼层

RE:为什么codewarrior中查看不了局部变量?

有这个问题,我用的是5.5,也存在局部变量实时调试显示问题。
哪怕就是在该位置设置断点,单步运行,都提示改变量未分配内存。
莫名其妙?

该用户从未签到

0

主题

3

帖子

0

新手上路

Rank: 1

积分
108
最后登录
1970-1-1
发表于 2009-2-4 15:58:22 | 显示全部楼层

RE:为什么codewarrior中查看不了局部变量?

可能是局部变量与全局变量重名;或有相同的局部变量名.

该用户从未签到

0

主题

9

帖子

0

新手上路

Rank: 1

积分
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).
 
回复 支持 反对

使用道具 举报

  • TA的每日心情
    慵懒
    2016-11-23 17:18
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    1

    主题

    35

    帖子

    0

    注册会员

    Rank: 2

    积分
    159
    最后登录
    2016-11-23
    发表于 2014-11-9 22:53:02 | 显示全部楼层
    wal5wx 发表于 2012-4-3 22:22
    the debugger can read from the memory while the  target is running (using BDM background cycles). Th ...

    Great                  
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-9-12 01:18 , Processed in 0.091688 second(s), 24 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表