我在 gdb 中调试 Chrome 时总是遇到这个问题:
如果我尝试打印某种类型的变量,GDB 不知道其内部结构:
(gdb) p current_child_.get()
$12 = (blink::NGBlockNode *) 0xc2f755c1830
(gdb) p *(current_child_.get())
$13 = <incomplete type>
但是,如果我只是在该类的构造函数中设置断点,gdb 会突然发现该类型的符号:
(gdb) br blink::NGBlockNode::NGBlockNode
Breakpoint 3 at 0x51db40 (4 locations)
(gdb) p *(current_child_.get())
$14 = {
<blink::NGLayoutInputNode> = {
<blink::GarbageCollectedFinalized<blink::NGLayoutInputNode>> = {
<blink::GarbageCollected<blink::NGLayoutInputNode>> = {<No data fields>}, <No data fields>},
这太烦人了,我有一组宏来在我通常打印的类中设置断点。还有其他解决方法吗?
我知道一种解决方法。如果您知道定义该类型的文件,则可以通过“print 'file.cc'::some_variable”强制加载该类型的调试信息。这个“some_variable”是否确实存在并不重要。
e.g.
(gdb) p render_thread
$2 = (content::RenderThreadImpl *) 0x1261201f7920
(gdb) p *render_thread
$3 = <incomplete type>
(gdb) ptype render_thread
type = class content::RenderThreadImpl {
<incomplete type>
} *
(gdb) p 'render_thread_impl.cc'::nonexist_variable
No symbol "nonexist_variable" in specified context.
(gdb) ptype render_thread
type = /* real type = content::RenderThreadImpl * */
class content::RenderThreadImpl : <snipped> {
<snipped>
} *
(gdb) p *render_thread
$4 = (content::RenderThreadImpl) { <snipped> }
(gdb)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)