From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24107 invoked by alias); 31 Aug 2008 17:52:29 -0000 Received: (qmail 23478 invoked by uid 22791); 31 Aug 2008 17:52:23 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate8.de.ibm.com (HELO mtagate8.de.ibm.com) (195.212.29.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:51:37 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate8.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpYf6245788 for ; Sun, 31 Aug 2008 17:51:34 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 m7VHpYFp3100760 for ; Sun, 31 Aug 2008 19:51:34 +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 m7VHpVtE020172 for ; Sun, 31 Aug 2008 19:51:31 +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 m7VHpV9r020168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:31 +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 m7VHpUQp002823 for ; Sun, 31 Aug 2008 19:51:30 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpUri002822 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:30 +0200 Message-Id: <20080831175130.615909000@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][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void Content-Disposition: inline; filename=diff-type-void 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/msg00680.txt.bz2 Hello, builtin_type_void is currently per-gdbarch type macro, even though the "void" type conceptually does not depend on the architecture. The rationale for this is that types derived from it (e.g. pointer to void or function returning void) *are* gdbarch-specific, and pointers to those are cached in the type data structure. However, this problem can be fixed by simply making sure that noone ever calls lookup_pointer_type, lookup_reference_type, or lookup_function_type on the platform-neutral builtin_type_void type. This is nearly everywhere already the case, since we have the per- gdbarch builtin_data_ptr and builtin_func_ptr for these purposes. This patch fixes the remaining uses, and converts builtin_type_void back to a global platform-neutral variable. This allows other parts of GDB to continue using builtin_type_void in platform-neutral code. Bye, Ulrich ChangeLog: * gdbtypes.h (builtin_type_void): Remove macro, add declaration. (builtin_type_f_void): Remove macro. * gdbtypes.c (builtin_type_void): New global variable. (_initialize_gdbtypes): Initialize it. * gnu-v3-abi.c (build_gdb_vtable_type): Do not call lookup_pointer_type or lookup_function_type on builtin_type_void. * printcmd.c (set_next_address): Likewise. * objc-lang.c (value_nsstring): Likewise. * mt-tdep.c (mt_copro_register_type): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * symfile.c (syms_from_objfile): Remove special handling of builtin_type_void and builtin_type_char. Index: gdb-head/gdb/gdbtypes.c =================================================================== --- gdb-head.orig/gdb/gdbtypes.c +++ gdb-head/gdb/gdbtypes.c @@ -108,6 +108,9 @@ struct type *builtin_type_arm_ext; struct type *builtin_type_ia64_spill; struct type *builtin_type_ia64_quad; +/* Platform-neutral void type. */ +struct type *builtin_type_void; + int opaque_type_resolution = 1; static void @@ -3330,6 +3333,11 @@ _initialize_gdbtypes (void) builtin_type_ia64_quad = build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad); + builtin_type_void = + init_type (TYPE_CODE_VOID, 1, + 0, + "void", (struct objfile *) NULL); + add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\ Set debugging of C++ overloading."), _("\ Show debugging of C++ overloading."), _("\ Index: gdb-head/gdb/gdbtypes.h =================================================================== --- gdb-head.orig/gdb/gdbtypes.h +++ gdb-head/gdb/gdbtypes.h @@ -1020,8 +1020,6 @@ extern const struct builtin_type *builti (builtin_type (current_gdbarch)->builtin_core_addr) #define builtin_type_true_char \ (builtin_type (current_gdbarch)->builtin_true_char) -#define builtin_type_void \ - (builtin_type (current_gdbarch)->builtin_void) #define builtin_type_char \ (builtin_type (current_gdbarch)->builtin_char) #define builtin_type_short \ @@ -1096,9 +1094,13 @@ extern struct type *builtin_type_arm_ext extern struct type *builtin_type_ia64_spill; extern struct type *builtin_type_ia64_quad; +/* Platform-neutral void type. Never attempt to construct a pointer + or reference type to this, because those cannot be platform-neutral. + You must use builtin_type (...)->builtin_void in those cases. */ +extern struct type *builtin_type_void; + /* This type represents a type that was unrecognized in symbol read-in. */ - extern struct type *builtin_type_error; @@ -1176,8 +1178,6 @@ extern const struct builtin_f_type *buil (builtin_f_type (current_gdbarch)->builtin_complex_s16) #define builtin_type_f_complex_s32 \ (builtin_f_type (current_gdbarch)->builtin_complex_s32) -#define builtin_type_f_void \ - (builtin_f_type (current_gdbarch)->builtin_void) /* RTTI for C++ */ Index: gdb-head/gdb/gnu-v3-abi.c =================================================================== --- gdb-head.orig/gdb/gnu-v3-abi.c +++ gdb-head/gdb/gnu-v3-abi.c @@ -107,9 +107,9 @@ build_gdb_vtable_type (struct gdbarch *a int offset; struct type *void_ptr_type - = lookup_pointer_type (builtin_type_void); + = builtin_type (arch)->builtin_data_ptr; struct type *ptr_to_void_fn_type - = lookup_pointer_type (lookup_function_type (builtin_type_void)); + = builtin_type (arch)->builtin_func_ptr; /* ARCH can't give us the true ptrdiff_t type, so we guess. */ struct type *ptrdiff_type Index: gdb-head/gdb/mt-tdep.c =================================================================== --- gdb-head.orig/gdb/mt-tdep.c +++ gdb-head/gdb/mt-tdep.c @@ -251,19 +251,13 @@ mt_copro_register_type (struct gdbarch * static struct type * mt_register_type (struct gdbarch *arch, int regnum) { - static struct type *void_func_ptr = NULL; - static struct type *void_ptr = NULL; - static struct type *copro_type; + static struct type *copro_type = NULL; if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS) { - if (void_func_ptr == NULL) + if (copro_type == NULL) { struct type *temp; - - void_ptr = lookup_pointer_type (builtin_type_void); - void_func_ptr = - lookup_pointer_type (lookup_function_type (builtin_type_void)); temp = create_range_type (NULL, builtin_type_unsigned_int, 0, 1); copro_type = create_array_type (NULL, builtin_type_int16, temp); } @@ -272,10 +266,10 @@ mt_register_type (struct gdbarch *arch, case MT_PC_REGNUM: case MT_RA_REGNUM: case MT_IRA_REGNUM: - return void_func_ptr; + return builtin_type (arch)->builtin_func_ptr; case MT_SP_REGNUM: case MT_FP_REGNUM: - return void_ptr; + return builtin_type (arch)->builtin_data_ptr; case MT_COPRO_REGNUM: case MT_COPRO_PSEUDOREG_REGNUM: return copro_type; Index: gdb-head/gdb/objc-lang.c =================================================================== --- gdb-head.orig/gdb/objc-lang.c +++ gdb-head/gdb/objc-lang.c @@ -173,7 +173,7 @@ value_nsstring (char *ptr, int len) if (sym == NULL) sym = lookup_struct_typedef("NXString", 0, 1); if (sym == NULL) - type = lookup_pointer_type(builtin_type_void); + type = builtin_type_void_data_ptr; else type = lookup_pointer_type(SYMBOL_TYPE (sym)); Index: gdb-head/gdb/printcmd.c =================================================================== --- gdb-head.orig/gdb/printcmd.c +++ gdb-head/gdb/printcmd.c @@ -513,8 +513,7 @@ set_next_address (CORE_ADDR addr) /* Make address available to the user as $_. */ set_internalvar (lookup_internalvar ("_"), - value_from_pointer (lookup_pointer_type (builtin_type_void), - addr)); + value_from_pointer (builtin_type_void_data_ptr, addr)); } /* Optionally print address ADDR symbolically as on STREAM, Index: gdb-head/gdb/symfile.c =================================================================== --- gdb-head.orig/gdb/symfile.c +++ gdb-head/gdb/symfile.c @@ -898,14 +898,6 @@ syms_from_objfile (struct objfile *objfi (*objfile->sf->sym_read) (objfile, mainline); - /* Don't allow char * to have a typename (else would get caddr_t). - Ditto void *. FIXME: Check whether this is now done by all the - symbol readers themselves (many of them now do), and if so remove - it from here. */ - - TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0; - TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0; - /* Mark the objfile has having had initial symbol read attempted. Note that this does not mean we found any symbols... */ Index: gdb-head/gdb/xtensa-tdep.c =================================================================== --- gdb-head.orig/gdb/xtensa-tdep.c +++ gdb-head/gdb/xtensa-tdep.c @@ -233,7 +233,7 @@ xtensa_register_type (struct gdbarch *gd if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == gdbarch_tdep (gdbarch)->a0_base + 1) - return lookup_pointer_type (builtin_type_void); + return builtin_type (gdbarch)->builtin_data_ptr; /* Return the stored type for all other registers. */ else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch) -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com