Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: runtime/vm/disassembler_arm.cc

Issue 12431016: Copies Simulator Debugger from ARM to MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/disassembler_arm.cc
===================================================================
--- runtime/vm/disassembler_arm.cc (revision 19939)
+++ runtime/vm/disassembler_arm.cc (working copy)
@@ -15,15 +15,20 @@
ARMDecoder(char* buffer, size_t buffer_size)
: buffer_(buffer),
buffer_size_(buffer_size),
- buffer_pos_(0) {
+ buffer_pos_(0),
+ decode_failure_(false) {
buffer_[buffer_pos_] = '\0';
}
~ARMDecoder() {}
// Writes one disassembled instruction into 'buffer' (0-terminated).
+ // Returns true if the instruction was successfully decoded, false otherwise.
void InstructionDecode(uword pc);
+ void DetectedDecodeFailure() { decode_failure_ = true; }
+ bool GetDecodeFailure() const { return decode_failure_; }
+
private:
// Bottleneck functions to print into the out_buffer.
void Print(const char* str);
@@ -66,6 +71,8 @@
size_t buffer_size_; // The size of the character buffer.
size_t buffer_pos_; // Current character position in buffer.
+ bool decode_failure_; // Set to true when a failure to decode is detected.
+
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(ARMDecoder);
};
@@ -572,6 +579,7 @@
// which will just print "unknown" of the instruction bits.
void ARMDecoder::Unknown(Instr* instr) {
Format(instr, "unknown");
+ DetectedDecodeFailure();
}
@@ -1210,7 +1218,8 @@
void ARMDecoder::InstructionDecode(uword pc) {
-Instr* instr = Instr::At(pc);
+ Instr* instr = Instr::At(pc);
+
if (instr->ConditionField() == kSpecialCondition) {
if (instr->InstructionBits() == static_cast<int32_t>(0xf57ff01f)) {
Format(instr, "clrex");
@@ -1258,22 +1267,26 @@
}
-int Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size,
+bool Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size,
char* human_buffer, intptr_t human_size,
- uword pc) {
+ int* out_instr_size, uword pc) {
ARMDecoder decoder(human_buffer, human_size);
decoder.InstructionDecode(pc);
int32_t instruction_bits = Instr::At(pc)->InstructionBits();
OS::SNPrint(hex_buffer, hex_size, "%08x", instruction_bits);
- return Instr::kInstrSize;
+ if (out_instr_size) {
+ *out_instr_size = Instr::kInstrSize;
+ }
+ return !decoder.GetDecodeFailure();
}
-void Disassembler::Disassemble(uword start,
+bool Disassembler::Disassemble(uword start,
uword end,
DisassemblyFormatter* formatter,
const Code::Comments& comments) {
ASSERT(formatter != NULL);
+ bool success = true;
char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
uword pc = start;
@@ -1287,11 +1300,13 @@
String::Handle(comments.CommentAt(comment_finger)).ToCString());
comment_finger++;
}
- int instruction_length = DecodeInstruction(hex_buffer,
- sizeof(hex_buffer),
- human_buffer,
- sizeof(human_buffer),
- pc);
+ int instruction_length;
+ bool res = DecodeInstruction(hex_buffer, sizeof(hex_buffer),
+ human_buffer, sizeof(human_buffer),
+ &instruction_length, pc);
+ if (!res) {
+ success = false;
+ }
formatter->ConsumeInstruction(hex_buffer,
sizeof(hex_buffer),
human_buffer,
@@ -1299,6 +1314,8 @@
pc);
pc += instruction_length;
}
+
+ return success;
}
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698