From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2394 invoked by alias); 28 Dec 2007 06:16:07 -0000 Received: (qmail 2384 invoked by uid 22791); 28 Dec 2007 06:16:07 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 28 Dec 2007 06:15:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 971BD2A966E for ; Fri, 28 Dec 2007 01:15:57 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LlVupmQW0vmX for ; Fri, 28 Dec 2007 01:15:57 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CEE8C2A966B for ; Fri, 28 Dec 2007 01:15:55 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 79E21E7ACB; Fri, 28 Dec 2007 10:15:13 +0400 (RET) Date: Fri, 28 Dec 2007 06:36:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/ada+testsuite] print ada boolean expression results as true/false Message-ID: <20071228061513.GA24450@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00431.txt.bz2 --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 937 This is a minor improvement, when printing the result of a boolean expression. Right now, GDB prints: (gdb) print 1 = 2 $1 = 0 (gdb) print 3 = 3 $2 = 1 The result should be of type boolean, which means either true or false. So the expected output is: (gdb) print 1 = 2 $1 = false (gdb) print 3 = 3 $2 = true The attached patches fixes it. 2007-12-27 Paul Hilfinger * ada-lang.c (ada_evaluate_subexp): Add cases for BINOP_LOGICAL_AND, BINOP_LOGICAL_OR, UNOP_LOGICAL_NOT, BINOP_BITWISE_IOR, BINOP_BITWISE_XOR, BINOP_BITWISE_AND. * language.c (lang_bool_type): Add Ada case. Tested on x86-linux. Checked in. In addition, I have written a small testcase for it: 2007-12-27 Joel Brobecker * gdb.ada/boolean_expr.exp: New testcase. Also tested on x86-linux. Fails without the ada-lang.c patch. -- Joel --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="boolean-ada.diff" Content-length: 1716 Index: ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.112 diff -u -p -r1.112 ada-lang.c --- ada-lang.c 24 Dec 2007 16:52:24 -0000 1.112 +++ ada-lang.c 28 Dec 2007 06:09:19 -0000 @@ -8151,6 +8151,24 @@ ada_evaluate_subexp (struct type *expect else return value_neg (arg1); + case BINOP_LOGICAL_AND: + case BINOP_LOGICAL_OR: + case UNOP_LOGICAL_NOT: + *pos -= 1; + return value_cast (LA_BOOL_TYPE, + evaluate_subexp_standard (expect_type, exp, + pos, noside)); + + case BINOP_BITWISE_AND: + case BINOP_BITWISE_IOR: + case BINOP_BITWISE_XOR: + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); + *pos = pc; + return value_cast (value_type (arg1), + evaluate_subexp_standard (expect_type, exp, + pos, noside)); + + case OP_VAR_VALUE: *pos -= 1; if (noside == EVAL_SKIP) Index: language.c =================================================================== RCS file: /cvs/src/src/gdb/language.c,v retrieving revision 1.70 diff -u -p -r1.70 language.c --- language.c 4 Dec 2007 23:33:00 -0000 1.70 +++ language.c 28 Dec 2007 06:09:19 -0000 @@ -801,6 +801,7 @@ lang_bool_type (void) return builtin_type_f_logical_s2; case language_cplus: case language_pascal: + case language_ada: if (current_language->la_language==language_cplus) {sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL, NULL);} else @@ -821,6 +822,7 @@ lang_bool_type (void) return type; } return java_boolean_type; + default: return builtin_type_int; } --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="boolean_expr.exp" Content-length: 1182 # Copyright 2007 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . if $tracelevel then { strace $tracelevel } load_lib "ada.exp" gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir set any_nb "\[0-9\]+" set any_addr "0x\[0-9a-zA-Z\]+" # Force the language to Ada, as this will not happen automatically # in this case (no test program). gdb_test "set lang ada" \ "" \ "Changing the language to ada" gdb_test "print 1 = 2" \ "false" \ "print 1 = 2" gdb_test "print 3 = 3" \ "true" \ "print 3 = 3" --cNdxnHkX5QqsyA0e--