Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 1 | //===-- LLVMSymbolize.cpp -------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Implementation for LLVM symbolization library. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Alexey Samsonov | 57f8837 | 2015-10-26 17:56:12 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/Symbolize/Symbolize.h" |
| 14 | |
Alexey Samsonov | 8df3a07 | 2015-10-29 22:21:37 +0000 | [diff] [blame] | 15 | #include "SymbolizableObjectFile.h" |
| 16 | |
Alexey Samsonov | dd71c5b | 2013-03-19 15:33:18 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Zachary Turner | 264b5d9 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 18 | #include "llvm/BinaryFormat/COFF.h" |
Zachary Turner | 6489d7b | 2015-04-23 17:37:47 +0000 | [diff] [blame] | 19 | #include "llvm/DebugInfo/DWARF/DWARFContext.h" |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 20 | #include "llvm/DebugInfo/PDB/PDB.h" |
| 21 | #include "llvm/DebugInfo/PDB/PDBContext.h" |
Eugene Zemtsov | cd72cbc | 2018-03-07 23:07:34 +0000 | [diff] [blame] | 22 | #include "llvm/Demangle/Demangle.h" |
Reid Kleckner | dafc5d7 | 2016-07-06 16:56:42 +0000 | [diff] [blame] | 23 | #include "llvm/Object/COFF.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 24 | #include "llvm/Object/MachO.h" |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 25 | #include "llvm/Object/MachOUniversal.h" |
Eugene Leviant | 18873b2 | 2019-04-08 12:31:12 +0000 | [diff] [blame] | 26 | #include "llvm/Support/CRC.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 27 | #include "llvm/Support/Casting.h" |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 28 | #include "llvm/Support/Compression.h" |
| 29 | #include "llvm/Support/DataExtractor.h" |
Rafael Espindola | 2a826e4 | 2014-06-13 17:20:48 +0000 | [diff] [blame] | 30 | #include "llvm/Support/Errc.h" |
Alexey Samsonov | 5239d58 | 2013-06-04 07:57:38 +0000 | [diff] [blame] | 31 | #include "llvm/Support/FileSystem.h" |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 32 | #include "llvm/Support/MemoryBuffer.h" |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 33 | #include "llvm/Support/Path.h" |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 34 | #include <algorithm> |
| 35 | #include <cassert> |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 36 | #include <cstring> |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 37 | |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 38 | #if defined(_MSC_VER) |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 39 | #include <Windows.h> |
Chandler Carruth | aaeada6 | 2017-06-06 12:43:20 +0000 | [diff] [blame] | 40 | |
| 41 | // This must be included after windows.h. |
| 42 | #include <DbgHelp.h> |
Leny Kholodov | bebb27b | 2015-07-02 14:34:57 +0000 | [diff] [blame] | 43 | #pragma comment(lib, "dbghelp.lib") |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 44 | |
| 45 | // Windows.h conflicts with our COFF header definitions. |
| 46 | #ifdef IMAGE_FILE_MACHINE_I386 |
| 47 | #undef IMAGE_FILE_MACHINE_I386 |
| 48 | #endif |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 49 | #endif |
| 50 | |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 51 | namespace llvm { |
| 52 | namespace symbolize { |
| 53 | |
David Blaikie | e5adb68 | 2017-07-30 01:34:08 +0000 | [diff] [blame] | 54 | Expected<DILineInfo> |
| 55 | LLVMSymbolizer::symbolizeCode(const std::string &ModuleName, |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 56 | object::SectionedAddress ModuleOffset, |
| 57 | StringRef DWPName) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 58 | SymbolizableModule *Info; |
David Blaikie | e5adb68 | 2017-07-30 01:34:08 +0000 | [diff] [blame] | 59 | if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName)) |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 60 | Info = InfoOrErr.get(); |
| 61 | else |
| 62 | return InfoOrErr.takeError(); |
| 63 | |
| 64 | // A null module means an error has already been reported. Return an empty |
| 65 | // result. |
| 66 | if (!Info) |
| 67 | return DILineInfo(); |
Reid Kleckner | e94fef7 | 2015-10-09 00:15:01 +0000 | [diff] [blame] | 68 | |
| 69 | // If the user is giving us relative addresses, add the preferred base of the |
| 70 | // object to the offset before we do the query. It's what DIContext expects. |
| 71 | if (Opts.RelativeAddresses) |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 72 | ModuleOffset.Address += Info->getModulePreferredBase(); |
Reid Kleckner | e94fef7 | 2015-10-09 00:15:01 +0000 | [diff] [blame] | 73 | |
Alexey Samsonov | 0fb6451 | 2015-10-26 22:34:56 +0000 | [diff] [blame] | 74 | DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions, |
| 75 | Opts.UseSymbolTable); |
Alexey Samsonov | 6881249 | 2015-11-03 21:36:13 +0000 | [diff] [blame] | 76 | if (Opts.Demangle) |
| 77 | LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info); |
Alexey Samsonov | d6aa820 | 2015-11-03 22:20:52 +0000 | [diff] [blame] | 78 | return LineInfo; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 81 | Expected<DIInliningInfo> |
Alexey Samsonov | d6aa820 | 2015-11-03 22:20:52 +0000 | [diff] [blame] | 82 | LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName, |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 83 | object::SectionedAddress ModuleOffset, |
| 84 | StringRef DWPName) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 85 | SymbolizableModule *Info; |
David Blaikie | e5adb68 | 2017-07-30 01:34:08 +0000 | [diff] [blame] | 86 | if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName)) |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 87 | Info = InfoOrErr.get(); |
| 88 | else |
| 89 | return InfoOrErr.takeError(); |
| 90 | |
| 91 | // A null module means an error has already been reported. Return an empty |
| 92 | // result. |
| 93 | if (!Info) |
| 94 | return DIInliningInfo(); |
Alexey Samsonov | 46c1ce6 | 2015-10-30 00:40:20 +0000 | [diff] [blame] | 95 | |
| 96 | // If the user is giving us relative addresses, add the preferred base of the |
| 97 | // object to the offset before we do the query. It's what DIContext expects. |
| 98 | if (Opts.RelativeAddresses) |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 99 | ModuleOffset.Address += Info->getModulePreferredBase(); |
Alexey Samsonov | 46c1ce6 | 2015-10-30 00:40:20 +0000 | [diff] [blame] | 100 | |
| 101 | DIInliningInfo InlinedContext = Info->symbolizeInlinedCode( |
| 102 | ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable); |
Alexey Samsonov | 6881249 | 2015-11-03 21:36:13 +0000 | [diff] [blame] | 103 | if (Opts.Demangle) { |
| 104 | for (int i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) { |
| 105 | auto *Frame = InlinedContext.getMutableFrame(i); |
| 106 | Frame->FunctionName = DemangleName(Frame->FunctionName, Info); |
| 107 | } |
| 108 | } |
Alexey Samsonov | d6aa820 | 2015-11-03 22:20:52 +0000 | [diff] [blame] | 109 | return InlinedContext; |
Alexey Samsonov | 46c1ce6 | 2015-10-30 00:40:20 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 112 | Expected<DIGlobal> |
| 113 | LLVMSymbolizer::symbolizeData(const std::string &ModuleName, |
| 114 | object::SectionedAddress ModuleOffset) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 115 | SymbolizableModule *Info; |
| 116 | if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName)) |
| 117 | Info = InfoOrErr.get(); |
| 118 | else |
| 119 | return InfoOrErr.takeError(); |
| 120 | |
| 121 | // A null module means an error has already been reported. Return an empty |
| 122 | // result. |
| 123 | if (!Info) |
| 124 | return DIGlobal(); |
Alexey Samsonov | 6881249 | 2015-11-03 21:36:13 +0000 | [diff] [blame] | 125 | |
| 126 | // If the user is giving us relative addresses, add the preferred base of |
| 127 | // the object to the offset before we do the query. It's what DIContext |
| 128 | // expects. |
| 129 | if (Opts.RelativeAddresses) |
Alexey Lapshin | 77fc1f6 | 2019-02-27 13:17:36 +0000 | [diff] [blame] | 130 | ModuleOffset.Address += Info->getModulePreferredBase(); |
Alexey Samsonov | 6881249 | 2015-11-03 21:36:13 +0000 | [diff] [blame] | 131 | |
| 132 | DIGlobal Global = Info->symbolizeData(ModuleOffset); |
| 133 | if (Opts.Demangle) |
| 134 | Global.Name = DemangleName(Global.Name, Info); |
Alexey Samsonov | d6aa820 | 2015-11-03 22:20:52 +0000 | [diff] [blame] | 135 | return Global; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 136 | } |
| 137 | |
Dmitry Vyukov | e8504e2 | 2013-03-19 10:24:42 +0000 | [diff] [blame] | 138 | void LLVMSymbolizer::flush() { |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 139 | ObjectForUBPathAndArch.clear(); |
| 140 | BinaryForPath.clear(); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 141 | ObjectPairForPathArch.clear(); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 142 | Modules.clear(); |
Dmitry Vyukov | e8504e2 | 2013-03-19 10:24:42 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 145 | namespace { |
| 146 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 147 | // For Path="/path/to/foo" and Basename="foo" assume that debug info is in |
| 148 | // /path/to/foo.dSYM/Contents/Resources/DWARF/foo. |
| 149 | // For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in |
| 150 | // /path/to/bar.dSYM/Contents/Resources/DWARF/foo. |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 151 | std::string getDarwinDWARFResourceForPath( |
| 152 | const std::string &Path, const std::string &Basename) { |
| 153 | SmallString<16> ResourceName = StringRef(Path); |
| 154 | if (sys::path::extension(Path) != ".dSYM") { |
| 155 | ResourceName += ".dSYM"; |
| 156 | } |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 157 | sys::path::append(ResourceName, "Contents", "Resources", "DWARF"); |
| 158 | sys::path::append(ResourceName, Basename); |
| 159 | return ResourceName.str(); |
| 160 | } |
| 161 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 162 | bool checkFileCRC(StringRef Path, uint32_t CRCHash) { |
Rafael Espindola | adf21f2 | 2014-07-06 17:43:13 +0000 | [diff] [blame] | 163 | ErrorOr<std::unique_ptr<MemoryBuffer>> MB = |
| 164 | MemoryBuffer::getFileOrSTDIN(Path); |
| 165 | if (!MB) |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 166 | return false; |
Eugene Leviant | 7671a1d | 2019-04-08 13:40:58 +0000 | [diff] [blame] | 167 | return CRCHash == llvm::crc32(0, MB.get()->getBuffer()); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 170 | bool findDebugBinary(const std::string &OrigPath, |
| 171 | const std::string &DebuglinkName, uint32_t CRCHash, |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 172 | const std::string &FallbackDebugPath, |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 173 | std::string &Result) { |
Jordan Rupprecht | 835df27 | 2019-02-01 21:04:16 +0000 | [diff] [blame] | 174 | SmallString<16> OrigDir(OrigPath); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 175 | llvm::sys::path::remove_filename(OrigDir); |
| 176 | SmallString<16> DebugPath = OrigDir; |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 177 | // Try relative/path/to/original_binary/debuglink_name |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 178 | llvm::sys::path::append(DebugPath, DebuglinkName); |
| 179 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 180 | Result = DebugPath.str(); |
| 181 | return true; |
| 182 | } |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 183 | // Try relative/path/to/original_binary/.debug/debuglink_name |
Francis Ricci | fe6cbce | 2018-03-02 22:56:45 +0000 | [diff] [blame] | 184 | DebugPath = OrigDir; |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 185 | llvm::sys::path::append(DebugPath, ".debug", DebuglinkName); |
| 186 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 187 | Result = DebugPath.str(); |
| 188 | return true; |
| 189 | } |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 190 | // Make the path absolute so that lookups will go to |
| 191 | // "/usr/lib/debug/full/path/to/debug", not |
| 192 | // "/usr/lib/debug/to/debug" |
| 193 | llvm::sys::fs::make_absolute(OrigDir); |
| 194 | if (!FallbackDebugPath.empty()) { |
| 195 | // Try <FallbackDebugPath>/absolute/path/to/original_binary/debuglink_name |
| 196 | DebugPath = FallbackDebugPath; |
| 197 | } else { |
Kamil Rytarowski | a8448ad | 2018-06-25 18:49:13 +0000 | [diff] [blame] | 198 | #if defined(__NetBSD__) |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 199 | // Try /usr/libdata/debug/absolute/path/to/original_binary/debuglink_name |
| 200 | DebugPath = "/usr/libdata/debug"; |
Kamil Rytarowski | a8448ad | 2018-06-25 18:49:13 +0000 | [diff] [blame] | 201 | #else |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 202 | // Try /usr/lib/debug/absolute/path/to/original_binary/debuglink_name |
| 203 | DebugPath = "/usr/lib/debug"; |
Kamil Rytarowski | a8448ad | 2018-06-25 18:49:13 +0000 | [diff] [blame] | 204 | #endif |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 205 | } |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 206 | llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir), |
| 207 | DebuglinkName); |
| 208 | if (checkFileCRC(DebugPath, CRCHash)) { |
| 209 | Result = DebugPath.str(); |
| 210 | return true; |
| 211 | } |
| 212 | return false; |
| 213 | } |
| 214 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 215 | bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName, |
| 216 | uint32_t &CRCHash) { |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 217 | if (!Obj) |
| 218 | return false; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 219 | for (const SectionRef &Section : Obj->sections()) { |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 220 | StringRef Name; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 221 | Section.getName(Name); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 222 | Name = Name.substr(Name.find_first_not_of("._")); |
| 223 | if (Name == "gnu_debuglink") { |
Hans Wennborg | 4da9ff9 | 2019-05-16 12:08:34 +0000 | [diff] [blame] | 224 | StringRef Data; |
| 225 | Section.getContents(Data); |
| 226 | DataExtractor DE(Data, Obj->isLittleEndian(), 0); |
Alexey Samsonov | 3e9997f | 2013-08-14 17:09:30 +0000 | [diff] [blame] | 227 | uint32_t Offset = 0; |
| 228 | if (const char *DebugNameStr = DE.getCStr(&Offset)) { |
| 229 | // 4-byte align the offset. |
| 230 | Offset = (Offset + 3) & ~0x3; |
| 231 | if (DE.isValidOffsetForDataOfSize(Offset, 4)) { |
| 232 | DebugName = DebugNameStr; |
| 233 | CRCHash = DE.getU32(&Offset); |
| 234 | return true; |
| 235 | } |
| 236 | } |
| 237 | break; |
| 238 | } |
| 239 | } |
| 240 | return false; |
| 241 | } |
| 242 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 243 | bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj, |
| 244 | const MachOObjectFile *Obj) { |
| 245 | ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid(); |
| 246 | ArrayRef<uint8_t> bin_uuid = Obj->getUuid(); |
| 247 | if (dbg_uuid.empty() || bin_uuid.empty()) |
| 248 | return false; |
| 249 | return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size()); |
| 250 | } |
| 251 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 252 | } // end anonymous namespace |
| 253 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 254 | ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath, |
| 255 | const MachOObjectFile *MachExeObj, const std::string &ArchName) { |
| 256 | // On Darwin we may find DWARF in separate object file in |
| 257 | // resource directory. |
| 258 | std::vector<std::string> DsymPaths; |
| 259 | StringRef Filename = sys::path::filename(ExePath); |
| 260 | DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename)); |
| 261 | for (const auto &Path : Opts.DsymHints) { |
| 262 | DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename)); |
| 263 | } |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 264 | for (const auto &Path : DsymPaths) { |
| 265 | auto DbgObjOrErr = getOrCreateObject(Path, ArchName); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 266 | if (!DbgObjOrErr) { |
| 267 | // Ignore errors, the file might not exist. |
| 268 | consumeError(DbgObjOrErr.takeError()); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 269 | continue; |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 270 | } |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 271 | ObjectFile *DbgObj = DbgObjOrErr.get(); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 272 | if (!DbgObj) |
| 273 | continue; |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 274 | const MachOObjectFile *MachDbgObj = dyn_cast<const MachOObjectFile>(DbgObj); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 275 | if (!MachDbgObj) |
| 276 | continue; |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 277 | if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj)) |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 278 | return DbgObj; |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 279 | } |
| 280 | return nullptr; |
| 281 | } |
| 282 | |
Alexey Samsonov | 5365a01 | 2015-11-04 00:30:26 +0000 | [diff] [blame] | 283 | ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path, |
| 284 | const ObjectFile *Obj, |
| 285 | const std::string &ArchName) { |
| 286 | std::string DebuglinkName; |
| 287 | uint32_t CRCHash; |
| 288 | std::string DebugBinaryPath; |
| 289 | if (!getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash)) |
| 290 | return nullptr; |
Jordan Rupprecht | 5b7ad42 | 2019-02-11 18:05:48 +0000 | [diff] [blame] | 291 | if (!findDebugBinary(Path, DebuglinkName, CRCHash, Opts.FallbackDebugPath, |
| 292 | DebugBinaryPath)) |
Alexey Samsonov | 5365a01 | 2015-11-04 00:30:26 +0000 | [diff] [blame] | 293 | return nullptr; |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 294 | auto DbgObjOrErr = getOrCreateObject(DebugBinaryPath, ArchName); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 295 | if (!DbgObjOrErr) { |
| 296 | // Ignore errors, the file might not exist. |
| 297 | consumeError(DbgObjOrErr.takeError()); |
Alexey Samsonov | 5365a01 | 2015-11-04 00:30:26 +0000 | [diff] [blame] | 298 | return nullptr; |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 299 | } |
Alexey Samsonov | 5365a01 | 2015-11-04 00:30:26 +0000 | [diff] [blame] | 300 | return DbgObjOrErr.get(); |
| 301 | } |
| 302 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 303 | Expected<LLVMSymbolizer::ObjectPair> |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 304 | LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path, |
| 305 | const std::string &ArchName) { |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 306 | const auto &I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName)); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 307 | if (I != ObjectPairForPathArch.end()) { |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 308 | return I->second; |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 309 | } |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 310 | |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 311 | auto ObjOrErr = getOrCreateObject(Path, ArchName); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 312 | if (!ObjOrErr) { |
| 313 | ObjectPairForPathArch.insert(std::make_pair(std::make_pair(Path, ArchName), |
| 314 | ObjectPair(nullptr, nullptr))); |
| 315 | return ObjOrErr.takeError(); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 316 | } |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 317 | |
| 318 | ObjectFile *Obj = ObjOrErr.get(); |
| 319 | assert(Obj != nullptr); |
| 320 | ObjectFile *DbgObj = nullptr; |
| 321 | |
| 322 | if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj)) |
| 323 | DbgObj = lookUpDsymFile(Path, MachObj, ArchName); |
Alexey Samsonov | 5365a01 | 2015-11-04 00:30:26 +0000 | [diff] [blame] | 324 | if (!DbgObj) |
| 325 | DbgObj = lookUpDebuglinkObject(Path, Obj, ArchName); |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 326 | if (!DbgObj) |
| 327 | DbgObj = Obj; |
| 328 | ObjectPair Res = std::make_pair(Obj, DbgObj); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 329 | ObjectPairForPathArch.insert( |
| 330 | std::make_pair(std::make_pair(Path, ArchName), Res)); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 331 | return Res; |
| 332 | } |
| 333 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 334 | Expected<ObjectFile *> |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 335 | LLVMSymbolizer::getOrCreateObject(const std::string &Path, |
| 336 | const std::string &ArchName) { |
| 337 | const auto &I = BinaryForPath.find(Path); |
| 338 | Binary *Bin = nullptr; |
| 339 | if (I == BinaryForPath.end()) { |
Kevin Enderby | 3fcdf6a | 2016-04-06 22:14:09 +0000 | [diff] [blame] | 340 | Expected<OwningBinary<Binary>> BinOrErr = createBinary(Path); |
| 341 | if (!BinOrErr) { |
Reid Kleckner | 4ece163 | 2016-06-06 23:46:14 +0000 | [diff] [blame] | 342 | BinaryForPath.insert(std::make_pair(Path, OwningBinary<Binary>())); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 343 | return BinOrErr.takeError(); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 344 | } |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 345 | Bin = BinOrErr->getBinary(); |
| 346 | BinaryForPath.insert(std::make_pair(Path, std::move(BinOrErr.get()))); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 347 | } else { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 348 | Bin = I->second.getBinary(); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 349 | } |
| 350 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 351 | if (!Bin) |
| 352 | return static_cast<ObjectFile *>(nullptr); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 353 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 354 | if (MachOUniversalBinary *UB = dyn_cast_or_null<MachOUniversalBinary>(Bin)) { |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 355 | const auto &I = ObjectForUBPathAndArch.find(std::make_pair(Path, ArchName)); |
| 356 | if (I != ObjectForUBPathAndArch.end()) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 357 | return I->second.get(); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 358 | } |
Kevin Enderby | 9acb109 | 2016-05-31 20:35:34 +0000 | [diff] [blame] | 359 | Expected<std::unique_ptr<ObjectFile>> ObjOrErr = |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 360 | UB->getObjectForArch(ArchName); |
Kevin Enderby | 9acb109 | 2016-05-31 20:35:34 +0000 | [diff] [blame] | 361 | if (!ObjOrErr) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 362 | ObjectForUBPathAndArch.insert(std::make_pair( |
| 363 | std::make_pair(Path, ArchName), std::unique_ptr<ObjectFile>())); |
| 364 | return ObjOrErr.takeError(); |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 365 | } |
| 366 | ObjectFile *Res = ObjOrErr->get(); |
| 367 | ObjectForUBPathAndArch.insert(std::make_pair(std::make_pair(Path, ArchName), |
| 368 | std::move(ObjOrErr.get()))); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 369 | return Res; |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 370 | } |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 371 | if (Bin->isObject()) { |
| 372 | return cast<ObjectFile>(Bin); |
| 373 | } |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 374 | return errorCodeToError(object_error::arch_not_found); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 375 | } |
| 376 | |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 377 | Expected<SymbolizableModule *> |
David Blaikie | e5adb68 | 2017-07-30 01:34:08 +0000 | [diff] [blame] | 378 | LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName, |
| 379 | StringRef DWPName) { |
Alexander Potapenko | 45bfe37 | 2014-10-14 13:40:44 +0000 | [diff] [blame] | 380 | const auto &I = Modules.find(ModuleName); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 381 | if (I != Modules.end()) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 382 | return I->second.get(); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 383 | } |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 384 | std::string BinaryName = ModuleName; |
| 385 | std::string ArchName = Opts.DefaultArch; |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 386 | size_t ColonPos = ModuleName.find_last_of(':'); |
| 387 | // Verify that substring after colon form a valid arch name. |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 388 | if (ColonPos != std::string::npos) { |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 389 | std::string ArchStr = ModuleName.substr(ColonPos + 1); |
NAKAMURA Takumi | 8ee89c6 | 2013-07-17 06:53:51 +0000 | [diff] [blame] | 390 | if (Triple(ArchStr).getArch() != Triple::UnknownArch) { |
Alexey Samsonov | b119b46 | 2013-07-17 06:45:36 +0000 | [diff] [blame] | 391 | BinaryName = ModuleName.substr(0, ColonPos); |
| 392 | ArchName = ArchStr; |
| 393 | } |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 394 | } |
Alexey Samsonov | 1eaae4c | 2015-12-18 22:02:14 +0000 | [diff] [blame] | 395 | auto ObjectsOrErr = getOrCreateObjectPair(BinaryName, ArchName); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 396 | if (!ObjectsOrErr) { |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 397 | // Failed to find valid object file. |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 398 | Modules.insert( |
| 399 | std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>())); |
| 400 | return ObjectsOrErr.takeError(); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 401 | } |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 402 | ObjectPair Objects = ObjectsOrErr.get(); |
| 403 | |
Alexey Samsonov | 7a952e5 | 2015-10-26 19:41:23 +0000 | [diff] [blame] | 404 | std::unique_ptr<DIContext> Context; |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 405 | // If this is a COFF object containing PDB info, use a PDBContext to |
| 406 | // symbolize. Otherwise, use DWARF. |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 407 | if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) { |
Saleem Abdulrasool | 0152802 | 2016-08-09 00:25:12 +0000 | [diff] [blame] | 408 | const codeview::DebugInfo *DebugInfo; |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 409 | StringRef PDBFileName; |
Saleem Abdulrasool | 0152802 | 2016-08-09 00:25:12 +0000 | [diff] [blame] | 410 | auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName); |
Reid Kleckner | d1882f2 | 2016-09-01 20:28:59 +0000 | [diff] [blame] | 411 | if (!EC && DebugInfo != nullptr && !PDBFileName.empty()) { |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 412 | using namespace pdb; |
| 413 | std::unique_ptr<IPDBSession> Session; |
| 414 | if (auto Err = loadDataForEXE(PDB_ReaderType::DIA, |
| 415 | Objects.first->getFileName(), Session)) { |
| 416 | Modules.insert( |
| 417 | std::make_pair(ModuleName, std::unique_ptr<SymbolizableModule>())); |
Alexandre Ganea | 6a7efef | 2018-08-31 17:41:58 +0000 | [diff] [blame] | 418 | // Return along the PDB filename to provide more context |
| 419 | return createFileError(PDBFileName, std::move(Err)); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 420 | } |
Alexey Samsonov | 7a952e5 | 2015-10-26 19:41:23 +0000 | [diff] [blame] | 421 | Context.reset(new PDBContext(*CoffObject, std::move(Session))); |
Zachary Turner | c007aa4 | 2015-05-06 22:26:30 +0000 | [diff] [blame] | 422 | } |
Zachary Turner | 20dbd0d | 2015-04-27 17:19:51 +0000 | [diff] [blame] | 423 | } |
| 424 | if (!Context) |
David Blaikie | e5adb68 | 2017-07-30 01:34:08 +0000 | [diff] [blame] | 425 | Context = DWARFContext::create(*Objects.second, nullptr, |
| 426 | DWARFContext::defaultErrorHandler, DWPName); |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 427 | assert(Context); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 428 | auto InfoOrErr = |
Alexey Samsonov | 8df3a07 | 2015-10-29 22:21:37 +0000 | [diff] [blame] | 429 | SymbolizableObjectFile::create(Objects.first, std::move(Context)); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 430 | std::unique_ptr<SymbolizableModule> SymMod; |
| 431 | if (InfoOrErr) |
| 432 | SymMod = std::move(InfoOrErr.get()); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 433 | auto InsertResult = |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 434 | Modules.insert(std::make_pair(ModuleName, std::move(SymMod))); |
Alexey Samsonov | 884adda | 2015-11-04 00:30:24 +0000 | [diff] [blame] | 435 | assert(InsertResult.second); |
Reid Kleckner | f27f3f8 | 2016-06-03 20:25:09 +0000 | [diff] [blame] | 436 | if (auto EC = InfoOrErr.getError()) |
| 437 | return errorCodeToError(EC); |
| 438 | return InsertResult.first->second.get(); |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 439 | } |
| 440 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 441 | namespace { |
| 442 | |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 443 | // Undo these various manglings for Win32 extern "C" functions: |
| 444 | // cdecl - _foo |
| 445 | // stdcall - _foo@12 |
| 446 | // fastcall - @foo@12 |
| 447 | // vectorcall - foo@@12 |
| 448 | // These are all different linkage names for 'foo'. |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 449 | StringRef demanglePE32ExternCFunc(StringRef SymbolName) { |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 450 | // Remove any '_' or '@' prefix. |
| 451 | char Front = SymbolName.empty() ? '\0' : SymbolName[0]; |
| 452 | if (Front == '_' || Front == '@') |
| 453 | SymbolName = SymbolName.drop_front(); |
| 454 | |
| 455 | // Remove any '@[0-9]+' suffix. |
| 456 | if (Front != '?') { |
| 457 | size_t AtPos = SymbolName.rfind('@'); |
| 458 | if (AtPos != StringRef::npos && |
| 459 | std::all_of(SymbolName.begin() + AtPos + 1, SymbolName.end(), |
| 460 | [](char C) { return C >= '0' && C <= '9'; })) { |
| 461 | SymbolName = SymbolName.substr(0, AtPos); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | // Remove any ending '@' for vectorcall. |
| 466 | if (SymbolName.endswith("@")) |
| 467 | SymbolName = SymbolName.drop_back(); |
| 468 | |
| 469 | return SymbolName; |
| 470 | } |
| 471 | |
Eugene Zelenko | 35623fb | 2016-03-28 17:40:08 +0000 | [diff] [blame] | 472 | } // end anonymous namespace |
| 473 | |
Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 474 | std::string |
| 475 | LLVMSymbolizer::DemangleName(const std::string &Name, |
| 476 | const SymbolizableModule *DbiModuleDescriptor) { |
Ed Maste | ef6fed7 | 2014-01-16 17:25:12 +0000 | [diff] [blame] | 477 | // We can spoil names of symbols with C linkage, so use an heuristic |
| 478 | // approach to check if the name should be demangled. |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 479 | if (Name.substr(0, 2) == "_Z") { |
| 480 | int status = 0; |
Eugene Zemtsov | cd72cbc | 2018-03-07 23:07:34 +0000 | [diff] [blame] | 481 | char *DemangledName = itaniumDemangle(Name.c_str(), nullptr, nullptr, &status); |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 482 | if (status != 0) |
| 483 | return Name; |
| 484 | std::string Result = DemangledName; |
| 485 | free(DemangledName); |
| 486 | return Result; |
| 487 | } |
Eugene Zemtsov | cd72cbc | 2018-03-07 23:07:34 +0000 | [diff] [blame] | 488 | |
| 489 | #if defined(_MSC_VER) |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 490 | if (!Name.empty() && Name.front() == '?') { |
| 491 | // Only do MSVC C++ demangling on symbols starting with '?'. |
| 492 | char DemangledName[1024] = {0}; |
| 493 | DWORD result = ::UnDecorateSymbolName( |
| 494 | Name.c_str(), DemangledName, 1023, |
| 495 | UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected |
| 496 | UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc |
| 497 | UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications |
| 498 | UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers |
| 499 | UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords |
| 500 | UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types |
| 501 | return (result == 0) ? Name : std::string(DemangledName); |
| 502 | } |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 503 | #endif |
Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 504 | if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module()) |
Reid Kleckner | c25c794 | 2015-08-10 21:47:11 +0000 | [diff] [blame] | 505 | return std::string(demanglePE32ExternCFunc(Name)); |
| 506 | return Name; |
Alexey Samsonov | ea83baf | 2013-01-22 14:21:19 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Alexey Samsonov | d5d7bb5 | 2013-02-15 08:54:47 +0000 | [diff] [blame] | 509 | } // namespace symbolize |
| 510 | } // namespace llvm |