From patchwork Fri Mar 10 15:48:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Kolesov X-Patchwork-Id: 19509 Received: (qmail 82353 invoked by alias); 10 Mar 2017 15:49:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 80910 invoked by uid 89); 10 Mar 2017 15:49:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:3344 X-HELO: smtprelay.synopsys.com Received: from us01smtprelay-2.synopsys.com (HELO smtprelay.synopsys.com) (198.182.47.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Mar 2017 15:49:03 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 481D224E201B for ; Fri, 10 Mar 2017 07:49:02 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 20DD05A8; Fri, 10 Mar 2017 07:49:02 -0800 (PST) Received: from akolesov-lab.internal.synopsys.com (akolesov-lab.internal.synopsys.com [10.121.8.134]) by mailhost.synopsys.com (Postfix) with ESMTP id 16E6B580; Fri, 10 Mar 2017 07:49:00 -0800 (PST) From: Anton Kolesov To: gdb-patches@sourceware.org Cc: Anton Kolesov , Francois Bedard Subject: [PATCH] Add test name argument to get_valueof, get_integer_valueof and get_sizeof Date: Fri, 10 Mar 2017 18:48:51 +0300 Message-Id: <20170310154851.14036-1-Anton.Kolesov@synopsys.com> An optional parameter TEST has been added to get_hexadecimal_valueof in commit: https://sourceware.org/ml/gdb-patches/2016-06/msg00469.html This patch adds a similar optional parameter to other related methods that retrieve expression values: get_valueof, get_integer_valueof and get_sizeof. Thus tests that evaluate same expression multiple times can provide custom test names, ensuring that test names will be unique. gdb/testsuite/ChangeLog: yyyy-mm-dd Anton Kolesov * lib/gdb.exp (get_valueof, get_integer_valueof, get_sizeof): Add optional 'test' parameter. --- gdb/testsuite/lib/gdb.exp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 188484f..63d816e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5523,10 +5523,18 @@ proc prepare_for_testing { testname executable {sources ""} {options {debug}}} { return 0 } -proc get_valueof { fmt exp default } { +# Retrieve the value of EXP in the inferior, represented in format +# specified in FMT (using "printFMT"). DEFAULT is used as fallback if +# print fails. TEST is the test message to use. It can be omitted, +# in which case a test message is built from EXP. + +proc get_valueof { fmt exp default {test ""} } { global gdb_prompt - set test "get valueof \"${exp}\"" + if {$test == "" } { + set test "get valueof \"${exp}\"" + } + set val ${default} gdb_test_multiple "print${fmt} ${exp}" "$test" { -re "\\$\[0-9\]* = (.*)\[\r\n\]*$gdb_prompt $" { @@ -5540,10 +5548,18 @@ proc get_valueof { fmt exp default } { return ${val} } -proc get_integer_valueof { exp default } { +# Retrieve the value of EXP in the inferior, as a signed decimal value +# (using "print /d"). DEFAULT is used as fallback if print fails. +# TEST is the test message to use. It can be omitted, in which case +# a test message is built from EXP. + +proc get_integer_valueof { exp default {test ""} } { global gdb_prompt - set test "get integer valueof \"${exp}\"" + if {$test == ""} { + set test "get integer valueof \"${exp}\"" + } + set val ${default} gdb_test_multiple "print /d ${exp}" "$test" { -re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" { @@ -5559,7 +5575,7 @@ proc get_integer_valueof { exp default } { # Retrieve the value of EXP in the inferior, as an hexadecimal value # (using "print /x"). DEFAULT is used as fallback if print fails. -# TEST is the test message to use. If can be ommitted, in which case +# TEST is the test message to use. It can be omitted, in which case # a test message is built from EXP. proc get_hexadecimal_valueof { exp default {test ""} } { @@ -5579,8 +5595,12 @@ proc get_hexadecimal_valueof { exp default {test ""} } { return ${val} } -proc get_sizeof { type default } { - return [get_integer_valueof "sizeof (${type})" $default] +# Retrieve the size of TYPE in the inferior, as a decimal value. DEFAULT +# is used as fallback if print fails. TEST is the test message to use. +# It can be omitted, in which case a test message is 'sizeof (TYPE)'. + +proc get_sizeof { type default {test ""} } { + return [get_integer_valueof "sizeof (${type})" $default $test] } proc get_target_charset { } {