[LLVMdev] Books/docs on exception handling

9 views
Skip to first unread message

Trevor Harmon

unread,
Apr 21, 2010, 5:07:47 PM4/21/10
to llvmdev List
Hi,

I'm trying to learn all that I can about exception handling from the
compiler's point of view. Although much has been written about
compiler theory in general -- parsing, code generation, you name it --
I can find almost nothing on the specific problem of exception
handling support. In fact, the most informative document I've been
able to find so far is "Bill's EH Proposal":

http://markmail.org/message/5ezbpz75yxjje3or?q=thread:ghrak3dzcadxyf4x

Are there any other books or articles that I should know about? I'm
looking for almost anything that talks about how compilers (LLVM or
otherwise) parse exception handlers, generate landing pads, implement
stack unwinding, and so on.

Thanks,

Trevor

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


--
Subscription settings: http://groups.google.com/group/llvm-dev/subscribe?hl=en

Eugene Toder

unread,
Apr 21, 2010, 5:39:27 PM4/21/10
to Trevor Harmon, llvmdev List
The best I've seen are
http://www.microsoft.com/msj/0197/exception/exception.aspx
http://www.codesourcery.com/public/cxx-abi/abi-eh.html

Not as good as a book on compilers, and not focused on how to do this
in compiler, but pretty detailed explanations of exception handling
low levels.

Eugene

Bill Wendling

unread,
Apr 22, 2010, 6:30:11 AM4/22/10
to Trevor Harmon, llvmdev List
Hi Trevor,

DWARF exception handling is an amalgam of several different documents and code tables, which all conspire to give us exception handling. :-) The documents you should read are:

* Exception Handling Tables (http://www.codesourcery.com/public/cxx-abi/exceptions.pdf)
This explains in detail what the table in the "__TEXT,__gcc_except_tab" section is all about.

* DWARF Debugging Information Format: Version 3 (or 4)
This explains the "CIE" and "FDE" tables and what their encodings means.

* http://www.codesourcery.com/public/cxx-abi/abi-eh.html
As Eugene pointed out, this explains what the personality function and unwind libraries do.

Well, "read" might be a bad way of putting it. You should definitely familiarize yourself with each document. But I would look to understand why the FDE looks like it does or what the format of the exception handling table means (-fverbose-asm gives extra information to help with this).

For specifics on how LLVM generates this information, look at these files:

* lib/CodeGen/AsmPrinter/DwarfException.cpp
This outputs the CIE, FDE, and exception handling tables.

* lib/Target/X86/X86RegisterInfo.cpp
The "X86RegisterInfo::emitPrologue" method shows how it constructs the "machine move" information that's used to create the FDE.

The front-end parses and generates the exception handlers and landing pads. The implementation of the stack unwinder is normally in a separate library (libunwind on Darwin). But the "abi-eh.html" document should give you a good idea of how a typical unwinder and personality function should act.

Lastly, GCC has a different approach (in their IR) to generating the EH data. They have many good people working on it. I tried to find a link to a document that someone on the GCC mailing list wrote up describing the exception handling table in detail, but couldn't find it. You may want to search that posting out. :-)

-bw

Trevor Harmon

unread,
Apr 22, 2010, 3:36:02 PM4/22/10
to Bill Wendling, llvmdev List
Thanks for the pointers guys. I found some other documents that may or
may not be useful:

http://theory.uwinnipeg.ca/localfiles/infofiles/gcc/gxxint_13.html

http://www.cs.nott.ac.uk/~gmh/exceptions.pdf

http://chasewoerner.org/exh.pdf

Trevor

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


Reply all
Reply to author
Forward
0 new messages