From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23457 invoked by alias); 31 Aug 2008 17:52:22 -0000 Received: (qmail 23277 invoked by uid 22791); 31 Aug 2008 17:52:19 -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:35 +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 m7VHpW5N147224 for ; Sun, 31 Aug 2008 17:51:32 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 m7VHpWtk3014830 for ; Sun, 31 Aug 2008 19:51:32 +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 m7VHpSUg020141 for ; Sun, 31 Aug 2008 19:51:29 +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 m7VHpSf8020138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:28 +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 m7VHpSsb002736 for ; Sun, 31 Aug 2008 19:51:28 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpSVf002735 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:28 +0200 Message-Id: <20080831175128.401018000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:53:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling Content-Disposition: inline; filename=diff-type-adaaddr 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/msg00701.txt.bz2 Hello, this eliminates a hard-coded use of builtin_type_void_data_ptr in ada_val_print_1. This use occurs in code to work around some GNAT versions that encode System.Address as an integer instead of pointer type. The following patch uses the gdbarch associates with the objfile where the type was defined to determine the pointer type to use for this work around. This is possible since for all types without objfile (i.e. builtin types), the work-around is not required as GDB installs them as pointer types to start with. Bye, Ulrich ChangeLog: * ada-valprint.c: Include "objfiles.h". (ada_val_print_1): Use the gdbarch associated with the objfile whether a System.Address type is defined to retrieve the proper pointer type to use to print it. Index: gdb-head/gdb/ada-valprint.c =================================================================== --- gdb-head.orig/gdb/ada-valprint.c +++ gdb-head/gdb/ada-valprint.c @@ -33,6 +33,7 @@ #include "c-lang.h" #include "infcall.h" #include "exceptions.h" +#include "objfiles.h" /* Encapsulates arguments to ada_val_print. */ struct ada_val_print_args @@ -792,18 +793,27 @@ ada_val_print_1 (struct type *type, cons { print_scalar_formatted (valaddr, type, format, 0, stream); } - else if (ada_is_system_address_type (type)) + else if (ada_is_system_address_type (type) + && TYPE_OBJFILE (type) != NULL) { /* FIXME: We want to print System.Address variables using the same format as for any access type. But for some reason GNAT encodes the System.Address type as an int, so we have to work-around this deficiency by handling - System.Address values as a special case. */ + System.Address values as a special case. + + We do this only for System.Address types defined in an + objfile. For the built-in version of System.Address we + have installed the proper type to begin with. */ + + struct gdbarch *gdbarch = get_objfile_arch (TYPE_OBJFILE (type)); + struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; + fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); fputs_filtered (paddress (extract_typed_address - (valaddr, builtin_type_void_data_ptr)), + (valaddr, ptr_type)), stream); } else -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com