From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yE4ZAn/n82EjewAAWB0awg (envelope-from ) for ; Fri, 28 Jan 2022 07:54:23 -0500 Received: by simark.ca (Postfix, from userid 112) id 065B31F3B7; Fri, 28 Jan 2022 07:54:23 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 00ACE1EE18 for ; Fri, 28 Jan 2022 07:54:22 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EE5D3947429 for ; Fri, 28 Jan 2022 12:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EE5D3947429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643374461; bh=h1/IhKf4vSM9LYguexlN41AjSJo8Sw2qa1ylg0Jeb38=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R2NViMigdGd9nIr9czaMc41+2U8ubvw4FETljlPagCyX/wiXHaqcywYvuvbZeVTBt 1uJuF+wZIAlhtQi+PcPUhYdhjPdIEjsRFolSzNYH3JCH04k8R1ajhaVLpTozJLGUl4 gJUMT46jNgsJTKKMFRvj4qi+TlgzWFZ3QuMvXjxw= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 5D6893947C27 for ; Fri, 28 Jan 2022 12:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D6893947C27 X-ASG-Debug-ID: 1643374172-0c856e06ab271c70001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id bqiHOz5SD2MVbsf5 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 Jan 2022 07:49:33 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id DC706441B21; Fri, 28 Jan 2022 07:49:32 -0500 (EST) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT macro, add getter/setter Date: Fri, 28 Jan 2022 07:45:14 -0500 X-ASG-Orig-Subj: [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT macro, add getter/setter Message-Id: <20220128124531.2302941-17-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128124531.2302941-1-simon.marchi@polymtl.ca> References: <20220128124531.2302941-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1643374173 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 11372 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.95629 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" From: Simon Marchi Add a getter and a setter for a symtab's compunit_symtab. Remove the corresponding macro and adjust all callers. For brevity, I chose the name "compunit" instead of "compunit_symtab" the the field, getter and setter names. Since we are already in symtab context, the _symtab suffix seems redundant. Change-Id: I4b9b731c96e3594f7733e75af1e3d01bc0e4fe92 --- gdb/amd64-tdep.c | 4 ++-- gdb/breakpoint.c | 2 +- gdb/macroscope.c | 3 ++- gdb/mdebugread.c | 2 +- gdb/mi/mi-cmd-file.c | 2 +- gdb/or1k-tdep.c | 2 +- gdb/python/py-symtab.c | 2 +- gdb/source.c | 6 +++--- gdb/symfile.c | 2 +- gdb/symmisc.c | 10 +++++----- gdb/symtab.c | 6 +++--- gdb/symtab.h | 21 +++++++++++++++------ gdb/z80-tdep.c | 2 +- 13 files changed, 37 insertions(+), 27 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 4444187515fb..b95ab1e87b81 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2474,8 +2474,8 @@ amd64_skip_xmm_prologue (CORE_ADDR pc, CORE_ADDR start_pc) start_pc_sal = find_pc_sect_line (start_pc, NULL, 0); if (start_pc_sal.symtab == NULL - || producer_is_gcc_ge_4 (SYMTAB_COMPUNIT - (start_pc_sal.symtab)->producer ()) < 6 + || producer_is_gcc_ge_4 (start_pc_sal.symtab->compunit () + ->producer ()) < 6 || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end) return pc; diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9567c737cabf..96a2b46dfc25 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9230,7 +9230,7 @@ resolve_sal_pc (struct symtab_and_line *sal) struct symbol *sym; bv = blockvector_for_pc_sect (sal->pc, 0, &b, - SYMTAB_COMPUNIT (sal->symtab)); + sal->symtab->compunit ()); if (bv != NULL) { sym = block_linkage_function (b); diff --git a/gdb/macroscope.c b/gdb/macroscope.c index c581c426eda0..93f561acccd8 100644 --- a/gdb/macroscope.c +++ b/gdb/macroscope.c @@ -43,7 +43,8 @@ sal_macro_scope (struct symtab_and_line sal) if (sal.symtab == NULL) return NULL; - cust = SYMTAB_COMPUNIT (sal.symtab); + + cust = sal.symtab->compunit (); if (cust->macro_table () == NULL) return NULL; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 59b70389531a..a6a70ccfea93 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4502,7 +4502,7 @@ add_block (struct block *b, struct symtab *s) + BLOCKVECTOR_NBLOCKS (bv) * sizeof (bv->block))); if (bv != SYMTAB_BLOCKVECTOR (s)) - SYMTAB_COMPUNIT (s)->set_blockvector (bv); + s->compunit ()->set_blockvector (bv); BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b; } diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index f4ee791f17b5..0ed7bed82e23 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -59,7 +59,7 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc) uiout->field_string ("fullname", symtab_to_fullname (st.symtab)); uiout->field_signed ("macro-info", - SYMTAB_COMPUNIT (st.symtab)->macro_table () != NULL); + st.symtab->compunit ()->macro_table () != NULL); } /* Implement -file-list-exec-source-files command. */ diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 5670a623024f..2787609d4f80 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -471,7 +471,7 @@ or1k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) { struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0); struct compunit_symtab *compunit - = SYMTAB_COMPUNIT (prologue_sal.symtab); + = prologue_sal.symtab->compunit (); const char *debug_format = compunit->debugformat (); if ((NULL != debug_format) diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index b973b25f1587..b5d102c1b7f1 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -131,7 +131,7 @@ stpy_get_producer (PyObject *self, void *closure) struct compunit_symtab *cust; STPY_REQUIRE_VALID (self, symtab); - cust = SYMTAB_COMPUNIT (symtab); + cust = symtab->compunit (); if (cust->producer () != nullptr) { const char *producer = cust->producer (); diff --git a/gdb/source.c b/gdb/source.c index e6ba44819413..ee896264277f 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -711,7 +711,7 @@ info_source_command (const char *ignore, int from_tty) return; } - cust = SYMTAB_COMPUNIT (s); + cust = s->compunit (); printf_filtered (_("Current source file is %s\n"), s->filename); if (SYMTAB_DIRNAME (s) != NULL) printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s)); @@ -1184,9 +1184,9 @@ open_source_file (struct symtab *s) if (fd.get () < 0) { - if (SYMTAB_COMPUNIT (s) != nullptr) + if (s->compunit () != nullptr) { - const objfile *ofp = SYMTAB_COMPUNIT (s)->objfile (); + const objfile *ofp = s->compunit ()->objfile (); std::string srcpath; if (IS_ABSOLUTE_PATH (s->filename)) diff --git a/gdb/symfile.c b/gdb/symfile.c index b20284cad988..46c42014a9f6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2807,7 +2807,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename) cust->add_filetab (symtab); /* Backlink to the containing compunit symtab. */ - symtab->compunit_symtab = cust; + symtab->set_compunit (cust); return symtab; } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 6e1a4c2e8341..d079ac460ee8 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -329,7 +329,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) } else { - compunit_symtab *compunit = SYMTAB_COMPUNIT (symtab); + compunit_symtab *compunit = symtab->compunit (); const char *compunit_filename = symtab_to_filename_for_display (compunit->primary_filetab ()); @@ -342,7 +342,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) compunit_symtabs included by this one. */ if (is_main_symtab_of_compunit_symtab (symtab)) { - struct compunit_symtab *cust = SYMTAB_COMPUNIT (symtab); + struct compunit_symtab *cust = symtab->compunit (); if (cust->user != nullptr) { @@ -956,14 +956,14 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data) struct linetable *linetable; struct objfile *objfile; - objfile = symtab->compunit_symtab->objfile (); + objfile = symtab->compunit ()->objfile (); printf_filtered (_("objfile: %ps ((struct objfile *) %s)\n"), styled_string (file_name_style.style (), objfile_name (objfile)), host_address_to_string (objfile)); printf_filtered (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"), - symtab->compunit_symtab->name, - host_address_to_string (symtab->compunit_symtab)); + symtab->compunit ()->name, + host_address_to_string (symtab->compunit ())); printf_filtered (_("symtab: %ps ((struct symtab *) %s)\n"), styled_string (file_name_style.style (), symtab_to_fullname (symtab)), diff --git a/gdb/symtab.c b/gdb/symtab.c index 5ad5cdbe3a3a..459c0c3c7487 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3709,7 +3709,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section, symtab_and_line sal = find_pc_sect_line (func_addr, section, 0); if (funfirstline && sal.symtab != NULL - && (SYMTAB_COMPUNIT (sal.symtab)->locations_valid () + && (sal.symtab->compunit ()->locations_valid () || SYMTAB_LANGUAGE (sal.symtab) == language_asm)) { struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); @@ -3885,7 +3885,7 @@ skip_prologue_sal (struct symtab_and_line *sal) have proven the CU (Compilation Unit) supports it. sal->SYMTAB does not have to be set by the caller so we use SYM instead. */ if (sym != NULL - && SYMTAB_COMPUNIT (symbol_symtab (sym))->locations_valid ()) + && symbol_symtab (sym)->compunit ()->locations_valid ()) force_skip = 0; saved_pc = pc; @@ -6095,7 +6095,7 @@ collect_file_symbol_completion_matches (completion_tracker &tracker, for symbols which match. */ iterate_over_symtabs (srcfile, [&] (symtab *s) { - add_symtab_completions (SYMTAB_COMPUNIT (s), + add_symtab_completions (s->compunit (), tracker, mode, lookup_name, sym_text, word, TYPE_CODE_UNDEF); return false; diff --git a/gdb/symtab.h b/gdb/symtab.h index c319d51a2714..c313d54de18e 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1373,6 +1373,16 @@ typedef std::vector section_offsets; struct symtab { + struct compunit_symtab *compunit () const + { + return m_compunit; + } + + void set_compunit (struct compunit_symtab *compunit) + { + m_compunit = compunit; + } + /* Unordered chain of all filetabs in the compunit, with the exception that the "main" source file is the first entry in the list. */ @@ -1380,7 +1390,7 @@ struct symtab /* Backlink to containing compunit symtab. */ - struct compunit_symtab *compunit_symtab; + struct compunit_symtab *m_compunit; /* Table mapping core addresses to line numbers for this file. Can be NULL if none. Never shared between different symtabs. */ @@ -1405,15 +1415,14 @@ struct symtab using symtab_range = next_range; -#define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab) #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable) #define SYMTAB_LANGUAGE(symtab) ((symtab)->language) #define SYMTAB_BLOCKVECTOR(symtab) \ - (SYMTAB_COMPUNIT (symtab)->blockvector ()) + (symtab->compunit ()->blockvector ()) #define SYMTAB_OBJFILE(symtab) \ - (SYMTAB_COMPUNIT (symtab)->objfile ()) + (symtab->compunit ()->objfile ()) #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace) -#define SYMTAB_DIRNAME(symtab) (SYMTAB_COMPUNIT (symtab)->dirname ()) +#define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ()) /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well as the list of all source files (what gdb has historically associated with @@ -1665,7 +1674,7 @@ extern enum language compunit_language (const struct compunit_symtab *cust); static inline bool is_main_symtab_of_compunit_symtab (struct symtab *symtab) { - return symtab == SYMTAB_COMPUNIT (symtab)->primary_filetab (); + return symtab == symtab->compunit ()->primary_filetab (); } diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 4a58fe5138ea..a252574c94e2 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -495,7 +495,7 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) if (prologue_end != 0) { struct symtab_and_line prologue_sal = find_pc_line (func_addr, 0); - struct compunit_symtab *compunit = SYMTAB_COMPUNIT (prologue_sal.symtab); + struct compunit_symtab *compunit = prologue_sal.symtab->compunit (); const char *debug_format = compunit->debugformat (); if (debug_format != NULL && -- 2.34.1