From ab5f850eed6aba84050d075e8c8a2cb16a876b15 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 19 Nov 2021 22:09:25 -0500 Subject: [PATCH] gdb: remove COMPUNIT_PRODUCER macro, add getter/setter Add a getter and a setter for a compunit_symtab's producer. Remove the corresponding macro and adjust all callers. Change-Id: Ia1d6d8a0e247a08a21af23819d71e49b37d8931b --- gdb/amd64-tdep.c | 10 +++++----- gdb/arm-tdep.c | 6 +++--- gdb/buildsym.c | 2 +- gdb/compile/compile.c | 6 +++--- gdb/dwarf2/frame.c | 2 +- gdb/i386-tdep.c | 6 +++--- gdb/python/py-symtab.c | 4 ++-- gdb/source.c | 4 ++-- gdb/symmisc.c | 5 ++--- gdb/symtab.h | 13 +++++++++++-- 10 files changed, 33 insertions(+), 25 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index e67aea8e66d..539ebe9e1c3 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 (COMPUNIT_PRODUCER - (SYMTAB_COMPUNIT (start_pc_sal.symtab))) < 6 + || producer_is_gcc_ge_4 (SYMTAB_COMPUNIT + (start_pc_sal.symtab)->producer ()) < 6 || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end) return pc; @@ -2545,9 +2545,9 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) compilers to emit usable line notes. */ if (post_prologue_pc && (cust != NULL - && COMPUNIT_PRODUCER (cust) != NULL - && (producer_is_llvm (COMPUNIT_PRODUCER (cust)) - || producer_is_icc_ge_19 (COMPUNIT_PRODUCER (cust))))) + && cust->producer () != nullptr + && (producer_is_llvm (cust->producer ()) + || producer_is_icc_ge_19 (cust->producer ())))) return std::max (start_pc, post_prologue_pc); } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index f46913e8eaa..d36856e1f3b 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1394,9 +1394,9 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) missing (e.g. for -gstabs), assuming the GNU tools. */ if (post_prologue_pc && (cust == NULL - || COMPUNIT_PRODUCER (cust) == NULL - || startswith (COMPUNIT_PRODUCER (cust), "GNU ") - || producer_is_llvm (COMPUNIT_PRODUCER (cust)))) + || cust->producer () == NULL + || startswith (cust->producer (), "GNU ") + || producer_is_llvm (cust->producer ()))) return post_prologue_pc; if (post_prologue_pc != 0) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 267b9462abd..22727277613 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1013,7 +1013,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, cu->set_debugformat (m_debugformat); /* Similarly for the producer. */ - COMPUNIT_PRODUCER (cu) = m_producer; + cu->set_producer (m_producer); COMPUNIT_BLOCKVECTOR (cu) = blockvector; { diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 6794c93d60e..7bd6ac817b8 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -561,11 +561,11 @@ get_selected_pc_producer_options (void) struct compunit_symtab *symtab = find_pc_compunit_symtab (pc); const char *cs; - if (symtab == NULL || symtab->producer == NULL - || !startswith (symtab->producer, "GNU ")) + if (symtab == NULL || symtab->producer () == NULL + || !startswith (symtab->producer (), "GNU ")) return NULL; - cs = symtab->producer; + cs = symtab->producer (); while (*cs != 0 && *cs != '-') cs = skip_spaces (skip_to_space (cs)); if (*cs != '-') diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index b4e699c37e1..0b7ed2c63fd 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -745,7 +745,7 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs, if (cust == NULL) return; - if (producer_is_realview (COMPUNIT_PRODUCER (cust))) + if (producer_is_realview (cust->producer ())) { if (fde->cie->version == 1) fs->armcc_cfa_offsets_sf = 1; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index aaa5592f40a..e598a4d197b 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1853,9 +1853,9 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) compilers to emit usable line notes. */ if (post_prologue_pc && (cust != NULL - && COMPUNIT_PRODUCER (cust) != NULL - && (producer_is_llvm (COMPUNIT_PRODUCER (cust)) - || producer_is_icc_ge_19 (COMPUNIT_PRODUCER (cust))))) + && cust->producer () != NULL + && (producer_is_llvm (cust->producer ()) + || producer_is_icc_ge_19 (cust->producer ())))) return std::max (start_pc, post_prologue_pc); } diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index db19e4b1213..b973b25f158 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -132,9 +132,9 @@ stpy_get_producer (PyObject *self, void *closure) STPY_REQUIRE_VALID (self, symtab); cust = SYMTAB_COMPUNIT (symtab); - if (COMPUNIT_PRODUCER (cust) != NULL) + if (cust->producer () != nullptr) { - const char *producer = COMPUNIT_PRODUCER (cust); + const char *producer = cust->producer (); return host_string_to_python_string (producer).release (); } diff --git a/gdb/source.c b/gdb/source.c index 3f047467b2e..07ea2af9fd8 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -724,8 +724,8 @@ info_source_command (const char *ignore, int from_tty) printf_filtered (_("Source language is %s.\n"), language_str (s->language)); printf_filtered (_("Producer is %s.\n"), - COMPUNIT_PRODUCER (cust) != NULL - ? COMPUNIT_PRODUCER (cust) : _("unknown")); + (cust->producer ()) != nullptr + ? cust->producer () : _("unknown")); printf_filtered (_("Compiled with %s debugging format.\n"), cust->debugformat ()); printf_filtered (_("%s preprocessor macro info.\n"), diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 4220fd7f939..b946fc8bde0 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -779,9 +779,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty) printf_filtered (" debugformat %s\n", cust->debugformat ()); printf_filtered (" producer %s\n", - COMPUNIT_PRODUCER (cust) != NULL - ? COMPUNIT_PRODUCER (cust) - : "(null)"); + (cust->producer () != nullptr + ? cust->producer () : "(null)")); printf_filtered (" dirname %s\n", COMPUNIT_DIRNAME (cust) != NULL ? COMPUNIT_DIRNAME (cust) diff --git a/gdb/symtab.h b/gdb/symtab.h index 2500c8e4166..1e3f95dc92f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1492,6 +1492,16 @@ struct compunit_symtab m_debugformat = debugformat; } + const char *producer () const + { + return m_producer; + } + + void set_producer (const char *producer) + { + m_producer = producer; + } + /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab. PRIMARY_FILETAB must already be a filetab of this compunit symtab. */ @@ -1538,7 +1548,7 @@ struct compunit_symtab const char *m_debugformat; /* String of producer version information, or NULL if we don't know. */ - const char *producer; + const char *m_producer; /* Directory in which it was compiled, or NULL if we don't know. */ const char *dirname; @@ -1587,7 +1597,6 @@ struct compunit_symtab using compunit_symtab_range = next_range; -#define COMPUNIT_PRODUCER(cust) ((cust)->producer) #define COMPUNIT_DIRNAME(cust) ((cust)->dirname) #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector) #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section) -- 2.30.2