Hi Mark,> You are confusing stopping the unwinding at *some* levels or at *all* > levels. > Eg. > invoke > call > call > invoke > call > call > unwindthe dwarf unwinder only stops and runs user code at the invokes. It does restore registers and so forth at every stack frame. This is extra work done at unwind time that reduces the cost of making invoke calls by avoiding the need to save a bunch of context. Ciao, Duncan.
On Mon, Jul 20, 2009 at 11:18 AM, Duncan Sands<baldrick at free.fr> wrote:> Hi Mark, > >> You are confusing stopping the unwinding at *some* levels or at *all* >> levels. >> Eg. >> invoke >> call >> call >> invoke >> call >> call >> unwind > > the dwarf unwinder only stops and runs user code at the invokes. > It does restore registers and so forth at every stack frame. > This is extra work done at unwind time that reduces the cost of > making invoke calls by avoiding the need to save a bunch of > context. >Is there anything in the current codebase that maps an "unwind" instruction to a DWARF unnwinder? Seeing as how (I think) the DWARF info is already compiled in, this would be a useful thing.
Duncan Sands wrote:> Hi Mark,Hi Duncan,> >> You are confusing stopping the unwinding at *some* levels or at *all* >> levels. >> Eg. >> invoke >> call >> call >> invoke >> call >> call >> unwind > > the dwarf unwinder only stops and runs user code at the invokes. > It does restore registers and so forth at every stack frame. > This is extra work done at unwind time that reduces the cost of > making invoke calls by avoiding the need to save a bunch of > context.Thanks for the informative answer. So who is responsible for (as stated under the invoke description in the language reference) "ensure that proper cleanup is performed in the case of either a longjmp or a thrown exception"? Is it entirely the front-end or is dwarf unwinding doing some extra work (other than a few unecessary register restores), like restoring signals, and calling pthread cleanup routines? In other words does the dwarf unwinder do nothing other than unwind, and was all that stuff about pthread_cleanup_pop() actions just a red-herring? Mark.> > Ciao, > > Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi Kenneth,> Is there anything in the current codebase that maps an "unwind" > instruction to a DWARF unnwinder? Seeing as how (I think) the DWARF > info is already compiled in, this would be a useful thing.in llvm from svn an "unwind" instruction is mapped to a call to _Unwind_Resume. This is no good for throwing a new dwarf exception, but it does mean that you can now implement cleanups as: invoke XYZ to label %normal unwind label %cleanup cleanup: do_stuff unwind Ciao, Duncan.
Hi Mark,> So who is responsible for (as stated under the invoke description in the > language reference) "ensure that proper cleanup is performed in the case > of either a longjmp or a thrown exception"?the unwinder (however it works) needs to stop at each invoke and run the code in the unwind block of the invoke. I think it is important that the default method of code generation for the unwind and invoke instructions should interact correctly with code compiled with gcc. This means that the default needs to make use of dwarf unwinding. It does not prevent having multiple code generation implementations, eg done using some kind of setjmp/longjmp implementation of unwind/invoke. Code created using other implementations will only work correctly if the entire executable, or at least the bits doing exception handling, are all built with the same compiler/codegen options, but that's ok if it's not the default.> Is it entirely the front-end or is dwarf unwinding doing some extra work > (other than a few unecessary register restores), like restoring signals, > and calling pthread cleanup routines?The front-end needs to ensure that there is an appropriate invoke that runs the pthread cleanup routines in the unwind block.> In other words does the dwarf unwinder do nothing other than unwind, > and was all that stuff about pthread_cleanup_pop() actions just a > red-herring?I think it was a red-herring, but I don't know anything about pthread_cleanup_pop. Ciao, Duncan.