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

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