diff options
author | Pedro Alves <palves@redhat.com> | 2015-03-07 14:50:04 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-03-07 14:56:43 +0000 |
commit | 7556d4a4f6c3181204e9575c08c661a632cafb5d (patch) | |
tree | 52bea387366e8dc0a141318bde5d9a8825337d70 /gdb/compile | |
parent | f873665f447ee4e36883e3122a4e35c2cd049045 (diff) | |
download | gdb-7556d4a4f6c3181204e9575c08c661a632cafb5d.zip gdb-7556d4a4f6c3181204e9575c08c661a632cafb5d.tar.gz gdb-7556d4a4f6c3181204e9575c08c661a632cafb5d.tar.bz2 |
Normalize TRY_CATCH exception handling block
This normalizes some exception catch blocks that check for ex.reason
to look like this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ALL)
{
...
}
if (ex.reason < 0)
{
...
}
~~~
This is a preparation step for running a script that converts all
TRY_CATCH uses to look like this instead:
~~~
TRY
{
...
}
CATCH (ex, RETURN_MASK_ALL)
{
...
}
END_CATCH
~~~
The motivation for that change is being able to reimplent TRY/CATCH in
terms of C++ try/catch.
This commit makes it so that:
- no condition other than ex.reason < 0 is checked in the if
predicate
- there's no "else" block to check whether no exception was caught
- there's no code between the TRY_CATCH (TRY) block and the
'if (ex.reason < 0)' block (CATCH).
- the exception object is no longer referred to outside the if/catch
block. Note the local volatile exception objects that are
currently defined inside functions that use TRY_CATCH will
disappear. In cases it's more convenient to still refer to the
exception outside the catch block, a new non-volatile local is
added and copy to that object is made within the catch block.
The following patches should make this all clearer.
gdb/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
* amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache)
(amd64_epilogue_frame_cache): Normal exception handling code.
* break-catch-throw.c (check_status_exception_catchpoint)
(re_set_exception_catchpoint): Ditto.
* cli/cli-interp.c (safe_execute_command):
* cli/cli-script.c (script_from_file): Ditto.
* compile/compile-c-symbols.c (generate_c_for_for_one_variable):
Ditto.
* compile/compile-object-run.c (compile_object_run): Ditto.
* cp-abi.c (baseclass_offset): Ditto.
* cp-valprint.c (cp_print_value): Ditto.
* exceptions.c (catch_exceptions_with_msg):
* frame-unwind.c (frame_unwind_try_unwinder): Ditto.
* frame.c (get_frame_address_in_block_if_available): Ditto.
* i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache)
(i386_sigtramp_frame_cache): Ditto.
* infcmd.c (post_create_inferior): Ditto.
* linespec.c (parse_linespec, find_linespec_symbols):
* p-valprint.c (pascal_object_print_value): Ditto.
* parse.c (parse_expression_for_completion): Ditto.
* python/py-finishbreakpoint.c (bpfinishpy_init): Ditto.
* remote.c (remote_get_noisy_reply): Ditto.
* s390-linux-tdep.c (s390_frame_unwind_cache): Ditto.
* solib-svr4.c (solib_svr4_r_map): Ditto.
Diffstat (limited to 'gdb/compile')
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 22 | ||||
-rw-r--r-- | gdb/compile/compile-object-run.c | 15 |
2 files changed, 19 insertions, 18 deletions
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 75c093f..1921704 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -699,17 +699,17 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler, } } - if (e.reason >= 0) - return; - - if (compiler->symbol_err_map == NULL) - compiler->symbol_err_map = htab_create_alloc (10, - hash_symbol_error, - eq_symbol_error, - del_symbol_error, - xcalloc, - xfree); - insert_symbol_error (compiler->symbol_err_map, sym, e.message); + if (e.reason < 0) + { + if (compiler->symbol_err_map == NULL) + compiler->symbol_err_map = htab_create_alloc (10, + hash_symbol_error, + eq_symbol_error, + del_symbol_error, + xcalloc, + xfree); + insert_symbol_error (compiler->symbol_err_map, sym, e.message); + } } /* See compile-internal.h. */ diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index d34c9ed..c40de0e 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -121,18 +121,19 @@ compile_object_run (struct compile_module *module) do_module_cleanup, data); } } - dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); - if (!executed) - data->executedp = NULL; - if (ex.reason >= 0) - gdb_assert (!dtor_found && executed); - else + if (ex.reason < 0) { - /* In the case od DTOR_FOUND or in the case of EXECUTED nothing + /* In the case of DTOR_FOUND or in the case of EXECUTED nothing needs to be done. */ + dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); + if (!executed) + data->executedp = NULL; gdb_assert (!(dtor_found && executed)); if (!dtor_found && !executed) do_module_cleanup (data); throw_exception (ex); } + + dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); + gdb_assert (!dtor_found && executed); } |