On Wed, 01 Apr 2009 07:54:20 -0700, Ian Lance Taylor <i...@google.com> wrote: > "Vincent R." <foru...@smartmobili.com> writes: > >> Now the question is can we declare a function with an eh region and will >> it >> construct prologue and epilogue ? > > The instructions are already in a function. Why do you need a separate > prologue and epilogue for them? > > Maybe I am missing the point here. It seems to me that the __except > keyword as you described it can be implemented by a transformation from > C++ to C++. gcc already knows how to handle exception regions; you > don't have to teach it anything in that area. You just have to generate > the correct GIMPLE or GENERIC in the frontend. You are talking about > creating a new function, but I just don't see any reason to do so. You > already have a function, and you can just create exception regions in > that function. The code in the exception region can call other > functions, etc. What am I missing? > > Ian
Yes I think I don't explain things very clearly, so what is important to know is that the __except keyword can be passed instructions(case 1) or directly a function(case 2). in the case 1) ie if you declare something like : ... __except( printf("hello gcc"), 1) and I look at asm generated I can notice that the instructions inside the patenthesis will be put inside a function because I can notice a prologue and epilogue. int main() { ... __except(puts("in filter"), EXCEPTION_EXECUTE_HANDLER) { ... } } // main ... So on a arm plateform here is the annoted asm (asm + source code), I have only pasted the __except part : And we can see that just after the closing } for main there is a prologue followed by the instructions originally in the __except and then the epilogue. // main } ; 128 : __except(puts("in filter"), EXCEPTION_EXECUTE_HANDLER){ str lr, [sp, #-4]! <<<< function prologue |$...@wmain| |$l...@wmain| ldr r0, [pc, #8] bl puts mov r0, #1 |$...@wmain| ldr pc, [sp], #4 <<<< function epilogue so instructions inside __except parenthesis are put in something that looks like a function Do I need to explain more ?