gdb输出stl-终结者

gdb中输出vector之类stl的方法可以用建立问价.gdbinit放在home下,
然而仍然不能输出嵌套的vector,下面的方法解决了这个问题
With GCC 4.1.2, to print the whole of a std::vector<int> called myVector, do the following:

print *(myVector._M_impl._M_start)@myVector.size()
To print only the first N elements, do:

print *(myVector._M_impl._M_start)@N
Explanation

This is probably heavily dependent on your compiler version, but for GCC 4.1.2, the pointer to the internal array is:

myVector._M_impl._M_start
And the GDB command to print N elements of an array starting at pointer P is:

print P@N
Or, in a short form (for a standard .gdbinit):

p P@N
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值