From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20591 invoked by alias); 4 Mar 2010 22:00:04 -0000 Received: (qmail 20513 invoked by uid 22791); 4 Mar 2010 22:00:02 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS 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; Thu, 04 Mar 2010 21:59:56 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o24Lxtba020860 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Mar 2010 16:59:55 -0500 Received: from ns3.rdu.redhat.com ([10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o24LxsFt026773; Thu, 4 Mar 2010 16:59:54 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o24LxrKo004907; Thu, 4 Mar 2010 16:59:53 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 17D1F3798F1; Thu, 4 Mar 2010 14:59:53 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: DW_FORM_ref_addr -vs- DWARF 3 Reply-To: tromey@redhat.com Date: Thu, 04 Mar 2010 22:00:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-03/txt/msg00219.txt.bz2 I'm checking this in. I will probably push it into 7.1 as well; let me know what you think of this. DWARF 3 changed DW_FORM_ref_addr to use an offset-sized value instead of an address-sized value. GDB does not cope with this, which can cause crashes. For a real-life example: https://bugzilla.redhat.com/show_bug.cgi?id=552619 I found this in the archives, after writing my patch: http://sourceware.org/ml/gdb-patches/2006-06/msg00286.html I guess it was never reviewed? I dunno. Anyway, I prefer my patch. Built and regression tested on x86-64 (compile farm). I also verified it before- and after- on the test program I have. Tom 2010-03-04 Tom Tromey * dwarf2read.c (skip_one_die) : Use offset size in DWARF 3 and later. (read_attribute_value) : Likewise. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a05c946..b2558f0 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2881,8 +2881,15 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr, skip_attribute: switch (form) { - case DW_FORM_addr: case DW_FORM_ref_addr: + /* In DWARF 2, DW_FORM_ref_addr is address sized; in DWARF 3 + and later it is offset sized. */ + if (cu->header.version == 2) + info_ptr += cu->header.addr_size; + else + info_ptr += cu->header.offset_size; + break; + case DW_FORM_addr: info_ptr += cu->header.addr_size; break; case DW_FORM_data1: @@ -7016,8 +7023,14 @@ read_attribute_value (struct attribute *attr, unsigned form, attr->form = form; switch (form) { - case DW_FORM_addr: case DW_FORM_ref_addr: + if (cu->header.version == 2) + DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read); + else + DW_ADDR (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read); + info_ptr += bytes_read; + break; + case DW_FORM_addr: DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read); info_ptr += bytes_read; break;