From patchwork Thu May 15 17:58:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 949 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 6E97736006F for ; Thu, 15 May 2014 10:58:11 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 3410941E3381C; Thu, 15 May 2014 10:58:11 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 1482C41DC3DE4 for ; Thu, 15 May 2014 10:58:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:cc:date:message-id :mime-version:content-type; q=dns; s=default; b=Poj3Z23HpTRMvnD4 9nPjHXvMo5Ya/UGP7Emug6o+ycC8oryOTKaUgdtQr03U2ioXQhteZZ2TARoEA2zm 7mW2nlgubL90lmrLxre0YJTDU/KsLh2fm0qolSIP7/gvqwoKM77oS93crueSVv2s 6NPEtg279+XRJPO3YhprY7xvOHw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:cc:date:message-id :mime-version:content-type; s=default; bh=/ozSl/G2EnW3xxODsAtE41 Z1ufA=; b=RACpHm+WKNhcUiZupryYmevSgzZ7RVryNr6JlBWg+bwR9hipQ4CzwF RFivs2/RKLZFQii3OscOLFeceT8kDNiz3eMrl2i6EBF8z8IxB2eMRtfjIqsnX7Yf lSwSFUejXIBGRg0mWybJFqbbUYEHcFuUaB1ZbE8RwjY5VuXywufeM= Received: (qmail 12722 invoked by alias); 15 May 2014 17:58:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 12712 invoked by uid 89); 15 May 2014 17:58:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f201.google.com Received: from mail-ie0-f201.google.com (HELO mail-ie0-f201.google.com) (209.85.223.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 15 May 2014 17:58:07 +0000 Received: by mail-ie0-f201.google.com with SMTP id rp18so298117iec.4 for ; Thu, 15 May 2014 10:58:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:cc:date:message-id:mime-version :content-type; bh=U9RBuVT2AblAbdmvNMbWqwc3OqrKnQpU+1pWXZEa6iM=; b=d1UWClnMQoiAaY+dEyOGx+Q/jM1hqe8JuSTDJi/v7XGTrEkyuDwKUw5SLX5cyC3nYc fOb7ne6Y1tz9rVWtcgjBR/2S5IAzG1T9UiH7+Uobq2SFS9UEbCblpPhy3LZ0fwmXkq9R uB+mMYvzUqL3QNrFUOYrOzn4W22PfmCrr7Gr/Dqwkup2TF64yVGWMOknaqOpaE5YJJAu j3q9ETa5Oz1qCeNtJTaxeoYZo2ANgnIip2ueodWh09H8zx9rQi/2JEBGyuEt3Xm6QCCf u4FcVi7cqiR2x9tF7pf0YYF+bYx9prdT/zbEIT82oqKY6hNdl67OdszAQBIVCOW8SIn7 /ayQ== X-Gm-Message-State: ALoCoQnZxx1Fo6yzP7keORyjBRwEcPwlYqNIkiHn9D6MkytBm4ijjQK5MKYEuK372OIs7GnNSz7J X-Received: by 10.50.108.47 with SMTP id hh15mr6075897igb.3.1400176685317; Thu, 15 May 2014 10:58:05 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id k43si276753yhq.3.2014.05.15.10.58.05 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 May 2014 10:58:05 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id BB1A231C239; Thu, 15 May 2014 10:58:04 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] dwarf2read.c type unit groups cleanup cc: ccoutant@google.com Date: Thu, 15 May 2014 10:58:04 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi. This patch removes some no longer used members of dwarf2_per_objfile, and does a few other simple cleanups. There's a few more cleanups that can be done on top of this, but I'm leaving them for a separate pass. I have another patch coming that adds support for skeleton-less type units (Fission), and this is preparatory work for that. Regression tested on amd64-linux. 2014-05-15 Doug Evans * dwarf2read.c (struct dwarf2_per_objfile): Delete unused members n_type_unit_groups, all_type_unit_groups. All uses removed. (get_type_unit_group, build_type_unit_groups): Delete forward decls. (dw2_get_cutu): Renamed from dw2_get_cu. All callers updated. (dw2_get_cu): Renamed from dw2_get_primary_cu. All callers updated. (add_type_unit_group_to_table): Delete. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index bf1e3d0..dfa2caf 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -239,13 +239,6 @@ struct dwarf2_per_objfile This is stored in malloc space because we may realloc it. */ struct signatured_type **all_type_units; - /* The number of entries in all_type_unit_groups. */ - int n_type_unit_groups; - - /* Table of type unit groups. - This exists to make it easy to iterate over all CUs and TU groups. */ - struct type_unit_group **all_type_unit_groups; - /* Table of struct type_unit_group objects. The hash key is the DW_AT_stmt_list value. */ htab_t type_unit_groups; @@ -1715,11 +1708,6 @@ static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu); static void read_signatured_type (struct signatured_type *); -static struct type_unit_group *get_type_unit_group - (struct dwarf2_cu *, const struct attribute *); - -static void build_type_unit_groups (die_reader_func_ftype *, void *); - /* memory allocation interface */ static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *); @@ -2673,21 +2661,21 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu) return per_cu->v.quick->symtab; } -/* Return the CU given its index. +/* Return the CU/TU given its index. This is intended for loops like: for (i = 0; i < (dwarf2_per_objfile->n_comp_units + dwarf2_per_objfile->n_type_units); ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); ...; } */ static struct dwarf2_per_cu_data * -dw2_get_cu (int index) +dw2_get_cutu (int index) { if (index >= dwarf2_per_objfile->n_comp_units) { @@ -2699,30 +2687,14 @@ dw2_get_cu (int index) return dwarf2_per_objfile->all_comp_units[index]; } -/* Return the primary CU given its index. - The difference between this function and dw2_get_cu is in the handling - of type units (TUs). Here we return the type_unit_group object. - - This is intended for loops like: - - for (i = 0; i < (dwarf2_per_objfile->n_comp_units - + dwarf2_per_objfile->n_type_unit_groups); ++i) - { - struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i); - - ...; - } -*/ +/* Return the CU given its index. + This differs from dw2_get_cutu in that it's for when you know INDEX + refers to a CU. */ static struct dwarf2_per_cu_data * -dw2_get_primary_cu (int index) +dw2_get_cu (int index) { - if (index >= dwarf2_per_objfile->n_comp_units) - { - index -= dwarf2_per_objfile->n_comp_units; - gdb_assert (index < dwarf2_per_objfile->n_type_unit_groups); - return &dwarf2_per_objfile->all_type_unit_groups[index]->per_cu; - } + gdb_assert (index >= 0 && index < dwarf2_per_objfile->n_comp_units); return dwarf2_per_objfile->all_comp_units[index]; } @@ -2889,7 +2861,7 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index) } addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1, - dw2_get_cu (cu_index)); + dw2_get_cutu (cu_index)); } objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map, @@ -3333,7 +3305,7 @@ dw2_find_last_source_symtab (struct objfile *objfile) dw2_setup (objfile); index = dwarf2_per_objfile->n_comp_units - 1; - return dw2_instantiate_symtab (dw2_get_cu (index)); + return dw2_instantiate_symtab (dw2_get_cutu (index)); } /* Traversal function for dw2_forget_cached_source_info. */ @@ -3409,7 +3381,7 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name, for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { int j; - struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); struct quick_file_names *file_data; /* We only need to look at symtabs not already expanded. */ @@ -3557,7 +3529,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter) continue; } - per_cu = dw2_get_cu (cu_index); + per_cu = dw2_get_cutu (cu_index); /* Skip if already read in. */ if (per_cu->v.quick->symtab) @@ -3668,7 +3640,7 @@ dw2_print_stats (struct objfile *objfile) count = 0; for (i = 0; i < total; ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); if (!per_cu->v.quick->symtab) ++count; @@ -3741,7 +3713,7 @@ dw2_expand_all_symtabs (struct objfile *objfile) for (i = 0; i < (dwarf2_per_objfile->n_comp_units + dwarf2_per_objfile->n_type_units); ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); dw2_instantiate_symtab (per_cu); } @@ -3763,7 +3735,7 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile, for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { int j; - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); struct quick_file_names *file_data; /* We only need to look at symtabs not already expanded. */ @@ -3840,7 +3812,7 @@ dw2_expand_symtabs_matching for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { int j; - struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); struct quick_file_names *file_data; void **slot; @@ -3975,7 +3947,7 @@ dw2_expand_symtabs_matching continue; } - per_cu = dw2_get_cu (cu_index); + per_cu = dw2_get_cutu (cu_index); if (file_matcher == NULL || per_cu->v.quick->mark) dw2_instantiate_symtab (per_cu); } @@ -4055,7 +4027,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun, for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); if (per_cu->v.quick->symtab) { @@ -4069,7 +4041,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun, for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { int j; - struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); struct quick_file_names *file_data; void **slot; @@ -4152,7 +4124,7 @@ dwarf2_initialize_objfile (struct objfile *objfile) for (i = 0; i < (dwarf2_per_objfile->n_comp_units + dwarf2_per_objfile->n_type_units); ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); per_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwarf2_per_cu_quick_data); @@ -5781,20 +5753,6 @@ sort_tu_by_abbrev_offset (const void *ap, const void *bp) return (aoff > boff) - (aoff < boff); } -/* A helper function to add a type_unit_group to a table. */ - -static int -add_type_unit_group_to_table (void **slot, void *datum) -{ - struct type_unit_group *tu_group = *slot; - struct type_unit_group ***datap = datum; - - **datap = tu_group; - ++*datap; - - return 1; -} - /* Efficiently read all the type units, calling init_cutu_and_read_dies on each one passing FUNC,DATA. @@ -5910,23 +5868,8 @@ build_type_unit_groups (die_reader_func_ftype *func, void *data) { dwarf2_per_objfile->type_unit_groups = allocate_type_unit_groups_table (); - dwarf2_per_objfile->n_type_unit_groups = 0; } - /* Create a vector of pointers to primary type units to make it easy to - iterate over them and CUs. See dw2_get_primary_cu. */ - dwarf2_per_objfile->n_type_unit_groups = - htab_elements (dwarf2_per_objfile->type_unit_groups); - dwarf2_per_objfile->all_type_unit_groups = - obstack_alloc (&objfile->objfile_obstack, - dwarf2_per_objfile->n_type_unit_groups - * sizeof (struct type_unit_group *)); - iter = &dwarf2_per_objfile->all_type_unit_groups[0]; - htab_traverse_noresize (dwarf2_per_objfile->type_unit_groups, - add_type_unit_group_to_table, &iter); - gdb_assert (iter - &dwarf2_per_objfile->all_type_unit_groups[0] - == dwarf2_per_objfile->n_type_unit_groups); - do_cleanups (cleanups); if (dwarf2_read_debug) @@ -6269,7 +6212,7 @@ set_partial_user (struct objfile *objfile) for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); struct partial_symtab *pst = per_cu->v.psymtab; int j; @@ -6322,7 +6265,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile) for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); + struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i); process_psymtab_comp_unit (per_cu, 0, language_minimal); }