From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0bBKKmudgWnKYCUAWB0awg (envelope-from ) for ; Tue, 03 Feb 2026 02:02:03 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=DR7ZdCOz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AA6DE1E0BA; Tue, 03 Feb 2026 02:02:03 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,RDNS_NONE autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (unknown [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DF97C1E089 for ; Tue, 03 Feb 2026 02:01:59 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6AE214BA2E3D for ; Tue, 3 Feb 2026 07:01:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AE214BA2E3D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=DR7ZdCOz Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 0F5B64BA2E0B for ; Tue, 3 Feb 2026 07:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F5B64BA2E0B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0F5B64BA2E0B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770102059; cv=none; b=b07/2edLkAWLAwy/1OC1A+C1N4qECqFCeWXnr3dcJ2HSBBxjKl65HBsqk6i9BWnxplS8XzHKKSdT1qKw0Cs27/RG4ySP6kGHpzMNLPR1JCDaTeFPnTkPyONf3c9Ka/ImpiRq2/UqCG28m4QTVuWNZ+DZHNI4AxDIaJL+kDsI4cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770102059; c=relaxed/simple; bh=H31hwGrC0QWInOr9judrOkAO6SAr3fyf3TSXqXzFvVM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UAkIK9MV82d9S05UhKyhHwMcnXhBCznAGlVywprOyrqaOaGFaC1UKdV+5lwTidZQHda6oDP9wx75zZvY8WjqyS6ku20Y5VvW5Ru8ihxfZnjJ5FH329BK/QjdL5g+0xyPu+X8Lf8HbgPtyi9A9ODQhFcbW6zFQ1x3Ep5vLdFZACs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F5B64BA2E0B Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 61370o5f181543 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 3 Feb 2026 02:00:55 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61370o5f181543 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1770102055; bh=Ehw0/waG8A4tzxzdiygnY8oqN+mpsYI7svrzqyTLrws=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=DR7ZdCOzSyF017gk4gTgSXE5RoSfexEUvdKUKnHI9475YdkHmijW2tZSSM+DJZr9V hKa0oVIsASFA6Wy5u5UvQFT7navjAOKVvpfOCpPoHS3GmjviBho19VWnwlKWQ94niD gLQ2wffhPfZTW5dhqVyPMWZefarTcg0Fyz3PYHMXH9OS+02o6aqAFvQmvbGjWYH/z7 xc5Q+ae6F7pLoxDK8TO2XXXrPn0e+rYYHzInWrQVxVj8tsSEEe9TE1R369yMTSlO3P mn9s1pXx2kVmvZD9p7hzXNMrLxB+gMDARPISHm8EzvgXs2IkzldFj37cbBEYpyEuar akLHVqekjs26g== Received: by simark.ca (Postfix) id 51E241E0E7; Tue, 03 Feb 2026 01:54:38 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Nick Alcock , Weimin Pan , Simon Marchi Subject: [RFC PATCH 4/8] gdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context Date: Tue, 3 Feb 2026 01:45:45 -0500 Message-ID: <20260203065435.3092465-5-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203065435.3092465-1-simon.marchi@polymtl.ca> References: <20260203065435.3092465-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 3 Feb 2026 07:00:50 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi This patch slightly reorganizes the data structures in ctfread.c to be a bit more like in the DWARF reader. That is, instead of duplicating the information (for instance, the objfile pointer), keep the information once in the most general object where in make sense (in the ctf_per_objfile in this case) and have the more specific objects (like ctf_context, ctf_archive_iter_psymtab_data) have a link to the more general object. Concretely, that means removing the archive and parent_dict fields from ctf_archive_iter_psymtab_data and ctf_context (those are per-objfile information), adding backlink to the ctf_per_objfile and using the parent_dict and archive fields there. Similarly, remove the objfile fields from these and add a new objfile field in ctf_per_objfile. Remove the objfile and dict parameters from the ctf_psymtab_add_stt_* functions, since they can be obtained from the other parameters. No functional changes expected. Change-Id: I837264eece869f2bb962842998dede8cd7806bfe --- gdb/ctfread.c | 188 ++++++++++++++++++++++++-------------------------- 1 file changed, 90 insertions(+), 98 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 5106af621dab..b2557ac31717 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -147,11 +147,16 @@ using ctf_dict_up = std::unique_ptr; struct ctf_per_objfile { - explicit ctf_per_objfile (ctf_archive_up archive, ctf_dict_up dict) - : archive (std::move (archive)), + explicit ctf_per_objfile (struct objfile *objfile, ctf_archive_up archive, + ctf_dict_up dict) + : objfile (objfile), + archive (std::move (archive)), parent_dict (std::move (dict)) {} + /* Backlink to objfile. */ + struct objfile *objfile; + /* Map from IDs to types. */ ctf_type_map type_map; @@ -162,15 +167,14 @@ struct ctf_per_objfile static const registry::key ctf_per_objfile_key; -/* A CTF context consists of a file pointer and an objfile pointer. */ +/* Data passed around when creating symtabs. */ struct ctf_context { + ctf_per_objfile *per_objfile; ctf_dict_t *dict; - struct objfile *objfile; psymtab_storage *partial_symtabs; partial_symtab *pst; - ctf_archive_t *arc; struct buildsym_compunit *builder; }; @@ -224,9 +228,7 @@ struct ctf_field_info struct ctf_archive_iter_psymtab_data { - ctf_dict_t *parent_dict; - struct objfile *objfile; - ctf_archive_t *archive; + ctf_per_objfile *per_objfile; psymbol_functions *psf; }; @@ -287,7 +289,7 @@ get_tid_type (struct objfile *objfile, ctf_id_t tid) static struct type * fetch_tid_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + struct objfile *objfile = ccp->per_objfile->objfile; struct type *typ; typ = get_tid_type (objfile, tid); @@ -404,9 +406,10 @@ ctf_add_member_cb (const char *name, t = read_type_record (ccp, tid); if (t == nullptr) { + objfile *objfile = ccp->per_objfile->objfile; complaint (_("ctf_add_member_cb: %s has NO type (%ld)"), name, tid); - t = builtin_type (ccp->objfile)->builtin_error; - set_tid_type (ccp->objfile, tid, t); + t = builtin_type (objfile)->builtin_error; + set_tid_type (objfile, tid, t); } } @@ -441,11 +444,12 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg) if (name != nullptr && *name != '\0') { - struct symbol *sym = new (&ccp->objfile->objfile_obstack) symbol; - OBJSTAT (ccp->objfile, n_syms++); + objfile *objfile = ccp->per_objfile->objfile; + struct symbol *sym = new (&objfile->objfile_obstack) symbol; + OBJSTAT (objfile, n_syms++); - sym->set_language (language_c, &ccp->objfile->objfile_obstack); - sym->compute_and_set_names (name, false, ccp->objfile->per_bfd); + sym->set_language (language_c, &objfile->objfile_obstack); + sym->compute_and_set_names (name, false, objfile->per_bfd); sym->set_loc_class_index (LOC_CONST); sym->set_domain (VAR_DOMAIN); sym->set_type (fip->ptype); @@ -468,7 +472,7 @@ new_type_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) const char *name = ctf_type_name_raw (dict, tid); if (name != nullptr && *name != '\0') { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; struct symbol *sym = new (&objfile->objfile_obstack) symbol; OBJSTAT (objfile, n_syms++); @@ -500,7 +504,7 @@ new_type_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) static struct type * read_base_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; ctf_encoding_t cet; struct type *type = nullptr; @@ -594,7 +598,7 @@ process_base_type (struct ctf_context *ccp, ctf_id_t tid) static struct type * read_structure_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *type; uint32_t kind; @@ -614,7 +618,7 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid) type->set_length (ctf_type_size (dict, tid)); set_type_align (type, ctf_type_align (dict, tid)); - return set_tid_type (ccp->objfile, tid, type); + return set_tid_type (objfile, tid, type); } /* Given a tid of CTF_K_STRUCT or CTF_K_UNION, process all its members @@ -652,7 +656,7 @@ process_structure_type (struct ctf_context *ccp, ctf_id_t tid) static struct type * read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *type, *rettype, *atype; ctf_funcinfo_t cfi; @@ -705,7 +709,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) static struct type * read_enum_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *type; @@ -769,7 +773,7 @@ add_array_cv_type (struct ctf_context *ccp, voltl |= TYPE_VOLATILE (el_type); inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); - return set_tid_type (ccp->objfile, tid, base_type); + return set_tid_type (ccp->per_objfile->objfile, tid, base_type); } /* Read all information from a TID of CTF_K_ARRAY. */ @@ -777,7 +781,7 @@ add_array_cv_type (struct ctf_context *ccp, static struct type * read_array_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *element_type, *range_type, *idx_type; struct type *type; @@ -820,7 +824,7 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) static struct type * read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; struct type *base_type, *cv_type; base_type = fetch_tid_type (ccp, btid); @@ -843,7 +847,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) static struct type * read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *base_type, *cv_type; @@ -870,7 +874,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) static struct type * read_restrict_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; struct type *base_type, *cv_type; base_type = fetch_tid_type (ccp, btid); @@ -894,7 +898,7 @@ static struct type * read_typedef_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid, const char *name) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; struct type *this_type, *target_type; char *aname = obstack_strdup (&objfile->objfile_obstack, name); @@ -917,7 +921,7 @@ read_typedef_type (struct ctf_context *ccp, ctf_id_t tid, static struct type * read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; struct type *target_type, *type; target_type = fetch_tid_type (ccp, btid); @@ -927,7 +931,7 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (target_type == nullptr) { complaint (_("read_pointer_type: NULL target type (%ld)"), btid); - target_type = builtin_type (ccp->objfile)->builtin_error; + target_type = builtin_type (objfile)->builtin_error; } } @@ -942,7 +946,7 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) static struct type * read_forward_type (struct ctf_context *ccp, ctf_id_t tid) { - struct objfile *objfile = ccp->objfile; + objfile *objfile = ccp->per_objfile->objfile; ctf_dict_t *dict = ccp->dict; struct type *type; uint32_t kind; @@ -1040,7 +1044,7 @@ ctf_add_type_cb (ctf_id_t tid, void *arg) uint32_t kind; /* Check if tid's type has already been defined. */ - type = get_tid_type (ccp->objfile, tid); + type = get_tid_type (ccp->per_objfile->objfile, tid); if (type != nullptr) { ctf_debug_printf ("tid=%ld already defined, skipping", tid); @@ -1112,8 +1116,9 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) struct symbol *sym = nullptr; struct type *type; uint32_t kind; + objfile *objfile = ccp->per_objfile->objfile; - type = get_tid_type (ccp->objfile, id); + type = get_tid_type (objfile, id); kind = ctf_type_kind (ccp->dict, id); @@ -1123,25 +1128,25 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) if (type == nullptr) { complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id); - type = builtin_type (ccp->objfile)->builtin_error; + type = builtin_type (objfile)->builtin_error; } - sym = new (&ccp->objfile->objfile_obstack) symbol; - OBJSTAT (ccp->objfile, n_syms++); + sym = new (&objfile->objfile_obstack) symbol; + OBJSTAT (objfile, n_syms++); sym->set_type (type); sym->set_loc_class_index (LOC_OPTIMIZED_OUT); - sym->compute_and_set_names (name, false, ccp->objfile->per_bfd); + sym->compute_and_set_names (name, false, objfile->per_bfd); if (kind == CTF_K_FUNCTION) { sym->set_domain (FUNCTION_DOMAIN); if (name != nullptr && strcmp (name, "main") == 0) - set_objfile_main_name (ccp->objfile, name, language_c); + set_objfile_main_name (objfile, name, language_c); } else sym->set_domain (VAR_DOMAIN); add_symbol_to_list (sym, ccp->builder->get_global_symbols ()); - set_symbol_address (ccp->objfile, sym, name); + set_symbol_address (objfile, sym, name); return 0; } @@ -1160,25 +1165,26 @@ add_stt_entries (struct ctf_context *ccp, int functions) while ((tid = ctf_symbol_next (ccp->dict, &i, &tname, functions)) != CTF_ERR) { - type = get_tid_type (ccp->objfile, tid); + objfile *objfile = ccp->per_objfile->objfile; + type = get_tid_type (objfile, tid); if (type == nullptr) { - ctf_debug_printf ("skipping '%s' tid=0x%lx (no type found)", - tname, tid); + ctf_debug_printf ("skipping '%s' tid=0x%lx (no type found)", tname, + tid); continue; } ctf_debug_printf ("adding %s '%s' tid=0x%lx", functions ? "function" : "object", tname, tid); - sym = new (&ccp->objfile->objfile_obstack) symbol; - OBJSTAT (ccp->objfile, n_syms++); + sym = new (&objfile->objfile_obstack) symbol; + OBJSTAT (objfile, n_syms++); sym->set_type (type); sym->set_domain (functions ? FUNCTION_DOMAIN : VAR_DOMAIN); sym->set_loc_class_index (LOC_STATIC); - sym->compute_and_set_names (tname, false, ccp->objfile->per_bfd); + sym->compute_and_set_names (tname, false, objfile->per_bfd); add_symbol_to_list (sym, ccp->builder->get_global_symbols ()); - set_symbol_address (ccp->objfile, sym, tname); + set_symbol_address (objfile, sym, tname); } } @@ -1222,11 +1228,10 @@ ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid) while ((ename = ctf_enum_next (ccp->dict, tid, &i, &val)) != nullptr) { - ccp->pst->add_psymbol (ename, true, - VAR_DOMAIN, LOC_CONST, -1, - psymbol_placement::GLOBAL, - unrelocated_addr (0), - language_c, ccp->partial_symtabs, ccp->objfile); + ccp->pst->add_psymbol (ename, true, VAR_DOMAIN, LOC_CONST, -1, + psymbol_placement::GLOBAL, unrelocated_addr (0), + language_c, ccp->partial_symtabs, + ccp->per_objfile->objfile); } if (ctf_errno (ccp->dict) != ECTF_NEXT_END) complaint (_("ctf_enum_next ctf_psymtab_add_enums failed - %s"), @@ -1237,8 +1242,7 @@ ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid) by FUNCTIONS, to psymtab. */ static void -ctf_psymtab_add_stt_entries (ctf_dict_t *dict, ctf_psymtab *pst, - struct objfile *objfile, int functions) +ctf_psymtab_add_stt_entries (ctf_dict_t *dict, ctf_psymtab *pst, int functions) { ctf_next_t *i = nullptr; ctf_id_t tid; @@ -1259,30 +1263,27 @@ ctf_psymtab_add_stt_entries (ctf_dict_t *dict, ctf_psymtab *pst, functions ? "function" : "object", tname, tid, ctf_kind_str (kind)); - pst->add_psymbol (tname, true, - tdomain, loc_class, -1, - psymbol_placement::GLOBAL, - unrelocated_addr (0), - language_c, pst->context.partial_symtabs, objfile); + pst->add_psymbol (tname, true, tdomain, loc_class, -1, + psymbol_placement::GLOBAL, unrelocated_addr (0), + language_c, pst->context.partial_symtabs, + pst->context.per_objfile->objfile); } } /* Add entries in data objects section to psymtab. */ static void -ctf_psymtab_add_stt_obj (ctf_dict_t *dict, ctf_psymtab *pst, - struct objfile *objfile) +ctf_psymtab_add_stt_obj (ctf_dict_t *dict, ctf_psymtab *pst) { - ctf_psymtab_add_stt_entries (dict, pst, objfile, 0); + ctf_psymtab_add_stt_entries (dict, pst, 0); } /* Add entries in function info section to psymtab. */ static void -ctf_psymtab_add_stt_func (ctf_dict_t *dict, ctf_psymtab *pst, - struct objfile *objfile) +ctf_psymtab_add_stt_func (ctf_dict_t *dict, ctf_psymtab *pst) { - ctf_psymtab_add_stt_entries (dict, pst, objfile, 1); + ctf_psymtab_add_stt_entries (dict, pst, 1); } /* Read in full symbols for PST, and anything it depends on. */ @@ -1375,19 +1376,17 @@ ctf_psymtab::read_symtab (struct objfile *objfile) static ctf_psymtab * create_partial_symtab (const char *name, - ctf_archive_t *arc, ctf_dict_t *dict, psymtab_storage *partial_symtabs, - struct objfile *objfile) + ctf_per_objfile *per_objfile) { ctf_psymtab *pst; - pst = new ctf_psymtab (name, partial_symtabs, objfile->per_bfd, + pst = new ctf_psymtab (name, partial_symtabs, per_objfile->objfile->per_bfd, unrelocated_addr (0)); - pst->context.arc = arc; + pst->context.per_objfile = per_objfile; pst->context.dict = dict; - pst->context.objfile = objfile; pst->context.partial_symtabs = partial_symtabs; pst->context.pst = pst; pst->context.builder = nullptr; @@ -1443,11 +1442,10 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg) ctf_debug_printf ("adding type tid=0x%lx kind=%s name='%s'", tid, ctf_kind_str (kind), name); - ccp->pst->add_psymbol (name, false, - domain, loc_class, section, - psymbol_placement::GLOBAL, - unrelocated_addr (0), - language_c, ccp->partial_symtabs, ccp->objfile); + ccp->pst->add_psymbol (name, false, domain, loc_class, section, + psymbol_placement::GLOBAL, unrelocated_addr (0), + language_c, ccp->partial_symtabs, + ccp->per_objfile->objfile); return 0; } @@ -1465,13 +1463,10 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg) name, id, ctf_kind_str (kind)); ccp->pst->add_psymbol (name, true, - kind == CTF_K_FUNCTION - ? FUNCTION_DOMAIN - : VAR_DOMAIN, - LOC_STATIC, -1, - psymbol_placement::GLOBAL, - unrelocated_addr (0), - language_c, ccp->partial_symtabs, ccp->objfile); + kind == CTF_K_FUNCTION ? FUNCTION_DOMAIN : VAR_DOMAIN, + LOC_STATIC, -1, psymbol_placement::GLOBAL, + unrelocated_addr (0), language_c, + ccp->partial_symtabs, ccp->per_objfile->objfile); return 0; } @@ -1480,10 +1475,9 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg) static void scan_partial_symbols (ctf_dict_t *dict, psymtab_storage *partial_symtabs, - ctf_archive_iter_psymtab_data *iter_data, - const char *fname) + ctf_per_objfile *per_objfile, const char *fname) { - objfile *objfile = iter_data->objfile; + objfile *objfile = per_objfile->objfile; bool isparent = false; CTF_SCOPED_DEBUG_START_END ("fname='%s'", fname); @@ -1495,8 +1489,8 @@ scan_partial_symbols (ctf_dict_t *dict, psymtab_storage *partial_symtabs, ctf_debug_printf ("is parent, using fname='%s'", fname); } - ctf_psymtab *pst = create_partial_symtab (fname, iter_data->archive, dict, - partial_symtabs, objfile); + ctf_psymtab *pst = create_partial_symtab (fname, dict, partial_symtabs, + per_objfile); struct ctf_context *ccx = &pst->context; if (isparent == false) @@ -1513,8 +1507,8 @@ scan_partial_symbols (ctf_dict_t *dict, psymtab_storage *partial_symtabs, /* Scan CTF object and function sections which correspond to each STT_FUNC or STT_OBJECT entry in the symbol table, pick up what init_symtab has done. */ - ctf_psymtab_add_stt_obj (dict, pst, objfile); - ctf_psymtab_add_stt_func (dict, pst, objfile); + ctf_psymtab_add_stt_obj (dict, pst); + ctf_psymtab_add_stt_func (dict, pst); pst->end (); } @@ -1525,9 +1519,10 @@ static int build_ctf_archive_member (ctf_dict_t *dict, const char *name, void *arg) { auto iter_data = static_cast (arg); + ctf_per_objfile *per_objfile = iter_data->per_objfile; if (strcmp (name, ".ctf") != 0) - ctf_import (dict, iter_data->parent_dict); + ctf_import (dict, per_objfile->parent_dict.get ()); if (info_verbose) { @@ -1536,7 +1531,7 @@ build_ctf_archive_member (ctf_dict_t *dict, const char *name, void *arg) } psymtab_storage *pss = iter_data->psf->get_partial_symtabs ().get (); - scan_partial_symbols (dict, pss, iter_data, name); + scan_partial_symbols (dict, pss, per_objfile, name); return 0; } @@ -1565,19 +1560,16 @@ elfctf_build_psymtabs (objfile *objfile) bfd_get_filename (abfd), ctf_errmsg (err)); ctf_per_objfile *per_objfile - = ctf_per_objfile_key.emplace (objfile, std::move (archive), + = ctf_per_objfile_key.emplace (objfile, objfile, std::move (archive), std::move (dict)); - - ctf_archive_iter_psymtab_data iter_data; - iter_data.parent_dict = per_objfile->parent_dict.get (); - iter_data.objfile = objfile; - iter_data.archive = per_objfile->archive.get (); - psymbol_functions *psf = new psymbol_functions (); + objfile->qf.emplace_front (psf); - iter_data.psf = psf; - if (ctf_archive_iter (iter_data.archive, build_ctf_archive_member, &iter_data) + ctf_archive_iter_psymtab_data iter_data { per_objfile, psf }; + + if (ctf_archive_iter (per_objfile->archive.get (), build_ctf_archive_member, + &iter_data) < 0) error (_("ctf_archive_iter failed in input file %s: - %s"), bfd_get_filename (abfd), ctf_errmsg (err)); -- 2.52.0