From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id E732B383A33D; Thu, 9 Jun 2022 13:41:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E732B383A33D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: handle errors better in test_compiler_info X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 08b326ee0a6384508703f9187905bb00bfe3d5d9 X-Git-Newrev: 0e471fde0742bbbc8e34f0d082d1b35c19aee96f Message-Id: <20220609134130.E732B383A33D@sourceware.org> Date: Thu, 9 Jun 2022 13:41:30 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2022 13:41:31 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0e471fde0742= bbbc8e34f0d082d1b35c19aee96f commit 0e471fde0742bbbc8e34f0d082d1b35c19aee96f Author: Andrew Burgess Date: Wed Jun 8 14:04:36 2022 +0100 gdb/testsuite: handle errors better in test_compiler_info =20 Now that get_compiler_info might actually fail (if the language is not handled), then we should try to handle this failure better in test_compiler_info. =20 After this commit, if get_compiler_info fails then we will return a suitable result depending on how the user called test_compiler_info. =20 If the user does something like: =20 set version [test_compiler_info "" "unknown-language"] =20 Then test_compiler_info will return an empty string. My assumption is that the user will be trying to match 'version' against something, and the empty string hopefully will not match. =20 If the user does something like: =20 if { [test_compiler_info "some_pattern" "unknown-language"] } { .... } =20 Then test_compiler_info will return false which seems the obvious choice. =20 There should be no change in the test results after this commit. Diff: --- gdb/testsuite/lib/gdb.exp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e530ba05a61..e28c33e8455 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4199,7 +4199,17 @@ proc get_compiler_info {{language "c"}} { =20 proc test_compiler_info { {compiler ""} {language "c"} } { global compiler_info - get_compiler_info $language + + if [get_compiler_info $language] { + # An error will already have been printed in this case. Just + # return a suitable result depending on how the user called + # this function. + if [string match "" $compiler] { + return "" + } else { + return false + } + } =20 # If no arg, return the compiler_info string. if [string match "" $compiler] {