aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-03-07 18:16:29 -0700
committerTom Tromey <tom@tromey.com>2023-03-11 08:48:10 -0700
commit977a0c161de83a5e5397f9f7950d58173c4b4be2 (patch)
tree5264db12f959dba8dfddaac35b4008ee02a4253a /gdb/python
parent1acc9dca423f78e44553928f0de839b618c13766 (diff)
downloadbinutils-977a0c161de83a5e5397f9f7950d58173c4b4be2.zip
binutils-977a0c161de83a5e5397f9f7950d58173c4b4be2.tar.gz
binutils-977a0c161de83a5e5397f9f7950d58173c4b4be2.tar.bz2
Constify linetables
Linetables no longer change after they are created. This patch applies const to them. Note there is one hack to cast away const in mdebugread.c. This code allocates a linetable using 'malloc', then later copies it to the obstack. While this could be cleaned up, I chose not to do so because I have no way of testing it. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-linetable.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index e42bcc2..6e89c43 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -156,7 +156,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 linetable_entry *best_entry = nullptr;
std::vector<CORE_ADDR> pcs;
LTPY_REQUIRE_VALID (self, symtab);
@@ -201,7 +201,7 @@ ltpy_has_line (PyObject *self, PyObject *args)
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;
}
@@ -219,7 +219,6 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
{
struct symtab *symtab;
Py_ssize_t index;
- struct linetable_entry *item;
LTPY_REQUIRE_VALID (self, symtab);
@@ -236,7 +235,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
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. */
@@ -395,7 +394,6 @@ ltpy_iternext (PyObject *self)
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);
@@ -405,7 +403,8 @@ ltpy_iternext (PyObject *self)
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. */