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

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