From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id A70243857BB7 for ; Fri, 23 Sep 2022 14:18:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A70243857BB7 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 28NEI3k1001492 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Sep 2022 10:18:07 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 28NEI3k1001492 Received: from simark.localdomain (unknown [217.28.27.60]) (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 ESMTPSA id EC6C01E112; Fri, 23 Sep 2022 10:18:02 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Subject: [PATCH 2/3] gdb/testsuite: use gdb_test in gdb.gdb/python-helper.exp Date: Fri, 23 Sep 2022 10:18:00 -0400 Message-Id: <20220923141801.1106678-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220923141801.1106678-1-simon.marchi@polymtl.ca> References: <20220923141801.1106678-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 23 Sep 2022 14:18:03 +0000 X-Spam-Status: No, score=-3190.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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-List-Received-Date: Fri, 23 Sep 2022 14:18:12 -0000 If some command in there gives the wrong answer, we currently have to wait for a timeout for the test to continue. For instance, I currently see: print *val->type $1 = Python Exception : Cannot take address of method length. (outer-gdb) FAIL: gdb.gdb/python-helper.exp: pretty print type (timeout) We can avoid this and modernize the test at the same time by using the -prompt option of gdb_test. gdb_test_no_output currently accepts a -prompt_re option (the variable name passed to parse_args defines the option name), but I think it's a typo. It's supposed to be -prompt, like gdb_test. I can't find anything using -prompt_re using grep. Change it to just "prompt". Change-Id: Icc0a9a0ef482e62460c708bccdd544c11d711eca --- gdb/testsuite/gdb.gdb/python-helper.exp | 88 +++++-------------------- gdb/testsuite/lib/gdb.exp | 8 +-- 2 files changed, 21 insertions(+), 75 deletions(-) diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp index 6db8bf0df507..ea362ef693d9 100644 --- a/gdb/testsuite/gdb.gdb/python-helper.exp +++ b/gdb/testsuite/gdb.gdb/python-helper.exp @@ -82,13 +82,11 @@ proc test_python_helper {} { # binary into the inner GDB. gdb_test_no_output "disable breakpoints" + set outer_prompt_re "\\(outer-gdb\\) $" + # Adjust the prompt on the outer gdb, this just makes things a # little clearer when trying to unpick which GDB is active. - gdb_test_multiple "set prompt (outer-gdb) " "set outer gdb prompt" { - -re "\[(\]outer-gdb\[)\].*\[(\]outer-gdb\[)\] $" { - pass $gdb_test_name - } - } + gdb_test_no_output -prompt $outer_prompt_re "set prompt (outer-gdb) " "set outer gdb prompt" # Send a command to the outer GDB to continue the inner GDB. The # stop is being detected from the inner GDB, hence the use of -i @@ -113,18 +111,10 @@ proc test_python_helper {} { # Send Ctrl-C to the inner GDB, this should kick us back to the # prompt of the outer GDB. send_inferior "\003" - gdb_test_multiple "" "interrupted the inner" { - -re ".*\\(outer-gdb\\) $" { - pass $gdb_test_name - } - } + gdb_test -prompt $outer_prompt_re "" "" "interrupted the inner" # Now enable all breakpoints within the outer GDB. - gdb_test_multiple "enable breakpoints" "" { - -re "\\(outer-gdb\\) $" { - pass $gdb_test_name - } - } + gdb_test_no_output -prompt $outer_prompt_re "enable breakpoints" # We need to resume the inner GDB after interrupting it, this is # done by sending 'continue'. However, GDB will not redisplay the @@ -137,11 +127,7 @@ 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_multiple "" "hit breakpoint in outer gdb" { - -re "Breakpoint $decimal, value_print.*\\(outer-gdb\\) $" { - pass $gdb_test_name - } - } + gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, value_print.*" "hit breakpoint in outer gdb" # Now inspect the type of parameter VAL, this should trigger the # pretty printers. @@ -152,16 +138,8 @@ proc test_python_helper {} { " chain = 0x0," \ " instance_flags = 0," \ " length = $decimal," \ - " main_type = $hex}" \ - "\\(outer-gdb\\) $"] - gdb_test_multiple "print *val->type" "pretty print type" { - -re "$answer" { - pass $gdb_test_name - } - -re "There is no member named.*\r\n\\(outer-gdb\\) $" { - fail $gdb_test_name - } - } + " main_type = $hex}"] + gdb_test -prompt $outer_prompt_re "print *val->type" $answer "pretty print type" set answer [multi_line \ "$decimal = " \ @@ -170,16 +148,8 @@ proc test_python_helper {} { " flags = \[^\r\n\]+," \ " owner = $hex \\(gdbarch\\)," \ " target_type = 0x0," \ - " type_specific_field = TYPE_SPECIFIC_NONE}" \ - "\\(outer-gdb\\) $"] - gdb_test_multiple "print *val->type->main_type" "pretty print type->main_type" { - -re "$answer" { - pass $gdb_test_name - } - -re "There is no member named.*\r\n\\(outer-gdb\\) $" { - fail $gdb_test_name - } - } + " type_specific_field = TYPE_SPECIFIC_NONE}"] + gdb_test -prompt $outer_prompt_re "print *val->type->main_type" $answer "pretty print type->main_type" # Send the continue to the outer GDB, which resumes the inner GDB, # we then detect the prompt from the inner GDB, hence the use of @@ -195,12 +165,8 @@ proc test_python_helper {} { # information, this will include the TYPE_SPECIFIC_INT # information. send_inferior "print global_c.m_val\n" - gdb_test_multiple "" "print integer from DWARF info" { - -re "Breakpoint $decimal, value_print.*\\(outer-gdb\\) $" { - pass $gdb_test_name - } - } - + gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, value_print.*" "print integer from DWARF info" + set answer [multi_line \ "$decimal = " \ "{name = $hex \"int\"," \ @@ -208,16 +174,8 @@ proc test_python_helper {} { " flags = \[^\r\n\]+," \ " owner = $hex \\(objfile\\)," \ " target_type = 0x0," \ - " int_stuff = { bit_size = $decimal, bit_offset = $decimal }}" \ - "\\(outer-gdb\\) $"] - gdb_test_multiple "print *val->type->main_type" "pretty print type->main_type for DWARF type" { - -re "$answer" { - pass $gdb_test_name - } - -re "There is no member named.*\r\n\\(outer-gdb\\) $" { - fail $gdb_test_name - } - } + " int_stuff = { bit_size = $decimal, bit_offset = $decimal }}"] + gdb_test -prompt $outer_prompt_re "print *val->type->main_type" $answer "pretty print type->main_type for DWARF type" # Send the continue to the outer GDB, which resumes the inner GDB, # we then detect the prompt from the inner GDB, hence the use of @@ -232,11 +190,7 @@ 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_multiple "" "hit breakpoint in outer gdb again" { - -re "Breakpoint $decimal, c_print_type .*\\(outer-gdb\\) $" { - pass $gdb_test_name - } - } + gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, c_print_type.*" "hit breakpoint in outer gdb again" set answer [multi_line \ "$decimal = " \ @@ -251,16 +205,8 @@ proc test_python_helper {} { " m_loc_kind = FIELD_LOC_KIND_BITPOS," \ " bitsize = 0," \ " bitpos = 0}," \ - " cplus_stuff = $hex}" \ - "\\(outer-gdb\\) $"] - gdb_test_multiple "print *type->main_type" "" { - -re "$answer" { - pass $gdb_test_name - } - -re "\r\n\\(outer-gdb\\) $" { - fail $gdb_test_name - } - } + " cplus_stuff = $hex}"] + gdb_test -prompt $outer_prompt_re "print *type->main_type" $answer return 0 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 68536b00f146..5ab4df1bcf3c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1478,17 +1478,17 @@ proc gdb_test_no_output { args } { global gdb_prompt parse_args { - {prompt_re ""} + {prompt ""} {nopass} } lassign $args command message - set prompt_re [fill_in_default_prompt $prompt_re] + set prompt [fill_in_default_prompt $prompt] set command_regex [string_to_regexp $command] - gdb_test_multiple $command $message -prompt $prompt_re { - -re "^$command_regex\r\n$prompt_re" { + gdb_test_multiple $command $message -prompt $prompt { + -re "^$command_regex\r\n$prompt" { if {!$nopass} { pass $gdb_test_name } -- 2.37.3