void bpfinishpy_pre_stop_hook (struct breakpoint_object *bp_obj) { struct finish_breakpoint_object *self_finishbp = (struct finish_breakpoint_object *) bp_obj; volatile struct gdb_exception except; /* Can compute return_value only once. */ gdb_assert (!self_finishbp->return_value); if (!self_finishbp->return_type) return; TRY_CATCH (except, RETURN_MASK_ALL) { struct value *ret = get_return_value (type_object_to_type (self_finishbp->function_type), type_object_to_type (self_finishbp->return_type)); if (ret) { self_finishbp->return_value = value_to_value_object (ret); if (!self_finishbp->return_value) gdbpy_print_stack (); } else { Py_INCREF (Py_None); self_finishbp->return_value = Py_None; } } if (except.reason < 0) { gdbpy_convert_exception (except); gdbpy_print_stack (); } }
static PyObject * stpy_convert_to_value (PyObject *self, PyObject *args) { lazy_string_object *self_string = (lazy_string_object *) self; struct value *val = NULL; if (self_string->address == 0) { PyErr_SetString (gdbpy_gdb_memory_error, _("Cannot create a value from NULL.")); return NULL; } TRY { struct type *type = type_object_to_type (self_string->type); struct type *realtype; gdb_assert (type != NULL); realtype = check_typedef (type); switch (TYPE_CODE (realtype)) { case TYPE_CODE_PTR: /* If a length is specified we need to convert this to an array of the specified size. */ if (self_string->length != -1) { /* PR 20786: There's no way to specify an array of length zero. Record a length of [0,-1] which is how Ada does it. Anything we do is broken, but this is one possible solution. */ type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype), 0, self_string->length - 1); val = value_at_lazy (type, self_string->address); } else val = value_from_pointer (type, self_string->address); break; default: val = value_at_lazy (type, self_string->address); break; } } CATCH (except, RETURN_MASK_ALL) { GDB_PY_HANDLE_EXCEPTION (except); }
void bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { struct finish_breakpoint_object *self_finishbp = (struct finish_breakpoint_object *) bp_obj; /* Can compute return_value only once. */ gdb_assert (!self_finishbp->return_value); if (!self_finishbp->return_type) return; TRY { struct value *function = value_object_to_value (self_finishbp->function_value); struct type *value_type = type_object_to_type (self_finishbp->return_type); /* bpfinishpy_init cannot finish into DUMMY_FRAME (throws an error in such case) so it is OK to always pass CTX_SAVER as NULL. */ struct value *ret = get_return_value (function, value_type, NULL); if (ret) { self_finishbp->return_value = value_to_value_object (ret); if (!self_finishbp->return_value) gdbpy_print_stack (); } else { Py_INCREF (Py_None); self_finishbp->return_value = Py_None; } } CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); }