diff options
| author | Kevin Enderby <enderby@apple.com> | 2014-01-03 19:33:09 +0000 |
|---|---|---|
| committer | Kevin Enderby <enderby@apple.com> | 2014-01-03 19:33:09 +0000 |
| commit | b05bec7ce821b1ae624da0a6cf01365cee3062b0 (patch) | |
| tree | c26e963d07e97d2cd6f41f6e4978cd92fd721728 /llvm/lib/MC | |
| parent | 68af21c9758a318ea54fa2ac9fea5b4643d91b70 (diff) | |
| download | bcm5719-llvm-b05bec7ce821b1ae624da0a6cf01365cee3062b0.tar.gz bcm5719-llvm-b05bec7ce821b1ae624da0a6cf01365cee3062b0.zip | |
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
llvm-svn: 198441
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/MCDisassembler/Disassembler.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/MC/MCExternalSymbolizer.cpp | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp index a0066c8885c..b0b8138e711 100644 --- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp +++ b/llvm/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/llvm/lib/MC/MCExternalSymbolizer.cpp b/llvm/lib/MC/MCExternalSymbolizer.cpp index ca368b27e19..dae3f522a4f 100644 --- a/llvm/lib/MC/MCExternalSymbolizer.cpp +++ b/llvm/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) { |

