From patchwork Fri Apr 21 14:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 68140 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 1D7323855584 for ; Fri, 21 Apr 2023 15:00:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D7323855584 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682089233; bh=xiQw0BuY6WDy8odxzLFhXjU/Z9mw604MDK37mlRWO6w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FojCcxEEcRA3SUTtNaCTOHdnwo7j/ETjf0o9gA8f0Ikv3ioqEIjdfWZJ/KmRwOYMz yURdTwidnPyL3F+iDx4EGomrrNO5ZvPaooyGw+7sLO7OtpuQgSXKYQknaY+PRXaNND ICVRhyvt0JdP1+vAHAVv2rhs0DGX9YDgwDNso/z8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 724773856DCB for ; Fri, 21 Apr 2023 14:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 724773856DCB 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 ACFE91FE11 for ; Fri, 21 Apr 2023 14:58: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 9B2441391A for ; Fri, 21 Apr 2023 14:58:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cGm7JKCkQmTqDAAAMHmgww (envelope-from ) for ; Fri, 21 Apr 2023 14:58:40 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [gdb/testsuite] Fix -wrap in presence of -prompt in gdb_test_multiple Date: Fri, 21 Apr 2023 16:58:31 +0200 Message-Id: <20230421145833.24521-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230421145833.24521-1-tdevries@suse.de> References: <20230421145833.24521-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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, T_SCC_BODY_TEXT_LINE 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" While writing a gdb_test_multiple call in a test-case I tried to use -wrap in combination with -prompt and found out that it doesn't work, because -wrap uses "$gdb_prompt $" instead of $prompt_regexp. Fix this by making -wrap use $prompt_regexp. Tested on x86_64-linux. --- gdb/testsuite/gdb.testsuite/gdb-test.exp | 11 +++++++++++ gdb/testsuite/lib/gdb.exp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.testsuite/gdb-test.exp b/gdb/testsuite/gdb.testsuite/gdb-test.exp index a582b1b125f..e19f2a8de4a 100644 --- a/gdb/testsuite/gdb.testsuite/gdb-test.exp +++ b/gdb/testsuite/gdb.testsuite/gdb-test.exp @@ -48,3 +48,14 @@ with_test_prefix "cmd with trailing control code" { gdb_assert { [string equal $output $expected_error_msg] } } } + +# Change the prompt. +set prompt "(GDB) " +set prompt_re "\\(GDB\\) $" +gdb_test -prompt $prompt_re "set prompt $prompt" + +gdb_test_multiple "print 1" "" -prompt $prompt_re { + -re -wrap " = 1" { + pass $gdb_test_name + } +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 9ea0334759d..fec64ed1e6c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1126,7 +1126,7 @@ proc gdb_test_multiple { command message args } { if { $wrap_pattern } { # Wrap subst_item as is done for the gdb_test PATTERN argument. lappend $current_list \ - "\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $" + "\[\r\n\]*(?:$subst_item)\[\r\n\]+$prompt_regexp" set wrap_pattern 0 } else { lappend $current_list $subst_item From patchwork Fri Apr 21 14:58:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 68138 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 B359C3854174 for ; Fri, 21 Apr 2023 14:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B359C3854174 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682089153; bh=pnqb+kNutJIKAtNDD9zoO5IoF+kt1G4fJDtTw3hi9Fo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=T3yGlOTKNFzcR7xZOzRJBISKw+9tBXozyX5hK1UndQWF/x63ptSMv4DW6VIT5k5Q3 W4Brxx2+EJyNBu4jLkf7IRIHdtU7GmBooJF8XJ09Q8ZBFWYtgql8FSmcWaHIMSRYa0 P0wO7pL6P5b7Hqp+LjPSFCjEpHVobldGano0mAL8= 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 A834D3856DD7 for ; Fri, 21 Apr 2023 14:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A834D3856DD7 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 D442E1FE1D for ; Fri, 21 Apr 2023 14:58: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 B35C31391A for ; Fri, 21 Apr 2023 14:58:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0AJnKqCkQmTqDAAAMHmgww (envelope-from ) for ; Fri, 21 Apr 2023 14:58:40 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 2/3] [gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2 -flto Date: Fri, 21 Apr 2023 16:58:32 +0200 Message-Id: <20230421145833.24521-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230421145833.24521-1-tdevries@suse.de> References: <20230421145833.24521-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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, T_SCC_BODY_TEXT_LINE 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" On openSUSE Leap 15.4, with gcc 7.5.0, when building gdb with -O2 -g -flto=auto, I run into: ... FAIL: gdb.gdb/python-helper.exp: hit breakpoint in outer gdb FAIL: gdb.gdb/python-helper.exp: print integer from DWARF info FAIL: gdb.gdb/python-helper.exp: print *type->main_type ... Fix the first two FAILs by using $bkptno_numopt_re. The last FAIL is due to: ... (outer-gdb) print *type->main_type^M A syntax error in expression, near `->main_type'.^M (outer-gdb) FAIL: gdb.gdb/python-helper.exp: print *type->main_type ... because: ... (outer-gdb) print type^M Attempt to use a type name as an expression^M ... Fix this by making the test unresolved if "print type" or "print type->main_type" doesn't succeed. On openSUSE Tumbleweed, with gcc 13.0.1, when building gdb with -O2 -g -flto=auto, I run into timeouts due to the breakpoint in c_print_type not hitting. Fix this by detecting the situation and bailing out. Tested on x86_64-linux. --- gdb/testsuite/gdb.gdb/python-helper.exp | 77 +++++++++++++++++++------ 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp index a58e3b601df..a2dbeee4815 100644 --- a/gdb/testsuite/gdb.gdb/python-helper.exp +++ b/gdb/testsuite/gdb.gdb/python-helper.exp @@ -124,7 +124,9 @@ proc test_python_helper {} { # GDB, this should result in the outer GDB stopping at one of the # breakpoints we created.. send_inferior "print 1\n" - gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, value_print.*" "hit breakpoint in outer gdb" + gdb_test -prompt $outer_prompt_re "" \ + "Breakpoint $bkptno_numopt_re, value_print.*" \ + "hit breakpoint in outer gdb" # Now inspect the type of parameter VAL, this should trigger the # pretty printers. @@ -162,8 +164,10 @@ proc test_python_helper {} { # information, this will include the TYPE_SPECIFIC_INT # information. send_inferior "print global_c.m_val\n" - gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, value_print.*" "print integer from DWARF info" - + gdb_test -prompt $outer_prompt_re "" \ + "Breakpoint $bkptno_numopt_re, value_print.*" \ + "print integer from DWARF info" + set answer [multi_line \ "$decimal = " \ "{name = $hex \"int\"," \ @@ -187,23 +191,58 @@ proc test_python_helper {} { # Send a command to the inner GDB, this should result in the outer # GDB stopping at the value_print breakpoint again. send_inferior "ptype global_c\n" - gdb_test -prompt $outer_prompt_re "" "Breakpoint $bkptno_numopt_re, c_print_type.*" "hit breakpoint in outer gdb again" + set test "hit breakpoint in outer gdb again" + set in_outer_gdb 0 + gdb_test_multiple "" $test -prompt $outer_prompt_re { + -re -wrap "Breakpoint $bkptno_numopt_re, c_print_type.*" { + pass $gdb_test_name + set in_outer_gdb 1 + } + -re "\r\n$gdb_prompt $" { + unsupported $gdb_test_name + } + } - set answer [multi_line \ - "$decimal = " \ - "{name = $hex \"CC\"," \ - " code = TYPE_CODE_STRUCT," \ - " flags = \[^\r\n\]+," \ - " owner = $hex \\(objfile\\)," \ - " target_type = 0x0," \ - " flds_bnds\\.fields\\\[0\\\]:" \ - " {m_name = $hex \"m_val\"," \ - " m_type = $hex," \ - " m_loc_kind = FIELD_LOC_KIND_BITPOS," \ - " bitsize = 0," \ - " bitpos = 0}," \ - " cplus_stuff = $hex}"] - gdb_test -prompt $outer_prompt_re "print *type->main_type" $answer + if { ! $in_outer_gdb } { + return 0 + } + + set cmd "print *type->main_type" + set cmd_supported 1 + foreach sub_expr { type type->main_type } { + set ok 0 + gdb_test_multiple "print $sub_expr" "" -prompt $outer_prompt_re { + -re -wrap " = \\(\[^\r\n\]+ \\*\\) $hex" { + set ok 1 + } + -re -wrap "" { + } + } + if { ! $ok } { + set cmd_supported 0 + break + } + } + + if { $cmd_supported } { + set answer [multi_line \ + "$decimal = " \ + "{name = $hex \"CC\"," \ + " code = TYPE_CODE_STRUCT," \ + " flags = \[^\r\n\]+," \ + " owner = $hex \\(objfile\\)," \ + " target_type = 0x0," \ + " flds_bnds\\.fields\\\[0\\\]:" \ + " {m_name = $hex \"m_val\"," \ + " m_type = $hex," \ + " m_loc_kind = FIELD_LOC_KIND_BITPOS," \ + " bitsize = 0," \ + " bitpos = 0}," \ + " cplus_stuff = $hex}"] + gdb_test -prompt $outer_prompt_re $cmd $answer + } else { + unsupported $cmd + } # Test the htab_t pretty-printer. gdb_test -prompt $outer_prompt_re "print all_bfds" "htab_t with ${::decimal} elements = \\{${::hex}.*\\}" From patchwork Fri Apr 21 14:58:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 68139 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 0CD7A3855586 for ; Fri, 21 Apr 2023 14:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CD7A3855586 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682089168; bh=2RAtWUQ+Dzzc/SocOMnzVBng8AC3heeg1HOGw/74BbY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sGD7c+gHEZjtlKBRFgZX8/Lf3mND0eeulmSYRve4lsMSXHt/I9y31ioaJupxQ6psu Kj9/5Hpi0pDCZpaBBJsomecmJYIHQFZ4RiuuWCyrkVx1n9wHRU/t8+X0gfWSS/G3Bd +qndjVa/fRsFSfdfi6azlox/oJZvd3IgySDwk7xQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id AD0923856DDC for ; Fri, 21 Apr 2023 14:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD0923856DDC 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 E12B41FE20 for ; Fri, 21 Apr 2023 14:58: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 CEED01390E for ; Fri, 21 Apr 2023 14:58:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wFg9MaCkQmTqDAAAMHmgww (envelope-from ) for ; Fri, 21 Apr 2023 14:58:40 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [gdb/testsuite] Fix auto-indent in gdb.gdb/python-helper.exp Date: Fri, 21 Apr 2023 16:58:33 +0200 Message-Id: <20230421145833.24521-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230421145833.24521-1-tdevries@suse.de> References: <20230421145833.24521-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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, T_SCC_BODY_TEXT_LINE 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" When editing gdb.gdb/python-helper.exp, auto-indent is broken in my editor (emacs). The problem is that this: ... if { 1 } { foo "{" "}"bar } ... produces this: ... if { 1 } { foo "{" "}" bar } ... Note that this doesn't happen for "{}". Fix this by using "\{" and "\}". Tested on x86_64-linux. --- gdb/testsuite/gdb.gdb/python-helper.exp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp index a2dbeee4815..217f123302d 100644 --- a/gdb/testsuite/gdb.gdb/python-helper.exp +++ b/gdb/testsuite/gdb.gdb/python-helper.exp @@ -132,22 +132,22 @@ proc test_python_helper {} { # pretty printers. set answer [multi_line \ "${decimal} = " \ - "{pointer_type = 0x0," \ + "\{pointer_type = 0x0," \ " reference_type = 0x0," \ " chain = 0x0," \ " instance_flags = 0," \ " length = $decimal," \ - " main_type = $hex}"] + " main_type = $hex\}"] gdb_test -prompt $outer_prompt_re "print *val->m_type" $answer "pretty print type" set answer [multi_line \ "$decimal = " \ - "{name = $hex \"int\"," \ + "\{name = $hex \"int\"," \ " code = TYPE_CODE_INT," \ " flags = \[^\r\n\]+," \ " owner = $hex \\(gdbarch\\)," \ " target_type = 0x0," \ - " int_stuff = { bit_size = $decimal, bit_offset = $decimal }}"] + " int_stuff = \{ bit_size = $decimal, bit_offset = $decimal \}\}"] gdb_test -prompt $outer_prompt_re "print *val->m_type->main_type" $answer "pretty print type->main_type" # Send the continue to the outer GDB, which resumes the inner GDB, @@ -170,12 +170,12 @@ proc test_python_helper {} { set answer [multi_line \ "$decimal = " \ - "{name = $hex \"int\"," \ + "\{name = $hex \"int\"," \ " code = TYPE_CODE_INT," \ " flags = \[^\r\n\]+," \ " owner = $hex \\(objfile\\)," \ " target_type = 0x0," \ - " int_stuff = { bit_size = $decimal, bit_offset = $decimal }}"] + " int_stuff = \{ bit_size = $decimal, bit_offset = $decimal \}\}"] gdb_test -prompt $outer_prompt_re "print *val->m_type->main_type" $answer "pretty print type->main_type for DWARF type" # Send the continue to the outer GDB, which resumes the inner GDB, @@ -227,18 +227,18 @@ proc test_python_helper {} { if { $cmd_supported } { set answer [multi_line \ "$decimal = " \ - "{name = $hex \"CC\"," \ + "\{name = $hex \"CC\"," \ " code = TYPE_CODE_STRUCT," \ " flags = \[^\r\n\]+," \ " owner = $hex \\(objfile\\)," \ " target_type = 0x0," \ " flds_bnds\\.fields\\\[0\\\]:" \ - " {m_name = $hex \"m_val\"," \ + " \{m_name = $hex \"m_val\"," \ " m_type = $hex," \ " m_loc_kind = FIELD_LOC_KIND_BITPOS," \ " bitsize = 0," \ - " bitpos = 0}," \ - " cplus_stuff = $hex}"] + " bitpos = 0\}," \ + " cplus_stuff = $hex\}"] gdb_test -prompt $outer_prompt_re $cmd $answer } else { unsupported $cmd