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

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