diff options
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-arch.c | 6 | ||||
-rw-r--r-- | gdb/python/py-block.c | 9 | ||||
-rw-r--r-- | gdb/python/py-breakpoint.c | 57 | ||||
-rw-r--r-- | gdb/python/py-cmd.c | 7 | ||||
-rw-r--r-- | gdb/python/py-finishbreakpoint.c | 40 | ||||
-rw-r--r-- | gdb/python/py-frame.c | 162 | ||||
-rw-r--r-- | gdb/python/py-framefilter.c | 134 | ||||
-rw-r--r-- | gdb/python/py-gdb-readline.c | 19 | ||||
-rw-r--r-- | gdb/python/py-inferior.c | 39 | ||||
-rw-r--r-- | gdb/python/py-infthread.c | 9 | ||||
-rw-r--r-- | gdb/python/py-lazy-string.c | 9 | ||||
-rw-r--r-- | gdb/python/py-linetable.c | 9 | ||||
-rw-r--r-- | gdb/python/py-objfile.c | 18 | ||||
-rw-r--r-- | gdb/python/py-param.c | 7 | ||||
-rw-r--r-- | gdb/python/py-prettyprint.c | 16 | ||||
-rw-r--r-- | gdb/python/py-symbol.c | 45 | ||||
-rw-r--r-- | gdb/python/py-type.c | 152 | ||||
-rw-r--r-- | gdb/python/py-utils.c | 9 | ||||
-rw-r--r-- | gdb/python/py-value.c | 228 | ||||
-rw-r--r-- | gdb/python/python.c | 69 |
20 files changed, 676 insertions, 368 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 49c654b..4fece39 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -199,7 +199,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) char *as = NULL; struct ui_file *memfile = mem_fileopen (); PyObject *insn_dict = PyDict_New (); - volatile struct gdb_exception except; if (insn_dict == NULL) { @@ -217,11 +216,11 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) return NULL; /* PyList_Append Sets the exception. */ } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (result_list); ui_file_delete (memfile); @@ -229,6 +228,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) gdbpy_convert_exception (except); return NULL; } + END_CATCH as = ui_file_xstrdup (memfile, NULL); if (PyDict_SetItemString (insn_dict, "addr", diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index fb6a6b6..6c0f5cb 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -373,19 +373,22 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args) gdb_py_ulongest pc; const struct block *block = NULL; struct compunit_symtab *cust = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { cust = find_pc_compunit_symtab (pc); if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 7807e4e..dcf1d5a 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -114,7 +114,6 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; int cmp; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -136,14 +135,18 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) if (cmp < 0) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (cmp == 1) enable_breakpoint (self_bp->bp); else disable_breakpoint (self_bp->bp); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return 0; } @@ -227,7 +230,6 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; long id; int valid_id = 0; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -242,11 +244,15 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) if (! gdb_py_int_as_long (newvalue, &id)) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { valid_id = valid_task_id (id); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH if (! valid_id) { @@ -278,15 +284,18 @@ static PyObject * bppy_delete_breakpoint (PyObject *self, PyObject *args) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; - volatile struct gdb_exception except; BPPY_REQUIRE_VALID (self_bp); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { delete_breakpoint (self_bp->bp); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -298,7 +307,6 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; long value; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -321,11 +329,15 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) if (value < 0) value = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_ignore_count (self_bp->number, (int) value, 0); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return 0; } @@ -429,7 +441,7 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) { char *exp; gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; BPPY_SET_REQUIRE_VALID (self_bp); @@ -448,10 +460,15 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) return -1; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_breakpoint_condition (self_bp->bp, exp, 0); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH if (newvalue != Py_None) xfree (exp); @@ -468,7 +485,6 @@ bppy_get_commands (PyObject *self, void *closure) gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; struct breakpoint *bp = self_bp->bp; long length; - volatile struct gdb_exception except; struct ui_file *string_file; struct cleanup *chain; PyObject *result; @@ -483,17 +499,18 @@ bppy_get_commands (PyObject *self, void *closure) chain = make_cleanup_ui_file_delete (string_file); ui_out_redirect (current_uiout, string_file); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } ui_out_redirect (current_uiout, NULL); - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { do_cleanups (chain); gdbpy_convert_exception (except); return NULL; } + END_CATCH cmdstr = ui_file_xstrdup (string_file, &length); make_cleanup (xfree, cmdstr); @@ -619,7 +636,6 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyObject *temporary = NULL; int internal_bp = 0; int temporary_bp = 0; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords, &spec, &type, &access_type, @@ -644,7 +660,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { char *copy = xstrdup (spec); struct cleanup *cleanup = make_cleanup (xfree, copy); @@ -681,13 +697,14 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { PyErr_Format (except.reason == RETURN_QUIT ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, "%s", except.message); return -1; } + END_CATCH BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self); return 0; diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index a5e96d6..1d89912 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -537,7 +537,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) int cmdtype; int completetype = -1; char *docstring = NULL; - volatile struct gdb_exception except; struct cmd_list_element **cmd_list; char *cmd_name, *pfx_name; static char *keywords[] = { "name", "command_class", "completer_class", @@ -637,7 +636,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) Py_INCREF (self); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cmd_list_element *cmd; @@ -668,7 +667,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) set_cmd_completer_handle_brkchars (cmd, cmdpy_completer_handle_brkchars); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (cmd_name); xfree (docstring); @@ -679,6 +678,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) "%s", except.message); return -1; } + END_CATCH + return 0; } diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 43f6807..34e9643 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -93,7 +93,6 @@ bpfinishpy_pre_stop_hook (struct gdbpy_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); @@ -101,7 +100,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) if (!self_finishbp->return_type) return; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *function = value_object_to_value (self_finishbp->function_value); @@ -121,11 +120,12 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) self_finishbp->return_value = Py_None; } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } /* Triggered when gdbpy_should_stop has triggered the `stop' callback @@ -134,19 +134,19 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) void bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Can't delete it here, but it will be removed at the next stop. */ disable_breakpoint (bp_obj->bp); gdb_assert (bp_obj->bp->disposition == disp_del); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } /* Python function to create a new breakpoint. */ @@ -166,7 +166,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyObject *internal = NULL; int internal_bp = 0; CORE_ADDR finish_pc, pc; - volatile struct gdb_exception except; char *addr_str, small_buf[100]; struct symbol *function; @@ -174,7 +173,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &frame_obj, &internal)) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Default frame to newest frame if necessary. */ if (frame_obj == NULL) @@ -212,12 +211,14 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return -1; } - else if (PyErr_Occurred ()) + END_CATCH + + if (PyErr_Occurred ()) return -1; thread = pid_to_thread_id (inferior_ptid); @@ -243,7 +244,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) self_bpfinish->return_type = NULL; self_bpfinish->function_value = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (get_frame_pc_if_available (frame, &pc)) { @@ -269,11 +270,12 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { /* Just swallow. Either the return type or the function value remain NULL. */ } + END_CATCH if (self_bpfinish->return_type == NULL || self_bpfinish->function_value == NULL) { @@ -289,7 +291,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Set a breakpoint on the return address. */ finish_pc = get_frame_pc (prev_frame); @@ -306,7 +308,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH self_bpfinish->py_bp.bp->frame_id = frame_id; self_bpfinish->py_bp.is_finish_bp = 1; @@ -347,7 +353,6 @@ bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj) static int bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) { - volatile struct gdb_exception except; struct breakpoint *bp_stopped = (struct breakpoint *) args; PyObject *py_bp = (PyObject *) b->py_bp_object; struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch (); @@ -362,18 +367,19 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) /* Check scope if not currently stopped at the FinishBreakpoint. */ if (b != bp_stopped) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (b->pspace == current_inferior ()->pspace && (!target_has_registers || frame_find_by_id (b->frame_id) == NULL)) bpfinishpy_out_of_scope (finish_bp); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 9ef8608..cd6e859 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -101,13 +101,16 @@ static PyObject * frapy_is_valid (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frame_object_to_frame_info (self); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (frame == NULL) Py_RETURN_FALSE; @@ -125,19 +128,19 @@ frapy_name (PyObject *self, PyObject *args) char *name = NULL; enum language lang; PyObject *result; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); find_frame_funname (frame, &name, &lang, NULL); } - - if (except.reason < 0) - xfree (name); - - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + xfree (name); + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (name) { @@ -161,15 +164,18 @@ frapy_type (PyObject *self, PyObject *args) { struct frame_info *frame; enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); type = get_frame_type (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return PyInt_FromLong (type); } @@ -182,13 +188,16 @@ frapy_arch (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ frame_object *obj = (frame_object *) self; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdbarch_to_arch_object (obj->gdbarch); } @@ -200,14 +209,17 @@ static PyObject * frapy_unwind_stop_reason (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; enum unwind_stop_reason stop_reason; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH stop_reason = get_frame_unwind_stop_reason (frame); @@ -222,15 +234,18 @@ frapy_pc (PyObject *self, PyObject *args) { CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ struct frame_info *frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); pc = get_frame_pc (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_long_from_ulongest (pc); } @@ -241,14 +256,13 @@ frapy_pc (PyObject *self, PyObject *args) static PyObject * frapy_read_register (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; const char *regnum_str; struct value *val = NULL; if (!PyArg_ParseTuple (args, "s", ®num_str)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct frame_info *frame; int regnum; @@ -264,7 +278,11 @@ frapy_read_register (PyObject *self, PyObject *args) if (val == NULL) PyErr_SetString (PyExc_ValueError, _("Unknown register.")); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return val == NULL ? NULL : value_to_value_object (val); } @@ -277,14 +295,17 @@ frapy_block (PyObject *self, PyObject *args) { struct frame_info *frame; const struct block *block = NULL, *fn_block; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); block = get_frame_block (frame, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH for (fn_block = block; fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL; @@ -316,15 +337,18 @@ frapy_function (PyObject *self, PyObject *args) { struct symbol *sym = NULL; struct frame_info *frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); sym = find_pc_function (get_frame_address_in_block (frame)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (sym) return symbol_to_symbol_object (sym); @@ -339,13 +363,12 @@ PyObject * 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_CATCH (except, RETURN_MASK_ALL) + TRY { /* Try to get the previous frame, to determine if this is the last frame @@ -365,12 +388,14 @@ frame_info_to_frame_object (struct frame_info *frame) } frame_obj->gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (frame_obj); gdbpy_convert_exception (except); return NULL; } + END_CATCH + return (PyObject *) frame_obj; } @@ -382,16 +407,19 @@ static PyObject * frapy_older (PyObject *self, PyObject *args) { struct frame_info *frame, *prev = NULL; - volatile struct gdb_exception except; PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); prev = get_prev_frame (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (prev) prev_obj = (PyObject *) frame_info_to_frame_object (prev); @@ -412,16 +440,19 @@ static PyObject * frapy_newer (PyObject *self, PyObject *args) { struct frame_info *frame, *next = NULL; - volatile struct gdb_exception except; PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); next = get_next_frame (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (next) next_obj = (PyObject *) frame_info_to_frame_object (next); @@ -442,17 +473,20 @@ frapy_find_sal (PyObject *self, PyObject *args) { struct frame_info *frame; struct symtab_and_line sal; - volatile struct gdb_exception except; PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); find_frame_sal (frame, &sal); sal_obj = symtab_and_line_to_sal_object (sal); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return sal_obj; } @@ -471,7 +505,6 @@ frapy_read_var (PyObject *self, PyObject *args) PyObject *sym_obj, *block_obj = NULL; struct symbol *var = NULL; /* gcc-4.3.2 false warning. */ struct value *val = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj)) return NULL; @@ -483,7 +516,6 @@ frapy_read_var (PyObject *self, PyObject *args) char *var_name; const struct block *block = NULL; struct cleanup *cleanup; - volatile struct gdb_exception except; var_name = python_string_to_target_string (sym_obj); if (!var_name) @@ -502,7 +534,7 @@ frapy_read_var (PyObject *self, PyObject *args) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); @@ -510,12 +542,13 @@ frapy_read_var (PyObject *self, PyObject *args) block = get_frame_block (frame, NULL); var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { do_cleanups (cleanup); gdbpy_convert_exception (except); return NULL; } + END_CATCH if (!var) { @@ -535,13 +568,17 @@ frapy_read_var (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); val = read_var_value (var, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -552,15 +589,18 @@ static PyObject * frapy_select (PyObject *self, PyObject *args) { struct frame_info *fi; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, fi); select_frame (fi); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -572,13 +612,16 @@ PyObject * gdbpy_newest_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_current_frame (); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return frame_info_to_frame_object (frame); } @@ -590,13 +633,16 @@ PyObject * gdbpy_selected_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_selected_frame ("No frame is currently selected."); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return frame_info_to_frame_object (frame); } diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 5531d2b..e3336b1 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -201,9 +201,8 @@ mi_should_print (struct symbol *sym, enum mi_print_types type) static enum ext_lang_bt_status py_print_type (struct ui_out *out, struct value *val) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct type *type; struct ui_file *stb; @@ -216,11 +215,12 @@ py_print_type (struct ui_out *out, struct value *val) ui_out_field_stream (out, "type", stb); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH return EXT_LANG_BT_OK; } @@ -242,7 +242,6 @@ py_print_value (struct ui_out *out, struct value *val, const struct language_defn *language) { int should_print = 0; - volatile struct gdb_exception except; int local_indent = (4 * indent); /* Never set an indent level for common_val_print if MI. */ @@ -257,15 +256,16 @@ py_print_value (struct ui_out *out, struct value *val, { struct type *type = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (value_type (val)); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH if (args_type == MI_PRINT_ALL_VALUES) should_print = 1; @@ -280,7 +280,7 @@ py_print_value (struct ui_out *out, struct value *val, if (should_print) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb; struct cleanup *cleanup; @@ -291,11 +291,12 @@ py_print_value (struct ui_out *out, struct value *val, ui_out_field_stream (out, "value", stb); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH } return EXT_LANG_BT_OK; @@ -363,7 +364,6 @@ py_print_single_arg (struct ui_out *out, const struct language_defn *language) { struct value *val; - volatile struct gdb_exception except; enum ext_lang_bt_status retval = EXT_LANG_BT_OK; if (fa != NULL) @@ -376,7 +376,7 @@ py_print_single_arg (struct ui_out *out, else val = fv; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); @@ -473,8 +473,11 @@ py_print_single_arg (struct ui_out *out, do_cleanups (cleanups); } - if (except.reason < 0) - gdbpy_convert_exception (except); + CATCH (except, RETURN_MASK_ERROR) + { + gdbpy_convert_exception (except); + } + END_CATCH return retval; } @@ -499,7 +502,6 @@ enumerate_args (PyObject *iter, { PyObject *item; struct value_print_options opts; - volatile struct gdb_exception except; get_user_print_options (&opts); @@ -511,15 +513,16 @@ enumerate_args (PyObject *iter, opts.deref_ref = 1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_frame_args (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto error; } + END_CATCH /* Collect the first argument outside of the loop, so output of commas in the argument output is correct. At the end of the @@ -578,16 +581,17 @@ enumerate_args (PyObject *iter, goto error; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { read_frame_arg (sym, frame, &arg, &entryarg); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (sym_name); gdbpy_convert_exception (except); goto error; } + END_CATCH /* The object has not provided a value, so this is a frame argument to be read by GDB. In this case we have to @@ -612,12 +616,12 @@ enumerate_args (PyObject *iter, { if (arg.entry_kind != print_entry_values_only) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ui_out_text (out, ", "); ui_out_wrap_hint (out, " "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (arg.error); xfree (entryarg.error); @@ -625,6 +629,7 @@ enumerate_args (PyObject *iter, gdbpy_convert_exception (except); goto error; } + END_CATCH } if (py_print_single_arg (out, NULL, &entryarg, NULL, &opts, @@ -664,30 +669,32 @@ enumerate_args (PyObject *iter, item = PyIter_Next (iter); if (item != NULL) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ui_out_text (out, ", "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (item); gdbpy_convert_exception (except); goto error; } + END_CATCH } else if (PyErr_Occurred ()) goto error; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_arg_end (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (item); gdbpy_convert_exception (except); goto error; } + END_CATCH } return EXT_LANG_BT_OK; @@ -729,7 +736,6 @@ enumerate_locals (PyObject *iter, struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; struct symbol *sym; - volatile struct gdb_exception except; int local_indent = 8 + (8 * indent); struct cleanup *locals_cleanups; @@ -761,16 +767,17 @@ enumerate_locals (PyObject *iter, /* If the object did not provide a value, read it. */ if (val == NULL) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { val = read_var_value (sym, frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (locals_cleanups); goto error; } + END_CATCH } /* With PRINT_NO_VALUES, MI does not emit a tuple normally as @@ -781,7 +788,7 @@ enumerate_locals (PyObject *iter, if (print_args_field || args_type != NO_VALUES) make_cleanup_ui_out_tuple_begin_end (out, NULL); } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { if (! ui_out_is_mi_like_p (out)) { @@ -794,12 +801,13 @@ enumerate_locals (PyObject *iter, if (! ui_out_is_mi_like_p (out)) ui_out_text (out, " = "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (locals_cleanups); goto error; } + END_CATCH if (args_type == MI_PRINT_SIMPLE_VALUES) { @@ -838,15 +846,16 @@ enumerate_locals (PyObject *iter, do_cleanups (locals_cleanups); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_text (out, "\n"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); goto error; } + END_CATCH } if (item == NULL && PyErr_Occurred ()) @@ -947,40 +956,41 @@ py_print_args (PyObject *filter, { PyObject *args_iter = get_py_iter_from_func (filter, "frame_args"); struct cleanup *old_chain = make_cleanup_py_xdecref (args_iter); - volatile struct gdb_exception except; if (args_iter == NULL) goto args_error; make_cleanup_ui_out_list_begin_end (out, "args"); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_frame_args (); if (! ui_out_is_mi_like_p (out)) ui_out_text (out, " ("); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto args_error; } + END_CATCH if (args_iter != Py_None) if (enumerate_args (args_iter, out, args_type, 0, frame) == EXT_LANG_BT_ERROR) goto args_error; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (! ui_out_is_mi_like_p (out)) ui_out_text (out, ")"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto args_error; } + END_CATCH do_cleanups (old_chain); return EXT_LANG_BT_OK; @@ -1018,7 +1028,6 @@ py_print_frame (PyObject *filter, int flags, struct value_print_options opts; PyObject *py_inf_frame; int print_level, print_frame_info, print_args, print_locals; - volatile struct gdb_exception except; /* Extract print settings from FLAGS. */ print_level = (flags & PRINT_LEVEL) ? 1 : 0; @@ -1042,15 +1051,16 @@ py_print_frame (PyObject *filter, int flags, if (frame == NULL) return EXT_LANG_BT_ERROR; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH /* stack-list-variables. */ if (print_locals && print_args && ! print_frame_info) @@ -1074,16 +1084,17 @@ py_print_frame (PyObject *filter, int flags, and are printed with indention. */ if (indent > 0) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_spaces (out, indent*4); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } /* The address is required for frame annotations, and also for @@ -1113,11 +1124,10 @@ py_print_frame (PyObject *filter, int flags, { struct frame_info **slot; int level; - volatile struct gdb_exception except; slot = (struct frame_info **) htab_find_slot (levels_printed, frame, INSERT); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { level = frame_relative_level (frame); @@ -1137,12 +1147,13 @@ py_print_frame (PyObject *filter, int flags, level); } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } if (print_frame_info) @@ -1151,19 +1162,20 @@ py_print_frame (PyObject *filter, int flags, print nothing. */ if (opts.addressprint && has_addr) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_address (); ui_out_field_core_addr (out, "addr", gdbarch, address); annotate_frame_address_end (); ui_out_text (out, " in "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } /* Print frame function name. */ @@ -1218,7 +1230,7 @@ py_print_frame (PyObject *filter, int flags, return EXT_LANG_BT_ERROR; } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_function_name (); if (function == NULL) @@ -1226,12 +1238,14 @@ py_print_frame (PyObject *filter, int flags, else ui_out_field_string (out, "func", function); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH + do_cleanups (py_func_cleanup); } } @@ -1251,16 +1265,17 @@ py_print_frame (PyObject *filter, int flags, /* File name/source/line number information. */ if (print_frame_info) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_source_begin (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH if (PyObject_HasAttrString (filter, "filename")) { @@ -1285,7 +1300,7 @@ py_print_frame (PyObject *filter, int flags, } make_cleanup (xfree, filename); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_wrap_hint (out, " "); ui_out_text (out, " at "); @@ -1293,12 +1308,13 @@ py_print_frame (PyObject *filter, int flags, ui_out_field_string (out, "file", filename); annotate_frame_source_file_end (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } do_cleanups (py_fn_cleanup); } @@ -1319,18 +1335,19 @@ py_print_frame (PyObject *filter, int flags, if (py_line != Py_None) { line = PyLong_AsLong (py_line); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_text (out, ":"); annotate_frame_source_line (); ui_out_field_int (out, "line", line); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } do_cleanups (py_line_cleanup); } @@ -1340,17 +1357,18 @@ py_print_frame (PyObject *filter, int flags, elided frames, so if MI output detected do not send newline. */ if (! ui_out_is_mi_like_p (out)) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_end (); ui_out_text (out, "\n"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } if (print_locals) @@ -1503,22 +1521,22 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, struct cleanup *cleanups; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; PyObject *iterable; - volatile struct gdb_exception except; PyObject *item; htab_t levels_printed; if (!gdb_python_initialized) return EXT_LANG_BT_NO_FILTERS; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { /* Let gdb try to print the stack trace. */ return EXT_LANG_BT_NO_FILTERS; } + END_CATCH cleanups = ensure_python_env (gdbarch, current_language); diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index 7a5c853..0cf4dfd 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -37,18 +37,18 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, { int n; char *p = NULL, *q; - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ALL) - p = command_line_input (prompt, 0, "python"); - - /* Detect user interrupt (Ctrl-C). */ - if (except.reason == RETURN_QUIT) - return NULL; + TRY + { + p = command_line_input (prompt, 0, "python"); + } /* Handle errors by raising Python exceptions. */ - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { + /* Detect user interrupt (Ctrl-C). */ + if (except.reason == RETURN_QUIT) + return NULL; + /* The thread state is nulled during gdbpy_readline_wrapper, with the original value saved in the following undocumented variable (see Python's Parser/myreadline.c and @@ -58,6 +58,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, PyEval_SaveThread (); return NULL; } + END_CATCH /* Detect EOF (Ctrl-D). */ if (p == NULL) diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 5d13e07..fe8a705 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -395,13 +395,18 @@ infpy_threads (PyObject *self, PyObject *args) struct threadlist_entry *entry; inferior_object *inf_obj = (inferior_object *) self; PyObject *tuple; - volatile struct gdb_exception except; INFPY_REQUIRE_VALID (inf_obj); - TRY_CATCH (except, RETURN_MASK_ALL) - update_thread_list (); - GDB_PY_HANDLE_EXCEPTION (except); + TRY + { + update_thread_list (); + } + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH tuple = PyTuple_New (inf_obj->nthreads); if (!tuple) @@ -503,7 +508,6 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) void *buffer = NULL; membuf_object *membuf_obj; PyObject *addr_obj, *length_obj, *result; - volatile struct gdb_exception except; static char *keywords[] = { "address", "length", NULL }; if (! PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords, @@ -514,17 +518,18 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) || get_addr_from_python (length_obj, &length) < 0) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { buffer = xmalloc (length); read_memory (addr, buffer, length); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (buffer); GDB_PY_HANDLE_EXCEPTION (except); } + END_CATCH membuf_obj = PyObject_New (membuf_object, &membuf_object_type); if (membuf_obj == NULL) @@ -557,11 +562,11 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) static PyObject * infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) { + struct gdb_exception except = exception_none; Py_ssize_t buf_len; const char *buffer; CORE_ADDR addr, length; PyObject *addr_obj, *length_obj = NULL; - volatile struct gdb_exception except; static char *keywords[] = { "address", "buffer", "length", NULL }; #ifdef IS_PY3K Py_buffer pybuf; @@ -588,10 +593,16 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) else if (get_addr_from_python (length_obj, &length) < 0) goto fail; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { write_memory_with_notification (addr, (gdb_byte *) buffer, length); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + #ifdef IS_PY3K PyBuffer_Release (&pybuf); #endif @@ -701,10 +712,10 @@ get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) static PyObject * infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) { + struct gdb_exception except = exception_none; CORE_ADDR start_addr, length; static char *keywords[] = { "address", "length", "pattern", NULL }; PyObject *start_addr_obj, *length_obj; - volatile struct gdb_exception except; Py_ssize_t pattern_size; const void *buffer; CORE_ADDR found_addr; @@ -760,12 +771,18 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) goto fail; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { found = target_search_memory (start_addr, length, buffer, pattern_size, &found_addr); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + #ifdef IS_PY3K PyBuffer_Release (&pybuf); #endif diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 9a9a2e6..4d0a020 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -147,15 +147,18 @@ static PyObject * thpy_switch (PyObject *self, PyObject *args) { thread_object *thread_obj = (thread_object *) self; - volatile struct gdb_exception except; THPY_REQUIRE_VALID (thread_obj); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch_to_thread (thread_obj->thread->ptid); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 9c0f7a4..c9774ab 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -96,7 +96,6 @@ stpy_convert_to_value (PyObject *self, PyObject *args) { lazy_string_object *self_string = (lazy_string_object *) self; struct value *val = NULL; - volatile struct gdb_exception except; if (self_string->address == 0) { @@ -105,11 +104,15 @@ stpy_convert_to_value (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_at_lazy (self_string->type, self_string->address); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index ff1716b..195a8b3 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -172,18 +172,21 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args) linetable_entry_object *result; VEC (CORE_ADDR) *pcs = NULL; PyObject *tuple; - volatile struct gdb_exception except; LTPY_REQUIRE_VALID (self, symtab); if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH tuple = build_line_table_tuple_from_pcs (py_line, pcs); VEC_free (CORE_ADDR, pcs); diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 0a10623..157d200 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -131,15 +131,18 @@ objfpy_get_build_id (PyObject *self, void *closure) objfile_object *obj = (objfile_object *) self; struct objfile *objfile = obj->objfile; const struct elf_build_id *build_id = NULL; - volatile struct gdb_exception except; OBJFPY_REQUIRE_VALID (obj); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { build_id = build_id_bfd_get (objfile->obfd); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (build_id != NULL) { @@ -386,20 +389,23 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw) objfile_object *obj = (objfile_object *) self; const char *file_name; int symfile_flags = 0; - volatile struct gdb_exception except; OBJFPY_REQUIRE_VALID (obj); if (!PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { bfd *abfd = symfile_bfd_open (file_name); symbol_file_add_separate (abfd, file_name, symfile_flags, obj->objfile); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index 2fe5be6..06b9ae9 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -662,7 +662,6 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) int parmclass, cmdtype; PyObject *enum_values = NULL; struct cmd_list_element **set_list, **show_list; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass, &enum_values)) @@ -724,14 +723,14 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) Py_INCREF (self); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { add_setshow_generic (parmclass, (enum command_class) cmdtype, cmd_name, obj, set_doc, show_doc, doc, set_list, show_list); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (cmd_name); xfree (set_doc); @@ -743,6 +742,8 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) "%s", except.message); return -1; } + END_CATCH + return 0; } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index f4c91d0..d8579fa 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -213,11 +213,10 @@ find_pretty_printer (PyObject *value) static PyObject * pretty_print_one_value (PyObject *printer, struct value **out_value) { - volatile struct gdb_exception except; PyObject *result = NULL; *out_value = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL); if (result) @@ -233,6 +232,10 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) } } } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH return result; } @@ -803,13 +806,16 @@ gdbpy_get_varobj_pretty_printer (struct value *value) { PyObject *val_obj; PyObject *pretty_printer = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = value_copy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH val_obj = value_to_value_object (value); if (! val_obj) diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 729bc64..4306f61 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -192,16 +192,19 @@ static PyObject * sympy_needs_frame (PyObject *self, void *closure) { struct symbol *symbol = NULL; - volatile struct gdb_exception except; int result = 0; SYMPY_REQUIRE_VALID (self, symbol); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = symbol_read_needs_frame (symbol); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (result) Py_RETURN_TRUE; @@ -246,7 +249,6 @@ sympy_value (PyObject *self, PyObject *args) struct frame_info *frame_info = NULL; PyObject *frame_obj = NULL; struct value *value = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "|O", &frame_obj)) return NULL; @@ -264,7 +266,7 @@ sympy_value (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (frame_obj != NULL) { @@ -278,7 +280,11 @@ sympy_value (PyObject *self, PyObject *args) value = read_var_value (symbol, frame_info); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (value); } @@ -365,7 +371,6 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) 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)) @@ -376,21 +381,28 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) else { struct frame_info *selected_frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { selected_frame = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_symbol (name, block, domain, &is_a_field_of_this); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH ret_tuple = PyTuple_New (2); if (!ret_tuple) @@ -430,17 +442,20 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) static char *keywords[] = { "name", "domain", NULL }; struct symbol *symbol = NULL; PyObject *sym_obj; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name, &domain)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_global_symbol (name, NULL, domain); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (symbol) { diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 72d4dcf..39376a1 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -341,15 +341,18 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) { PyObject *py_type = self; PyObject *result = NULL, *iter = NULL; - volatile struct gdb_exception except; struct type *type = ((type_object *) py_type)->type; struct type *checked_type = type; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (checked_type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (checked_type != type) py_type = type_to_type_object (checked_type); @@ -449,13 +452,16 @@ static PyObject * typy_strip_typedefs (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -466,15 +472,18 @@ typy_strip_typedefs (PyObject *self, PyObject *args) static struct type * typy_get_composite (struct type *type) { - volatile struct gdb_exception except; for (;;) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -505,7 +514,6 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) PyObject *n2_obj = NULL; struct type *array = NULL; struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "l|O", &n1, &n2_obj)) return NULL; @@ -535,13 +543,17 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (array); } @@ -567,13 +579,16 @@ static PyObject * typy_pointer (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_pointer_type (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -648,13 +663,16 @@ static PyObject * typy_reference (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_reference_type (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -680,13 +698,16 @@ static PyObject * typy_const (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (1, 0, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -696,13 +717,16 @@ static PyObject * typy_volatile (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 1, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -712,13 +736,16 @@ static PyObject * typy_unqualified (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 0, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -728,12 +755,16 @@ static PyObject * typy_get_sizeof (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { check_typedef (type); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH + /* Ignore exceptions. */ return gdb_py_long_from_longest (TYPE_LENGTH (type)); @@ -743,9 +774,8 @@ static struct type * typy_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -757,7 +787,11 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (python_language, python_gdbarch, type_name, block, 0); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type; } @@ -769,7 +803,6 @@ typy_lookup_type (struct demangle_component *demangled, struct type *type, *rtype = NULL; 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. */ @@ -784,7 +817,7 @@ typy_lookup_type (struct demangle_component *demangled, if (! type) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* If the demangled_type matches with one of the types below, run the corresponding function and save the type @@ -806,7 +839,11 @@ typy_lookup_type (struct demangle_component *demangled, break; } } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH } /* If we have a type from the switch statement above, just return @@ -837,7 +874,6 @@ typy_legacy_template_argument (struct type *type, const struct block *block, const char *err; struct type *argtype; struct cleanup *cleanup; - volatile struct gdb_exception except; if (TYPE_NAME (type) == NULL) { @@ -845,12 +881,16 @@ typy_legacy_template_argument (struct type *type, const struct block *block, return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Note -- this is not thread-safe. */ info = cp_demangled_name_to_comp (TYPE_NAME (type), &err); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (! info) { @@ -903,7 +943,6 @@ typy_template_argument (PyObject *self, PyObject *args) PyObject *block_obj = NULL; struct symbol *sym; struct value *val = NULL; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj)) return NULL; @@ -919,13 +958,17 @@ typy_template_argument (PyObject *self, PyObject *args) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); if (TYPE_CODE (type) == TYPE_CODE_REF) type = check_typedef (TYPE_TARGET_TYPE (type)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH /* We might not have DW_TAG_template_*, so try to parse the type's name. This is inefficient if we do not have a template type -- @@ -950,11 +993,15 @@ typy_template_argument (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_of_variable (sym, block); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -962,12 +1009,11 @@ typy_template_argument (PyObject *self, PyObject *args) static PyObject * typy_str (PyObject *self) { - volatile struct gdb_exception except; char *thetype = NULL; long length = 0; PyObject *result; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *old_chain; struct ui_file *stb; @@ -981,11 +1027,12 @@ typy_str (PyObject *self) thetype = ui_file_xstrdup (stb, &length); do_cleanups (old_chain); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (thetype); GDB_PY_HANDLE_EXCEPTION (except); } + END_CATCH result = PyUnicode_Decode (thetype, length, host_charset (), NULL); xfree (thetype); @@ -1001,7 +1048,6 @@ typy_richcompare (PyObject *self, PyObject *other, int op) int result = Py_NE; struct type *type1 = type_object_to_type (self); struct type *type2 = type_object_to_type (other); - volatile struct gdb_exception except; /* We can only compare ourselves to another Type object, and only for equality or inequality. */ @@ -1015,13 +1061,17 @@ typy_richcompare (PyObject *self, PyObject *other, int op) result = Py_EQ; else { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = types_deeply_equal (type1, type2); } - /* If there is a GDB exception, a comparison is not capable - (or trusted), so exit. */ - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + /* If there is a GDB exception, a comparison is not capable + (or trusted), so exit. */ + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH } if (op == (result ? Py_EQ : Py_NE)) diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 58a5934..2e32f11 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -316,13 +316,16 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) { if (gdbpy_is_value_object (obj)) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { *addr = value_as_address (value_object_to_value (obj)); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH } else { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 5a13777..6622d11 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -172,10 +172,9 @@ gdbpy_preserve_values (const struct extension_language_defn *extlang, static PyObject * valpy_dereference (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *res_val; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -184,7 +183,11 @@ valpy_dereference (PyObject *self, PyObject *args) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -200,10 +203,9 @@ valpy_dereference (PyObject *self, PyObject *args) static PyObject * valpy_referenced_value (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *self_val, *res_val; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -225,7 +227,11 @@ valpy_referenced_value (PyObject *self, PyObject *args) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -235,11 +241,10 @@ static PyObject * valpy_get_address (PyObject *self, void *closure) { value_object *val_obj = (value_object *) self; - volatile struct gdb_exception except; if (!val_obj->address) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *res_val; struct cleanup *cleanup @@ -249,11 +254,12 @@ valpy_get_address (PyObject *self, void *closure) val_obj->address = value_to_value_object (res_val); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { val_obj->address = Py_None; Py_INCREF (Py_None); } + END_CATCH } Py_XINCREF (val_obj->address); @@ -283,7 +289,6 @@ static PyObject * valpy_get_dynamic_type (PyObject *self, void *closure) { value_object *obj = (value_object *) self; - volatile struct gdb_exception except; struct type *type = NULL; if (obj->dynamic_type != NULL) @@ -292,7 +297,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) return obj->dynamic_type; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *val = obj->value; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -331,7 +336,11 @@ valpy_get_dynamic_type (PyObject *self, void *closure) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (type == NULL) obj->dynamic_type = valpy_get_type (self, NULL); @@ -358,13 +367,12 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) const char *user_encoding = NULL; static char *keywords[] = { "encoding", "length", NULL }; PyObject *str_obj = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG, keywords, &user_encoding, &length)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -377,7 +385,11 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return str_obj; } @@ -394,7 +406,6 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) int length = -1; gdb_byte *buffer; struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; PyObject *unicode; const char *encoding = NULL; const char *errors = NULL; @@ -407,11 +418,15 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) &user_encoding, &errors, &length)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; unicode = PyUnicode_Decode ((const char *) buffer, @@ -429,7 +444,6 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) { PyObject *type_obj, *result = NULL; struct type *type; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "O", &type_obj)) return NULL; @@ -442,7 +456,7 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *val = ((value_object *) self)->value; struct value *res_val; @@ -461,7 +475,11 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -508,7 +526,6 @@ value_has_field (struct value *v, PyObject *field) struct type *parent_type, *val_type; enum type_code type_code; PyObject *type_object = PyObject_GetAttrString (field, "parent_type"); - volatile struct gdb_exception except; int has_field = 0; if (type_object == NULL) @@ -524,7 +541,7 @@ value_has_field (struct value *v, PyObject *field) return -1; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val_type = value_type (v); val_type = check_typedef (val_type); @@ -539,7 +556,11 @@ value_has_field (struct value *v, PyObject *field) else has_field = 0; } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return has_field; } @@ -591,11 +612,11 @@ get_field_type (PyObject *field) static PyObject * valpy_getitem (PyObject *self, PyObject *key) { + struct gdb_exception except = exception_none; value_object *self_value = (value_object *) self; char *field = NULL; struct type *base_class_type = NULL, *field_type = NULL; long bitpos = -1; - volatile struct gdb_exception except; PyObject *result = NULL; if (gdbpy_is_string (key)) @@ -673,7 +694,7 @@ valpy_getitem (PyObject *self, PyObject *key) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *tmp = self_value->value; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -723,6 +744,11 @@ valpy_getitem (PyObject *self, PyObject *key) result = value_to_value_object (res_val); do_cleanups (cleanup); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH xfree (field); GDB_PY_HANDLE_EXCEPTION (except); @@ -744,18 +770,21 @@ static PyObject * valpy_call (PyObject *self, PyObject *args, PyObject *keywords) { Py_ssize_t args_count; - volatile struct gdb_exception except; struct value *function = ((value_object *) self)->value; struct value **vargs = NULL; struct type *ftype = NULL; struct value *mark = value_mark (); PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ftype = check_typedef (value_type (function)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (TYPE_CODE (ftype) != TYPE_CODE_FUNC) { @@ -790,7 +819,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (mark); struct value *return_value; @@ -799,7 +828,11 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) result = value_to_value_object (return_value); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -812,12 +845,11 @@ valpy_str (PyObject *self) char *s = NULL; PyObject *result; struct value_print_options opts; - volatile struct gdb_exception except; get_user_print_options (&opts); opts.deref_ref = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb = mem_fileopen (); struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); @@ -828,7 +860,11 @@ valpy_str (PyObject *self) do_cleanups (old_chain); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH result = PyUnicode_Decode (s, strlen (s), host_charset (), NULL); xfree (s); @@ -842,13 +878,16 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) { struct value *value = ((value_object *) self)->value; int opt = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { opt = value_optimized_out (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (opt) Py_RETURN_TRUE; @@ -862,13 +901,16 @@ valpy_get_is_lazy (PyObject *self, void *closure) { struct value *value = ((value_object *) self)->value; int opt = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { opt = value_lazy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (opt) Py_RETURN_TRUE; @@ -881,14 +923,17 @@ static PyObject * valpy_fetch_lazy (PyObject *self, PyObject *args) { struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (value_lazy (value)) value_fetch_lazy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -926,10 +971,9 @@ enum valpy_opcode static PyObject * valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *arg1, *arg2; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1049,7 +1093,11 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1103,10 +1151,9 @@ valpy_power (PyObject *self, PyObject *other, PyObject *unused) static PyObject * valpy_negative (PyObject *self) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Perhaps overkill, but consistency has some virtue. */ struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1116,7 +1163,11 @@ valpy_negative (PyObject *self) result = value_to_value_object (val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1131,10 +1182,9 @@ static PyObject * valpy_absolute (PyObject *self) { struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; int isabs = 1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1143,7 +1193,11 @@ valpy_absolute (PyObject *self) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (isabs) return valpy_positive (self); @@ -1155,12 +1209,12 @@ valpy_absolute (PyObject *self) static int valpy_nonzero (PyObject *self) { - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; value_object *self_value = (value_object *) self; struct type *type; int nonzero = 0; /* Appease GCC warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (value_type (self_value->value)); @@ -1176,6 +1230,12 @@ valpy_nonzero (PyObject *self) /* All other values are True. */ nonzero = 1; } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + /* This is not documented in the Python documentation, but if this function fails, return -1 as slot_nb_nonzero does (the default Python nonzero function). */ @@ -1189,13 +1249,16 @@ static PyObject * valpy_invert (PyObject *self) { struct value *val = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_complement (((value_object *) self)->value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -1241,7 +1304,6 @@ static PyObject * valpy_richcompare (PyObject *self, PyObject *other, int op) { int result = 0; - volatile struct gdb_exception except; if (other == Py_None) /* Comparing with None is special. From what I can tell, in Python @@ -1262,7 +1324,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *value_other, *mark = value_mark (); struct cleanup *cleanup; @@ -1307,7 +1369,11 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH /* In this case, the Python exception has already been set. */ if (result < 0) @@ -1327,16 +1393,19 @@ valpy_int (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); LONGEST l = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (!is_integral_type (type)) error (_("Cannot convert value to int.")); l = value_as_long (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_object_from_longest (l); } @@ -1349,9 +1418,8 @@ valpy_long (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); LONGEST l = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); @@ -1361,7 +1429,11 @@ valpy_long (PyObject *self) l = value_as_long (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_long_from_longest (l); } @@ -1373,9 +1445,8 @@ valpy_float (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); double d = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); @@ -1384,7 +1455,11 @@ valpy_float (PyObject *self) d = value_as_double (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return PyFloat_FromDouble (d); } @@ -1431,12 +1506,11 @@ struct value * convert_value_from_python (PyObject *obj) { struct value *value = NULL; /* -Wall */ - volatile struct gdb_exception except; int cmp; gdb_assert (obj != NULL); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (PyBool_Check (obj)) { @@ -1532,13 +1606,14 @@ convert_value_from_python (PyObject *obj) PyString_AsString (PyObject_Str (obj))); #endif } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { PyErr_Format (except.reason == RETURN_QUIT ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, "%s", except.message); return NULL; } + END_CATCH return value; } @@ -1549,16 +1624,19 @@ gdbpy_history (PyObject *self, PyObject *args) { int i; struct value *res_val = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "i", &i)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = access_value_history (i); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (res_val); } diff --git a/gdb/python/python.c b/gdb/python/python.c index c3ffbae..58c7c92 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -564,21 +564,27 @@ gdbpy_parameter_value (enum var_types type, void *var) PyObject * gdbpy_parameter (PyObject *self, PyObject *args) { + struct gdb_exception except = exception_none; struct cmd_list_element *alias, *prefix, *cmd; const char *arg; char *newarg; int found = -1; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "s", &arg)) return NULL; newarg = concat ("show ", arg, (char *) NULL); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + xfree (newarg); GDB_PY_HANDLE_EXCEPTION (except); if (!found) @@ -619,7 +625,6 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) const char *arg; PyObject *from_tty_obj = NULL, *to_string_obj = NULL; int from_tty, to_string; - volatile struct gdb_exception except; static char *keywords[] = {"command", "from_tty", "to_string", NULL }; char *result = NULL; @@ -646,7 +651,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) to_string = cmp; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Copy the argument text in case the command modifies it. */ char *copy = xstrdup (arg); @@ -666,7 +671,11 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); @@ -710,6 +719,7 @@ gdbpy_solib_name (PyObject *self, PyObject *args) static PyObject * gdbpy_decode_line (PyObject *self, PyObject *args) { + struct gdb_exception except = exception_none; struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */ struct symtab_and_line sal; @@ -719,7 +729,6 @@ gdbpy_decode_line (PyObject *self, PyObject *args) PyObject *result = NULL; PyObject *return_result = NULL; PyObject *unparsed = NULL; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "|s", &arg)) return NULL; @@ -727,7 +736,8 @@ gdbpy_decode_line (PyObject *self, PyObject *args) cleanups = make_cleanup (null_cleanup, NULL); sals.sals = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + + TRY { if (arg) { @@ -743,6 +753,11 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals.nelts = 1; } } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH if (sals.sals != NULL && sals.sals != &sal) { @@ -824,16 +839,19 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) { const char *expr_str; struct value *result = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "s", &expr_str)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = parse_and_eval (expr_str); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (result); } @@ -845,13 +863,12 @@ static PyObject * gdbpy_find_pc_line (PyObject *self, PyObject *args) { gdb_py_ulongest pc_llu; - volatile struct gdb_exception except; PyObject *result = NULL; /* init for gcc -Wall */ if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct symtab_and_line sal; CORE_ADDR pc; @@ -860,7 +877,11 @@ gdbpy_find_pc_line (PyObject *self, PyObject *args) sal = find_pc_line (pc, 0); result = symtab_and_line_to_sal_object (sal); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1096,13 +1117,12 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) const char *arg; static char *keywords[] = {"text", "stream", NULL }; int stream_type = 0; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg, &stream_type)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (stream_type) { @@ -1120,7 +1140,11 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) fprintf_filtered (gdb_stdout, "%s", arg); } } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -1165,7 +1189,6 @@ gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw) void gdbpy_print_stack (void) { - volatile struct gdb_exception except; /* Print "none", just clear exception. */ if (gdbpy_should_print_stack == python_excp_none) @@ -1179,10 +1202,14 @@ gdbpy_print_stack (void) /* PyErr_Print doesn't necessarily end output with a newline. This works because Python's stdout/stderr is fed through printf_filtered. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { begin_line (); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH } /* Print "message", just error print message. */ else @@ -1196,7 +1223,7 @@ gdbpy_print_stack (void) msg = gdbpy_exception_to_string (ptype, pvalue); type = gdbpy_obj_to_string (ptype); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (msg == NULL) { @@ -1210,6 +1237,10 @@ gdbpy_print_stack (void) fprintf_filtered (gdb_stderr, "Python Exception %s %s: \n", type, msg); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH Py_XDECREF (ptype); Py_XDECREF (pvalue); |