diff options
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r-- | gdb/python/python.c | 69 |
1 files changed, 50 insertions, 19 deletions
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); |