integer, the index of the new item in the history list, is
returned.
+ ** New function gdb.history_count(), which returns the number of
+ values in GDB's value history.
+
** New gdb.events.gdb_exiting event. This event is called with a
gdb.GdbExitingEvent object which has the read-only attribute
'exit_code', which contains the value of the GDB exit code. This
user convenient access to those values via CLI history facilities.
@end defun
+@defun gdb.history_count ()
+Return an integer indicating the number of values in @value{GDBN}'s
+value history (@pxref{Value History}).
+@end defun
+
@findex gdb.convenience_variable
@defun gdb.convenience_variable (name)
Return the value of the convenience variable (@pxref{Convenience
return nullptr;
}
+/* Return an integer, the number of items in GDB's history. */
+
+PyObject *
+gdbpy_history_count (PyObject *self, PyObject *args)
+{
+ return gdb_py_object_from_ulongest (value_history_count ()).release ();
+}
+
/* Return the value of a convenience variable. */
PyObject *
gdbpy_convenience_variable (PyObject *self, PyObject *args)
\f
PyObject *gdbpy_history (PyObject *self, PyObject *args);
PyObject *gdbpy_add_history (PyObject *self, PyObject *args);
+extern PyObject *gdbpy_history_count (PyObject *self, PyObject *args);
PyObject *gdbpy_convenience_variable (PyObject *self, PyObject *args);
PyObject *gdbpy_set_convenience_variable (PyObject *self, PyObject *args);
PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
"Get a value from history" },
{ "add_history", gdbpy_add_history, METH_VARARGS,
"Add a value to the value history list" },
+ { "history_count", gdbpy_history_count, METH_NOARGS,
+ "Return an integer, the number of values in GDB's value history" },
{ "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS,
"execute (command [, from_tty] [, to_string]) -> [String]\n\
Evaluate command, a string, as a gdb CLI command. Optionally returns\n\
"check printing of MyValue when initiaized with a type"
}
+# Test the history count. This must be the first thing called after
+# starting GDB as it depends on there being nothing in the value
+# history.
+proc test_history_count {} {
+ for { set i 0 } { $i < 5 } { incr i } {
+ gdb_test "python print('history count is %d' % gdb.history_count())" \
+ "history count is $i" "history count is $i"
+ gdb_test "print $i" " = $i"
+ }
+}
+
# Build C version of executable. C++ is built later.
if { [build_inferior "${binfile}" "c"] < 0 } {
return -1
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
+test_history_count
test_value_creation
test_value_reinit
test_value_numeric_ops
return value_copy (value_history[absnum].get ());
}
+/* See value.h. */
+
+ULONGEST
+value_history_count ()
+{
+ return value_history.size ();
+}
+
static void
show_values (const char *num_exp, int from_tty)
{
extern struct value *access_value_history (int num);
+/* Return the number of items in the value history. */
+
+extern ULONGEST value_history_count ();
+
extern struct value *value_of_internalvar (struct gdbarch *gdbarch,
struct internalvar *var);