* python/py-breakpoint.c (bppy_set_enabled): Use TRY_CATCH.
(bppy_set_task): Ditto.
(bppy_delete_breakpoint): Ditto.
* python/py-symbol.c (gdbpy_lookup_symbol): Ditto.
(gdbpy_lookup_global_symbol): Ditto.
* python/py-lazy-string.c (stpy_convert_to_value): Ditto.
* python/py-frame.c (frapy_is_valid): Ditto.
(frame_info_to_frame_object): Ditto.
* python/py-type.c (typy_lookup_type): Ditto.
(typy_getitem): Ditto.
(typy_has_key): Ditto.
(typy_richcompare): Use TRY_CATCH. Do not return Py_NE on error.
+2011-10-27 Phil Muldoon <pmuldoon@redhat.com>
+
+ * python/py-breakpoint.c (bppy_set_enabled): Use TRY_CATCH.
+ (bppy_set_task): Ditto.
+ (bppy_delete_breakpoint): Ditto.
+ * python/py-symbol.c (gdbpy_lookup_symbol): Ditto.
+ (gdbpy_lookup_global_symbol): Ditto.
+ * python/py-lazy-string.c (stpy_convert_to_value): Ditto.
+ * python/py-frame.c (frapy_is_valid): Ditto.
+ (frame_info_to_frame_object): Ditto.
+ * python/py-type.c (typy_lookup_type): Ditto.
+ (typy_getitem): Ditto.
+ (typy_has_key): Ditto.
+ (typy_richcompare): Use TRY_CATCH. Do not return Py_NE on error.
+
2011-10-26 Joel Brobecker <brobecker@adacore.com>
* gdbarch.h: Regenerate.
{
breakpoint_object *self_bp = (breakpoint_object *) self;
int cmp;
+ volatile struct gdb_exception except;
BPPY_SET_REQUIRE_VALID (self_bp);
cmp = PyObject_IsTrue (newvalue);
if (cmp < 0)
return -1;
- else if (cmp == 1)
- enable_breakpoint (self_bp->bp);
- else
- disable_breakpoint (self_bp->bp);
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ if (cmp == 1)
+ enable_breakpoint (self_bp->bp);
+ else
+ disable_breakpoint (self_bp->bp);
+ }
+ GDB_PY_SET_HANDLE_EXCEPTION (except);
+
return 0;
}
{
breakpoint_object *self_bp = (breakpoint_object *) self;
long id;
+ int valid_id = 0;
+ volatile struct gdb_exception except;
BPPY_SET_REQUIRE_VALID (self_bp);
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
- if (! valid_task_id (id))
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ valid_id = valid_task_id (id);
+ }
+ GDB_PY_SET_HANDLE_EXCEPTION (except);
+
+ if (! valid_id)
{
PyErr_SetString (PyExc_RuntimeError,
_("Invalid task ID."));
bppy_delete_breakpoint (PyObject *self, PyObject *args)
{
breakpoint_object *self_bp = (breakpoint_object *) self;
+ volatile struct gdb_exception except;
BPPY_REQUIRE_VALID (self_bp);
- delete_breakpoint (self_bp->bp);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ delete_breakpoint (self_bp->bp);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
Py_RETURN_NONE;
}
static PyObject *
frapy_is_valid (PyObject *self, PyObject *args)
{
- struct frame_info *frame;
+ struct frame_info *frame = NULL;
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ frame = frame_object_to_frame_info ((frame_object *) self);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
- frame = frame_object_to_frame_info ((frame_object *) self);
if (frame == NULL)
Py_RETURN_FALSE;
frame_info_to_frame_object (struct frame_info *frame)
{
frame_object *frame_obj;
+ volatile struct gdb_exception except;
frame_obj = PyObject_New (frame_object, &frame_object_type);
if (frame_obj == NULL)
return NULL;
}
- /* Try to get the previous frame, to determine if this is the last frame
- in a corrupt stack. If so, we need to store the frame_id of the next
- frame and not of this one (which is possibly invalid). */
- if (get_prev_frame (frame) == NULL
- && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
- && get_next_frame (frame) != NULL)
- {
- frame_obj->frame_id = get_frame_id (get_next_frame (frame));
- frame_obj->frame_id_is_next = 1;
- }
- else
+ TRY_CATCH (except, RETURN_MASK_ALL)
{
- frame_obj->frame_id = get_frame_id (frame);
- frame_obj->frame_id_is_next = 0;
- }
- frame_obj->gdbarch = get_frame_arch (frame);
+ /* Try to get the previous frame, to determine if this is the last frame
+ in a corrupt stack. If so, we need to store the frame_id of the next
+ frame and not of this one (which is possibly invalid). */
+ if (get_prev_frame (frame) == NULL
+ && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
+ && get_next_frame (frame) != NULL)
+ {
+ frame_obj->frame_id = get_frame_id (get_next_frame (frame));
+ frame_obj->frame_id_is_next = 1;
+ }
+ else
+ {
+ frame_obj->frame_id = get_frame_id (frame);
+ frame_obj->frame_id_is_next = 0;
+ }
+ frame_obj->gdbarch = get_frame_arch (frame);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
return (PyObject *) frame_obj;
}
stpy_convert_to_value (PyObject *self, PyObject *args)
{
lazy_string_object *self_string = (lazy_string_object *) self;
- struct value *val;
+ struct value *val = NULL;
+ volatile struct gdb_exception except;
if (self_string->address == 0)
{
return NULL;
}
- val = value_at_lazy (self_string->type, self_string->address);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ val = value_at_lazy (self_string->type, self_string->address);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
return value_to_value_object (val);
}
int domain = VAR_DOMAIN, is_a_field_of_this = 0;
const char *name;
static char *keywords[] = { "name", "block", "domain", NULL };
- struct symbol *symbol;
+ struct symbol *symbol = NULL;
PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj;
const struct block *block = NULL;
+ volatile struct gdb_exception except;
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
&block_object_type, &block_obj, &domain))
GDB_PY_HANDLE_EXCEPTION (except);
}
- symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
ret_tuple = PyTuple_New (2);
if (!ret_tuple)
int domain = VAR_DOMAIN;
const char *name;
static char *keywords[] = { "name", "domain", NULL };
- struct symbol *symbol;
+ struct symbol *symbol = NULL;
PyObject *sym_obj;
+ volatile struct gdb_exception except;
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name,
&domain))
return NULL;
- symbol = lookup_symbol_global (name, NULL, domain);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ symbol = lookup_symbol_global (name, NULL, domain);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
if (symbol)
{
}
if (except.reason < 0)
{
- PyErr_Format (except.reason == RETURN_QUIT
- ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
- "%s", except.message);
+ gdbpy_convert_exception (except);
return NULL;
}
const struct block *block)
{
struct type *type;
- char *type_name;
+ char *type_name = NULL;
enum demangle_component_type demangled_type;
+ volatile struct gdb_exception except;
/* Save the type: typy_lookup_type() may (indirectly) overwrite
memory pointed by demangled. */
if (! type)
return NULL;
- switch (demangled_type)
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ switch (demangled_type)
+ {
+ case DEMANGLE_COMPONENT_REFERENCE:
+ return lookup_reference_type (type);
+ case DEMANGLE_COMPONENT_POINTER:
+ return lookup_pointer_type (type);
+ case DEMANGLE_COMPONENT_CONST:
+ return make_cv_type (1, 0, type, NULL);
+ case DEMANGLE_COMPONENT_VOLATILE:
+ return make_cv_type (0, 1, type, NULL);
+ }
+
+ type_name = cp_comp_to_string (demangled, 10);
+ }
+ if (except.reason < 0)
{
- case DEMANGLE_COMPONENT_REFERENCE:
- return lookup_reference_type (type);
- case DEMANGLE_COMPONENT_POINTER:
- return lookup_pointer_type (type);
- case DEMANGLE_COMPONENT_CONST:
- return make_cv_type (1, 0, type, NULL);
- case DEMANGLE_COMPONENT_VOLATILE:
- return make_cv_type (0, 1, type, NULL);
+ gdbpy_convert_exception (except);
+ return NULL;
}
}
- type_name = cp_comp_to_string (demangled, 10);
type = typy_lookup_typename (type_name, block);
xfree (type_name);
{
result = check_types_worklist (&worklist, cache);
}
- if (except.reason < 0)
- result = Py_NE;
-
+ /* check_types_worklist calls several nested Python helper
+ functions, some of which can raise a GDB Exception, so we
+ just check and convert here. If there is a GDB exception, a
+ comparison is not capable (or trusted), so exit. */
bcache_xfree (cache);
VEC_free (type_equality_entry_d, worklist);
+ GDB_PY_HANDLE_EXCEPTION (except);
}
if (op == result)
struct type *type = ((type_object *) self)->type;
char *field;
int i;
-
+ volatile struct gdb_exception except;
+
field = python_string_to_host_string (key);
if (field == NULL)
return NULL;
for (;;)
{
- CHECK_TYPEDEF (type);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ CHECK_TYPEDEF (type);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
if (TYPE_CODE (type) != TYPE_CODE_PTR
&& TYPE_CODE (type) != TYPE_CODE_REF)
break;
struct type *type = ((type_object *) self)->type;
const char *field;
int i;
-
+ volatile struct gdb_exception except;
+
if (!PyArg_ParseTuple (args, "s", &field))
return NULL;
for (;;)
{
- CHECK_TYPEDEF (type);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ CHECK_TYPEDEF (type);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
if (TYPE_CODE (type) != TYPE_CODE_PTR
&& TYPE_CODE (type) != TYPE_CODE_REF)
break;