[英]gdb user-defined functions: how to pass complex argument?
I want to examine several QString variables, so I found macros for this in Internet: 我想检查几个QString变量,所以我在Internet上找到了这个宏:
define printqstring
printf "(QString)0x%x (length=%i): \"",&$arg0,$arg0.d->size
set $i=0
while $i < ($arg0).d->size
set $c=$arg0.d->data[$i++]
if $c < 32 || $c > 127
printf "\\u0x%04x", $c
else
printf "%c", (char)$c
end
end
printf "\"\n"
end
But when I try to use it, I got such error: 但是当我尝试使用它时,出现了这样的错误:
(gdb) printqstring ((MyWidget *)0xd98cb0)->caption_
A syntax error in expression, near `,((MyWidget.d->size'.
if I try to use commands from macros by hand, they work fine: 如果我尝试手动使用宏命令,它们可以正常工作:
(gdb) printf "(QString)0x%x (length=%i): \"",&((MyWidget *)0xd98cb0)->caption_,((MyWidget *)0xd98cb0)->caption_.d->size
(QString)0xd98ccc (length=3)
So how can I pass such complex argument to gdb macros? 那么如何将这样复杂的参数传递给gdb宏呢?
Unfortunately gdb always divides input to a user-defined function at any space character, even if that character is inside parentheses or something like that. 不幸的是,gdb总是在任何空格字符处将输入划分为用户定义的函数,即使该字符位于括号内或类似的内容内。
So you can just make sure you don't use any spaces in the argument you want to pass: 因此,您可以确保不要在要传递的参数中使用任何空格:
(gdb) printqstring ((MyWidget*)0xd98cb0)->caption_
^~~ removed space
I don't know of any good way to make this more convenient and allow spaces. 我不知道有什么好方法可以使此操作更加方便并留出空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.