aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2026-02-20 13:20:56 -0700
committerTom Tromey <tromey@adacore.com>2026-02-23 05:29:12 -0700
commita93acde059bbdfc038fff232c834a58b3835bdcf (patch)
tree3302825f30036f98b533856d166228cc6d298546 /gdb/python
parent472748485eb75a4a5744b6829e47848cba58ef59 (diff)
downloadfsf-binutils-gdb-a93acde059bbdfc038fff232c834a58b3835bdcf.zip
fsf-binutils-gdb-a93acde059bbdfc038fff232c834a58b3835bdcf.tar.gz
fsf-binutils-gdb-a93acde059bbdfc038fff232c834a58b3835bdcf.tar.bz2
Return gdbpy_ref<> from gdbarch_to_arch_object
This changes gdbarch_to_arch_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-arch.c4
-rw-r--r--gdb/python/py-disasm.c2
-rw-r--r--gdb/python/py-frame.c2
-rw-r--r--gdb/python/py-inferior.c2
-rw-r--r--gdb/python/py-unwind.c2
-rw-r--r--gdb/python/python-internal.h2
-rw-r--r--gdb/python/python.c2
7 files changed, 8 insertions, 8 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index cf74082..f40d7da 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -84,7 +84,7 @@ gdbpy_is_architecture (PyObject *obj)
Returns a new reference to the arch_object associated as data with
GDBARCH. */
-PyObject *
+gdbpy_ref<>
gdbarch_to_arch_object (struct gdbarch *gdbarch)
{
PyObject *new_ref = arch_object_data.get (gdbarch);
@@ -97,7 +97,7 @@ gdbarch_to_arch_object (struct gdbarch *gdbarch)
/* new_ref could be NULL if creation failed. */
Py_XINCREF (new_ref);
- return new_ref;
+ return gdbpy_ref<> (new_ref);
}
/* Implementation of gdb.Architecture.name (self) -> String.
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 9f5d0e2..748ffd5 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -699,7 +699,7 @@ disasmpy_info_architecture (PyObject *self, void *closure)
{
disasm_info_object *obj = (disasm_info_object *) self;
DISASMPY_DISASM_INFO_REQUIRE_VALID (obj);
- return gdbarch_to_arch_object (obj->gdbarch);
+ return gdbarch_to_arch_object (obj->gdbarch).release ();
}
/* Implement DisassembleInfo.progspace attribute. Return the
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index bba0b29..9d122f1 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -201,7 +201,7 @@ frapy_arch (PyObject *self, PyObject *args)
return gdbpy_handle_gdb_exception (nullptr, except);
}
- return gdbarch_to_arch_object (obj->gdbarch);
+ return gdbarch_to_arch_object (obj->gdbarch).release ();
}
/* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 53f3344..fd9da27 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -778,7 +778,7 @@ infpy_architecture (PyObject *self, PyObject *args)
INFPY_REQUIRE_VALID (inf);
- return gdbarch_to_arch_object (inf->inferior->arch ());
+ return gdbarch_to_arch_object (inf->inferior->arch ()).release ();
}
/* Implement repr() for gdb.Inferior. */
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 277e8d2..d160db1 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -762,7 +762,7 @@ pending_framepy_architecture (PyObject *self, PyObject *args)
PENDING_FRAMEPY_REQUIRE_VALID (pending_frame);
- return gdbarch_to_arch_object (pending_frame->gdbarch);
+ return gdbarch_to_arch_object (pending_frame->gdbarch).release ();
}
/* Implementation of PendingFrame.level (self) -> Integer. */
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 85f7f1f..1f0964f 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -517,7 +517,7 @@ PyObject *objfpy_get_frame_unwinders (PyObject *, void *);
PyObject *objfpy_get_xmethods (PyObject *, void *);
PyObject *gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw);
-PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch);
+gdbpy_ref<> gdbarch_to_arch_object (struct gdbarch *gdbarch);
PyObject *gdbpy_all_architecture_names (PyObject *self, PyObject *args);
PyObject *gdbpy_new_register_descriptor_iterator (struct gdbarch *gdbarch,
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 9862d1a..8739864 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1421,7 +1421,7 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
return {};
}
- gdbpy_ref<> gdbarch_arg (gdbarch_to_arch_object (gdbarch));
+ gdbpy_ref<> gdbarch_arg = gdbarch_to_arch_object (gdbarch);
if (gdbarch_arg == nullptr)
{
gdbpy_print_stack ();