From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25712 invoked by alias); 9 Nov 2009 21:31:41 -0000 Received: (qmail 25702 invoked by uid 22791); 9 Nov 2009 21:31:40 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Nov 2009 21:31:37 +0000 Received: from zps78.corp.google.com (zps78.corp.google.com [172.25.146.78]) by smtp-out.google.com with ESMTP id nA9LVYuA024444 for ; Mon, 9 Nov 2009 13:31:35 -0800 Received: from pxi15 (pxi15.prod.google.com [10.243.27.15]) by zps78.corp.google.com with ESMTP id nA9LV5iJ006756 for ; Mon, 9 Nov 2009 13:31:32 -0800 Received: by pxi15 with SMTP id 15so2394415pxi.23 for ; Mon, 09 Nov 2009 13:31:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.143.25.38 with SMTP id c38mr860451wfj.253.1257802292349; Mon, 09 Nov 2009 13:31:32 -0800 (PST) Date: Mon, 09 Nov 2009 21:31:00 -0000 Message-ID: Subject: [patch] Fix "Cannot find DIE" error with -gdwarf-4 From: Cary Coutant To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true 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: 2009-11/txt/msg00187.txt.bz2 This patch fixes a problem in read_import_statement, where we get a "Cannot find DIE" error when trying to process a DW_AT_import attribute that refers to a DIE in a different CU. When finding the referenced DIE, the current code clobbers the CU parameter, but later calls determine_prefix(die, cu), assuming that CU is still the CU that contains DIE. I found this problem using -gdwarf-4 and DW_FORM_sig8, but I don't think this problem was introduced with the support for type units. The same problem could have occurred given a compiler that splits debug info into separate compilation units by include file, using DW_FORM_ref_addr to refer to a DIE in a different CU. OK for trunk? -cary * dwarf2read.c (read_import_statement): Don't clobber original cu. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.331 diff -u -p -r1.331 dwarf2read.c --- dwarf2read.c 5 Nov 2009 23:18:00 -0000 1.331 +++ dwarf2read.c 9 Nov 2009 21:15:57 -0000 @@ -3372,6 +3372,7 @@ read_import_statement (struct die_info * { struct attribute *import_attr; struct die_info *imported_die; + struct dwarf2_cu *imported_cu; const char *imported_name; const char *imported_name_prefix; const char *import_prefix; @@ -3385,8 +3386,9 @@ read_import_statement (struct die_info * return; } - imported_die = follow_die_ref_or_sig (die, import_attr, &cu); - imported_name = dwarf2_name (imported_die, cu); + imported_cu = cu; + imported_die = follow_die_ref_or_sig (die, import_attr, &imported_cu); + imported_name = dwarf2_name (imported_die, imported_cu); if (imported_name == NULL) { /* GCC bug: https://bugzilla.redhat.com/show_bug.cgi?id=506524 @@ -3431,7 +3433,7 @@ read_import_statement (struct die_info * /* Figure out what the scope of the imported die is and prepend it to the name of the imported die. */ - imported_name_prefix = determine_prefix (imported_die, cu); + imported_name_prefix = determine_prefix (imported_die, imported_cu); if (strlen (imported_name_prefix) > 0) {