What is DWARF Introduction to the DWARF Format 2012.05.03.

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Programs in Memory Bryce Boe 2012/08/29 CS32, Summer 2012 B.
1 C and the 8051 EGRE Introduction The Silicon Labs ISE uses the Keil C51 compiler. The code size is limiter to 2K C has replaced PL/M (the original.
UEE072HM Linking HLL and ALP An example on ARM. Embedded and Real-Time Systems We will mainly look at embedded systems –Systems which have the computer.
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Lecture 10: Linking and loading. Lecture 10 / Page 2AE4B33OSS 2011 Contents Linker vs. loader Linking the executable Libraries Loading executable ELF.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Together, We make the difference. MCLinker Intermediate Representation Luba Tang 2013/2/24.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
Embedded Systems Programming Introduction to cross development techniques.
Embedded Control Systems Introduction to cross development techniques.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
1 uClinux course Day 3 of 5 The uclinux toolchain, elf format and ripping a “hello world”
OBJECT MODULE FORMATS. The object module format we have employed as an educational device is called OMF (relocatable object format). It’s one of the earliest.
Syntax Directed Translation. Syntax directed translation Yacc can do a simple kind of syntax directed translation from an input sentence to C code We.
University of Maryland Compiler-Assisted Binary Parsing Tugrul Ince PD Week – 27 March 2012.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
1 Program Layout in memory –Code –Data Global variables –Stack Local variables & function Invocation Frames –Heap Dynamically allocated memory Today’s.
Objective At the conclusion of this chapter you will be able to:
Topic 2d High-Level languages and Systems Software
CPS120: Introduction to Computer Science Functions.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
CS412/413 Introduction to Compilers and Translators April 14, 1999 Lecture 29: Linking and loading.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
1 Introduction Purpose  This course gives an overview of assembler settings of the High-performance Embedded Workshop (HEW), used for developing software.
THE PREPROCESSOR
C P ROGRAMMING T OOLS. C OMPILING AND R UNNING S INGLE M ODULE P ROGRAM.
CSc 453 Linking and Loading
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
The World Leader in High Performance Signal Processing Solutions Toolchain Basics.
Introduction To Software Development Environment.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd.
Program Execution in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Lecture 3 Translation.
Advanced Computer Systems
MODERN OPERATING SYSTEMS Third Edition ANDREW S
CS 140 Lecture Notes: Virtual Memory
Muen Policy & Toolchain
Instruction Set Architectures
Computer Architecture & Operations I
CSCI-235 Micro-Computer Applications
The University of Adelaide, School of Computer Science
Debugging with gdb gdb is the GNU debugger on our CS machines.
Chapter7 Structure & C++
Program Execution in Linux
Software Development with uMPS
The HP OpenVMS Itanium® Calling Standard
CS 140 Lecture Notes: Virtual Memory
Computer Organization & Compilation Process
CALL & Pthread.
FIGURE 12-1 Memory Hierarchy
Loaders and Linkers: Features
Machine Independent Features
CS 140 Lecture Notes: Virtual Memory
Memory Management Overview
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
Program Execution in Linux
Computer Organization & Compilation Process
CS 140 Lecture Notes: Virtual Memory
CSPA Templates for sharing services
CSPA Templates for sharing services
Presentation transcript:

What is DWARF Introduction to the DWARF Format

Reference Introduction to the DWARF Debugging Format, Michael J. Eager, Eager Consulting DWARF Debugging Information Format, Version 4, DWARF Debugging Information Format Committee; Gnu gold linker, GNU Binutils Gnu BFD, GNU Binutils

Introduction DWARF is a format for debugging. DWARF data are several sections in the object file The purpose is to figure out the mapping between object code and source code. DWARF is a tree structure with nodes called Debugging Information Entry (DIE). The tree describes the whole source program readelf --dump-debug to dump the debug data

Debug Sections NamesFunctions.debug_abbrevAbbreviations used in the.debug_info section.debug_infoThe core DWARF data containing DIEs.debug_frameCall Frame Information  similar to eh_frame.debug_lineLine Number Program.debug_macinfoMacro descriptions.debug_arangesA mapping between memory address and compilation.debug_locA lookup table for global objects and functions.debug_pubnamesA lookup table for global objects and functions.debug_pubtypesA lookup table for global types.debug_rangesAddress ranges referenced by DIEs.debug_strString table used by.debug_info

DIE DIEs are used to represent types, variables, or functions. DIE contains a Tag and a set of Attributes – TAG Specify what this DIE describes DW_TAG_XXX : DW_TAG_base_type, DW_TAG_variable,... – Attribute A detail description such as name, size, address,… DW_AT_XXX: DW_AT_name, DW_AT_byte_size,…

Base Types and Variables Describes 32-bit and 16-bit int base type DW_TAG_base_type DW_AT_name = int DW_AT_byte_size = 4 DW_AT_encoding = signed DW_TAG_base_type DW_AT_name = int DW_AT_byte_size = 2 DW_AT_encoding = signed : DW_TAG_variable DW_AT_name = px DW_AT_type = : DW_TAG_pointer_type DW_AT_byte_size = 4 DW_AT_type = : DW_TAG_base_type DW_AT_name = word DW_AT_byte_size = 4 DW_AT_encoding = signed Describes int *px

Describe Executable Code Compilation Unit DIE – Each separately compiled source file is a compilation unit – Each compilation unit has a DIE to describe its name, directory, address, … – The parent of all other DIEs for this compilation unit Functions – Subprograms DIE Describes name, low/high pc Return value : DW_AT_TYPE – Input parameter DIE Owned by subprogram Described parameter name, type, …

Executable Code, an Example 1 DW_TAG_compile_unit [has children] DW_AT_producer DW_FORM_strp DW_AT_language DW_FORM_data1 DW_AT_name DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_low_pc DW_FORM_addr DW_AT_high_pc DW_FORM_addr DW_AT_stmt_list DW_FORM_data4 Compilation Unit DIE : Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_producer : (indirect string, offset: 0x0): GNU C DW_AT_language : 1 (ANSI C) DW_AT_name : (indirect string, offset: 0xc): test.c DW_AT_comp_dir : (indirect string, offset: 0x13): /proj/mtk02422/test/test2 DW_AT_low_pc : 0x0 DW_AT_high_pc : 0x30 DW_AT_stmt_list : 0x0. debug_abbrev. debug_info int foo(int i) { return i++; } int foo(int i) { return i++; } Describe the data types Describe the value

Executable Code, an Example Subprograms DIE : Abbrev Number: 2 (DW_TAG_subprogram) DW_AT_external : 1 DW_AT_name : foo DW_AT_decl_file : 1 DW_AT_decl_line : 1 DW_AT_prototyped : 1 DW_AT_type : DW_AT_low_pc : 0x0 DW_AT_high_pc : 0x30 DW_AT_frame_base : 0x0 (location list) DW_AT_sibling : … : Abbrev Number: 4 (DW_TAG_base_type) DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) DW_AT_name : int. debug_info

Other DWARF Data Line Number Table –.debug_line – Mapping between the source lines and the memory address – Line number program The byte-coded instruction stream – State machine Expand the line number program and recreate the line number table Macro Information –.debug_macinfo Call Frame Information –.debug_frame – Virtually unwind and find out the desired data in the call stack – CIE (Common Information Entry) – FDE (Frame Description Entry)

What linkers should do? Related options – --strip-debug Strip the debugging information – --strip-debug-non-line Emit only debug line number information (gold only) – --strip-debug-gdb Strip debug symbols that are unused by gdb (at least version 6.7) (gold only) Section merge, applying relocation (Normal passes) Post processing – Compress the sections – Reduce the debug output data.debug_abbrev.debug_info DWARF reader – For error message