2c2fa1
New testcase for:
2c2fa1
https://bugzilla.redhat.com/show_bug.cgi?id=466222
2c2fa1
	(for the first / customer recommended fix)
2c2fa1
and the upstream fix:
2c2fa1
http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html
2c2fa1
	[rfc] Do not make up line information
2c2fa1
http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html
2c2fa1
2c2fa1
--- /dev/null
2c2fa1
+++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c
2c2fa1
@@ -0,0 +1,21 @@
2c2fa1
+/* This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+   Copyright 2009 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This program is free software; you can redistribute it and/or modify
2c2fa1
+   it under the terms of the GNU General Public License as published by
2c2fa1
+   the Free Software Foundation; either version 3 of the License, or
2c2fa1
+   (at your option) any later version.
2c2fa1
+
2c2fa1
+   This program is distributed in the hope that it will be useful,
2c2fa1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+   GNU General Public License for more details.
2c2fa1
+
2c2fa1
+   You should have received a copy of the GNU General Public License
2c2fa1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2c2fa1
+
2c2fa1
+void
2c2fa1
+func (void)
2c2fa1
+{
2c2fa1
+}
2c2fa1
--- /dev/null
2c2fa1
+++ b/gdb/testsuite/gdb.base/lineno-makeup.c
2c2fa1
@@ -0,0 +1,35 @@
2c2fa1
+/* This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+   Copyright 2009 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This program is free software; you can redistribute it and/or modify
2c2fa1
+   it under the terms of the GNU General Public License as published by
2c2fa1
+   the Free Software Foundation; either version 3 of the License, or
2c2fa1
+   (at your option) any later version.
2c2fa1
+
2c2fa1
+   This program is distributed in the hope that it will be useful,
2c2fa1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+   GNU General Public License for more details.
2c2fa1
+
2c2fa1
+   You should have received a copy of the GNU General Public License
2c2fa1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2c2fa1
+
2c2fa1
+/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number
2c2fa1
+   information (.debug_line) so we cannot use an external object file.
2c2fa1
+   
2c2fa1
+   It must not be just a label as it would alias on the next function even for
2c2fa1
+   correct GDB.  Therefore some stub data must be placed there.
2c2fa1
+   
2c2fa1
+   We need to provide a real stub function body as at least s390
2c2fa1
+   (s390_analyze_prologue) would skip the whole body till reaching `main'.  */
2c2fa1
+
2c2fa1
+extern void func (void);
2c2fa1
+asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\"");
2c2fa1
+
2c2fa1
+int
2c2fa1
+main (void)
2c2fa1
+{
2c2fa1
+  func ();
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
--- /dev/null
2c2fa1
+++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
2c2fa1
@@ -0,0 +1,78 @@
2c2fa1
+# Copyright 2009 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+set testfile "lineno-makeup"
2c2fa1
+set srcfuncfile ${testfile}-func.c
2c2fa1
+set srcfile ${testfile}.c
2c2fa1
+set objfuncfile ${objdir}/${subdir}/${testfile}-func.o
2c2fa1
+set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin
2c2fa1
+set binfile ${objdir}/${subdir}/${testfile}
2c2fa1
+
2c2fa1
+if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } {
2c2fa1
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
2c2fa1
+}
2c2fa1
+
2c2fa1
+set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output]
2c2fa1
+verbose -log "objcopy=$objcopy: $output"
2c2fa1
+if { $objcopy != 0 } {
2c2fa1
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
2c2fa1
+}
2c2fa1
+set binfuncfilesize [file size $binfuncfile]
2c2fa1
+verbose -log "file size $binfuncfile = $binfuncfilesize"
2c2fa1
+
2c2fa1
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
2c2fa1
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
2c2fa1
+}
2c2fa1
+
2c2fa1
+gdb_exit
2c2fa1
+gdb_start
2c2fa1
+gdb_reinitialize_dir $srcdir/$subdir
2c2fa1
+gdb_load ${binfile}
2c2fa1
+
2c2fa1
+set b_addr ""
2c2fa1
+set test "break func"
2c2fa1
+gdb_test_multiple $test $test {
2c2fa1
+    -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
2c2fa1
+	set b_addr $expect_out(1,string)
2c2fa1
+	pass $test
2c2fa1
+    }
2c2fa1
+    -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" {
2c2fa1
+	set b_addr $expect_out(1,string)
2c2fa1
+	fail $test
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+verbose -log "b_addr=<$b_addr>"
2c2fa1
+
2c2fa1
+set p_addr ""
2c2fa1
+set test "print func"
2c2fa1
+gdb_test_multiple $test $test {
2c2fa1
+    -re "\\$\[0-9\]+ = {<text variable, no debug info>} (0x\[0-9a-f\]+) <func>\r\n$gdb_prompt $" {
2c2fa1
+	set p_addr $expect_out(1,string)
2c2fa1
+	pass $test
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+verbose -log "p_addr=<$p_addr>"
2c2fa1
+
2c2fa1
+set test "break address belongs to func"
2c2fa1
+if {$b_addr == $p_addr} {
2c2fa1
+    pass "$test (exact match)"
2c2fa1
+} else {
2c2fa1
+    set skip [expr $b_addr - $p_addr]
2c2fa1
+    if {$skip > 0 && $skip < $binfuncfilesize} {
2c2fa1
+	pass "$test (prologue skip by $skip bytes)"
2c2fa1
+    } else {
2c2fa1
+	fail $test
2c2fa1
+    }
2c2fa1
+}