if (++i == 3)
abort();
else
recurse();
}
int main(int argc, char **argv)
{
recurse();
}
Вот небольшой сеанс GDB с этой программой:
$ gcc -g ch15-abort.c -o ch15-abort /* Компилировать без -O */
$ ch15-abort /* Запустить программу */
Aborted (core dumped) /* Она печально завершается */
$ gdb ch15-abort core.4124 /* Запустить для нее GDB */
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU
General Public License, and you are
welcome to change it and/or distribute copies of it
under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Core was generated by 'ch15-abort'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0x42028ccl in kill() from /lib/i686/libc.so.6