summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2014-01-03 19:33:09 +0000
committerKevin Enderby <enderby@apple.com>2014-01-03 19:33:09 +0000
commit6cedb064926bf70195d9808ae0a821b8d5214929 (patch)
treeb1063d39213487208795d49fb3341ea317aa19ae
parent8e0f67dcec577760e3bdc36f0377c6f43e1894d8 (diff)
downloadllvm-6cedb064926bf70195d9808ae0a821b8d5214929.tar.gz
llvm-6cedb064926bf70195d9808ae0a821b8d5214929.tar.bz2
llvm-6cedb064926bf70195d9808ae0a821b8d5214929.tar.xz
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198441 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp1
-rw-r--r--lib/MC/MCExternalSymbolizer.cpp9
2 files changed, 10 insertions, 0 deletions
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..dae3f522a4 100644
--- a/lib/MC/MCExternalSymbolizer.cpp
+++ b/lib/MC/MCExternalSymbolizer.cpp
@@ -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::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 (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) {