diff options
author | Kevin Enderby <enderby@apple.com> | 2014-01-06 22:08:08 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2014-01-06 22:08:08 +0000 |
commit | 284c8bc4b0c1642e0feced9d9b7416b08a4d1b5d (patch) | |
tree | 2341ab83744c8d209f6dd5a0956ea7bb8caebbab | |
parent | 177648336ab01faf4cee8a105a5f237642c23e98 (diff) | |
download | llvm-284c8bc4b0c1642e0feced9d9b7416b08a4d1b5d.tar.gz llvm-284c8bc4b0c1642e0feced9d9b7416b08a4d1b5d.tar.bz2 llvm-284c8bc4b0c1642e0feced9d9b7416b08a4d1b5d.tar.xz |
For the 'C' disassembler API, add a new ReferenceType for the
SymbolLookUp() call back to return a demangled C++ name to
be used as a comment.
For example darwin's otool(1) program the uses the llvm
disassembler now can produce disassembly like:
callq __ZNK4llvm6Target20createMCDisassemblerERKNS_15MCSubtargetInfoE ## llvm::Target::createMCDisassembler(llvm::MCSubtargetInfo const&) const
Also fix a bug in LLVMDisasmInstruction() that was not flushing
the raw_svector_ostream for the disassembled instruction string
before copying it to the output buffer that was causing truncation
of the output.
rdar://10173828
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198637 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm-c/Disassembler.h | 3 | ||||
-rw-r--r-- | lib/MC/MCDisassembler/Disassembler.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCExternalSymbolizer.cpp | 3 |
3 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index 79bcfcdab9..aec037e16b 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -141,6 +141,9 @@ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo, /* The output reference is to a Objective-C class ref. */ #define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8 +/* The output reference is to a C++ symbol name. */ +#define LLVMDisassembler_ReferenceType_DeMangled_Name 9 + #ifdef __cplusplus extern "C" { #endif /* !defined(__cplusplus) */ diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index a0066c8885..b0b8138e71 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -298,6 +298,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, emitLatency(DC, Inst); emitComments(DC, FormattedOS); + OS.flush(); assert(OutStringSize != 0 && "Output buffer cannot be zero size"); size_t OutputSize = std::min(OutStringSize-1, InsnStr.size()); diff --git a/lib/MC/MCExternalSymbolizer.cpp b/lib/MC/MCExternalSymbolizer.cpp index ca368b27e1..def662777d 100644 --- a/lib/MC/MCExternalSymbolizer.cpp +++ b/lib/MC/MCExternalSymbolizer.cpp @@ -56,6 +56,9 @@ bool MCExternalSymbolizer::tryAddingSymbolicOperand(MCInst &MI, if (Name) { SymbolicOp.AddSymbol.Name = Name; SymbolicOp.AddSymbol.Present = true; + // If Name is a C++ symbol name put the human readable name in a comment. + if(ReferenceType == LLVMDisassembler_ReferenceType_DeMangled_Name) + cStream << ReferenceName; } // For branches always create an MCExpr so it gets printed as hex address. else if (IsBranch) { |