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