From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19750 invoked by alias); 15 Dec 2009 05:55:16 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 19736 invoked by uid 22791); 15 Dec 2009 05:55:14 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org From: "Matt McCormick (thewtex)" To: archer@sourceware.org Cc: "Matt McCormick (thewtex)" Subject: [PATCH 1/2] [python] Add gdb.value_history_count() Date: Tue, 15 Dec 2009 05:55:00 -0000 Message-Id: <1260856483-24773-1-git-send-email-matt@mmmccormick.com> In-Reply-To: References: X-SW-Source: 2009-q4/txt/msg00104.txt.bz2 2009-12-14 Matt McCormick * gdb/python/py-value.c (gdbpy_value_history_count): Implement gdb.value_history_count() * gdb/python/python-internal.h (thread_object): Python extension definition. * gdb/python/python.c (GdbMethods): Register in module methods. * gdb/value.c (get_value_history_count): New Function. * gdb/value.h (get_value_history_count): New Function. --- gdb/python/py-value.c | 7 +++++++ gdb/python/python-internal.h | 1 + gdb/python/python.c | 5 +++++ gdb/value.c | 6 ++++++ gdb/value.h | 4 ++++ 5 files changed, 23 insertions(+), 0 deletions(-) diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 14efd79..a607b9a 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -403,6 +403,13 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) Py_RETURN_FALSE; } +/* Implementation of gdb.value_history_count. */ +PyObject * +gdbpy_value_history_count (PyObject *self, PyObject *args) +{ + return Py_BuildValue("i", get_value_history_count()); +} + enum valpy_opcode { VALPY_ADD, diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 47662d9..8056ba8 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -93,6 +93,7 @@ PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw); PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args); PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args); PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw); +PyObject *gdbpy_value_history_count (PyObject *self, PyObject* args); PyObject *gdbpy_inferiors (PyObject *unused, PyObject *unused2); PyObject *gdbpy_selected_thread (PyObject *self, PyObject *args); diff --git a/gdb/python/python.c b/gdb/python/python.c index 707b700..debf189 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1007,6 +1007,11 @@ Return a string explaining unwind stop reason." }, "lookup_type (name [, block]) -> type\n\ Return a Type corresponding to the given name." }, + { "value_history_count", (PyCFunction) gdbpy_value_history_count, + METH_VARARGS, + "value_history_count () -> int.\n\ +Return an int corresponding to the number of entries in the value history." }, + { "lookup_symbol", (PyCFunction) gdbpy_lookup_symbol, METH_VARARGS | METH_KEYWORDS, "lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)\n\ diff --git a/gdb/value.c b/gdb/value.c index 2f31185..a9e8ec3 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -343,6 +343,12 @@ allocate_computed_value (struct type *type, /* Accessor methods. */ +int +get_value_history_count() +{ + return value_history_count; +} + struct value * value_next (struct value *value) { diff --git a/gdb/value.h b/gdb/value.h index 0da7031..cfe6618 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -48,6 +48,10 @@ struct value; struct value *value_next (struct value *); +/* Abs number of last entry stored */ + +int get_value_history_count(); + /* Type of the value. */ extern struct type *value_type (struct value *); -- 1.6.5.6