您的位置:首页 > 其它

在脚本里面执行 gdb

2015-11-09 11:13 246 查看
1. 

$ echo disass main | gdb --silent test200
Reading symbols from test200...done.
(gdb) Dump of assembler code for function main:
0x080483eb <+0>: push %ebp
0x080483ec <+1>: mov %esp,%ebp
0x080483ee <+3>: mov $0x0,%eax
0x080483f3 <+8>: pop %ebp
0x080483f4 <+9>: ret
End of assembler dump.
(gdb) quit
charles@xiaotao:~$

2.
$ gdb --silent test200 <<< "disass main"
Reading symbols from test200...done.
(gdb) Dump of assembler code for function main:
0x080483eb <+0>: push %ebp
0x080483ec <+1>: mov %esp,%ebp
0x080483ee <+3>: mov $0x0,%eax
0x080483f3 <+8>: pop %ebp
0x080483f4 <+9>: ret
End of assembler dump.
(gdb) quit

3.

$ (echo -ne "disass main\nquit\n"; cat) | gdb --silent test200
Reading symbols from test200...done.
(gdb) Dump of assembler code for function main:
0x080483eb <+0>: push %ebp
0x080483ec <+1>: mov %esp,%ebp
0x080483ee <+3>: mov $0x0,%eax
0x080483f3 <+8>: pop %ebp
0x080483f4 <+9>: ret
End of assembler dump.
(gdb)


但是这个不能自动退出gdb.

http://stackoverflow.com/questions/322110/invoke-gdb-to-automatically-pass-arguments-to-the-program-being-debugged
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: