From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DT9tHn1KfGEPdgAAWB0awg (envelope-from ) for ; Fri, 29 Oct 2021 15:24:45 -0400 Received: by simark.ca (Postfix, from userid 112) id 6BF771F0BB; Fri, 29 Oct 2021 15:24:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 63ECD1EE18 for ; Fri, 29 Oct 2021 15:24:44 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BD983858017 for ; Fri, 29 Oct 2021 19:24:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BD983858017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635535483; bh=ABFCPP3eWmyJXmVQVNEmW/MusX+TiE/xwlELzKzw4mo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Q1rDuBFlAsq2XVaNpYjsbZQkQYsio2In/UlLjnzv3P8Nid0cxRIvCxr3kMsK2Yxog IzswRYk9VKi7mN7r5OIfIAtsACg9ZHieetpO5XH9kSU4XEBxddvvUlu8HNB/M1Wqxr vvJvuDlaR9h1KFwB+7w7f6yV/P2Wb4fKO/Tjq2bE= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 0D5FC3858430 for ; Fri, 29 Oct 2021 19:24:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D5FC3858430 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-out2.suse.de (Postfix) with ESMTPS id 1CC901FD67; Fri, 29 Oct 2021 19:24:23 +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 0538313F80; Fri, 29 Oct 2021 19:24:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OqchAGdKfGG+HgAAMHmgww (envelope-from ); Fri, 29 Oct 2021 19:24:22 +0000 Date: Fri, 29 Oct 2021 21:24:21 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Work around skip_prologue problems in gdb.threads/process-dies-while-detaching.exp Message-ID: <20211029192419.GA26416@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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, we don't want to be testing this behaviour in this test-case. [ Initially I tried to fix it by setting a breakpoint on "*_exit" instead, but that one only sets one location. The breakpoint on "_exit" sets two locations, one in /lib64/libc.so.6 and one in /lib64/ld64.so.2. I tried on x86_64 and there the breakpoint on "*_exit" mapped to the /lib64/libc.so.6 location, and the test-case passed. But on powerpc it mapped to the /lib64/ld64.so.2 location and I still got the same failures. ] Fix this by setting two breakpoints on the calls to _exit and exit instead. Tested on x86_64-linux and powerpc64le-linux. Any comments? Thanks, - Tom [gdb/testsuite] Work around skip_prologue problems in gdb.threads/process-dies-while-detaching.exp --- gdb/testsuite/gdb.threads/process-dies-while-detaching.c | 4 ++-- gdb/testsuite/gdb.threads/process-dies-while-detaching.exp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.c b/gdb/testsuite/gdb.threads/process-dies-while-detaching.c index 502b4622614..c4c0b0a648b 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.c +++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.c @@ -46,7 +46,7 @@ void * thread_function (void *arg) { pthread_barrier_wait (&start_threads_barrier); - _exit (0); + _exit (0); /* Exit in thread. */ } /* The fork child's entry point. */ @@ -63,7 +63,7 @@ child_function (void) pthread_create (&threads[i], NULL, thread_function, NULL); pthread_barrier_wait (&start_threads_barrier); - exit (0); + exit (0); /* Exit in child. */ } /* This is defined by the .exp file if testing the multi-process diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp index cabbc4faacc..bbf1e0e6740 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp @@ -126,8 +126,12 @@ proc detach_and_expect_exit {inf_output_re test} { # Run to _exit in the child. proc continue_to_exit_bp {} { - gdb_breakpoint "_exit" temporary - gdb_continue_to_breakpoint "_exit" ".*_exit.*" + set line [gdb_get_line_number "Exit in child"] + gdb_breakpoint $line temporary + set line [gdb_get_line_number "Exit in thread"] + gdb_breakpoint $line temporary + gdb_continue_to_breakpoint "exit" ".*exit.*" + delete_breakpoints } # If testing single-process, simply detach from the process.