From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5845 invoked by alias); 26 Jun 2009 15:53:31 -0000 Received: (qmail 5835 invoked by uid 22791); 26 Jun 2009 15:53:30 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtagate4.de.ibm.com (HELO mtagate4.de.ibm.com) (195.212.29.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Jun 2009 15:53:23 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.14.3/8.13.8) with ESMTP id n5QFrL4I127342 for ; Fri, 26 Jun 2009 15:53:21 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.2) with ESMTP id n5QFrL9k3887232 for ; Fri, 26 Jun 2009 17:53:21 +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 n5QFrKuj030073 for ; Fri, 26 Jun 2009 17:53:21 +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 SMTP id n5QFrJfo030041; Fri, 26 Jun 2009 17:53:19 +0200 Message-Id: <200906261553.n5QFrJfo030041@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 26 Jun 2009 17:53:19 +0200 Subject: [rfa/Ada] Remove builtin types from type/value printing routines To: brobecker@adacore.com, gdb-patches@sourceware.org Date: Fri, 26 Jun 2009 15:53:00 -0000 From: "Ulrich Weigand" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2009-06/txt/msg00718.txt.bz2 Hello Joel, the remaining references to global integer builtin types are all related to type/value printing. Various places that are unable to determine a proper type to use for printing integer values fall back to a default builtin_type_int32 type. The precise properties of this type do not actually matter, however; it only serves as means to indicate to ada_print_scalar to print the value as a default signed integer. This patch simply changes ada_print_scalar to accept a NULL type argument to indicate the same thing, and updates the callers to use NULL instead of builtin_type_int32. (A non-obvious instance of this is ada_variant_discrim_type, which returns a type that is solely used as argument to ada_print_scalar, after having been passed through print_choices.) Tested on amd64-linux. OK for mainline? Bye, Ulrich ChangeLog: * ada-valprint.c (ada_print_scalar): Accept NULL type argument to indicate scalar should be printed as default integer. (print_optional_low_bound): Pass NULL to ada_print_scalar to indicate default integer output. * ada-typeprint.c (print_range, print_range_bound): Likewise. (print_choices): Likewise. Thus, accept NULL as val_type. * ada-lang.c (ada_variant_discrim_type): Return NULL when failed to look up controlling discriminant name. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -5645,18 +5645,14 @@ ada_is_variant_part (struct type *type, /* Assuming that VAR_TYPE is a variant wrapper (type of the variant part) whose discriminants are contained in the record type OUTER_TYPE, - returns the type of the controlling discriminant for the variant. */ + returns the type of the controlling discriminant for the variant. + May return NULL if the type could not be found. */ struct type * ada_variant_discrim_type (struct type *var_type, struct type *outer_type) { char *name = ada_variant_discrim_name (var_type); - struct type *type = - ada_lookup_struct_elt_type (outer_type, name, 1, 1, NULL); - if (type == NULL) - return builtin_type_int32; - else - return type; + return ada_lookup_struct_elt_type (outer_type, name, 1, 1, NULL); } /* Assuming that TYPE is the type of a variant wrapper, and FIELD_NUM is a Index: gdb-head/gdb/ada-typeprint.c =================================================================== --- gdb-head.orig/gdb/ada-typeprint.c +++ gdb-head/gdb/ada-typeprint.c @@ -133,7 +133,7 @@ print_range (struct type *type, struct u case TYPE_CODE_ENUM: break; default: - target_type = builtin_type_int32; + target_type = NULL; break; } @@ -181,12 +181,12 @@ print_range_bound (struct type *type, ch be printed as a signed or an unsigned value. This causes the upper bound of the 0 .. -1 range types to be printed as a very large unsigned number instead of -1. - To workaround this stabs deficiency, we replace the TYPE by - builtin_type_int32 when we detect that the bound is negative, + To workaround this stabs deficiency, we replace the TYPE by NULL + to indicate default output when we detect that the bound is negative, and the type is a TYPE_CODE_INT. The bound is negative when 'm' is the last character of the number scanned in BOUNDS. */ if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT) - type = builtin_type_int32; + type = NULL; ada_print_scalar (type, B, stream); if (bounds[*n] == '_') *n += 2; @@ -423,7 +423,7 @@ print_array_type (struct type *type, str } /* Print the choices encoded by field FIELD_NUM of variant-part TYPE on - STREAM, assuming the VAL_TYPE is the type of the values. */ + STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the values. */ static void print_choices (struct type *type, int field_num, struct ui_file *stream, Index: gdb-head/gdb/ada-valprint.c =================================================================== --- gdb-head.orig/gdb/ada-valprint.c +++ gdb-head/gdb/ada-valprint.c @@ -122,7 +122,7 @@ print_optional_low_bound (struct ui_file return 0; break; case TYPE_CODE_UNDEF: - index_type = builtin_type_int32; + index_type = NULL; /* FALL THROUGH */ default: if (low_bound == 1) @@ -375,7 +375,8 @@ ada_printchar (int c, struct type *type, } /* [From print_type_scalar in typeprint.c]. Print VAL on STREAM in a - form appropriate for TYPE. */ + form appropriate for TYPE, if non-NULL. If TYPE is NULL, print VAL + like a default signed integer. */ void ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream) @@ -383,6 +384,12 @@ ada_print_scalar (struct type *type, LON unsigned int i; unsigned len; + if (!type) + { + print_longest (stream, 'd', 0, val); + return; + } + type = ada_check_typedef (type); switch (TYPE_CODE (type)) -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com