如何添加表达式以使用 Eclipse 中的监视窗口查看内存范围?
mysql有如下代码:
table->file->ha_write_row(table->record[0]))
其中 table->record[0] 是一个缓冲区,其大小由另一个变量 reclength 确定。现在我知道了reclength,看到它是203。我想查看值(table->record[0])[0..202],这意味着从第一个字节到最后一个字节。如果我只是将 (table->record[0]) 放入手表中,它只会显示几个字符,因为 table->record[0] 中有很多 0,比如“xxx\\0\\” 0\\0yyy...”,在这种情况下,eclipse只在监视窗口中显示“xxx”,因为它认为“xxx\0”是以“\\0”结尾的完整字符串,但实际上我想看到更多缓冲值。所以我在手表中使用了 (table->record[0])[i],i 是 0 , 1, 2 ..,但这很无聊,有什么好方法可以看到所有这些吗?
The mysql has the following code:
table->file->ha_write_row(table->record[0]))
where table->record[0] is a buffer whose size is determined by another variable reclength. Now I know the reclength, see it's 203. And I want to see the value (table->record[0])[0..202], which means from the first byte to the last byte. If I just put (table->record[0]) in the watch, it only display several chars as there are many 0 inside table->record[0], say it could be like "xxx\\0\\0\\0yyy...", In this case, eclipse only show "xxx" in the watch window as it thinks "xxx\0" is the complete string terminated by "\\0", but actually I want to see more buffer value. So I used (table->record[0])[i] in the watch, i is 0 , 1, 2 .., but that's boring, is there any good way to see all of them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 gdb 语法打印数组值,对于第一个元素由指针
p
指向的数组,使用:要查看前 100 个元素。在您的情况下,编辑您的监视表达式(左键单击 ->
编辑监视表达式
):您没有提到
表->记录
的类型 ---我假设它保存指针(而不是指针到指针)。顺便说一句,您可以将指针转换为任何数据类型,就像在 gdb 控制台中一样。
Use the gdb syntax for printing array values, for array whose first element is pointed to by pointer
p
, use:To see first 100 elements. In your case, edit your watch expression (left click ->
Edit Watch Expression
) to:You didn't mention the type of
table->record
--- I am assuming it holds the pointer (and not the pointer-to-pointer).And btw, you can cast your pointer to any data type, exactly as in a gdb console.