Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 1 | //===- DWARFContext.cpp ---------------------------------------------------===// |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Alexey Samsonov | e16e16a | 2012-07-19 07:03:58 +0000 | [diff] [blame] | 10 | #include "llvm/ADT/SmallString.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/SmallVector.h" |
| 12 | #include "llvm/ADT/STLExtras.h" |
Alexey Samsonov | 3d0e3ed | 2013-04-17 14:27:04 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/StringSwitch.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/StringRef.h" |
Zachary Turner | 82af943 | 2015-01-30 18:07:45 +0000 | [diff] [blame] | 15 | #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" |
| 17 | #include "llvm/DebugInfo/DWARF/DWARFContext.h" |
| 18 | #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" |
| 19 | #include "llvm/DebugInfo/DWARF/DWARFDebugAranges.h" |
Zachary Turner | 82af943 | 2015-01-30 18:07:45 +0000 | [diff] [blame] | 20 | #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 21 | #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" |
| 22 | #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" |
| 23 | #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" |
| 24 | #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" |
George Rimar | e71e33f | 2016-12-17 09:10:32 +0000 | [diff] [blame] | 25 | #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 26 | #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" |
| 27 | #include "llvm/DebugInfo/DWARF/DWARFDie.h" |
| 28 | #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" |
| 29 | #include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" |
| 30 | #include "llvm/DebugInfo/DWARF/DWARFSection.h" |
David Blaikie | 65a8efe | 2015-11-11 19:28:21 +0000 | [diff] [blame] | 31 | #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" |
George Rimar | 4bf3083 | 2017-01-11 15:26:41 +0000 | [diff] [blame] | 32 | #include "llvm/Object/Decompressor.h" |
Reid Kleckner | dafc5d7 | 2016-07-06 16:56:42 +0000 | [diff] [blame] | 33 | #include "llvm/Object/MachO.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 34 | #include "llvm/Object/ObjectFile.h" |
Reid Kleckner | dafc5d7 | 2016-07-06 16:56:42 +0000 | [diff] [blame] | 35 | #include "llvm/Object/RelocVisitor.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 36 | #include "llvm/Support/Casting.h" |
| 37 | #include "llvm/Support/DataExtractor.h" |
| 38 | #include "llvm/Support/Debug.h" |
| 39 | #include "llvm/Support/Error.h" |
Benjamin Kramer | 07d4b1c | 2011-09-15 16:57:13 +0000 | [diff] [blame] | 40 | #include "llvm/Support/Format.h" |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 41 | #include "llvm/Support/MemoryBuffer.h" |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 42 | #include "llvm/Support/raw_ostream.h" |
Benjamin Kramer | 2602ca6 | 2011-09-15 20:43:22 +0000 | [diff] [blame] | 43 | #include <algorithm> |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 44 | #include <cstdint> |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 45 | #include <map> |
| 46 | #include <set> |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 47 | #include <string> |
| 48 | #include <utility> |
| 49 | #include <vector> |
| 50 | |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 51 | using namespace llvm; |
Benjamin Kramer | 6dda032 | 2011-09-15 18:02:20 +0000 | [diff] [blame] | 52 | using namespace dwarf; |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 53 | using namespace object; |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 54 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 55 | #define DEBUG_TYPE "dwarf" |
| 56 | |
Eric Christopher | 494109b | 2012-10-16 23:46:25 +0000 | [diff] [blame] | 57 | typedef DWARFDebugLine::LineTable DWARFLineTable; |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 58 | typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind; |
| 59 | typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind; |
Eric Christopher | 494109b | 2012-10-16 23:46:25 +0000 | [diff] [blame] | 60 | |
George Rimar | f8a9642 | 2017-04-21 09:12:18 +0000 | [diff] [blame] | 61 | uint64_t llvm::getRelocatedValue(const DataExtractor &Data, uint32_t Size, |
| 62 | uint32_t *Off, const RelocAddrMap *Relocs) { |
| 63 | if (!Relocs) |
| 64 | return Data.getUnsigned(Off, Size); |
| 65 | RelocAddrMap::const_iterator AI = Relocs->find(*Off); |
| 66 | if (AI == Relocs->end()) |
| 67 | return Data.getUnsigned(Off, Size); |
| 68 | return Data.getUnsigned(Off, Size) + AI->second.second; |
| 69 | } |
| 70 | |
Frederic Riss | 7c50047 | 2014-11-14 19:30:08 +0000 | [diff] [blame] | 71 | static void dumpAccelSection(raw_ostream &OS, StringRef Name, |
| 72 | const DWARFSection& Section, StringRef StringSection, |
| 73 | bool LittleEndian) { |
| 74 | DataExtractor AccelSection(Section.Data, LittleEndian, 0); |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 75 | DataExtractor StrData(StringSection, LittleEndian, 0); |
| 76 | OS << "\n." << Name << " contents:\n"; |
Frederic Riss | 7c50047 | 2014-11-14 19:30:08 +0000 | [diff] [blame] | 77 | DWARFAcceleratorTable Accel(AccelSection, StrData, Section.Relocs); |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 78 | if (!Accel.extract()) |
| 79 | return; |
| 80 | Accel.dump(OS); |
| 81 | } |
| 82 | |
David Blaikie | 50cc27e | 2016-10-18 21:09:48 +0000 | [diff] [blame] | 83 | void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH, |
| 84 | bool SummarizeTypes) { |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 85 | if (DumpType == DIDT_All || DumpType == DIDT_Abbrev) { |
| 86 | OS << ".debug_abbrev contents:\n"; |
| 87 | getDebugAbbrev()->dump(OS); |
| 88 | } |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 89 | |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 90 | if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) |
| 91 | if (const DWARFDebugAbbrev *D = getDebugAbbrevDWO()) { |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 92 | OS << "\n.debug_abbrev.dwo contents:\n"; |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 93 | D->dump(OS); |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 94 | } |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 95 | |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 96 | if (DumpType == DIDT_All || DumpType == DIDT_Info) { |
| 97 | OS << "\n.debug_info contents:\n"; |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 98 | for (const auto &CU : compile_units()) |
| 99 | CU->dump(OS); |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 100 | } |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 101 | |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 102 | if ((DumpType == DIDT_All || DumpType == DIDT_InfoDwo) && |
| 103 | getNumDWOCompileUnits()) { |
| 104 | OS << "\n.debug_info.dwo contents:\n"; |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 105 | for (const auto &DWOCU : dwo_compile_units()) |
| 106 | DWOCU->dump(OS); |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 107 | } |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 108 | |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 109 | if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) { |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 110 | OS << "\n.debug_types contents:\n"; |
Frederic Riss | 312a02e | 2014-09-29 13:56:39 +0000 | [diff] [blame] | 111 | for (const auto &TUS : type_unit_sections()) |
| 112 | for (const auto &TU : TUS) |
David Blaikie | 50cc27e | 2016-10-18 21:09:48 +0000 | [diff] [blame] | 113 | TU->dump(OS, SummarizeTypes); |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 116 | if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) && |
| 117 | getNumDWOTypeUnits()) { |
| 118 | OS << "\n.debug_types.dwo contents:\n"; |
Frederic Riss | 312a02e | 2014-09-29 13:56:39 +0000 | [diff] [blame] | 119 | for (const auto &DWOTUS : dwo_type_unit_sections()) |
| 120 | for (const auto &DWOTU : DWOTUS) |
David Blaikie | 50cc27e | 2016-10-18 21:09:48 +0000 | [diff] [blame] | 121 | DWOTU->dump(OS, SummarizeTypes); |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 122 | } |
David Blaikie | 92d9d62 | 2014-01-09 05:08:24 +0000 | [diff] [blame] | 123 | |
David Blaikie | 18e7350 | 2013-06-19 21:37:13 +0000 | [diff] [blame] | 124 | if (DumpType == DIDT_All || DumpType == DIDT_Loc) { |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 125 | OS << "\n.debug_loc contents:\n"; |
David Blaikie | 18e7350 | 2013-06-19 21:37:13 +0000 | [diff] [blame] | 126 | getDebugLoc()->dump(OS); |
| 127 | } |
| 128 | |
David Blaikie | 9c550ac | 2014-03-25 01:44:02 +0000 | [diff] [blame] | 129 | if (DumpType == DIDT_All || DumpType == DIDT_LocDwo) { |
| 130 | OS << "\n.debug_loc.dwo contents:\n"; |
| 131 | getDebugLocDWO()->dump(OS); |
| 132 | } |
| 133 | |
Eli Bendersky | fd08bc1 | 2013-02-05 23:30:58 +0000 | [diff] [blame] | 134 | if (DumpType == DIDT_All || DumpType == DIDT_Frames) { |
| 135 | OS << "\n.debug_frame contents:\n"; |
| 136 | getDebugFrame()->dump(OS); |
Igor Laevsky | 03a670c | 2016-01-26 15:09:42 +0000 | [diff] [blame] | 137 | if (DumpEH) { |
| 138 | OS << "\n.eh_frame contents:\n"; |
| 139 | getEHFrame()->dump(OS); |
| 140 | } |
Eli Bendersky | fd08bc1 | 2013-02-05 23:30:58 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Amjad Aboud | e59cc3e | 2015-11-12 09:38:54 +0000 | [diff] [blame] | 143 | if (DumpType == DIDT_All || DumpType == DIDT_Macro) { |
| 144 | OS << "\n.debug_macinfo contents:\n"; |
| 145 | getDebugMacro()->dump(OS); |
| 146 | } |
| 147 | |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 148 | uint32_t offset = 0; |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 149 | if (DumpType == DIDT_All || DumpType == DIDT_Aranges) { |
| 150 | OS << "\n.debug_aranges contents:\n"; |
| 151 | DataExtractor arangesData(getARangeSection(), isLittleEndian(), 0); |
| 152 | DWARFDebugArangeSet set; |
| 153 | while (set.extract(arangesData, &offset)) |
| 154 | set.dump(OS); |
| 155 | } |
Benjamin Kramer | 5acab50 | 2011-09-15 02:12:05 +0000 | [diff] [blame] | 156 | |
Alexey Samsonov | 034e57a | 2012-08-27 07:17:47 +0000 | [diff] [blame] | 157 | uint8_t savedAddressByteSize = 0; |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 158 | if (DumpType == DIDT_All || DumpType == DIDT_Line) { |
| 159 | OS << "\n.debug_line contents:\n"; |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 160 | for (const auto &CU : compile_units()) { |
| 161 | savedAddressByteSize = CU->getAddressByteSize(); |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 162 | auto CUDIE = CU->getUnitDIE(); |
| 163 | if (!CUDIE) |
Alexey Samsonov | 7a18c06 | 2015-05-19 21:54:32 +0000 | [diff] [blame] | 164 | continue; |
Greg Clayton | 97d2218 | 2017-01-13 21:08:18 +0000 | [diff] [blame] | 165 | if (auto StmtOffset = toSectionOffset(CUDIE.find(DW_AT_stmt_list))) { |
David Blaikie | 1b5ee5d | 2013-09-23 17:42:01 +0000 | [diff] [blame] | 166 | DataExtractor lineData(getLineSection().Data, isLittleEndian(), |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 167 | savedAddressByteSize); |
Alexey Samsonov | 110d595 | 2014-04-30 00:09:19 +0000 | [diff] [blame] | 168 | DWARFDebugLine::LineTable LineTable; |
Greg Clayton | 52fe1f6 | 2016-12-14 22:38:08 +0000 | [diff] [blame] | 169 | uint32_t Offset = *StmtOffset; |
| 170 | LineTable.parse(lineData, &getLineSection().Relocs, &Offset); |
Alexey Samsonov | 110d595 | 2014-04-30 00:09:19 +0000 | [diff] [blame] | 171 | LineTable.dump(OS); |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 172 | } |
Benjamin Kramer | 6dda032 | 2011-09-15 18:02:20 +0000 | [diff] [blame] | 173 | } |
| 174 | } |
Benjamin Kramer | 07d4b1c | 2011-09-15 16:57:13 +0000 | [diff] [blame] | 175 | |
David Blaikie | 65a8efe | 2015-11-11 19:28:21 +0000 | [diff] [blame] | 176 | if (DumpType == DIDT_All || DumpType == DIDT_CUIndex) { |
| 177 | OS << "\n.debug_cu_index contents:\n"; |
David Blaikie | b073cb9 | 2015-12-02 06:21:34 +0000 | [diff] [blame] | 178 | getCUIndex().dump(OS); |
David Blaikie | 65a8efe | 2015-11-11 19:28:21 +0000 | [diff] [blame] | 179 | } |
| 180 | |
David Blaikie | 51c4028 | 2015-11-11 19:40:49 +0000 | [diff] [blame] | 181 | if (DumpType == DIDT_All || DumpType == DIDT_TUIndex) { |
| 182 | OS << "\n.debug_tu_index contents:\n"; |
David Blaikie | b073cb9 | 2015-12-02 06:21:34 +0000 | [diff] [blame] | 183 | getTUIndex().dump(OS); |
David Blaikie | 51c4028 | 2015-11-11 19:40:49 +0000 | [diff] [blame] | 184 | } |
| 185 | |
David Blaikie | 1d4736e | 2014-02-24 23:58:54 +0000 | [diff] [blame] | 186 | if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) { |
| 187 | OS << "\n.debug_line.dwo contents:\n"; |
| 188 | unsigned stmtOffset = 0; |
| 189 | DataExtractor lineData(getLineDWOSection().Data, isLittleEndian(), |
| 190 | savedAddressByteSize); |
Alexey Samsonov | 110d595 | 2014-04-30 00:09:19 +0000 | [diff] [blame] | 191 | DWARFDebugLine::LineTable LineTable; |
| 192 | while (LineTable.Prologue.parse(lineData, &stmtOffset)) { |
| 193 | LineTable.dump(OS); |
| 194 | LineTable.clear(); |
| 195 | } |
David Blaikie | 1d4736e | 2014-02-24 23:58:54 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 198 | if (DumpType == DIDT_All || DumpType == DIDT_Str) { |
| 199 | OS << "\n.debug_str contents:\n"; |
| 200 | DataExtractor strData(getStringSection(), isLittleEndian(), 0); |
| 201 | offset = 0; |
| 202 | uint32_t strOffset = 0; |
| 203 | while (const char *s = strData.getCStr(&offset)) { |
| 204 | OS << format("0x%8.8x: \"%s\"\n", strOffset, s); |
| 205 | strOffset = offset; |
| 206 | } |
Benjamin Kramer | 07d4b1c | 2011-09-15 16:57:13 +0000 | [diff] [blame] | 207 | } |
Alexey Samsonov | 034e57a | 2012-08-27 07:17:47 +0000 | [diff] [blame] | 208 | |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 209 | if ((DumpType == DIDT_All || DumpType == DIDT_StrDwo) && |
| 210 | !getStringDWOSection().empty()) { |
| 211 | OS << "\n.debug_str.dwo contents:\n"; |
| 212 | DataExtractor strDWOData(getStringDWOSection(), isLittleEndian(), 0); |
| 213 | offset = 0; |
| 214 | uint32_t strDWOOffset = 0; |
| 215 | while (const char *s = strDWOData.getCStr(&offset)) { |
| 216 | OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s); |
| 217 | strDWOOffset = offset; |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 218 | } |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 219 | } |
David Blaikie | 622dce4 | 2014-01-08 23:29:59 +0000 | [diff] [blame] | 220 | |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 221 | if (DumpType == DIDT_All || DumpType == DIDT_Ranges) { |
| 222 | OS << "\n.debug_ranges contents:\n"; |
| 223 | // In fact, different compile units may have different address byte |
| 224 | // sizes, but for simplicity we just use the address byte size of the last |
| 225 | // compile unit (there is no easy and fast way to associate address range |
| 226 | // list and the compile unit it describes). |
George Rimar | ca53211 | 2017-04-24 10:19:45 +0000 | [diff] [blame] | 227 | DataExtractor rangesData(getRangeSection().Data, isLittleEndian(), |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 228 | savedAddressByteSize); |
| 229 | offset = 0; |
| 230 | DWARFDebugRangeList rangeList; |
George Rimar | ca53211 | 2017-04-24 10:19:45 +0000 | [diff] [blame] | 231 | while (rangeList.extract(rangesData, &offset, getRangeSection().Relocs)) |
Eli Bendersky | 7a94daa | 2013-01-25 20:26:43 +0000 | [diff] [blame] | 232 | rangeList.dump(OS); |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 233 | } |
Eric Christopher | 962c908 | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 234 | |
Eric Christopher | 0de5359 | 2013-09-25 23:02:36 +0000 | [diff] [blame] | 235 | if (DumpType == DIDT_All || DumpType == DIDT_Pubnames) |
George Rimar | e71e33f | 2016-12-17 09:10:32 +0000 | [diff] [blame] | 236 | DWARFDebugPubTable(getPubNamesSection(), isLittleEndian(), false) |
| 237 | .dump("debug_pubnames", OS); |
Krzysztof Parzyszek | 97438dc | 2013-02-12 16:20:28 +0000 | [diff] [blame] | 238 | |
Eric Christopher | 4c7e6ba | 2013-09-25 23:02:41 +0000 | [diff] [blame] | 239 | if (DumpType == DIDT_All || DumpType == DIDT_Pubtypes) |
George Rimar | e71e33f | 2016-12-17 09:10:32 +0000 | [diff] [blame] | 240 | DWARFDebugPubTable(getPubTypesSection(), isLittleEndian(), false) |
| 241 | .dump("debug_pubtypes", OS); |
Eric Christopher | 4c7e6ba | 2013-09-25 23:02:41 +0000 | [diff] [blame] | 242 | |
David Blaikie | ecd21ff | 2013-09-24 19:50:00 +0000 | [diff] [blame] | 243 | if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames) |
George Rimar | e71e33f | 2016-12-17 09:10:32 +0000 | [diff] [blame] | 244 | DWARFDebugPubTable(getGnuPubNamesSection(), isLittleEndian(), |
| 245 | true /* GnuStyle */) |
| 246 | .dump("debug_gnu_pubnames", OS); |
David Blaikie | ecd21ff | 2013-09-24 19:50:00 +0000 | [diff] [blame] | 247 | |
| 248 | if (DumpType == DIDT_All || DumpType == DIDT_GnuPubtypes) |
George Rimar | e71e33f | 2016-12-17 09:10:32 +0000 | [diff] [blame] | 249 | DWARFDebugPubTable(getGnuPubTypesSection(), isLittleEndian(), |
| 250 | true /* GnuStyle */) |
| 251 | .dump("debug_gnu_pubtypes", OS); |
David Blaikie | 404d304 | 2013-09-19 23:01:29 +0000 | [diff] [blame] | 252 | |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 253 | if ((DumpType == DIDT_All || DumpType == DIDT_StrOffsetsDwo) && |
| 254 | !getStringOffsetDWOSection().empty()) { |
| 255 | OS << "\n.debug_str_offsets.dwo contents:\n"; |
| 256 | DataExtractor strOffsetExt(getStringOffsetDWOSection(), isLittleEndian(), |
| 257 | 0); |
| 258 | offset = 0; |
| 259 | uint64_t size = getStringOffsetDWOSection().size(); |
| 260 | while (offset < size) { |
| 261 | OS << format("0x%8.8x: ", offset); |
| 262 | OS << format("%8.8x\n", strOffsetExt.getU32(&offset)); |
Eric Christopher | 92f3c0b | 2013-05-06 17:50:42 +0000 | [diff] [blame] | 263 | } |
David Blaikie | 66865d6 | 2014-01-09 00:13:35 +0000 | [diff] [blame] | 264 | } |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 265 | |
George Rimar | 4f82df5 | 2016-09-23 11:01:53 +0000 | [diff] [blame] | 266 | if ((DumpType == DIDT_All || DumpType == DIDT_GdbIndex) && |
| 267 | !getGdbIndexSection().empty()) { |
| 268 | OS << "\n.gnu_index contents:\n"; |
| 269 | getGdbIndex().dump(OS); |
| 270 | } |
| 271 | |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 272 | if (DumpType == DIDT_All || DumpType == DIDT_AppleNames) |
| 273 | dumpAccelSection(OS, "apple_names", getAppleNamesSection(), |
| 274 | getStringSection(), isLittleEndian()); |
| 275 | |
| 276 | if (DumpType == DIDT_All || DumpType == DIDT_AppleTypes) |
| 277 | dumpAccelSection(OS, "apple_types", getAppleTypesSection(), |
| 278 | getStringSection(), isLittleEndian()); |
| 279 | |
| 280 | if (DumpType == DIDT_All || DumpType == DIDT_AppleNamespaces) |
| 281 | dumpAccelSection(OS, "apple_namespaces", getAppleNamespacesSection(), |
| 282 | getStringSection(), isLittleEndian()); |
| 283 | |
| 284 | if (DumpType == DIDT_All || DumpType == DIDT_AppleObjC) |
| 285 | dumpAccelSection(OS, "apple_objc", getAppleObjCSection(), |
| 286 | getStringSection(), isLittleEndian()); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 289 | DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) { |
| 290 | parseCompileUnits(); |
| 291 | if (auto *CU = CUs.getUnitForOffset(Offset)) |
| 292 | return CU->getDIEForOffset(Offset); |
| 293 | return DWARFDie(); |
| 294 | } |
| 295 | |
| 296 | namespace { |
| 297 | |
| 298 | class Verifier { |
| 299 | raw_ostream &OS; |
| 300 | DWARFContext &DCtx; |
| 301 | public: |
| 302 | Verifier(raw_ostream &S, DWARFContext &D) : OS(S), DCtx(D) {} |
| 303 | |
| 304 | bool HandleDebugInfo() { |
| 305 | bool Success = true; |
| 306 | // A map that tracks all references (converted absolute references) so we |
| 307 | // can verify each reference points to a valid DIE and not an offset that |
| 308 | // lies between to valid DIEs. |
| 309 | std::map<uint64_t, std::set<uint32_t>> ReferenceToDIEOffsets; |
| 310 | |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 311 | OS << "Verifying .debug_info...\n"; |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 312 | for (const auto &CU : DCtx.compile_units()) { |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 313 | unsigned NumDies = CU->getNumDIEs(); |
| 314 | for (unsigned I = 0; I < NumDies; ++I) { |
| 315 | auto Die = CU->getDIEAtIndex(I); |
| 316 | const auto Tag = Die.getTag(); |
| 317 | if (Tag == DW_TAG_null) |
| 318 | continue; |
| 319 | for (auto AttrValue : Die.attributes()) { |
| 320 | const auto Attr = AttrValue.Attr; |
| 321 | const auto Form = AttrValue.Value.getForm(); |
| 322 | switch (Attr) { |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 323 | case DW_AT_ranges: |
| 324 | // Make sure the offset in the DW_AT_ranges attribute is valid. |
| 325 | if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) { |
| 326 | if (*SectionOffset >= DCtx.getRangeSection().Data.size()) { |
| 327 | Success = false; |
| 328 | OS << "error: DW_AT_ranges offset is beyond .debug_ranges " |
| 329 | "bounds:\n"; |
| 330 | Die.dump(OS, 0); |
| 331 | OS << "\n"; |
| 332 | } |
| 333 | } else { |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 334 | Success = false; |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 335 | OS << "error: DIE has invalid DW_AT_ranges encoding:\n"; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 336 | Die.dump(OS, 0); |
| 337 | OS << "\n"; |
| 338 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 339 | break; |
| 340 | case DW_AT_stmt_list: |
| 341 | // Make sure the offset in the DW_AT_stmt_list attribute is valid. |
| 342 | if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) { |
| 343 | if (*SectionOffset >= DCtx.getLineSection().Data.size()) { |
| 344 | Success = false; |
| 345 | OS << "error: DW_AT_stmt_list offset is beyond .debug_line " |
| 346 | "bounds: " |
| 347 | << format("0x%08" PRIx32, *SectionOffset) << "\n"; |
| 348 | CU->getUnitDIE().dump(OS, 0); |
| 349 | OS << "\n"; |
| 350 | } |
| 351 | } else { |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 352 | Success = false; |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 353 | OS << "error: DIE has invalid DW_AT_stmt_list encoding:\n"; |
| 354 | Die.dump(OS, 0); |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 355 | OS << "\n"; |
| 356 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 357 | break; |
| 358 | |
| 359 | default: |
| 360 | break; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 361 | } |
| 362 | switch (Form) { |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 363 | case DW_FORM_ref1: |
| 364 | case DW_FORM_ref2: |
| 365 | case DW_FORM_ref4: |
| 366 | case DW_FORM_ref8: |
| 367 | case DW_FORM_ref_udata: { |
| 368 | // Verify all CU relative references are valid CU offsets. |
| 369 | Optional<uint64_t> RefVal = AttrValue.Value.getAsReference(); |
| 370 | assert(RefVal); |
| 371 | if (RefVal) { |
| 372 | auto DieCU = Die.getDwarfUnit(); |
| 373 | auto CUSize = DieCU->getNextUnitOffset() - DieCU->getOffset(); |
| 374 | auto CUOffset = AttrValue.Value.getRawUValue(); |
| 375 | if (CUOffset >= CUSize) { |
| 376 | Success = false; |
| 377 | OS << "error: " << FormEncodingString(Form) << " CU offset " |
| 378 | << format("0x%08" PRIx32, CUOffset) |
| 379 | << " is invalid (must be less than CU size of " |
| 380 | << format("0x%08" PRIx32, CUSize) << "):\n"; |
| 381 | Die.dump(OS, 0); |
| 382 | OS << "\n"; |
| 383 | } else { |
| 384 | // Valid reference, but we will verify it points to an actual |
| 385 | // DIE later. |
| 386 | ReferenceToDIEOffsets[*RefVal].insert(Die.getOffset()); |
| 387 | } |
| 388 | } |
| 389 | break; |
| 390 | } |
| 391 | case DW_FORM_ref_addr: { |
| 392 | // Verify all absolute DIE references have valid offsets in the |
| 393 | // .debug_info section. |
| 394 | Optional<uint64_t> RefVal = AttrValue.Value.getAsReference(); |
| 395 | assert(RefVal); |
| 396 | if (RefVal) { |
| 397 | if(*RefVal >= DCtx.getInfoSection().Data.size()) { |
| 398 | Success = false; |
| 399 | OS << "error: DW_FORM_ref_addr offset beyond .debug_info " |
| 400 | "bounds:\n"; |
| 401 | Die.dump(OS, 0); |
| 402 | OS << "\n"; |
| 403 | } else { |
| 404 | // Valid reference, but we will verify it points to an actual |
| 405 | // DIE later. |
| 406 | ReferenceToDIEOffsets[*RefVal].insert(Die.getOffset()); |
| 407 | } |
| 408 | } |
| 409 | break; |
| 410 | } |
| 411 | case DW_FORM_strp: { |
| 412 | auto SecOffset = AttrValue.Value.getAsSectionOffset(); |
| 413 | assert(SecOffset); // DW_FORM_strp is a section offset. |
| 414 | if (SecOffset && *SecOffset >= DCtx.getStringSection().size()) { |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 415 | Success = false; |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 416 | OS << "error: DW_FORM_strp offset beyond .debug_str bounds:\n"; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 417 | Die.dump(OS, 0); |
| 418 | OS << "\n"; |
| 419 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 420 | break; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 421 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 422 | default: |
| 423 | break; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 428 | |
| 429 | // Take all references and make sure they point to an actual DIE by |
| 430 | // getting the DIE by offset and emitting an error |
| 431 | OS << "Verifying .debug_info references...\n"; |
| 432 | for (auto Pair: ReferenceToDIEOffsets) { |
| 433 | auto Die = DCtx.getDIEForOffset(Pair.first); |
| 434 | if (Die) |
| 435 | continue; |
| 436 | Success = false; |
| 437 | OS << "error: invalid DIE reference " << format("0x%08" PRIx64, Pair.first) |
| 438 | << ". Offset is in between DIEs:\n"; |
| 439 | for (auto Offset: Pair.second) { |
| 440 | auto ReferencingDie = DCtx.getDIEForOffset(Offset); |
| 441 | ReferencingDie.dump(OS, 0); |
| 442 | OS << "\n"; |
| 443 | } |
| 444 | OS << "\n"; |
| 445 | } |
| 446 | return Success; |
| 447 | } |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 448 | |
| 449 | bool HandleDebugLine() { |
Greg Clayton | 8df55b4 | 2017-05-03 15:45:31 +0000 | [diff] [blame^] | 450 | std::map<uint64_t, DWARFDie> StmtListToDie; |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 451 | bool Success = true; |
| 452 | OS << "Verifying .debug_line...\n"; |
| 453 | for (const auto &CU : DCtx.compile_units()) { |
| 454 | uint32_t LineTableOffset = 0; |
Greg Clayton | 8df55b4 | 2017-05-03 15:45:31 +0000 | [diff] [blame^] | 455 | auto CUDie = CU->getUnitDIE(); |
| 456 | auto StmtFormValue = CUDie.find(DW_AT_stmt_list); |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 457 | if (!StmtFormValue) { |
| 458 | // No line table for this compile unit. |
| 459 | continue; |
| 460 | } |
| 461 | // Get the attribute value as a section offset. No need to produce an |
| 462 | // error here if the encoding isn't correct because we validate this in |
| 463 | // the .debug_info verifier. |
| 464 | if (auto StmtSectionOffset = toSectionOffset(StmtFormValue)) { |
| 465 | LineTableOffset = *StmtSectionOffset; |
| 466 | if (LineTableOffset >= DCtx.getLineSection().Data.size()) { |
| 467 | // Make sure we don't get a valid line table back if the offset |
| 468 | // is wrong. |
| 469 | assert(DCtx.getLineTableForUnit(CU.get()) == nullptr); |
| 470 | // Skip this line table as it isn't valid. No need to create an error |
| 471 | // here because we validate this in the .debug_info verifier. |
| 472 | continue; |
Greg Clayton | 8df55b4 | 2017-05-03 15:45:31 +0000 | [diff] [blame^] | 473 | } else { |
| 474 | auto Iter = StmtListToDie.find(LineTableOffset); |
| 475 | if (Iter != StmtListToDie.end()) { |
| 476 | Success = false; |
| 477 | OS << "error: two compile unit DIEs, " |
| 478 | << format("0x%08" PRIx32, Iter->second.getOffset()) << " and " |
| 479 | << format("0x%08" PRIx32, CUDie.getOffset()) |
| 480 | << ", have the same DW_AT_stmt_list section offset:\n"; |
| 481 | Iter->second.dump(OS, 0); |
| 482 | CUDie.dump(OS, 0); |
| 483 | OS << '\n'; |
| 484 | // Already verified this line table before, no need to do it again. |
| 485 | continue; |
| 486 | } |
| 487 | StmtListToDie[LineTableOffset] = CUDie; |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | auto LineTable = DCtx.getLineTableForUnit(CU.get()); |
| 491 | if (!LineTable) { |
| 492 | Success = false; |
| 493 | OS << "error: .debug_line[" << format("0x%08" PRIx32, LineTableOffset) |
| 494 | << "] was not able to be parsed for CU:\n"; |
Greg Clayton | 8df55b4 | 2017-05-03 15:45:31 +0000 | [diff] [blame^] | 495 | CUDie.dump(OS, 0); |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 496 | OS << '\n'; |
| 497 | continue; |
| 498 | } |
| 499 | uint32_t MaxFileIndex = LineTable->Prologue.FileNames.size(); |
| 500 | uint64_t PrevAddress = 0; |
| 501 | uint32_t RowIndex = 0; |
| 502 | for (const auto &Row : LineTable->Rows) { |
| 503 | if (Row.Address < PrevAddress) { |
| 504 | Success = false; |
| 505 | OS << "error: .debug_line[" << format("0x%08" PRIx32, LineTableOffset) |
| 506 | << "] row[" << RowIndex |
| 507 | << "] decreases in address from previous row:\n"; |
| 508 | |
| 509 | DWARFDebugLine::Row::dumpTableHeader(OS); |
| 510 | if (RowIndex > 0) |
| 511 | LineTable->Rows[RowIndex - 1].dump(OS); |
| 512 | Row.dump(OS); |
| 513 | OS << '\n'; |
| 514 | } |
| 515 | |
| 516 | if (Row.File > MaxFileIndex) { |
| 517 | Success = false; |
| 518 | OS << "error: .debug_line[" << format("0x%08" PRIx32, LineTableOffset) |
| 519 | << "][" << RowIndex << "] has invalid file index " << Row.File |
| 520 | << " (valid values are [1," << MaxFileIndex << "]):\n"; |
| 521 | DWARFDebugLine::Row::dumpTableHeader(OS); |
| 522 | Row.dump(OS); |
| 523 | OS << '\n'; |
| 524 | } |
| 525 | if (Row.EndSequence) |
| 526 | PrevAddress = 0; |
| 527 | else |
| 528 | PrevAddress = Row.Address; |
| 529 | ++RowIndex; |
| 530 | } |
| 531 | } |
| 532 | return Success; |
| 533 | } |
Greg Clayton | c7695a8 | 2017-05-02 20:28:33 +0000 | [diff] [blame] | 534 | }; |
| 535 | |
| 536 | } // anonymous namespace |
| 537 | |
| 538 | bool DWARFContext::verify(raw_ostream &OS, DIDumpType DumpType) { |
| 539 | bool Success = true; |
| 540 | Verifier verifier(OS, *this); |
| 541 | if (DumpType == DIDT_All || DumpType == DIDT_Info) { |
| 542 | if (!verifier.HandleDebugInfo()) |
| 543 | Success = false; |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 544 | } |
Greg Clayton | 6707046 | 2017-05-02 22:48:52 +0000 | [diff] [blame] | 545 | if (DumpType == DIDT_All || DumpType == DIDT_Line) { |
| 546 | if (!verifier.HandleDebugLine()) |
| 547 | Success = false; |
| 548 | } |
Greg Clayton | 48432cf | 2017-05-01 22:07:02 +0000 | [diff] [blame] | 549 | return Success; |
| 550 | } |
David Blaikie | 82641be | 2015-11-17 00:39:55 +0000 | [diff] [blame] | 551 | const DWARFUnitIndex &DWARFContext::getCUIndex() { |
| 552 | if (CUIndex) |
| 553 | return *CUIndex; |
| 554 | |
| 555 | DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), 0); |
| 556 | |
David Blaikie | b073cb9 | 2015-12-02 06:21:34 +0000 | [diff] [blame] | 557 | CUIndex = llvm::make_unique<DWARFUnitIndex>(DW_SECT_INFO); |
David Blaikie | 82641be | 2015-11-17 00:39:55 +0000 | [diff] [blame] | 558 | CUIndex->parse(CUIndexData); |
| 559 | return *CUIndex; |
| 560 | } |
| 561 | |
| 562 | const DWARFUnitIndex &DWARFContext::getTUIndex() { |
| 563 | if (TUIndex) |
| 564 | return *TUIndex; |
| 565 | |
| 566 | DataExtractor TUIndexData(getTUIndexSection(), isLittleEndian(), 0); |
| 567 | |
David Blaikie | b073cb9 | 2015-12-02 06:21:34 +0000 | [diff] [blame] | 568 | TUIndex = llvm::make_unique<DWARFUnitIndex>(DW_SECT_TYPES); |
David Blaikie | 82641be | 2015-11-17 00:39:55 +0000 | [diff] [blame] | 569 | TUIndex->parse(TUIndexData); |
| 570 | return *TUIndex; |
| 571 | } |
| 572 | |
George Rimar | 4f82df5 | 2016-09-23 11:01:53 +0000 | [diff] [blame] | 573 | DWARFGdbIndex &DWARFContext::getGdbIndex() { |
| 574 | if (GdbIndex) |
| 575 | return *GdbIndex; |
| 576 | |
| 577 | DataExtractor GdbIndexData(getGdbIndexSection(), true /*LE*/, 0); |
| 578 | GdbIndex = llvm::make_unique<DWARFGdbIndex>(); |
| 579 | GdbIndex->parse(GdbIndexData); |
| 580 | return *GdbIndex; |
| 581 | } |
| 582 | |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 583 | const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() { |
| 584 | if (Abbrev) |
| 585 | return Abbrev.get(); |
| 586 | |
| 587 | DataExtractor abbrData(getAbbrevSection(), isLittleEndian(), 0); |
| 588 | |
| 589 | Abbrev.reset(new DWARFDebugAbbrev()); |
Alexey Samsonov | 4316df5 | 2014-04-25 21:10:56 +0000 | [diff] [blame] | 590 | Abbrev->extract(abbrData); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 591 | return Abbrev.get(); |
| 592 | } |
| 593 | |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 594 | const DWARFDebugAbbrev *DWARFContext::getDebugAbbrevDWO() { |
| 595 | if (AbbrevDWO) |
| 596 | return AbbrevDWO.get(); |
| 597 | |
| 598 | DataExtractor abbrData(getAbbrevDWOSection(), isLittleEndian(), 0); |
| 599 | AbbrevDWO.reset(new DWARFDebugAbbrev()); |
Alexey Samsonov | 4316df5 | 2014-04-25 21:10:56 +0000 | [diff] [blame] | 600 | AbbrevDWO->extract(abbrData); |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 601 | return AbbrevDWO.get(); |
| 602 | } |
| 603 | |
David Blaikie | 18e7350 | 2013-06-19 21:37:13 +0000 | [diff] [blame] | 604 | const DWARFDebugLoc *DWARFContext::getDebugLoc() { |
| 605 | if (Loc) |
| 606 | return Loc.get(); |
| 607 | |
David Blaikie | 1b5ee5d | 2013-09-23 17:42:01 +0000 | [diff] [blame] | 608 | DataExtractor LocData(getLocSection().Data, isLittleEndian(), 0); |
| 609 | Loc.reset(new DWARFDebugLoc(getLocSection().Relocs)); |
David Blaikie | 18e7350 | 2013-06-19 21:37:13 +0000 | [diff] [blame] | 610 | // assume all compile units have the same address byte size |
| 611 | if (getNumCompileUnits()) |
| 612 | Loc->parse(LocData, getCompileUnitAtIndex(0)->getAddressByteSize()); |
| 613 | return Loc.get(); |
| 614 | } |
| 615 | |
David Blaikie | 9c550ac | 2014-03-25 01:44:02 +0000 | [diff] [blame] | 616 | const DWARFDebugLocDWO *DWARFContext::getDebugLocDWO() { |
| 617 | if (LocDWO) |
| 618 | return LocDWO.get(); |
| 619 | |
| 620 | DataExtractor LocData(getLocDWOSection().Data, isLittleEndian(), 0); |
| 621 | LocDWO.reset(new DWARFDebugLocDWO()); |
| 622 | LocDWO->parse(LocData); |
| 623 | return LocDWO.get(); |
| 624 | } |
| 625 | |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 626 | const DWARFDebugAranges *DWARFContext::getDebugAranges() { |
| 627 | if (Aranges) |
| 628 | return Aranges.get(); |
| 629 | |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 630 | Aranges.reset(new DWARFDebugAranges()); |
Alexey Samsonov | a1694c1 | 2012-11-16 08:36:25 +0000 | [diff] [blame] | 631 | Aranges->generate(this); |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 632 | return Aranges.get(); |
| 633 | } |
| 634 | |
Eli Bendersky | fd08bc1 | 2013-02-05 23:30:58 +0000 | [diff] [blame] | 635 | const DWARFDebugFrame *DWARFContext::getDebugFrame() { |
| 636 | if (DebugFrame) |
| 637 | return DebugFrame.get(); |
| 638 | |
| 639 | // There's a "bug" in the DWARFv3 standard with respect to the target address |
| 640 | // size within debug frame sections. While DWARF is supposed to be independent |
| 641 | // of its container, FDEs have fields with size being "target address size", |
| 642 | // which isn't specified in DWARF in general. It's only specified for CUs, but |
| 643 | // .eh_frame can appear without a .debug_info section. Follow the example of |
| 644 | // other tools (libdwarf) and extract this from the container (ObjectFile |
| 645 | // provides this information). This problem is fixed in DWARFv4 |
| 646 | // See this dwarf-discuss discussion for more details: |
| 647 | // http://lists.dwarfstd.org/htdig.cgi/dwarf-discuss-dwarfstd.org/2011-December/001173.html |
| 648 | DataExtractor debugFrameData(getDebugFrameSection(), isLittleEndian(), |
| 649 | getAddressSize()); |
Igor Laevsky | 03a670c | 2016-01-26 15:09:42 +0000 | [diff] [blame] | 650 | DebugFrame.reset(new DWARFDebugFrame(false /* IsEH */)); |
| 651 | DebugFrame->parse(debugFrameData); |
| 652 | return DebugFrame.get(); |
| 653 | } |
| 654 | |
| 655 | const DWARFDebugFrame *DWARFContext::getEHFrame() { |
| 656 | if (EHFrame) |
| 657 | return EHFrame.get(); |
| 658 | |
| 659 | DataExtractor debugFrameData(getEHFrameSection(), isLittleEndian(), |
| 660 | getAddressSize()); |
| 661 | DebugFrame.reset(new DWARFDebugFrame(true /* IsEH */)); |
Eli Bendersky | fd08bc1 | 2013-02-05 23:30:58 +0000 | [diff] [blame] | 662 | DebugFrame->parse(debugFrameData); |
| 663 | return DebugFrame.get(); |
| 664 | } |
| 665 | |
Amjad Aboud | e59cc3e | 2015-11-12 09:38:54 +0000 | [diff] [blame] | 666 | const DWARFDebugMacro *DWARFContext::getDebugMacro() { |
| 667 | if (Macro) |
| 668 | return Macro.get(); |
| 669 | |
| 670 | DataExtractor MacinfoData(getMacinfoSection(), isLittleEndian(), 0); |
| 671 | Macro.reset(new DWARFDebugMacro()); |
| 672 | Macro->parse(MacinfoData); |
| 673 | return Macro.get(); |
| 674 | } |
| 675 | |
Eric Christopher | 494109b | 2012-10-16 23:46:25 +0000 | [diff] [blame] | 676 | const DWARFLineTable * |
Alexey Samsonov | 7a18c06 | 2015-05-19 21:54:32 +0000 | [diff] [blame] | 677 | DWARFContext::getLineTableForUnit(DWARFUnit *U) { |
Benjamin Kramer | 679e175 | 2011-09-15 20:43:18 +0000 | [diff] [blame] | 678 | if (!Line) |
David Blaikie | 1b5ee5d | 2013-09-23 17:42:01 +0000 | [diff] [blame] | 679 | Line.reset(new DWARFDebugLine(&getLineSection().Relocs)); |
David Blaikie | c4e2bed | 2015-11-17 21:08:05 +0000 | [diff] [blame] | 680 | |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 681 | auto UnitDIE = U->getUnitDIE(); |
| 682 | if (!UnitDIE) |
Alexey Samsonov | 7a18c06 | 2015-05-19 21:54:32 +0000 | [diff] [blame] | 683 | return nullptr; |
David Blaikie | c4e2bed | 2015-11-17 21:08:05 +0000 | [diff] [blame] | 684 | |
Greg Clayton | 97d2218 | 2017-01-13 21:08:18 +0000 | [diff] [blame] | 685 | auto Offset = toSectionOffset(UnitDIE.find(DW_AT_stmt_list)); |
Greg Clayton | 52fe1f6 | 2016-12-14 22:38:08 +0000 | [diff] [blame] | 686 | if (!Offset) |
Craig Topper | 2617dcc | 2014-04-15 06:32:26 +0000 | [diff] [blame] | 687 | return nullptr; // No line table for this compile unit. |
Benjamin Kramer | 5acab50 | 2011-09-15 02:12:05 +0000 | [diff] [blame] | 688 | |
Greg Clayton | 52fe1f6 | 2016-12-14 22:38:08 +0000 | [diff] [blame] | 689 | uint32_t stmtOffset = *Offset + U->getLineTableOffset(); |
Benjamin Kramer | 679e175 | 2011-09-15 20:43:18 +0000 | [diff] [blame] | 690 | // See if the line table is cached. |
Eric Christopher | 494109b | 2012-10-16 23:46:25 +0000 | [diff] [blame] | 691 | if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset)) |
Benjamin Kramer | 679e175 | 2011-09-15 20:43:18 +0000 | [diff] [blame] | 692 | return lt; |
| 693 | |
| 694 | // We have to parse it first. |
David Blaikie | c4e2bed | 2015-11-17 21:08:05 +0000 | [diff] [blame] | 695 | DataExtractor lineData(U->getLineSection(), isLittleEndian(), |
Alexey Samsonov | 7a18c06 | 2015-05-19 21:54:32 +0000 | [diff] [blame] | 696 | U->getAddressByteSize()); |
Benjamin Kramer | 679e175 | 2011-09-15 20:43:18 +0000 | [diff] [blame] | 697 | return Line->getOrParseLineTable(lineData, stmtOffset); |
Benjamin Kramer | 5acab50 | 2011-09-15 02:12:05 +0000 | [diff] [blame] | 698 | } |
| 699 | |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 700 | void DWARFContext::parseCompileUnits() { |
Alexey Samsonov | 8cd4c9d | 2014-10-08 00:07:53 +0000 | [diff] [blame] | 701 | CUs.parse(*this, getInfoSection()); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 702 | } |
Benjamin Kramer | 2602ca6 | 2011-09-15 20:43:22 +0000 | [diff] [blame] | 703 | |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 704 | void DWARFContext::parseTypeUnits() { |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 705 | if (!TUs.empty()) |
| 706 | return; |
| 707 | for (const auto &I : getTypesSections()) { |
Benjamin Kramer | f5e2fc4 | 2015-05-29 19:43:39 +0000 | [diff] [blame] | 708 | TUs.emplace_back(); |
Alexey Samsonov | 8cd4c9d | 2014-10-08 00:07:53 +0000 | [diff] [blame] | 709 | TUs.back().parse(*this, I.second); |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 710 | } |
| 711 | } |
| 712 | |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 713 | void DWARFContext::parseDWOCompileUnits() { |
Alexey Samsonov | 8cd4c9d | 2014-10-08 00:07:53 +0000 | [diff] [blame] | 714 | DWOCUs.parseDWO(*this, getInfoDWOSection()); |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 715 | } |
| 716 | |
David Blaikie | 92d9d62 | 2014-01-09 05:08:24 +0000 | [diff] [blame] | 717 | void DWARFContext::parseDWOTypeUnits() { |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 718 | if (!DWOTUs.empty()) |
| 719 | return; |
| 720 | for (const auto &I : getTypesDWOSections()) { |
Benjamin Kramer | f5e2fc4 | 2015-05-29 19:43:39 +0000 | [diff] [blame] | 721 | DWOTUs.emplace_back(); |
Alexey Samsonov | 8cd4c9d | 2014-10-08 00:07:53 +0000 | [diff] [blame] | 722 | DWOTUs.back().parseDWO(*this, I.second); |
David Blaikie | 92d9d62 | 2014-01-09 05:08:24 +0000 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 726 | DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 727 | parseCompileUnits(); |
Frederic Riss | 4e126a0 | 2014-09-15 07:50:27 +0000 | [diff] [blame] | 728 | return CUs.getUnitForOffset(Offset); |
Benjamin Kramer | 2602ca6 | 2011-09-15 20:43:22 +0000 | [diff] [blame] | 729 | } |
| 730 | |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 731 | DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { |
Benjamin Kramer | 112ec17 | 2011-09-15 21:59:13 +0000 | [diff] [blame] | 732 | // First, get the offset of the compile unit. |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 733 | uint32_t CUOffset = getDebugAranges()->findAddress(Address); |
Benjamin Kramer | 2602ca6 | 2011-09-15 20:43:22 +0000 | [diff] [blame] | 734 | // Retrieve the compile unit. |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 735 | return getCompileUnitForOffset(CUOffset); |
| 736 | } |
| 737 | |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 738 | static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU, |
| 739 | uint64_t Address, |
| 740 | FunctionNameKind Kind, |
| 741 | std::string &FunctionName, |
| 742 | uint32_t &StartLine) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 743 | // The address may correspond to instruction in some inlined function, |
| 744 | // so we have to build the chain of inlined functions and take the |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 745 | // name of the topmost function in it. |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 746 | SmallVector<DWARFDie, 4> InlinedChain; |
| 747 | CU->getInlinedChainForAddress(Address, InlinedChain); |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 748 | if (InlinedChain.empty()) |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 749 | return false; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 750 | |
| 751 | const DWARFDie &DIE = InlinedChain[0]; |
| 752 | bool FoundResult = false; |
| 753 | const char *Name = nullptr; |
| 754 | if (Kind != FunctionNameKind::None && (Name = DIE.getSubroutineName(Kind))) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 755 | FunctionName = Name; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 756 | FoundResult = true; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 757 | } |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 758 | if (auto DeclLineResult = DIE.getDeclLine()) { |
| 759 | StartLine = DeclLineResult; |
| 760 | FoundResult = true; |
| 761 | } |
| 762 | |
| 763 | return FoundResult; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 764 | } |
| 765 | |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 766 | DILineInfo DWARFContext::getLineInfoForAddress(uint64_t Address, |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 767 | DILineInfoSpecifier Spec) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 768 | DILineInfo Result; |
| 769 | |
Alexey Samsonov | 45be793 | 2012-08-30 07:49:50 +0000 | [diff] [blame] | 770 | DWARFCompileUnit *CU = getCompileUnitForAddress(Address); |
| 771 | if (!CU) |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 772 | return Result; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 773 | getFunctionNameAndStartLineForAddress(CU, Address, Spec.FNKind, |
| 774 | Result.FunctionName, |
| 775 | Result.StartLine); |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 776 | if (Spec.FLIKind != FileLineInfoKind::None) { |
Frederic Riss | 101b5e2 | 2014-09-19 15:11:51 +0000 | [diff] [blame] | 777 | if (const DWARFLineTable *LineTable = getLineTableForUnit(CU)) |
| 778 | LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(), |
| 779 | Spec.FLIKind, Result); |
Alexey Samsonov | f4462fa | 2012-07-02 05:54:45 +0000 | [diff] [blame] | 780 | } |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 781 | return Result; |
Benjamin Kramer | 2602ca6 | 2011-09-15 20:43:22 +0000 | [diff] [blame] | 782 | } |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 783 | |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 784 | DILineInfoTable |
| 785 | DWARFContext::getLineInfoForAddressRange(uint64_t Address, uint64_t Size, |
| 786 | DILineInfoSpecifier Spec) { |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 787 | DILineInfoTable Lines; |
| 788 | DWARFCompileUnit *CU = getCompileUnitForAddress(Address); |
| 789 | if (!CU) |
| 790 | return Lines; |
| 791 | |
| 792 | std::string FunctionName = "<invalid>"; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 793 | uint32_t StartLine = 0; |
| 794 | getFunctionNameAndStartLineForAddress(CU, Address, Spec.FNKind, FunctionName, |
| 795 | StartLine); |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 796 | |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 797 | // If the Specifier says we don't need FileLineInfo, just |
| 798 | // return the top-most function at the starting address. |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 799 | if (Spec.FLIKind == FileLineInfoKind::None) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 800 | DILineInfo Result; |
| 801 | Result.FunctionName = FunctionName; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 802 | Result.StartLine = StartLine; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 803 | Lines.push_back(std::make_pair(Address, Result)); |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 804 | return Lines; |
| 805 | } |
| 806 | |
Frederic Riss | ec8a5ba | 2014-09-04 06:14:40 +0000 | [diff] [blame] | 807 | const DWARFLineTable *LineTable = getLineTableForUnit(CU); |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 808 | |
| 809 | // Get the index of row we're looking for in the line table. |
| 810 | std::vector<uint32_t> RowVector; |
| 811 | if (!LineTable->lookupAddressRange(Address, Size, RowVector)) |
| 812 | return Lines; |
| 813 | |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 814 | for (uint32_t RowIndex : RowVector) { |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 815 | // Take file number and line/column from the row. |
| 816 | const DWARFDebugLine::Row &Row = LineTable->Rows[RowIndex]; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 817 | DILineInfo Result; |
Frederic Riss | 101b5e2 | 2014-09-19 15:11:51 +0000 | [diff] [blame] | 818 | LineTable->getFileNameByIndex(Row.File, CU->getCompilationDir(), |
| 819 | Spec.FLIKind, Result.FileName); |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 820 | Result.FunctionName = FunctionName; |
| 821 | Result.Line = Row.Line; |
| 822 | Result.Column = Row.Column; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 823 | Result.StartLine = StartLine; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 824 | Lines.push_back(std::make_pair(Row.Address, Result)); |
Andrew Kaylor | 9a8ff81 | 2013-01-26 00:28:05 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | return Lines; |
| 828 | } |
| 829 | |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 830 | DIInliningInfo |
| 831 | DWARFContext::getInliningInfoForAddress(uint64_t Address, |
| 832 | DILineInfoSpecifier Spec) { |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 833 | DIInliningInfo InliningInfo; |
| 834 | |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 835 | DWARFCompileUnit *CU = getCompileUnitForAddress(Address); |
| 836 | if (!CU) |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 837 | return InliningInfo; |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 838 | |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 839 | const DWARFLineTable *LineTable = nullptr; |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 840 | SmallVector<DWARFDie, 4> InlinedChain; |
| 841 | CU->getInlinedChainForAddress(Address, InlinedChain); |
| 842 | if (InlinedChain.size() == 0) { |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 843 | // If there is no DIE for address (e.g. it is in unavailable .dwo file), |
| 844 | // try to at least get file/line info from symbol table. |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 845 | if (Spec.FLIKind != FileLineInfoKind::None) { |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 846 | DILineInfo Frame; |
Frederic Riss | ec8a5ba | 2014-09-04 06:14:40 +0000 | [diff] [blame] | 847 | LineTable = getLineTableForUnit(CU); |
Frederic Riss | 101b5e2 | 2014-09-19 15:11:51 +0000 | [diff] [blame] | 848 | if (LineTable && |
| 849 | LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(), |
| 850 | Spec.FLIKind, Frame)) |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 851 | InliningInfo.addFrame(Frame); |
Alexey Samsonov | 5c39fdf | 2014-04-18 22:22:44 +0000 | [diff] [blame] | 852 | } |
| 853 | return InliningInfo; |
| 854 | } |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 855 | |
Dehao Chen | ef700d5 | 2017-04-17 20:10:39 +0000 | [diff] [blame] | 856 | uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0; |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 857 | for (uint32_t i = 0, n = InlinedChain.size(); i != n; i++) { |
| 858 | DWARFDie &FunctionDIE = InlinedChain[i]; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 859 | DILineInfo Frame; |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 860 | // Get function name if necessary. |
Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 861 | if (const char *Name = FunctionDIE.getSubroutineName(Spec.FNKind)) |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 862 | Frame.FunctionName = Name; |
David Blaikie | efc4eba | 2017-02-06 20:19:02 +0000 | [diff] [blame] | 863 | if (auto DeclLineResult = FunctionDIE.getDeclLine()) |
| 864 | Frame.StartLine = DeclLineResult; |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 865 | if (Spec.FLIKind != FileLineInfoKind::None) { |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 866 | if (i == 0) { |
| 867 | // For the topmost frame, initialize the line table of this |
| 868 | // compile unit and fetch file/line info from it. |
Frederic Riss | ec8a5ba | 2014-09-04 06:14:40 +0000 | [diff] [blame] | 869 | LineTable = getLineTableForUnit(CU); |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 870 | // For the topmost routine, get file/line info from line table. |
Frederic Riss | 101b5e2 | 2014-09-19 15:11:51 +0000 | [diff] [blame] | 871 | if (LineTable) |
| 872 | LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(), |
| 873 | Spec.FLIKind, Frame); |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 874 | } else { |
| 875 | // Otherwise, use call file, call line and call column from |
| 876 | // previous DIE in inlined chain. |
Frederic Riss | 101b5e2 | 2014-09-19 15:11:51 +0000 | [diff] [blame] | 877 | if (LineTable) |
| 878 | LineTable->getFileNameByIndex(CallFile, CU->getCompilationDir(), |
| 879 | Spec.FLIKind, Frame.FileName); |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 880 | Frame.Line = CallLine; |
| 881 | Frame.Column = CallColumn; |
Dehao Chen | ef700d5 | 2017-04-17 20:10:39 +0000 | [diff] [blame] | 882 | Frame.Discriminator = CallDiscriminator; |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 883 | } |
| 884 | // Get call file/line/column of a current DIE. |
| 885 | if (i + 1 < n) { |
Dehao Chen | ef700d5 | 2017-04-17 20:10:39 +0000 | [diff] [blame] | 886 | FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn, |
| 887 | CallDiscriminator); |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 888 | } |
| 889 | } |
Alexey Samsonov | c942e6b | 2012-09-04 08:12:33 +0000 | [diff] [blame] | 890 | InliningInfo.addFrame(Frame); |
| 891 | } |
| 892 | return InliningInfo; |
| 893 | } |
| 894 | |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 895 | static Error createError(const Twine &Reason, llvm::Error E) { |
| 896 | return make_error<StringError>(Reason + toString(std::move(E)), |
| 897 | inconvertibleErrorCode()); |
| 898 | } |
| 899 | |
| 900 | /// Returns the address of symbol relocation used against. Used for futher |
| 901 | /// relocations computation. Symbol's section load address is taken in account if |
| 902 | /// LoadedObjectInfo interface is provided. |
| 903 | static Expected<uint64_t> getSymbolAddress(const object::ObjectFile &Obj, |
| 904 | const RelocationRef &Reloc, |
| 905 | const LoadedObjectInfo *L) { |
| 906 | uint64_t Ret = 0; |
| 907 | object::section_iterator RSec = Obj.section_end(); |
| 908 | object::symbol_iterator Sym = Reloc.getSymbol(); |
| 909 | |
| 910 | // First calculate the address of the symbol or section as it appears |
| 911 | // in the object file |
| 912 | if (Sym != Obj.symbol_end()) { |
| 913 | Expected<uint64_t> SymAddrOrErr = Sym->getAddress(); |
| 914 | if (!SymAddrOrErr) |
| 915 | return createError("error: failed to compute symbol address: ", |
| 916 | SymAddrOrErr.takeError()); |
| 917 | |
| 918 | // Also remember what section this symbol is in for later |
| 919 | auto SectOrErr = Sym->getSection(); |
| 920 | if (!SectOrErr) |
| 921 | return createError("error: failed to get symbol section: ", |
| 922 | SectOrErr.takeError()); |
| 923 | |
| 924 | RSec = *SectOrErr; |
| 925 | Ret = *SymAddrOrErr; |
| 926 | } else if (auto *MObj = dyn_cast<MachOObjectFile>(&Obj)) { |
| 927 | RSec = MObj->getRelocationSection(Reloc.getRawDataRefImpl()); |
| 928 | Ret = RSec->getAddress(); |
| 929 | } |
| 930 | |
| 931 | // If we are given load addresses for the sections, we need to adjust: |
| 932 | // SymAddr = (Address of Symbol Or Section in File) - |
| 933 | // (Address of Section in File) + |
| 934 | // (Load Address of Section) |
| 935 | // RSec is now either the section being targeted or the section |
| 936 | // containing the symbol being targeted. In either case, |
| 937 | // we need to perform the same computation. |
| 938 | if (L && RSec != Obj.section_end()) |
| 939 | if (uint64_t SectionLoadAddress = L->getSectionLoadAddress(*RSec)) |
| 940 | Ret += SectionLoadAddress - RSec->getAddress(); |
| 941 | return Ret; |
| 942 | } |
| 943 | |
| 944 | static bool isRelocScattered(const object::ObjectFile &Obj, |
| 945 | const RelocationRef &Reloc) { |
George Rimar | d4998b0 | 2017-04-13 09:52:50 +0000 | [diff] [blame] | 946 | const MachOObjectFile *MachObj = dyn_cast<MachOObjectFile>(&Obj); |
| 947 | if (!MachObj) |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 948 | return false; |
| 949 | // MachO also has relocations that point to sections and |
| 950 | // scattered relocations. |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 951 | auto RelocInfo = MachObj->getRelocation(Reloc.getRawDataRefImpl()); |
| 952 | return MachObj->isRelocationScattered(RelocInfo); |
| 953 | } |
| 954 | |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 955 | DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj, |
| 956 | const LoadedObjectInfo *L) |
Rafael Espindola | a04bb5b | 2014-07-31 20:19:36 +0000 | [diff] [blame] | 957 | : IsLittleEndian(Obj.isLittleEndian()), |
| 958 | AddressSize(Obj.getBytesInAddress()) { |
| 959 | for (const SectionRef &Section : Obj.sections()) { |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 960 | StringRef name; |
Alexey Samsonov | 063eb3f | 2014-03-13 13:52:54 +0000 | [diff] [blame] | 961 | Section.getName(name); |
David Majnemer | dac3985 | 2014-09-26 22:32:16 +0000 | [diff] [blame] | 962 | // Skip BSS and Virtual sections, they aren't interesting. |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 963 | bool IsBSS = Section.isBSS(); |
David Majnemer | dac3985 | 2014-09-26 22:32:16 +0000 | [diff] [blame] | 964 | if (IsBSS) |
| 965 | continue; |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 966 | bool IsVirtual = Section.isVirtual(); |
David Majnemer | dac3985 | 2014-09-26 22:32:16 +0000 | [diff] [blame] | 967 | if (IsVirtual) |
| 968 | continue; |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 969 | StringRef data; |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 970 | |
Lang Hames | 2e88f4f | 2015-07-28 17:52:11 +0000 | [diff] [blame] | 971 | section_iterator RelocatedSection = Section.getRelocatedSection(); |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 972 | // Try to obtain an already relocated version of this section. |
| 973 | // Else use the unrelocated section from the object file. We'll have to |
| 974 | // apply relocations ourselves later. |
Lang Hames | 2e88f4f | 2015-07-28 17:52:11 +0000 | [diff] [blame] | 975 | if (!L || !L->getLoadedSectionContents(*RelocatedSection,data)) |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 976 | Section.getContents(data); |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 977 | |
George Rimar | 4bf3083 | 2017-01-11 15:26:41 +0000 | [diff] [blame] | 978 | if (Decompressor::isCompressed(Section)) { |
| 979 | Expected<Decompressor> Decompressor = |
| 980 | Decompressor::create(name, data, IsLittleEndian, AddressSize == 8); |
| 981 | if (!Decompressor) |
| 982 | continue; |
George Rimar | 401e4e5 | 2016-05-24 12:48:46 +0000 | [diff] [blame] | 983 | SmallString<32> Out; |
George Rimar | 4bf3083 | 2017-01-11 15:26:41 +0000 | [diff] [blame] | 984 | if (auto Err = Decompressor->decompress(Out)) |
Alexey Samsonov | 068fc8a | 2013-04-23 10:17:34 +0000 | [diff] [blame] | 985 | continue; |
George Rimar | 401e4e5 | 2016-05-24 12:48:46 +0000 | [diff] [blame] | 986 | UncompressedSections.emplace_back(std::move(Out)); |
David Blaikie | a505f24 | 2014-04-05 21:26:44 +0000 | [diff] [blame] | 987 | data = UncompressedSections.back(); |
Alexey Samsonov | 068fc8a | 2013-04-23 10:17:34 +0000 | [diff] [blame] | 988 | } |
| 989 | |
George Rimar | 4bf3083 | 2017-01-11 15:26:41 +0000 | [diff] [blame] | 990 | // Compressed sections names in GNU style starts from ".z", |
| 991 | // at this point section is decompressed and we drop compression prefix. |
| 992 | name = name.substr( |
| 993 | name.find_first_not_of("._z")); // Skip ".", "z" and "_" prefixes. |
| 994 | |
Chris Bieneman | 2e752db | 2017-01-20 19:03:14 +0000 | [diff] [blame] | 995 | if (StringRef *SectionData = MapSectionToMember(name)) { |
Alexey Samsonov | 063eb3f | 2014-03-13 13:52:54 +0000 | [diff] [blame] | 996 | *SectionData = data; |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 997 | if (name == "debug_ranges") { |
| 998 | // FIXME: Use the other dwo range section when we emit it. |
George Rimar | ca53211 | 2017-04-24 10:19:45 +0000 | [diff] [blame] | 999 | RangeDWOSection.Data = data; |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 1000 | } |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 1001 | } else if (name == "debug_types") { |
David Blaikie | 427e435 | 2013-09-23 23:39:55 +0000 | [diff] [blame] | 1002 | // Find debug_types data by section rather than name as there are |
| 1003 | // multiple, comdat grouped, debug_types sections. |
Alexey Samsonov | 063eb3f | 2014-03-13 13:52:54 +0000 | [diff] [blame] | 1004 | TypesSections[Section].Data = data; |
David Blaikie | 92d9d62 | 2014-01-09 05:08:24 +0000 | [diff] [blame] | 1005 | } else if (name == "debug_types.dwo") { |
Alexey Samsonov | 063eb3f | 2014-03-13 13:52:54 +0000 | [diff] [blame] | 1006 | TypesDWOSections[Section].Data = data; |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 1007 | } |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1008 | |
Rafael Espindola | a04bb5b | 2014-07-31 20:19:36 +0000 | [diff] [blame] | 1009 | if (RelocatedSection == Obj.section_end()) |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 1010 | continue; |
| 1011 | |
| 1012 | StringRef RelSecName; |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 1013 | StringRef RelSecData; |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 1014 | RelocatedSection->getName(RelSecName); |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 1015 | |
| 1016 | // If the section we're relocating was relocated already by the JIT, |
| 1017 | // then we used the relocated version above, so we do not need to process |
| 1018 | // relocations for it now. |
Lang Hames | 2e88f4f | 2015-07-28 17:52:11 +0000 | [diff] [blame] | 1019 | if (L && L->getLoadedSectionContents(*RelocatedSection,RelSecData)) |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 1020 | continue; |
| 1021 | |
Frederic Riss | 7bb1226 | 2015-08-23 04:44:21 +0000 | [diff] [blame] | 1022 | // In Mach-o files, the relocations do not need to be applied if |
| 1023 | // there is no load offset to apply. The value read at the |
| 1024 | // relocation point already factors in the section address |
| 1025 | // (actually applying the relocations will produce wrong results |
| 1026 | // as the section address will be added twice). |
Craig Topper | 66059c9 | 2015-11-18 07:07:59 +0000 | [diff] [blame] | 1027 | if (!L && isa<MachOObjectFile>(&Obj)) |
Frederic Riss | 7bb1226 | 2015-08-23 04:44:21 +0000 | [diff] [blame] | 1028 | continue; |
| 1029 | |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 1030 | RelSecName = RelSecName.substr( |
| 1031 | RelSecName.find_first_not_of("._")); // Skip . and _ prefixes. |
| 1032 | |
Andrew Kaylor | d55d701 | 2013-01-25 22:50:58 +0000 | [diff] [blame] | 1033 | // TODO: Add support for relocations in other sections as needed. |
| 1034 | // Record relocations for the debug_info and debug_line sections. |
Rafael Espindola | 4f60a38 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 1035 | RelocAddrMap *Map = StringSwitch<RelocAddrMap*>(RelSecName) |
David Blaikie | 1b5ee5d | 2013-09-23 17:42:01 +0000 | [diff] [blame] | 1036 | .Case("debug_info", &InfoSection.Relocs) |
| 1037 | .Case("debug_loc", &LocSection.Relocs) |
| 1038 | .Case("debug_info.dwo", &InfoDWOSection.Relocs) |
| 1039 | .Case("debug_line", &LineSection.Relocs) |
George Rimar | ca53211 | 2017-04-24 10:19:45 +0000 | [diff] [blame] | 1040 | .Case("debug_ranges", &RangeSection.Relocs) |
Frederic Riss | 7c50047 | 2014-11-14 19:30:08 +0000 | [diff] [blame] | 1041 | .Case("apple_names", &AppleNamesSection.Relocs) |
| 1042 | .Case("apple_types", &AppleTypesSection.Relocs) |
| 1043 | .Case("apple_namespaces", &AppleNamespacesSection.Relocs) |
| 1044 | .Case("apple_namespac", &AppleNamespacesSection.Relocs) |
| 1045 | .Case("apple_objc", &AppleObjCSection.Relocs) |
Craig Topper | 2617dcc | 2014-04-15 06:32:26 +0000 | [diff] [blame] | 1046 | .Default(nullptr); |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 1047 | if (!Map) { |
David Blaikie | 427e435 | 2013-09-23 23:39:55 +0000 | [diff] [blame] | 1048 | // Find debug_types relocs by section rather than name as there are |
| 1049 | // multiple, comdat grouped, debug_types sections. |
David Blaikie | 92d9d62 | 2014-01-09 05:08:24 +0000 | [diff] [blame] | 1050 | if (RelSecName == "debug_types") |
| 1051 | Map = &TypesSections[*RelocatedSection].Relocs; |
| 1052 | else if (RelSecName == "debug_types.dwo") |
| 1053 | Map = &TypesDWOSections[*RelocatedSection].Relocs; |
| 1054 | else |
| 1055 | continue; |
David Blaikie | 03c089c | 2013-09-23 22:44:47 +0000 | [diff] [blame] | 1056 | } |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1057 | |
Alexey Samsonov | 063eb3f | 2014-03-13 13:52:54 +0000 | [diff] [blame] | 1058 | if (Section.relocation_begin() != Section.relocation_end()) { |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 1059 | uint64_t SectionSize = RelocatedSection->getSize(); |
Alexey Samsonov | aa4d295 | 2014-03-14 14:22:49 +0000 | [diff] [blame] | 1060 | for (const RelocationRef &Reloc : Section.relocations()) { |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 1061 | // FIXME: it's not clear how to correctly handle scattered |
| 1062 | // relocations. |
| 1063 | if (isRelocScattered(Obj, Reloc)) |
| 1064 | continue; |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 1065 | |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 1066 | Expected<uint64_t> SymAddrOrErr = getSymbolAddress(Obj, Reloc, L); |
| 1067 | if (!SymAddrOrErr) { |
Krasimir Georgiev | 4ed589d | 2017-04-12 11:33:26 +0000 | [diff] [blame] | 1068 | errs() << toString(SymAddrOrErr.takeError()) << '\n'; |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 1069 | continue; |
Keno Fischer | c780e8e | 2015-05-21 21:24:32 +0000 | [diff] [blame] | 1070 | } |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1071 | |
Eric Christopher | 47e079d | 2014-10-06 06:55:55 +0000 | [diff] [blame] | 1072 | object::RelocVisitor V(Obj); |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 1073 | object::RelocToApply R(V.visit(Reloc.getType(), Reloc, *SymAddrOrErr)); |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1074 | if (V.error()) { |
| 1075 | SmallString<32> Name; |
Rafael Espindola | 41bb432 | 2015-06-30 04:08:37 +0000 | [diff] [blame] | 1076 | Reloc.getTypeName(Name); |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1077 | errs() << "error: failed to compute relocation: " |
| 1078 | << Name << "\n"; |
| 1079 | continue; |
| 1080 | } |
George Rimar | 702dac6 | 2017-04-12 08:59:15 +0000 | [diff] [blame] | 1081 | uint64_t Address = Reloc.getOffset(); |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1082 | if (Address + R.Width > SectionSize) { |
| 1083 | errs() << "error: " << R.Width << "-byte relocation starting " |
| 1084 | << Address << " bytes into section " << name << " which is " |
| 1085 | << SectionSize << " bytes long.\n"; |
| 1086 | continue; |
| 1087 | } |
| 1088 | if (R.Width > 8) { |
| 1089 | errs() << "error: can't handle a relocation of more than 8 bytes at " |
| 1090 | "a time.\n"; |
| 1091 | continue; |
| 1092 | } |
| 1093 | DEBUG(dbgs() << "Writing " << format("%p", R.Value) |
| 1094 | << " at " << format("%p", Address) |
| 1095 | << " with width " << format("%d", R.Width) |
| 1096 | << "\n"); |
Eric Christopher | da4b219 | 2013-01-02 23:52:13 +0000 | [diff] [blame] | 1097 | Map->insert(std::make_pair(Address, std::make_pair(R.Width, R.Value))); |
Eric Christopher | 7370b55 | 2012-11-12 21:40:38 +0000 | [diff] [blame] | 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | } |
| 1102 | |
Chris Bieneman | 2e752db | 2017-01-20 19:03:14 +0000 | [diff] [blame] | 1103 | DWARFContextInMemory::DWARFContextInMemory( |
| 1104 | const StringMap<std::unique_ptr<MemoryBuffer>> &Sections, uint8_t AddrSize, |
| 1105 | bool isLittleEndian) |
| 1106 | : IsLittleEndian(isLittleEndian), AddressSize(AddrSize) { |
| 1107 | for (const auto &SecIt : Sections) { |
| 1108 | if (StringRef *SectionData = MapSectionToMember(SecIt.first())) |
| 1109 | *SectionData = SecIt.second->getBuffer(); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | StringRef *DWARFContextInMemory::MapSectionToMember(StringRef Name) { |
| 1114 | return StringSwitch<StringRef *>(Name) |
| 1115 | .Case("debug_info", &InfoSection.Data) |
| 1116 | .Case("debug_abbrev", &AbbrevSection) |
| 1117 | .Case("debug_loc", &LocSection.Data) |
| 1118 | .Case("debug_line", &LineSection.Data) |
| 1119 | .Case("debug_aranges", &ARangeSection) |
| 1120 | .Case("debug_frame", &DebugFrameSection) |
| 1121 | .Case("eh_frame", &EHFrameSection) |
| 1122 | .Case("debug_str", &StringSection) |
George Rimar | ca53211 | 2017-04-24 10:19:45 +0000 | [diff] [blame] | 1123 | .Case("debug_ranges", &RangeSection.Data) |
Chris Bieneman | 2e752db | 2017-01-20 19:03:14 +0000 | [diff] [blame] | 1124 | .Case("debug_macinfo", &MacinfoSection) |
| 1125 | .Case("debug_pubnames", &PubNamesSection) |
| 1126 | .Case("debug_pubtypes", &PubTypesSection) |
| 1127 | .Case("debug_gnu_pubnames", &GnuPubNamesSection) |
| 1128 | .Case("debug_gnu_pubtypes", &GnuPubTypesSection) |
| 1129 | .Case("debug_info.dwo", &InfoDWOSection.Data) |
| 1130 | .Case("debug_abbrev.dwo", &AbbrevDWOSection) |
| 1131 | .Case("debug_loc.dwo", &LocDWOSection.Data) |
| 1132 | .Case("debug_line.dwo", &LineDWOSection.Data) |
| 1133 | .Case("debug_str.dwo", &StringDWOSection) |
| 1134 | .Case("debug_str_offsets.dwo", &StringOffsetDWOSection) |
| 1135 | .Case("debug_addr", &AddrSection) |
| 1136 | .Case("apple_names", &AppleNamesSection.Data) |
| 1137 | .Case("apple_types", &AppleTypesSection.Data) |
| 1138 | .Case("apple_namespaces", &AppleNamespacesSection.Data) |
| 1139 | .Case("apple_namespac", &AppleNamespacesSection.Data) |
| 1140 | .Case("apple_objc", &AppleObjCSection.Data) |
| 1141 | .Case("debug_cu_index", &CUIndexSection) |
| 1142 | .Case("debug_tu_index", &TUIndexSection) |
| 1143 | .Case("gdb_index", &GdbIndexSection) |
| 1144 | // Any more debug info sections go here. |
| 1145 | .Default(nullptr); |
| 1146 | } |
| 1147 | |
Eugene Zelenko | 28db7e6 | 2017-03-01 01:14:23 +0000 | [diff] [blame] | 1148 | void DWARFContextInMemory::anchor() {} |