From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23576 invoked by alias); 31 Aug 2008 17:52:24 -0000 Received: (qmail 23252 invoked by uid 22791); 31 Aug 2008 17:52:18 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:51:30 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpRj5288250 for ; Sun, 31 Aug 2008 17:51:27 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7VHpRYD1683456 for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7VHpQUd020107 for ; Sun, 31 Aug 2008 19:51:26 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m7VHpQAH020104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:26 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (localhost.localdomain [127.0.0.1]) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpQbW002649 for ; Sun, 31 Aug 2008 19:51:26 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpQDS002648 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:26 +0200 Message-Id: <20080831175126.215914000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:52:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types Content-Disposition: inline; filename=diff-type-derefint 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-08/txt/msg00686.txt.bz2 Hello, GDB allows to dereference an integer type, treating it as if it were an "int *". This patch pulls support for this special extension out of common value_ind code (which doesn't know which architecture to use for that "int" type) and into the expression evaluators -- which already handle it for the EVAL_AVOID_SIDE_EFFECTS case. It might make sense to check for which languages this extension is actually useful, and remove it from the rest. Bye, Ulrich ChangeLog: * valops.c (value_ind): No longer allow dereferencing an integer type. * eval.c (evaluate_subexp_standard): Handle deferencing an integer type here. * ada-lang.c (ada_evaluate_subexp): Likewise. * jv-lang.c (evaluate_subexp_java): Likewise. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -9194,7 +9194,8 @@ ada_evaluate_subexp (struct type *expect } else if (TYPE_CODE (type) == TYPE_CODE_INT) /* GDB allows dereferencing an int. */ - return value_zero (builtin_type_int, lval_memory); + return value_zero (builtin_type (exp->gdbarch)->builtin_int, + lval_memory); else error (_("Attempt to take contents of a non-pointer value.")); } @@ -9204,6 +9205,10 @@ ada_evaluate_subexp (struct type *expect if (ada_is_array_descriptor_type (type)) /* GDB allows dereferencing GNAT array descriptors. */ return ada_coerce_to_simple_array (arg1); + else if (TYPE_CODE (type) == TYPE_CODE_INT) + /* GDB allows dereferencing an int. */ + return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, + (CORE_ADDR) value_as_address (arg1)); else return ada_value_ind (arg1); Index: gdb-head/gdb/eval.c =================================================================== --- gdb-head.orig/gdb/eval.c +++ gdb-head/gdb/eval.c @@ -2288,10 +2288,19 @@ evaluate_subexp_standard (struct type *e lval_memory); else if (TYPE_CODE (type) == TYPE_CODE_INT) /* GDB allows dereferencing an int. */ - return value_zero (builtin_type_int, lval_memory); + return value_zero (builtin_type (exp->gdbarch)->builtin_int, + lval_memory); else error (_("Attempt to take contents of a non-pointer value.")); } + + /* Allow * on an integer so we can cast it to whatever we want. + This returns an int, which seems like the most C-like thing to + do. "long long" variables are rare enough that + BUILTIN_TYPE_LONGEST would seem to be a mistake. */ + if (TYPE_CODE (type) == TYPE_CODE_INT) + return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, + (CORE_ADDR) value_as_address (arg1)); return value_ind (arg1); case UNOP_ADDR: Index: gdb-head/gdb/jv-lang.c =================================================================== --- gdb-head.orig/gdb/jv-lang.c +++ gdb-head/gdb/jv-lang.c @@ -855,6 +855,10 @@ evaluate_subexp_java (struct type *expec } if (noside == EVAL_SKIP) goto nosideret; + if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_INT) + /* GDB allows dereferencing an int. */ + return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, + (CORE_ADDR) value_as_address (arg1)); return value_ind (arg1); case BINOP_SUBSCRIPT: Index: gdb-head/gdb/valops.c =================================================================== --- gdb-head.orig/gdb/valops.c +++ gdb-head/gdb/valops.c @@ -1166,14 +1166,7 @@ value_ind (struct value *arg1) base_type = check_typedef (value_type (arg1)); - /* Allow * on an integer so we can cast it to whatever we want. - This returns an int, which seems like the most C-like thing to - do. "long long" variables are rare enough that - BUILTIN_TYPE_LONGEST would seem to be a mistake. */ - if (TYPE_CODE (base_type) == TYPE_CODE_INT) - return value_at_lazy (builtin_type_int, - (CORE_ADDR) value_as_address (arg1)); - else if (TYPE_CODE (base_type) == TYPE_CODE_PTR) + if (TYPE_CODE (base_type) == TYPE_CODE_PTR) { struct type *enc_type; /* We may be pointing to something embedded in a larger object. -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com