Modify 'movq reg, reg' encoding in 64-bit code.

Use 0x89 encoding (instead of 0x8B encoding), which is expected by gdb64
older than 7.3.1-gg5 when disassembling a function's prolog (movq rbp, rsp)
for proper unwinding of Dart frames (use --generate_gdb_symbols and -O0).
Review URL: https://chromiumcodereview.appspot.com//10052013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6422 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
regis@google.com 2012-04-11 18:13:09 +00:00
parent 113c4b6626
commit d1d3235013
2 changed files with 10 additions and 7 deletions

View file

@ -278,12 +278,15 @@ void Assembler::movq(Register dst, const Immediate& imm) {
}
// Use 0x89 encoding (instead of 0x8B encoding), which is expected by gdb64
// older than 7.3.1-gg5 when disassembling a function's prolog (movq rbp, rsp)
// for proper unwinding of Dart frames (use --generate_gdb_symbols and -O0).
void Assembler::movq(Register dst, Register src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
Operand operand(src);
EmitOperandREX(dst, operand, REX_W);
EmitUint8(0x8B);
EmitOperand(dst & 7, operand);
Operand operand(dst);
EmitOperandREX(src, operand, REX_W);
EmitUint8(0x89);
EmitOperand(src & 7, operand);
}

View file

@ -32,7 +32,7 @@ RawInstance* ActivationFrame::GetInstanceCallReceiver(
void CodeBreakpoint::PatchFunctionReturn() {
uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
// movq %rbp,%rsp
ASSERT((code[0] == 0x48) && (code[1] == 0x8b) && (code[2] == 0xe5));
ASSERT((code[0] == 0x48) && (code[1] == 0x89) && (code[2] == 0xec));
ASSERT(code[3] == 0x5d); // popq %rbp
ASSERT(code[4] == 0xc3); // ret
// Next 8 bytes are nop instructions
@ -56,8 +56,8 @@ void CodeBreakpoint::RestoreFunctionReturn() {
uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
ASSERT((code[0] == 0x49) && (code[1] == 0xbb));
code[0] = 0x48; // movq %rbp,%rsp
code[1] = 0x8b;
code[2] = 0xe5;
code[1] = 0x89;
code[2] = 0xec;
code[3] = 0x5d; // popq %rbp
code[4] = 0xc3; // ret
code[5] = 0x90; // nop