From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SKkMNAno82EjewAAWB0awg (envelope-from ) for ; Fri, 28 Jan 2022 07:56:41 -0500 Received: by simark.ca (Postfix, from userid 112) id D2B5B1F3B7; Fri, 28 Jan 2022 07:56:41 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 EF2FD1EE18 for ; Fri, 28 Jan 2022 07:56:40 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9349B38515FF for ; Fri, 28 Jan 2022 12:56:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9349B38515FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643374600; bh=1s2PTnWNCqZPMF5VcRc2pmcqfkDANJjrPCHbyFAo8DU=; 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=sRw0D3Dx0kEtlCgQ8GvLOJH+yCA+a/kALwSH/zg4iQNgs1ro9NpySF3FxF2LrVYWZ 4ZzAHdGvCK81pI4szOmZjkejlZ1L1RX6twVnrgIuUNH8Ie0550/AcQL/xDCWuPoAYI 4SGU8pEEfM2rLc6GW5WfjVq43c9FKjj7zqHbxoiI= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 1A455394742B for ; Fri, 28 Jan 2022 12:49:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A455394742B X-ASG-Debug-ID: 1643374173-0c856e06ab271c80001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id D8eqk7CiIf9Y694C (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 0C2EE441D65; Fri, 28 Jan 2022 07:49:33 -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 18/33] gdb: remove SYMTAB_LANGUAGE macro, add getter/setter Date: Fri, 28 Jan 2022 07:45:16 -0500 X-ASG-Orig-Subj: [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE macro, add getter/setter Message-Id: <20220128124531.2302941-19-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-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 9054 X-Barracuda-BRTS-Status: 1 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 language. Remove the corresponding macro and adjust all callers. Change-Id: I9f4d840b11c19f80f39bac1bce020fdd1739e11f --- gdb/buildsym.c | 2 +- gdb/dwarf2/read.c | 8 ++++---- gdb/linespec.c | 2 +- gdb/mdebugread.c | 5 +++-- gdb/source.c | 3 ++- gdb/stack.c | 2 +- gdb/symfile.c | 2 +- gdb/symmisc.c | 8 ++++---- gdb/symtab.c | 8 ++++---- gdb/symtab.h | 13 +++++++++++-- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 2a99a96e2e60..27206f97b2b0 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -991,7 +991,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, we created the subfile, and we may have altered our opinion of what language it is from things we found in the symbols. */ - symtab->language = subfile->language; + symtab->set_language (subfile->language); } /* Make sure the filetab of main_subfile is the primary filetab of the CU. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index fb138de86adc..3bbd253d8413 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9477,8 +9477,8 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && cust->primary_filetab ()->language != language_unknown)) - cust->primary_filetab ()->language = cu->per_cu->lang; + && cust->primary_filetab ()->language () != language_unknown)) + cust->primary_filetab ()->set_language (cu->per_cu->lang); /* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can produce DW_AT_location with location lists but it can be possibly @@ -9562,8 +9562,8 @@ process_full_type_unit (dwarf2_cu *cu, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && cust->primary_filetab ()->language != language_c)) - cust->primary_filetab ()->language = cu->per_cu->lang; + && cust->primary_filetab ()->language () != language_c)) + cust->primary_filetab ()->set_language (cu->per_cu->lang); } } else diff --git a/gdb/linespec.c b/gdb/linespec.c index f8b4b86a1e8e..c16e81753c0d 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4424,7 +4424,7 @@ add_matching_symbols_to_info (const char *name, which we don't have debug info. Check for a minimal symbol in this case. */ if (prev_len == info->result.symbols->size () - && elt->language == language_asm) + && elt->language () == language_asm) search_minsyms_for_name (info, lookup_name, pspace, elt); } } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 3dc6a8b72971..192fafa5d02a 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4084,10 +4084,11 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) /* The proper language was already determined when building the psymtab, use it. */ - cust->primary_filetab ()->language = PST_PRIVATE (pst)->pst_language; + cust->primary_filetab ()->set_language + (PST_PRIVATE (pst)->pst_language); } - psymtab_language = cust->primary_filetab ()->language; + psymtab_language = cust->primary_filetab ()->language (); lines = cust->primary_filetab ()->linetable (); diff --git a/gdb/source.c b/gdb/source.c index ee896264277f..e99fff885254 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -722,7 +722,8 @@ info_source_command (const char *ignore, int from_tty) printf_filtered (_("Contains %d line%s.\n"), (int) offsets->size (), offsets->size () == 1 ? "" : "s"); - printf_filtered (_("Source language is %s.\n"), language_str (s->language)); + printf_filtered (_("Source language is %s.\n"), + language_str (s->language ())); printf_filtered (_("Producer is %s.\n"), (cust->producer ()) != nullptr ? cust->producer () : _("unknown")); diff --git a/gdb/stack.c b/gdb/stack.c index c7269e2ac326..8d5983e64391 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1638,7 +1638,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) if (s) printf_filtered (" source language %s.\n", - language_str (s->language)); + language_str (s->language ())); { /* Address of the argument list for this frame, or 0. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 46c42014a9f6..1a64fc797423 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2780,7 +2780,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename) symtab->filename = objfile->intern (filename); symtab->fullname = NULL; - symtab->language = deduce_language_from_filename (filename); + symtab->set_language (deduce_language_from_filename (filename)); /* This can be very verbose with lots of headers. Only print at higher debug levels. */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 2fdd0f626274..24b2915a3acc 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -256,7 +256,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) objfile_name (objfile), host_address_to_string (objfile)); fprintf_filtered (outfile, "Language: %s\n", - language_str (symtab->language)); + language_str (symtab->language ())); /* First print the line table. */ l = symtab->linetable (); @@ -370,11 +370,11 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile) because certain routines used during dump_symtab() use the current language to print an image of the symbol. We'll restore it later. But use only real languages, not placeholders. */ - if (symtab->language != language_unknown - && symtab->language != language_auto) + if (symtab->language () != language_unknown + && symtab->language () != language_auto) { scoped_restore_current_language save_lang; - set_language (symtab->language); + set_language (symtab->language ()); dump_symtab_1 (symtab, outfile); } else diff --git a/gdb/symtab.c b/gdb/symtab.c index f796ee4bd362..65359374fef6 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -407,7 +407,7 @@ compunit_language (const struct compunit_symtab *cust) /* The language of the compunit symtab is the language of its primary source file. */ - return SYMTAB_LANGUAGE (symtab); + return symtab->language (); } /* See symtab.h. */ @@ -3710,7 +3710,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section, if (funfirstline && sal.symtab != NULL && (sal.symtab->compunit ()->locations_valid () - || SYMTAB_LANGUAGE (sal.symtab) == language_asm)) + || sal.symtab->language () == language_asm)) { struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); @@ -3840,7 +3840,7 @@ skip_prologue_sal (struct symtab_and_line *sal) is likely to be the wrong choice. */ if (sal->symtab != nullptr && sal->explicit_line - && SYMTAB_LANGUAGE (sal->symtab) == language_asm) + && sal->symtab->language () == language_asm) return; scoped_restore_current_pspace_and_thread restore_pspace_thread; @@ -4023,7 +4023,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) The GNU assembler emits separate line notes for each instruction in a multi-instruction macro, but compilers generally will not do this. */ - if (prologue_sal.symtab->language != language_asm) + if (prologue_sal.symtab->language () != language_asm) { struct linetable *linetable = prologue_sal.symtab->linetable (); int idx = 0; diff --git a/gdb/symtab.h b/gdb/symtab.h index 8881f4e5c02b..28309695bca3 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1393,6 +1393,16 @@ struct symtab m_linetable = linetable; } + enum language language () const + { + return m_language; + } + + void set_language (enum language language) + { + m_language = language; + } + /* Unordered chain of all filetabs in the compunit, with the exception that the "main" source file is the first entry in the list. */ @@ -1413,7 +1423,7 @@ struct symtab /* Language of this source file. */ - enum language language; + enum language m_language; /* Full name of file as found by searching the source path. NULL if not yet known. */ @@ -1425,7 +1435,6 @@ struct symtab using symtab_range = next_range; -#define SYMTAB_LANGUAGE(symtab) ((symtab)->language) #define SYMTAB_BLOCKVECTOR(symtab) \ (symtab->compunit ()->blockvector ()) #define SYMTAB_OBJFILE(symtab) \ -- 2.34.1