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

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