From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id B0CD8395CCB4 for ; Tue, 12 May 2020 21:15:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B0CD8395CCB4 X-ASG-Debug-ID: 1589318118-0c856e18f31444e20001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id lAo1yFd4c3XEaa4u (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:15:18 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 83AF2441D64; Tue, 12 May 2020 17:15:18 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 X-Barracuda-RBL-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 28/42] Remove dwarf2_per_cu_data::objfile () Date: Tue, 12 May 2020 17:12:36 -0400 X-ASG-Orig-Subj: [PATCH v2 28/42] Remove dwarf2_per_cu_data::objfile () Message-Id: <20200512211250.6230-29-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512210913.5593-1-simon.marchi@efficios.com> References: <20200512210913.5593-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1589318118 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: 18364 X-Virus-Scanned: by bsmtpd at ebox.ca 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.81805 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-15.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 21:15:21 -0000 Since dwarf2_per_cu_data objects are going to become objfile-independent, the backlink from dwarf2_per_cu_data to one particular objfile must be removed. Instead, users of dwarf2_per_cu_data that need an objfile must know from somewhere else in the context of which objfile they are using this CU. This also helps remove a dwarf2_per_cu_data::dwarf2_per_objfile reference (from where the objfile was obtained). Note that the dwarf2_per_cu_data::objfile method has a special case to make sure to return the main objfile, if the objfile associated to the dwarf2_per_cu_data is a separate debug objfile. I don't really know if this is necessary: I ignored that, and didn't see any regression when testing with the various Dejagnu boards with separate debug info, so I presume it wasn't needed. If it turns out this was needed, then we can have a helper method on the objfile type for that. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_cu_data) : Remove. * dwarf2/read.c (dwarf2_compute_name): Pass per_objfile down. (read_call_site_scope): Assign per_objfile. (dwarf2_per_cu_data::objfile): Remove. * gdbtypes.h (struct call_site) : New member. * dwarf2/loc.h (dwarf2_evaluate_loc_desc): Add dwarf2_per_objfile parameter. * dwarf2/loc.c (dwarf2_evaluate_loc_desc_full): Add dwarf2_per_objfile parameter. (dwarf_expr_reg_to_entry_parameter): Add output dwarf2_per_objfile parameter. (locexpr_get_frame_base): Update. (class dwarf_evaluate_loc_desc) : Update. : Update. : Update. (dwarf_entry_parameter_to_value): Add dwarf2_per_objfile parameter. (value_of_dwarf_reg_entry): Update. (rw_pieced_value): Update. (indirect_synthetic_pointer): Update. (dwarf2_evaluate_property): Update. (dwarf2_loc_desc_get_symbol_read_needs): Add dwarf2_per_objfile parameter. (locexpr_read_variable): Update. (locexpr_get_symbol_read_needs): Update. (loclist_read_variable): Update. --- gdb/dwarf2/loc.c | 94 ++++++++++++++++++++++++++--------------------- gdb/dwarf2/loc.h | 3 +- gdb/dwarf2/read.c | 19 ++-------- gdb/dwarf2/read.h | 5 --- gdb/gdbtypes.h | 8 +++- 5 files changed, 65 insertions(+), 64 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index c1ccbda8235..a4b7edf7bff 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -47,19 +47,17 @@ #include "gdbsupport/underlying.h" #include "gdbsupport/byte-vector.h" -static struct value *dwarf2_evaluate_loc_desc_full (struct type *type, - struct frame_info *frame, - const gdb_byte *data, - size_t size, - struct dwarf2_per_cu_data *per_cu, - struct type *subobj_type, - LONGEST subobj_byte_offset); +static struct value *dwarf2_evaluate_loc_desc_full + (struct type *type, struct frame_info *frame, const gdb_byte *data, + size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, + struct type *subobj_type, LONGEST subobj_byte_offset); static struct call_site_parameter *dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, - struct dwarf2_per_cu_data **per_cu_return); + dwarf2_per_cu_data **per_cu_return, + dwarf2_per_objfile **per_objfile_return); static struct value *indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, @@ -476,7 +474,7 @@ locexpr_get_frame_base (struct symbol *framefunc, struct frame_info *frame) SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location (framefunc, get_frame_pc (frame), &start, &length); result = dwarf2_evaluate_loc_desc (type, frame, start, length, - dlbaton->per_cu); + dlbaton->per_cu, dlbaton->per_objfile); /* The DW_AT_frame_base attribute contains a location description which computes the base address itself. However, the call to @@ -533,7 +531,7 @@ loclist_get_frame_base (struct symbol *framefunc, struct frame_info *frame) SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location (framefunc, get_frame_pc (frame), &start, &length); result = dwarf2_evaluate_loc_desc (type, frame, start, length, - dlbaton->per_cu); + dlbaton->per_cu, dlbaton->per_objfile); /* The DW_AT_frame_base attribute contains a location description which computes the base address itself. However, the call to @@ -654,9 +652,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context current thread's thread-local storage with offset OFFSET. */ CORE_ADDR get_tls_address (CORE_ADDR offset) override { - struct objfile *objfile = per_cu->objfile (); - - return target_translate_tls_address (objfile, offset); + return target_translate_tls_address (per_objfile->objfile, offset); } /* Helper interface of per_cu_dwarf_call for @@ -716,7 +712,8 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context int deref_size) override { struct frame_info *caller_frame; - struct dwarf2_per_cu_data *caller_per_cu; + dwarf2_per_cu_data *caller_per_cu; + dwarf2_per_objfile *caller_per_objfile; struct call_site_parameter *parameter; const gdb_byte *data_src; size_t size; @@ -724,10 +721,13 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context caller_frame = get_prev_frame (frame); parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu); + &caller_per_cu, + &caller_per_objfile); data_src = deref_size == -1 ? parameter->value : parameter->data_value; size = deref_size == -1 ? parameter->value_size : parameter->data_value_size; + gdb_assert (this->per_objfile == caller_per_objfile); + /* DEREF_SIZE size is not verified here. */ if (data_src == NULL) throw_error (NO_ENTRY_VALUE_ERROR, @@ -741,7 +741,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context (CORE_ADDR) 0); scoped_restore save_arch = make_scoped_restore (&this->gdbarch); - this->gdbarch = per_cu->objfile ()->arch (); + this->gdbarch = this->per_objfile->objfile->arch (); scoped_restore save_addr_size = make_scoped_restore (&this->addr_size); this->addr_size = per_cu->addr_size (); @@ -869,7 +869,8 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, caller_core_addr_type = builtin_type (caller_arch)->builtin_func_ptr; val = dwarf2_evaluate_loc_desc (caller_core_addr_type, caller_frame, dwarf_block->data, dwarf_block->size, - dwarf_block->per_cu); + dwarf_block->per_cu, + dwarf_block->per_objfile); /* DW_AT_call_target is a DWARF expression, not a DWARF location. */ if (VALUE_LVAL (val) == lval_memory) return value_address (val); @@ -1290,7 +1291,8 @@ static struct call_site_parameter * dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, - struct dwarf2_per_cu_data **per_cu_return) + dwarf2_per_cu_data **per_cu_return, + dwarf2_per_objfile **per_objfile_return) { CORE_ADDR func_addr, caller_pc; struct gdbarch *gdbarch; @@ -1381,6 +1383,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, } *per_cu_return = call_site->per_cu; + *per_objfile_return = call_site->per_objfile; return parameter; } @@ -1398,7 +1401,8 @@ static struct value * dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, CORE_ADDR deref_size, struct type *type, struct frame_info *caller_frame, - struct dwarf2_per_cu_data *per_cu) + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile) { const gdb_byte *data_src; gdb_byte *data; @@ -1419,7 +1423,8 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, memcpy (data, data_src, size); data[size] = DW_OP_stack_value; - return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu); + return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu, + per_objfile); } /* VALUE must be of type lval_computed with entry_data_value_funcs. Perform @@ -1493,14 +1498,17 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, struct frame_info *caller_frame = get_prev_frame (frame); struct value *outer_val, *target_val, *val; struct call_site_parameter *parameter; - struct dwarf2_per_cu_data *caller_per_cu; + dwarf2_per_cu_data *caller_per_cu; + dwarf2_per_objfile *caller_per_objfile; parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu); + &caller_per_cu, + &caller_per_objfile); outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, type, caller_frame, - caller_per_cu); + caller_per_cu, + caller_per_objfile); /* Check if DW_AT_call_data_value cannot be used. If it should be used and it is not available do not fall back to OUTER_VAL - dereferencing @@ -1514,7 +1522,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, target_val = dwarf_entry_parameter_to_value (parameter, TYPE_LENGTH (target_type), target_type, caller_frame, - caller_per_cu); + caller_per_cu, + caller_per_objfile); val = allocate_computed_value (type, &entry_data_value_funcs, release_value (target_val).release ()); @@ -1831,8 +1840,7 @@ rw_pieced_value (struct value *v, struct value *from) break; } - struct objfile *objfile = c->per_cu->objfile (); - struct gdbarch *objfile_gdbarch = objfile->arch (); + gdbarch *objfile_gdbarch = c->per_objfile->objfile->arch (); ULONGEST stack_value_size_bits = 8 * TYPE_LENGTH (value_type (p->v.value)); @@ -2023,6 +2031,7 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, if (baton.data != NULL) return dwarf2_evaluate_loc_desc_full (orig_type, frame, baton.data, baton.size, baton.per_cu, + baton.per_objfile, TYPE_TARGET_TYPE (type), byte_offset); else @@ -2187,12 +2196,12 @@ static const struct lval_funcs pieced_value_funcs = { static struct value * dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, const gdb_byte *data, size_t size, - struct dwarf2_per_cu_data *per_cu, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, struct type *subobj_type, LONGEST subobj_byte_offset) { struct value *retval; - struct objfile *objfile = per_cu->objfile (); if (subobj_type == NULL) { @@ -2205,7 +2214,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, if (size == 0) return allocate_optimized_out_value (subobj_type); - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); dwarf_evaluate_loc_desc ctx (per_objfile); ctx.frame = frame; ctx.per_cu = per_cu; @@ -2213,7 +2221,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, scoped_value_mark free_values; - ctx.gdbarch = objfile->arch (); + ctx.gdbarch = per_objfile->objfile->arch (); ctx.addr_size = per_cu->addr_size (); ctx.ref_addr_size = per_cu->ref_addr_size (); @@ -2336,7 +2344,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, size_t n = TYPE_LENGTH (value_type (value)); size_t len = TYPE_LENGTH (subobj_type); size_t max = TYPE_LENGTH (type); - struct gdbarch *objfile_gdbarch = objfile->arch (); + gdbarch *objfile_gdbarch = per_objfile->objfile->arch (); if (subobj_byte_offset + len > max) invalid_synthetic_pointer (); @@ -2399,10 +2407,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, struct value * dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, const gdb_byte *data, size_t size, - struct dwarf2_per_cu_data *per_cu) + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile) { return dwarf2_evaluate_loc_desc_full (type, frame, data, size, per_cu, - NULL, 0); + per_objfile, NULL, 0); } /* A specialization of dwarf_evaluate_loc_desc that is used by @@ -2603,7 +2612,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, if (data != NULL) { val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data, - size, baton->loclist.per_cu); + size, baton->loclist.per_cu, + baton->loclist.per_objfile); if (!value_optimized_out (val)) { *value = value_as_address (val); @@ -2806,18 +2816,18 @@ class symbol_needs_eval_context : public dwarf_expr_context static enum symbol_needs_kind dwarf2_loc_desc_get_symbol_read_needs (const gdb_byte *data, size_t size, - struct dwarf2_per_cu_data *per_cu) + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile) { int in_reg; - struct objfile *objfile = per_cu->objfile (); scoped_value_mark free_values; - symbol_needs_eval_context ctx (get_dwarf2_per_objfile (objfile)); + symbol_needs_eval_context ctx (per_objfile); ctx.needs = SYMBOL_NEEDS_NONE; ctx.per_cu = per_cu; - ctx.gdbarch = objfile->arch (); + ctx.gdbarch = per_objfile->objfile->arch (); ctx.addr_size = per_cu->addr_size (); ctx.ref_addr_size = per_cu->ref_addr_size (); @@ -3641,7 +3651,8 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame) struct value *val; val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data, - dlbaton->size, dlbaton->per_cu); + dlbaton->size, dlbaton->per_cu, + dlbaton->per_objfile); return val; } @@ -3670,7 +3681,8 @@ locexpr_get_symbol_read_needs (struct symbol *symbol) = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol); return dwarf2_loc_desc_get_symbol_read_needs (dlbaton->data, dlbaton->size, - dlbaton->per_cu); + dlbaton->per_cu, + dlbaton->per_objfile); } /* Return true if DATA points to the end of a piece. END is one past @@ -4460,7 +4472,7 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame) data = dwarf2_find_location_expression (dlbaton, &size, pc); val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, data, size, - dlbaton->per_cu); + dlbaton->per_cu, dlbaton->per_objfile); return val; } diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 51f242ec431..907455b72c1 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -61,7 +61,8 @@ struct value *dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, const gdb_byte *data, size_t size, - struct dwarf2_per_cu_data *per_cu); + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile); /* A chain of addresses that might be needed to resolve a dynamic property. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d221d0148c0..63449cf2c6f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10316,7 +10316,8 @@ dwarf2_compute_name (const char *name, v = dwarf2_evaluate_loc_desc (type, NULL, baton->data, baton->size, - baton->per_cu); + baton->per_cu, + baton->per_objfile); else if (bytes != NULL) { v = allocate_value (type); @@ -13460,6 +13461,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) sect_offset_str (die->sect_off), objfile_name (objfile)); call_site->per_cu = cu->per_cu; + call_site->per_objfile = per_objfile; for (child_die = die->child; child_die && child_die->tag; @@ -23277,21 +23279,6 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, } } -/* See read.h. */ - -struct objfile * -dwarf2_per_cu_data::objfile () const -{ - struct objfile *objfile = dwarf2_per_objfile->objfile; - - /* Return the master objfile, so that we can report and look up the - correct file containing this variable. */ - if (objfile->separate_debug_objfile_backlink) - objfile = objfile->separate_debug_objfile_backlink; - - return objfile; -} - /* Return comp_unit_head for PER_CU, either already available in PER_CU->CU (CU_HEADERP is unused in such case) or prepare a temporary copy at CU_HEADERP first. */ diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index c6d236b4778..dda5ed71c4d 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -491,11 +491,6 @@ struct dwarf2_per_cu_data imported_symtabs = nullptr; } - /* Return the OBJFILE associated with this compilation unit. If - this compilation unit came from a separate debuginfo file, then - the master objfile is returned. */ - struct objfile *objfile () const; - /* Return the address size given in the compilation unit header for this CU. */ int addr_size () const; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 7514bd27f7c..c8338f38495 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -58,6 +58,8 @@ struct field; struct block; struct value_print_options; struct language_defn; +struct dwarf2_per_cu_data; +struct dwarf2_per_objfile; /* These declarations are DWARF-specific as some of the gdbtypes.h data types are already DWARF-specific. */ @@ -1333,7 +1335,11 @@ struct call_site /* * CU of the function where the call is located. It gets used for DWARF blocks execution in the parameter array below. */ - struct dwarf2_per_cu_data *per_cu; + dwarf2_per_cu_data *per_cu; + + /* objfile of the function where the call is located. */ + + dwarf2_per_objfile *per_objfile; /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */ -- 2.26.2