root@ct:~/Desktop# ulimit -c unlimited ----------------produce core file
root@ct:~/Desktop# gcc -g test.c -o test--------------- -g then we can use gdb
root@ct:~/Desktop# gdb ./test ----------------------- run the program
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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 "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./test...done.
(gdb) run
Starting program: /root/Desktop/test
Program received signal SIGSEGV, Segmentation fault.
0x080483fd in main () at test.c:7
7 *p=5;
(gdb) bt ----------------------- bt means backtrace ----print stack and heap information
#0 0x080483fd in main () at test.c:7
(gdb)
简单的gdb 使用
最新推荐文章于 2024-10-07 00:08:39 发布