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

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