diff options
author | Owen Anderson <resistor@mac.com> | 2011-09-15 18:37:20 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2011-09-15 18:37:20 +0000 |
commit | 8f29e6969eb99410b9914bcb5ee2d9a125f07f88 (patch) | |
tree | f2325b584a2e1b3ae48d197354bd95b90f172948 /lib/MC/MCDisassembler/Disassembler.cpp | |
parent | ede042dc8d59ff48a48ef8e2271f2a7ee8324ba5 (diff) |
The the MC disassembler C API to print in verbose mode. Perhaps there should be a parameter to request verbose mode?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCDisassembler/Disassembler.cpp')
-rw-r--r-- | lib/MC/MCDisassembler/Disassembler.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index fd462f84c4..858a58cf35 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -81,6 +81,9 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, TheTarget, MAI, MRI, Ctx, DisAsm, IP); assert(DC && "Allocation failure!"); + + IP->setCommentStream(DC->CommentStream); + return DC; } @@ -154,6 +157,25 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, IP->printInst(&Inst, OS); OS.flush(); + DC->CommentStream.flush(); + assert(DC->CommentsToEmit.back() == '\n'); + + DC->CommentsToEmit.push_back('\n'); + StringRef Comments = DC->CommentsToEmit.str(); + + do { + // Emit a line of comments. + size_t Position = Comments.find('\n'); + OS << ' ' << DC->getAsmInfo()->getCommentString() + << ' ' << Comments.substr(0, Position) << '\n'; + + Comments = Comments.substr(Position+1); + } while (!Comments.empty()); + + DC->CommentsToEmit.clear(); + // Tell the comment stream that the vector changed underneath it. + DC->CommentStream.resync(); + assert(OutStringSize != 0 && "Output buffer cannot be zero size"); size_t OutputSize = std::min(OutStringSize-1, InsnStr.size()); std::memcpy(OutString, InsnStr.data(), OutputSize); |