From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id n8L0E/XFTWHtNgAAWB0awg (envelope-from ) for ; Fri, 24 Sep 2021 08:35:01 -0400 Received: by simark.ca (Postfix, from userid 112) id 394D41EE25; Fri, 24 Sep 2021 08:35:01 -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 0E1651EDF0 for ; Fri, 24 Sep 2021 08:35:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A54823858022 for ; Fri, 24 Sep 2021 12:34:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A54823858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632486899; bh=wmn0wsR5/4utY72Z0WjsFvgySAUTgndhFZRtE7uSkNc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bmS7wJby9fg+hFzMzSasRA2Bz/GHQ4u89gCc33r/k7BtwMlbKJH+Fohw/QHZmHnsL Qv0Va5yYZYl130KH/Dfuk8BMzRuL6RkJkBEkHU3lKRqQ+IMH3T1m6//L0q1rJsZrgQ oZa2no4vTANiUZ7NLimGlEmEoPYRiI+fY++LfiAw= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 1CCEB3858402 for ; Fri, 24 Sep 2021 12:34:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1CCEB3858402 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 4F9D61FFEF; Fri, 24 Sep 2021 12:34:40 +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 2F97013B67; Fri, 24 Sep 2021 12:34:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mCpbCuDFTWF/EgAAMHmgww (envelope-from ); Fri, 24 Sep 2021 12:34:40 +0000 Subject: [PATCH][gdb/testsuite] Don't leave gdb instance running after function_range To: Simon Marchi , gdb-patches@sourceware.org References: <20210917224909.GA15407@delia> <5b995a81-afd0-adbb-1639-b1aecfa4d8e7@polymtl.ca> <13a04bcb-6842-a5ce-5457-ed4510a0a79b@suse.de> Message-ID: Date: Fri, 24 Sep 2021 14:34:39 +0200 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: <13a04bcb-6842-a5ce-5457-ed4510a0a79b@suse.de> Content-Type: multipart/mixed; boundary="------------83164AE2DEE7C615B0CBC42F" Content-Language: en-US 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" This is a multi-part message in MIME format. --------------83164AE2DEE7C615B0CBC42F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit [ Re: [PATCH][gdb/testsuite] Replace prepare_for_testing with build_executable ] On 9/23/21 11:43 PM, Tom de Vries wrote: > I found a problem in cpp-linkage-name.exp. The test passes, but the gdb > commands execute on a lingering gdb instance started by function_range, > so I had to fix that first (by adding gdb_exit at the end of > function_range) to trigger the FAIL introduced by the script. I've > removed the change in that test-case, and similar cases, and am > currently retesting. I've factored this out as a separate patch. Any comments? Thanks, - Tom --------------83164AE2DEE7C615B0CBC42F Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Don-t-leave-gdb-instance-running-after-function_range.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-testsuite-Don-t-leave-gdb-instance-running-after-fu"; filename*1="nction_range.patch" [gdb/testsuite] Don't leave gdb instance running after function_range A typical dwarf assembly test-case start like this: ... standard_testfile .c -debug.S set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { ... } if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { return -1 } ... When accidentally using build_for_executable instead of prepare_for_testing (or intentionally using it but forgetting to add clean_restart $binfile or some such) the mistake may not be caught, because another gdb instance is still running, and we may silently end up testing compiler-generated DWARF. This can be caused by something relatively obvious, like an earlier prepare_for_testing or clean_restart, but also by something more obscure like function_range, which may even be triggered by dwarf assembly like this: ... {MACRO_AT_func {main}} ... Fix this by calling gdb_exit at the end of function_range. Also fix the fallout of that in test-case gdb.dwarf2/dw2-bad-elf.exp, where a get_sizeof call used the gdb instance left lingering by function_range. [ A better and more complete fix would add a new proc get_exec_info, that would be called at the start of the dwarf: ... Dwarf::assemble $asm_file { get_exec_info {main foo} {int void*} ... that would: - do a prepare_for_testing with $srcfile (roughtly equivalent to what MACRO_AT_func does, - call function_range for all functions main and foo, without starting a new gdb instance - set corresponding variables at the call-site: main_start, main_len, main_end, foo_start, foo_len, foo_end. - get size for types int and void* - set corresponding variable at the call-site: int_size, void_ptr_size. ] Tested on x86_64-linux. --- gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp | 11 ++++++++--- gdb/testsuite/lib/dwarf.exp | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp index 5ab08c18f77..d276bf8f0d4 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp @@ -36,10 +36,17 @@ if {![dwarf2_support]} { standard_testfile main.c -other.S -dwarf.S +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + untested "failed to compile" + return -1 +} + +set int_size [get_sizeof "int" 4] + # Make some DWARF for the test. set asm_file [standard_output_file $srcfile3] Dwarf::assemble $asm_file { - global srcdir subdir srcfile srcfile2 + global srcdir subdir srcfile srcfile2 int_size declare_labels ranges_label_1 ranges_label_2 L1 L2 @@ -47,8 +54,6 @@ Dwarf::assemble $asm_file { set main_start [lindex $main_result 0] set main_length [lindex $main_result 1] - set int_size [get_sizeof "int" 4] - cu {} { DW_TAG_compile_unit { {DW_AT_language @DW_LANG_C} diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 87bb6c152d1..c248296aa8d 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -271,6 +271,7 @@ proc function_range { func src {options {debug}} } { } } + gdb_exit return [list "${func}_label - $func_label_offset" $func_length] } --------------83164AE2DEE7C615B0CBC42F--