From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14835 invoked by alias); 26 Feb 2006 22:48:51 -0000 Received: (qmail 14821 invoked by uid 22791); 26 Feb 2006 22:48:51 -0000 X-Spam-Check-By: sourceware.org Received: from mail.math.TU-Berlin.DE (HELO mail.math.TU-Berlin.DE) (130.149.12.212) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 26 Feb 2006 22:48:49 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.math.TU-Berlin.DE (8.13.5/8.13.3) with ESMTP id k1QMmlt7018218 for ; Sun, 26 Feb 2006 23:48:47 +0100 (MET) Received: from mail.math.TU-Berlin.DE ([127.0.0.1]) by localhost (mail.math.tu-berlin.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 17368-09 for ; Sun, 26 Feb 2006 23:48:46 +0100 (MET) Received: from mersenne.math.TU-Berlin.DE (mersenne.math.TU-Berlin.DE [130.149.14.233]) by mail.math.TU-Berlin.DE (8.13.5/8.13.3) with ESMTP id k1QMmjbX018213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 26 Feb 2006 23:48:45 +0100 (MET) Received: from mersenne.math.TU-Berlin.DE (localhost [127.0.0.1]) by mersenne.math.TU-Berlin.DE (8.13.3/8.13.3/SuSE Linux 0.7) with ESMTP id k1QMmj5b010000 for ; Sun, 26 Feb 2006 23:48:45 +0100 Received: (from thor@localhost) by mersenne.math.TU-Berlin.DE (8.13.3/8.13.3/Submit) id k1QMmjlB009999 for gdb-patches@sourceware.org; Sun, 26 Feb 2006 23:48:45 +0100 From: Thomas Richter Message-Id: <200602262248.k1QMmjlB009999@mersenne.math.TU-Berlin.DE> Subject: [PATCH] Print references as /x correctly To: gdb-patches@sourceware.org Date: Sun, 26 Feb 2006 23:42:00 -0000 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00489.txt.bz2 Hi Folks, gdb 6.4 does not print references correctly with the type specifier /x. To reproduce, create a reference "a" to an int variable, then try to print its value by p /x a gdb will now incorrectly print the address of the variable a references, not its contents. To fix this problem, edit print_formatted() in printcmd.c, the "default:" case of the big switch in lines 323 of printcmd.c as follows: default: if (format == 0 /* FIX THOR: Print references also by this */ || TYPE_CODE (type) == TYPE_CODE_ARRAY || TYPE_CODE (type) == TYPE_CODE_STRING || TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION || TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_NAMESPACE) /* If format is 0, use the 'natural' format for * that type of value. If the type is non-scalar, * we have to use language rules to print it as * a series of scalars. */ value_print (val, stream, format, Val_pretty_default); Thus, include the type code TYPE_CODE_REF in the default printing style. So long, Thomas