From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34744 invoked by alias); 1 Apr 2018 00:04:57 -0000 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 Received: (qmail 34713 invoked by uid 89); 1 Apr 2018 00:04:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*MI:sk:2018040, dwz, CUs, cus X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Apr 2018 00:04:55 +0000 X-ASG-Debug-ID: 1522541087-0c856e618974ed90001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id XBrrZ494dYKLwwK8 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 31 Mar 2018 20:04:47 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 7D1E3441D67; Sat, 31 Mar 2018 20:04:47 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-164-54.qc.cable.ebox.net[192.222.164.54] X-Barracuda-Apparent-Source-IP: 192.222.164.54 X-Barracuda-RBL-IP: 192.222.164.54 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/5] Remove some usages of get_dwarf2_per_objfile Date: Sun, 01 Apr 2018 00:04:00 -0000 X-ASG-Orig-Subj: [PATCH 3/5] Remove some usages of get_dwarf2_per_objfile Message-Id: <20180401000444.13490-4-simon.marchi@polymtl.ca> In-Reply-To: <20180401000444.13490-1-simon.marchi@polymtl.ca> References: <20180401000444.13490-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1522541087 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 6807 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.49475 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00002.txt.bz2 This patch removes some usages of get_dwarf2_per_objfile, where we can get hold of the dwarf2_per_objfile object in a simpler way. For example, it's simpler (and slightly less work) to pass dwarf2_per_objfile and get the objfile from it than to pass the objfile and call get_dwarf2_per_objfile. Ideally, get_dwarf2_per_objfile should only be used in the entry points of the dwarf2 code, where we receive an objfile. gdb/ChangeLog: * dwarf2read.c (create_cus_from_index_list): Replace objfile arg with dwarf2_per_objfile. (create_cus_from_index): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dwarf2_initialize_objfile): Likewise. (dwarf2_fetch_die_loc_sect_off): Get dwarf2_per_objfile from per_cu rather than get_dwarf2_per_objfile. --- gdb/dwarf2read.c | 60 +++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 695799e96f4f..9b77fcfda179 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2978,17 +2978,13 @@ create_cu_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile, CUs. */ static void -create_cus_from_index_list (struct objfile *objfile, +create_cus_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile, const gdb_byte *cu_list, offset_type n_elements, struct dwarf2_section_info *section, int is_dwz, int base_offset) { - offset_type i; - struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); - - for (i = 0; i < n_elements; i += 2) + for (offset_type i = 0; i < n_elements; i += 2) { gdb_static_assert (sizeof (ULONGEST) >= 8); @@ -3007,42 +3003,38 @@ create_cus_from_index_list (struct objfile *objfile, the CU objects for this objfile. */ static void -create_cus_from_index (struct objfile *objfile, +create_cus_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile, const gdb_byte *cu_list, offset_type cu_list_elements, const gdb_byte *dwz_list, offset_type dwz_elements) { - struct dwz_file *dwz; - struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); + struct objfile *objfile = dwarf2_per_objfile->objfile; dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2; dwarf2_per_objfile->all_comp_units = XOBNEWVEC (&objfile->objfile_obstack, struct dwarf2_per_cu_data *, dwarf2_per_objfile->n_comp_units); - create_cus_from_index_list (objfile, cu_list, cu_list_elements, + create_cus_from_index_list (dwarf2_per_objfile, cu_list, cu_list_elements, &dwarf2_per_objfile->info, 0, 0); if (dwz_elements == 0) return; - dwz = dwarf2_get_dwz_file (dwarf2_per_objfile); - create_cus_from_index_list (objfile, dwz_list, dwz_elements, &dwz->info, 1, - cu_list_elements / 2); + dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile); + create_cus_from_index_list (dwarf2_per_objfile, dwz_list, dwz_elements, + &dwz->info, 1, cu_list_elements / 2); } /* Create the signatured type hash table from the index. */ static void -create_signatured_type_table_from_index (struct objfile *objfile, - struct dwarf2_section_info *section, - const gdb_byte *bytes, - offset_type elements) +create_signatured_type_table_from_index + (struct dwarf2_per_objfile *dwarf2_per_objfile, + struct dwarf2_section_info *section, + const gdb_byte *bytes, + offset_type elements) { - offset_type i; - htab_t sig_types_hash; - struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); + struct objfile *objfile = dwarf2_per_objfile->objfile; dwarf2_per_objfile->n_type_units = dwarf2_per_objfile->n_allocated_type_units @@ -3050,9 +3042,9 @@ create_signatured_type_table_from_index (struct objfile *objfile, dwarf2_per_objfile->all_type_units = XNEWVEC (struct signatured_type *, dwarf2_per_objfile->n_type_units); - sig_types_hash = allocate_signatured_type_table (objfile); + htab_t sig_types_hash = allocate_signatured_type_table (objfile); - for (i = 0; i < elements; i += 3) + for (offset_type i = 0; i < elements; i += 3) { struct signatured_type *sig_type; ULONGEST signature; @@ -3559,14 +3551,13 @@ to use the section anyway."), elements of all the CUs and return 1. Otherwise, return 0. */ static int -dwarf2_read_index (struct objfile *objfile) +dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) { struct mapped_index local_map, *map; const gdb_byte *cu_list, *types_list, *dwz_list = NULL; offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; struct dwz_file *dwz; - struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); + struct objfile *objfile = dwarf2_per_objfile->objfile; if (!read_index_from_section (objfile, objfile_name (objfile), use_deprecated_index_sections, @@ -3601,8 +3592,8 @@ dwarf2_read_index (struct objfile *objfile) } } - create_cus_from_index (objfile, cu_list, cu_list_elements, dwz_list, - dwz_list_elements); + create_cus_from_index (dwarf2_per_objfile, cu_list, cu_list_elements, + dwz_list, dwz_list_elements); if (types_list_elements) { @@ -3616,8 +3607,8 @@ dwarf2_read_index (struct objfile *objfile) section = VEC_index (dwarf2_section_info_def, dwarf2_per_objfile->types, 0); - create_signatured_type_table_from_index (objfile, section, types_list, - types_list_elements); + create_signatured_type_table_from_index (dwarf2_per_objfile, section, + types_list, types_list_elements); } create_addrmap_from_index (dwarf2_per_objfile, &local_map); @@ -6259,7 +6250,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) return true; } - if (dwarf2_read_index (objfile)) + if (dwarf2_read_index (dwarf2_per_objfile)) { *index_kind = dw_index_kind::GDB_INDEX; return true; @@ -22927,9 +22918,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, struct die_info *die; struct attribute *attr; struct dwarf2_locexpr_baton retval; - struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; - struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); + struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile; + struct objfile *objfile = dwarf2_per_objfile->objfile; if (per_cu->cu == NULL) load_cu (per_cu); -- 2.16.3