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