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

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