- Patches added (backports from trunk):

* gdb-testsuite-add-gdb.opt-break-on-_exit.exp.patch
  * gdb-tdep-rs6000-don-t-skip-system-call-in-skip_prologue.patch
  * gdb-testsuite-fix-stepi-test-cases-with-unix-m32-fpie-pie.patch
  * gdb-testsuite-fix-assembly-comments-in-gdb.dwarf2-clang-debug-names.exp.tcl.patch
  * gdb-doc-fix-print-inferior-events-default.patch
  * gdb-testsuite-fix-gdb.guile-scm-type.exp-with-gcc-4.8.patch
  * gdb-testsuite-add-gdb.arch-ppc64-break-on-_exit.exp.patch
  * gdb-testsuite-don-t-error-when-trying-to-unset-last_spawn_tty_name.patch
  * gdb-exp-improve-error-reading-variable-message.patch
  * fix-gdb.base-sigstep.exp-test-for-ppc.patch
  * gdb-testsuite-fix-regexp-in-gdb.base-foll-vfork.exp.patch
- Patches added (backports from ml):
  * gdb-testsuite-disable-inferior-output-in-gdb.base-foll-vfork.exp.patch
- Maintenance script qa.sh:
  - Add -m32/-pie to known clean configs.
  - Add kfail for PR28467.

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=303
This commit is contained in:
Tom de Vries 2021-11-15 14:37:03 +00:00 committed by Git OBS Bridge
parent a904cd2911
commit 67695ab596
15 changed files with 1460 additions and 5 deletions

View File

@ -0,0 +1,58 @@
Fix gdb.base/sigstep.exp test for ppc
The test stops at <signal_handler called> which is the call to the handler
rather than in the handler as intended. This patch replaces the
gdb_test "$enter_cmd to handler" with a gdb_test_multiple test. The multiple
test looks for the stop at <signal_handler called>. If found, the command
is issued again. The test passes if gdb stops in the handler as expected.
(gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step
from handler: continue to signal
stepi
<signal handler called>
1: x/i $pc
=> 0x7ffff7f80440 <__kernel_start_sigtramp_rt64>: bctrl
(gdb) stepi
handler (sig=551) at sigstep.c:32
32 {
1: x/i $pc
=> 0x10000097c <handler>: addis r2,r12,2
(gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler,
step from handler: stepi to handler
Patch has been tested on x86_64-linux and ppc64le-linux with no test failures.
---
gdb/testsuite/gdb.base/sigstep.exp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp
index ea254af5297..176918b67d6 100644
--- a/gdb/testsuite/gdb.base/sigstep.exp
+++ b/gdb/testsuite/gdb.base/sigstep.exp
@@ -79,6 +79,7 @@ validate_backtrace
proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } {
global gdb_prompt inferior_exited_re
global clear_done other_handler_location
+ global decimal
set prefix "$enter_cmd to handler, $in_handler_prefix in handler, $exit_cmd from handler"
@@ -93,7 +94,16 @@ proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } {
gdb_test "handle SIGVTALRM print pass stop"
gdb_test "continue" "Program received signal.*" "continue to signal"
}
- gdb_test "$enter_cmd" ".*handler .*" "$enter_cmd to handler"
+
+ gdb_test_multiple "$enter_cmd" "$enter_cmd to handler" {
+ -re -wrap "\r\n<signal handler called>.*" {
+ send_gdb "$enter_cmd\n"
+ exp_continue
+ }
+ -re -wrap "\r\n(Breakpoint $decimal, )?handler \\(sig=.*" {
+ pass $gdb_test_name
+ }
+ }
delete_breakpoints

View File

@ -0,0 +1,29 @@
[gdb/doc] Fix print inferior-events default
In the docs about print inferior-events we read:
...
By default, these messages will not be printed.
...
That used to be the case, but is no longer so since commit f67c0c91715 "Enable
'set print inferior-events' and improve detach/fork/kill/exit messages".
Fix this by updating the docs.
---
gdb/doc/gdb.texinfo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1700b0305c5..d53c9a03704 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -3395,7 +3395,7 @@ control use @w{@code{set print inferior-events}}:
The @code{set print inferior-events} command allows you to enable or
disable printing of messages when @value{GDBN} notices that new
inferiors have started or that inferiors have exited or have been
-detached. By default, these messages will not be printed.
+detached. By default, these messages will be printed.
@kindex show print inferior-events
@item show print inferior-events

View File

@ -0,0 +1,138 @@
[gdb/exp] Improve <error reading variable> message
When printing a variable x in a subroutine foo:
...
subroutine foo (x)
integer(4) :: x (*)
x(3) = 1
end subroutine foo
...
where x is an array with unknown bounds, we get:
...
$ gdb -q -batch outputs/gdb.fortran/array-no-bounds/array-no-bounds \
-ex "break foo" \
-ex run \
-ex "print x"
Breakpoint 1 at 0x4005cf: file array-no-bounds.f90, line 18.
Breakpoint 1, foo (x=...) at array-no-bounds.f90:18
18 x(3) = 1
$1 = <error reading variable>
...
Improve the error message by printing the details of the error, such that we
have instead:
...
$1 = <error reading variable: failed to get range bounds>
...
This is a change in gdb/valprint.c, and grepping through the sources reveals
that this is a common pattern.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.fortran/array-no-bounds.exp | 44 +++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/array-no-bounds.f90 | 30 ++++++++++++++++++
gdb/valprint.c | 2 +-
3 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.fortran/array-no-bounds.exp b/gdb/testsuite/gdb.fortran/array-no-bounds.exp
new file mode 100644
index 00000000000..a686232cb0e
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/array-no-bounds.exp
@@ -0,0 +1,44 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite. It contains test to ensure that
+# array bounds accept LONGEST.
+
+if { [skip_fortran_tests] } { return -1 }
+
+standard_testfile .f90
+load_lib fortran.exp
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {f90 debug}] } {
+ return -1
+}
+
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
+ continue
+}
+
+# Go to foo.
+gdb_breakpoint foo
+gdb_continue_to_breakpoint "foo"
+
+# Print x, and check that we get a useful error message.
+gdb_test "p x" \
+ " = <error reading variable: failed to get range bounds>"
+
+# Print x using @ syntax.
+gdb_test "p x(1)@5" \
+ " = \\(0, 0, 0, 0, 0\\)"
diff --git a/gdb/testsuite/gdb.fortran/array-no-bounds.f90 b/gdb/testsuite/gdb.fortran/array-no-bounds.f90
new file mode 100644
index 00000000000..7b9ca998fff
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/array-no-bounds.f90
@@ -0,0 +1,30 @@
+! Copyright 2021 Free Software Foundation, Inc.
+
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+subroutine foo (x)
+ integer(4) :: x (*)
+ x(3) = 1
+end subroutine foo
+
+program test
+ interface
+ subroutine foo (x)
+ integer(4) :: x (*)
+ end subroutine
+ end interface
+ integer(4) :: x (5)
+ x(:) = 0
+ call foo (x)
+end program
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 324055da93f..05740c838ad 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1050,7 +1050,7 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse,
catch (const gdb_exception_error &except)
{
fprintf_styled (stream, metadata_style.style (),
- _("<error reading variable>"));
+ _("<error reading variable: %s>"), except.what ());
}
}

View File

@ -0,0 +1,53 @@
[gdb/tdep, rs6000] Don't skip system call in skip_prologue
I ran into a case where a breakpoint on _exit never triggered, because it was
set past the end of the _exit prologue, past the end of the exit_group system
call (which does not return).
More concretely, the breakpoint was set at the last insn show here:
...
Dump of assembler code for function _exit:
0x00007ffff7e42ea0 <+0>: 12 00 4c 3c addis r2,r12,18
0x00007ffff7e42ea4 <+4>: 60 43 42 38 addi r2,r2,17248
0x00007ffff7e42ea8 <+8>: 00 00 00 60 nop
0x00007ffff7e42eac <+12>: f8 ff e1 fb std r31,-8(r1)
0x00007ffff7e42eb0 <+16>: 78 1b 7f 7c mr r31,r3
0x00007ffff7e42eb4 <+20>: f0 ff c1 fb std r30,-16(r1)
0x00007ffff7e42eb8 <+24>: ea 00 00 38 li r0,234
0x00007ffff7e42ebc <+28>: a0 8b 22 e9 ld r9,-29792(r2)
0x00007ffff7e42ec0 <+32>: 78 fb e3 7f mr r3,r31
0x00007ffff7e42ec4 <+36>: 14 6a c9 7f add r30,r9,r13
0x00007ffff7e42ec8 <+40>: 02 00 00 44 sc
0x00007ffff7e42ecc <+44>: 26 00 00 7c mfcr r0
0x00007ffff7e42ed0 <+48>: 00 10 09 74 andis. r9,r0,4096
...
Fix this by treating system calls the same as branches in skip_prologue:
by default, don't skip, such that the breakpoint is set at 0x00007ffff7e42eb8
instead.
Tested on ppc64le-linux, on a power 8 machine.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28527
---
gdb/rs6000-tdep.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 826f0266ed8..9ac5db57898 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2137,6 +2137,12 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
/* Never skip branches. */
break;
+ /* Test based on opcode and mask values of
+ powerpc_opcodes[svc..svcla] in opcodes/ppc-opc.c. */
+ if ((op & 0xffff0000) == 0x44000000)
+ /* Never skip system calls. */
+ break;
+
if (num_skip_non_prologue_insns++ > max_skip_non_prologue_insns)
/* Do not scan too many insns, scanning insns is expensive with
remote targets. */

View File

@ -0,0 +1,348 @@
[gdb/testsuite] Add gdb.arch/ppc64-break-on-_exit.exp
Add a regression test-case for commit a50bdb99afe "[gdb/tdep, rs6000] Don't
skip system call in skip_prologue":
- set a breakpoint on a local copy of glibc's _exit, and
- verify that it triggers.
The test-case uses an assembly file by default, but also has the possibility
to use a C source file instead.
Tested on ppc64le-linux. Verified that the test-case fails without
aforementioned commit, and passes with the commit. Both with assembly
and C source.
---
gdb/testsuite/gdb.arch/ppc64-break-on-_exit-main.c | 27 +++++
gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c | 112 +++++++++++++++++++++
gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp | 56 +++++++++++
gdb/testsuite/gdb.arch/ppc64-break-on-_exit.s | 108 ++++++++++++++++++++
4 files changed, 303 insertions(+)
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit-main.c b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit-main.c
new file mode 100644
index 00000000000..77253140e36
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit-main.c
@@ -0,0 +1,27 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+
+__thread int __libc_errno;
+
+int
+main ()
+{
+ _exit (22);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c
new file mode 100644
index 00000000000..8638a7a6b70
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c
@@ -0,0 +1,112 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file was generated from glibc's 2.31 _exit.c, by doing a glibc build
+ on ppc64le-linux, copying the command line, adding -g0 -save-temps and
+ recuding the _exit.i file. */
+
+void _exit (int status);
+
+extern __thread int __libc_errno;
+
+void
+_exit (int status)
+{
+ while (1)
+ {
+ ({
+ long int sc_err __attribute__ ((unused));
+ long int sc_ret
+ = ({
+ register long int r0 __asm__ ("r0");
+ register long int r3 __asm__ ("r3");
+ register long int r4 __asm__ ("r4");
+ register long int r5 __asm__ ("r5");
+ register long int r6 __asm__ ("r6");
+ register long int r7 __asm__ ("r7");
+ register long int r8 __asm__ ("r8");
+ long int arg1 = (long int) (status);
+
+ r0 = 234;
+
+ extern void __illegally_sized_syscall_arg1 (void);
+ if (__builtin_classify_type (status) != 5 && sizeof (status) > 8)
+ __illegally_sized_syscall_arg1 ();
+
+ r3 = arg1;
+ __asm__ __volatile__ ("sc\n\t" "mfcr %0\n\t" "0:"
+ : "=&r" (r0), "=&r" (r3), "=&r" (r4),
+ "=&r" (r5), "=&r" (r6), "=&r" (r7),
+ "=&r" (r8) : "0" (r0), "1" (r3)
+ : "r9", "r10", "r11", "r12", "cr0", "ctr", "memory");
+ sc_err = r0;
+
+ r3;
+ });
+
+ if (((void) (sc_ret), __builtin_expect ((sc_err) & (1 << 28), 0)))
+ {
+ (__libc_errno = ((sc_ret)));
+ sc_ret = -1L;
+ }
+
+ sc_ret;
+ });
+
+ ({
+ long int sc_err __attribute__ ((unused));
+ long int sc_ret
+ = ({
+ register long int r0 __asm__ ("r0");
+ register long int r3 __asm__ ("r3");
+ register long int r4 __asm__ ("r4");
+ register long int r5 __asm__ ("r5");
+ register long int r6 __asm__ ("r6");
+ register long int r7 __asm__ ("r7");
+ register long int r8 __asm__ ("r8");
+ long int arg1 = (long int) (status);
+
+ r0 = 1;
+
+ extern void __illegally_sized_syscall_arg1 (void);
+ if (__builtin_classify_type (status) != 5 && sizeof (status) > 8)
+ __illegally_sized_syscall_arg1 ();
+
+ r3 = arg1;
+ __asm__ __volatile__ ("sc\n\t" "mfcr %0\n\t" "0:"
+ : "=&r" (r0), "=&r" (r3), "=&r" (r4),
+ "=&r" (r5), "=&r" (r6), "=&r" (r7),
+ "=&r" (r8) : "0" (r0), "1" (r3)
+ : "r9", "r10", "r11", "r12", "cr0", "ctr", "memory");
+ sc_err = r0;
+
+ r3;
+ });
+
+ if (((void) (sc_ret), __builtin_expect ((sc_err) & (1 << 28), 0)))
+ {
+ (__libc_errno = ((sc_ret)));
+ sc_ret = -1L;
+ }
+
+ sc_ret;
+ });
+
+
+ asm (".long 0");
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
new file mode 100644
index 00000000000..b2fef8e8b76
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
@@ -0,0 +1,56 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Set a breakpoint on a local copy of glibc's _exit, and verify that it
+# triggers. The function does a syscall immediately after the prologue, and
+# if the breakpoint is set past the syscall due to faulty prologue skipping,
+# the breakpoint will not trigger.
+#
+# In particular, we're trying to excercise the instruction analysis
+# functionality of prologue skipping. If non-minimal symbols are
+# read, then that functionality might not be used because f.i.
+# line-info is used instead. So, we use nodebug.
+
+if {![istarget "powerpc*"] || ![is_lp64_target]} {
+ unsupported "Not powerpc64"
+ return
+}
+
+set flags { nodebug }
+if { 1 } {
+ standard_testfile .s -main.c
+} else {
+ standard_testfile .c -main.c
+ lappend flags optimize=-O2
+ lappend flags additional_flags=-fno-stack-protector
+ lappend flags additional_flags=-mlong-double-128
+ lappend flags additional_flags=-fpic
+ lappend flags additional_flags=-ftls-model=initial-exec
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $srcfile2] $flags] } {
+ return -1
+}
+
+if ![runto_main] then {
+ return 0
+}
+
+gdb_breakpoint "_exit"
+
+# If the skip_prologue analysis of _exit is too eager, we may not hit the
+# breakpoint.
+gdb_continue_to_breakpoint "_exit" "_exit \\(\\).*"
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.s b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.s
new file mode 100644
index 00000000000..37a9ace2aff
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.s
@@ -0,0 +1,108 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file was generated from ppc64-break-on-_exit.c. */
+
+ .file "ppc64-break-on-_exit.c"
+ .abiversion 2
+ .section ".text"
+ .align 2
+ .p2align 4,,15
+ .globl _exit
+ .type _exit, @function
+_exit:
+.LCF0:
+0: addis 2,12,.TOC.-.LCF0@ha
+ addi 2,2,.TOC.-.LCF0@l
+ .localentry _exit,.-_exit
+ addis 9,2,__libc_errno@got@tprel@ha
+ std 31,-8(1)
+ mr 31,3
+ std 30,-16(1)
+ li 0,234
+ ld 9,__libc_errno@got@tprel@l(9)
+ mr 3,31
+ add 30,9,__libc_errno@tls
+#APP
+ # 28 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ sc
+ mfcr 0
+ 0:
+ # 0 "" 2
+#NO_APP
+ andis. 9,0,0x1000
+ mr 9,3
+ li 0,1
+ mr 3,31
+ bne 0,.L13
+ .p2align 4,,15
+.L2:
+#APP
+ # 67 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ sc
+ mfcr 0
+ 0:
+ # 0 "" 2
+#NO_APP
+ andis. 9,0,0x1000
+ bne 0,.L14
+.L3:
+#APP
+ # 87 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ .long 0
+ # 0 "" 2
+#NO_APP
+.L15:
+ li 0,234
+ mr 3,31
+#APP
+ # 28 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ sc
+ mfcr 0
+ 0:
+ # 0 "" 2
+#NO_APP
+ andis. 9,0,0x1000
+ mr 9,3
+ li 0,1
+ mr 3,31
+ beq 0,.L2
+.L13:
+ stw 9,0(30)
+#APP
+ # 67 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ sc
+ mfcr 0
+ 0:
+ # 0 "" 2
+#NO_APP
+ andis. 9,0,0x1000
+ beq 0,.L3
+ .p2align 4,,15
+.L14:
+ stw 3,0(30)
+#APP
+ # 87 "src/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c" 1
+ .long 0
+ # 0 "" 2
+#NO_APP
+ b .L15
+ .long 0
+ .byte 0,0,0,0,0,2,0,0
+ .size _exit,.-_exit
+ .ident "GCC: (SUSE Linux) 7.5.0"
+ .section .note.GNU-stack,"",@progbits

View File

@ -0,0 +1,131 @@
[gdb/testsuite] Add gdb.opt/break-on-_exit.exp
Add a test-case to excercise the problem scenario reported in PR28527 and
fixed in commit a50bdb99afe "[gdb/tdep, rs6000] Don't skip system call in
skip_prologue":
- set a breakpoint on _exit, and
- verify that it triggers.
Note that this is not a regression test for that commit. Since the actual
code in _exit may vary across os instances, we cannot guarantee that the
problem will always trigger with this test-case.
Rather, this test-case is a version of the original test-case
(gdb.threads/process-dies-while-detaching.exp) that is minimal while still
reproducing the problem reported in PR28527, in that same setting.
The benefit of this test-case is that it exercise real-life code and may
expose similar problems in other settings. Also, it provides a much easier
test-case to investigate in case a similar problem occurs.
Tested on x86_64-linux and ppc64le-linux.
---
gdb/testsuite/gdb.opt/break-on-_exit.c | 26 +++++++++++++
gdb/testsuite/gdb.opt/break-on-_exit.exp | 66 ++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+)
diff --git a/gdb/testsuite/gdb.opt/break-on-_exit.c b/gdb/testsuite/gdb.opt/break-on-_exit.c
new file mode 100644
index 00000000000..d8da66193a8
--- /dev/null
+++ b/gdb/testsuite/gdb.opt/break-on-_exit.c
@@ -0,0 +1,26 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+
+int
+main (void)
+{
+ _exit (0);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.opt/break-on-_exit.exp b/gdb/testsuite/gdb.opt/break-on-_exit.exp
new file mode 100644
index 00000000000..38476412862
--- /dev/null
+++ b/gdb/testsuite/gdb.opt/break-on-_exit.exp
@@ -0,0 +1,66 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+# Set a breakpoint on libc's _exit, and verify that it triggers. The function
+# tends to do a syscall immediately after the prologue, and if the breakpoint is
+# set past the syscall due to faulty prologue skipping, the breakpoint will not
+# trigger.
+#
+# In particular, we're trying to excercise the instruction analysis
+# functionality of prologue skipping. If the non-minimal symbols are
+# read for libc, then that functionality might not be used because f.i.
+# line-info is used instead. Also, if the minimal symbols are not read
+# for libc, then the breakpoint is set on the exec-local _exit@plt instead,
+# and that functionality will also not be used.
+#
+# We may get the required setup in case of a libc with misssing separate
+# debuginfo, but we want the same effect if that debuginfo is installed.
+#
+# So, we use -readnever to read minimal symbols, but not non-miminal symbols.
+#
+# Because the code at _exit may be and usually is optimized, the test is in
+# the gdb.opt directory.
+
+standard_testfile
+
+# See if we have target board readnow.exp or similar.
+if { [lsearch -exact $GDBFLAGS -readnow] != -1 \
+ || [lsearch -exact $GDBFLAGS --readnow] != -1 } {
+ untested "--readnever not allowed in combination with --readnow"
+ return -1
+}
+
+save_vars { GDBFLAGS } {
+ append GDBFLAGS " -readnever"
+
+ if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} {
+ return -1
+ }
+}
+
+if ![runto_main] then {
+ return 0
+}
+
+gdb_breakpoint "_exit"
+
+# Give some background information about the breakpoint(s) and corresponding
+# the shared lib(s).
+gdb_test "info breakpoints"
+gdb_test "info shared"
+
+# If the skip_prologue analysis of _exit is too eager, we may not hit the
+# breakpoint.
+gdb_continue_to_breakpoint "_exit" "_exit \\(\\) .*"

View File

@ -0,0 +1,153 @@
[gdb/testsuite] Disable inferior output in gdb.base/foll-vfork.exp
Test-case gdb.base/foll-vfork.exp has inferior output that is not needed, but
which makes the regexp matching more difficult (see commit 1f28b70def1
"[gdb/testsuite] Fix regexp in gdb.base/foll-vfork.exp").
Disable the inferior output using '#if DEBUG'.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/foll-vfork-exit.c | 14 ++++++++++++--
gdb/testsuite/gdb.base/foll-vfork.c | 9 ++++++++-
gdb/testsuite/gdb.base/foll-vfork.exp | 17 +++++++++++------
gdb/testsuite/gdb.base/vforked-prog.c | 7 ++++++-
4 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork-exit.c b/gdb/testsuite/gdb.base/foll-vfork-exit.c
index 6c263cdc057..15e272afe82 100644
--- a/gdb/testsuite/gdb.base/foll-vfork-exit.c
+++ b/gdb/testsuite/gdb.base/foll-vfork-exit.c
@@ -29,12 +29,22 @@ main ()
pid = vfork (); /* VFORK */
if (pid == 0)
{
- printf ("I'm the child!\n");
+ const char *s = "I'm the child!";
+#if DEBUG
+ printf ("%s\n", s);
+#else
+ const char *volatile v = s;
+#endif
_exit (0);
}
else
{
- printf ("I'm the proud parent of child #%d!\n", pid);
+ const char *s = "I'm the proud parent of child";
+#if DEBUG
+ printf ("%s #%d!\n", s, pid);
+#else
+ const char *volatile v = s;
+#endif
}
return 0;
diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c
index 2f6661d1a0b..b7e332e146b 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.c
+++ b/gdb/testsuite/gdb.base/foll-vfork.c
@@ -40,12 +40,19 @@ main (int argc, char ** argv)
memcpy (prog + len - 10, "vforked-prog", 12);
prog[len + 2] = 0;
+#if DEBUG
printf ("I'm the child!\n");
+#endif
execlp (prog, prog, (char *) 0);
perror ("exec failed");
_exit (1);
}
else {
- printf ("I'm the proud parent of child #%d!\n", pid);
+ const char *s = "I'm the proud parent of child";
+#if DEBUG
+ printf ("%s #%d!\n", s, pid);
+#else
+ const char *volatile v = s;
+#endif
}
}
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index a781a5c2087..fc710167f7d 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -32,9 +32,14 @@ if [gdb_debug_enabled] {
return 0
}
+# Set DEBUG to 0 or 1 in sources.
+set debug 0
+
standard_testfile
-set compile_options debug
+set compile_options {}
+lappend compile_options debug
+lappend compile_options additional_flags=-DDEBUG=$debug
if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
untested "failed to compile main testcase"
@@ -126,7 +131,7 @@ proc vfork_parent_follow_to_bp {} {
gdb_test_no_output "set follow-fork parent"
- set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
+ set bp_location [gdb_get_line_number "I'm the proud parent of child"]
gdb_test "break ${srcfile}:${bp_location}" ".*" "break, vfork to bp"
set test "continue to bp"
@@ -176,7 +181,7 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
gdb_test_no_output "set follow-fork child"
- set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+ set linenum [gdb_get_line_number "Hello from vforked-prog" ${srcfile2}]
set test "continue to bp"
gdb_test_multiple "continue" $test {
@@ -278,7 +283,7 @@ proc tcatch_vfork_then_child_follow_exec {} {
continue_to_vfork
set linenum1 [gdb_get_line_number "pid = vfork ();"]
- set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+ set linenum2 [gdb_get_line_number "Hello from vforked-prog" ${srcfile2}]
set test "finish"
gdb_test_multiple "finish" $test {
@@ -356,7 +361,7 @@ proc vfork_relations_in_info_inferiors { variant } {
if { $variant == "exec" } {
global srcfile2
- set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+ set linenum [gdb_get_line_number "Hello from vforked-prog" ${srcfile2}]
set test "continue to bp"
gdb_test_multiple "continue" $test {
-re ".*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
@@ -487,7 +492,7 @@ set testfile "foll-vfork-exit"
set srcfile ${testfile}.c
set binfile [standard_output_file ${testfile}]
-if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
+if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
untested "failed to build $testfile"
return
}
diff --git a/gdb/testsuite/gdb.base/vforked-prog.c b/gdb/testsuite/gdb.base/vforked-prog.c
index 936c6e6032d..999efa8ce0d 100644
--- a/gdb/testsuite/gdb.base/vforked-prog.c
+++ b/gdb/testsuite/gdb.base/vforked-prog.c
@@ -19,6 +19,11 @@
int main (void)
{
- printf("Hello from vforked-prog...\n");
+ const char *s = "Hello from vforked-prog";
+#if DEBUG
+ printf ("%s...\n", s);
+#else
+ const char *volatile v = s;
+#endif
return 0;
}

View File

@ -0,0 +1,80 @@
gdb/testsuite: don't error when trying to unset last_spawn_tty_name
In spawn_capture_tty_name (lib/gdb.exp) we either set or unset
last_spawn_tty_name depending on whether spawn_out(slave,name) exists
or not.
One situation that might cause spawn_out(slave,name) to not exists is
if the spawn function is called with the argument -leaveopen, which is
how it is called when processes are created as part of a pipeline, the
created process has no tty, instead its output is written to a file
descriptor.
If a pipeline is created consisting of multiple processes then there
will be multiple sequential calls to spawn, all using -leaveopen. The
first of these calls is fine, spawn_out(slave,name) is not set, and so
in spawn_capture_tty_name we unset last_spawn_tty_name. However, on
the second call to spawn, spawn_out(slave,name) is still not set and
so in spawn_capture_tty_name we again try to unset
last_spawn_tty_name, this now throws an error (as last_spawn_tty_name
is already unset).
Fix this issue by using -nocomplain with the call to unset in
spawn_capture_tty_name.
Before this commit I was seeing gdb.base/gnu-debugdata.exp report 1
pass, and 1 unsupported test. After this commit I now see 16 passes
from this test script.
I have also improved the code that used to do this:
if { [info exists spawn_out] } {
set ::last_spawn_tty_name $spawn_out(slave,name)
} else {
...
}
The problem here is that we check for the existence of spawn_out, and
then unconditionally read spawn_out(slave,name). A situation could
arise where some other element of spawn_out is set,
e.g. spawn_out(foo), in which case we would enter the if block and try
to read a non-existent variable. After this commit we now check
specifically for spawn_out(slave,name).
Finally, it is worth noting that before this issue was fixed runtest
itself, or rather the expect process behind runtest, would segfault
while exiting. I haven't looked at all into what the problem is here
that caused expect to crash, as fixing the bug in GDB's testing
scripts made the segfault go away.
---
gdb/testsuite/lib/gdb.exp | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7a8332dd573..8b62d73ca9a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2010,10 +2010,20 @@ proc gdb_file_cmd { arg } {
proc spawn_capture_tty_name { args } {
set result [uplevel builtin_spawn $args]
upvar spawn_out spawn_out
- if { [info exists spawn_out] } {
+ if { [info exists spawn_out(slave,name)] } {
set ::last_spawn_tty_name $spawn_out(slave,name)
} else {
- unset ::last_spawn_tty_name
+ # If a process is spawned as part of a pipe line (e.g. passing
+ # -leaveopen to the spawn proc) then the spawned process is no
+ # assigned a tty and spawn_out(slave,name) will not be set.
+ # In that case we want to ensure that last_spawn_tty_name is
+ # not set.
+ #
+ # If the previous process spawned was also not assigned a tty
+ # (e.g. multiple processed chained in a pipeline) then
+ # last_spawn_tty_name will already be unset, so, if we don't
+ # use -nocomplain here we would otherwise get an error.
+ unset -nocomplain ::last_spawn_tty_name
}
return $result
}

View File

@ -0,0 +1,117 @@
[gdb/testsuite] Fix assembly comments in gdb.dwarf2/clang-debug-names.exp.tcl
On openSUSE Leap 15.2 aarch64 I ran into:
...
clang-debug-names-debug.S:72: \
Error: junk at end of line, first unrecognized character is `#'
...
due to:
...
71 .Ldebug_names_start:
72 .short 5 # Header: version
...
Fix this by using the /* ... */ comment style instead:
...
$ sed -i 's% #\([^"]*\)%/*\1 */%' clang-debug-names.exp.tcl
...
Tested on aarch64-linux and x86_64-linux.
---
gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl | 76 +++++++++++-----------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl
index 6c2858aef0a..4700024c788 100644
--- a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl
@@ -31,50 +31,50 @@ set debug_names \
[list \
" .4byte .Ldebug_names_end - .Ldebug_names_start" \
".Ldebug_names_start:" \
- " .short 5 # Header: version" \
- " .short 0 # Header: padding" \
- " .long 1 # Header: compilation unit count" \
- " .long 0 # Header: local type unit count" \
- " .long 0 # Header: foreign type unit count" \
- " .long 2 # Header: bucket count" \
- " .long 2 # Header: name count" \
+ " .short 5 /* Header: version */" \
+ " .short 0 /* Header: padding */" \
+ " .long 1 /* Header: compilation unit count */" \
+ " .long 0 /* Header: local type unit count */" \
+ " .long 0 /* Header: foreign type unit count */" \
+ " .long 2 /* Header: bucket count */" \
+ " .long 2 /* Header: name count */" \
" .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \
- " # Header: abbreviation table size" \
- " .long 8 # Header: augmentation string size" \
- " .ascii \"LLVM0700\" # Header: augmentation string" \
- " .long .Lcu1_begin # Compilation unit 0" \
- " .long 1 # Bucket 0" \
- " .long 0 # Bucket 1" \
- " .long 193495088 # Hash in Bucket 0" \
- " .long 2090499946 # Hash in Bucket 0" \
- " .long $int_str_label # String in Bucket 0: int" \
- " .long $main_str_label # String in Bucket 0: main" \
- " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \
- " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \
+ " /* Header: abbreviation table size */" \
+ " .long 8 /* Header: augmentation string size */" \
+ " .ascii \"LLVM0700\" /* Header: augmentation string */" \
+ " .long .Lcu1_begin /* Compilation unit 0 */" \
+ " .long 1 /* Bucket 0 */" \
+ " .long 0 /* Bucket 1 */" \
+ " .long 193495088 /* Hash in Bucket 0 */" \
+ " .long 2090499946 /* Hash in Bucket 0 */" \
+ " .long $int_str_label /* String in Bucket 0: int */" \
+ " .long $main_str_label /* String in Bucket 0: main */" \
+ " .long .Lnames1-.Lnames_entries0/* Offset in Bucket 0 */" \
+ " .long .Lnames0-.Lnames_entries0/* Offset in Bucket 0 */" \
".Lnames_abbrev_start0:" \
- " .byte 46 # Abbrev code" \
- " .byte 46 # DW_TAG_subprogram" \
- " .byte 3 # DW_IDX_die_offset" \
- " .byte 19 # DW_FORM_ref4" \
- " .byte 0 # End of abbrev" \
- " .byte 0 # End of abbrev" \
- " .byte 36 # Abbrev code" \
- " .byte 36 # DW_TAG_base_type" \
- " .byte 3 # DW_IDX_die_offset" \
- " .byte 19 # DW_FORM_ref4" \
- " .byte 0 # End of abbrev" \
- " .byte 0 # End of abbrev" \
- " .byte 0 # End of abbrev list" \
+ " .byte 46 /* Abbrev code */" \
+ " .byte 46 /* DW_TAG_subprogram */" \
+ " .byte 3 /* DW_IDX_die_offset */" \
+ " .byte 19 /* DW_FORM_ref4 */" \
+ " .byte 0 /* End of abbrev */" \
+ " .byte 0 /* End of abbrev */" \
+ " .byte 36 /* Abbrev code */" \
+ " .byte 36 /* DW_TAG_base_type */" \
+ " .byte 3 /* DW_IDX_die_offset */" \
+ " .byte 19 /* DW_FORM_ref4 */" \
+ " .byte 0 /* End of abbrev */" \
+ " .byte 0 /* End of abbrev */" \
+ " .byte 0 /* End of abbrev list */" \
".Lnames_abbrev_end0:" \
".Lnames_entries0:" \
".Lnames1:" \
- " .byte 36 # Abbreviation code" \
- " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \
- " .long 0 # End of list: int" \
+ " .byte 36 /* Abbreviation code */" \
+ " .long $int_die_label - .Lcu1_begin/* DW_IDX_die_offset */" \
+ " .long 0 /* End of list: int */" \
".Lnames0:" \
- " .byte 46 # Abbreviation code" \
- " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \
- " .long 0 # End of list: main" \
+ " .byte 46 /* Abbreviation code */" \
+ " .long $main_die_label - .Lcu1_begin/* DW_IDX_die_offset */" \
+ " .long 0 /* End of list: main */" \
" .p2align 2" \
".Ldebug_names_end:"]

View File

@ -0,0 +1,71 @@
[gdb/testsuite] Fix gdb.guile/scm-type.exp with gcc 4.8
With gcc 7.5.0, I get:
...
(gdb) guile (print (type-range (field-type (type-field (value-type \
(value-dereference f)) "items"))))^M
= (0 0)^M
(gdb) PASS: gdb.guile/scm-type.exp: lang_cpp: test_range: \
on flexible array member: $cmd
...
but with gcc 4.8.5, I get instead:
...
(gdb) guile (print (type-range (field-type (type-field (value-type \
(value-dereference f)) "items"))))^M
= (0 -1)^M
(gdb) FAIL: gdb.guile/scm-type.exp: lang_cpp: test_range: \
on flexible array member: $cmd
...
There's a difference in debug info. With gcc 4.8.5, we have:
...
<2><224>: Abbrev Number: 15 (DW_TAG_member)
<225> DW_AT_name : items
<22b> DW_AT_type : <0x231>
<1><231>: Abbrev Number: 4 (DW_TAG_array_type)
<232> DW_AT_type : <0x105>
<2><23a>: Abbrev Number: 16 (DW_TAG_subrange_type)
<23b> DW_AT_type : <0x11a>
<23f> DW_AT_upper_bound : 0xffffffffffffffff
...
and with gcc 7.5.0, we have instead:
...
<2><89f>: Abbrev Number: 12 (DW_TAG_member)
<8a0> DW_AT_name : items
<8a6> DW_AT_type : <0x8ac>
<1><8ac>: Abbrev Number: 17 (DW_TAG_array_type)
<8ad> DW_AT_type : <0x29d>
<2><8b5>: Abbrev Number: 41 (DW_TAG_subrange_type)
<2><8b6>: Abbrev Number: 0
...
As mentioned in commit 858c8f2c1b9 "gdb/testsuite: adjust
gdb.python/flexible-array-member.exp expected pattern":
...
Ideally, GDB would present a consistent and documented value for an
array member declared with size 0, regardless of how the debug info
looks like.
...
As in gdb.python/flexible-array-member.exp, change the test to accept the two
values.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.guile/scm-type.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.guile/scm-type.exp b/gdb/testsuite/gdb.guile/scm-type.exp
index ccde98ca224..e5eaab365cc 100644
--- a/gdb/testsuite/gdb.guile/scm-type.exp
+++ b/gdb/testsuite/gdb.guile/scm-type.exp
@@ -267,7 +267,7 @@ proc test_range {} {
gdb_scm_test_silent_cmd "guile (define f (history-ref 0))" \
"get value (f) from history"
gdb_test "guile (print (type-range (field-type (type-field (value-type (value-dereference f)) \"items\"))))" \
- "= \\(0 0\\)"
+ "= \\(0 (0|-1)\\)"
gdb_test "guile (print (value-subscript (value-field (value-dereference f) \"items\") 0))" \
"= 111"
gdb_test "guile (print (value-subscript (value-field (value-dereference f) \"items\") 1))" \

View File

@ -0,0 +1,45 @@
[gdb/testsuite] Fix regexp in gdb.base/foll-vfork.exp
On OBS I ran into:
...
(gdb) PASS: gdb.base/foll-vfork.exp: exit: \
vfork relations in info inferiors: continue to child exit
info inferiors^M
Num Description Connection Executable ^M
1 <null> foll-vfork-exit ^M
* 2 <null> foll-vfork-exit ^M
(gdb) I'm the proud parent of child #5044!^M
FAIL: gdb.base/foll-vfork.exp: exit: vfork relations in info inferiors: \
vfork relation no longer appears in info inferiors (timeout)
...
Fix this by removing the '$' anchor in the corresponding '$gdb_prompt $'
regexps.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 577bd4d573b..a781a5c2087 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -374,13 +374,13 @@ proc vfork_relations_in_info_inferiors { variant } {
set test "vfork relation no longer appears in info inferiors"
gdb_test_multiple "info inferiors" $test {
- -re "is vfork child of inferior 1.*$gdb_prompt $" {
+ -re "is vfork child of inferior 1.*$gdb_prompt " {
fail $test
}
- -re "is vfork parent of inferior 2.*$gdb_prompt $" {
+ -re "is vfork parent of inferior 2.*$gdb_prompt " {
fail $test
}
- -re "$gdb_prompt $" {
+ -re "$gdb_prompt " {
pass $test
}
}

View File

@ -0,0 +1,176 @@
[gdb/testsuite] Fix stepi test-cases with unix/-m32/-fPIE/-pie
When running test-case gdb.base/step-indirect-call-thunk.exp with target board
unix/-m32/-fPIE/-pie, I run into:
...
(gdb) stepi^M
0x5655552e 22 { /* inc.1 */^M
(gdb) stepi^M
0x56555530 22 { /* inc.1 */^M
(gdb) stepi^M
0x565555f7 in __x86.get_pc_thunk.ax ()^M
(gdb) FAIL: gdb.base/step-indirect-call-thunk.exp: stepi into return thunk
...
In contrast, with unix/-m32 we have instead:
...
(gdb) stepi^M
0x08048407 22 { /* inc.1 */^M
(gdb) stepi^M
23 return x + 1; /* inc.2 */^M
(gdb) stepi^M
0x0804840c 23 return x + 1; /* inc.2 */^M
(gdb) stepi^M
24 } /* inc.3 */^M
(gdb) stepi^M
0x08048410 24 } /* inc.3 */^M
(gdb) stepi^M
0x0804848f in __x86_return_thunk ()^M
(gdb) PASS: gdb.base/step-indirect-call-thunk.exp: stepi into return thunk
...
The test-case doesn't expect to run into __x86.get_pc_thunk.ax, which is a
PIC helper function for x86_64-linux.
Fix this by insn-stepping through it.
Likewise in a few other test-cases.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/step-indirect-call-thunk.exp | 5 ++++-
gdb/testsuite/gdb.base/step-test.exp | 4 +++-
gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp | 6 ++++--
gdb/testsuite/gdb.reverse/step-precsave.exp | 10 ++++++++++
gdb/testsuite/gdb.reverse/step-reverse.exp | 10 ++++++++++
5 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp b/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp
index d84a0232265..18f5bdcbe9a 100644
--- a/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp
+++ b/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp
@@ -65,9 +65,12 @@ gdb_test "step" "inc\.2.*" "step through call thunk into inc"
gdb_test "step" "inc\.3.*" "step inside inc"
gdb_test "step" "thrice\.4.*" "step through return thunk back into thrice"
+set alphanum_re "\[a-zA-Z0-9\]"
+set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
+
# We can use instruction stepping to step into thunks.
stepi_until "thrice" "indirect_thunk" "stepi into call thunk"
stepi_until "indirect_thunk" "inc." "stepi out of call thunk into inc"
-stepi_until "inc" "return_thunk" "stepi into return thunk"
+stepi_until "(inc|$pic_thunk_re)" "return_thunk" "stepi into return thunk"
stepi_until "return_thunk" "thrice" \
"stepi out of return thunk back into thrice"
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index 8664b3eda22..5f480e07edd 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -128,8 +128,10 @@ test_i "stepi into function" "stepi" \
# Continue to step until we reach the function's body. This makes it
# more likely that we've actually completed the prologue, so "finish"
# will work.
+set alphanum_re "\[a-zA-Z0-9\]"
+set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
test_i "stepi into function's first source line" "stepi" \
- ".*${decimal}.*int callee" \
+ "(${decimal}.*int callee|$pic_thunk_re)" \
".*${decimal}.*myglob.*; return 0;"
# Have to be careful here, if the finish does not work,
diff --git a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp b/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp
index dad43d78e6b..1f43206074f 100644
--- a/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp
+++ b/gdb/testsuite/gdb.reverse/step-indirect-call-thunk.exp
@@ -86,7 +86,9 @@ gdb_test "reverse-next" "apply\.2.*" \
step_until "stepi" "apply\.2" "indirect_thunk" "stepi into call thunk"
step_until "stepi" "indirect_thunk" "inc" \
"stepi out of call thunk into inc"
-step_until "stepi" "inc" "return_thunk" "stepi into return thunk"
+set alphanum_re "\[a-zA-Z0-9\]"
+set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
+step_until "stepi" "(inc|$pic_thunk_re)" "return_thunk" "stepi into return thunk"
step_until "stepi" "return_thunk" "apply" \
"stepi out of return thunk back into apply"
@@ -94,7 +96,7 @@ step_until "reverse-stepi" "apply" "return_thunk" \
"reverse-stepi into return thunk"
step_until "reverse-stepi" "return_thunk" "inc" \
"reverse-stepi out of return thunk into inc"
-step_until "reverse-stepi" "inc" "indirect_thunk" \
+step_until "reverse-stepi" "(inc|$pic_thunk_re)" "indirect_thunk" \
"reverse-stepi into call thunk"
step_until "reverse-stepi" "indirect_thunk" "apply" \
"reverse-stepi out of call thunk into apply"
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 43f6ab3a11a..e85cdabfb73 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -124,6 +124,8 @@ gdb_test_multiple "stepi" "$test_message" {
# stepi into a function call
+set alphanum_re "\[a-zA-Z0-9\]"
+set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
set test_message "stepi into function call"
gdb_test_multiple "stepi" "$test_message" {
-re "ARRIVED IN CALLEE.*$gdb_prompt $" {
@@ -143,6 +145,10 @@ gdb_test_multiple "stepi" "$test_message" {
send_gdb "stepi\n"
exp_continue
}
+ -re "$pic_thunk_re.*$gdb_prompt $" {
+ send_gdb "stepi\n"
+ exp_continue
+ }
}
# stepi thru return of a function call
@@ -216,6 +222,10 @@ gdb_test_multiple "stepi" "$test_message" {
send_gdb "stepi\n"
exp_continue
}
+ -re "$pic_thunk_re.*$gdb_prompt $" {
+ send_gdb "stepi\n"
+ exp_continue
+ }
-re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
send_gdb "stepi\n"
exp_continue
diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp
index 335ccfbd399..32c18faaaa6 100644
--- a/gdb/testsuite/gdb.reverse/step-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/step-reverse.exp
@@ -87,6 +87,8 @@ gdb_test_multiple "stepi" "$test_message" {
# stepi into a function call
+set alphanum_re "\[a-zA-Z0-9\]"
+set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
set test_message "stepi into function call"
gdb_test_multiple "stepi" "$test_message" {
-re "ARRIVED IN CALLEE.*$gdb_prompt $" {
@@ -106,6 +108,10 @@ gdb_test_multiple "stepi" "$test_message" {
send_gdb "stepi\n"
exp_continue
}
+ -re "$pic_thunk_re.*$gdb_prompt $" {
+ send_gdb "stepi\n"
+ exp_continue
+ }
}
# stepi thru return of a function call
@@ -179,6 +185,10 @@ gdb_test_multiple "stepi" "$test_message" {
send_gdb "stepi\n"
exp_continue
}
+ -re "$pic_thunk_re.*$gdb_prompt $" {
+ send_gdb "stepi\n"
+ exp_continue
+ }
-re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
send_gdb "stepi\n"
exp_continue

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Thu Nov 11 10:36:08 UTC 2021 - Tom de Vries <tdevries@suse.com>
- Patches added (backports from trunk):
* gdb-testsuite-add-gdb.opt-break-on-_exit.exp.patch
* gdb-tdep-rs6000-don-t-skip-system-call-in-skip_prologue.patch
* gdb-testsuite-fix-stepi-test-cases-with-unix-m32-fpie-pie.patch
* gdb-testsuite-fix-assembly-comments-in-gdb.dwarf2-clang-debug-names.exp.tcl.patch
* gdb-doc-fix-print-inferior-events-default.patch
* gdb-testsuite-fix-gdb.guile-scm-type.exp-with-gcc-4.8.patch
* gdb-testsuite-add-gdb.arch-ppc64-break-on-_exit.exp.patch
* gdb-testsuite-don-t-error-when-trying-to-unset-last_spawn_tty_name.patch
* gdb-exp-improve-error-reading-variable-message.patch
* fix-gdb.base-sigstep.exp-test-for-ppc.patch
* gdb-testsuite-fix-regexp-in-gdb.base-foll-vfork.exp.patch
- Patches added (backports from ml):
* gdb-testsuite-disable-inferior-output-in-gdb.base-foll-vfork.exp.patch
- Maintenance script qa.sh:
- Add -m32/-pie to known clean configs.
- Add kfail for PR28467.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Nov 9 15:54:58 UTC 2021 - Tom de Vries <tdevries@suse.com> Tue Nov 9 15:54:58 UTC 2021 - Tom de Vries <tdevries@suse.com>

View File

@ -332,6 +332,17 @@ Patch2019: gdb-testsuite-update-test-gdb.base-step-over-syscall.exp.patch
Patch2020: gdb-testsuite-fix-gdb.threads-linux-dp.exp.patch Patch2020: gdb-testsuite-fix-gdb.threads-linux-dp.exp.patch
Patch2021: gdb-testsuite-add-gdb.testsuite-dump-system-info.exp.patch Patch2021: gdb-testsuite-add-gdb.testsuite-dump-system-info.exp.patch
Patch2022: gdb-testsuite-factor-out-dump_info-in-gdb.testsuite-dump-system-info.exp.patch Patch2022: gdb-testsuite-factor-out-dump_info-in-gdb.testsuite-dump-system-info.exp.patch
Patch2023: gdb-testsuite-add-gdb.opt-break-on-_exit.exp.patch
Patch2024: gdb-tdep-rs6000-don-t-skip-system-call-in-skip_prologue.patch
Patch2025: gdb-testsuite-fix-stepi-test-cases-with-unix-m32-fpie-pie.patch
Patch2026: gdb-testsuite-fix-assembly-comments-in-gdb.dwarf2-clang-debug-names.exp.tcl.patch
Patch2027: gdb-doc-fix-print-inferior-events-default.patch
Patch2028: gdb-testsuite-fix-gdb.guile-scm-type.exp-with-gcc-4.8.patch
Patch2029: gdb-testsuite-add-gdb.arch-ppc64-break-on-_exit.exp.patch
Patch2030: gdb-testsuite-don-t-error-when-trying-to-unset-last_spawn_tty_name.patch
Patch2031: gdb-exp-improve-error-reading-variable-message.patch
Patch2032: fix-gdb.base-sigstep.exp-test-for-ppc.patch
Patch2033: gdb-testsuite-fix-regexp-in-gdb.base-foll-vfork.exp.patch
# Backports from master, not yet available in next release. # Backports from master, not yet available in next release.
@ -369,6 +380,8 @@ Patch2114: gdb-cli-add-ignore-errors-command.patch
Patch2115: gdb-testsuite-fix-data-alignment-in-gdb.arch-i386-avx-sse-.exp.patch Patch2115: gdb-testsuite-fix-data-alignment-in-gdb.arch-i386-avx-sse-.exp.patch
# https://sourceware.org/pipermail/gdb-patches/2021-October/182887.html # https://sourceware.org/pipermail/gdb-patches/2021-October/182887.html
Patch2116: gdb-testsuite-fix-fail-in-gdb.tui-basic.exp.patch Patch2116: gdb-testsuite-fix-fail-in-gdb.tui-basic.exp.patch
# https://sourceware.org/pipermail/gdb-patches/2021-November/date.html
Patch2117: gdb-testsuite-disable-inferior-output-in-gdb.base-foll-vfork.exp.patch
BuildRequires: bison BuildRequires: bison
@ -769,6 +782,17 @@ find -name "*.info*"|xargs rm -f
%patch2020 -p1 %patch2020 -p1
%patch2021 -p1 %patch2021 -p1
%patch2022 -p1 %patch2022 -p1
%patch2023 -p1
%patch2024 -p1
%patch2025 -p1
%patch2026 -p1
%patch2027 -p1
%patch2028 -p1
%patch2029 -p1
%patch2030 -p1
%patch2031 -p1
%patch2032 -p1
%patch2033 -p1
%patch2100 -p1 %patch2100 -p1
%patch2101 -p1 %patch2101 -p1
@ -785,6 +809,7 @@ find -name "*.info*"|xargs rm -f
%patch2114 -p1 %patch2114 -p1
%patch2115 -p1 %patch2115 -p1
%patch2116 -p1 %patch2116 -p1
%patch2117 -p1
#unpack libipt #unpack libipt
%if 0%{have_libipt} %if 0%{have_libipt}

20
qa.sh
View File

@ -121,6 +121,9 @@ kfail=(
"FAIL: gdb.mi/mi-nonstop.exp: wait for thread exit \(timeout\)" "FAIL: gdb.mi/mi-nonstop.exp: wait for thread exit \(timeout\)"
# https://sourceware.org/bugzilla/show_bug.cgi?id=26273 # https://sourceware.org/bugzilla/show_bug.cgi?id=26273
"FAIL: gdb.threads/gcore-stale-thread.exp: save a corefile" "FAIL: gdb.threads/gcore-stale-thread.exp: save a corefile"
# https://sourceware.org/bugzilla/show_bug.cgi?id=28467
# -pie, x86_64 -m32 or i586.
"FAIL: gdb.base/nodebug.exp: p/c \(int\) array_index\(\"abcdef\",2\)"
# https://sourceware.org/bugzilla/show_bug.cgi?id=26284 # https://sourceware.org/bugzilla/show_bug.cgi?id=26284
# https://sourceware.org/bugzilla/show_bug.cgi?id=28275 # https://sourceware.org/bugzilla/show_bug.cgi?id=28275
@ -233,31 +236,36 @@ case $n in
config=openSUSE_Leap_15.1.x86_64/gdb-testresults config=openSUSE_Leap_15.1.x86_64/gdb-testresults
sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m64.sum"
"$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m32.sum")
# Known clean config: Leap 15.2 x86_64. # Known clean config: Leap 15.2 x86_64.
config=openSUSE_Leap_15.2.x86_64/gdb-testresults config=openSUSE_Leap_15.2.x86_64/gdb-testresults
sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m64.sum"
"$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m32.sum")
# Known clean config: Leap 15.3 x86_64 # Known clean config: Leap 15.3 x86_64
config=openSUSE_Leap_15.3.x86_64/gdb-testresults config=openSUSE_Leap_15.3.x86_64/gdb-testresults
sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m64.sum"
"$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m32.sum")
# Known clean config: SLE 15 x86_64. # Known clean config: SLE 15 x86_64.
config=SLE-15.x86_64/gdb-testresults config=SLE-15.x86_64/gdb-testresults
sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m64.sum"
"$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m32.sum")
# Known cleanish config: Factory x86_64. # Known cleanish config: Factory x86_64.
config=openSUSE_Factory.x86_64/gdb-testresults config=openSUSE_Factory.x86_64/gdb-testresults
sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m64.sum"
"$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum"
"$config/gdb-x86_64-suse-linux-m32.sum")
kfail+=("${kfail_factory[@]}") kfail+=("${kfail_factory[@]}")
@ -282,6 +290,8 @@ case $n in
sums+=("${MAPFILE[@]}") sums+=("${MAPFILE[@]}")
mapfile -t < <(echo_line "$dir"/*-m32.-fno-PIE.-no-pie.sum) mapfile -t < <(echo_line "$dir"/*-m32.-fno-PIE.-no-pie.sum)
sums+=("${MAPFILE[@]}") sums+=("${MAPFILE[@]}")
mapfile -t < <(echo_line "$dir"/*-m32.sum)
sums+=("${MAPFILE[@]}")
# Assume this is factory. # Assume this is factory.
kfail+=("${kfail_factory[@]}") kfail+=("${kfail_factory[@]}")