版权声明:打劫来的原创!!未经允许可随便转载。【 May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely,never taking more than you give. 】 https://blog.csdn.net/hunter___/article/details/88654515
gdb 调试模式下,循环输出
(gdb) set $x=13
(gdb) while $x--
>p $x
>end
$6 = 12
$7 = 11
$8 = 10
$9 = 9
$10 = 8
$11 = 7
$12 = 6
$13 = 5
$14 = 4
$15 = 3
$16 = 2
$17 = 1
$18 = 0
实际用起来:
真是打击啊,,,
(gdb) set $x=13
(gdb) while $x--
>set $PCur=0x614c20
>set $data=$PCur->mData
>p $data
>set $PCur=PCur->mNext
>end
Attempt to extract a component of a value that is not a structure pointer.
(gdb) set $x=13
(gdb) while $x--
>if(PCur->mData)
>PCur=PCur->mNext
>p PCur->mData
>end
>end
(gdb)
nm
我的锅,要set啦!!!
Attempt to extract a component of a value that is not a structure pointer.
(gdb) set $x=13
(gdb) while $x--
>if(PCur->mData)
>PCur=PCur->mNext
>p PCur->mData
>end
>end
(gdb) p PCur->mData
$19 = 0
(gdb) PCur=PCur->mNext
Undefined command: "PCur". Try "help".
(gdb) PCur=(PCur->mNext)
Undefined command: "PCur". Try "help".
(gdb) set PCur=(PCur->mNext)
(gdb) p PCur->mData
$20 = 5
再来:
(gdb) set $x=13
(gdb) while $x--
>p PCur->mData
>set PCur=(PCur->mNext)
>end
$21 = 5
$22 = 8
$23 = 666
$24 = 666
$25 = 12
$26 = 6
$27 = 4
$28 = 6
$29 = 9
$30 = 1
$31 = 4
$32 = 8
$33 = 2
(gdb)
成功打印,,
如何直接写成个gdb脚本呢,两个参数,链表地址,不用长度