+2020-10-30 Simon Marchi <simon.marchi@efficios.com>
+
+ * infrun.h (displaced_debug_printf): New macro. Replace
+ displaced debug prints throughout to use it.
+ (displaced_debug_printf_1): New declaration.
+ (displaced_step_dump_bytes): Return string, remove ui_file
+ parameter, update all callers.
+ * infrun.c (displaced_debug_printf_1): New function.
+ (displaced_step_dump_bytes): Return string, remove ui_file
+ parameter
+
2020-10-30 Simon Marchi <simon.marchi@polymtl.ca>
* rs6000-tdep.c (rs6000_dwarf2_reg_to_regnum): Return -1 for
relocated instruction(s) there. */
for (i = 0; i < dsd.insn_count; i++)
{
- if (debug_displaced)
- {
- debug_printf ("displaced: writing insn ");
- debug_printf ("%.8x", dsd.insn_buf[i]);
- debug_printf (" at %s\n", paddress (gdbarch, to + i * 4));
- }
+ displaced_debug_printf ("writing insn %.8x at %s",
+ dsd.insn_buf[i],
+ paddress (gdbarch, to + i * 4));
+
write_memory_unsigned_integer (to + i * 4, 4, byte_order_for_code,
(ULONGEST) dsd.insn_buf[i]);
}
regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc);
- if (debug_displaced)
- debug_printf ("Displaced: PC after stepping: %s (was %s).\n",
- paddress (gdbarch, pc), paddress (gdbarch, to));
+ displaced_debug_printf ("PC after stepping: %s (was %s).",
+ paddress (gdbarch, pc), paddress (gdbarch, to));
if (dsc->cond)
{
- if (debug_displaced)
- debug_printf ("Displaced: [Conditional] pc_adjust before: %d\n",
- dsc->pc_adjust);
+ displaced_debug_printf ("[Conditional] pc_adjust before: %d",
+ dsc->pc_adjust);
if (pc - to == 8)
{
else
gdb_assert_not_reached ("Unexpected PC value after displaced stepping");
- if (debug_displaced)
- debug_printf ("Displaced: [Conditional] pc_adjust after: %d\n",
- dsc->pc_adjust);
+ displaced_debug_printf ("[Conditional] pc_adjust after: %d",
+ dsc->pc_adjust);
}
- if (debug_displaced)
- debug_printf ("Displaced: %s PC by %d\n",
- dsc->pc_adjust? "adjusting" : "not adjusting",
- dsc->pc_adjust);
-
+ displaced_debug_printf ("%s PC by %d",
+ dsc->pc_adjust ? "adjusting" : "not adjusting",
+ dsc->pc_adjust);
if (dsc->pc_adjust != 0)
{
took place. */
if ((pc - to) == 0)
{
- if (debug_displaced)
- debug_printf ("Displaced: PC did not move. Discarding PC "
- "adjustment.\n");
+ displaced_debug_printf ("PC did not move. Discarding PC adjustment.");
dsc->pc_adjust = 0;
}
- if (debug_displaced)
- {
- debug_printf ("Displaced: fixup: set PC to %s:%d\n",
- paddress (gdbarch, from), dsc->pc_adjust);
- }
+ displaced_debug_printf ("fixup: set PC to %s:%d",
+ paddress (gdbarch, from), dsc->pc_adjust);
+
regcache_cooked_write_unsigned (regs, AARCH64_PC_REGNUM,
from + dsc->pc_adjust);
}
regcache_cooked_write_unsigned (regs, tmp_regno, rip_base);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: %%rip-relative addressing used.\n"
- "displaced: using temp reg %d, old value %s, new value %s\n",
- dsc->tmp_regno, paddress (gdbarch, dsc->tmp_save),
- paddress (gdbarch, rip_base));
+ displaced_debug_printf ("%%rip-relative addressing used.");
+ displaced_debug_printf ("using temp reg %d, old value %s, new value %s",
+ dsc->tmp_regno, paddress (gdbarch, dsc->tmp_save),
+ paddress (gdbarch, rip_base));
}
static void
write_memory (to, buf, len);
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
- paddress (gdbarch, from), paddress (gdbarch, to));
- displaced_step_dump_bytes (gdb_stdlog, buf, len);
- }
+ displaced_debug_printf ("copy %s->%s: %s",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ displaced_step_dump_bytes (buf, len).c_str ());
/* This is a work around for a problem with g++ 4.8. */
return displaced_step_closure_up (dsc.release ());
gdb_byte *insn = dsc->insn_buf.data ();
const struct amd64_insn *insn_details = &dsc->insn_details;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: fixup (%s, %s), "
- "insn = 0x%02x 0x%02x ...\n",
- paddress (gdbarch, from), paddress (gdbarch, to),
- insn[0], insn[1]);
+ displaced_debug_printf ("fixup (%s, %s), insn = 0x%02x 0x%02x ...",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ insn[0], insn[1]);
/* If we used a tmp reg, restore it. */
if (dsc->tmp_used)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: restoring reg %d to %s\n",
- dsc->tmp_regno, paddress (gdbarch, dsc->tmp_save));
+ displaced_debug_printf ("restoring reg %d to %s",
+ dsc->tmp_regno, paddress (gdbarch, dsc->tmp_save));
regcache_cooked_write_unsigned (regs, dsc->tmp_regno, dsc->tmp_save);
}
Presumably this is a kernel bug.
Fixup ensures its a nop, we add one to the length for it. */
&& orig_rip != to + insn_len + 1)
- {
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: syscall changed %%rip; "
- "not relocating\n");
- }
+ displaced_debug_printf ("syscall changed %%rip; not relocating");
else
{
ULONGEST rip = orig_rip - insn_offset;
regcache_cooked_write_unsigned (regs, AMD64_RIP_REGNUM, rip);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: "
- "relocated %%rip from %s to %s\n",
- paddress (gdbarch, orig_rip),
- paddress (gdbarch, rip));
+ displaced_debug_printf ("relocated %%rip from %s to %s",
+ paddress (gdbarch, orig_rip),
+ paddress (gdbarch, rip));
}
}
retaddr = (retaddr - insn_offset) & 0xffffffffffffffffULL;
write_memory_unsigned_integer (rsp, retaddr_len, byte_order, retaddr);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: relocated return addr at %s "
- "to %s\n",
- paddress (gdbarch, rsp),
- paddress (gdbarch, retaddr));
+ displaced_debug_printf ("relocated return addr at %s to %s",
+ paddress (gdbarch, rsp),
+ paddress (gdbarch, retaddr));
}
}
newrel = (oldloc - *to) + rel32;
store_signed_integer (insn + 1, 4, byte_order, newrel);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "Adjusted insn rel32=%s at %s to"
- " rel32=%s at %s\n",
- hex_string (rel32), paddress (gdbarch, oldloc),
- hex_string (newrel), paddress (gdbarch, *to));
+ displaced_debug_printf ("adjusted insn rel32=%s at %s to rel32=%s at %s",
+ hex_string (rel32), paddress (gdbarch, oldloc),
+ hex_string (newrel), paddress (gdbarch, *to));
/* Write the adjusted jump into its displaced location. */
append_insns (to, 5, insn);
rel32 = extract_signed_integer (insn + offset, 4, byte_order);
newrel = (oldloc - *to) + rel32;
store_signed_integer (insn + offset, 4, byte_order, newrel);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "Adjusted insn rel32=%s at %s to"
- " rel32=%s at %s\n",
- hex_string (rel32), paddress (gdbarch, oldloc),
- hex_string (newrel), paddress (gdbarch, *to));
+ displaced_debug_printf ("adjusted insn rel32=%s at %s to rel32=%s at %s",
+ hex_string (rel32), paddress (gdbarch, oldloc),
+ hex_string (newrel), paddress (gdbarch, *to));
}
/* Write the adjusted instruction into its displaced location. */
&& apparent_pc < (dsc->scratch_base
+ ARM_DISPLACED_MODIFIED_INSNS * 4 + 4));
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: PC is apparently %.8lx after "
- "SVC step ", (unsigned long) apparent_pc);
- if (within_scratch)
- fprintf_unfiltered (gdb_stdlog, "(within scratch space)\n");
- else
- fprintf_unfiltered (gdb_stdlog, "(outside scratch space)\n");
- }
+ displaced_debug_printf ("PC is apparently %.8lx after SVC step %s",
+ (unsigned long) apparent_pc,
+ (within_scratch
+ ? "(within scratch space)"
+ : "(outside scratch space)"));
if (within_scratch)
displaced_write_reg (regs, dsc, ARM_PC_REGNUM,
{
struct symtab_and_line sal;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: found "
- "sigreturn/rt_sigreturn SVC call. PC in "
- "frame = %lx\n",
- (unsigned long) get_frame_pc (frame));
+ displaced_debug_printf ("found sigreturn/rt_sigreturn SVC call. "
+ "PC in frame = %lx",
+ (unsigned long) get_frame_pc (frame));
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: unwind pc = %lx. "
- "Setting momentary breakpoint.\n",
- (unsigned long) return_to);
+ displaced_debug_printf ("unwind pc = %lx. Setting momentary breakpoint.",
+ (unsigned long) return_to);
gdb_assert (inferior_thread ()->control.step_resume_breakpoint
== NULL);
breakpoint set above. */
insert_breakpoints ();
}
- else if (debug_displaced)
- fprintf_unfiltered (gdb_stderr, "displaced: couldn't find previous "
- "frame to set momentary breakpoint for "
- "sigreturn/rt_sigreturn\n");
+ else
+ displaced_debug_printf ("couldn't find previous frame to set momentary "
+ "breakpoint for sigreturn/rt_sigreturn");
}
- else if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: found SVC call\n");
+ else
+ displaced_debug_printf ("found SVC call");
/* Preparation: If we detect sigreturn, set momentary breakpoint at resume
location, else nothing.
stop at the return location. */
if (from > 0xffff0000)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: detected kernel helper "
- "at %.8lx\n", (unsigned long) from);
+ displaced_debug_printf ("detected kernel helper at %.8lx",
+ (unsigned long) from);
arm_catch_kernel_helper_return (gdbarch, from, to, regs, dsc.get ());
}
should be determined by instruction on the original address. */
if (dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: check mode of %.8lx instead of %.8lx\n",
- (unsigned long) dsc->insn_addr,
- (unsigned long) memaddr);
+ displaced_debug_printf ("check mode of %.8lx instead of %.8lx",
+ (unsigned long) dsc->insn_addr,
+ (unsigned long) memaddr);
memaddr = dsc->insn_addr;
}
else
from += 4;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: read pc value %.8lx\n",
- (unsigned long) from);
+ displaced_debug_printf ("read pc value %.8lx",
+ (unsigned long) from);
return (ULONGEST) from;
}
else
{
regcache_cooked_read_unsigned (regs, regno, &ret);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: read r%d value %.8lx\n",
- regno, (unsigned long) ret);
+
+ displaced_debug_printf ("read r%d value %.8lx",
+ regno, (unsigned long) ret);
+
return ret;
}
}
{
if (regno == ARM_PC_REGNUM)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: writing pc %.8lx\n",
- (unsigned long) val);
+ displaced_debug_printf ("writing pc %.8lx", (unsigned long) val);
+
switch (write_pc)
{
case BRANCH_WRITE_PC:
}
else
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: writing r%d value %.8lx\n",
- regno, (unsigned long) val);
+ displaced_debug_printf ("writing r%d value %.8lx",
+ regno, (unsigned long) val);
regcache_cooked_write_unsigned (regs, regno, val);
}
}
arm_copy_unmodified (struct gdbarch *gdbarch, uint32_t insn,
const char *iname, arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.8lx, "
- "opcode/class '%s' unmodified\n", (unsigned long) insn,
- iname);
+ displaced_debug_printf ("copying insn %.8lx, opcode/class '%s' unmodified",
+ (unsigned long) insn, iname);
dsc->modinsn[0] = insn;
uint16_t insn2, const char *iname,
arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.4x %.4x, "
- "opcode/class '%s' unmodified\n", insn1, insn2,
- iname);
+ displaced_debug_printf ("copying insn %.4x %.4x, opcode/class '%s' "
+ "unmodified", insn1, insn2, iname);
dsc->modinsn[0] = insn1;
dsc->modinsn[1] = insn2;
const char *iname,
arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.4x, "
- "opcode/class '%s' unmodified\n", insn,
- iname);
+ displaced_debug_printf ("copying insn %.4x, opcode/class '%s' unmodified",
+ insn, iname);
dsc->modinsn[0] = insn;
if (!insn_references_pc (insn, 0x000f0000ul))
return arm_copy_unmodified (gdbarch, insn, "preload", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying preload insn %.8lx\n",
- (unsigned long) insn);
+ displaced_debug_printf ("copying preload insn %.8lx", (unsigned long) insn);
dsc->modinsn[0] = insn & 0xfff0ffff;
/* PC is only allowed to use in PLI (immediate,literal) Encoding T3, and
PLD (literal) Encoding T1. */
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying pld/pli pc (0x%x) %c imm12 %.4x\n",
- (unsigned int) dsc->insn_addr, u_bit ? '+' : '-',
- imm12);
+ displaced_debug_printf ("copying pld/pli pc (0x%x) %c imm12 %.4x",
+ (unsigned int) dsc->insn_addr, u_bit ? '+' : '-',
+ imm12);
if (!u_bit)
imm12 = -1 * imm12;
if (!insn_references_pc (insn, 0x000f000ful))
return arm_copy_unmodified (gdbarch, insn, "preload reg", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying preload insn %.8lx\n",
- (unsigned long) insn);
+ displaced_debug_printf ("copying preload insn %.8lx",
+ (unsigned long) insn);
dsc->modinsn[0] = (insn & 0xfff0fff0) | 0x1;
if (!insn_references_pc (insn, 0x000f0000ul))
return arm_copy_unmodified (gdbarch, insn, "copro load/store", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying coprocessor "
- "load/store insn %.8lx\n", (unsigned long) insn);
+ displaced_debug_printf ("copying coprocessor load/store insn %.8lx",
+ (unsigned long) insn);
dsc->modinsn[0] = insn & 0xfff0ffff;
return thumb_copy_unmodified_32bit (gdbarch, insn1, insn2,
"copro load/store", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying coprocessor "
- "load/store insn %.4x%.4x\n", insn1, insn2);
+ displaced_debug_printf ("copying coprocessor load/store insn %.4x%.4x",
+ insn1, insn2);
dsc->modinsn[0] = insn1 & 0xfff0;
dsc->modinsn[1] = insn2;
int link = exchange || bit (insn, 24);
long offset;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying %s immediate insn "
- "%.8lx\n", (exchange) ? "blx" : (link) ? "bl" : "b",
- (unsigned long) insn);
+ displaced_debug_printf ("copying %s immediate insn %.8lx",
+ (exchange) ? "blx" : (link) ? "bl" : "b",
+ (unsigned long) insn);
if (exchange)
/* For BLX, set bit 0 of the destination. The cleanup_branch function will
then arrange the switch into Thumb mode. */
(bits (insn2, 1, 10) << 2) : (bits (insn2, 0, 10) << 1);
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying %s insn "
- "%.4x %.4x with offset %.8lx\n",
- link ? (exchange) ? "blx" : "bl" : "b",
- insn1, insn2, offset);
+ displaced_debug_printf ("copying %s insn %.4x %.4x with offset %.8lx",
+ link ? (exchange) ? "blx" : "bl" : "b",
+ insn1, insn2, offset);
dsc->modinsn[0] = THUMB_NOP;
cond = INST_AL;
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying b immediate insn %.4x "
- "with offset %d\n", insn, offset);
+ displaced_debug_printf ("copying b immediate insn %.4x with offset %d",
+ insn, offset);
dsc->u.branch.cond = cond;
dsc->u.branch.link = 0;
int link = bit (insn, 5);
unsigned int rm = bits (insn, 0, 3);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.8lx",
- (unsigned long) insn);
+ displaced_debug_printf ("copying insn %.8lx", (unsigned long) insn);
dsc->modinsn[0] = ARM_NOP;
int link = bit (insn, 7);
unsigned int rm = bits (insn, 3, 6);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.4x",
- (unsigned short) insn);
+ displaced_debug_printf ("copying insn %.4x", (unsigned short) insn);
dsc->modinsn[0] = THUMB_NOP;
if (!insn_references_pc (insn, 0x000ff000ul))
return arm_copy_unmodified (gdbarch, insn, "ALU immediate", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying immediate %s insn "
- "%.8lx\n", is_mov ? "move" : "ALU",
- (unsigned long) insn);
+ displaced_debug_printf ("copying immediate %s insn %.8lx",
+ is_mov ? "move" : "ALU",
+ (unsigned long) insn);
/* Instruction is of form:
if (rm != ARM_PC_REGNUM && rd != ARM_PC_REGNUM)
return thumb_copy_unmodified_32bit (gdbarch, insn1, insn2, "ALU imm", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying reg %s insn %.4x%.4x\n",
- "ALU", insn1, insn2);
+ displaced_debug_printf ("copying reg %s insn %.4x%.4x", "ALU", insn1, insn2);
/* Instruction is of form:
if (!insn_references_pc (insn, 0x000ff00ful))
return arm_copy_unmodified (gdbarch, insn, "ALU reg", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying reg %s insn %.8lx\n",
- is_mov ? "move" : "ALU", (unsigned long) insn);
+ displaced_debug_printf ("copying reg %s insn %.8lx",
+ is_mov ? "move" : "ALU", (unsigned long) insn);
if (is_mov)
dsc->modinsn[0] = (insn & 0xfff00ff0) | 0x2;
if (rd != ARM_PC_REGNUM && rm != ARM_PC_REGNUM)
return thumb_copy_unmodified_16bit (gdbarch, insn, "ALU reg", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying ALU reg insn %.4x\n",
- (unsigned short) insn);
+ displaced_debug_printf ("copying ALU reg insn %.4x", (unsigned short) insn);
dsc->modinsn[0] = ((insn & 0xff00) | 0x10);
if (!insn_references_pc (insn, 0x000fff0ful))
return arm_copy_unmodified (gdbarch, insn, "ALU shifted reg", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying shifted reg %s insn "
- "%.8lx\n", is_mov ? "move" : "ALU",
- (unsigned long) insn);
+ displaced_debug_printf ("copying shifted reg %s insn %.8lx",
+ is_mov ? "move" : "ALU",
+ (unsigned long) insn);
rn = bits (insn, 16, 19);
rm = bits (insn, 0, 3);
if (!insn_references_pc (insn, 0x000ff00ful))
return arm_copy_unmodified (gdbarch, insn, "extra load/store", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying %sextra load/store "
- "insn %.8lx\n", unprivileged ? "unprivileged " : "",
- (unsigned long) insn);
+ displaced_debug_printf ("copying %sextra load/store insn %.8lx",
+ unprivileged ? "unprivileged " : "",
+ (unsigned long) insn);
opcode = ((op2 << 2) | (op1 & 0x1) | ((op1 & 0x4) >> 1)) - 4;
int imm12 = bits (insn2, 0, 11);
ULONGEST pc_val;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying ldr pc (0x%x) R%d %c imm12 %.4x\n",
- (unsigned int) dsc->insn_addr, rt, u_bit ? '+' : '-',
- imm12);
+ displaced_debug_printf ("copying ldr pc (0x%x) R%d %c imm12 %.4x",
+ (unsigned int) dsc->insn_addr, rt, u_bit ? '+' : '-',
+ imm12);
if (!u_bit)
imm12 = -1 * imm12;
return thumb_copy_unmodified_32bit (gdbarch, insn1, insn2, "load",
dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying ldr r%d [r%d] insn %.4x%.4x\n",
- rt, rn, insn1, insn2);
+ displaced_debug_printf ("copying ldr r%d [r%d] insn %.4x%.4x",
+ rt, rn, insn1, insn2);
install_load_store (gdbarch, regs, dsc, 1, immed, writeback, 4,
0, rt, rm, rn);
if (!insn_references_pc (insn, 0x000ff00ful))
return arm_copy_unmodified (gdbarch, insn, "load/store", dsc);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying %s%s r%d [r%d] insn %.8lx\n",
- load ? (size == 1 ? "ldrb" : "ldr")
- : (size == 1 ? "strb" : "str"), usermode ? "t" : "",
- rt, rn,
- (unsigned long) insn);
+ displaced_debug_printf ("copying %s%s r%d [r%d] insn %.8lx",
+ load ? (size == 1 ? "ldrb" : "ldr")
+ : (size == 1 ? "strb" : "str"),
+ usermode ? "t" : "",
+ rt, rn,
+ (unsigned long) insn);
install_load_store (gdbarch, regs, dsc, load, immed, writeback, size,
usermode, rt, rm, rn);
/* We don't handle any stores here for now. */
gdb_assert (dsc->u.block.load != 0);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: emulating block transfer: "
- "%s %s %s\n", dsc->u.block.load ? "ldm" : "stm",
- dsc->u.block.increment ? "inc" : "dec",
- dsc->u.block.before ? "before" : "after");
+ displaced_debug_printf ("emulating block transfer: %s %s %s",
+ dsc->u.block.load ? "ldm" : "stm",
+ dsc->u.block.increment ? "inc" : "dec",
+ dsc->u.block.before ? "before" : "after");
while (regmask)
{
stm_insn_addr = dsc->scratch_base;
offset = pc_val - stm_insn_addr;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: detected PC offset %.8lx for "
- "STM instruction\n", offset);
+ displaced_debug_printf ("detected PC offset %.8lx for STM instruction",
+ offset);
/* Rewrite the stored PC to the proper value for the non-displaced original
instruction. */
{
ULONGEST rval = displaced_read_reg (regs, dsc, read_reg);
displaced_write_reg (regs, dsc, write_reg, rval, LOAD_WRITE_PC);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: LDM: move "
- "loaded register r%d to r%d\n"), read_reg,
- write_reg);
+ displaced_debug_printf ("LDM: move loaded register r%d to r%d",
+ read_reg, write_reg);
}
- else if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: LDM: register "
- "r%d already in the right place\n"),
- write_reg);
+ else
+ displaced_debug_printf ("LDM: register r%d already in the right "
+ "place", write_reg);
clobbered &= ~(1 << write_reg);
{
displaced_write_reg (regs, dsc, write_reg, dsc->tmp[write_reg],
CANNOT_WRITE_PC);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: LDM: restored "
- "clobbered register r%d\n"), write_reg);
+ displaced_debug_printf ("LDM: restored clobbered register r%d",
+ write_reg);
clobbered &= ~(1 << write_reg);
}
}
return arm_copy_unmodified (gdbarch, insn, "unpredictable ldm/stm", dsc);
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying block transfer insn "
- "%.8lx\n", (unsigned long) insn);
+ displaced_debug_printf ("copying block transfer insn %.8lx",
+ (unsigned long) insn);
dsc->u.block.xfer_addr = displaced_read_reg (regs, dsc, rn);
dsc->u.block.rn = rn;
new_regmask = (1 << num_in_list) - 1;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: LDM r%d%s, "
- "{..., pc}: original reg list %.4x, modified "
- "list %.4x\n"), rn, writeback ? "!" : "",
- (int) insn & 0xffff, new_regmask);
+ displaced_debug_printf ("LDM r%d%s, {..., pc}: original reg list "
+ "%.4x, modified list %.4x",
+ rn, writeback ? "!" : "",
+ (int) insn & 0xffff, new_regmask);
dsc->modinsn[0] = (insn & ~0xffff) | (new_regmask & 0xffff);
"unpredictable ldm/stm", dsc);
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying block transfer insn "
- "%.4x%.4x\n", insn1, insn2);
+ displaced_debug_printf ("copying block transfer insn %.4x%.4x",
+ insn1, insn2);
/* Clear bit 13, since it should be always zero. */
dsc->u.block.regmask = (insn2 & 0xdfff);
new_regmask = (1 << num_in_list) - 1;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: LDM r%d%s, "
- "{..., pc}: original reg list %.4x, modified "
- "list %.4x\n"), rn, writeback ? "!" : "",
- (int) dsc->u.block.regmask, new_regmask);
+ displaced_debug_printf ("LDM r%d%s, {..., pc}: original reg list "
+ "%.4x, modified list %.4x",
+ rn, writeback ? "!" : "",
+ (int) dsc->u.block.regmask, new_regmask);
dsc->modinsn[0] = insn1;
dsc->modinsn[1] = (new_regmask & 0xffff);
{
CORE_ADDR resume_addr = dsc->insn_addr + dsc->insn_size;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: cleanup for svc, resume at "
- "%.8lx\n", (unsigned long) resume_addr);
+ displaced_debug_printf ("cleanup for svc, resume at %.8lx",
+ (unsigned long) resume_addr);
displaced_write_reg (regs, dsc, ARM_PC_REGNUM, resume_addr, BRANCH_WRITE_PC);
}
struct regcache *regs, arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying svc insn %.8lx\n",
- (unsigned long) insn);
+ displaced_debug_printf ("copying svc insn %.8lx",
+ (unsigned long) insn);
dsc->modinsn[0] = insn;
struct regcache *regs, arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying svc insn %.4x\n",
- insn);
+ displaced_debug_printf ("copying svc insn %.4x", insn);
dsc->modinsn[0] = insn;
arm_copy_undef (struct gdbarch *gdbarch, uint32_t insn,
arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying undefined insn %.8lx\n",
- (unsigned long) insn);
+ displaced_debug_printf ("copying undefined insn %.8lx",
+ (unsigned long) insn);
dsc->modinsn[0] = insn;
arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying undefined insn "
- "%.4x %.4x\n", (unsigned short) insn1,
- (unsigned short) insn2);
+ displaced_debug_printf ("copying undefined insn %.4x %.4x",
+ (unsigned short) insn1, (unsigned short) insn2);
dsc->modinsn[0] = insn1;
dsc->modinsn[1] = insn2;
arm_copy_unpred (struct gdbarch *gdbarch, uint32_t insn,
arm_displaced_step_closure *dsc)
{
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying unpredictable insn "
- "%.8lx\n", (unsigned long) insn);
+ displaced_debug_printf ("copying unpredictable insn %.8lx",
+ (unsigned long) insn);
dsc->modinsn[0] = insn;
unsigned int rd = bits (insn, 8, 10);
unsigned int imm8 = bits (insn, 0, 7);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying thumb adr r%d, #%d insn %.4x\n",
- rd, imm8, insn);
+ displaced_debug_printf ("copying thumb adr r%d, #%d insn %.4x",
+ rd, imm8, insn);
return thumb_copy_pc_relative_16bit (gdbarch, regs, dsc, rd, imm8);
}
unsigned int imm_3_8 = insn2 & 0x70ff;
unsigned int imm_i = insn1 & 0x0400; /* Clear all bits except bit 10. */
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying thumb adr r%d, #%d:%d insn %.4x%.4x\n",
- rd, imm_i, imm_3_8, insn1, insn2);
+ displaced_debug_printf ("copying thumb adr r%d, #%d:%d insn %.4x%.4x",
+ rd, imm_i, imm_3_8, insn1, insn2);
if (bit (insn1, 7)) /* Encoding T2 */
{
Insn: LDR R0, [R2, R3];
Cleanup: R2 <- tmp2, R3 <- tmp3, Rd <- R0, R0 <- tmp0 */
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying thumb ldr r%d [pc #%d]\n"
- , rt, imm8);
+ displaced_debug_printf ("copying thumb ldr r%d [pc #%d]", rt, imm8);
dsc->tmp[0] = displaced_read_reg (regs, dsc, 0);
dsc->tmp[2] = displaced_read_reg (regs, dsc, 2);
dsc->u.branch.link = 0;
dsc->u.branch.exchange = 0;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying %s [r%d = 0x%x]"
- " insn %.4x to %.8lx\n", non_zero ? "cbnz" : "cbz",
- rn, rn_val, insn1, dsc->u.branch.dest);
+ displaced_debug_printf ("copying %s [r%d = 0x%x] insn %.4x to %.8lx",
+ non_zero ? "cbnz" : "cbz",
+ rn, rn_val, insn1, dsc->u.branch.dest);
dsc->modinsn[0] = THUMB_NOP;
halfwords = extract_unsigned_integer (buf, 1, byte_order);
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: %s base 0x%x offset 0x%x"
- " offset 0x%x\n", is_tbh ? "tbh" : "tbb",
- (unsigned int) rn_val, (unsigned int) rm_val,
- (unsigned int) halfwords);
+ displaced_debug_printf ("%s base 0x%x offset 0x%x offset 0x%x",
+ is_tbh ? "tbh" : "tbb",
+ (unsigned int) rn_val, (unsigned int) rm_val,
+ (unsigned int) halfwords);
dsc->u.branch.cond = INST_AL;
dsc->u.branch.link = 0;
Cleanup: Set registers in original reglist from r0 - rN. Restore r0 - rN
from tmp[] properly.
*/
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: copying thumb pop {%.8x, pc} insn %.4x\n",
- dsc->u.block.regmask, insn1);
+ displaced_debug_printf ("copying thumb pop {%.8x, pc} insn %.4x",
+ dsc->u.block.regmask, insn1);
if (dsc->u.block.regmask == 0xff)
{
new_regmask = (1 << (num_in_list + 1)) - 1;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, _("displaced: POP "
- "{..., pc}: original reg list %.4x,"
- " modified list %.4x\n"),
- (int) dsc->u.block.regmask, new_regmask);
+ displaced_debug_printf ("POP {..., pc}: original reg list %.4x, "
+ "modified list %.4x",
+ (int) dsc->u.block.regmask, new_regmask);
dsc->u.block.regmask |= 0x8000;
dsc->u.block.writeback = 0;
uint16_t insn1
= read_memory_unsigned_integer (from, 2, byte_order_for_code);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: process thumb insn %.4x "
- "at %.8lx\n", insn1, (unsigned long) from);
+ displaced_debug_printf ("process thumb insn %.4x at %.8lx",
+ insn1, (unsigned long) from);
dsc->is_thumb = 1;
dsc->insn_size = thumb_insn_size (insn1);
dsc->is_thumb = 0;
dsc->insn_size = 4;
insn = read_memory_unsigned_integer (from, 4, byte_order_for_code);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: stepping insn %.8lx "
- "at %.8lx\n", (unsigned long) insn,
- (unsigned long) from);
+ displaced_debug_printf ("stepping insn %.8lx at %.8lx",
+ (unsigned long) insn, (unsigned long) from);
if ((insn & 0xf0000000) == 0xf0000000)
err = arm_decode_unconditional (gdbarch, insn, regs, dsc);
/* Poke modified instruction(s). */
for (i = 0; i < dsc->numinsns; i++)
{
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: writing insn ");
- if (size == 4)
- fprintf_unfiltered (gdb_stdlog, "%.8lx",
- dsc->modinsn[i]);
- else if (size == 2)
- fprintf_unfiltered (gdb_stdlog, "%.4x",
- (unsigned short)dsc->modinsn[i]);
-
- fprintf_unfiltered (gdb_stdlog, " at %.8lx\n",
- (unsigned long) to + offset);
+ if (size == 4)
+ displaced_debug_printf ("writing insn %.8lx at %.8lx",
+ dsc->modinsn[i], (unsigned long) to + offset);
+ else if (size == 2)
+ displaced_debug_printf ("writing insn %.4x at %.8lx",
+ (unsigned short) dsc->modinsn[i],
+ (unsigned long) to + offset);
- }
write_memory_unsigned_integer (to + offset, size,
byte_order_for_code,
dsc->modinsn[i]);
/* Put breakpoint afterwards. */
write_memory (to + offset, bkp_insn, len);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
- paddress (gdbarch, from), paddress (gdbarch, to));
+ displaced_debug_printf ("copy %s->%s", paddress (gdbarch, from),
+ paddress (gdbarch, to));
}
/* Entry point for cleaning things up after a displaced instruction has been
write_memory (to, buf, len);
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
- paddress (gdbarch, from), paddress (gdbarch, to));
- displaced_step_dump_bytes (gdb_stdlog, buf, len);
- }
+ displaced_debug_printf ("%s->%s: %s",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ displaced_step_dump_bytes (buf, len).c_str ());
/* This is a work around for a problem with g++ 4.8. */
return displaced_step_closure_up (closure.release ());
/* The start of the insn, needed in case we see some prefixes. */
gdb_byte *insn_start = insn;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: fixup (%s, %s), "
- "insn = 0x%02x 0x%02x ...\n",
- paddress (gdbarch, from), paddress (gdbarch, to),
- insn[0], insn[1]);
+ displaced_debug_printf ("fixup (%s, %s), insn = 0x%02x 0x%02x ...",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ insn[0], insn[1]);
/* The list of issues to contend with here is taken from
resume_execution in arch/i386/kernel/kprobes.c, Linux 2.6.20.
Presumably this is a kernel bug.
i386_displaced_step_copy_insn ensures its a nop,
we add one to the length for it. */
- && orig_eip != to + (insn - insn_start) + insn_len + 1)
- {
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: syscall changed %%eip; "
- "not relocating\n");
- }
+ && orig_eip != to + (insn - insn_start) + insn_len + 1)
+ displaced_debug_printf ("syscall changed %%eip; not relocating");
else
{
ULONGEST eip = (orig_eip - insn_offset) & 0xffffffffUL;
regcache_cooked_write_unsigned (regs, I386_EIP_REGNUM, eip);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: "
- "relocated %%eip from %s to %s\n",
- paddress (gdbarch, orig_eip),
- paddress (gdbarch, eip));
+ displaced_debug_printf ("relocated %%eip from %s to %s",
+ paddress (gdbarch, orig_eip),
+ paddress (gdbarch, eip));
}
}
retaddr = (retaddr - insn_offset) & 0xffffffffUL;
write_memory_unsigned_integer (esp, retaddr_len, byte_order, retaddr);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: relocated return addr at %s to %s\n",
- paddress (gdbarch, esp),
- paddress (gdbarch, retaddr));
+ displaced_debug_printf ("relocated return addr at %s to %s",
+ paddress (gdbarch, esp),
+ paddress (gdbarch, retaddr));
}
}
newrel = (oldloc - *to) + rel32;
store_signed_integer (insn + 1, 4, byte_order, newrel);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "Adjusted insn rel32=%s at %s to"
- " rel32=%s at %s\n",
- hex_string (rel32), paddress (gdbarch, oldloc),
- hex_string (newrel), paddress (gdbarch, *to));
+ displaced_debug_printf ("adjusted insn rel32=%s at %s to rel32=%s at %s",
+ hex_string (rel32), paddress (gdbarch, oldloc),
+ hex_string (newrel), paddress (gdbarch, *to));
/* Write the adjusted jump into its displaced location. */
append_insns (to, 5, insn);
rel32 = extract_signed_integer (insn + offset, 4, byte_order);
newrel = (oldloc - *to) + rel32;
store_signed_integer (insn + offset, 4, byte_order, newrel);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "Adjusted insn rel32=%s at %s to"
- " rel32=%s at %s\n",
- hex_string (rel32), paddress (gdbarch, oldloc),
- hex_string (newrel), paddress (gdbarch, *to));
+ displaced_debug_printf ("adjusted insn rel32=%s at %s to rel32=%s at %s",
+ hex_string (rel32), paddress (gdbarch, oldloc),
+ hex_string (newrel), paddress (gdbarch, *to));
}
/* Write the adjusted instructions into their displaced
fprintf_filtered (file, _("Inferior debugging is %s.\n"), value);
}
+/* See infrun.h. */
+
+void
+displaced_debug_printf_1 (const char *func_name, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ debug_prefixed_vprintf ("displaced", func_name, fmt, ap);
+ va_end (ap);
+}
/* Support for disabling address space randomization. */
using displaced_step_reset_cleanup = FORWARD_SCOPE_EXIT (displaced_step_reset);
-/* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */
-void
-displaced_step_dump_bytes (struct ui_file *file,
- const gdb_byte *buf,
- size_t len)
+/* See infrun.h. */
+
+std::string
+displaced_step_dump_bytes (const gdb_byte *buf, size_t len)
{
- int i;
+ std::string ret;
- for (i = 0; i < len; i++)
- fprintf_unfiltered (file, "%02x ", buf[i]);
- fputs_unfiltered ("\n", file);
+ for (size_t i = 0; i < len; i++)
+ {
+ if (i == 0)
+ ret += string_printf ("%02x", buf[i]);
+ else
+ ret += string_printf (" %02x", buf[i]);
+ }
+
+ return ret;
}
/* Prepare to single-step, using displaced stepping.
/* Already waiting for a displaced step to finish. Defer this
request and place in queue. */
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: deferring step of %s\n",
- target_pid_to_str (tp->ptid).c_str ());
+ displaced_debug_printf ("deferring step of %s",
+ target_pid_to_str (tp->ptid).c_str ());
thread_step_over_chain_enqueue (tp);
return 0;
}
else
- {
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: stepping %s now\n",
+ displaced_debug_printf ("stepping %s now",
target_pid_to_str (tp->ptid).c_str ());
- }
displaced_step_reset (displaced);
in the scratch pad range (after initial startup) anyway, but
the former is unacceptable. Simply punt and fallback to
stepping over this breakpoint in-line. */
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog,
- "displaced: breakpoint set in scratch pad. "
- "Stepping over breakpoint in-line instead.\n");
- }
+ displaced_debug_printf ("breakpoint set in scratch pad. "
+ "Stepping over breakpoint in-line instead.");
return -1;
}
_("Error accessing memory address %s (%s) for "
"displaced-stepping scratch space."),
paddress (gdbarch, copy), safe_strerror (status));
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: saved %s: ",
- paddress (gdbarch, copy));
- displaced_step_dump_bytes (gdb_stdlog,
- displaced->step_saved_copy.data (),
- len);
- };
+
+ displaced_debug_printf ("saved %s: %s",
+ paddress (gdbarch, copy),
+ displaced_step_dump_bytes
+ (displaced->step_saved_copy.data (), len).c_str ());
displaced->step_closure
= gdbarch_displaced_step_copy_insn (gdbarch, original, copy, regcache);
cleanup.release ();
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: displaced pc to %s\n",
- paddress (gdbarch, copy));
+ displaced_debug_printf ("displaced pc to %s", paddress (gdbarch, copy));
return 1;
}
write_memory_ptid (ptid, displaced->step_copy,
displaced->step_saved_copy.data (), len);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: restored %s %s\n",
- target_pid_to_str (ptid).c_str (),
- paddress (displaced->step_gdbarch,
- displaced->step_copy));
+
+ displaced_debug_printf ("restored %s %s",
+ target_pid_to_str (ptid).c_str (),
+ paddress (displaced->step_gdbarch,
+ displaced->step_copy));
}
/* If we displaced stepped an instruction successfully, adjust
CORE_ADDR actual_pc = regcache_read_pc (resume_regcache);
gdb_byte buf[4];
- fprintf_unfiltered (gdb_stdlog, "displaced: run %s: ",
- paddress (resume_gdbarch, actual_pc));
read_memory (actual_pc, buf, sizeof (buf));
- displaced_step_dump_bytes (gdb_stdlog, buf, sizeof (buf));
+ displaced_debug_printf ("run %s: %s",
+ paddress (resume_gdbarch, actual_pc),
+ displaced_step_dump_bytes
+ (buf, sizeof (buf)).c_str ());
}
if (tp->control.may_range_step)
/* Read PC value of parent process. */
parent_pc = regcache_read_pc (regcache);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: write child pc from %s to %s\n",
- paddress (gdbarch,
- regcache_read_pc (child_regcache)),
- paddress (gdbarch, parent_pc));
+ displaced_debug_printf ("write child pc from %s to %s",
+ paddress (gdbarch,
+ regcache_read_pc (child_regcache)),
+ paddress (gdbarch, parent_pc));
regcache_write_pc (child_regcache, parent_pc);
}
/* True if we are debugging displaced stepping. */
extern bool debug_displaced;
+/* Print a "displaced" debug statement. Should be used through
+ displaced_debug_printf. */
+void ATTRIBUTE_PRINTF (2, 3) displaced_debug_printf_1
+ (const char *func_name, const char *fmt, ...);
+
+#define displaced_debug_printf(fmt, ...) \
+ do \
+ { \
+ if (debug_displaced) \
+ displaced_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
+ } \
+ while (0)
+
/* Nonzero if we want to give control to the user when we're notified
of shared library events by the dynamic linker. */
extern int stop_on_solib_events;
$_exitsignal. */
extern void clear_exit_convenience_vars (void);
-/* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */
-extern void displaced_step_dump_bytes (struct ui_file *file,
- const gdb_byte *buf, size_t len);
+/* Dump LEN bytes at BUF in hex to a string and return it. */
+extern std::string displaced_step_dump_bytes (const gdb_byte *buf, size_t len);
extern struct displaced_step_closure *get_displaced_step_closure_by_addr
(CORE_ADDR addr);
/* Assume all atomic sequences start with a Load and Reserve instruction. */
if (IS_LOAD_AND_RESERVE_INSN (insn))
{
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog,
- "displaced: can't displaced step "
- "atomic sequence at %s\n",
+ displaced_debug_printf ("can't displaced step atomic sequence at %s",
paddress (gdbarch, from));
- }
return NULL;
}
write_memory (to, buf, len);
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
- paddress (gdbarch, from), paddress (gdbarch, to));
- displaced_step_dump_bytes (gdb_stdlog, buf, len);
- }
+ displaced_debug_printf ("copy %s->%s: %s",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ displaced_step_dump_bytes (buf, len).c_str ());;
/* This is a work around for a problem with g++ 4.8. */
return displaced_step_closure_up (closure.release ());
opcode = insn & BRANCH_MASK;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: (ppc) fixup (%s, %s)\n",
- paddress (gdbarch, from), paddress (gdbarch, to));
-
+ displaced_debug_printf ("(ppc) fixup (%s, %s)",
+ paddress (gdbarch, from), paddress (gdbarch, to));
/* Handle PC-relative branch instructions. */
if (opcode == B_INSN || opcode == BC_INSN || opcode == BXL_INSN)
if (!(insn & 0x2))
{
/* PC-relative addressing is being used in the branch. */
- if (debug_displaced)
- fprintf_unfiltered
- (gdb_stdlog,
- "displaced: (ppc) branch instruction: %s\n"
- "displaced: (ppc) adjusted PC from %s to %s\n",
- paddress (gdbarch, insn), paddress (gdbarch, current_pc),
- paddress (gdbarch, from + offset));
+ displaced_debug_printf ("(ppc) branch instruction: %s",
+ paddress (gdbarch, insn));
+ displaced_debug_printf ("(ppc) adjusted PC from %s to %s",
+ paddress (gdbarch, current_pc),
+ paddress (gdbarch, from + offset));
regcache_cooked_write_unsigned (regs,
gdbarch_pc_regnum (gdbarch),
regcache_cooked_write_unsigned (regs,
gdbarch_tdep (gdbarch)->ppc_lr_regnum,
from + PPC_INSN_SIZE);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: (ppc) adjusted LR to %s\n",
- paddress (gdbarch, from + PPC_INSN_SIZE));
+ displaced_debug_printf ("(ppc) adjusted LR to %s",
+ paddress (gdbarch, from + PPC_INSN_SIZE));
}
}
{
/* Let the core fall back to stepping over the breakpoint
in-line. */
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog,
- "displaced: can't displaced step "
- "RIL instruction: offset %s out of range\n",
- plongest (offset));
- }
+ displaced_debug_printf ("can't displaced step RIL instruction: offset "
+ "%s out of range", plongest (offset));
return NULL;
}
write_memory (to, buf, len);
- if (debug_displaced)
- {
- fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
- paddress (gdbarch, from), paddress (gdbarch, to));
- displaced_step_dump_bytes (gdb_stdlog, buf, len);
- }
+ displaced_debug_printf ("copy %s->%s: %s",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ displaced_step_dump_bytes (buf, len).c_str ());
/* This is a work around for a problem with g++ 4.8. */
return displaced_step_closure_up (closure.release ());
amode &= 0x80000000;
}
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: (s390) fixup (%s, %s) pc %s len %d amode 0x%x\n",
- paddress (gdbarch, from), paddress (gdbarch, to),
- paddress (gdbarch, pc), insnlen, (int) amode);
+ displaced_debug_printf ("(s390) fixup (%s, %s) pc %s len %d amode 0x%x",
+ paddress (gdbarch, from), paddress (gdbarch, to),
+ paddress (gdbarch, pc), insnlen, (int) amode);
/* Handle absolute branch and save instructions. */
int op_basr_p = is_rr (insn, op_basr, &r1, &r2);
else
regcache_write_pc (regs, pc - to + from);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog,
- "displaced: (s390) pc is now %s\n",
- paddress (gdbarch, regcache_read_pc (regs)));
+ displaced_debug_printf ("(s390) pc is now %s",
+ paddress (gdbarch, regcache_read_pc (regs)));
}
/* Implement displaced_step_hw_singlestep gdbarch method. */
+2020-10-30 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdb.arch/amd64-disp-step-avx.exp: Update displaced step debug
+ expected output.
+
2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/paginate-after-ctrl-c-running.exp: Update with no pagination
gdb_test_no_output "set debug displaced on"
gdb_test "continue" \
- "Continuing.*displaced: displaced pc to.*Breakpoint.*, ${test_end_label} ().*" \
+ "Continuing.*displaced pc to.*Breakpoint.*, ${test_end_label} ().*" \
"continue to ${test_end_label}"
gdb_test_no_output "set debug displaced off"