Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: tools/pnacl-bcdis/pnacl-bcdis.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/pnacl-bcdis/Makefile ('k') | tools/pnacl-benchmark/CMakeLists.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===-- pnacl-bcdis.cpp - Disassemble pnacl bitcode -----------------------===//
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 /// TODO(kschimpf): Add disassembling abbreviations.
11
12 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Support/FileSystem.h"
15 #include "llvm/Support/ManagedStatic.h"
16 #include "llvm/Support/MemoryBuffer.h"
17 #include "llvm/Support/PrettyStackTrace.h"
18 #include "llvm/Support/Signals.h"
19 #include "llvm/Support/ToolOutputFile.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include <system_error>
22
23 namespace {
24
25 using namespace llvm;
26
27 // The input file to read.
28 static cl::opt<std::string>
29 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
30
31 // The output file to generate.
32 static cl::opt<std::string>
33 OutputFilename("o", cl::desc("Specify output filename"),
34 cl::value_desc("filename"), cl::init("-"));
35
36 static cl::opt<bool>
37 NoRecords("no-records",
38 cl::desc("Don't include records"),
39 cl::init(false));
40
41 static cl::opt<bool>
42 NoAssembly("no-assembly",
43 cl::desc("Don't include assembly"),
44 cl::init(false));
45
46 // Reads and disassembles the bitcode file. Returns false
47 // if successful, true otherwise.
48 static bool DisassembleBitcode() {
49 // Open the bitcode file and put into a buffer.
50 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile =
51 MemoryBuffer::getFileOrSTDIN(InputFilename);
52 if (std::error_code EC = ErrOrFile.getError()) {
53 errs() << "Error reading '" << InputFilename << "': " << EC.message()
54 << "\n";
55 return true;
56 }
57
58 // Create a stream to output the bitcode text to.
59 std::error_code EC;
60 raw_fd_ostream Output(OutputFilename, EC, sys::fs::F_None);
61 if (EC) {
62 errs() << EC.message() << '\n';
63 return true;
64 }
65
66 // Parse the the bitcode file.
67 return NaClObjDump(ErrOrFile.get().release(), Output, NoRecords, NoAssembly);
68 }
69
70 }
71
72 int main(int argc, char **argv) {
73 // Print a stack trace if we signal out.
74 sys::PrintStackTraceOnErrorSignal();
75 PrettyStackTraceProgram X(argc, argv);
76 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
77 cl::ParseCommandLineOptions(argc, argv, "pnacl-bccompress file analyzer\n");
78
79 if (DisassembleBitcode()) return 1;
80 return 0;
81 }
OLDNEW
« no previous file with comments | « tools/pnacl-bcdis/Makefile ('k') | tools/pnacl-benchmark/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698