From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30025 invoked by alias); 11 Jul 2010 16:23:42 -0000 Received: (qmail 30013 invoked by uid 22791); 11 Jul 2010 16:23:40 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL,BAYES_05,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_XF,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Jul 2010 16:23:36 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6BGNCBa003051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Jul 2010 12:23:12 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6BGN91E017476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Jul 2010 12:23:11 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o6BGN9pQ031316; Sun, 11 Jul 2010 18:23:09 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o6BGN8VR031315; Sun, 11 Jul 2010 18:23:08 +0200 Date: Sun, 11 Jul 2010 16:23:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Paul Hilfinger Subject: [patch] Fix forgotten check_typedef()s Message-ID: <20100711162307.GA31312@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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: 2010-07/txt/msg00199.txt.bz2 Hi, patch [COMMIT] 64-bit range types in GDB http://sourceware.org/ml/gdb-patches/2009-12/msg00181.html violates the comment /* Note that if thistype is a TYPEDEF type, you have to call check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, so you only have to call check_typedef once. Since allocate_value calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ #define TYPE_LENGTH(thistype) (thistype)->length by not calling check_typedef or CHECK_TYPEDEF before using TYPE_LENGTH in read_subrange_type. On gdb.pascal/hello.pas it has no effect but apparently the calculation is not right: (gdb) p base_type->length $7 = 0 (gdb) p base_type->main_type->flag_unsigned $8 = 0 (gdb) p/x negative_mask $5 = 0x8000000000000000 (gdb) p check_typedef (base_type) $9 = (struct type *) 0x1ed9190 (gdb) p $9->length $12 = 1 (gdb) p $9->main_type->flag_unsigned $13 = 1 (gdb) p/x low $14 = 0x0 (gdb) p/x high $15 = 0xff I did not try to find a reproducer. With the archer-jankratochvil-vla patchset there is a regression as LENGTH is check_typedef'ed there. pascal_printstr is the same class of bug, unrelated to the 64-bit range types patch above. (archer-jankratochvil-vla has a problem as create_array_type does not do CHECK_TYPEDEF (element_type) when it is not immediately required.) [ In a longterm IMO check_typedef should return a different GDB C type than what is its argument so that check_typedef is enforced during gdb compilation. ] No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. OK to check-in? Thanks, Jan gdb/ 2010-07-11 Jan Kratochvil * dwarf2read.c (read_subrange_type): Call read_subrange_type. * p-lang.c (pascal_printstr): Likewise. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6332,6 +6332,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) LONGEST negative_mask; base_type = die_type (die, cu); + /* Preserve BASE_TYPE's original type, just set its LENGTH. */ + check_typedef (base_type); /* The die_type call above may have already set the type for this DIE. */ range_type = get_die_type (die, cu); --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -222,7 +222,11 @@ pascal_printstr (struct ui_file *stream, struct type *type, unsigned int things_printed = 0; int in_quotes = 0; int need_comma = 0; - int width = TYPE_LENGTH (type); + int width; + + /* Preserve TYPE's original type, just set its LENGTH. */ + check_typedef (type); + width = TYPE_LENGTH (type); /* If the string was not truncated due to `set print elements', and the last byte of it is a null, we don't print that, in traditional C