mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1309180: Add interactive disasm calls to ARM simulator. r=bbouvier
--HG-- extra : amend_source : 765d7d3bcae7357bfc0425935ea9a9df6b657c61
This commit is contained in:
parent
c0165d049a
commit
b6838e3947
@ -421,6 +421,38 @@ Simulator::Destroy(Simulator* sim)
|
||||
js_delete(sim);
|
||||
}
|
||||
|
||||
void
|
||||
Simulator::disassemble(SimInstruction* instr, size_t n)
|
||||
{
|
||||
disasm::NameConverter converter;
|
||||
disasm::Disassembler dasm(converter);
|
||||
disasm::EmbeddedVector<char, disasm::ReasonableBufferSize> buffer;
|
||||
while (n-- > 0) {
|
||||
dasm.InstructionDecode(buffer,
|
||||
reinterpret_cast<uint8_t*>(instr));
|
||||
printf(" 0x%08x %s\n", uint32_t(instr), buffer.start());
|
||||
instr = reinterpret_cast<SimInstruction*>(reinterpret_cast<uint8_t*>(instr) + 4);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Simulator::disasm(SimInstruction* instr)
|
||||
{
|
||||
disassemble(instr, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Simulator::disasm(SimInstruction* instr, size_t n)
|
||||
{
|
||||
disassemble(instr, n);
|
||||
}
|
||||
|
||||
void
|
||||
Simulator::disasm(SimInstruction* instr, size_t m, size_t n)
|
||||
{
|
||||
disassemble(reinterpret_cast<SimInstruction*>(reinterpret_cast<uint8_t*>(instr) - m * 4), n);
|
||||
}
|
||||
|
||||
// The ArmDebugger class is used by the simulator while debugging simulated ARM
|
||||
// code.
|
||||
class ArmDebugger {
|
||||
|
@ -116,6 +116,29 @@ class Simulator
|
||||
return Simulator::Current()->stackLimit();
|
||||
}
|
||||
|
||||
// Disassemble some instructions starting at instr and print them
|
||||
// on stdout. Useful for working within GDB after a MOZ_CRASH(),
|
||||
// among other things.
|
||||
//
|
||||
// Typical use within a crashed instruction decoding method is simply:
|
||||
//
|
||||
// call Simulator::disassemble(instr, 1)
|
||||
//
|
||||
// or use one of the (much) more convenient inline methods below.
|
||||
static void disassemble(SimInstruction* instr, size_t n);
|
||||
|
||||
// Disassemble one instruction.
|
||||
// "call disasm(instr)"
|
||||
void disasm(SimInstruction* instr);
|
||||
|
||||
// Disassemble n instructions starting at instr.
|
||||
// "call disasm(instr, 3)"
|
||||
void disasm(SimInstruction* instr, size_t n);
|
||||
|
||||
// Skip backwards m instructions before starting, then disassemble n instructions.
|
||||
// "call disasm(instr, 3, 7)"
|
||||
void disasm(SimInstruction* instr, size_t m, size_t n);
|
||||
|
||||
uintptr_t* addressOfStackLimit();
|
||||
|
||||
// Accessors for register state. Reading the pc value adheres to the ARM
|
||||
|
Loading…
Reference in New Issue
Block a user