source: libcfa/src/concurrency/exception.cfa@ 6b765d5

Last change on this file since 6b765d5 was c5e1aa6, checked in by Peter A. Buhr <pabuhr@…>, 6 months ago

update abort messages for exception handling

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[d119d613]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// exception.cfa -- Exceptions in a concurrent environment.
8//
9// Author : Andrew Beach
10// Created On : Mon Aug 17 10:41:00 2020
[c5e1aa6]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Sep 25 17:25:37 2024
13// Update Count : 15
[d119d613]14//
15
[c960331]16#define __cforall_thread__
[d119d613]17
18#include "exception.hfa"
[c960331]19
[d119d613]20#include "coroutine.hfa"
21
[e84ab3d]22extern struct thread$ * mainThread;
[c960331]23extern "C" {
24extern void __cfactx_thrd_leave();
25}
[d119d613]26
27// Common pattern for all the stop functions, wait until the end then act.
28#define STOP_AT_END_FUNCTION(NAME, ...) \
29static _Unwind_Reason_Code NAME( \
30 int version, \
31 _Unwind_Action actions, \
32 _Unwind_Exception_Class exception_class, \
33 struct _Unwind_Exception * unwind_exception, \
34 struct _Unwind_Context * unwind_context, \
35 void * stop_param) { \
36 verify(actions & _UA_CLEANUP_PHASE); \
37 verify(actions & _UA_FORCE_UNWIND); \
38 verify(!(actions & _UA_SEARCH_PHASE)); \
39 verify(!(actions & _UA_HANDLER_FRAME)); \
40 if ( actions & _UA_END_OF_STACK ) { \
41 __VA_ARGS__ \
42 } else { \
43 return _URC_NO_REASON; \
44 } \
45}
46
47STOP_AT_END_FUNCTION(main_cancelstop,
[c5e1aa6]48 abort(
49 "Propagation failed to find a matching handler.\n"
50 "Possible cause is a missing try block with appropriate catch clause for the specified or derived exception type.\n"
51 "Last exception name or message: %%s.\n"
52// NODE_TO_EXCEPT( UNWIND_TO_NODE( unwind_exception ) )->
53// virtual_table->msg( NODE_TO_EXCEPT( UNWIND_TO_NODE( unwind_exception ) ) )
54 );
[d119d613]55)
56
57STOP_AT_END_FUNCTION(thread_cancelstop,
[342be43]58 __cfactx_thrd_leave();
59 __cabi_abort( "Resumed cancelled thread" );
[d119d613]60)
61
62STOP_AT_END_FUNCTION(coroutine_cancelstop,
[e84ab3d]63 struct coroutine$ * src = (coroutine$ *)stop_param;
64 struct coroutine$ * dst = src->last;
[4269d1b]65 dst->cancellation = 1p;
[1c01c58]66 $ctx_switch( src, dst );
[c5e1aa6]67 abort( "coroutine_cancelstop" );
[d119d613]68)
69
70extern "C" {
71
[c18bf9e]72struct exception_context_t * this_exception_context(void) libcfa_public {
[d119d613]73 return &__get_stack( active_coroutine() )->exception_context;
74}
75
[c18bf9e]76_Unwind_Reason_Code __cfaehm_cancellation_unwind( struct _Unwind_Exception * unwind_exception ) libcfa_public {
[d119d613]77 _Unwind_Stop_Fn stop_func;
78 void * stop_param;
79
[e84ab3d]80 struct thread$ * this_thread = active_thread();
[d119d613]81 if ( &this_thread->self_cor != this_thread->curr_cor ) {
[e84ab3d]82 struct coroutine$ * cor = this_thread->curr_cor;
[d119d613]83 cor->cancellation = unwind_exception;
84
85 stop_func = coroutine_cancelstop;
86 stop_param = cor;
87 } else if ( mainThread == this_thread ) {
88 stop_func = main_cancelstop;
89 stop_param = (void *)0x22;
90 } else {
[ab8c6a6]91 this_thread->self_cor.cancellation = unwind_exception;
92
[d119d613]93 stop_func = thread_cancelstop;
94 stop_param = this_thread;
95 }
96
97 return _Unwind_ForcedUnwind( unwind_exception, stop_func, stop_param );
98}
99
100}
Note: See TracBrowser for help on using the repository browser.