aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-value.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-01-26 20:53:45 +0000
committerTom Tromey <tromey@redhat.com>2011-01-26 20:53:45 +0000
commit74aedc4602913e330a1ec0cf5e9b8c8fe2b19a48 (patch)
treec62ace6e4f31af6c12769e075478bd76c3070534 /gdb/python/py-value.c
parent6ec8b48eb879136808e264dc6a41cffed5e0133b (diff)
downloadbinutils-74aedc4602913e330a1ec0cf5e9b8c8fe2b19a48.zip
binutils-74aedc4602913e330a1ec0cf5e9b8c8fe2b19a48.tar.gz
binutils-74aedc4602913e330a1ec0cf5e9b8c8fe2b19a48.tar.bz2
* python/python.c (gdbpy_solib_name): Use gdb_py_longest and
GDB_PY_LL_ARG. * python/python-internal.h (GDB_PY_LL_ARG, GDB_PY_LLU_ARG): New macros. (gdb_py_longest, gdb_py_ulongest): New typedefs. (gdb_py_long_from_longest, gdb_py_long_from_ulongest) (gdb_py_long_as_ulongest): New defines. (gdb_py_object_from_longest, gdb_py_object_from_ulongest) (gdb_py_int_as_long): Declare. * python/py-value.c (valpy_lazy_string): Use gdb_py_longest, GDB_PY_LL_ARG, gdb_py_object_from_longest. (valpy_long): Add comment. * python/py-utils.c (get_addr_from_python): Use gdb_py_long_as_ulongest. Handle overflow properly. (gdb_py_object_from_longest): New function. (gdb_py_object_from_ulongest): Likewise. (gdb_py_int_as_long): Likewise. * python/py-type.c (typy_array): Use gdb_py_int_as_long. * python/py-symtab.c (salpy_get_pc): Use gdb_py_long_from_ulongest. (salpy_get_line): Use PyInt_FromLong. * python/py-param.c (set_parameter_value): Use gdb_py_int_as_long. * python/py-lazy-string.c (stpy_get_address): Use gdb_py_long_from_ulongest. * python/py-frame.c (frapy_pc): Use gdb_py_long_from_ulongest. * python/py-cmd.c (cmdpy_completer): Use gdb_py_int_as_long. * python/py-breakpoint.c (bppy_set_thread): Use gdb_py_int_as_long. (bppy_set_task): Likewise. (bppy_set_ignore_count): Likewise. (bppy_set_hit_count): Likewise. * python/py-block.c (blpy_get_start): Use gdb_py_object_from_ulongest. (blpy_get_end): Likewise. (gdbpy_block_for_pc): Use gdb_py_ulongest and GDB_PY_LLU_ARG.
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r--gdb/python/py-value.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 1aa9443..27bf101 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -307,13 +307,13 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
static PyObject *
valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
{
- int length = -1;
+ gdb_py_longest length = -1;
struct value *value = ((value_object *) self)->value;
const char *user_encoding = NULL;
static char *keywords[] = { "encoding", "length", NULL };
PyObject *str_obj;
- if (!PyArg_ParseTupleAndKeywords (args, kw, "|si", keywords,
+ if (!PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG, keywords,
&user_encoding, &length))
return NULL;
@@ -987,14 +987,7 @@ valpy_int (PyObject *self)
}
GDB_PY_HANDLE_EXCEPTION (except);
-#ifdef HAVE_LONG_LONG /* Defined by Python. */
- /* If we have 'long long', and the value overflows a 'long', use a
- Python Long; otherwise use a Python Int. */
- if (sizeof (l) > sizeof (long) && (l > PyInt_GetMax ()
- || l < (- (LONGEST) PyInt_GetMax ()) - 1))
- return PyLong_FromLongLong (l);
-#endif
- return PyInt_FromLong (l);
+ return gdb_py_object_from_longest (l);
}
/* Implements conversion to long. */
@@ -1019,11 +1012,7 @@ valpy_long (PyObject *self)
}
GDB_PY_HANDLE_EXCEPTION (except);
-#ifdef HAVE_LONG_LONG /* Defined by Python. */
- return PyLong_FromLongLong (l);
-#else
- return PyLong_FromLong (l);
-#endif
+ return gdb_py_long_from_longest (l);
}
/* Implements conversion to float. */