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