[llvm] r198441 - For disassembly when adding a symbolic operand that is a C++
Kevin Enderby
enderby at apple.com
Fri Jan 3 11:33:09 PST 2014
Author: enderby
Date: Fri Jan 3 13:33:09 2014
New Revision: 198441
URL: http://llvm.org/viewvc/llvm-project?rev=198441&view=rev
Log:
For disassembly when adding a symbolic operand that is a C++
symbol name, also put the human readable name in a comment.
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
Modified:
llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
llvm/trunk/lib/MC/MCExternalSymbolizer.cpp
Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=198441&r1=198440&r2=198441&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Fri Jan 3 13:33:09 2014
@@ -298,6 +298,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmC
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());
Modified: llvm/trunk/lib/MC/MCExternalSymbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExternalSymbolizer.cpp?rev=198441&r1=198440&r2=198441&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExternalSymbolizer.cpp (original)
+++ llvm/trunk/lib/MC/MCExternalSymbolizer.cpp Fri Jan 3 13:33:09 2014
@@ -13,6 +13,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
+#include <cxxabi.h>
using namespace llvm;
@@ -56,6 +57,14 @@ bool MCExternalSymbolizer::tryAddingSymb
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 (strncmp(Name, "__Z", 3) == 0) {
+ char *demangled = abi::__cxa_demangle(Name + 1, 0, 0, 0);
+ if (demangled) {
+ cStream << demangled;
+ free(demangled);
+ }
+ }
}
// For branches always create an MCExpr so it gets printed as hex address.
else if (IsBranch) {
More information about the llvm-commits
mailing list