This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Make TRY/CATCH use real C++ try/catch in C++ mode


*** TEST RESULTS FOR COMMIT 72df25b28d68fd0b903380ceb06c6b5866eab453 ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 72df25b28d68fd0b903380ceb06c6b5866eab453

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]