From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id C3236384188E; Fri, 10 Jun 2022 10:05:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3236384188E 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: remove definition of true/false from gdb_compiler_info X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 3abc1d8fe0e09a4ba806d5e2a1902ac45f825ee9 X-Git-Newrev: 80c0a3bf1b949403521d186fc04ed9052ea1d7d4 Message-Id: <20220610100556.C3236384188E@sourceware.org> Date: Fri, 10 Jun 2022 10:05:56 +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: Fri, 10 Jun 2022 10:05:56 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D80c0a3bf1b94= 9403521d186fc04ed9052ea1d7d4 commit 80c0a3bf1b949403521d186fc04ed9052ea1d7d4 Author: Andrew Burgess Date: Thu Jun 9 16:56:35 2022 +0100 gdb/testsuite: remove definition of true/false from gdb_compiler_info =20 Since pretty much forever the get_compiler_info function has included these lines: =20 # Most compilers will evaluate comparisons and other boolean # operations to 0 or 1. uplevel \#0 { set true 1 } uplevel \#0 { set false 0 } =20 These define global variables true (to 1) and false (to 0). =20 It seems odd to me that these globals are defined in get_compiler_info, I guess maybe the original thinking was that if a compiler had different true/false values then we would detect it there and define true/false differently. =20 I don't think we should be bundling this logic into get_compiler_info, it seems weird to me that in order to use $true/$false a user needs to first call get_compiler_info. =20 It would be better I think if each test script that wants these variables just defined them itself, if in the future we did need different true/false values based on compiler version then we'd just do: =20 if { [test_compiler_info "some_pattern"] } { # Defined true/false one way... } else { # Defined true/false another way... } =20 But given the current true/false definitions have been in place since at least 1999, I suspect this will not be needed any time soon. =20 Given that the definitions of true/false are so simple, right now my suggestion is just to define them in each test script that wants them (there's not that many). If we ever did need more complex logic then we can always add a function in gdb.exp that sets up these globals, but that seems overkill for now. =20 There should be no change in what is tested after this commit. Diff: --- gdb/testsuite/gdb.base/all-bin.exp | 4 ++++ gdb/testsuite/gdb.base/eval-skip.exp | 3 +++ gdb/testsuite/gdb.base/exprs.exp | 4 ++++ gdb/testsuite/gdb.base/miscexprs.exp | 3 +++ gdb/testsuite/gdb.base/pointers.exp | 4 ++++ gdb/testsuite/gdb.base/relational.exp | 4 ++++ gdb/testsuite/lib/gdb.exp | 5 ----- 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.base/all-bin.exp b/gdb/testsuite/gdb.base/al= l-bin.exp index 5d493e6d6fc..1f481210e19 100644 --- a/gdb/testsuite/gdb.base/all-bin.exp +++ b/gdb/testsuite/gdb.base/all-bin.exp @@ -46,6 +46,10 @@ if ![runto_main] then { return } =20 +# These are used as expected result values. +set false 0 +set true 1 + gdb_test "next" "return 0;" "continuing after dummy()" =20 gdb_test "print v_int+v_char" " =3D 71" "print value of v_int+v_char" diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/= eval-skip.exp index 218aaab476c..81b37d1a891 100644 --- a/gdb/testsuite/gdb.base/eval-skip.exp +++ b/gdb/testsuite/gdb.base/eval-skip.exp @@ -51,6 +51,9 @@ if ![runto_main] then { return } =20 +# This is used as an expected result value. +set false 0 + gdb_test_no_output "set variable x=3D14" "set variable x=3D14" gdb_test_no_output "set variable y=3D2" "set variable y=3D2" gdb_test_no_output "set variable z=3D2" "set variable z=3D2" diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/expr= s.exp index 83bc60aa610..dfe0ec93737 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -41,6 +41,10 @@ if ![runto_main] then { return } =20 +# These are used as expected result values. +set false 0 +set true 1 + proc test_expr { args } { if { [llength $args] % 2 } { warning "an even # of arguments should be passed to test_expr" diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/= miscexprs.exp index cac8cf2ce87..f633d143b6f 100644 --- a/gdb/testsuite/gdb.base/miscexprs.exp +++ b/gdb/testsuite/gdb.base/miscexprs.exp @@ -59,6 +59,9 @@ if ![runto_main] then { return } =20 +# This is used as an expected result value. +set false 0 + gdb_test "break marker1" ".*" "" =20 gdb_test "cont" \ diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/p= ointers.exp index e6406613318..586f85a4947 100644 --- a/gdb/testsuite/gdb.base/pointers.exp +++ b/gdb/testsuite/gdb.base/pointers.exp @@ -48,6 +48,10 @@ if ![runto_main] then { return } =20 +# These are used as expected result values. +set false 0 +set true 1 + gdb_test "next " "more_code.*;" "continuing after dummy()" =20 =20 diff --git a/gdb/testsuite/gdb.base/relational.exp b/gdb/testsuite/gdb.base= /relational.exp index 858398323cd..87ccb9f3fe7 100644 --- a/gdb/testsuite/gdb.base/relational.exp +++ b/gdb/testsuite/gdb.base/relational.exp @@ -42,6 +42,10 @@ if ![runto_main] then { return } =20 +# These are used as expected result values. +set false 0 +set true 1 + # # test expressions with "int" types # diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 37accd9947a..75efc4a62d1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4191,11 +4191,6 @@ proc get_compiler_info {{language "c"}} { # Log what happened. verbose -log "get_compiler_info: $compiler_info" =20 - # Most compilers will evaluate comparisons and other boolean - # operations to 0 or 1. - uplevel \#0 { set true 1 } - uplevel \#0 { set false 0 } - return 0 }