我在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”是否实际存在并不重要。
例如
(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)
关于c++ - gdb类是不完整的类型,直到我在类构造函数中设置断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41068557/