size_t entry_array_size = n_entries * sizeof (struct linetable_entry);
int linetablesize = sizeof (struct linetable) + entry_array_size;
- symtab->set_linetable
- (XOBNEWVAR (&m_objfile->objfile_obstack, struct linetable,
- linetablesize));
+ struct linetable *new_table
+ = XOBNEWVAR (&m_objfile->objfile_obstack, struct linetable,
+ linetablesize);
- symtab->linetable ()->nitems = n_entries;
- memcpy (symtab->linetable ()->item,
+ new_table->nitems = n_entries;
+ memcpy (new_table->item,
subfile->line_vector_entries.data (), entry_array_size);
+
+ symtab->set_linetable (new_table);
}
else
symtab->set_linetable (nullptr);
{
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;
size_t size = ((stab->linetable->nitems - 1)
* sizeof (struct linetable_entry)
+ sizeof (struct linetable));
- filetab->set_linetable ((struct linetable *)
- obstack_alloc (&objfile->objfile_obstack, size));
- memcpy (filetab->linetable (), stab->linetable.get (), size);
+ struct linetable *new_table
+ = (struct linetable *) obstack_alloc (&objfile->objfile_obstack,
+ size);
+ memcpy (new_table, stab->linetable.get (), size);
+ filetab->set_linetable (new_table);
}
blockvector_size = (sizeof (struct blockvector)
(struct linespec_state *self,
linespec *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,
values = decode_digits_list_mode (self, ls, val);
else
{
- struct linetable_entry *best_entry = NULL;
+ const linetable_entry *best_entry = NULL;
int i, j;
std::vector<symtab_and_line> intermediate_results
decode_digits_ordinary (struct linespec_state *self,
linespec *ls,
int line,
- struct linetable_entry **best_entry)
+ const linetable_entry **best_entry)
{
std::vector<symtab_and_line> sals;
for (const auto &elt : ls->file_symtabs)
psymtab_language = cust->primary_filetab ()->language ();
- lines = cust->primary_filetab ()->linetable ();
+ /* This code allocates the line table on the heap and then later
+ copies it to the obstack. So, while casting away const here
+ is ugly, it's not incorrect. */
+ lines = const_cast<linetable *> (cust->primary_filetab ()->linetable ());
/* Get a new lexical context. */
{
struct symtab *symtab;
gdb_py_longest py_line;
- struct linetable_entry *best_entry = NULL;
+ const linetable_entry *best_entry = nullptr;
std::vector<CORE_ADDR> pcs;
LTPY_REQUIRE_VALID (self, symtab);
for (index = 0; index < symtab->linetable ()->nitems; index++)
{
- struct linetable_entry *item = &(symtab->linetable ()->item[index]);
+ const linetable_entry *item = &(symtab->linetable ()->item[index]);
if (item->line == py_line)
Py_RETURN_TRUE;
}
{
struct symtab *symtab;
Py_ssize_t index;
- struct linetable_entry *item;
LTPY_REQUIRE_VALID (self, symtab);
for (index = 0; index < symtab->linetable ()->nitems; index++)
{
- item = &(symtab->linetable ()->item[index]);
+ const linetable_entry *item = &(symtab->linetable ()->item[index]);
/* 0 is used to signify end of line table information. Do not
include in the source set. */
ltpy_iterator_object *iter_obj = (ltpy_iterator_object *) self;
struct symtab *symtab;
PyObject *obj;
- struct linetable_entry *item;
LTPY_REQUIRE_VALID (iter_obj->source, symtab);
return NULL;
}
- item = &(symtab->linetable ()->item[iter_obj->current_index]);
+ const linetable_entry *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. */
btrace_find_line_range (CORE_ADDR pc)
{
struct btrace_line_range range;
- struct linetable_entry *lines;
- struct linetable *ltable;
+ const linetable_entry *lines;
+ const linetable *ltable;
struct symtab *symtab;
int nlines, i;
struct objfile *objfile = symtab->compunit ()->objfile ();
struct gdbarch *gdbarch = objfile->arch ();
struct mdict_iterator miter;
- struct linetable *l;
+ const struct linetable *l;
struct symbol *sym;
int depth;
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 ()->objfile ();
for (int i = 0; i < linetable->nitems; ++i)
{
- struct linetable_entry *item;
+ const linetable_entry *item;
item = &linetable->item [i];
ui_out_emit_tuple tuple_emitter (uiout, nullptr);
static void rbreak_command (const char *, int);
-static int find_line_common (struct linetable *, int, int *, int);
+static int find_line_common (const linetable *, int, int *, int);
static struct block_symbol
lookup_symbol_aux (const char *name,
find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
{
struct compunit_symtab *cust;
- struct linetable *l;
+ const linetable *l;
int len;
- struct linetable_entry *item;
+ const 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 linetable_entry *best = NULL;
CORE_ADDR best_end = 0;
struct symtab *best_symtab = 0;
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 linetable_entry *alt = NULL;
/* Info on best line seen in this file. */
- struct linetable_entry *prev;
+ const linetable_entry *prev;
/* If this pc is not from the current frame,
it is the address of the end of a call instruction.
return comp_pc < lhs.raw_pc ();
};
- struct linetable_entry *first = item;
- struct linetable_entry *last = item + len;
+ const linetable_entry *first = item;
+ const linetable_entry *last = item + len;
item = std::upper_bound (first, last,
pc - objfile->text_section_offset (),
pc_compare);
pretty cheap. */
if (!best->is_stmt)
{
- struct linetable_entry *tmp = best;
+ const linetable_entry *tmp = best;
while (tmp > first && (tmp - 1)->raw_pc () == tmp->raw_pc ()
&& (tmp - 1)->line != 0 && !tmp->is_stmt)
--tmp;
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. */
{
for (symtab *s : cu->filetabs ())
{
- struct linetable *l;
+ const struct linetable *l;
int ind;
if (FILENAME_CMP (sym_tab->filename, s->filename) != 0)
std::vector<CORE_ADDR>
find_pcs_for_symtab_line (struct symtab *symtab, int line,
- struct linetable_entry **best_item)
+ const linetable_entry **best_item)
{
int start = 0;
std::vector<CORE_ADDR> result;
if (!was_exact)
{
- struct linetable_entry *item = &symtab->linetable ()->item[idx];
+ const linetable_entry *item = &symtab->linetable ()->item[idx];
if (*best_item == NULL
|| (item->line < (*best_item)->line && item->is_stmt))
bool
find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc)
{
- struct linetable *l;
+ const struct linetable *l;
int ind;
*pc = 0;
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 linetable *l, int lineno,
int *exact_match, int start)
{
int i;
len = l->nitems;
for (i = start; i < len; i++)
{
- struct linetable_entry *item = &(l->item[i]);
+ const linetable_entry *item = &(l->item[i]);
/* Ignore non-statements. */
if (!item->is_stmt)
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. */
address we are looking for. */
for (i = 0; i < l->nitems; i++)
{
- struct linetable_entry *item = &(l->item[i]);
+ const linetable_entry *item = &(l->item[i]);
CORE_ADDR item_pc = item->pc (objfile);
/* Don't use line numbers of zero, they mark special entries in
if (prologue_sal.symtab != nullptr
&& prologue_sal.symtab->language () != language_asm)
{
- struct linetable *linetable = prologue_sal.symtab->linetable ();
+ const linetable *linetable = prologue_sal.symtab->linetable ();
struct objfile *objfile = prologue_sal.symtab->compunit ()->objfile ();
start_pc -= objfile->text_section_offset ();
{
struct objfile *objfile
= prologue_sal.symtab->compunit ()->objfile ();
- struct linetable *linetable = prologue_sal.symtab->linetable ();
+ const linetable *linetable = prologue_sal.symtab->linetable ();
int idx = 0;
/* Skip any earlier lines, and any end-of-sequence marker
m_compunit = compunit;
}
- struct linetable *linetable () const
+ const struct linetable *linetable () const
{
return m_linetable;
}
- void set_linetable (struct linetable *linetable)
+ void set_linetable (const struct linetable *linetable)
{
m_linetable = linetable;
}
/* Table mapping core addresses to line numbers for this file.
Can be NULL if none. Never shared between different symtabs. */
- struct linetable *m_linetable;
+ const struct linetable *m_linetable;
/* Name of this source file, in a form appropriate to print to the user.
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 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