Apr 1

XMD的Watch功能

RickySu , 17:35 , 技术经验 , 评论(0) , 引用(0) , 阅读(320) , Via 本站原创 | |
问题:通常我们设置breakpoint只能设置在某个函数或者某条指令上,那么我能不能在某个变量变化的时候让程序停下并让GDB指示现在停在哪里?

解决:通过XMD的Watch功能。

怎样使用watch功能?
- EDK --> MicroBlaze --> Configure IP --> Debug --> Number of Write/Read Address Watchpoints 设置为需要的数目,因为watch功能需要硬件支持
- 在使用GDB连接XMD并下载程序之后,在XMD输入相应的watch命令:
watch {r | w} <address> [<data>]

引用
Example Usage:
watch r 0x400 0x1234
watch r 0x40X 0x12X4
watch r 0b01000000XXXX 0b00010010XXXX0100
watch r 0x40X

说明:
Sets a read or write watchpoint at address. If the value compares to data, stop the processor.
•  Address and Data can be specified in hex “0x” format or binary “0b” format.
•  Don’t care values are specified using X.
•  Addresses can be only of contiguous range.
•  Default value of data is 0xXXXXXXXX. That is, it matches any value.

- 在GDB中Continue,程序就会在相应的地方停下,并在XMD窗口显示如下内容:
引用
XMD% watch w 0xbe4
XMD% Write Watchpoint 1 Hit, Processor Stopped at 0x000002e4


后续问题1: 这个watch和GDB图形程序中的Watch Expression有什么区别?
Watch Expression只能看到Expression的内容,不会在内容改变时将停下。

后续问题2: 怎样找到某个variable的地址?
方法1: 定义一个指针,把指针指向这个variable,就能得到地址了
方法2: 在GDB的Watch Experession中使用取地址符将这个variable的地址取出来。
方法3: 把这个变量定义为全局变量,那么地址在objdump的结果中就能直接找到。

【参考资料】
est_rm.pdf --> XMD章节
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]