@@ -1373,10 +1373,10 @@ 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 *)
+ linetable *new_table = (struct linetable *)
obstack_alloc (&objfile->objfile_obstack, linetablesize);
- memcpy (SYMTAB_LINETABLE (symtab), subfile->line_vector,
- linetablesize);
+ memcpy (new_table, subfile->line_vector, linetablesize);
+ SYMTAB_LINETABLE (symtab) = new_table;
}
else
{
@@ -343,7 +343,7 @@ do_mixed_source_and_assembly_deprecated
{
int newlines = 0;
int nlines;
- struct linetable_entry *le;
+ const struct linetable_entry *le;
struct deprecated_dis_line_entry *mle;
struct symtab_and_line sal;
int i;
@@ -672,10 +672,10 @@ 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 (COMPUNIT_FILETABS (cust))
- = (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size);
- memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)), stab->linetable,
- size);
+ struct linetable *new_table =
+ (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size);
+ memcpy (new_table, stab->linetable, size);
+ SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)) = new_table;
}
blockvector_size = (sizeof (struct blockvector)
@@ -389,7 +389,7 @@ static std::vector<symtab_and_line> decode_digits_ordinary
(struct linespec_state *self,
linespec_p ls,
int line,
- linetable_entry **best_entry);
+ const linetable_entry **best_entry);
static std::vector<symtab_and_line> decode_digits_list_mode
(struct linespec_state *self,
@@ -2192,7 +2192,7 @@ create_sals_line_offset (struct linespec_state *self,
values = decode_digits_list_mode (self, ls, val);
else
{
- struct linetable_entry *best_entry = NULL;
+ const struct linetable_entry *best_entry = NULL;
int i, j;
std::vector<symtab_and_line> intermediate_results
@@ -4235,7 +4235,7 @@ static std::vector<symtab_and_line>
decode_digits_ordinary (struct linespec_state *self,
linespec_p ls,
int line,
- struct linetable_entry **best_entry)
+ const struct linetable_entry **best_entry)
{
int ix;
struct symtab *elt;
@@ -236,7 +236,8 @@ enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
static struct block *new_block (enum block_type, enum language);
-static struct compunit_symtab *new_symtab (const char *, int, struct objfile *);
+static struct compunit_symtab *new_symtab (const char *, int, struct objfile *,
+ struct linetable **);
static struct linetable *new_linetable (int);
@@ -2177,9 +2178,6 @@ parse_external (EXTR *es, int bigend, struct section_offsets *section_offsets,
numbers can go back and forth, apparently we can live
with that and do not need to reorder our linetables. */
-static void parse_lines (FDR *, PDR *, struct linetable *, int,
- struct partial_symtab *, CORE_ADDR);
-
static void
parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
struct partial_symtab *pst, CORE_ADDR lowest_pdr_addr)
@@ -3919,7 +3917,6 @@ psymtab_to_symtab_1 (struct objfile *objfile,
int i;
struct compunit_symtab *cust = NULL;
FDR *fh;
- struct linetable *lines;
CORE_ADDR lowest_pdr_addr = 0;
int last_symtab_ended = 0;
struct section_offsets *section_offsets = objfile->section_offsets;
@@ -4159,16 +4156,17 @@ psymtab_to_symtab_1 (struct objfile *objfile,
int maxlines, size;
EXTR *ext_ptr;
+ struct linetable *lines;
if (fh == 0)
{
maxlines = 0;
- cust = new_symtab ("unknown", 0, objfile);
+ cust = new_symtab ("unknown", 0, objfile, &lines);
}
else
{
maxlines = 2 * fh->cline;
- cust = new_symtab (pst->filename, maxlines, objfile);
+ cust = new_symtab (pst->filename, maxlines, objfile, &lines);
/* The proper language was already determined when building
the psymtab, use it. */
@@ -4177,8 +4175,6 @@ psymtab_to_symtab_1 (struct objfile *objfile,
psymtab_language = COMPUNIT_FILETABS (cust)->language;
- lines = SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust));
-
/* Get a new lexical context. */
push_parse_stack ();
@@ -4712,17 +4708,17 @@ sort_blocks (struct symtab *s)
linenumbers MAXLINES we'll put in it. */
static struct compunit_symtab *
-new_symtab (const char *name, int maxlines, struct objfile *objfile)
+new_symtab (const char *name, int maxlines, struct objfile *objfile,
+ struct linetable **lines)
{
struct compunit_symtab *cust = allocate_compunit_symtab (objfile, name);
- struct symtab *symtab;
struct blockvector *bv;
enum language lang;
add_compunit_symtab_to_objfile (cust);
- symtab = allocate_symtab (cust, name);
+ allocate_symtab (cust, name);
- SYMTAB_LINETABLE (symtab) = new_linetable (maxlines);
+ *lines = new_linetable (maxlines);
lang = compunit_language (cust);
/* All symtabs must have at least two blocks. */
@@ -34,7 +34,7 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
struct symtab *s;
int i;
struct ui_out *uiout = current_uiout;
- struct linetable *linetable;
+ const struct linetable *linetable;
if (argc != 1)
error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
@@ -158,7 +158,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
{
struct symtab *symtab;
gdb_py_longest py_line;
- struct linetable_entry *best_entry = NULL;
+ const struct linetable_entry *best_entry = NULL;
std::vector<CORE_ADDR> pcs;
LTPY_REQUIRE_VALID (self, symtab);
@@ -204,7 +204,8 @@ ltpy_has_line (PyObject *self, PyObject *args)
for (index = 0; index < SYMTAB_LINETABLE (symtab)->nitems; index++)
{
- struct linetable_entry *item = &(SYMTAB_LINETABLE (symtab)->item[index]);
+ const struct linetable_entry *item
+ = &(SYMTAB_LINETABLE (symtab)->item[index]);
if (item->line == py_line)
Py_RETURN_TRUE;
}
@@ -222,7 +223,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
{
struct symtab *symtab;
Py_ssize_t index;
- struct linetable_entry *item;
+ const struct linetable_entry *item;
LTPY_REQUIRE_VALID (self, symtab);
@@ -397,7 +398,7 @@ ltpy_iternext (PyObject *self)
ltpy_iterator_object *iter_obj = (ltpy_iterator_object *) self;
struct symtab *symtab;
PyObject *obj;
- struct linetable_entry *item;
+ const struct linetable_entry *item;
LTPY_REQUIRE_VALID (iter_obj->source, symtab);
@@ -576,8 +576,8 @@ static struct btrace_line_range
btrace_find_line_range (CORE_ADDR pc)
{
struct btrace_line_range range;
- struct linetable_entry *lines;
- struct linetable *ltable;
+ const struct linetable_entry *lines;
+ const struct linetable *ltable;
struct symtab *symtab;
int nlines, i;
@@ -276,7 +276,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
int i;
struct dict_iterator iter;
int len;
- struct linetable *l;
+ const struct linetable *l;
const struct blockvector *bv;
struct symbol *sym;
struct block *b;
@@ -986,7 +986,7 @@ block_depth (struct block *block)
static int
maintenance_print_one_line_table (struct symtab *symtab, void *data)
{
- struct linetable *linetable;
+ const struct linetable *linetable;
struct objfile *objfile;
objfile = symtab->compunit_symtab->objfile;
@@ -1017,7 +1017,7 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
for (i = 0; i < linetable->nitems; ++i)
{
- struct linetable_entry *item;
+ const struct linetable_entry *item;
item = &linetable->item [i];
printf_filtered (_("%-6d %6d %s\n"), i, item->line,
@@ -72,7 +72,7 @@
static void rbreak_command (const char *, int);
-static int find_line_common (struct linetable *, int, int *, int);
+static int find_line_common (const struct linetable *, int, int *, int);
static struct block_symbol
lookup_symbol_aux (const char *name,
@@ -3051,16 +3051,16 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
{
struct compunit_symtab *cust;
struct symtab *iter_s;
- struct linetable *l;
+ const struct linetable *l;
int len;
int i;
- struct linetable_entry *item;
+ const struct linetable_entry *item;
const struct blockvector *bv;
struct bound_minimal_symbol msymbol;
/* Info on best line seen so far, and where it starts, and its file. */
- struct linetable_entry *best = NULL;
+ const struct linetable_entry *best = NULL;
CORE_ADDR best_end = 0;
struct symtab *best_symtab = 0;
@@ -3069,12 +3069,12 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
If we don't find a line whose range contains PC,
we will use a line one less than this,
with a range from the start of that file to the first line's pc. */
- struct linetable_entry *alt = NULL;
+ const struct linetable_entry *alt = NULL;
struct symtab *alt_symtab = NULL;
/* Info on best line seen in this file. */
- struct linetable_entry *prev;
+ const struct linetable_entry *prev;
/* If this pc is not from the current frame,
it is the address of the end of a call instruction.
@@ -3224,8 +3224,8 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
return pc < LINETABLE_ENTRY_ADDRESS (iter_s, lhs);
};
- struct linetable_entry *first = item;
- struct linetable_entry *last = item + len;
+ const struct linetable_entry *first = item;
+ const struct linetable_entry *last = item + len;
item = std::upper_bound (first, last, pc, pc_compare);
if (item != first)
prev = item - 1; /* Found a matching item. */
@@ -3342,7 +3342,7 @@ find_line_symtab (struct symtab *symtab, int line,
so far seen. */
int best_index;
- struct linetable *best_linetable;
+ const struct linetable *best_linetable;
struct symtab *best_symtab;
/* First try looking it up in the given symtab. */
@@ -3381,7 +3381,7 @@ find_line_symtab (struct symtab *symtab, int line,
ALL_FILETABS (objfile, cu, s)
{
- struct linetable *l;
+ const struct linetable *l;
int ind;
if (FILENAME_CMP (symtab->filename, s->filename) != 0)
@@ -3428,11 +3428,11 @@ done:
std::vector<CORE_ADDR>
find_pcs_for_symtab_line (struct symtab *symtab, int line,
- struct linetable_entry **best_item)
+ const struct linetable_entry **best_item)
{
int start = 0;
std::vector<CORE_ADDR> result;
- struct linetable *linetable = SYMTAB_LINETABLE (symtab);
+ const struct linetable *linetable = SYMTAB_LINETABLE (symtab);
/* First, collect all the PCs that are at this line. */
while (1)
@@ -3446,7 +3446,7 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line,
if (!was_exact)
{
- struct linetable_entry *item = &linetable->item[idx];
+ const struct linetable_entry *item = &linetable->item[idx];
if (*best_item == NULL || item->line < (*best_item)->line)
*best_item = item;
@@ -3470,7 +3470,7 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line,
int
find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc)
{
- struct linetable *l;
+ const struct linetable *l;
int ind;
*pc = 0;
@@ -3535,7 +3535,7 @@ find_line_pc_range (struct symtab_and_line sal, CORE_ADDR *startptr,
Set *EXACT_MATCH nonzero if the value returned is an exact match. */
static int
-find_line_common (struct linetable *l, int lineno,
+find_line_common (const struct linetable *l, int lineno,
int *exact_match, int start)
{
int i;
@@ -3558,7 +3558,7 @@ find_line_common (struct linetable *l, int lineno,
len = l->nitems;
for (i = start; i < len; i++)
{
- struct linetable_entry *item = &(l->item[i]);
+ const struct linetable_entry *item = &(l->item[i]);
if (item->line == lineno)
{
@@ -3646,7 +3646,7 @@ static CORE_ADDR
skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
{
CORE_ADDR func_start, func_end;
- struct linetable *l;
+ const struct linetable *l;
int i;
/* Give up if this symbol has no lineinfo table. */
@@ -3665,7 +3665,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
address we are looking for. */
for (i = 0; i < l->nitems; i++)
{
- struct linetable_entry *item = &(l->item[i]);
+ const struct linetable_entry *item = &(l->item[i]);
/* Don't use line numbers of zero, they mark special entries in
the table. See the commentary on symtab.h before the
@@ -3889,7 +3889,8 @@ 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);
+ const struct linetable *linetable
+ = SYMTAB_LINETABLE (prologue_sal.symtab);
int idx = 0;
/* Skip any earlier lines, and any end-of-sequence marker
@@ -1316,7 +1316,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;
+ const struct linetable *linetable;
/* Name of this source file. This pointer is never NULL. */
@@ -2032,7 +2032,8 @@ void iterate_over_symtabs (const char *name,
std::vector<CORE_ADDR> find_pcs_for_symtab_line
- (struct symtab *symtab, int line, struct linetable_entry **best_entry);
+ (struct symtab *symtab, int line,
+ const struct linetable_entry **best_entry);
/* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS. The callback
is called once per matching symbol SYM. The callback should return