Blame SOURCES/gdb-lineno-makeup-test.patch

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