aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2026-02-20 13:18:57 -0700
committerTom Tromey <tromey@adacore.com>2026-02-23 05:29:12 -0700
commit472748485eb75a4a5744b6829e47848cba58ef59 (patch)
tree980b090d6bbb5d6deff7a66531c85dee5b603ac2 /gdb/python
parent3c21c869807427bea6b49cae7dfacbdbf979b5c0 (diff)
downloadbinutils-472748485eb75a4a5744b6829e47848cba58ef59.tar.gz
binutils-472748485eb75a4a5744b6829e47848cba58ef59.tar.bz2
binutils-472748485eb75a4a5744b6829e47848cba58ef59.zip
Return gdbpy_ref<> from symtab_to_linetable_object
This changes symtab_to_linetable_object to return a gdbpy_ref<>, using the type system to convey that a new reference is always returned. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-linetable.c4
-rw-r--r--gdb/python/py-symtab.c2
-rw-r--r--gdb/python/python-internal.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 384ced68a32..2afa9b033e7 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -77,7 +77,7 @@ get_symtab (PyObject *linetable)
/* Helper function to create a line table object that wraps a
gdb.Symtab object. */
-PyObject *
+gdbpy_ref<>
symtab_to_linetable_object (PyObject *symtab)
{
linetable_object *ltable;
@@ -88,7 +88,7 @@ symtab_to_linetable_object (PyObject *symtab)
ltable->symtab = symtab;
Py_INCREF (symtab);
}
- return (PyObject *) ltable;
+ return gdbpy_ref<> (ltable);
}
/* Internal helper function to build a line table object from a line
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 550f287a6ee..ed5abac1372 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -220,7 +220,7 @@ stpy_get_linetable (PyObject *self, PyObject *args)
STPY_REQUIRE_VALID (self, symtab);
- return symtab_to_linetable_object (self);
+ return symtab_to_linetable_object (self).release ();
}
static PyObject *
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 0b816db196f..85f7f1f4dd1 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -503,7 +503,7 @@ gdbpy_ref<> block_to_block_object (const struct block *block,
gdbpy_ref<> value_to_value_object (struct value *v);
gdbpy_ref<> type_to_type_object (struct type *);
gdbpy_ref<> frame_info_to_frame_object (const frame_info_ptr &frame);
-PyObject *symtab_to_linetable_object (PyObject *symtab);
+gdbpy_ref<> symtab_to_linetable_object (PyObject *symtab);
gdbpy_ref<> pspace_to_pspace_object (struct program_space *);
PyObject *pspy_get_printers (PyObject *, void *);
PyObject *pspy_get_frame_filters (PyObject *, void *);