aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPaul Koning <pkoning@equallogic.com>2011-10-25 18:34:51 +0000
committerPaul Koning <pkoning@equallogic.com>2011-10-25 18:34:51 +0000
commit913460fcdec816bfc5b72c9f48b46481a418cba1 (patch)
tree4d95a5fd07d2a95e89153573ddd4679fffb4db0f /gdb
parentdb5d0b26be0bd4b367289365d3dfe77d2f55dcfd (diff)
downloadbinutils-913460fcdec816bfc5b72c9f48b46481a418cba1.zip
binutils-913460fcdec816bfc5b72c9f48b46481a418cba1.tar.gz
binutils-913460fcdec816bfc5b72c9f48b46481a418cba1.tar.bz2
PR python/13327
* python/py-value.c (value_to_value_object): Remove fetching of the value if it was lazy. (valpy_get_is_lazy): New function. (valpy_fetch_lazy): New function.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/python/py-value.c51
2 files changed, 52 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f5cdd45..f8aa187 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2011-10-25 Paul Koning <paul_koning@dell.com>
+
+ PR python/13327
+
+ * python/py-value.c (value_to_value_object): Remove fetching of
+ the value if it was lazy.
+ (valpy_get_is_lazy): New function.
+ (valpy_fetch_lazy): New function.
+
2011-10-24 Joel Brobecker <brobecker@adacore.com>
* ppc-sysv-tdep.c (do_ppc_sysv_return_value): Do not check
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index d22fb06..15c183a 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -617,6 +617,43 @@ valpy_get_is_optimized_out (PyObject *self, void *closure)
Py_RETURN_FALSE;
}
+/* Implements gdb.Value.is_lazy. */
+static PyObject *
+valpy_get_is_lazy (PyObject *self, void *closure)
+{
+ struct value *value = ((value_object *) self)->value;
+ int opt = 0;
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ opt = value_lazy (value);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
+ if (opt)
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
+}
+
+/* Implements gdb.Value.fetch_lazy (). */
+static PyObject *
+valpy_fetch_lazy (PyObject *self, PyObject *args)
+{
+ struct value *value = ((value_object *) self)->value;
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ if (value_lazy (value))
+ value_fetch_lazy (value);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
+ Py_RETURN_NONE;
+}
+
/* Calculate and return the address of the PyObject as the value of
the builtin __hash__ call. */
static long
@@ -1081,15 +1118,7 @@ PyObject *
value_to_value_object (struct value *val)
{
value_object *val_obj;
- volatile struct gdb_exception except;
- TRY_CATCH (except, RETURN_MASK_ALL)
- {
- if (value_lazy (val))
- value_fetch_lazy (val);
- }
- GDB_PY_HANDLE_EXCEPTION (except);
-
val_obj = PyObject_New (value_object, &value_object_type);
if (val_obj != NULL)
{
@@ -1276,6 +1305,10 @@ static PyGetSetDef value_object_getset[] = {
{ "type", valpy_get_type, NULL, "Type of the value.", NULL },
{ "dynamic_type", valpy_get_dynamic_type, NULL,
"Dynamic type of the value.", NULL },
+ { "is_lazy", valpy_get_is_lazy, NULL,
+ "Boolean telling whether the value is lazy (not fetched yet\n\
+from the inferior). A lazy value is fetched when needed, or when\n\
+the \"fetch_lazy()\" method is called.", NULL },
{NULL} /* Sentinel */
};
@@ -1298,6 +1331,8 @@ Return a lazy string representation of the value." },
{ "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
"string ([encoding] [, errors] [, length]) -> string\n\
Return Unicode string representation of the value." },
+ { "fetch_lazy", valpy_fetch_lazy, METH_NOARGS,
+ "Fetches the value from the inferior, if it was lazy." },
{NULL} /* Sentinel */
};