From f16c8c5162bae2f8f58a53871a1ee87708fa1e31 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Mon, 6 Jan 2014 22:08:08 +0000 Subject: 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 llvm-svn: 198637 --- llvm/lib/MC/MCExternalSymbolizer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/MC/MCExternalSymbolizer.cpp') diff --git a/llvm/lib/MC/MCExternalSymbolizer.cpp b/llvm/lib/MC/MCExternalSymbolizer.cpp index ca368b27e19..def662777d6 100644 --- a/llvm/lib/MC/MCExternalSymbolizer.cpp +++ b/llvm/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) { -- cgit v1.2.3