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

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