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

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