Books/docs on exception handling


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.



The best I've seen are

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.


Hi Trevor,

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

* Exception Handling Tables (
  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:

* 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. :slight_smile:


Thanks for the pointers guys. I found some other documents that may or may not be useful: