summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-05-19 01:05:37 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-05-19 01:05:37 +0000
commitd74647840483ea5402cfdbdc64366b2e07709968 (patch)
tree6dff41a286e0f21efce5d942ba76df58914d408a /lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
parent5f06955aa03328e8c230db23290360aef5767916 (diff)
downloadbcm5719-llvm-d74647840483ea5402cfdbdc64366b2e07709968.tar.gz
bcm5719-llvm-d74647840483ea5402cfdbdc64366b2e07709968.zip
Make InstructionLLVM::Dump() more robust for edis in cases when all the
EDOperandIndexForToken(token) calls fail to return a meaningful operand index, resulting in both operands and comment being empty. We will use the raw disassembly string as output in these cases. There is still a known bug where llvm:tB (A8.6.16 B Encoding T2) is not being processed as a branch instruction and therefore the symbolic information is not being dumped for non-raw mode. llvm-svn: 131615
Diffstat (limited to 'lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp')
-rw-r--r--lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp60
1 files changed, 36 insertions, 24 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index fc1de902865..9be65dc11ee 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -99,6 +99,16 @@ PadString(Stream *s, const std::string &str, size_t width)
s->Printf("%s ", str.c_str());
}
+#include "llvm/ADT/StringRef.h"
+static void
+StripSpaces(llvm::StringRef &Str)
+{
+ while (!Str.empty() && isspace(Str[0]))
+ Str = Str.substr(1);
+ while (!Str.empty() && isspace(Str.back()))
+ Str = Str.substr(0, Str.size()-1);
+}
+
void
InstructionLLVM::Dump
(
@@ -230,7 +240,7 @@ InstructionLLVM::Dump
if (printTokenized)
{
- bool show_token;
+ bool show_token = false;
for (; tokenIndex < numTokens; ++tokenIndex)
{
@@ -300,40 +310,42 @@ InstructionLLVM::Dump
}
} // for (tokenIndex)
- if (printTokenized)
+ // If both operands and comment are empty, we will just print out
+ // the raw disassembly.
+ if (operands.GetString().empty() && comment.GetString().empty())
{
- if (operands.GetString().empty())
- {
- s->PutCString(opcode.GetString().c_str());
- }
+ const char *str;
+
+ if (EDGetInstString(&str, m_inst))
+ return;
+ llvm::StringRef raw_disasm(str);
+ StripSpaces(raw_disasm);
+ s->PutCString(raw_disasm.str().c_str());
+ }
+ else
+ {
+ PadString(s, opcode.GetString(), opcodeColumnWidth);
+
+ if (comment.GetString().empty())
+ s->PutCString(operands.GetString().c_str());
else
{
- PadString(s, opcode.GetString(), opcodeColumnWidth);
+ PadString(s, operands.GetString(), operandColumnWidth);
- if (comment.GetString().empty())
- {
- s->PutCString(operands.GetString().c_str());
- }
- else
- {
- PadString(s, operands.GetString(), operandColumnWidth);
-
- s->PutCString("; ");
- s->PutCString(comment.GetString().c_str());
- } // else (comment.GetString().empty())
- } // else (operands.GetString().empty())
- } // printTokenized
- } // for (tokenIndex)
+ s->PutCString("; ");
+ s->PutCString(comment.GetString().c_str());
+ } // else (comment.GetString().empty())
+ } // else (operands.GetString().empty() && comment.GetString().empty())
+ } // printTokenized
} // numTokens != -1
if (!printTokenized)
{
const char *str;
- if (EDGetInstString(&str, m_inst))
+ if (EDGetInstString(&str, m_inst)) // 0 on success
return;
- else
- s->Write(str, strlen(str) - 1);
+ s->Write(str, strlen(str) - 1);
}
}
OpenPOWER on IntegriCloud