How to debug a GCC segmentation fault

Configure GCC with --enable-checking. Compile it with -g -O0 so that you can use gdb.

Compile your test case with -v -da -Q.

Next, use gdb to get a stack trace:

bash$ gdb cc1
gdb> run arguments
(cc1 will stop at the segmentation fault)
gdb> where
gdb> list

Print out the values of interesting variables, e.g., the ones in the statement which got the segmentation fault. You can use the pt and pr macros from the gdbinit.in file to display GCC data. For example, if there is a value of type tree named t, and a value of type rtx named r, you can use these commands:

gdb> source .gdbinit
gdb> print t
gdb> pt
gdb> print r
gdb> pr
gdb> pt

Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to contact the FSF.

These pages are maintained by the GCC team.

For questions related to the use of GCC, please consult these web pages and the GCC manuals. If that fails, the gcc-help@gcc.gnu.org mailing list might help.
Please send comments on these web pages and the development of GCC to our developer mailing list at gcc@gnu.org or gcc@gcc.gnu.org. All of our lists have public archives.

Copyright (C) Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

Last modified 2005-07-11 Valid XHTML 1.0
Mirror provided by HKMirror. Sponsored by Porno Verzameling and webcamsex