gdb调试某应用,可以直接使用sudo gdb /usr/local/bin/git
,可以使用run方法执行特殊指令,比如run checkout -f HEAD
。
详情执行如下:
sudo gdb /usr/local/bin/git
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-92.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/bin/git...(no debugging symbols found)...done.
(gdb) run checkout -f HEAD
Starting program: /usr/local/bin/git checkout -f HEAD
[Thread debugging using libthread_db enabled]
fatal: BUG: your vsnprintf is broken (returned -1)
Program exited with code 0200.
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.209.el6_9.1.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt