From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D63053858D35 for ; Thu, 4 Nov 2021 11:20:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D63053858D35 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D0E2A218D5; Thu, 4 Nov 2021 11:20:14 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BB46513C68; Thu, 4 Nov 2021 11:20:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 3OVgLO7Bg2EsaAAAMHmgww (envelope-from ); Thu, 04 Nov 2021 11:20:14 +0000 Subject: [PATCH][gdb/testsuite] Add gdb.opt/break-on-_exit.exp To: Kevin Buettner , Tom de Vries via Gdb-patches References: <20211029192419.GA26416@delia> <2cc5e63d-5be1-a5c7-b1cd-6058223a5a19@suse.de> <20211102101329.565a324b@f35-m1> From: Tom de Vries Message-ID: <33a30d8d-247e-fba8-c9f1-b8ff0bd001b2@suse.de> Date: Thu, 4 Nov 2021 12:20:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20211102101329.565a324b@f35-m1> Content-Type: multipart/mixed; boundary="------------D928B7751BB75D0AB57E0C9D" Content-Language: en-US X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2021 11:20:18 -0000 This is a multi-part message in MIME format. --------------D928B7751BB75D0AB57E0C9D Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit [ was: Re: [PATCH][gdb/testsuite] Work around skip_prologue problems in gdb.threads/process-dies-while-detaching.exp ] On 11/2/21 6:13 PM, Kevin Buettner wrote: > On Tue, 2 Nov 2021 12:38:26 +0100 > Tom de Vries via Gdb-patches wrote: > >> On 10/29/21 9:24 PM, Tom de Vries via Gdb-patches wrote: >>> Hi, >>> >>> On powerpc64le-linux, I run into: >>> ... >>> [Inferior 1 (process 5156) exited normally]^M >>> (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: \ >>> detach: detach: continue to breakpoint: _exit (the program exited) >>> ... >>> >>> What happens is the following: >>> - a breakpoint is set on _exit, >>> - a continue is issued >>> - the continue is supposed to hit the breakpoint, but instead >>> the program exits. >>> >>> I traced this down to the breakpoint on _exit being set too far from function >>> entry. This is caused by the skip_prologue function (in rs6000-tdep.c) >>> optimistically ignoring insns it doesn't recognize. In particular, it walks >>> past the system call instruction "sc" which initiates the actual exit. >>> >>> While this needs fixing, >> >> Filed here: https://sourceware.org/bugzilla/show_bug.cgi?id=28527 . >> >> Submitted patch here: >> https://sourceware.org/pipermail/gdb-patches/2021-November/183016.html . >> >> Thanks, >> - Tom >> >>> we don't want to be testing this behaviour in this >>> test-case. > > Since you've fixed the problem in skip_prologue(), I'd prefer that this > testsuite patch not go in. One possible objection would be that otherwise we no longer excercise the problem, so here's a test-case for that. Any comments? Thanks, - Tom --------------D928B7751BB75D0AB57E0C9D Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Add-gdb.opt-break-on-_exit.exp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-gdb-testsuite-Add-gdb.opt-break-on-_exit.exp.patch" [gdb/testsuite] Add gdb.opt/break-on-_exit.exp Add a test-case to excercise the problem 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. 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 . */ + +#include + +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 . */ + +# 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 \\(\\) .*" --------------D928B7751BB75D0AB57E0C9D--