diff options
author | Tom Tromey <tom@tromey.com> | 2019-04-03 16:02:42 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-04-08 09:05:39 -0600 |
commit | a70b814420059e1f2de2130d532ddd7b2b2500fc (patch) | |
tree | ce50952af2443675e67a60508a10c8fd5ab0715c /gdb/python | |
parent | 3d6e9d2336c9ffcedb10f89631981a23dd518e8e (diff) | |
download | fsf-binutils-gdb-a70b814420059e1f2de2130d532ddd7b2b2500fc.zip fsf-binutils-gdb-a70b814420059e1f2de2130d532ddd7b2b2500fc.tar.gz fsf-binutils-gdb-a70b814420059e1f2de2130d532ddd7b2b2500fc.tar.bz2 |
Rewrite TRY/CATCH
This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was
largely written by script, though one change (to a comment in
common-exceptions.h) was reverted by hand.
gdb/ChangeLog
2019-04-08 Tom Tromey <tom@tromey.com>
* xml-support.c: Use C++ exception handling.
* x86-linux-nat.c: Use C++ exception handling.
* windows-nat.c: Use C++ exception handling.
* varobj.c: Use C++ exception handling.
* value.c: Use C++ exception handling.
* valprint.c: Use C++ exception handling.
* valops.c: Use C++ exception handling.
* unittests/parse-connection-spec-selftests.c: Use C++ exception
handling.
* unittests/cli-utils-selftests.c: Use C++ exception handling.
* typeprint.c: Use C++ exception handling.
* tui/tui.c: Use C++ exception handling.
* tracefile-tfile.c: Use C++ exception handling.
* top.c: Use C++ exception handling.
* thread.c: Use C++ exception handling.
* target.c: Use C++ exception handling.
* symmisc.c: Use C++ exception handling.
* symfile-mem.c: Use C++ exception handling.
* stack.c: Use C++ exception handling.
* sparc64-linux-tdep.c: Use C++ exception handling.
* solib.c: Use C++ exception handling.
* solib-svr4.c: Use C++ exception handling.
* solib-spu.c: Use C++ exception handling.
* solib-frv.c: Use C++ exception handling.
* solib-dsbt.c: Use C++ exception handling.
* selftest-arch.c: Use C++ exception handling.
* s390-tdep.c: Use C++ exception handling.
* rust-lang.c: Use C++ exception handling.
* rust-exp.y: Use C++ exception handling.
* rs6000-tdep.c: Use C++ exception handling.
* rs6000-aix-tdep.c: Use C++ exception handling.
* riscv-tdep.c: Use C++ exception handling.
* remote.c: Use C++ exception handling.
* remote-fileio.c: Use C++ exception handling.
* record-full.c: Use C++ exception handling.
* record-btrace.c: Use C++ exception handling.
* python/python.c: Use C++ exception handling.
* python/py-value.c: Use C++ exception handling.
* python/py-utils.c: Use C++ exception handling.
* python/py-unwind.c: Use C++ exception handling.
* python/py-type.c: Use C++ exception handling.
* python/py-symbol.c: Use C++ exception handling.
* python/py-record.c: Use C++ exception handling.
* python/py-record-btrace.c: Use C++ exception handling.
* python/py-progspace.c: Use C++ exception handling.
* python/py-prettyprint.c: Use C++ exception handling.
* python/py-param.c: Use C++ exception handling.
* python/py-objfile.c: Use C++ exception handling.
* python/py-linetable.c: Use C++ exception handling.
* python/py-lazy-string.c: Use C++ exception handling.
* python/py-infthread.c: Use C++ exception handling.
* python/py-inferior.c: Use C++ exception handling.
* python/py-gdb-readline.c: Use C++ exception handling.
* python/py-framefilter.c: Use C++ exception handling.
* python/py-frame.c: Use C++ exception handling.
* python/py-finishbreakpoint.c: Use C++ exception handling.
* python/py-cmd.c: Use C++ exception handling.
* python/py-breakpoint.c: Use C++ exception handling.
* python/py-arch.c: Use C++ exception handling.
* printcmd.c: Use C++ exception handling.
* ppc-linux-tdep.c: Use C++ exception handling.
* parse.c: Use C++ exception handling.
* p-valprint.c: Use C++ exception handling.
* objc-lang.c: Use C++ exception handling.
* mi/mi-main.c: Use C++ exception handling.
* mi/mi-interp.c: Use C++ exception handling.
* mi/mi-cmd-stack.c: Use C++ exception handling.
* mi/mi-cmd-break.c: Use C++ exception handling.
* main.c: Use C++ exception handling.
* linux-thread-db.c: Use C++ exception handling.
* linux-tdep.c: Use C++ exception handling.
* linux-nat.c: Use C++ exception handling.
* linux-fork.c: Use C++ exception handling.
* linespec.c: Use C++ exception handling.
* language.c: Use C++ exception handling.
* jit.c: Use C++ exception handling.
* infrun.c: Use C++ exception handling.
* infcmd.c: Use C++ exception handling.
* infcall.c: Use C++ exception handling.
* inf-loop.c: Use C++ exception handling.
* i386-tdep.c: Use C++ exception handling.
* i386-linux-tdep.c: Use C++ exception handling.
* guile/scm-value.c: Use C++ exception handling.
* guile/scm-type.c: Use C++ exception handling.
* guile/scm-symtab.c: Use C++ exception handling.
* guile/scm-symbol.c: Use C++ exception handling.
* guile/scm-pretty-print.c: Use C++ exception handling.
* guile/scm-ports.c: Use C++ exception handling.
* guile/scm-param.c: Use C++ exception handling.
* guile/scm-math.c: Use C++ exception handling.
* guile/scm-lazy-string.c: Use C++ exception handling.
* guile/scm-frame.c: Use C++ exception handling.
* guile/scm-disasm.c: Use C++ exception handling.
* guile/scm-cmd.c: Use C++ exception handling.
* guile/scm-breakpoint.c: Use C++ exception handling.
* guile/scm-block.c: Use C++ exception handling.
* guile/guile-internal.h: Use C++ exception handling.
* gnu-v3-abi.c: Use C++ exception handling.
* gdbtypes.c: Use C++ exception handling.
* frame.c: Use C++ exception handling.
* frame-unwind.c: Use C++ exception handling.
* fbsd-tdep.c: Use C++ exception handling.
* f-valprint.c: Use C++ exception handling.
* exec.c: Use C++ exception handling.
* event-top.c: Use C++ exception handling.
* event-loop.c: Use C++ exception handling.
* eval.c: Use C++ exception handling.
* dwarf2read.c: Use C++ exception handling.
* dwarf2loc.c: Use C++ exception handling.
* dwarf2-frame.c: Use C++ exception handling.
* dwarf2-frame-tailcall.c: Use C++ exception handling.
* dwarf-index-write.c: Use C++ exception handling.
* dwarf-index-cache.c: Use C++ exception handling.
* dtrace-probe.c: Use C++ exception handling.
* disasm-selftests.c: Use C++ exception handling.
* darwin-nat.c: Use C++ exception handling.
* cp-valprint.c: Use C++ exception handling.
* cp-support.c: Use C++ exception handling.
* cp-abi.c: Use C++ exception handling.
* corelow.c: Use C++ exception handling.
* completer.c: Use C++ exception handling.
* compile/compile-object-run.c: Use C++ exception handling.
* compile/compile-object-load.c: Use C++ exception handling.
* compile/compile-cplus-symbols.c: Use C++ exception handling.
* compile/compile-c-symbols.c: Use C++ exception handling.
* common/selftest.c: Use C++ exception handling.
* common/new-op.c: Use C++ exception handling.
* cli/cli-script.c: Use C++ exception handling.
* cli/cli-interp.c: Use C++ exception handling.
* cli/cli-cmds.c: Use C++ exception handling.
* c-varobj.c: Use C++ exception handling.
* btrace.c: Use C++ exception handling.
* breakpoint.c: Use C++ exception handling.
* break-catch-throw.c: Use C++ exception handling.
* arch-utils.c: Use C++ exception handling.
* amd64-tdep.c: Use C++ exception handling.
* ada-valprint.c: Use C++ exception handling.
* ada-typeprint.c: Use C++ exception handling.
* ada-lang.c: Use C++ exception handling.
* aarch64-tdep.c: Use C++ exception handling.
gdb/gdbserver/ChangeLog
2019-04-08 Tom Tromey <tom@tromey.com>
* server.c: Use C++ exception handling.
* linux-low.c: Use C++ exception handling.
* gdbreplay.c: Use C++ exception handling.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-arch.c | 5 | ||||
-rw-r--r-- | gdb/python/py-breakpoint.c | 40 | ||||
-rw-r--r-- | gdb/python/py-cmd.c | 5 | ||||
-rw-r--r-- | gdb/python/py-finishbreakpoint.c | 30 | ||||
-rw-r--r-- | gdb/python/py-frame.c | 90 | ||||
-rw-r--r-- | gdb/python/py-framefilter.c | 10 | ||||
-rw-r--r-- | gdb/python/py-gdb-readline.c | 5 | ||||
-rw-r--r-- | gdb/python/py-inferior.c | 25 | ||||
-rw-r--r-- | gdb/python/py-infthread.c | 5 | ||||
-rw-r--r-- | gdb/python/py-lazy-string.c | 5 | ||||
-rw-r--r-- | gdb/python/py-linetable.c | 5 | ||||
-rw-r--r-- | gdb/python/py-objfile.c | 10 | ||||
-rw-r--r-- | gdb/python/py-param.c | 5 | ||||
-rw-r--r-- | gdb/python/py-prettyprint.c | 10 | ||||
-rw-r--r-- | gdb/python/py-progspace.c | 10 | ||||
-rw-r--r-- | gdb/python/py-record-btrace.c | 20 | ||||
-rw-r--r-- | gdb/python/py-record.c | 10 | ||||
-rw-r--r-- | gdb/python/py-symbol.c | 25 | ||||
-rw-r--r-- | gdb/python/py-type.c | 90 | ||||
-rw-r--r-- | gdb/python/py-unwind.c | 20 | ||||
-rw-r--r-- | gdb/python/py-utils.c | 5 | ||||
-rw-r--r-- | gdb/python/py-value.c | 155 | ||||
-rw-r--r-- | gdb/python/python.c | 35 |
23 files changed, 248 insertions, 372 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 23cb2c5..c7c6fae 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -199,16 +199,15 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) string_file stb; - TRY + try { insn_len = gdb_print_insn (gdbarch, pc, &stb, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH if (PyDict_SetItemString (insn_dict.get (), "addr", gdb_py_long_from_ulongest (pc)) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index ba3b4f0..16c717c 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -138,18 +138,17 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) if (cmp < 0) return -1; - TRY + try { if (cmp == 1) enable_breakpoint (self_bp->bp); else disable_breakpoint (self_bp->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return 0; } @@ -247,15 +246,14 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) if (! gdb_py_int_as_long (newvalue, &id)) return -1; - TRY + try { valid_id = valid_task_id (id); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH if (! valid_id) { @@ -290,15 +288,14 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args) BPPY_REQUIRE_VALID (self_bp); - TRY + try { delete_breakpoint (self_bp->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -332,15 +329,14 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) if (value < 0) value = 0; - TRY + try { set_ignore_count (self_bp->number, (int) value, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return 0; } @@ -469,15 +465,14 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) exp = exp_holder.get (); } - TRY + try { set_breakpoint_condition (self_bp->bp, exp, 0); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_SET_HANDLE_EXCEPTION (except); @@ -499,17 +494,16 @@ bppy_get_commands (PyObject *self, void *closure) string_file stb; current_uiout->redirect (&stb); - TRY + try { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { current_uiout->redirect (NULL); gdbpy_convert_exception (except); return NULL; } - END_CATCH current_uiout->redirect (NULL); return host_string_to_python_string (stb.c_str ()).release (); @@ -530,7 +524,7 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure) if (commands == nullptr) return -1; - TRY + try { bool first = true; char *save_ptr = nullptr; @@ -546,11 +540,10 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure) counted_command_line lines = read_command_lines_1 (reader, 1, nullptr); breakpoint_set_commands (self_bp->bp, std::move (lines)); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_SET_HANDLE_EXCEPTION (except); @@ -801,7 +794,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY + try { switch (type) { @@ -871,13 +864,12 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) error(_("Do not understand breakpoint type to set.")); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { bppy_pending_object = NULL; gdbpy_convert_exception (except); 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 1677c3d..2432127 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -541,7 +541,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self); - TRY + try { struct cmd_list_element *cmd; @@ -572,7 +572,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) set_cmd_completer_handle_brkchars (cmd, cmdpy_completer_handle_brkchars); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (cmd_name); xfree (docstring); @@ -580,7 +580,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) gdbpy_convert_exception (except); return -1; } - END_CATCH return 0; } diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index f3affbd..6faffd2e 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -101,7 +101,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) if (!self_finishbp->return_type) return; - TRY + try { struct value *function = value_object_to_value (self_finishbp->function_value); @@ -121,12 +121,11 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) self_finishbp->return_value = Py_None; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } /* Triggered when gdbpy_should_stop has triggered the `stop' callback @@ -136,18 +135,17 @@ void bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { - TRY + 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); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } /* Python function to create a new breakpoint. */ @@ -172,7 +170,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &frame_obj, &internal)) return -1; - TRY + try { /* Default frame to newest frame if necessary. */ if (frame_obj == NULL) @@ -210,12 +208,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return -1; } - END_CATCH if (PyErr_Occurred ()) return -1; @@ -244,7 +241,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) self_bpfinish->return_type = NULL; self_bpfinish->function_value = NULL; - TRY + try { if (get_frame_pc_if_available (frame, &pc)) { @@ -270,12 +267,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* 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) { @@ -291,7 +287,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY + try { /* Set a breakpoint on the return address. */ event_location_up location @@ -306,11 +302,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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; @@ -362,19 +357,18 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) /* Check scope if not currently stopped at the FinishBreakpoint. */ if (b != bp_stopped) { - TRY + try { if (b->pspace == current_inferior ()->pspace && (!target_has_registers || frame_find_by_id (b->frame_id) == NULL)) bpfinishpy_out_of_scope (finish_bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 0eef654..9066f60 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -95,15 +95,14 @@ frapy_is_valid (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = frame_object_to_frame_info (self); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (frame == NULL) Py_RETURN_FALSE; @@ -122,17 +121,16 @@ frapy_name (PyObject *self, PyObject *args) enum language lang; PyObject *result; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); name = find_frame_funname (frame, &lang, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (name) { @@ -157,17 +155,16 @@ frapy_type (PyObject *self, PyObject *args) struct frame_info *frame; enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); type = get_frame_type (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyInt_FromLong (type); } @@ -181,15 +178,14 @@ frapy_arch (PyObject *self, PyObject *args) struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ frame_object *obj = (frame_object *) self; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return gdbarch_to_arch_object (obj->gdbarch); } @@ -203,15 +199,14 @@ frapy_unwind_stop_reason (PyObject *self, PyObject *args) struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ enum unwind_stop_reason stop_reason; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH stop_reason = get_frame_unwind_stop_reason (frame); @@ -227,17 +222,16 @@ frapy_pc (PyObject *self, PyObject *args) CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ struct frame_info *frame; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); pc = get_frame_pc (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return gdb_py_long_from_ulongest (pc); } @@ -254,7 +248,7 @@ frapy_read_register (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", ®num_str)) return NULL; - TRY + try { struct frame_info *frame; int regnum; @@ -270,11 +264,10 @@ frapy_read_register (PyObject *self, PyObject *args) if (val == NULL) PyErr_SetString (PyExc_ValueError, _("Unknown register.")); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return val == NULL ? NULL : value_to_value_object (val); } @@ -288,16 +281,15 @@ frapy_block (PyObject *self, PyObject *args) struct frame_info *frame; const struct block *block = NULL, *fn_block; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); block = get_frame_block (frame, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH for (fn_block = block; fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL; @@ -330,7 +322,7 @@ frapy_function (PyObject *self, PyObject *args) struct symbol *sym = NULL; struct frame_info *frame; - TRY + try { enum language funlang; @@ -339,11 +331,10 @@ frapy_function (PyObject *self, PyObject *args) gdb::unique_xmalloc_ptr<char> funname = find_frame_funname (frame, &funlang, &sym); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (sym) return symbol_to_symbol_object (sym); @@ -362,7 +353,7 @@ frame_info_to_frame_object (struct frame_info *frame) if (frame_obj == NULL) return NULL; - TRY + try { /* Try to get the previous frame, to determine if this is the last frame @@ -382,12 +373,11 @@ frame_info_to_frame_object (struct frame_info *frame) } frame_obj->gdbarch = get_frame_arch (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return (PyObject *) frame_obj.release (); } @@ -402,17 +392,16 @@ frapy_older (PyObject *self, PyObject *args) struct frame_info *frame, *prev = NULL; PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); prev = get_prev_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (prev) prev_obj = frame_info_to_frame_object (prev); @@ -435,17 +424,16 @@ frapy_newer (PyObject *self, PyObject *args) struct frame_info *frame, *next = NULL; PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); next = get_next_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (next) next_obj = frame_info_to_frame_object (next); @@ -467,18 +455,17 @@ frapy_find_sal (PyObject *self, PyObject *args) struct frame_info *frame; PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); symtab_and_line sal = find_frame_sal (frame); sal_obj = symtab_and_line_to_sal_object (sal); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return sal_obj; } @@ -523,7 +510,7 @@ frapy_read_var (PyObject *self, PyObject *args) } } - TRY + try { struct block_symbol lookup_sym; FRAPY_REQUIRE_VALID (self, frame); @@ -534,12 +521,11 @@ frapy_read_var (PyObject *self, PyObject *args) var = lookup_sym.symbol; block = lookup_sym.block; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH if (!var) { @@ -556,17 +542,16 @@ frapy_read_var (PyObject *self, PyObject *args) return NULL; } - TRY + try { FRAPY_REQUIRE_VALID (self, frame); val = read_var_value (var, block, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -578,17 +563,16 @@ frapy_select (PyObject *self, PyObject *args) { struct frame_info *fi; - TRY + try { FRAPY_REQUIRE_VALID (self, fi); select_frame (fi); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -601,15 +585,14 @@ gdbpy_newest_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = get_current_frame (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return frame_info_to_frame_object (frame); } @@ -622,15 +605,14 @@ gdbpy_selected_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = get_selected_frame ("No frame is currently selected."); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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 7b241bb..deb4a8f 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -1081,16 +1081,15 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, if (!gdb_python_initialized) return EXT_LANG_BT_NO_FILTERS; - TRY + try { gdbarch = get_frame_arch (frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* Let gdb try to print the stack trace. */ return EXT_LANG_BT_NO_FILTERS; } - END_CATCH gdbpy_enter enter_py (gdbarch, current_language); @@ -1166,17 +1165,16 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, } } - TRY + try { success = py_print_frame (item.get (), flags, args_type, out, 0, levels_printed.get ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { gdbpy_convert_exception (except); success = EXT_LANG_BT_ERROR; } - END_CATCH /* Do not exit on error printing a single frame. Print the error and continue with other frames. */ diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index 1e6cd73..51ec6d8 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -39,12 +39,12 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, int n; char *p = NULL, *q; - TRY + try { p = command_line_input (prompt, "python"); } /* Handle errors by raising Python exceptions. */ - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* Detect user interrupt (Ctrl-C). */ if (except.reason == RETURN_QUIT) @@ -59,7 +59,6 @@ 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 72fbf6d..fee6b30 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -389,15 +389,14 @@ infpy_threads (PyObject *self, PyObject *args) INFPY_REQUIRE_VALID (inf_obj); - TRY + try { update_thread_list (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH tuple = PyTuple_New (inf_obj->nthreads); if (!tuple) @@ -508,17 +507,16 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) || get_addr_from_python (length_obj, &length) < 0) return NULL; - TRY + try { buffer.reset ((gdb_byte *) xmalloc (length)); read_memory (addr, buffer.get (), length); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<membuf_object> membuf_obj (PyObject_New (membuf_object, &membuf_object_type)); @@ -572,15 +570,14 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) else if (get_addr_from_python (length_obj, &length) < 0) return nullptr; - TRY + try { write_memory_with_notification (addr, buffer, length); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -725,17 +722,16 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) return nullptr; } - TRY + try { found = target_search_memory (start_addr, length, buffer, pattern_size, &found_addr); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -782,7 +778,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - TRY + try { struct thread_info *thread_info; struct value *val = value_object_to_value (handle_obj); @@ -791,11 +787,10 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) if (thread_info != NULL) return thread_to_thread_object (thread_info).release (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index bf90d08..3c6d147 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -181,15 +181,14 @@ thpy_switch (PyObject *self, PyObject *args) THPY_REQUIRE_VALID (thread_obj); - TRY + try { switch_to_thread (thread_obj->thread); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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 443aeb7..61722d9 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -113,7 +113,7 @@ stpy_convert_to_value (PyObject *self, PyObject *args) return NULL; } - TRY + try { struct type *type = type_object_to_type (self_string->type); struct type *realtype; @@ -142,11 +142,10 @@ stpy_convert_to_value (PyObject *self, PyObject *args) break; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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 b9d74b8..813b2d9 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -164,15 +164,14 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args) if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line)) return NULL; - TRY + try { pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return build_line_table_tuple_from_pcs (py_line, pcs); } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 67f63b3..75ccc18 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -130,15 +130,14 @@ objfpy_get_build_id (PyObject *self, void *closure) OBJFPY_REQUIRE_VALID (obj); - TRY + try { build_id = build_id_bfd_get (objfile->obfd); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (build_id != NULL) { @@ -421,17 +420,16 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw) if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name)) return NULL; - TRY + try { gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name)); symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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 3b79a5c..c211d47 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -726,21 +726,20 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) Py_INCREF (self); - TRY + try { add_setshow_generic (parmclass, (enum command_class) cmdtype, cmd_name, obj, set_doc.get (), show_doc.get (), doc.get (), set_list, show_list); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (cmd_name); Py_DECREF (self); gdbpy_convert_exception (except); return -1; } - END_CATCH return 0; } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index e64d1f8..a02965d 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -190,7 +190,7 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) gdbpy_ref<> result; *out_value = NULL; - TRY + try { if (!PyObject_HasAttr (printer, gdbpy_to_string_cst)) result = gdbpy_ref<>::new_reference (Py_None); @@ -212,10 +212,9 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH return result; } @@ -637,15 +636,14 @@ apply_varobj_pretty_printer (PyObject *printer_obj, gdbpy_ref<> gdbpy_get_varobj_pretty_printer (struct value *value) { - TRY + try { value = value_copy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> val_obj (value_to_value_object (value)); if (val_obj == NULL) diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index b82a91b..eb6acb2 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -381,7 +381,7 @@ pspy_block_for_pc (PyObject *o, PyObject *args) if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) return NULL; - TRY + try { scoped_restore_current_program_space saver; @@ -391,11 +391,10 @@ pspy_block_for_pc (PyObject *o, PyObject *args) if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { @@ -425,7 +424,7 @@ pspy_find_pc_line (PyObject *o, PyObject *args) if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu)) return NULL; - TRY + try { struct symtab_and_line sal; CORE_ADDR pc; @@ -437,11 +436,10 @@ pspy_find_pc_line (PyObject *o, PyObject *args) sal = find_pc_line (pc, 0); result = symtab_and_line_to_sal_object (sal); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 229a3b8..64b25fa 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -208,15 +208,14 @@ recpy_bt_insn_sal (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { result = symtab_and_line_to_sal_object (find_pc_line (insn->pc, 0)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -279,16 +278,15 @@ recpy_bt_insn_data (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { buffer.resize (insn->size); read_memory (insn->pc, buffer.data (), insn->size); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH object = PyBytes_FromStringAndSize ((const char *) buffer.data (), insn->size); @@ -316,16 +314,15 @@ recpy_bt_insn_decoded (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { gdb_print_insn (target_gdbarch (), insn->pc, &strfile, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return PyBytes_FromString (strfile.string ().c_str ()); @@ -787,7 +784,7 @@ recpy_bt_goto (PyObject *self, PyObject *args) return PyErr_Format (PyExc_TypeError, _("Argument must be instruction.")); obj = (const recpy_element_object *) parse_obj; - TRY + try { struct btrace_insn_iterator iter; @@ -798,11 +795,10 @@ recpy_bt_goto (PyObject *self, PyObject *args) else target_goto_record (obj->number); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c index e818560..66fa8bf 100644 --- a/gdb/python/py-record.c +++ b/gdb/python/py-record.c @@ -602,16 +602,15 @@ gdbpy_start_recording (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "|ss", &method, &format)) return NULL; - TRY + try { record_start (method, format, 0); ret = gdbpy_current_recording (self, args); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); } - END_CATCH return ret; } @@ -638,15 +637,14 @@ gdbpy_current_recording (PyObject *self, PyObject *args) PyObject * gdbpy_stop_recording (PyObject *self, PyObject *args) { - TRY + try { record_stop (0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index afff995..63d8ab1 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -196,15 +196,14 @@ sympy_needs_frame (PyObject *self, void *closure) SYMPY_REQUIRE_VALID (self, symbol); - TRY + try { result = symbol_read_needs_frame (symbol); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (result) Py_RETURN_TRUE; @@ -266,7 +265,7 @@ sympy_value (PyObject *self, PyObject *args) return NULL; } - TRY + try { if (frame_obj != NULL) { @@ -284,11 +283,10 @@ sympy_value (PyObject *self, PyObject *args) can happen with nested functions). */ value = read_var_value (symbol, NULL, frame_info); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (value); } @@ -388,28 +386,26 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) { struct frame_info *selected_frame; - TRY + try { selected_frame = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } - TRY + try { symbol = lookup_symbol (name, block, (domain_enum) domain, &is_a_field_of_this).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> ret_tuple (PyTuple_New (2)); if (ret_tuple == NULL) @@ -451,15 +447,14 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) &domain)) return NULL; - TRY + try { symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (symbol) { diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index c908ec6..d918fc0 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -312,15 +312,14 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) struct type *type = ((type_object *) py_type)->type; struct type *checked_type = type; - TRY + try { checked_type = check_typedef (checked_type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> type_holder; if (checked_type != type) @@ -420,15 +419,14 @@ typy_strip_typedefs (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -442,15 +440,14 @@ typy_get_composite (struct type *type) for (;;) { - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_IS_REFERENCE (type)) break; @@ -510,17 +507,16 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) return NULL; } - TRY + try { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (array); } @@ -547,15 +543,14 @@ typy_pointer (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = lookup_pointer_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -616,15 +611,14 @@ typy_reference (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = lookup_lvalue_reference_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -651,15 +645,14 @@ typy_const (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (1, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -670,15 +663,14 @@ typy_volatile (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (0, 1, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -689,15 +681,14 @@ typy_unqualified (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (0, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -708,14 +699,13 @@ typy_get_sizeof (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; - TRY + try { check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH /* Ignore exceptions. */ @@ -729,15 +719,14 @@ typy_get_alignof (PyObject *self, void *closure) struct type *type = ((type_object *) self)->type; ULONGEST align = 0; - TRY + try { align = type_align (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { align = 0; } - END_CATCH /* Ignore exceptions. */ @@ -749,7 +738,7 @@ typy_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - TRY + try { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -761,11 +750,10 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (python_language, python_gdbarch, type_name, block, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type; } @@ -791,7 +779,7 @@ typy_lookup_type (struct demangle_component *demangled, if (! type) return NULL; - TRY + try { /* If the demangled_type matches with one of the types below, run the corresponding function and save the type @@ -816,11 +804,10 @@ typy_lookup_type (struct demangle_component *demangled, break; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } /* If we have a type from the switch statement above, just return @@ -854,16 +841,15 @@ typy_legacy_template_argument (struct type *type, const struct block *block, return NULL; } - TRY + try { /* Note -- this is not thread-safe. */ info = cp_demangled_name_to_comp (TYPE_NAME (type), &err); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (! info) { @@ -934,17 +920,16 @@ typy_template_argument (PyObject *self, PyObject *args) } } - TRY + try { type = check_typedef (type); if (TYPE_IS_REFERENCE (type)) type = check_typedef (TYPE_TARGET_TYPE (type)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { 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 -- @@ -969,15 +954,14 @@ typy_template_argument (PyObject *self, PyObject *args) return NULL; } - TRY + try { val = value_of_variable (sym, block); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -987,16 +971,15 @@ typy_str (PyObject *self) { string_file thetype; - TRY + try { LA_PRINT_TYPE (type_object_to_type (self), "", &thetype, -1, 0, &type_print_raw_options); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (thetype.c_str (), thetype.size (), host_charset (), NULL); @@ -1023,17 +1006,16 @@ typy_richcompare (PyObject *self, PyObject *other, int op) result = true; else { - TRY + try { result = types_deeply_equal (type1, type2); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* 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-unwind.c b/gdb/python/py-unwind.c index f07a8d8..e506ec0 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -141,7 +141,7 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) int rc = 0; struct value *value; - TRY + try { if ((value = value_object_to_value (pyo_value)) != NULL) { @@ -150,11 +150,10 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) rc = 1; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); } - END_CATCH return rc; } @@ -211,16 +210,15 @@ unwind_infopy_str (PyObject *self) stb.printf ("%s(%d, ", sep, reg.number); if (value != NULL) { - TRY + try { value_print (value, &stb, &opts); stb.puts (")"); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } else stb.puts ("<BAD>)"); @@ -346,16 +344,15 @@ pending_framepy_str (PyObject *self) if (frame == NULL) return PyString_FromString ("Stale PendingFrame instance"); - TRY + try { sp_str = core_addr_to_string_nz (get_frame_sp (frame)); pc_str = core_addr_to_string_nz (get_frame_pc (frame)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str); } @@ -385,7 +382,7 @@ pending_framepy_read_register (PyObject *self, PyObject *args) return NULL; } - TRY + try { /* Fetch the value associated with a register, whether it's a real register or a so called "user" register, like "pc", @@ -398,11 +395,10 @@ pending_framepy_read_register (PyObject *self, PyObject *args) "Cannot read register %d from frame.", regnum); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return val == NULL ? NULL : value_to_value_object (val); } diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 87715ee..76b5ac0 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -254,15 +254,14 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) if (gdbpy_is_value_object (obj)) { - TRY + try { *addr = value_as_address (value_object_to_value (obj)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH } else { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 1dcb60d..a761b1e 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -216,7 +216,7 @@ valpy_dereference (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *res_val; scoped_value_mark free_values; @@ -224,11 +224,10 @@ valpy_dereference (PyObject *self, PyObject *args) res_val = value_ind (((value_object *) self)->value); result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -246,7 +245,7 @@ valpy_referenced_value (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *self_val, *res_val; scoped_value_mark free_values; @@ -268,11 +267,10 @@ valpy_referenced_value (PyObject *self, PyObject *args) result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -284,7 +282,7 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode) { PyObject *result = NULL; - TRY + try { struct value *self_val; scoped_value_mark free_values; @@ -292,11 +290,10 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode) self_val = ((value_object *) self)->value; result = value_to_value_object (value_ref (self_val, refcode)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -320,7 +317,7 @@ valpy_const_value (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *self_val, *res_val; scoped_value_mark free_values; @@ -329,11 +326,10 @@ valpy_const_value (PyObject *self, PyObject *args) res_val = make_cv_value (1, 0, self_val); result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -346,7 +342,7 @@ valpy_get_address (PyObject *self, void *closure) if (!val_obj->address) { - TRY + try { struct value *res_val; scoped_value_mark free_values; @@ -354,12 +350,11 @@ valpy_get_address (PyObject *self, void *closure) res_val = value_addr (val_obj->value); val_obj->address = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { val_obj->address = Py_None; Py_INCREF (Py_None); } - END_CATCH } Py_XINCREF (val_obj->address); @@ -397,7 +392,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) return obj->dynamic_type; } - TRY + try { struct value *val = obj->value; scoped_value_mark free_values; @@ -433,11 +428,10 @@ valpy_get_dynamic_type (PyObject *self, void *closure) type = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (type == NULL) obj->dynamic_type = valpy_get_type (self, NULL); @@ -485,7 +479,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - TRY + try { scoped_value_mark free_values; struct type *type, *realtype; @@ -540,11 +534,10 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding, type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return str_obj; } @@ -572,15 +565,14 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) &user_encoding, &errors, &length)) return NULL; - TRY + try { LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; return PyUnicode_Decode ((const char *) buffer.get (), @@ -733,16 +725,15 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) string_file stb; - TRY + try { common_val_print (((value_object *) self)->value, &stb, 0, &opts, python_language); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -766,7 +757,7 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) return NULL; } - TRY + try { struct value *val = ((value_object *) self)->value; struct value *res_val; @@ -784,11 +775,10 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -849,7 +839,7 @@ value_has_field (struct value *v, PyObject *field) return -1; } - TRY + try { val_type = value_type (v); val_type = check_typedef (val_type); @@ -863,11 +853,10 @@ value_has_field (struct value *v, PyObject *field) else has_field = 0; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return has_field; } @@ -988,7 +977,7 @@ valpy_getitem (PyObject *self, PyObject *key) } } - TRY + try { struct value *tmp = self_value->value; struct value *res_val = NULL; @@ -1042,11 +1031,10 @@ valpy_getitem (PyObject *self, PyObject *key) if (res_val) result = value_to_value_object (res_val); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -1072,15 +1060,14 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) struct type *ftype = NULL; PyObject *result = NULL; - TRY + try { ftype = check_typedef (value_type (function)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_CODE (ftype) != TYPE_CODE_FUNC) { @@ -1115,7 +1102,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) } } - TRY + try { scoped_value_mark free_values; @@ -1124,11 +1111,10 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) gdb::make_array_view (vargs, args_count)); result = value_to_value_object (return_value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1145,16 +1131,15 @@ valpy_str (PyObject *self) string_file stb; - TRY + try { common_val_print (((value_object *) self)->value, &stb, 0, &opts, python_language); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -1166,15 +1151,14 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) struct value *value = ((value_object *) self)->value; int opt = 0; - TRY + try { opt = value_optimized_out (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (opt) Py_RETURN_TRUE; @@ -1189,15 +1173,14 @@ valpy_get_is_lazy (PyObject *self, void *closure) struct value *value = ((value_object *) self)->value; int opt = 0; - TRY + try { opt = value_lazy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (opt) Py_RETURN_TRUE; @@ -1211,16 +1194,15 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) { struct value *value = ((value_object *) self)->value; - TRY + try { if (value_lazy (value)) value_fetch_lazy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -1384,15 +1366,14 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { PyObject *result = NULL; - TRY + try { result = valpy_binop_throw (opcode, self, other); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1448,7 +1429,7 @@ valpy_negative (PyObject *self) { PyObject *result = NULL; - TRY + try { /* Perhaps overkill, but consistency has some virtue. */ scoped_value_mark free_values; @@ -1457,11 +1438,10 @@ valpy_negative (PyObject *self) val = value_neg (((value_object *) self)->value); result = value_to_value_object (val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1478,18 +1458,17 @@ valpy_absolute (PyObject *self) struct value *value = ((value_object *) self)->value; int isabs = 1; - TRY + try { scoped_value_mark free_values; if (value_less (value, value_zero (value_type (value), not_lval))) isabs = 0; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (isabs) return valpy_positive (self); @@ -1506,7 +1485,7 @@ valpy_nonzero (PyObject *self) struct type *type; int nonzero = 0; /* Appease GCC warning. */ - TRY + try { type = check_typedef (value_type (self_value->value)); @@ -1519,11 +1498,10 @@ valpy_nonzero (PyObject *self) /* All other values are True. */ nonzero = 1; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { 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 @@ -1539,15 +1517,14 @@ valpy_invert (PyObject *self) { struct value *val = NULL; - TRY + try { val = value_complement (((value_object *) self)->value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -1667,15 +1644,14 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) return NULL; } - TRY + try { result = valpy_richcompare_throw (self, other, op); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH /* In this case, the Python exception has already been set. */ if (result < 0) @@ -1696,7 +1672,7 @@ valpy_int (PyObject *self) struct type *type = value_type (value); LONGEST l = 0; - TRY + try { if (is_floating_value (value)) { @@ -1710,11 +1686,10 @@ valpy_int (PyObject *self) l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_UNSIGNED (type)) return gdb_py_object_from_ulongest (l).release (); @@ -1731,7 +1706,7 @@ valpy_long (PyObject *self) struct type *type = value_type (value); LONGEST l = 0; - TRY + try { if (is_floating_value (value)) { @@ -1747,11 +1722,10 @@ valpy_long (PyObject *self) l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_UNSIGNED (type)) return gdb_py_long_from_ulongest (l); @@ -1767,7 +1741,7 @@ valpy_float (PyObject *self) struct type *type = value_type (value); double d = 0; - TRY + try { type = check_typedef (type); @@ -1783,11 +1757,10 @@ valpy_float (PyObject *self) else error (_("Cannot convert value to float.")); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyFloat_FromDouble (d); } @@ -1837,7 +1810,7 @@ convert_value_from_python (PyObject *obj) gdb_assert (obj != NULL); - TRY + try { if (PyBool_Check (obj)) { @@ -1927,12 +1900,11 @@ convert_value_from_python (PyObject *obj) PyString_AsString (PyObject_Str (obj))); #endif } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return value; } @@ -1947,15 +1919,14 @@ gdbpy_history (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "i", &i)) return NULL; - TRY + try { res_val = access_value_history (i); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (res_val); } @@ -1970,7 +1941,7 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &varname)) return NULL; - TRY + try { struct internalvar *var = lookup_only_internalvar (varname); @@ -1981,11 +1952,10 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) res_val = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (res_val == NULL) Py_RETURN_NONE; @@ -2012,7 +1982,7 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args) return NULL; } - TRY + try { if (value == NULL) { @@ -2028,11 +1998,10 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args) set_internalvar (var, value); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/python.c b/gdb/python/python.c index 0d9415c..503639e 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -497,15 +497,14 @@ gdbpy_parameter (PyObject *self, PyObject *args) std::string newarg = std::string ("show ") + arg; - TRY + try { found = lookup_cmd_composition (newarg.c_str (), &alias, &prefix, &cmd); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { GDB_PY_HANDLE_EXCEPTION (ex); } - END_CATCH if (!found) return PyErr_Format (PyExc_RuntimeError, @@ -574,7 +573,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) scoped_restore preventer = prevent_dont_repeat (); - TRY + try { gdbpy_allow_threads allow_threads; @@ -615,11 +614,10 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (to_string) return PyString_FromString (to_string_res.c_str ()); @@ -830,7 +828,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) std::vector<symtab_and_line> decoded_sals; symtab_and_line def_sal; gdb::array_view<symtab_and_line> sals; - TRY + try { if (location != NULL) { @@ -844,13 +842,12 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals = def_sal; } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* We know this will always throw. */ gdbpy_convert_exception (ex); return NULL; } - END_CATCH if (!sals.empty ()) { @@ -898,16 +895,15 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &expr_str)) return NULL; - TRY + try { gdbpy_allow_threads allow_threads; result = parse_and_eval (expr_str); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (result); } @@ -1136,7 +1132,7 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) &stream_type)) return NULL; - TRY + try { switch (stream_type) { @@ -1154,11 +1150,10 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) fprintf_filtered (gdb_stdout, "%s", arg); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -1224,14 +1219,13 @@ 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 + try { begin_line (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH } /* Print "message", just error print message. */ else @@ -1245,7 +1239,7 @@ gdbpy_print_stack (void) if (msg != NULL) type = fetched_error.type_to_string (); - TRY + try { if (msg == NULL || type == NULL) { @@ -1260,10 +1254,9 @@ gdbpy_print_stack (void) fprintf_filtered (gdb_stderr, "Python Exception %s %s: \n", type.get (), msg.get ()); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH } } |