From patchwork Tue Nov 29 13:32:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 61222 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDAF13858431 for ; Tue, 29 Nov 2022 13:32:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDAF13858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669728773; bh=a6eSl4gucQrmD3IWdr0uQ5w/nnq1zEDpqPkrFCdwpgQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Obc4w+iWttlUXFU5onvwiWIbREKrf/VFPOsnTxOqtYyFnVV0CGvq0mhjcq+Ucedoi wvdgkkFvzdiXVCsVECb3eWOH+CmJsAk6wtGIQ1evtzdelfNHT8C2wUrNnOtJZ6r5V+ NheiuULbgufIoIDowl/5Qr1Wt7RHEgQEv0CsF2jg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id F30763858D1E for ; Tue, 29 Nov 2022 13:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F30763858D1E 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 3D47A1FDEC; Tue, 29 Nov 2022 13:32:29 +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 1E11A13AF6; Tue, 29 Nov 2022 13:32:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id p4ZWBu0JhmM0MgAAMHmgww (envelope-from ); Tue, 29 Nov 2022 13:32:29 +0000 To: gdb-patches@sourceware.org Cc: Ulrich Weigand , Carl Love Subject: [PATCH] [gdb/testsuite] Fix gdb.base/vla-optimized-out.exp for ppc64le Date: Tue, 29 Nov 2022 14:32:28 +0100 Message-Id: <20221129133228.12599-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 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, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Tom de Vries On powerpc64le-linux, I run into: ... (gdb) PASS: gdb.base/vla-optimized-out.exp: o1: printed optimized out vla p sizeof (a)^M $2 = ^M (gdb) FAIL: gdb.base/vla-optimized-out.exp: o1: \ printed size of optimized out vla ... The problem happens as follows. In order to find the size of the optimized out vla, gdb needs to evaluate: ... <155> DW_AT_upper_bound : 13 byte block: f3 1 53 23 1 8 20 24 8 20 26 31 1c \ (DW_OP_GNU_entry_value: (DW_OP_reg3 (r3)); DW_OP_plus_uconst: 1; DW_OP_const1u: 32; DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra; DW_OP_lit1; DW_OP_minus) ... When trying to evaluate DW_OP_GNU_entry_value, it looks for a call site matching the pc, but doesn't find it: ... $ gdb -q -batch outputs/gdb.base/vla-optimized-out/vla-optimized-out-o1 \ -ex "break f1" -ex run -ex "set debug entry-values 1" -ex "print sizeof (a)" Breakpoint 1 at 0x1000067c: file vla-optimized-out.c, line 34. Breakpoint 1, f1 (i=5) at vla-optimized-out.c:34 34 } DW_OP_entry_value resolving cannot find DW_TAG_call_site 0x100006b0 in main $1 = .... The call site lookup fails because the call site label .LVL4: ... bl f1 # 11 *call_value_nonlocal_aixdi [length = 8] nop .LVL4: ... is not placed directly after the bl insn. This is gcc PR target/107909. However, after manually fixing the .s file we have instead: ... Cannot find matching parameter at DW_TAG_call_site 0x10000690 at main $1 = ... due to the fact that the call site has no call site parameters. The call site does have a reference to the corresponding function f1, with parameter i, for which we find location list entries: ... 0037 1000067c 10000680 (DW_OP_reg3 (r3)) 004a 10000680 10000690 (DW_OP_GNU_entry_value: (DW_OP_reg3 (r3)); DW_OP_stack_value) ... and we could use the fact that the current pc is in the 1000067c-10000680 range, and that that the range starts at the start of the function, to deduce that DW_OP_GNU_entry_value: (DW_OP_reg3 (r3)) == DW_OP_reg3 (r3). But that's a non-trivial enhancement, filed as enhancement PR symtab/29836. Fix this by allowing for target powerpc and the gcc compiler. PR testsuite/29813 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29813 --- gdb/testsuite/gdb.base/vla-optimized-out.exp | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp index b16142ee329..b897ea8124c 100644 --- a/gdb/testsuite/gdb.base/vla-optimized-out.exp +++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp @@ -67,12 +67,23 @@ proc vla_optimized_out {exe_suffix options} { "print out of range element of vla (0xffffffff)" } -foreach {test_prefix options} \ - { "o1" {{debug optimize=-O1 additional_flags=-DNOCLONE} "6"} \ - "o3" {{debug optimize=-O3} "|6"} \ - "o3_strict" {{debug optimize=-O3 \ - additional_flags=-gstrict-dwarf} \ - "|6"}} { +set o1_sizeof_result "6" +if { [istarget powerpc*-*-*] && [gcc_major_version] != -1 } { + set o1_sizeof_result "|6" +} + +set test_matrix {} +lappend test_matrix \ + "o1" \ + [list {debug optimize=-O1 additional_flags=-DNOCLONE} $o1_sizeof_result] +lappend test_matrix \ + "o3" \ + {{debug optimize=-O3} "|6"} +lappend test_matrix \ + "o3_strict" \ + {{debug optimize=-O3 additional_flags=-gstrict-dwarf} "|6"} + +foreach {test_prefix options} $test_matrix { with_test_prefix $test_prefix { vla_optimized_out $test_prefix $options }