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

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