diff options
author | Pedro Alves <palves@redhat.com> | 2015-03-07 14:50:03 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-03-07 15:26:27 +0000 |
commit | 72df25b28d68fd0b903380ceb06c6b5866eab453 (patch) | |
tree | bcd5de764de71dad8a163506d6506f815d7fa2af /.cvsignore | |
parent | 284e6217cf8f96c7648b13274431dcf73aa084a9 (diff) | |
download | gdb-72df25b28d68fd0b903380ceb06c6b5866eab453.zip gdb-72df25b28d68fd0b903380ceb06c6b5866eab453.tar.gz gdb-72df25b28d68fd0b903380ceb06c6b5866eab453.tar.bz2 |
Make TRY/CATCH use real C++ try/catch in C++ mode
Although the current TRY/CATCH implementation works in C++ mode too,
it relies on setjmp/longjmp, and longjmp bypasses calling the
destructors of objects on the stack, which is obviously bad for C++.
This patch fixes this by makes TRY/CATCH use real try/catch in C++
mode behind the scenes. The way this is done allows RAII and cleanups
to coexist while we phase out cleanups, instead of requiring a flag
day.
This patch is not strictly necessary until we require a C++ compiler
and start actually using RAII, though I'm all for baby steps, and it
shows my proposed way forward. Putting it in now, allows for easier
experimentation and exposure of potential problems with real C++
exceptions.
gdb/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c [!__cplusplus] (enum catcher_state)
(exceptions_state_mc_action_iter)
(exceptions_state_mc_action_iter_1, exceptions_state_mc_catch):
Don't define.
[__cplusplus] (try_scope_depth): New global.
[__cplusplus] (exception_try_scope_entry)
(exception_try_scope_exit, gdb_exception_sliced_copy)
(exception_rethrow): New functions.
(throw_exception): In C++ mode, throw
gdb_exception_RETURN_MASK_QUIT for RETURN_QUIT and
gdb_exception_RETURN_MASK_ERROR for RETURN_ERROR.
(throw_it): In C++ mode, use try_scope_depth.
* common/common-exceptions.h [!__cplusplus]
(exceptions_state_mc_action_iter)
(exceptions_state_mc_action_iter_1, exceptions_state_mc_catch):
Don't declare.
[__cplusplus] (exception_try_scope_entry)
(exception_try_scope_exit, exception_rethrow): Declare.
[__cplusplus] (struct exception_try_scope): New struct.
[__cplusplus] (TRY, CATCH, END_CATCH): Reimplement on top of real
C++ exceptions.
(struct gdb_exception_RETURN_MASK_ALL)
(struct gdb_exception_RETURN_MASK_ERROR)
(struct gdb_exception_RETURN_MASK_QUIT): New types.
Diffstat (limited to '.cvsignore')
0 files changed, 0 insertions, 0 deletions