1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2010-2016, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef DWARF_IMAGE_DEBUG_INFO_H 7 #define DWARF_IMAGE_DEBUG_INFO_H 8 9 10 #include <Locker.h> 11 12 #include <util/OpenHashTable.h> 13 14 #include "AddressSectionTypes.h" 15 #include "ImageInfo.h" 16 #include "SpecificImageDebugInfo.h" 17 #include "Type.h" 18 19 20 class Architecture; 21 class CompilationUnit; 22 class DebuggerInterface; 23 class DIEType; 24 class DwarfFunctionDebugInfo; 25 class DwarfStackFrameDebugInfo; 26 class DwarfFile; 27 class ElfSegment; 28 class FileManager; 29 class FileSourceCode; 30 class FunctionID; 31 class FunctionInstance; 32 class GlobalTypeCache; 33 class GlobalTypeLookup; 34 class LocatableFile; 35 class SourceCode; 36 class TeamFunctionSourceInformation; 37 38 39 class DwarfImageDebugInfo : public SpecificImageDebugInfo { 40 public: 41 DwarfImageDebugInfo(const ImageInfo& imageInfo, 42 DebuggerInterface* interface, 43 Architecture* architecture, 44 FileManager* fileManager, 45 GlobalTypeLookup* typeLookup, 46 GlobalTypeCache* typeCache, 47 TeamFunctionSourceInformation* sourceInfo, 48 DwarfFile* file); 49 virtual ~DwarfImageDebugInfo(); 50 51 status_t Init(); 52 53 target_addr_t RelocationDelta() const 54 { return fRelocationDelta; } 55 56 virtual status_t GetFunctions( 57 const BObjectList<SymbolInfo>& symbols, 58 BObjectList<FunctionDebugInfo>& functions); 59 virtual status_t GetType(GlobalTypeCache* cache, 60 const BString& name, 61 const TypeLookupConstraints& constraints, 62 Type*& _type); 63 virtual bool HasType(const BString& name, 64 const TypeLookupConstraints& constraints) 65 const; 66 67 virtual AddressSectionType GetAddressSectionType(target_addr_t address); 68 69 virtual status_t CreateFrame(Image* image, 70 FunctionInstance* functionInstance, 71 CpuState* cpuState, 72 bool getFullFrameInfo, 73 ReturnValueInfoList* returnValueInfos, 74 StackFrame*& _frame, 75 CpuState*& _previousCpuState); 76 virtual status_t GetStatement(FunctionDebugInfo* function, 77 target_addr_t address, 78 Statement*& _statement); 79 virtual status_t GetStatementAtSourceLocation( 80 FunctionDebugInfo* function, 81 const SourceLocation& sourceLocation, 82 Statement*& _statement); 83 84 virtual status_t GetSourceLanguage(FunctionDebugInfo* function, 85 SourceLanguage*& _language); 86 87 virtual ssize_t ReadCode(target_addr_t address, void* buffer, 88 size_t size); 89 90 virtual status_t AddSourceCodeInfo(LocatableFile* file, 91 FileSourceCode* sourceCode); 92 93 private: 94 struct BasicTargetInterface; 95 struct UnwindTargetInterface; 96 struct EntryListWrapper; 97 98 struct TypeNameKey; 99 struct TypeNameEntry; 100 struct TypeNameEntryHashDefinition; 101 102 typedef BOpenHashTable<TypeNameEntryHashDefinition> 103 TypeNameTable; 104 105 struct TypeEntryInfo; 106 typedef BObjectList<TypeEntryInfo> TypeEntryList; 107 108 private: 109 status_t _AddSourceCodeInfo(CompilationUnit* unit, 110 FileSourceCode* sourceCode, 111 int32 fileIndex); 112 int32 _GetSourceFileIndex(CompilationUnit* unit, 113 LocatableFile* sourceFile) const; 114 115 status_t _CreateLocalVariables(CompilationUnit* unit, 116 StackFrame* frame, FunctionID* functionID, 117 DwarfStackFrameDebugInfo& factory, 118 target_addr_t instructionPointer, 119 target_addr_t lowPC, 120 const EntryListWrapper& variableEntries, 121 const EntryListWrapper& blockEntries); 122 123 status_t _CreateReturnValues( 124 ReturnValueInfoList* returnValueInfos, 125 Image* image, 126 StackFrame* frame, 127 DwarfStackFrameDebugInfo& factory); 128 129 bool _EvaluateBaseTypeConstraints(DIEType* type, 130 const TypeLookupConstraints& constraints) 131 const; 132 133 status_t _BuildTypeNameTable(); 134 135 private: 136 BLocker fLock; 137 ImageInfo fImageInfo; 138 DebuggerInterface* fDebuggerInterface; 139 Architecture* fArchitecture; 140 FileManager* fFileManager; 141 GlobalTypeLookup* fTypeLookup; 142 GlobalTypeCache* fTypeCache; 143 TeamFunctionSourceInformation* fSourceInfo; 144 TypeNameTable* fTypeNameTable; 145 DwarfFile* fFile; 146 ElfSegment* fTextSegment; 147 target_addr_t fRelocationDelta; 148 target_addr_t fTextSectionStart; 149 target_addr_t fTextSectionEnd; 150 target_addr_t fPLTSectionStart; 151 target_addr_t fPLTSectionEnd; 152 }; 153 154 155 #endif // DWARF_IMAGE_DEBUG_INFO_H 156