Index: gdb/testsuite/gdb.base/prologue-gccbug49906.exp
===================================================================
RCS file: gdb/testsuite/gdb.base/prologue-gccbug49906.exp
diff -N gdb/testsuite/gdb.base/prologue-gccbug49906.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/prologue-gccbug49906.exp 25 Oct 2011 17:29:12 -0000
@@ -0,0 +1,45 @@
+# Test for prologue skipping in minimal symbols with line info when
+# compiled with -O0. Test workaround gcc bug 49906.
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+set testfile "prologue"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug optimize=-O0}] != "" } {
+ untested prologue.exp
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+set loc_end_of_prologue_workaround [gdb_get_line_number "end of prologue workaround"]
+set loc_end_of_prologue_broken [gdb_get_line_number "end of prologue broken"]
+
+# Test less human-confusing breakpoint location in case weirdness is
+# encountered.
+gdb_test "break f_gccbug49906"\
+ "Breakpoint.*at.*file.*$srcfile,.*line.*$loc_end_of_prologue_workaround\\."\
+ "Workaround gcc bug 49906 worked"
+
Index: gdb/testsuite/gdb.base/prologue.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/prologue.c,v
retrieving revision 1.6
diff -u -p -r1.6 prologue.c
--- gdb/testsuite/gdb.base/prologue.c 1 Jan 2011 15:33:42 -0000 1.6
+++ gdb/testsuite/gdb.base/prologue.c 25 Oct 2011 17:29:12 -0000
@@ -16,6 +16,15 @@
along with this program. If not, see .
*/
+
+static int i;
+static void
+f_gccbug49906 (void)
+{ for (;;) /* end of prologue workaround - Weird style intended! */
+ if (i++)
+ break;
+} /* end of prologue broken */
+
int leaf (void)
{
return 1;
@@ -33,6 +42,7 @@ int main(void)
{
marker (0);
marker (0);
+ f_gccbug49906 (); /* set breakpoint here */
return 0;
}