aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-value.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r--gdb/python/py-value.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 8df8a15..26d5940 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1960,6 +1960,33 @@ gdbpy_history (PyObject *self, PyObject *args)
return value_to_value_object (res_val);
}
+/* Add a gdb.Value into GDB's history, and return (as an integer) the
+ position of the newly added value. */
+PyObject *
+gdbpy_add_history (PyObject *self, PyObject *args)
+{
+ PyObject *value_obj;
+
+ if (!PyArg_ParseTuple (args, "O", &value_obj))
+ return nullptr;
+
+ struct value *value = convert_value_from_python (value_obj);
+ if (value == nullptr)
+ return nullptr;
+
+ try
+ {
+ int idx = record_latest_value (value);
+ return gdb_py_object_from_longest (idx).release ();
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ return nullptr;
+}
+
/* Return the value of a convenience variable. */
PyObject *
gdbpy_convenience_variable (PyObject *self, PyObject *args)