From: Simon Marchi Date: Sat, 20 Nov 2021 13:40:12 +0000 (-0500) Subject: gdb: remove SYMTAB_LINETABLE macro, add getter/setter X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b6074611edfdd1590e8da1ca443950b47942bbb;p=binutils-gdb.git gdb: remove SYMTAB_LINETABLE macro, add getter/setter Add a getter and a setter for a symtab's linetable. Remove the corresponding macro and adjust all callers. Change-Id: I159183fc0ccd8e18ab937b3c2f09ef2244ec6e9c --- diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b42c40830c9..2a99a96e2e6 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -977,15 +977,13 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, if (subfile->line_vector) { /* Reallocate the line table on the symbol obstack. */ - SYMTAB_LINETABLE (symtab) = (struct linetable *) - obstack_alloc (&m_objfile->objfile_obstack, linetablesize); - memcpy (SYMTAB_LINETABLE (symtab), subfile->line_vector, - linetablesize); + symtab->set_linetable + ((struct linetable *) + obstack_alloc (&m_objfile->objfile_obstack, linetablesize)); + memcpy (symtab->linetable (), subfile->line_vector, linetablesize); } else - { - SYMTAB_LINETABLE (symtab) = NULL; - } + symtab->set_linetable (nullptr); /* Use whatever language we have been using for this subfile, not the one that was deduced in allocate_symtab diff --git a/gdb/disasm.c b/gdb/disasm.c index 5cd1f5adbd2..bfccbfcddcd 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -393,10 +393,10 @@ do_mixed_source_and_assembly_deprecated int num_displayed = 0; print_source_lines_flags psl_flags = 0; - gdb_assert (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL); + gdb_assert (symtab != nullptr && symtab->linetable () != nullptr); - nlines = SYMTAB_LINETABLE (symtab)->nitems; - le = SYMTAB_LINETABLE (symtab)->item; + nlines = symtab->linetable ()->nitems; + le = symtab->linetable ()->item; if (flags & DISASSEMBLY_FILENAME) psl_flags |= PRINT_SOURCE_LINES_FILENAME; @@ -535,7 +535,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct symtab *last_symtab; int last_line; - gdb_assert (main_symtab != NULL && SYMTAB_LINETABLE (main_symtab) != NULL); + gdb_assert (main_symtab != NULL && main_symtab->linetable () != NULL); /* First pass: collect the list of all source files and lines. We do this so that we can only print lines containing code once. @@ -553,8 +553,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, line after the opening brace. We still want to print this opening brace. first_le is used to implement this. */ - nlines = SYMTAB_LINETABLE (main_symtab)->nitems; - le = SYMTAB_LINETABLE (main_symtab)->item; + nlines = main_symtab->linetable ()->nitems; + le = main_symtab->linetable ()->item; first_le = NULL; /* Skip all the preceding functions. */ @@ -850,8 +850,8 @@ gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, /* Assume symtab is valid for whole PC range. */ symtab = find_pc_line_symtab (low); - if (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL) - nlines = SYMTAB_LINETABLE (symtab)->nitems; + if (symtab != NULL && symtab->linetable () != NULL) + nlines = symtab->linetable ()->nitems; if (!(flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE)) || nlines <= 0) diff --git a/gdb/jit.c b/gdb/jit.c index c86124c9e1b..9d844bfb4b2 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -521,10 +521,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) size_t size = ((stab->linetable->nitems - 1) * sizeof (struct linetable_entry) + sizeof (struct linetable)); - SYMTAB_LINETABLE (filetab) - = (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size); - memcpy (SYMTAB_LINETABLE (filetab), - stab->linetable.get (), size); + filetab->set_linetable ((struct linetable *) + obstack_alloc (&objfile->objfile_obstack, size)); + memcpy (filetab->linetable (), stab->linetable.get (), size); } blockvector_size = (sizeof (struct blockvector) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index a6a70ccfea9..3dc6a8b7297 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4089,7 +4089,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) psymtab_language = cust->primary_filetab ()->language; - lines = SYMTAB_LINETABLE (cust->primary_filetab ()); + lines = cust->primary_filetab ()->linetable (); /* Get a new lexical context. */ @@ -4173,11 +4173,11 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) size = lines->nitems; if (size > 1) --size; - SYMTAB_LINETABLE (cust->primary_filetab ()) - = ((struct linetable *) - obstack_copy (&mdebugread_objfile->objfile_obstack, - lines, (sizeof (struct linetable) - + size * sizeof (lines->item)))); + cust->primary_filetab ()->set_linetable + ((struct linetable *) + obstack_copy (&mdebugread_objfile->objfile_obstack, + lines, (sizeof (struct linetable) + + size * sizeof (lines->item)))); xfree (lines); /* .. and our share of externals. @@ -4623,7 +4623,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile) add_compunit_symtab_to_objfile (cust); symtab = allocate_symtab (cust, name); - SYMTAB_LINETABLE (symtab) = new_linetable (maxlines); + symtab->set_linetable (new_linetable (maxlines)); lang = compunit_language (cust); /* All symtabs must have at least two blocks. */ diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 2177354ae19..2078ab8e524 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -53,12 +53,12 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) gdbarch = SYMTAB_OBJFILE (s)->arch (); ui_out_emit_list list_emitter (uiout, "lines"); - if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0) - for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++) + if (s->linetable () != NULL && s->linetable ()->nitems > 0) + for (i = 0; i < s->linetable ()->nitems; i++) { ui_out_emit_tuple tuple_emitter (uiout, NULL); - uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc); - uiout->field_signed ("line", SYMTAB_LINETABLE (s)->item[i].line); + uiout->field_core_addr ("pc", gdbarch, s->linetable ()->item[i].pc); + uiout->field_signed ("line", s->linetable ()->item[i].line); } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 7e1ec6ca92d..d41dc73b02b 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -656,7 +656,7 @@ objfile_relocate1 (struct objfile *objfile, struct linetable *l; /* First the line table. */ - l = SYMTAB_LINETABLE (s); + l = s->linetable (); if (l) { for (int i = 0; i < l->nitems; ++i) diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index dfd4cbebdae..8e545febb17 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -192,16 +192,16 @@ ltpy_has_line (PyObject *self, PyObject *args) if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line)) return NULL; - if (SYMTAB_LINETABLE (symtab) == NULL) + if (symtab->linetable () == NULL) { PyErr_SetString (PyExc_RuntimeError, _("Linetable information not found in symbol table")); return NULL; } - for (index = 0; index < SYMTAB_LINETABLE (symtab)->nitems; index++) + for (index = 0; index < symtab->linetable ()->nitems; index++) { - struct linetable_entry *item = &(SYMTAB_LINETABLE (symtab)->item[index]); + struct linetable_entry *item = &(symtab->linetable ()->item[index]); if (item->line == py_line) Py_RETURN_TRUE; } @@ -223,7 +223,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args) LTPY_REQUIRE_VALID (self, symtab); - if (SYMTAB_LINETABLE (symtab) == NULL) + if (symtab->linetable () == NULL) { PyErr_SetString (PyExc_RuntimeError, _("Linetable information not found in symbol table")); @@ -234,9 +234,9 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args) if (source_dict == NULL) return NULL; - for (index = 0; index < SYMTAB_LINETABLE (symtab)->nitems; index++) + for (index = 0; index < symtab->linetable ()->nitems; index++) { - item = &(SYMTAB_LINETABLE (symtab)->item[index]); + item = &(symtab->linetable ()->item[index]); /* 0 is used to signify end of line table information. Do not include in the source set. */ @@ -399,13 +399,13 @@ ltpy_iternext (PyObject *self) LTPY_REQUIRE_VALID (iter_obj->source, symtab); - if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems) + if (iter_obj->current_index >= symtab->linetable ()->nitems) { PyErr_SetNone (PyExc_StopIteration); return NULL; } - item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]); + item = &(symtab->linetable ()->item[iter_obj->current_index]); /* Skip over internal entries such as 0. 0 signifies the end of line table data and is not useful to the API user. */ @@ -414,12 +414,12 @@ ltpy_iternext (PyObject *self) iter_obj->current_index++; /* Exit if the internal value is the last item in the line table. */ - if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems) + if (iter_obj->current_index >= symtab->linetable ()->nitems) { PyErr_SetNone (PyExc_StopIteration); return NULL; } - item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]); + item = &(symtab->linetable ()->item[iter_obj->current_index]); } obj = build_linetable_entry (item->line, item->pc); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index e6542bd317a..3dfdf592dd5 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -713,7 +713,7 @@ btrace_find_line_range (CORE_ADDR pc) if (symtab == NULL) return btrace_mk_line_range (NULL, 0, 0); - ltable = SYMTAB_LINETABLE (symtab); + ltable = symtab->linetable (); if (ltable == NULL) return btrace_mk_line_range (symtab, 0, 0); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index d079ac460ee..2fdd0f62627 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -77,7 +77,7 @@ print_objfile_statistics (void) for (symtab *s : cu->filetabs ()) { i++; - if (SYMTAB_LINETABLE (s) != NULL) + if (s->linetable () != NULL) linetables++; } } @@ -259,7 +259,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) language_str (symtab->language)); /* First print the line table. */ - l = SYMTAB_LINETABLE (symtab); + l = symtab->linetable (); if (l) { fprintf_filtered (outfile, "\nLine table:\n\n"); @@ -824,7 +824,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty) : "(null)"); printf_filtered ("\t " "linetable ((struct linetable *) %s)\n", - host_address_to_string (symtab->linetable)); + host_address_to_string + (symtab->linetable ())); printf_filtered ("\t}\n"); } } @@ -968,7 +969,7 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data) styled_string (file_name_style.style (), symtab_to_fullname (symtab)), host_address_to_string (symtab)); - linetable = SYMTAB_LINETABLE (symtab); + linetable = symtab->linetable (); printf_filtered (_("linetable: ((struct linetable *) %s):\n"), host_address_to_string (linetable)); diff --git a/gdb/symtab.c b/gdb/symtab.c index 459c0c3c748..f796ee4bd36 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3285,7 +3285,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) for (symtab *iter_s : cust->filetabs ()) { /* Find the best line in this symtab. */ - l = SYMTAB_LINETABLE (iter_s); + l = iter_s->linetable (); if (!l) continue; len = l->nitems; @@ -3454,7 +3454,7 @@ find_line_symtab (struct symtab *sym_tab, int line, struct symtab *best_symtab; /* First try looking it up in the given symtab. */ - best_linetable = SYMTAB_LINETABLE (sym_tab); + best_linetable = sym_tab->linetable (); best_symtab = sym_tab; best_index = find_line_common (best_linetable, line, &exact, 0); if (best_index < 0 || !exact) @@ -3493,7 +3493,7 @@ find_line_symtab (struct symtab *sym_tab, int line, if (FILENAME_CMP (symtab_to_fullname (sym_tab), symtab_to_fullname (s)) != 0) continue; - l = SYMTAB_LINETABLE (s); + l = s->linetable (); ind = find_line_common (l, line, &exact, 0); if (ind >= 0) { @@ -3545,14 +3545,14 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line, int was_exact; int idx; - idx = find_line_common (SYMTAB_LINETABLE (symtab), line, &was_exact, + idx = find_line_common (symtab->linetable (), line, &was_exact, start); if (idx < 0) break; if (!was_exact) { - struct linetable_entry *item = &SYMTAB_LINETABLE (symtab)->item[idx]; + struct linetable_entry *item = &symtab->linetable ()->item[idx]; if (*best_item == NULL || (item->line < (*best_item)->line && item->is_stmt)) @@ -3561,7 +3561,7 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line, break; } - result.push_back (SYMTAB_LINETABLE (symtab)->item[idx].pc); + result.push_back (symtab->linetable ()->item[idx].pc); start = idx + 1; } @@ -3586,7 +3586,7 @@ find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc) symtab = find_line_symtab (symtab, line, &ind, NULL); if (symtab != NULL) { - l = SYMTAB_LINETABLE (symtab); + l = symtab->linetable (); *pc = l->item[ind].pc; return true; } @@ -3783,7 +3783,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab) int i; /* Give up if this symbol has no lineinfo table. */ - l = SYMTAB_LINETABLE (symtab); + l = symtab->linetable (); if (l == NULL) return func_addr; @@ -4025,7 +4025,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) do this. */ if (prologue_sal.symtab->language != language_asm) { - struct linetable *linetable = SYMTAB_LINETABLE (prologue_sal.symtab); + struct linetable *linetable = prologue_sal.symtab->linetable (); int idx = 0; /* Skip any earlier lines, and any end-of-sequence marker diff --git a/gdb/symtab.h b/gdb/symtab.h index c313d54de18..8881f4e5c02 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1383,6 +1383,16 @@ struct symtab m_compunit = compunit; } + struct linetable *linetable () const + { + return m_linetable; + } + + void set_linetable (struct linetable *linetable) + { + m_linetable = linetable; + } + /* Unordered chain of all filetabs in the compunit, with the exception that the "main" source file is the first entry in the list. */ @@ -1395,7 +1405,7 @@ struct symtab /* Table mapping core addresses to line numbers for this file. Can be NULL if none. Never shared between different symtabs. */ - struct linetable *linetable; + struct linetable *m_linetable; /* Name of this source file. This pointer is never NULL. */ @@ -1415,7 +1425,6 @@ struct symtab using symtab_range = next_range; -#define SYMTAB_LINETABLE(symtab) ((symtab)->linetable) #define SYMTAB_LANGUAGE(symtab) ((symtab)->language) #define SYMTAB_BLOCKVECTOR(symtab) \ (symtab->compunit ()->blockvector ())