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

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