* 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.
This commit is contained in:
Tom Tromey 2011-01-26 20:53:45 +00:00
parent 6ec8b48eb8
commit 74aedc4602
13 changed files with 184 additions and 78 deletions

View file

@ -211,7 +211,7 @@ static int
bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
{
breakpoint_object *self_bp = (breakpoint_object *) self;
int id;
long id;
BPPY_SET_REQUIRE_VALID (self_bp);
@ -223,7 +223,9 @@ bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
}
else if (PyInt_Check (newvalue))
{
id = (int) PyInt_AsLong (newvalue);
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
if (! valid_thread_id (id))
{
PyErr_SetString (PyExc_RuntimeError,
@ -250,7 +252,7 @@ static int
bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
{
breakpoint_object *self_bp = (breakpoint_object *) self;
int id;
long id;
BPPY_SET_REQUIRE_VALID (self_bp);
@ -262,7 +264,9 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
}
else if (PyInt_Check (newvalue))
{
id = (int) PyInt_AsLong (newvalue);
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
if (! valid_task_id (id))
{
PyErr_SetString (PyExc_RuntimeError,
@ -324,7 +328,9 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
return -1;
}
value = PyInt_AsLong (newvalue);
if (! gdb_py_int_as_long (newvalue, &value))
return -1;
if (value < 0)
value = 0;
set_ignore_count (self_bp->number, (int) value, 0);
@ -346,11 +352,19 @@ bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
_("Cannot delete `hit_count' attribute."));
return -1;
}
else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0)
else
{
PyErr_SetString (PyExc_AttributeError,
_("The value of `hit_count' must be zero."));
return -1;
long value;
if (! gdb_py_int_as_long (newvalue, &value))
return -1;
if (value != 0)
{
PyErr_SetString (PyExc_AttributeError,
_("The value of `hit_count' must be zero."));
return -1;
}
}
self_bp->bp->hit_count = 0;