dwarf_cu_to_module.h revision 87855248f1fab83caf002418196a34051d359f2c
1057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// -*- mode: c++ -*- 2057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 383e085b7a331c96237cf8e814f97b3ef4c36a70fjimblandy// Copyright (c) 2010 Google Inc. 4057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// All rights reserved. 5057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 6057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// Redistribution and use in source and binary forms, with or without 7057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// modification, are permitted provided that the following conditions are 8057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// met: 9057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 10057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Redistributions of source code must retain the above copyright 11057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// notice, this list of conditions and the following disclaimer. 12057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Redistributions in binary form must reproduce the above 13057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// copyright notice, this list of conditions and the following disclaimer 14057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// in the documentation and/or other materials provided with the 15057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// distribution. 16057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Neither the name of Google Inc. nor the names of its 17057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// contributors may be used to endorse or promote products derived from 18057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// this software without specific prior written permission. 19057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 20057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 32c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> 33c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy 34c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// Add DWARF debugging information to a Breakpad symbol file. This 35c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// file defines the DwarfCUToModule class, which accepts parsed DWARF 36c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// data and populates a google_breakpad::Module with the results; the 37c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// Module can then write its contents as a Breakpad symbol file. 38c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy 39057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#ifndef COMMON_LINUX_DWARF_CU_TO_MODULE_H__ 40057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#define COMMON_LINUX_DWARF_CU_TO_MODULE_H__ 41057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 42057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include <string> 43057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 44057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include <elf.h> 45057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include <link.h> 4687855248f1fab83caf002418196a34051d359f2cjimblandy#include "common/language.h" 4787855248f1fab83caf002418196a34051d359f2cjimblandy#include "common/module.h" 48057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include "common/dwarf/bytereader.h" 49057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include "common/dwarf/dwarf2diehandler.h" 50057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include "common/dwarf/dwarf2reader.h" 51057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 52057aa1f6173501e1a62cf91fd08275e7da439166jimblandynamespace google_breakpad { 53057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 54057aa1f6173501e1a62cf91fd08275e7da439166jimblandyusing dwarf2reader::AttributeList; 55057aa1f6173501e1a62cf91fd08275e7da439166jimblandyusing dwarf2reader::DwarfAttribute; 56057aa1f6173501e1a62cf91fd08275e7da439166jimblandyusing dwarf2reader::DwarfForm; 57057aa1f6173501e1a62cf91fd08275e7da439166jimblandyusing dwarf2reader::DwarfLanguage; 58057aa1f6173501e1a62cf91fd08275e7da439166jimblandyusing dwarf2reader::DwarfTag; 59057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 60057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// Populate a google_breakpad::Module with DWARF debugging information. 61057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 62057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// An instance of this class can be provided as a handler to a 63057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// dwarf2reader::CompilationUnit DWARF parser. The handler uses the 64057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// results of parsing to populate a google_breakpad::Module with 65057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// source file, function, and source line information. 66057aa1f6173501e1a62cf91fd08275e7da439166jimblandyclass DwarfCUToModule: public dwarf2reader::RootDIEHandler { 67057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct FilePrivate; 68057aa1f6173501e1a62cf91fd08275e7da439166jimblandy public: 69057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 70057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Information global to the DWARF-bearing file we are processing, 71057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // for use by DwarfCUToModule. Each DwarfCUToModule instance deals 72057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // with a single compilation unit within the file, but information 73057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // global to the whole file is held here. The client is responsible 74057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // for filling it in appropriately (except for the 'file_private' 75057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // field, which the constructor and destructor take care of), and 76057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // then providing it to the DwarfCUToModule instance for each 77057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // compilation unit we process in that file. 78057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct FileContext { 79057aa1f6173501e1a62cf91fd08275e7da439166jimblandy FileContext(const string &filename_arg, Module *module_arg); 80057aa1f6173501e1a62cf91fd08275e7da439166jimblandy ~FileContext(); 81057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 82057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The name of this file, for use in error messages. 83057aa1f6173501e1a62cf91fd08275e7da439166jimblandy string filename; 84057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 85057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // A map of this file's sections, used for finding other DWARF 86057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // sections that the .debug_info section may refer to. 87057aa1f6173501e1a62cf91fd08275e7da439166jimblandy dwarf2reader::SectionMap section_map; 88057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 89057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The Module to which we're contributing definitions. 90057aa1f6173501e1a62cf91fd08275e7da439166jimblandy Module *module; 91057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 92057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Inter-compilation unit data used internally by the handlers. 93057aa1f6173501e1a62cf91fd08275e7da439166jimblandy FilePrivate *file_private; 94057aa1f6173501e1a62cf91fd08275e7da439166jimblandy }; 95057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 96057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // An abstract base class for functors that handle DWARF line data 97057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // for DwarfCUToModule. DwarfCUToModule could certainly just use 98057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // dwarf2reader::LineInfo itself directly, but decoupling things 99057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // this way makes unit testing a little easier. 100057aa1f6173501e1a62cf91fd08275e7da439166jimblandy class LineToModuleFunctor { 101057aa1f6173501e1a62cf91fd08275e7da439166jimblandy public: 102057aa1f6173501e1a62cf91fd08275e7da439166jimblandy LineToModuleFunctor() { } 103057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual ~LineToModuleFunctor() { } 104057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 105057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Populate MODULE and LINES with source file names and code/line 106057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // mappings, given a pointer to some DWARF line number data 107057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // PROGRAM, and an overestimate of its size. Add no zero-length 108057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // lines to LINES. 109057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void operator()(const char *program, uint64 length, 110057aa1f6173501e1a62cf91fd08275e7da439166jimblandy Module *module, vector<Module::Line> *lines) = 0; 111057aa1f6173501e1a62cf91fd08275e7da439166jimblandy }; 112057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 113057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The interface DwarfCUToModule uses to report warnings. The member 114057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // function definitions for this class write messages to stderr, but 115057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // you can override them if you'd like to detect or report these 116057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // conditions yourself. 117057aa1f6173501e1a62cf91fd08275e7da439166jimblandy class WarningReporter { 118057aa1f6173501e1a62cf91fd08275e7da439166jimblandy public: 119057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Warn about problems in the DWARF file FILENAME, in the 120057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // compilation unit at OFFSET. 121057aa1f6173501e1a62cf91fd08275e7da439166jimblandy WarningReporter(const string &filename, uint64 cu_offset) 122057aa1f6173501e1a62cf91fd08275e7da439166jimblandy : filename_(filename), cu_offset_(cu_offset), printed_cu_header_(false), 1239e6b619ad084c58af9fb8983b1a646192adb3835jimblandy printed_unpaired_header_(false), 1249e6b619ad084c58af9fb8983b1a646192adb3835jimblandy uncovered_warnings_enabled_(false) { } 125057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual ~WarningReporter() { } 126057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 127057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Set the name of the compilation unit we're processing to NAME. 128057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void SetCUName(const string &name) { cu_name_ = name; } 129057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 1309e6b619ad084c58af9fb8983b1a646192adb3835jimblandy // Accessor and setter for uncovered_warnings_enabled_. 1319e6b619ad084c58af9fb8983b1a646192adb3835jimblandy // UncoveredFunction and UncoveredLine only report a problem if that is 1329e6b619ad084c58af9fb8983b1a646192adb3835jimblandy // true. By default, these warnings are disabled, because those 1339e6b619ad084c58af9fb8983b1a646192adb3835jimblandy // conditions occur occasionally in healthy code. 1349e6b619ad084c58af9fb8983b1a646192adb3835jimblandy virtual bool uncovered_warnings_enabled() const { 1359e6b619ad084c58af9fb8983b1a646192adb3835jimblandy return uncovered_warnings_enabled_; 1369e6b619ad084c58af9fb8983b1a646192adb3835jimblandy } 1379e6b619ad084c58af9fb8983b1a646192adb3835jimblandy virtual void set_uncovered_warnings_enabled(bool value) { 1389e6b619ad084c58af9fb8983b1a646192adb3835jimblandy uncovered_warnings_enabled_ = value; 1399e6b619ad084c58af9fb8983b1a646192adb3835jimblandy } 1409e6b619ad084c58af9fb8983b1a646192adb3835jimblandy 141057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // A DW_AT_specification in the DIE at OFFSET refers to a DIE we 142057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // haven't processed yet, or that wasn't marked as a declaration, 143057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // at TARGET. 144057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void UnknownSpecification(uint64 offset, uint64 target); 145dd5067f391baee2561404f8e2915429b3d638ff7jimblandy 146dd5067f391baee2561404f8e2915429b3d638ff7jimblandy // A DW_AT_abstract_origin in the DIE at OFFSET refers to a DIE we 147dd5067f391baee2561404f8e2915429b3d638ff7jimblandy // haven't processed yet, or that wasn't marked as inline, at TARGET. 148dd5067f391baee2561404f8e2915429b3d638ff7jimblandy virtual void UnknownAbstractOrigin(uint64 offset, uint64 target); 149dd5067f391baee2561404f8e2915429b3d638ff7jimblandy 150057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // We were unable to find the DWARF section named SECTION_NAME. 151057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void MissingSection(const string §ion_name); 152057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 153057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The CU's DW_AT_stmt_list offset OFFSET is bogus. 154057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void BadLineInfoOffset(uint64 offset); 155057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 156057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // FUNCTION includes code covered by no line number data. 157057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void UncoveredFunction(const Module::Function &function); 158057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 159057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Line number NUMBER in LINE_FILE, of length LENGTH, includes code 160057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // covered by no function. 161057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual void UncoveredLine(const Module::Line &line); 162057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 163057aa1f6173501e1a62cf91fd08275e7da439166jimblandy protected: 164057aa1f6173501e1a62cf91fd08275e7da439166jimblandy string filename_; 165057aa1f6173501e1a62cf91fd08275e7da439166jimblandy uint64 cu_offset_; 166057aa1f6173501e1a62cf91fd08275e7da439166jimblandy string cu_name_; 167057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool printed_cu_header_; 168057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool printed_unpaired_header_; 1699e6b619ad084c58af9fb8983b1a646192adb3835jimblandy bool uncovered_warnings_enabled_; 170057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 171057aa1f6173501e1a62cf91fd08275e7da439166jimblandy private: 172057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Print a per-CU heading, once. 173057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void CUHeading(); 174057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Print an unpaired function/line heading, once. 175057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void UncoveredHeading(); 176057aa1f6173501e1a62cf91fd08275e7da439166jimblandy }; 177057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 178057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Create a DWARF debugging info handler for a compilation unit 179057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // within FILE_CONTEXT. This uses information received from the 180057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // dwarf2reader::CompilationUnit DWARF parser to populate 181057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // FILE_CONTEXT->module. Use LINE_READER to handle the compilation 182057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // unit's line number data. Use REPORTER to report problems with the 183057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // data we find. 184057aa1f6173501e1a62cf91fd08275e7da439166jimblandy DwarfCUToModule(FileContext *file_context, 185057aa1f6173501e1a62cf91fd08275e7da439166jimblandy LineToModuleFunctor *line_reader, 186057aa1f6173501e1a62cf91fd08275e7da439166jimblandy WarningReporter *reporter); 187057aa1f6173501e1a62cf91fd08275e7da439166jimblandy ~DwarfCUToModule(); 188057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 189057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void ProcessAttributeSigned(enum DwarfAttribute attr, 190057aa1f6173501e1a62cf91fd08275e7da439166jimblandy enum DwarfForm form, 191057aa1f6173501e1a62cf91fd08275e7da439166jimblandy int64 data); 192057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void ProcessAttributeUnsigned(enum DwarfAttribute attr, 193057aa1f6173501e1a62cf91fd08275e7da439166jimblandy enum DwarfForm form, 194057aa1f6173501e1a62cf91fd08275e7da439166jimblandy uint64 data); 195057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void ProcessAttributeString(enum DwarfAttribute attr, 196057aa1f6173501e1a62cf91fd08275e7da439166jimblandy enum DwarfForm form, 197057aa1f6173501e1a62cf91fd08275e7da439166jimblandy const string &data); 198057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool EndAttributes(); 199057aa1f6173501e1a62cf91fd08275e7da439166jimblandy DIEHandler *FindChildHandler(uint64 offset, enum DwarfTag tag, 200057aa1f6173501e1a62cf91fd08275e7da439166jimblandy const AttributeList &attrs); 201057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 202057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Assign all our source Lines to the Functions that cover their 203057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // addresses, and then add them to module_. 204057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void Finish(); 205057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 206057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool StartCompilationUnit(uint64 offset, uint8 address_size, 207057aa1f6173501e1a62cf91fd08275e7da439166jimblandy uint8 offset_size, uint64 cu_length, 208057aa1f6173501e1a62cf91fd08275e7da439166jimblandy uint8 dwarf_version); 209057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool StartRootDIE(uint64 offset, enum DwarfTag tag, 210057aa1f6173501e1a62cf91fd08275e7da439166jimblandy const AttributeList& attrs); 211057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 212057aa1f6173501e1a62cf91fd08275e7da439166jimblandy private: 213057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 214057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Used internally by the handler. Full definitions are in 215057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // dwarf_cu_to_module.cc. 216057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct FilePrivate; 217057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct Specification; 218057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct CUContext; 219057aa1f6173501e1a62cf91fd08275e7da439166jimblandy struct DIEContext; 220057aa1f6173501e1a62cf91fd08275e7da439166jimblandy class GenericDIEHandler; 221057aa1f6173501e1a62cf91fd08275e7da439166jimblandy class FuncHandler; 222057aa1f6173501e1a62cf91fd08275e7da439166jimblandy class NamedScopeHandler; 223057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 224057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // A map from section offsets to specifications. 225057aa1f6173501e1a62cf91fd08275e7da439166jimblandy typedef map<uint64, Specification> SpecificationByOffset; 226057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 227057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Set this compilation unit's source language to LANGUAGE. 228057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void SetLanguage(DwarfLanguage language); 229057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 230057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Read source line information at OFFSET in the .debug_line 231057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // section. Record source files in module_, but record source lines 232057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // in lines_; we apportion them to functions in 233057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // AssignLinesToFunctions. 234057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void ReadSourceLines(uint64 offset); 235057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 236057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Assign the lines in lines_ to the individual line lists of the 237057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // functions in functions_. (DWARF line information maps an entire 238057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // compilation unit at a time, and gives no indication of which 239057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // lines belong to which functions, beyond their addresses.) 240057aa1f6173501e1a62cf91fd08275e7da439166jimblandy void AssignLinesToFunctions(); 241057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 242057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The only reason cu_context_ and child_context_ are pointers is 243057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // that we want to keep their definitions private to 244057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // dwarf_cu_to_module.cc, instead of listing them all here. They are 245057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // owned by this DwarfCUToModule: the constructor sets them, and the 246057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // destructor deletes them. 247057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 248057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The functor to use to handle line number data. 249057aa1f6173501e1a62cf91fd08275e7da439166jimblandy LineToModuleFunctor *line_reader_; 250057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 251057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // This compilation unit's context. 252057aa1f6173501e1a62cf91fd08275e7da439166jimblandy CUContext *cu_context_; 253057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 254057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // A context for our children. 255057aa1f6173501e1a62cf91fd08275e7da439166jimblandy DIEContext *child_context_; 256057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 257057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // True if this compilation unit has source line information. 258057aa1f6173501e1a62cf91fd08275e7da439166jimblandy bool has_source_line_info_; 259057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 260057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The offset of this compilation unit's line number information in 261057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // the .debug_line section. 262057aa1f6173501e1a62cf91fd08275e7da439166jimblandy uint64 source_line_offset_; 263057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 264057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // The line numbers we have seen thus far. We accumulate these here 265057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // during parsing. Then, in Finish, we call AssignLinesToFunctions 266057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // to dole them out to the appropriate functions. 267057aa1f6173501e1a62cf91fd08275e7da439166jimblandy vector<Module::Line> lines_; 268057aa1f6173501e1a62cf91fd08275e7da439166jimblandy}; 269057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 270057aa1f6173501e1a62cf91fd08275e7da439166jimblandy} // namespace google_breakpad 271057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 272057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#endif // COMMON_LINUX_DWARF_CU_TO_MODULE_H__ 273