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
This commit is contained in:
Simon Marchi 2021-11-20 08:40:12 -05:00 committed by Simon Marchi
parent c615965258
commit 5b6074611e
11 changed files with 64 additions and 57 deletions

View file

@ -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);