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

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