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

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