Overview of Exception Handling Implementation in Open64

Slides:



Advertisements
Similar presentations
Procedures Procedures are very important for writing reusable and maintainable code in assembly and high-level languages. How are they implemented? Application.
Advertisements

CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Program Representations. Representing programs Goals.
Review Linked list: Doubly linked list, insertback, insertbefore Remove Search.
B. Childers, M. L. Soffa, J. Beaver, L. Ber, K. Cammarata, J. Litman, J. Misurda Presented by: Priyanka Puri SOFTTEST: A FRAMEWORK FOR SOFTWARE.
CPSC Compiler Tutorial 8 Code Generator (unoptimized)
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Generational Stack Collection And Profile driven Pretenuring Perry Cheng Robert Harper Peter Lee Presented By Moti Alperovitch
Code Generation Professor Yihjia Tsai Tamkang University.
Previous finals up on the web page use them as practice problems look at them early.
Address Obfuscation: An Efficient Approach to Combat a Broad Range of Memory Error Exploits Sandeep Bhatkar, Daniel C. DuVarney, and R. Sekar Stony Brook.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Copyright © 2005 Elsevier Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Introduction to Exception Handling and Defensive Programming.
COP4020 Programming Languages Subroutines and Parameter Passing Prof. Xin Yuan.
Procedure Basics Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Procedure Support From previous study of high-level languages,
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Lecture 19: Control Abstraction (Section )
CS212: Object Oriented Analysis and Design Lecture 19: Exception Handling.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
CSCI 383 Object-Oriented Programming & Design Lecture 20 Martin van Bommel.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
1 Chapter10: Code generator. 2 Code Generator Source Program Target Program Semantic Analyzer Intermediate Code Generator Code Optimizer Code Generator.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
WORKING OF SCHEDULER IN OS
Procedures Procedures are very important for writing reusable and maintainable code in assembly and high-level languages. How are they implemented? Application.
Lecture 3 Translation.
Optimistic Hybrid Analysis
Storage Allocation Mechanisms
Exception Handling in C++
16 Exception Handling.
Data Watch Presenter Information Jason Puncher and François Tétreault
143A: Principles of Operating Systems Lecture 4: Calling conventions
Run-time organization
Software Development with uMPS
Procedures (Functions)
Workshop in Nihzny Novgorod State University Activity Report
Functions and Procedures
The HP OpenVMS Itanium® Calling Standard
Chapter 9 :: Subroutines and Control Abstraction
C++ Exception Handling for IA-64 Unix
Application Binary Interface (ABI)
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Stack Frame Linkage.
Human Complexity of Software
Inlining and Devirtualization Hal Perkins Autumn 2011
PZ09A - Activation records
Exceptions.
Architectural Support for OS
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Languages and Compilers (SProg og Oversættere)
Problems Debugging is fine and dandy, but remember we divided problems into compile-time problems and runtime problems? Debugging only copes with the former.
CSE451 Virtual Memory Paging Autumn 2002
Architectural Support for OS
Where is all the knowledge we lost with information? T. S. Eliot
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Introduction to Computer Systems Engineering
CMSC 202 Exceptions.
Dynamic Binary Translators and Instrumenters
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Topic 2b ISA Support for High-Level Languages
Runtime Stack Activation record for hanoi;
Return-to-libc Attacks
Presentation transcript:

Overview of Exception Handling Implementation in Open64 Hucheng Zhou Wenguang Chen Tsinghua University 10/15/2019

Outline Introduction Three-Level C++ EH ABI Overview of component of EH Mechanism EH Implementation in Open64 LSDA structure Call Frame Dwarf Information How to debug EH implementation 10/15/2019

Introduction Exceptions Handling provides a systematic and robust approach to coping with errors that cannot be recovered from locally at the point where they are detected There are two main strategies to EH implementation: “Code” based approach “Table” based approach C++ EH ABI defines the convention of “Table” based approach Most of the existed compiler adopt the “Table” based approach, including gcc, open64, LLVM Since it is “zero-cost” way that it will not add the burden on the exception-free execution We will describe the detailed C++ EH ABI and the specific implementation in Open64 10/15/2019

Three Level C++ EH ABI According to the bottom-up order Level 1: 2019/10/15 Three Level C++ EH ABI According to the bottom-up order Level 1: Unwind Library Level 2: Runtime Library, i.e., libstdc++.so Level 3: Unwind descriptor and EH table generated by compiler This EH ABI is part of C++ ABI for Itanium, but as the de fact ABI for EH. 10/15/2019

Three Level EH ABI 10/15/2019

Component of EH FLOW 10/15/2019

EH Implementation in Open64 10/15/2019

EH Implementation in Open64 The implantation in FE, IPA, OPT and CGEMIT is straightforward Here we mainly focus on CG part: LSDA (Language Specific Data Area) generation, including call site table, activation record table, type table and type specification table Unwind Descriptor generation Call Frame Dwarf Information .eh_frame section 10/15/2019

2019/10/15 This graph shows the internal data structure for EH table, which is not documented well. These data structures were dumped through reversing engineering and debug the personality_routine in libstdc++. 10/15/2019

Unwind Table 10/15/2019

LSDA Structure 10/15/2019

LSDA Illustration 10/15/2019

Call Frame Dwarf Information The unwinding operation needs CIE and FDE information to know how to recover the saved registers and how to compute the predecessor’s CFA (Canonical Frame Address) and code location 10/15/2019

Example 10/15/2019 2019/10/15 There are 8 4-byte registers: R0 always 0; R1 hold the return address; R2~R3 caller saved registers; R4~R6 callee saved registers; R7 stack register. 10/15/2019

2019/10/15 Example Cont’ The first column indicates an address for every location. The remaining columns contain virtual unwinding rules that are associated with the indicated location given in the first column. CFA(Canonical Frame Address) is used to identify the current call frame. Typically, CFA is defined to be the values of the stack pointer at the call site in the previous frame. S = same_value; u = undefined value; r = register(N) rule; c = offset(N) rule; a = architecture rule 10/15/2019

10/15/2019

Call Frame Dwarf Information Prologue and epilogue code is not always in distinct blocks at the beginning and end of a program There are different ways to manage the call frame, sometimes using frame pointer CFA’s computation will be different at different PC Some PU hasn’t call frame Callee saved register can be saved in another register which is a scratch register 10/15/2019

Impact on Optimization 2019/10/15 Impact on Optimization Optimization to exception free application Generally, there is no runtime overhead. However, EH has a few impacts on compiler optimization More complex CFG (e.g., There should be an edge from throw point to its landing pad) Conservative optimization across EH region Optimization to exception intensive application Unnecessary EH ranges removable IPA can help to statically analyze the thrown point and its related landing pad Profile the exception caught path, and inline the calls during thrown point and its handler function Generally, table based EH implementation does not add any runtime overhead to exception-free application 10/15/2019

How to Debug EH Implementation 1. Add EH related trace mechanism 2. Instrument the personality routine in libstdc++.so 3. Even instrument the functions in unwind library 10/15/2019

Thanks Thank you very much And any questions? 10/15/2019