From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2518 invoked by alias); 31 Jan 2008 22:48:25 -0000 Received: (qmail 2510 invoked by uid 22791); 31 Jan 2008 22:48:25 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 31 Jan 2008 22:48:05 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id D4C4898217; Thu, 31 Jan 2008 22:48:03 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id B161A98214; Thu, 31 Jan 2008 22:48:03 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1JKiCQ-0002L3-GA; Thu, 31 Jan 2008 17:48:02 -0500 Date: Thu, 31 Jan 2008 23:01:00 -0000 From: Daniel Jacobowitz To: Doug Evans Cc: gdb-patches@sourceware.org Subject: Re: [RFA] BINOP_DIV and ptyp command Message-ID: <20080131224802.GB8210@caradoc.them.org> Mail-Followup-To: Doug Evans , gdb-patches@sourceware.org References: <20080130172852.4CFD413EC2@sebabeach.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080130172852.4CFD413EC2@sebabeach.org> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes 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: 2008-01/txt/msg00883.txt.bz2 On Wed, Jan 30, 2008 at 09:28:52AM -0800, Doug Evans wrote: > + /* If EVAL_AVOID_SIDE_EFFECTS and we're dividing by zero, > + fudge arg2 to avoid division-by-zero, the caller is > + (theoretically) only looking for the type of the result. */ > + if (noside == EVAL_AVOID_SIDE_EFFECTS > + /* ??? Do we really want to test for BINOP_MOD here? > + The implementation of value_binop gives it a well-defined > + value. */ > + && (op == BINOP_DIV > + || op == BINOP_INTDIV > + || op == BINOP_REM > + || op == BINOP_MOD) > + && value_logical_not (arg2)) > + { > + struct value *v_one, *retval; > + > + v_one = value_one (value_type (arg2), not_lval); > + retval = value_binop (arg1, v_one, op); > + value_free (v_one); > + return retval; > + } Can't call value_free here. That's just a call to free, and values are kept in a linked list; see value_release and value_free_to_mark. In general, it's fine to leak values unless you're in a loop. If your caller cares, it will use value_free_to_mark to clean up; otherwise it will happen at the top level. value_one has the same issue. > + else if (is_integral_type (type1)) > + { > + /* Perform integral promotion for ANSI C/C++. > + If not appropropriate for any particular language it needs to > + supply its own la_unop_result_type function. */ No la_unop_result_type in this version (which I like best of the several you posted). > + switch (current_language->la_language) > + { > + case language_c: > + case language_cplus: > + case language_asm: > + /* ??? language_objc? */ > + /* Perform ANSI/ISO-C promotions. > + If only one type is float, use its type. > + Otherwise use the bigger type. */ > + if (TYPE_CODE (type1) != TYPE_CODE_FLT) > + return type2; > + else if (TYPE_CODE (type2) != TYPE_CODE_FLT) > + return type1; > + else > + return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) ? type1 : type2; > + > + default: > + /* For other languages the result type is unchanged from 6.7 for > + backward compatibility. > + If either arg was long double, make sure that value is also long > + double. */ > + if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (current_gdbarch) > + || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (current_gdbarch)) > + return builtin_type_long_double; > + else > + return builtin_type_double; > + } > + } Yes, Objective-C also. Please clarify that "6.7" is a GDB version number, or use a date. Or just change it for all languages; documenting "the value system uses C type promotions" is nice and simple. Either way is OK with me. Beyond that the patch looked OK. -- Daniel Jacobowitz CodeSourcery