From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27034 invoked by alias); 9 Apr 2012 17:46:33 -0000 Received: (qmail 27025 invoked by uid 22791); 9 Apr 2012 17:46:32 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-gx0-f201.google.com (HELO mail-gx0-f201.google.com) (209.85.161.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Apr 2012 17:46:13 +0000 Received: by ggki24 with SMTP id i24so496894ggk.0 for ; Mon, 09 Apr 2012 10:46:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=kJFjRRRUdxmFqMJUuVW/gqRzSDygnvKb5Ly/eArPUto=; b=cgLAwzVqatylHfNIel1GIC5LmLQuVvyma7ZEPCIDGpFFA7mYr5lD3FBGe9u6kKB2/i uTtxRob9rA4Flx8Glk97yxYg5d4bbAWuD1rLDZArEZOVLGBA/+k2wlrM3kbxEryV063R NjBjs9UZZkvIeRKTozwMP6rXI/0IqZeCK0i0tlVJDNzFjKBfF8O06egaib12vhz/lq97 Z/6pQadQi9mdJZSk/usoX7x45P2bskWjF58CinrHbCuZ6wO04wFdXFdX2I9K6r2dEnIZ W35rcgq5xvUopnu9y381hLUFH1QxylGjcNGLz47rWsiEuM81Ms9gKuzbxFPc6vrV2QXJ oXfw== Received: by 10.101.180.28 with SMTP id h28mr3272590anp.24.1333993572904; Mon, 09 Apr 2012 10:46:12 -0700 (PDT) Received: by 10.101.180.28 with SMTP id h28mr3272581anp.24.1333993572762; Mon, 09 Apr 2012 10:46:12 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id k54si15441481yhh.5.2012.04.09.10.46.12 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 09 Apr 2012 10:46:12 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.110.50]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 9550F1E004D for ; Mon, 9 Apr 2012 10:46:12 -0700 (PDT) Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 1F60824618E; Mon, 9 Apr 2012 10:46:12 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [patch] find_partial_die cleanups Message-Id: <20120409174612.1F60824618E@ruffy.mtv.corp.google.com> Date: Mon, 09 Apr 2012 17:46:00 -0000 From: dje@google.com (Doug Evans) X-Gm-Message-State: ALoCoQkG77ksDdxFVCJOoKUC0NO1ayi2vGtxKxL+Gl4gH7/8GF8W0nXbfUZgGmUGY5jxq7eGVIgizcw/Fq99TmRSjeaXUoiZTKMzKthhWzDqoy+E7A+AHRbPXeOuaPBE1SPvmapjYEOVrvup01JaZYKFFBu2ou9N7fHz8bHwySx3wJWYeL6gnsw= 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: 2012-04/txt/msg00151.txt.bz2 Hi. I have more radical changes queued up for Fission, ref: http://gcc.gnu.org/wiki/DebugFission but I want to check in some preliminary changes so that there's a better base to review the patches from, plus make some general improvements along the way. This patch is standalone, and so I'm not submitting it as part of a set. I will check this in in a few days if there are no objections. Regression tested on amd64-linux, with this patch applied to exercise the if (pd == NULL && per_cu->load_all_dies == 0) code path, ref: http://sourceware.org/bugzilla/show_bug.cgi?id=13961 diff -u -p -r1.628 dwarf2read.c --- dwarf2read.c 7 Apr 2012 19:35:17 -0000 1.628 +++ dwarf2read.c 9 Apr 2012 16:01:55 -0000 @@ -9722,11 +9721,11 @@ load_partial_dies (bfd *abfd, gdb_byte * unit with load_all_dies set. */ if (load_all - || abbrev->tag == DW_TAG_constant + /*|| abbrev->tag == DW_TAG_constant || abbrev->tag == DW_TAG_subprogram || abbrev->tag == DW_TAG_variable || abbrev->tag == DW_TAG_namespace - || part_die->is_declaration) + || part_die->is_declaration*/) { void **slot; 2012-04-09 Doug Evans * dwarf2read.c (dwarf2_per_cu_data). Clarify comment. (load_partial_dies): Clarify comment. (find_partial_die): Support rereading type units. Clarify CU handling, if we know offset is in CU, don't search for the containing CU. Add comment regarding memory waste. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.628 diff -u -p -r1.628 dwarf2read.c --- dwarf2read.c 7 Apr 2012 19:35:17 -0000 1.628 +++ dwarf2read.c 9 Apr 2012 16:08:58 -0000 @@ -415,9 +415,9 @@ struct dwarf2_per_cu_data any of the current compilation units are processed. */ unsigned int queued : 1; - /* This flag will be set if we need to load absolutely all DIEs - for this compilation unit, instead of just the ones we think - are interesting. It gets set if we look for a DIE in the + /* This flag will be set when reading partial DIEs if we need to load + absolutely all DIEs for this compilation unit, instead of just the ones + we think are interesting. It gets set if we look for a DIE in the hash table and don't find it. */ unsigned int load_all_dies : 1; @@ -9516,7 +9516,6 @@ load_partial_dies (bfd *abfd, gdb_byte * struct abbrev_info *abbrev; unsigned int bytes_read; unsigned int load_all = 0; - int nesting_level = 1; parent_die = NULL; @@ -9579,7 +9578,7 @@ load_partial_dies (bfd *abfd, gdb_byte * } } - /* We only recurse into subprograms looking for template arguments. + /* We only recurse into c++ subprograms looking for template arguments. Skip their other children. */ if (!load_all && cu->language == language_cplus @@ -9996,28 +9995,33 @@ find_partial_die (sect_offset offset, st struct dwarf2_per_cu_data *per_cu = NULL; struct partial_die_info *pd = NULL; - if (cu->per_cu->debug_types_section) - { - pd = find_partial_die_in_comp_unit (offset, cu); - if (pd != NULL) - return pd; - goto not_found; - } - if (offset_in_cu_p (&cu->header, offset)) { pd = find_partial_die_in_comp_unit (offset, cu); if (pd != NULL) return pd; + /* We missed recording what we needed. + Load all dies and try again. */ + per_cu = cu->per_cu; } + else + { + /* TUs don't reference other CUs/TUs (except via type signatures). */ + if (cu->per_cu->debug_types_section) + { + error (_("Dwarf Error: Type Unit at offset 0x%lx contains" + " external reference to offset 0x%lx [in module %s].\n"), + (long) cu->header.offset.sect_off, (long) offset.sect_off, + bfd_get_filename (objfile->obfd)); + } + per_cu = dwarf2_find_containing_comp_unit (offset, objfile); - per_cu = dwarf2_find_containing_comp_unit (offset, objfile); - - if (per_cu->cu == NULL || per_cu->cu->partial_dies == NULL) - load_partial_comp_unit (per_cu); + if (per_cu->cu == NULL || per_cu->cu->partial_dies == NULL) + load_partial_comp_unit (per_cu); - per_cu->cu->last_used = 0; - pd = find_partial_die_in_comp_unit (offset, per_cu->cu); + per_cu->cu->last_used = 0; + pd = find_partial_die_in_comp_unit (offset, per_cu->cu); + } if (pd == NULL && per_cu->load_all_dies == 0) { @@ -10026,28 +10030,34 @@ find_partial_die (sect_offset offset, st struct abbrev_info *abbrev; unsigned int bytes_read; char *info_ptr; + struct dwarf2_section_info* sec; per_cu->load_all_dies = 1; - /* Re-read the DIEs. */ + if (per_cu->debug_types_section) + sec = per_cu->debug_types_section; + else + sec = &dwarf2_per_objfile->info; + + /* Re-read the DIEs, this time reading all of them. + NOTE: We don't discard the previous set of DIEs. + This doesn't happen very often so it's (hopefully) not a problem. */ back_to = make_cleanup (null_cleanup, 0); if (per_cu->cu->dwarf2_abbrevs == NULL) { dwarf2_read_abbrevs (per_cu->cu); make_cleanup (dwarf2_free_abbrev_table, per_cu->cu); } - info_ptr = (dwarf2_per_objfile->info.buffer + info_ptr = (sec->buffer + per_cu->cu->header.offset.sect_off + per_cu->cu->header.first_die_offset.cu_off); abbrev = peek_die_abbrev (info_ptr, &bytes_read, per_cu->cu); info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read, - objfile->obfd, - dwarf2_per_objfile->info.buffer, info_ptr, + objfile->obfd, sec->buffer, info_ptr, per_cu->cu); if (comp_unit_die.has_children) - load_partial_dies (objfile->obfd, - dwarf2_per_objfile->info.buffer, info_ptr, - 0, per_cu->cu); + load_partial_dies (objfile->obfd, sec->buffer, info_ptr, 0, + per_cu->cu); do_cleanups (back_to); pd = find_partial_die_in_comp_unit (offset, per_cu->cu);