diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-10-30 15:10:08 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-10-30 15:10:58 -0400 |
commit | 136821d9f6fdb7f457500d154166a1b4b41a0d1b (patch) | |
tree | 8204382983b0abf241cd990e5731ae9ac3225e83 /gdb/amd64-tdep.c | |
parent | aa2045e7fa41ea80a876421bca89443f7a2df92f (diff) | |
download | fsf-binutils-gdb-136821d9f6fdb7f457500d154166a1b4b41a0d1b.zip fsf-binutils-gdb-136821d9f6fdb7f457500d154166a1b4b41a0d1b.tar.gz fsf-binutils-gdb-136821d9f6fdb7f457500d154166a1b4b41a0d1b.tar.bz2 |
gdb: introduce displaced_debug_printf
Move all debug prints of the "displaced" category to use a new
displaced_debug_printf macro, like what was done for infrun and others
earlier.
The debug output for one displaced step one amd64 looks like:
[displaced] displaced_step_prepare_throw: stepping process 3367044 now
[displaced] displaced_step_prepare_throw: saved 0x555555555042: 1e fa 31 ed 49 89 d1 5e 48 89 e2 48 83 e4 f0 50
[displaced] amd64_displaced_step_copy_insn: copy 0x555555555131->0x555555555042: b8 00 00 00 00 5d c3 0f 1f 84 00 00 00 00 00 f3
[displaced] displaced_step_prepare_throw: displaced pc to 0x555555555042
[displaced] resume_1: run 0x555555555042: b8 00 00 00
[displaced] displaced_step_restore: restored process 3367044 0x555555555042
[displaced] amd64_displaced_step_fixup: fixup (0x555555555131, 0x555555555042), insn = 0xb8 0x00 ...
[displaced] amd64_displaced_step_fixup: relocated %rip from 0x555555555047 to 0x555555555136
On test case needed to be updated because it relied on the specific
formatting of the message.
gdb/ChangeLog:
* 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
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-disp-step-avx.exp: Update displaced step debug
expected output.
Change-Id: Ie78837f56431f6f98378790ba1e6051337bf6533
Diffstat (limited to 'gdb/amd64-tdep.c')
-rw-r--r-- | gdb/amd64-tdep.c | 75 |
1 files changed, 25 insertions, 50 deletions
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index e801f83..57d57be 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -1438,11 +1438,10 @@ fixup_riprel (struct gdbarch *gdbarch, amd64_displaced_step_closure *dsc, 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 @@ -1504,12 +1503,9 @@ amd64_displaced_step_copy_insn (struct gdbarch *gdbarch, 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 ()); @@ -1685,20 +1681,16 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch, 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); } @@ -1743,12 +1735,7 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch, 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; @@ -1759,12 +1746,9 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch, 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)); } } @@ -1787,12 +1771,9 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch, 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)); } } @@ -1910,12 +1891,9 @@ amd64_relocate_instruction (struct gdbarch *gdbarch, 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); @@ -1939,12 +1917,9 @@ amd64_relocate_instruction (struct gdbarch *gdbarch, 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. */ |