From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8445 invoked by alias); 14 May 2009 11:37:07 -0000 Received: (qmail 8436 invoked by uid 22791); 14 May 2009 11:37:06 -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 mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 May 2009 11:36:59 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id n4EBautL005350 for ; Thu, 14 May 2009 11:36:56 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 n4EBauxD4386914 for ; Thu, 14 May 2009 13:36:56 +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 n4EBatDc002970 for ; Thu, 14 May 2009 13:36:55 +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 n4EBas1D002964; Thu, 14 May 2009 13:36:54 +0200 Message-Id: <200905141136.n4EBas1D002964@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 14 May 2009 13:36:54 +0200 Subject: [rfc] Ada simplification: ada_val_print_1 To: gdb-patches@sourceware.org, brobecker@adacore.com Date: Thu, 14 May 2009 11:37: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-05/txt/msg00296.txt.bz2 Hello, another problematic Ada case: ada_val_print_1 initializes a static type variable to the result of "make_pointer_type" -- which (implicitly today, but explicitly in the future) depends on an architecture to determine the size of a pointer. This could break in a multi-arch scenario. The whole logic there seems to have the sole purpose of printing a character string stored at some memory location as a result of an inferior call. We do have a routine val_print_string that should be able to do just that, without the need to create a dummy type ... Joel, is this OK? Bye, Ulrich ChangeLog: * ada-valprint.c (ada_val_print_1): Use val_print_string to print result of ada_vax_float_print_function inferior call. Index: gdb-head/gdb/ada-valprint.c =================================================================== --- gdb-head.orig/gdb/ada-valprint.c +++ gdb-head/gdb/ada-valprint.c @@ -739,22 +739,10 @@ ada_val_print_1 (struct type *type, cons struct value *func = ada_vax_float_print_function (type); if (func != 0) { - static struct type *parray_of_char = NULL; - struct value *printable_val; - - if (parray_of_char == NULL) - parray_of_char = - make_pointer_type - (create_array_type - (NULL, builtin_type_true_char, - create_range_type (NULL, builtin_type_int32, 0, 32)), NULL); - - printable_val = - value_ind (value_cast (parray_of_char, - call_function_by_hand (func, 1, - &val))); - - fprintf_filtered (stream, "%s", value_contents (printable_val)); + CORE_ADDR addr; + addr = value_as_address (call_function_by_hand (func, 1, &val)); + val_print_string (builtin_type_true_char, + addr, -1, stream, options); return 0; } /* No special printing function. Do as best we can. */ -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com