Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 1 | //===-- LLVMSymbolize.cpp -------------------------------------------------===// |
| 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 | // |
| 10 | // Implementation for LLVM symbolization library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "LLVMSymbolize.h" |
Alexey Samsonov | dd71c5b | 2013-03-19 15:33:18 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/STLExtras.h" |
Alexey Samsonov | a591ae6 | 2013-08-26 18:12:03 +0000 | [diff] [blame] | 16 | #include "llvm/Config/config.h" |
Zachary Turner | 6489d7b | 2015-04-23 17:37:47 +0000 | [diff] [blame] | 17 | #include "llvm/DebugInfo/DWARF/DWARFContext.h" |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 18 | #include "llvm/DebugInfo/PDB/PDB.h" |
| 19 | #include "llvm/DebugInfo/PDB/PDBContext.h" |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 20 | #include "llvm/Object/ELFObjectFile.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 21 | #include "llvm/Object/MachO.h" |
| 22 | #include "llvm/Support/Casting.h" |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Compression.h" |
| 24 | #include "llvm/Support/DataExtractor.h" |
Rafael Espindola | 2a826e4 | 2014-06-13 17:20:48 +0000 | [diff] [blame] | 25 | #include "llvm/Support/Errc.h" |
Alexey Samsonov | 5239d58 | 2013-06-04 07:57:38 +0000 | [diff] [blame] | 26 | #include "llvm/Support/FileSystem.h" |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 27 | #include "llvm/Support/MemoryBuffer.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 28 | #include "llvm/Support/Path.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 29 | #include <sstream> |
Alexey Samsonov | a591ae6 | 2013-08-26 18:12:03 +0000 | [diff] [blame] | 30 | #include <stdlib.h> |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 31 | |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 32 | #if defined(_MSC_VER) |
| 33 | #include <Windows.h> |
| 34 | #include <DbgHelp.h> |
| 35 | #endif |
| 36 | |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 37 | namespace llvm { |
| 38 | namespace symbolize { |
| 39 | |
Rafael Espindola | 4453e4294 | 2014-06-13 03:07:50 +0000 | [diff] [blame] | 40 | static bool error(std::error_code ec) { |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 41 | if (!ec) |
| 42 | return false; |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 43 | errs() << "LLVMSymbolizer: error reading file: " << ec.message() << ".\n"; |
| 44 | return true; |
| 45 | } |
| 46 | |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 47 | static DILineInfoSpecifier |
| 48 | getDILineInfoSpecifier(const LLVMSymbolizer::Options &Opts) { |
| 49 | return DILineInfoSpecifier( |
| 50 | DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 51 | Opts.PrintFunctions); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 54 | ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx) |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 55 | : Module(Obj), DebugInfoContext(DICtx) { |
Jay Foad | 52695da | 2014-11-07 09:08:39 +0000 | [diff] [blame] | 56 | std::unique_ptr<DataExtractor> OpdExtractor; |
| 57 | uint64_t OpdAddress = 0; |
| 58 | // Find the .opd (function descriptor) section if any, for big-endian |
| 59 | // PowerPC64 ELF. |
| 60 | if (Module->getArch() == Triple::ppc64) { |
| 61 | for (section_iterator Section : Module->sections()) { |
| 62 | StringRef Name; |
| 63 | if (!error(Section->getName(Name)) && Name == ".opd") { |
| 64 | StringRef Data; |
| 65 | if (!error(Section->getContents(Data))) { |
| 66 | OpdExtractor.reset(new DataExtractor(Data, Module->isLittleEndian(), |
| 67 | Module->getBytesInAddress())); |
| 68 | OpdAddress = Section->getAddress(); |
| 69 | } |
| 70 | break; |
| 71 | } |
| 72 | } |
| 73 | } |
Alexey Samsonov | 464d2e4 | 2014-03-17 07:28:19 +0000 | [diff] [blame] | 74 | for (const SymbolRef &Symbol : Module->symbols()) { |
Jay Foad | 52695da | 2014-11-07 09:08:39 +0000 | [diff] [blame] | 75 | addSymbol(Symbol, OpdExtractor.get(), OpdAddress); |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 76 | } |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 77 | bool NoSymbolTable = (Module->symbol_begin() == Module->symbol_end()); |
| 78 | if (NoSymbolTable && Module->isELF()) { |
| 79 | // Fallback to dynamic symbol table, if regular symbol table is stripped. |
| 80 | std::pair<symbol_iterator, symbol_iterator> IDyn = |
| 81 | getELFDynamicSymbolIterators(Module); |
| 82 | for (symbol_iterator si = IDyn.first, se = IDyn.second; si != se; ++si) { |
Jay Foad | 52695da | 2014-11-07 09:08:39 +0000 | [diff] [blame] | 83 | addSymbol(*si, OpdExtractor.get(), OpdAddress); |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
Jay Foad | 52695da | 2014-11-07 09:08:39 +0000 | [diff] [blame] | 88 | void ModuleInfo::addSymbol(const SymbolRef &Symbol, DataExtractor *OpdExtractor, |
| 89 | uint64_t OpdAddress) { |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 90 | SymbolRef::Type SymbolType; |
Alexey Samsonov | 464d2e4 | 2014-03-17 07:28:19 +0000 | [diff] [blame] | 91 | if (error(Symbol.getType(SymbolType))) |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 92 | return; |
Alexey Samsonov | 464d2e4 | 2014-03-17 07:28:19 +0000 | [diff] [blame] | 93 | if (SymbolType != SymbolRef::ST_Function && SymbolType != SymbolRef::ST_Data) |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 94 | return; |
| 95 | uint64_t SymbolAddress; |
Alexey Samsonov | 464d2e4 | 2014-03-17 07:28:19 +0000 | [diff] [blame] | 96 | if (error(Symbol.getAddress(SymbolAddress)) || |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 97 | SymbolAddress == UnknownAddressOrSize) |
| 98 | return; |
Jay Foad | 52695da | 2014-11-07 09:08:39 +0000 | [diff] [blame] | 99 | if (OpdExtractor) { |
| 100 | // For big-endian PowerPC64 ELF, symbols in the .opd section refer to |
| 101 | // function descriptors. The first word of the descriptor is a pointer to |
| 102 | // the function's code. |
| 103 | // For the purposes of symbolization, pretend the symbol's address is that |
| 104 | // of the function's code, not the descriptor. |
| 105 | uint64_t OpdOffset = SymbolAddress - OpdAddress; |
| 106 | uint32_t OpdOffset32 = OpdOffset; |
| 107 | if (OpdOffset == OpdOffset32 && |
| 108 | OpdExtractor->isValidOffsetForAddress(OpdOffset32)) |
| 109 | SymbolAddress = OpdExtractor->getAddress(&OpdOffset32); |
| 110 | } |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 111 | uint64_t SymbolSize; |
| 112 | // Getting symbol size is linear for Mach-O files, so assume that symbol |
| 113 | // occupies the memory range up to the following symbol. |
| 114 | if (isa<MachOObjectFile>(Module)) |
| 115 | SymbolSize = 0; |
Rafael Espindola | 5eb02e4 | 2015-06-01 00:27:26 +0000 | [diff] [blame] | 116 | else { |
| 117 | SymbolSize = Symbol.getSize(); |
| 118 | if (SymbolSize == UnknownAddressOrSize) |
| 119 | return; |
| 120 | } |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 121 | StringRef SymbolName; |
Alexey Samsonov | 464d2e4 | 2014-03-17 07:28:19 +0000 | [diff] [blame] | 122 | if (error(Symbol.getName(SymbolName))) |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 123 | return; |
| 124 | // Mach-O symbol table names have leading underscore, skip it. |
| 125 | if (Module->isMachO() && SymbolName.size() > 0 && SymbolName[0] == '_') |
| 126 | SymbolName = SymbolName.drop_front(); |
| 127 | // FIXME: If a function has alias, there are two entries in symbol table |
| 128 | // with same address size. Make sure we choose the correct one. |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 129 | auto &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects; |
Alexey Samsonov | a5f0768 | 2014-02-26 13:10:01 +0000 | [diff] [blame] | 130 | SymbolDesc SD = { SymbolAddress, SymbolSize }; |
| 131 | M.insert(std::make_pair(SD, SymbolName)); |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | bool ModuleInfo::getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address, |
| 135 | std::string &Name, uint64_t &Addr, |
| 136 | uint64_t &Size) const { |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 137 | const auto &SymbolMap = Type == SymbolRef::ST_Function ? Functions : Objects; |
| 138 | if (SymbolMap.empty()) |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 139 | return false; |
Alexey Samsonov | 5239d58 | 2013-06-04 07:57:38 +0000 | [diff] [blame] | 140 | SymbolDesc SD = { Address, Address }; |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 141 | auto SymbolIterator = SymbolMap.upper_bound(SD); |
| 142 | if (SymbolIterator == SymbolMap.begin()) |
Alexey Samsonov | 35c987d | 2013-06-07 15:25:27 +0000 | [diff] [blame] | 143 | return false; |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 144 | --SymbolIterator; |
| 145 | if (SymbolIterator->first.Size != 0 && |
| 146 | SymbolIterator->first.Addr + SymbolIterator->first.Size <= Address) |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 147 | return false; |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 148 | Name = SymbolIterator->second.str(); |
| 149 | Addr = SymbolIterator->first.Addr; |
| 150 | Size = SymbolIterator->first.Size; |
Dmitry Vyukov | ef8fb72 | 2013-02-14 13:06:18 +0000 | [diff] [blame] | 151 | return true; |
| 152 | } |
| 153 | |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 154 | DILineInfo ModuleInfo::symbolizeCode( |
| 155 | uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 156 | DILineInfo LineInfo; |
| 157 | if (DebugInfoContext) { |
| 158 | LineInfo = DebugInfoContext->getLineInfoForAddress( |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 159 | ModuleOffset, getDILineInfoSpecifier(Opts)); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 160 | } |
| 161 | // Override function name from symbol table if necessary. |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 162 | if (Opts.PrintFunctions != FunctionNameKind::None && Opts.UseSymbolTable) { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 163 | std::string FunctionName; |
| 164 | uint64_t Start, Size; |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 165 | if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset, |
| 166 | FunctionName, Start, Size)) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 167 | LineInfo.FunctionName = FunctionName; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | return LineInfo; |
| 171 | } |
| 172 | |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 173 | DIInliningInfo ModuleInfo::symbolizeInlinedCode( |
| 174 | uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 175 | DIInliningInfo InlinedContext; |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 176 | |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 177 | if (DebugInfoContext) { |
| 178 | InlinedContext = DebugInfoContext->getInliningInfoForAddress( |
Alexey Samsonov | dce6734 | 2014-05-15 21:24:32 +0000 | [diff] [blame] | 179 | ModuleOffset, getDILineInfoSpecifier(Opts)); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 180 | } |
| 181 | // Make sure there is at least one frame in context. |
| 182 | if (InlinedContext.getNumberOfFrames() == 0) { |
| 183 | InlinedContext.addFrame(DILineInfo()); |
| 184 | } |
| 185 | // Override the function name in lower frame with name from symbol table. |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 186 | if (Opts.PrintFunctions != FunctionNameKind::None && Opts.UseSymbolTable) { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 187 | DIInliningInfo PatchedInlinedContext; |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 188 | for (uint32_t i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 189 | DILineInfo LineInfo = InlinedContext.getFrame(i); |
| 190 | if (i == n - 1) { |
| 191 | std::string FunctionName; |
| 192 | uint64_t Start, Size; |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 193 | if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset, |
| 194 | FunctionName, Start, Size)) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 195 | LineInfo.FunctionName = FunctionName; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | PatchedInlinedContext.addFrame(LineInfo); |
| 199 | } |
| 200 | InlinedContext = PatchedInlinedContext; |
| 201 | } |
| 202 | return InlinedContext; |
| 203 | } |
| 204 | |
| 205 | bool ModuleInfo::symbolizeData(uint64_t ModuleOffset, std::string &Name, |
| 206 | uint64_t &Start, uint64_t &Size) const { |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 207 | return getNameFromSymbolTable(SymbolRef::ST_Data, ModuleOffset, Name, Start, |
| 208 | Size); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Alexey Samsonov | d6cef10 | 2013-02-04 15:55:26 +0000 | [diff] [blame] | 211 | const char LLVMSymbolizer::kBadString[] = "??"; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 212 | |
| 213 | std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName, |
| 214 | uint64_t ModuleOffset) { |
| 215 | ModuleInfo *Info = getOrCreateModuleInfo(ModuleName); |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 216 | if (!Info) |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 217 | return printDILineInfo(DILineInfo()); |
| 218 | if (Opts.PrintInlining) { |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 219 | DIInliningInfo InlinedContext = |
| 220 | Info->symbolizeInlinedCode(ModuleOffset, Opts); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 221 | uint32_t FramesNum = InlinedContext.getNumberOfFrames(); |
| 222 | assert(FramesNum > 0); |
| 223 | std::string Result; |
| 224 | for (uint32_t i = 0; i < FramesNum; i++) { |
| 225 | DILineInfo LineInfo = InlinedContext.getFrame(i); |
| 226 | Result += printDILineInfo(LineInfo); |
| 227 | } |
| 228 | return Result; |
| 229 | } |
| 230 | DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts); |
| 231 | return printDILineInfo(LineInfo); |
| 232 | } |
| 233 | |
| 234 | std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName, |
| 235 | uint64_t ModuleOffset) { |
| 236 | std::string Name = kBadString; |
| 237 | uint64_t Start = 0; |
| 238 | uint64_t Size = 0; |
| 239 | if (Opts.UseSymbolTable) { |
| 240 | if (ModuleInfo *Info = getOrCreateModuleInfo(ModuleName)) { |
Alexey Samsonov | 601beb7 | 2013-06-28 12:06:25 +0000 | [diff] [blame] | 241 | if (Info->symbolizeData(ModuleOffset, Name, Start, Size) && Opts.Demangle) |
Ed Maste | ef6fed7 | 2014-01-16 17:25:12 +0000 | [diff] [blame] | 242 | Name = DemangleName(Name); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | std::stringstream ss; |
| 246 | ss << Name << "\n" << Start << " " << Size << "\n"; |
| 247 | return ss.str(); |
| 248 | } |
| 249 | |
Dmitry Vyukov | e8504e2 | 2013-03-19 10:24:42 +0000 | [diff] [blame] | 250 | void LLVMSymbolizer::flush() { |
Alexey Samsonov | dd71c5b | 2013-03-19 15:33:18 +0000 | [diff] [blame] | 251 | DeleteContainerSeconds(Modules); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 252 | ObjectPairForPathArch.clear(); |
Alexey Samsonov | fe3a5d9 | 2013-06-28 15:08:29 +0000 | [diff] [blame] | 253 | ObjectFileForArch.clear(); |
Dmitry Vyukov | e8504e2 | 2013-03-19 10:24:42 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 256 | // For Path="/path/to/foo" and Basename="foo" assume that debug info is in |
| 257 | // /path/to/foo.dSYM/Contents/Resources/DWARF/foo. |
| 258 | // For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in |
| 259 | // /path/to/bar.dSYM/Contents/Resources/DWARF/foo. |
| 260 | static |
| 261 | std::string getDarwinDWARFResourceForPath( |
| 262 | const std::string &Path, const std::string &Basename) { |
| 263 | SmallString<16> ResourceName = StringRef(Path); |
| 264 | if (sys::path::extension(Path) != ".dSYM") { |
| 265 | ResourceName += ".dSYM"; |
| 266 | } |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 267 | sys::path::append(ResourceName, "Contents", "Resources", "DWARF"); |
| 268 | sys::path::append(ResourceName, Basename); |
| 269 | return ResourceName.str(); |
| 270 | } |
| 271 | |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 272 | static bool checkFileCRC(StringRef Path, uint32_t CRCHash) { |
Rafael Espindola | adf21f2 | 2014-07-06 17:43:13 +0000 | [diff] [blame] | 273 | ErrorOr<std::unique_ptr<MemoryBuffer>> MB = |
| 274 | MemoryBuffer::getFileOrSTDIN(Path); |
| 275 | if (!MB) |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 276 | return false; |
Rafael Espindola | adf21f2 | 2014-07-06 17:43:13 +0000 | [diff] [blame] | 277 | return !zlib::isAvailable() || CRCHash == zlib::crc32(MB.get()->getBuffer()); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static bool findDebugBinary(const std::string &OrigPath, |
| 281 | const std::string &DebuglinkName, uint32_t CRCHash, |
| 282 | std::string &Result) { |
Alexey Samsonov | a591ae6 | 2013-08-26 18:12:03 +0000 | [diff] [blame] | 283 | std::string OrigRealPath = OrigPath; |
| 284 | #if defined(HAVE_REALPATH) |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 285 | if (char *RP = realpath(OrigPath.c_str(), nullptr)) { |
Alexey Samsonov | a591ae6 | 2013-08-26 18:12:03 +0000 | [diff] [blame] | 286 | OrigRealPath = RP; |
| 287 | free(RP); |
| 288 | } |
| 289 | #endif |
| 290 | SmallString<16> OrigDir(OrigRealPath); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 291 | llvm::sys::path::remove_filename(OrigDir); |
| 292 | SmallString<16> DebugPath = OrigDir; |
| 293 | // Try /path/to/original_binary/debuglink_name |
| 294 | llvm::sys::path::append(DebugPath, DebuglinkName); |
| 295 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 296 | Result = DebugPath.str(); |
| 297 | return true; |
| 298 | } |
| 299 | // Try /path/to/original_binary/.debug/debuglink_name |
Alexey Samsonov | a591ae6 | 2013-08-26 18:12:03 +0000 | [diff] [blame] | 300 | DebugPath = OrigRealPath; |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 301 | llvm::sys::path::append(DebugPath, ".debug", DebuglinkName); |
| 302 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 303 | Result = DebugPath.str(); |
| 304 | return true; |
| 305 | } |
| 306 | // Try /usr/lib/debug/path/to/original_binary/debuglink_name |
| 307 | DebugPath = "/usr/lib/debug"; |
| 308 | llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir), |
| 309 | DebuglinkName); |
| 310 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 311 | Result = DebugPath.str(); |
| 312 | return true; |
| 313 | } |
| 314 | return false; |
| 315 | } |
| 316 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 317 | static bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName, |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 318 | uint32_t &CRCHash) { |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 319 | if (!Obj) |
| 320 | return false; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 321 | for (const SectionRef &Section : Obj->sections()) { |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 322 | StringRef Name; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 323 | Section.getName(Name); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 324 | Name = Name.substr(Name.find_first_not_of("._")); |
| 325 | if (Name == "gnu_debuglink") { |
| 326 | StringRef Data; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 327 | Section.getContents(Data); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 328 | DataExtractor DE(Data, Obj->isLittleEndian(), 0); |
| 329 | uint32_t Offset = 0; |
| 330 | if (const char *DebugNameStr = DE.getCStr(&Offset)) { |
| 331 | // 4-byte align the offset. |
| 332 | Offset = (Offset + 3) & ~0x3; |
| 333 | if (DE.isValidOffsetForDataOfSize(Offset, 4)) { |
| 334 | DebugName = DebugNameStr; |
| 335 | CRCHash = DE.getU32(&Offset); |
| 336 | return true; |
| 337 | } |
| 338 | } |
| 339 | break; |
| 340 | } |
| 341 | } |
| 342 | return false; |
| 343 | } |
| 344 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 345 | static |
| 346 | bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj, |
| 347 | const MachOObjectFile *Obj) { |
| 348 | ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid(); |
| 349 | ArrayRef<uint8_t> bin_uuid = Obj->getUuid(); |
| 350 | if (dbg_uuid.empty() || bin_uuid.empty()) |
| 351 | return false; |
| 352 | return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size()); |
| 353 | } |
| 354 | |
| 355 | ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath, |
| 356 | const MachOObjectFile *MachExeObj, const std::string &ArchName) { |
| 357 | // On Darwin we may find DWARF in separate object file in |
| 358 | // resource directory. |
| 359 | std::vector<std::string> DsymPaths; |
| 360 | StringRef Filename = sys::path::filename(ExePath); |
| 361 | DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename)); |
| 362 | for (const auto &Path : Opts.DsymHints) { |
| 363 | DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename)); |
| 364 | } |
| 365 | for (const auto &path : DsymPaths) { |
| 366 | ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(path); |
| 367 | std::error_code EC = BinaryOrErr.getError(); |
| 368 | if (EC != errc::no_such_file_or_directory && !error(EC)) { |
| 369 | OwningBinary<Binary> B = std::move(BinaryOrErr.get()); |
| 370 | ObjectFile *DbgObj = |
Lang Hames | f04de6e | 2014-10-31 21:37:49 +0000 | [diff] [blame] | 371 | getObjectFileFromBinary(B.getBinary(), ArchName); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 372 | const MachOObjectFile *MachDbgObj = |
| 373 | dyn_cast<const MachOObjectFile>(DbgObj); |
| 374 | if (!MachDbgObj) continue; |
| 375 | if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj)) { |
Rafael Espindola | 48af1c2 | 2014-08-19 18:44:46 +0000 | [diff] [blame] | 376 | addOwningBinary(std::move(B)); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 377 | return DbgObj; |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 378 | } |
| 379 | } |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 380 | } |
| 381 | return nullptr; |
| 382 | } |
| 383 | |
| 384 | LLVMSymbolizer::ObjectPair |
| 385 | LLVMSymbolizer::getOrCreateObjects(const std::string &Path, |
| 386 | const std::string &ArchName) { |
| 387 | const auto &I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName)); |
| 388 | if (I != ObjectPairForPathArch.end()) |
| 389 | return I->second; |
| 390 | ObjectFile *Obj = nullptr; |
| 391 | ObjectFile *DbgObj = nullptr; |
| 392 | ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(Path); |
| 393 | if (!error(BinaryOrErr.getError())) { |
| 394 | OwningBinary<Binary> &B = BinaryOrErr.get(); |
Lang Hames | f04de6e | 2014-10-31 21:37:49 +0000 | [diff] [blame] | 395 | Obj = getObjectFileFromBinary(B.getBinary(), ArchName); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 396 | if (!Obj) { |
| 397 | ObjectPair Res = std::make_pair(nullptr, nullptr); |
| 398 | ObjectPairForPathArch[std::make_pair(Path, ArchName)] = Res; |
| 399 | return Res; |
| 400 | } |
| 401 | addOwningBinary(std::move(B)); |
| 402 | if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj)) |
| 403 | DbgObj = lookUpDsymFile(Path, MachObj, ArchName); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 404 | // Try to locate the debug binary using .gnu_debuglink section. |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 405 | if (!DbgObj) { |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 406 | std::string DebuglinkName; |
| 407 | uint32_t CRCHash; |
| 408 | std::string DebugBinaryPath; |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 409 | if (getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash) && |
Rafael Espindola | 63da295 | 2014-01-15 19:37:43 +0000 | [diff] [blame] | 410 | findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath)) { |
| 411 | BinaryOrErr = createBinary(DebugBinaryPath); |
| 412 | if (!error(BinaryOrErr.getError())) { |
Rafael Espindola | 48af1c2 | 2014-08-19 18:44:46 +0000 | [diff] [blame] | 413 | OwningBinary<Binary> B = std::move(BinaryOrErr.get()); |
Lang Hames | f04de6e | 2014-10-31 21:37:49 +0000 | [diff] [blame] | 414 | DbgObj = getObjectFileFromBinary(B.getBinary(), ArchName); |
Rafael Espindola | 48af1c2 | 2014-08-19 18:44:46 +0000 | [diff] [blame] | 415 | addOwningBinary(std::move(B)); |
Rafael Espindola | 63da295 | 2014-01-15 19:37:43 +0000 | [diff] [blame] | 416 | } |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 417 | } |
| 418 | } |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 419 | } |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 420 | if (!DbgObj) |
| 421 | DbgObj = Obj; |
| 422 | ObjectPair Res = std::make_pair(Obj, DbgObj); |
| 423 | ObjectPairForPathArch[std::make_pair(Path, ArchName)] = Res; |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 424 | return Res; |
| 425 | } |
| 426 | |
| 427 | ObjectFile * |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 428 | LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, |
| 429 | const std::string &ArchName) { |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 430 | if (!Bin) |
| 431 | return nullptr; |
| 432 | ObjectFile *Res = nullptr; |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 433 | if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin)) { |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 434 | const auto &I = ObjectFileForArch.find( |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 435 | std::make_pair(UB, ArchName)); |
| 436 | if (I != ObjectFileForArch.end()) |
| 437 | return I->second; |
Rafael Espindola | 4f7932b | 2014-06-23 20:41:02 +0000 | [diff] [blame] | 438 | ErrorOr<std::unique_ptr<ObjectFile>> ParsedObj = |
Frederic Riss | ebc162a | 2015-06-22 21:33:24 +0000 | [diff] [blame] | 439 | UB->getObjectForArch(ArchName); |
Rafael Espindola | 4f7932b | 2014-06-23 20:41:02 +0000 | [diff] [blame] | 440 | if (ParsedObj) { |
| 441 | Res = ParsedObj.get().get(); |
| 442 | ParsedBinariesAndObjects.push_back(std::move(ParsedObj.get())); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 443 | } |
| 444 | ObjectFileForArch[std::make_pair(UB, ArchName)] = Res; |
| 445 | } else if (Bin->isObject()) { |
| 446 | Res = cast<ObjectFile>(Bin); |
| 447 | } |
| 448 | return Res; |
| 449 | } |
| 450 | |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 451 | ModuleInfo * |
| 452 | LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 453 | const auto &I = Modules.find(ModuleName); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 454 | if (I != Modules.end()) |
| 455 | return I->second; |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 456 | std::string BinaryName = ModuleName; |
| 457 | std::string ArchName = Opts.DefaultArch; |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 458 | size_t ColonPos = ModuleName.find_last_of(':'); |
| 459 | // Verify that substring after colon form a valid arch name. |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 460 | if (ColonPos != std::string::npos) { |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 461 | std::string ArchStr = ModuleName.substr(ColonPos + 1); |
NAKAMURA Takumi | 8ee89c6 | 2013-07-17 06:53:51 +0000 | [diff] [blame] | 462 | if (Triple(ArchStr).getArch() != Triple::UnknownArch) { |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 463 | BinaryName = ModuleName.substr(0, ColonPos); |
| 464 | ArchName = ArchStr; |
| 465 | } |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 466 | } |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 467 | ObjectPair Objects = getOrCreateObjects(BinaryName, ArchName); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 468 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 469 | if (!Objects.first) { |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 470 | // Failed to find valid object file. |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 471 | Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr)); |
| 472 | return nullptr; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 473 | } |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 474 | DIContext *Context = nullptr; |
| 475 | if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) { |
| 476 | // If this is a COFF object, assume it contains PDB debug information. If |
| 477 | // we don't find any we will fall back to the DWARF case. |
| 478 | std::unique_ptr<IPDBSession> Session; |
| 479 | PDB_ErrorCode Error = loadDataForEXE(PDB_ReaderType::DIA, |
| 480 | Objects.first->getFileName(), Session); |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 481 | if (Error == PDB_ErrorCode::Success) { |
| 482 | Context = new PDBContext(*CoffObject, std::move(Session), |
| 483 | Opts.RelativeAddresses); |
| 484 | } |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 485 | } |
| 486 | if (!Context) |
| 487 | Context = new DWARFContextInMemory(*Objects.second); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 488 | assert(Context); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 489 | ModuleInfo *Info = new ModuleInfo(Objects.first, Context); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 490 | Modules.insert(make_pair(ModuleName, Info)); |
| 491 | return Info; |
| 492 | } |
| 493 | |
| 494 | std::string LLVMSymbolizer::printDILineInfo(DILineInfo LineInfo) const { |
| 495 | // By default, DILineInfo contains "<invalid>" for function/filename it |
| 496 | // cannot fetch. We replace it to "??" to make our output closer to addr2line. |
| 497 | static const std::string kDILineInfoBadString = "<invalid>"; |
| 498 | std::stringstream Result; |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 499 | if (Opts.PrintFunctions != FunctionNameKind::None) { |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 500 | std::string FunctionName = LineInfo.FunctionName; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 501 | if (FunctionName == kDILineInfoBadString) |
| 502 | FunctionName = kBadString; |
Alexey Samsonov | 601beb7 | 2013-06-28 12:06:25 +0000 | [diff] [blame] | 503 | else if (Opts.Demangle) |
| 504 | FunctionName = DemangleName(FunctionName); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 505 | Result << FunctionName << "\n"; |
| 506 | } |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 507 | std::string Filename = LineInfo.FileName; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 508 | if (Filename == kDILineInfoBadString) |
| 509 | Filename = kBadString; |
Alexey Samsonov | d010999 | 2014-04-18 21:36:39 +0000 | [diff] [blame] | 510 | Result << Filename << ":" << LineInfo.Line << ":" << LineInfo.Column << "\n"; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 511 | return Result.str(); |
| 512 | } |
| 513 | |
| 514 | #if !defined(_MSC_VER) |
| 515 | // Assume that __cxa_demangle is provided by libcxxabi (except for Windows). |
| 516 | extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer, |
| 517 | size_t *length, int *status); |
| 518 | #endif |
| 519 | |
Alexey Samsonov | 601beb7 | 2013-06-28 12:06:25 +0000 | [diff] [blame] | 520 | std::string LLVMSymbolizer::DemangleName(const std::string &Name) { |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 521 | #if !defined(_MSC_VER) |
Ed Maste | ef6fed7 | 2014-01-16 17:25:12 +0000 | [diff] [blame] | 522 | // We can spoil names of symbols with C linkage, so use an heuristic |
| 523 | // approach to check if the name should be demangled. |
| 524 | if (Name.substr(0, 2) != "_Z") |
| 525 | return Name; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 526 | int status = 0; |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 527 | char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 528 | if (status != 0) |
Alexey Samsonov | 601beb7 | 2013-06-28 12:06:25 +0000 | [diff] [blame] | 529 | return Name; |
| 530 | std::string Result = DemangledName; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 531 | free(DemangledName); |
Alexey Samsonov | 601beb7 | 2013-06-28 12:06:25 +0000 | [diff] [blame] | 532 | return Result; |
| 533 | #else |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 534 | char DemangledName[1024] = {0}; |
| 535 | DWORD result = ::UnDecorateSymbolName( |
| 536 | Name.c_str(), DemangledName, 1023, |
| 537 | UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected |
| 538 | UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc |
| 539 | UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications |
| 540 | UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers |
| 541 | UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords |
| 542 | UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types |
| 543 | |
| 544 | return (result == 0) ? Name : std::string(DemangledName); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 545 | #endif |
| 546 | } |
| 547 | |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 548 | } // namespace symbolize |
| 549 | } // namespace llvm |