[LLVMdev] Books/docs on exception handling
wendling at apple.com
Thu Apr 22 03:30:11 PDT 2010
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.
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:
This outputs the CIE, FDE, and exception handling tables.
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. :-)
On Apr 21, 2010, at 2:07 PM, Trevor Harmon wrote:
> 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":
> 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.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev