From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id CB4533947C31 for ; Fri, 28 Jan 2022 12:49:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB4533947C31 X-ASG-Debug-ID: 1643374173-0c856e06ad271a60001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 1Ckhmv6LUZguINs7 (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 EDCAA441D64; Fri, 28 Jan 2022 07:49:32 -0500 (EST) From: Simon Marchi 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 Cc: Simon Marchi Subject: [PATCH 17/33] gdb: remove SYMTAB_LINETABLE macro, add getter/setter Date: Fri, 28 Jan 2022 07:45:15 -0500 X-ASG-Orig-Subj: [PATCH 17/33] gdb: remove SYMTAB_LINETABLE macro, add getter/setter Message-Id: <20220128124531.2302941-18-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: 16426 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-Spam-Status: No, score=-3613.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 28 Jan 2022 12:49:42 -0000 From: Simon Marchi Add a getter and a setter for a symtab's linetable. Remove the corresponding macro and adjust all callers. Change-Id: I159183fc0ccd8e18ab937b3c2f09ef2244ec6e9c --- gdb/buildsym.c | 12 +++++------- gdb/disasm.c | 16 ++++++++-------- gdb/jit.c | 7 +++---- gdb/mdebugread.c | 14 +++++++------- gdb/mi/mi-symbol-cmds.c | 8 ++++---- gdb/objfiles.c | 2 +- gdb/python/py-linetable.c | 20 ++++++++++---------- gdb/record-btrace.c | 2 +- gdb/symmisc.c | 9 +++++---- gdb/symtab.c | 18 +++++++++--------- gdb/symtab.h | 13 +++++++++++-- 11 files changed, 64 insertions(+), 57 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b42c40830c90..2a99a96e2e60 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 3000e5dddad9..d739e22293e0 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 6f397fc91fc7..c8415781672a 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -512,10 +512,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 a6a70ccfea93..3dc6a8b72971 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 2177354ae19c..2078ab8e5243 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 7e1ec6ca92dd..d41dc73b02b8 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 dfd4cbebdae8..8e545febb171 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 e6542bd317a9..3dfdf592dd51 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 d079ac460ee8..2fdd0f626274 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 459c0c3c7487..f796ee4bd362 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 c313d54de18e..8881f4e5c02b 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 ()) -- 2.34.1