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 29900395B0B3 for ; Tue, 12 May 2020 21:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 29900395B0B3 X-ASG-Debug-ID: 1589317755-0c856e18f31444b70001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id scvmnCQsTBbF97gF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:09:15 -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 98439441D68; Tue, 12 May 2020 17:09:15 -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: Tom Tromey Subject: [PATCH v2 04/42] Add dwarf2_per_objfile member to DWARF batons Date: Tue, 12 May 2020 17:08:35 -0400 X-ASG-Orig-Subj: [PATCH v2 04/42] Add dwarf2_per_objfile member to DWARF batons Message-Id: <20200512210913.5593-5-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: 1589317755 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: 10307 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=-30.3 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 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:09:19 -0000 From: Tom Tromey Various DWARF callbacks expect to be able to fetch the objfile and / or dwarf2_per_objfile from the DWARF CU object. However, this won't be possible once sharing is implemented. Because these objects are related to full symbols (e.g., they are used to implement location expressions), they can simply store the dwarf2_per_objfile they need. This patch adds a per_objfile member to the various "baton" structures and arranges to set this value when constructing the baton. YYYY-MM-DD Tom Tromey YYYY-MM-DD Simon Marchi * dwarf2/loc.c (struct piece_closure) : New member. (allocate_piece_closure): Set "per_objfile" member. (dwarf2_find_location_expression, dwarf2_locexpr_baton_eval) (locexpr_describe_location, loclist_describe_location): Use new member. * dwarf2/read.c (read_call_site_scope) (mark_common_block_symbol_computed, attr_to_dynamic_prop) (dwarf2_const_value_attr, dwarf2_fetch_die_loc_sect_off) (fill_in_loclist_baton, dwarf2_symbol_mark_computed): Set per_objfile member. * dwarf2/loc.h (struct dwarf2_locexpr_baton) : New member. (struct dwarf2_loclist_baton) : New member. --- gdb/dwarf2/loc.c | 16 ++++++++++++---- gdb/dwarf2/loc.h | 8 +++++++- gdb/dwarf2/read.c | 24 +++++++++++++++++------- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 5b690ca9276..e4a9ee90311 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -317,7 +317,8 @@ const gdb_byte * dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, size_t *locexpr_length, CORE_ADDR pc) { - struct objfile *objfile = baton->per_cu->objfile (); + dwarf2_per_objfile *per_objfile = baton->per_objfile; + struct objfile *objfile = per_objfile->objfile; struct gdbarch *gdbarch = objfile->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int addr_size = baton->per_cu->addr_size (); @@ -1552,6 +1553,9 @@ struct piece_closure /* Reference count. */ int refc = 0; + /* The objfile from which this closure's expression came. */ + dwarf2_per_objfile *per_objfile = nullptr; + /* The CU from which this closure's expression came. */ struct dwarf2_per_cu_data *per_cu = NULL; @@ -1574,6 +1578,8 @@ allocate_piece_closure (struct dwarf2_per_cu_data *per_cu, struct piece_closure *c = new piece_closure; c->refc = 1; + /* We must capture this here due to sharing of DWARF state. */ + c->per_objfile = per_cu->dwarf2_per_objfile; c->per_cu = per_cu; c->pieces = std::move (pieces); if (frame == NULL) @@ -2454,7 +2460,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, ctx.data_view = addr_stack->valaddr; } - objfile = dlbaton->per_cu->objfile (); + objfile = dlbaton->per_objfile->objfile; ctx.gdbarch = objfile->arch (); ctx.addr_size = dlbaton->per_cu->addr_size (); @@ -4348,7 +4354,8 @@ locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr, { struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol); - struct objfile *objfile = dlbaton->per_cu->objfile (); + dwarf2_per_objfile *per_objfile = dlbaton->per_objfile; + struct objfile *objfile = per_objfile->objfile; unsigned int addr_size = dlbaton->per_cu->addr_size (); int offset_size = dlbaton->per_cu->offset_size (); @@ -4485,7 +4492,8 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol); const gdb_byte *loc_ptr, *buf_end; - struct objfile *objfile = dlbaton->per_cu->objfile (); + dwarf2_per_objfile *per_objfile = dlbaton->per_objfile; + struct objfile *objfile = per_objfile->objfile; struct gdbarch *gdbarch = objfile->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int addr_size = dlbaton->per_cu->addr_size (); diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 9815368d625..51f242ec431 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -23,7 +23,7 @@ #include "dwarf2/expr.h" struct symbol_computed_ops; -struct objfile; +struct dwarf2_per_objfile; struct dwarf2_per_cu_data; struct dwarf2_loclist_baton; struct agent_expr; @@ -146,6 +146,9 @@ struct dwarf2_locexpr_baton directly. */ bool is_reference; + /* The objfile that was used when creating this. */ + dwarf2_per_objfile *per_objfile; + /* The compilation unit containing the symbol whose location we're computing. */ struct dwarf2_per_cu_data *per_cu; @@ -163,6 +166,9 @@ struct dwarf2_loclist_baton /* Length of the location list. */ size_t size; + /* The objfile that was used when creating this. */ + dwarf2_per_objfile *per_objfile; + /* The compilation unit containing the symbol whose location we're computing. */ struct dwarf2_per_cu_data *per_cu; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9217f784b38..4699645c6fc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13199,7 +13199,8 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) static void read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) { - struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; + dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile; + struct objfile *objfile = per_objfile->objfile; struct gdbarch *gdbarch = objfile->arch (); CORE_ADDR pc, baseaddr; struct attribute *attr; @@ -13339,6 +13340,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); dlbaton->data = DW_BLOCK (attr)->data; dlbaton->size = DW_BLOCK (attr)->size; + dlbaton->per_objfile = per_objfile; dlbaton->per_cu = cu->per_cu; SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton); @@ -16274,9 +16276,8 @@ mark_common_block_symbol_computed (struct symbol *sym, struct attribute *member_loc, struct dwarf2_cu *cu) { - struct dwarf2_per_objfile *dwarf2_per_objfile - = cu->per_cu->dwarf2_per_objfile; - struct objfile *objfile = dwarf2_per_objfile->objfile; + dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile; + struct objfile *objfile = per_objfile->objfile; struct dwarf2_locexpr_baton *baton; gdb_byte *ptr; unsigned int cu_off; @@ -16289,6 +16290,7 @@ mark_common_block_symbol_computed (struct symbol *sym, || member_loc->form_is_constant ()); baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); + baton->per_objfile = per_objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); @@ -17412,8 +17414,9 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, struct type *default_type) { struct dwarf2_property_baton *baton; - struct obstack *obstack - = &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack; + dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile; + struct objfile *objfile = per_objfile->objfile; + struct obstack *obstack = &objfile->objfile_obstack; gdb_assert (default_type != NULL); @@ -17425,6 +17428,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = default_type; baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.per_objfile = per_objfile; baton->locexpr.size = DW_BLOCK (attr)->size; baton->locexpr.data = DW_BLOCK (attr)->data; switch (attr->name) @@ -17471,6 +17475,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = die_type (target_die, target_cu); baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.per_objfile = per_objfile; baton->locexpr.size = DW_BLOCK (target_attr)->size; baton->locexpr.data = DW_BLOCK (target_attr)->data; baton->locexpr.is_reference = true; @@ -21028,7 +21033,8 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, LONGEST *value, const gdb_byte **bytes, struct dwarf2_locexpr_baton **baton) { - struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; + dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile; + struct objfile *objfile = per_objfile->objfile; struct comp_unit_head *cu_header = &cu->header; struct dwarf_block *blk; enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd) ? @@ -21054,6 +21060,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, piggyback on the existing location code rather than writing a new implementation of symbol_computed_ops. */ *baton = XOBNEW (obstack, struct dwarf2_locexpr_baton); + (*baton)->per_objfile = per_objfile; (*baton)->per_cu = cu->per_cu; gdb_assert ((*baton)->per_cu); @@ -22291,6 +22298,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, retval.data = DW_BLOCK (attr)->data; retval.size = DW_BLOCK (attr)->size; } + retval.per_objfile = dwarf2_per_objfile; retval.per_cu = cu->per_cu; age_cached_comp_units (dwarf2_per_objfile); @@ -23140,6 +23148,7 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, section->read (dwarf2_per_objfile->objfile); + baton->per_objfile = dwarf2_per_objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); /* We don't know how long the location list is, but make sure we @@ -23188,6 +23197,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, struct dwarf2_locexpr_baton *baton; baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); + baton->per_objfile = dwarf2_per_objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); -- 2.26.2