OLD | NEW |
1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// | 1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This program is a utility that works like traditional Unix "nm", that is, it | 10 // This program is a utility that works like traditional Unix "nm", that is, it |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 std::string ToolName; | 160 std::string ToolName; |
161 | 161 |
162 // @LOCALMOD-BEGIN | 162 // @LOCALMOD-BEGIN |
163 cl::opt<NaClFileFormat> InputFileFormat( | 163 cl::opt<NaClFileFormat> InputFileFormat( |
164 "bitcode-format", cl::desc("Define format of input file:"), | 164 "bitcode-format", cl::desc("Define format of input file:"), |
165 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"), | 165 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"), |
166 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), | 166 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), |
167 clEnumValEnd), | 167 clEnumValEnd), |
168 cl::init(LLVMFormat)); | 168 cl::init(LLVMFormat)); |
| 169 |
| 170 static cl::opt<bool> |
| 171 VerboseErrors( |
| 172 "verbose-parse-errors", |
| 173 cl::desc("Print out more descriptive PNaCl bitcode parse errors"), |
| 174 cl::init(false)); |
169 // @LOCALMOD-END | 175 // @LOCALMOD-END |
170 } | 176 } |
171 | 177 |
172 static void error(Twine Message, Twine Path = Twine()) { | 178 static void error(Twine Message, Twine Path = Twine()) { |
173 HadError = true; | 179 HadError = true; |
174 errs() << ToolName << ": " << Path << ": " << Message << ".\n"; | 180 errs() << ToolName << ": " << Path << ": " << Message << ".\n"; |
175 } | 181 } |
176 | 182 |
177 static bool error(std::error_code EC, Twine Path = Twine()) { | 183 static bool error(std::error_code EC, Twine Path = Twine()) { |
178 if (EC) { | 184 if (EC) { |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 MemoryBuffer::getFileOrSTDIN(Filename); | 1010 MemoryBuffer::getFileOrSTDIN(Filename); |
1005 if (error(BufferOrErr.getError(), Filename)) | 1011 if (error(BufferOrErr.getError(), Filename)) |
1006 return; | 1012 return; |
1007 | 1013 |
1008 LLVMContext &Context = getGlobalContext(); | 1014 LLVMContext &Context = getGlobalContext(); |
1009 | 1015 |
1010 // @LOCALMOD-BEGIN | 1016 // @LOCALMOD-BEGIN |
1011 // Support parsing PNaCl bitcode files | 1017 // Support parsing PNaCl bitcode files |
1012 /* TODO(jfb) This is currently broken: the code base now requires an Object. | 1018 /* TODO(jfb) This is currently broken: the code base now requires an Object. |
1013 if (InputFileFormat == PNaClFormat) { | 1019 if (InputFileFormat == PNaClFormat) { |
1014 std::string ErrorMessage; | 1020 std::string VerboseBuffer; |
1015 Module *Result = NaClParseBitcodeFile(BufferOrErr.get().release(), Context, | 1021 raw_string_ostream VerboseStrm(VerboseBuffer); |
1016 &ErrorMessage); | 1022 raw_ostream *Verbose = VerboseErrors ? &VerboseStrm : nullptr; |
| 1023 ErrorOr<Module *> Result = |
| 1024 NaClParseBitcodeFile(BufferOrErr.get().release(), Verbose, |
| 1025 Context); |
1017 if (Result) { | 1026 if (Result) { |
1018 DumpSymbolNamesFromModule(Result); | 1027 DumpSymbolNamesFromModule(Result.get()); |
1019 delete Result; | 1028 delete Result; |
1020 } else { | 1029 } else { |
1021 error(ErrorMessage, Filename); | 1030 error(VerboseStrm.str() + Result.message()), Filename); |
1022 return; | 1031 return; |
1023 } | 1032 } |
1024 } | 1033 } |
1025 */ | 1034 */ |
1026 // @LOCALMOD-END | 1035 // @LOCALMOD-END |
1027 | 1036 |
1028 ErrorOr<Binary *> BinaryOrErr = | 1037 ErrorOr<Binary *> BinaryOrErr = |
1029 createBinary(std::move(*BufferOrErr), &Context); | 1038 createBinary(std::move(*BufferOrErr), &Context); |
1030 if (error(BinaryOrErr.getError(), Filename)) | 1039 if (error(BinaryOrErr.getError(), Filename)) |
1031 return; | 1040 return; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 "for the -s option"); | 1274 "for the -s option"); |
1266 | 1275 |
1267 std::for_each(InputFilenames.begin(), InputFilenames.end(), | 1276 std::for_each(InputFilenames.begin(), InputFilenames.end(), |
1268 dumpSymbolNamesFromFile); | 1277 dumpSymbolNamesFromFile); |
1269 | 1278 |
1270 if (HadError) | 1279 if (HadError) |
1271 return 1; | 1280 return 1; |
1272 | 1281 |
1273 return 0; | 1282 return 0; |
1274 } | 1283 } |
OLD | NEW |