summaryrefslogtreecommitdiff
path: root/gdb/python/py-value.c
diff options
context:
space:
mode:
authorpmuldoon <pmuldoon>2010-06-28 21:16:01 +0000
committerpmuldoon <pmuldoon>2010-06-28 21:16:01 +0000
commit1371a50ec70573353e400b3a0075cfff12edfe87 (patch)
tree161037f5740b13f5ff5f63c4b8137f045eb77f94 /gdb/python/py-value.c
parent758a1f7149cb7469c7e6bb30cb572715ee90a6e8 (diff)
downloadgdb-1371a50ec70573353e400b3a0075cfff12edfe87.tar.gz
2010-06-28 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> * value.c (pack_unsigned_long): New function. (value_from_ulongest): New function. * value.h (value_from_ulongest): Declare. * python/python.c (_initialize_python): Call gdbpy_initialize_thread and gdbpy_initialize_inferior. * python/python-internal.h: Define thread_object. (gdbpy_inferiors, gdbpy_selected_thread) (frame_info_to_frame_object, create_thread_object) (find_thread_object, find_inferior_object) (gdbpy_initialize_thread, gdbpy_initialize_inferiors) (gdbpy_is_value_object, get_addr_from_python): Declare. * python/py-value.c (builtin_type_upylong): Define. (convert_value_from_python): Add logic for ulongest. (gdbpy_is_value_object): New function. * python/py-utils.c (get_addr_from_python): New function. * python/py-frame.c (frame_info_to_frame_object): Return a PyObject. (gdbpy_selected_frame): Use PyObject over frame_info. * Makefile.in (SUBDIR_PYTHON_OBS): Add py-inferior and py-infthread. (SUBDIR_PYTHON_SRCS): Likewise. (py-inferior.o): New Rule. (py-infthread.o): New Rule. * python/py-inferior.c: New File. * python/py-infthread.c: New File. 2010-06-28 Phil Muldoon <pmuldoon@redhat.com> Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> * gdb.texinfo (Inferiors In Python): New node. * gdb.texinfo (Threads In Python): New node. 2010-06-28 Phil Muldoon <pmuldoon@redhat.com> Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> * gdb.python/py-inferior.c: New File. * gdb.python/py-infthread.c: New File. * gdb.python/py-inferior.exp: New File. * gdb.python/py-infthread.exp: New File.
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r--gdb/python/py-value.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index eb20de8cf2f..2024021ac11 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -43,6 +43,10 @@
/* Python's long type corresponds to C's long long type. */
#define builtin_type_pylong builtin_type (python_gdbarch)->builtin_long_long
+/* Python's long type corresponds to C's long long type. Unsigned version. */
+#define builtin_type_upylong builtin_type \
+ (python_gdbarch)->builtin_unsigned_long_long
+
#define builtin_type_pybool \
language_bool_type (python_language, python_gdbarch)
@@ -961,7 +965,34 @@ convert_value_from_python (PyObject *obj)
{
LONGEST l = PyLong_AsLongLong (obj);
- if (! PyErr_Occurred ())
+ if (PyErr_Occurred ())
+ {
+ /* If the error was an overflow, we can try converting to
+ ULONGEST instead. */
+ if (PyErr_ExceptionMatches (PyExc_OverflowError))
+ {
+ PyObject *etype, *evalue, *etraceback, *zero;
+
+ PyErr_Fetch (&etype, &evalue, &etraceback);
+ zero = PyInt_FromLong (0);
+
+ /* Check whether obj is positive. */
+ if (PyObject_RichCompareBool (obj, zero, Py_GT) > 0)
+ {
+ ULONGEST ul;
+
+ ul = PyLong_AsUnsignedLongLong (obj);
+ if (! PyErr_Occurred ())
+ value = value_from_ulongest (builtin_type_upylong, ul);
+ }
+ else
+ /* There's nothing we can do. */
+ PyErr_Restore (etype, evalue, etraceback);
+
+ Py_DECREF (zero);
+ }
+ }
+ else
value = value_from_longest (builtin_type_pylong, l);
}
else if (PyFloat_Check (obj))
@@ -1028,6 +1059,14 @@ gdbpy_history (PyObject *self, PyObject *args)
return value_to_value_object (res_val);
}
+/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise. */
+
+int
+gdbpy_is_value_object (PyObject *obj)
+{
+ return PyObject_TypeCheck (obj, &value_object_type);
+}
+
void
gdbpy_initialize_values (void)
{