Commit 6903ecbf authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Use portable Printf formats.

BUG=

Review URL: https://codereview.chromium.org/1895843002

Cr-Commit-Position: refs/heads/master@{#35591}
parent 10413402
......@@ -586,7 +586,7 @@ void MipsDebugger::Debug() {
}
while (cur < end) {
PrintF(" 0x%08x: 0x%08x %10d",
PrintF(" 0x%08" PRIxPTR ": 0x%08x %10d",
reinterpret_cast<intptr_t>(cur), *cur, *cur);
HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
int value = *cur;
......@@ -649,8 +649,8 @@ void MipsDebugger::Debug() {
while (cur < end) {
dasm.InstructionDecode(buffer, cur);
PrintF(" 0x%08x %s\n",
reinterpret_cast<intptr_t>(cur), buffer.start());
PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur),
buffer.start());
cur += Instruction::kInstrSize;
}
} else if (strcmp(cmd, "gdb") == 0) {
......@@ -771,8 +771,8 @@ void MipsDebugger::Debug() {
while (cur < end) {
dasm.InstructionDecode(buffer, cur);
PrintF(" 0x%08x %s\n",
reinterpret_cast<intptr_t>(cur), buffer.start());
PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur),
buffer.start());
cur += Instruction::kInstrSize;
}
} else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) {
......@@ -1786,8 +1786,8 @@ void Simulator::TraceMemWr(int32_t addr, int32_t value, TraceType t) {
int Simulator::ReadW(int32_t addr, Instruction* instr) {
if (addr >=0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n",
addr, reinterpret_cast<intptr_t>(instr));
PrintF("Memory read from bad address: 0x%08x, pc=0x%08" PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
MipsDebugger dbg(this);
dbg.Debug();
}
......@@ -1808,8 +1808,8 @@ int Simulator::ReadW(int32_t addr, Instruction* instr) {
void Simulator::WriteW(int32_t addr, int value, Instruction* instr) {
if (addr >= 0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n",
addr, reinterpret_cast<intptr_t>(instr));
PrintF("Memory write to bad address: 0x%08x, pc=0x%08" PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
MipsDebugger dbg(this);
dbg.Debug();
}
......@@ -1953,7 +1953,7 @@ uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
// Unsupported instructions use Format to print an error and stop execution.
void Simulator::Format(Instruction* instr, const char* format) {
PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR ": %s\n",
reinterpret_cast<intptr_t>(instr), format);
UNIMPLEMENTED_MIPS();
}
......@@ -4413,8 +4413,9 @@ void Simulator::InstructionDecode(Instruction* instr) {
UNSUPPORTED();
}
if (::v8::internal::FLAG_trace_sim) {
PrintF(" 0x%08x %-44s %s\n", reinterpret_cast<intptr_t>(instr),
buffer.start(), trace_buf_.start());
PrintF(" 0x%08" PRIxPTR " %-44s %s\n",
reinterpret_cast<intptr_t>(instr), buffer.start(),
trace_buf_.start());
}
if (!pc_modified_) {
set_register(pc, reinterpret_cast<int32_t>(instr) +
......
......@@ -375,7 +375,8 @@ void Decoder::PrintXImm26(Instruction* instr) {
uint64_t target = static_cast<uint64_t>(instr->Imm26Value())
<< kImmFieldShift;
target = (reinterpret_cast<uint64_t>(instr) & ~0xfffffff) | target;
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%lx", target);
out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_, "0x%" PRIx64, target);
}
......@@ -801,16 +802,14 @@ int Decoder::DecodeBreakInstr(Instruction* instr) {
if (instr->Bits(25, 6) == static_cast<int>(kMaxStopCode)) {
// This is stop(msg).
Format(instr, "break, code: 'code");
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"\n%p %08lx stop msg: %s",
static_cast<void*>
(reinterpret_cast<int32_t*>(instr
+ Instruction::kInstrSize)),
reinterpret_cast<uint64_t>
(*reinterpret_cast<char**>(instr
+ Instruction::kInstrSize)),
*reinterpret_cast<char**>(instr
+ Instruction::kInstrSize));
out_buffer_pos_ += SNPrintF(
out_buffer_ + out_buffer_pos_,
"\n%p %08" PRIx64 " stop msg: %s",
static_cast<void*>(
reinterpret_cast<int32_t*>(instr + Instruction::kInstrSize)),
reinterpret_cast<uint64_t>(
*reinterpret_cast<char**>(instr + Instruction::kInstrSize)),
*reinterpret_cast<char**>(instr + Instruction::kInstrSize));
// Size 3: the break_ instr, plus embedded 64-bit char pointer.
return 3 * Instruction::kInstrSize;
} else {
......
......@@ -268,33 +268,42 @@ void MipsDebugger::PrintAllRegs() {
PrintF("\n");
// at, v0, a0.
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64
"\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n",
REG_INFO(1), REG_INFO(2), REG_INFO(4));
// v1, a1.
PrintF("%34s\t%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \n",
"", REG_INFO(3), REG_INFO(5));
// a2.
PrintF("%34s\t%34s\t%3s: 0x%016lx %14ld\n", "", "", REG_INFO(6));
PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "",
REG_INFO(6));
// a3.
PrintF("%34s\t%34s\t%3s: 0x%016lx %14ld\n", "", "", REG_INFO(7));
PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "",
REG_INFO(7));
PrintF("\n");
// a4-t3, s0-s7
for (int i = 0; i < 8; i++) {
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
REG_INFO(8+i), REG_INFO(16+i));
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \n",
REG_INFO(8 + i), REG_INFO(16 + i));
}
PrintF("\n");
// t8, k0, LO.
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n",
REG_INFO(24), REG_INFO(26), REG_INFO(32));
// t9, k1, HI.
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n",
REG_INFO(25), REG_INFO(27), REG_INFO(33));
// sp, fp, gp.
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n",
REG_INFO(29), REG_INFO(30), REG_INFO(28));
// pc.
PrintF("%3s: 0x%016lx %14ld\t%3s: 0x%016lx %14ld\n",
PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64
" %14" PRId64 " \n",
REG_INFO(31), REG_INFO(34));
#undef REG_INFO
......@@ -312,38 +321,38 @@ void MipsDebugger::PrintAllRegsIncludingFPU() {
PrintF("\n\n");
// f0, f1, f2, ... f31.
// TODO(plind): consider printing 2 columns for space efficiency.
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(0) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(1) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(2) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(3) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(4) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(5) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(6) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(7) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(8) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(9) );
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(10));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(11));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(12));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(13));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(14));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(15));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(16));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(17));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(18));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(19));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(20));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(21));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(22));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(23));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(24));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(25));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(26));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(27));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(28));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(29));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(30));
PrintF("%3s: 0x%016lx %16.4e\n", FPU_REG_INFO(31));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(0));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(1));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(2));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(3));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(4));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(5));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(6));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(7));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(8));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(9));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(10));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(11));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(12));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(13));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(14));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(15));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(16));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(17));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(18));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(19));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(20));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(21));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(22));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(23));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(24));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(25));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(26));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(27));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(28));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(29));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(30));
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(31));
#undef REG_INFO
#undef FPU_REG_INFO
......@@ -382,7 +391,7 @@ void MipsDebugger::Debug() {
v8::internal::EmbeddedVector<char, 256> buffer;
dasm.InstructionDecode(buffer,
reinterpret_cast<byte*>(sim_->get_pc()));
PrintF(" 0x%016lx %s\n", sim_->get_pc(), buffer.start());
PrintF(" 0x%016" PRIx64 " %s\n", sim_->get_pc(), buffer.start());
last_pc = sim_->get_pc();
}
char* line = ReadLine("sim> ");
......@@ -433,11 +442,12 @@ void MipsDebugger::Debug() {
if (regnum != kInvalidRegister) {
value = GetRegisterValue(regnum);
PrintF("%s: 0x%08lx %ld \n", arg1, value, value);
PrintF("%s: 0x%08" PRIx64 " %" PRId64 " \n", arg1, value,
value);
} else if (fpuregnum != kInvalidFPURegister) {
value = GetFPURegisterValue(fpuregnum);
dvalue = GetFPURegisterValueDouble(fpuregnum);
PrintF("%3s: 0x%016lx %16.4e\n",
PrintF("%3s: 0x%016" PRIx64 " %16.4e\n",
FPURegisters::Name(fpuregnum), value, dvalue);
} else {
PrintF("%s unrecognized\n", arg1);
......@@ -454,7 +464,7 @@ void MipsDebugger::Debug() {
value = GetFPURegisterValue(fpuregnum);
value &= 0xffffffffUL;
fvalue = GetFPURegisterValueFloat(fpuregnum);
PrintF("%s: 0x%08lx %11.4e\n", arg1, value, fvalue);
PrintF("%s: 0x%08" PRIx64 " %11.4e\n", arg1, value, fvalue);
} else {
PrintF("%s unrecognized\n", arg1);
}
......@@ -513,7 +523,7 @@ void MipsDebugger::Debug() {
end = cur + words;
while (cur < end) {
PrintF(" 0x%012lx: 0x%016lx %14ld",
PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ",
reinterpret_cast<intptr_t>(cur), *cur, *cur);
HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
int64_t value = *cur;
......@@ -576,8 +586,8 @@ void MipsDebugger::Debug() {
while (cur < end) {
dasm.InstructionDecode(buffer, cur);
PrintF(" 0x%08lx %s\n",
reinterpret_cast<intptr_t>(cur), buffer.start());
PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur),
buffer.start());
cur += Instruction::kInstrSize;
}
} else if (strcmp(cmd, "gdb") == 0) {
......@@ -698,8 +708,8 @@ void MipsDebugger::Debug() {
while (cur < end) {
dasm.InstructionDecode(buffer, cur);
PrintF(" 0x%08lx %s\n",
reinterpret_cast<intptr_t>(cur), buffer.start());
PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur),
buffer.start());
cur += Instruction::kInstrSize;
}
} else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) {
......@@ -1683,7 +1693,7 @@ void Simulator::DieOrDebug() {
void Simulator::TraceRegWr(int64_t value) {
if (::v8::internal::FLAG_trace_sim) {
SNPrintF(trace_buf_, "%016lx", value);
SNPrintF(trace_buf_, "%016" PRIx64 " ", value);
}
}
......@@ -1691,8 +1701,9 @@ void Simulator::TraceRegWr(int64_t value) {
// TODO(plind): consider making icount_ printing a flag option.
void Simulator::TraceMemRd(int64_t addr, int64_t value) {
if (::v8::internal::FLAG_trace_sim) {
SNPrintF(trace_buf_, "%016lx <-- [%016lx] (%ld)",
value, addr, icount_);
SNPrintF(trace_buf_,
"%016" PRIx64 " <-- [%016" PRIx64 " ] (%" PRId64 " )", value,
addr, icount_);
}
}
......@@ -1701,19 +1712,20 @@ void Simulator::TraceMemWr(int64_t addr, int64_t value, TraceType t) {
if (::v8::internal::FLAG_trace_sim) {
switch (t) {
case BYTE:
SNPrintF(trace_buf_, " %02x --> [%016lx]",
SNPrintF(trace_buf_, " %02x --> [%016" PRIx64 " ]",
static_cast<int8_t>(value), addr);
break;
case HALF:
SNPrintF(trace_buf_, " %04x --> [%016lx]",
SNPrintF(trace_buf_, " %04x --> [%016" PRIx64 " ]",
static_cast<int16_t>(value), addr);
break;
case WORD:
SNPrintF(trace_buf_, " %08x --> [%016lx]",
SNPrintF(trace_buf_, " %08x --> [%016" PRIx64 " ]",
static_cast<int32_t>(value), addr);
break;
case DWORD:
SNPrintF(trace_buf_, "%016lx --> [%016lx] (%ld)",
SNPrintF(trace_buf_,
"%016" PRIx64 " --> [%016" PRIx64 " ] (%" PRId64 " )",
value, addr, icount_);
break;
}
......@@ -1726,7 +1738,8 @@ void Simulator::TraceMemWr(int64_t addr, int64_t value, TraceType t) {
int32_t Simulator::ReadW(int64_t addr, Instruction* instr) {
if (addr >=0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory read from bad address: 0x%08lx, pc=0x%08lx\n",
PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR
" \n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1735,8 +1748,7 @@ int32_t Simulator::ReadW(int64_t addr, Instruction* instr) {
TraceMemRd(addr, static_cast<int64_t>(*ptr));
return *ptr;
}
PrintF("Unaligned read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
DieOrDebug();
return 0;
......@@ -1746,7 +1758,8 @@ int32_t Simulator::ReadW(int64_t addr, Instruction* instr) {
uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) {
if (addr >=0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory read from bad address: 0x%08lx, pc=0x%08lx\n",
PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR
" \n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1755,8 +1768,7 @@ uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) {
TraceMemRd(addr, static_cast<int64_t>(*ptr));
return *ptr;
}
PrintF("Unaligned read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
DieOrDebug();
return 0;
......@@ -1766,7 +1778,8 @@ uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) {
void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) {
if (addr >= 0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory write to bad address: 0x%08lx, pc=0x%08lx\n",
PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR
" \n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1776,8 +1789,7 @@ void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) {
*ptr = value;
return;
}
PrintF("Unaligned write at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1786,7 +1798,8 @@ void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) {
int64_t Simulator::Read2W(int64_t addr, Instruction* instr) {
if (addr >=0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory read from bad address: 0x%08lx, pc=0x%08lx\n",
PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR
" \n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1795,8 +1808,7 @@ int64_t Simulator::Read2W(int64_t addr, Instruction* instr) {
TraceMemRd(addr, *ptr);
return *ptr;
}
PrintF("Unaligned read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
DieOrDebug();
return 0;
......@@ -1806,7 +1818,8 @@ int64_t Simulator::Read2W(int64_t addr, Instruction* instr) {
void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) {
if (addr >= 0 && addr < 0x400) {
// This has to be a NULL-dereference, drop into debugger.
PrintF("Memory write to bad address: 0x%08lx, pc=0x%08lx\n",
PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR
"\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1816,8 +1829,7 @@ void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) {
*ptr = value;
return;
}
PrintF("Unaligned write at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr,
reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1828,9 +1840,8 @@ double Simulator::ReadD(int64_t addr, Instruction* instr) {
double* ptr = reinterpret_cast<double*>(addr);
return *ptr;
}
PrintF("Unaligned (double) read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned (double) read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n",
addr, reinterpret_cast<intptr_t>(instr));
base::OS::Abort();
return 0;
}
......@@ -1842,9 +1853,9 @@ void Simulator::WriteD(int64_t addr, double value, Instruction* instr) {
*ptr = value;
return;
}
PrintF("Unaligned (double) write at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned (double) write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR
"\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1855,9 +1866,9 @@ uint16_t Simulator::ReadHU(int64_t addr, Instruction* instr) {
TraceMemRd(addr, static_cast<int64_t>(*ptr));
return *ptr;
}
PrintF("Unaligned unsigned halfword read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned unsigned halfword read at 0x%08" PRIx64
" , pc=0x%08" V8PRIxPTR "\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
return 0;
}
......@@ -1869,9 +1880,9 @@ int16_t Simulator::ReadH(int64_t addr, Instruction* instr) {
TraceMemRd(addr, static_cast<int64_t>(*ptr));
return *ptr;
}
PrintF("Unaligned signed halfword read at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned signed halfword read at 0x%08" PRIx64
" , pc=0x%08" V8PRIxPTR "\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
return 0;
}
......@@ -1884,10 +1895,9 @@ void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) {
*ptr = value;
return;
}
PrintF(
"Unaligned unsigned halfword write at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned unsigned halfword write at 0x%08" PRIx64
" , pc=0x%08" V8PRIxPTR "\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1899,9 +1909,9 @@ void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) {
*ptr = value;
return;
}
PrintF("Unaligned halfword write at 0x%08lx, pc=0x%08" V8PRIxPTR "\n",
addr,
reinterpret_cast<intptr_t>(instr));
PrintF("Unaligned halfword write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR
"\n",
addr, reinterpret_cast<intptr_t>(instr));
DieOrDebug();
}
......@@ -1950,7 +1960,7 @@ uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
// Unsupported instructions use Format to print an error and stop execution.
void Simulator::Format(Instruction* instr, const char* format) {
PrintF("Simulator found unsupported instruction:\n 0x%08lx: %s\n",
PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR " : %s\n",
reinterpret_cast<intptr_t>(instr), format);
UNIMPLEMENTED_MIPS();
}
......@@ -2133,8 +2143,8 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
}
} else if (redirection->type() == ExternalReference::DIRECT_API_CALL) {
if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08lx\n",
reinterpret_cast<void*>(external), arg0);
PrintF("Call to host function at %p args %08" PRIx64 " \n",
reinterpret_cast<void*>(external), arg0);
}
SimulatorRuntimeDirectApiCall target =
reinterpret_cast<SimulatorRuntimeDirectApiCall>(external);
......@@ -2142,8 +2152,9 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
} else if (
redirection->type() == ExternalReference::PROFILING_API_CALL) {
if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08lx %08lx\n",
reinterpret_cast<void*>(external), arg0, arg1);
PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64
" \n",
reinterpret_cast<void*>(external), arg0, arg1);
}
SimulatorRuntimeProfilingApiCall target =
reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external);
......@@ -2151,8 +2162,9 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
} else if (
redirection->type() == ExternalReference::DIRECT_GETTER_CALL) {
if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08lx %08lx\n",
reinterpret_cast<void*>(external), arg0, arg1);
PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64
" \n",
reinterpret_cast<void*>(external), arg0, arg1);
}
SimulatorRuntimeDirectGetterCall target =
reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external);
......@@ -2160,8 +2172,9 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
} else if (
redirection->type() == ExternalReference::PROFILING_GETTER_CALL) {
if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08lx %08lx %08lx\n",
reinterpret_cast<void*>(external), arg0, arg1, arg2);
PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64
" %08" PRIx64 " \n",
reinterpret_cast<void*>(external), arg0, arg1, arg2);
}
SimulatorRuntimeProfilingGetterCall target =
reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external);
......@@ -2195,14 +2208,9 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
if (::v8::internal::FLAG_trace_sim) {
PrintF(
"Call to host function at %p "
"args %08lx, %08lx, %08lx, %08lx, %08lx, %08lx\n",
FUNCTION_ADDR(target),
arg0,
arg1,
arg2,
arg3,
arg4,
arg5);
"args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64
" , %08" PRIx64 " , %08" PRIx64 " \n",
FUNCTION_ADDR(target), arg0, arg1, arg2, arg3, arg4, arg5);
}
// int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5);
// set_register(v0, static_cast<int32_t>(result));
......@@ -2212,7 +2220,8 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
set_register(v1, (int64_t)(result.y));
}
if (::v8::internal::FLAG_trace_sim) {
PrintF("Returned %08lx : %08lx\n", get_register(v1), get_register(v0));
PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(v1),
get_register(v0));
}
set_register(ra, saved_ra);
set_pc(get_register(ra));
......@@ -2241,7 +2250,8 @@ bool Simulator::IsWatchpoint(uint64_t code) {
void Simulator::PrintWatchpoint(uint64_t code) {
MipsDebugger dbg(this);
++break_count_;
PrintF("\n---- break %ld marker: %3d (instr count: %8ld) ----------"
PrintF("\n---- break %" PRId64 " marker: %3d (instr count: %8" PRId64
" ) ----------"
"----------------------------------",
code, break_count_, icount_);
dbg.PrintAllRegs(); // Print registers and continue running.
......@@ -2291,8 +2301,10 @@ void Simulator::DisableStop(uint64_t code) {
void Simulator::IncreaseStopCounter(uint64_t code) {
DCHECK(code <= kMaxStopCode);
if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) {
PrintF("Stop counter for code %ld has overflowed.\n"
"Enabling this code and reseting the counter to 0.\n", code);
PrintF("Stop counter for code %" PRId64
" has overflowed.\n"
"Enabling this code and reseting the counter to 0.\n",
code);
watched_stops_[code].count = 0;
EnableStop(code);
} else {
......@@ -2315,11 +2327,11 @@ void Simulator::PrintStopInfo(uint64_t code) {
// Don't print the state of unused breakpoints.
if (count != 0) {
if (watched_stops_[code].desc) {
PrintF("stop %ld - 0x%lx: \t%s, \tcounter = %i, \t%s\n",
PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i, \t%s\n",
code, code, state, count, watched_stops_[code].desc);
} else {
PrintF("stop %ld - 0x%lx: \t%s, \tcounter = %i\n",
code, code, state, count);
PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i\n", code,
code, state, count);
}
}
}
......@@ -4672,8 +4684,9 @@ void Simulator::InstructionDecode(Instruction* instr) {
}
if (::v8::internal::FLAG_trace_sim) {
PrintF(" 0x%08lx %-44s %s\n", reinterpret_cast<intptr_t>(instr),
buffer.start(), trace_buf_.start());
PrintF(" 0x%08" PRIxPTR " %-44s %s\n",
reinterpret_cast<intptr_t>(instr), buffer.start(),
trace_buf_.start());
}
if (!pc_modified_) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment