[PATCH] Displaced stepping (non-stop debugging) support for ARM Linux

Julian Brown julian@codesourcery.com
Wed Jul 15 19:16:00 GMT 2009


Here's a new version of the ARM displaced-stepping patch, together with
a new version of the patch to always use displaced stepping if it is
enabled:

Pedro wrote:
> It would be nice to have that fixed, for sure, so yes to the
> we should fix that question.  However, it seems to me that this
> is something that can be worked on mostly independently of the ARM
> bits as it's a general software single-step issue, not really ARM
> specific.  Unless someone wants to (and has time to) tackle it
> right now, I'd say go with the always displace-step version.  If
> nothing else, helps in stressing the displaced stepping
> implementation.  :-)

As suggested here.

Dan wrote:
> Pedro wrote:
> > Care must be taken to keep  
> 
> Thanks for the plan.  I suspect this is too much to insist on before
> this patch goes in :-)

The current patch still uses a target round trip with a NOP
instruction, rather than fiddling with infrun.c to handle
fully-emulated instructions more cleanly (and/or faster). Something for
future improvement, perhaps.

Dan wrote:
> [a Linux signal handling explanation]

Thanks for that -- I think signal handling for displaced stepping now
works reasonably well, including stepping over sigreturn/rt_sigreturn
syscalls (for EABI). AFAICT the scratch space address never leaks into
the signal trampoline frame, so the potentially-disastrous results of
that happening are avoided already.

One possibly dubious part though is the positioning of the
insert_breakpoints() call in arm-linux-tdep.c:arm_linux_copy_svc():
without that, the momentary breakpoint used to regain control after a
sigreturn syscall never actually gets inserted into the debugged
program, because the displaced-step copy function gets called after
that normally happens. It should be safe AFAICT, but I may have
overlooked something.

Other things mentioned during previous review are fixed, hopefully.

Test results look reasonable, I think. "mi-nonstop.exp" tests fail in
Thumb mode, since this patch doesn't support Thumb. There's some noise
in threading results, but that's probably just bad luck.

OK to apply?

Cheers,

Julian

ChangeLog (displaced-stepping-always)

    * infrun.c (displaced_step_fixup): If this is a software
    single-stepping arch, don't tell the target to single-step.
    (maybe_software_singlestep): Return 0 if we're using displaced
    stepping.
    (resume): If this is a software single-stepping arch, and
    displaced-stepping is enabled, use it for all single-step
    requests.

ChangeLog (displaced-stepping)

    gdb/
    * arm-linux-tdep.c (arch-utils.h, inferior.h, gdbthread.h, symfile.h): Include files.
    (arm_linux_cleanup_svc, arm_linux_copy_svc): New.
    (cleanup_kernel_helper_return, arm_catch_kernel_helper_return): New.
    (arm_linux_displaced_step_copy_insn): New.
    (arm_linux_init_abi): Initialise displaced stepping callbacks.
    * arm-tdep.c (DISPLACED_STEPPING_ARCH_VERSION): New macro.
    (ARM_NOP): New.
    (displaced_read_reg, displaced_in_arm_mode, branch_write_pc)
    (bx_write_pc, load_write_pc, alu_write_pc, displaced_write_reg)
    (insn_references_pc, copy_unmodified, cleanup_preload, copy_preload)
    (copy_preload_reg, cleanup_copro_load_store, copy_copro_load_store)
    (cleanup_branch, copy_b_bl_blx, copy_bx_blx_reg, cleanup_alu_imm)
    (copy_alu_imm, cleanup_alu_reg, copy_alu_reg)
    (cleanup_alu_shifted_reg, copy_alu_shifted_reg, cleanup_load)
    (cleanup_store, copy_extra_ld_st, copy_ldr_str_ldrb_strb)
    (cleanup_block_load_all, cleanup_block_store_pc)
    (cleanup_block_load_pc, copy_block_xfer, cleanup_svc, copy_svc)
    (copy_undef, copy_unpred): New.
    (decode_misc_memhint_neon, decode_unconditional)
    (decode_miscellaneous, decode_dp_misc, decode_ld_st_word_ubyte)
    (decode_media, decode_b_bl_ldmstm, decode_ext_reg_ld_st)
    (decode_svc_copro, arm_process_displaced_insn)
    (arm_displaced_init_closure, arm_displaced_step_copy_insn)
    (arm_displaced_step_fixup): New.
    (arm_gdbarch_init): Initialise max insn length field.
    * arm-tdep.h (DISPLACED_TEMPS, DISPLACED_MODIFIED_INSNS): New
    macros.
    (displaced_step_closure, pc_write_style): New.
    (arm_displaced_init_closure, displaced_read_reg)
    (arm_process_displaced_insn, arm_displaced_init_closure, displaced_read_reg)
    (displaced_write_reg, arm_displaced_step_copy_insn, arm_displaced_step_fixup): Add
    prototypes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsf-arm-displaced-stepping-8.diff
Type: text/x-patch
Size: 88697 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20090715/019e0e4f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsf-displaced-stepping-always-3.diff
Type: text/x-patch
Size: 2501 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20090715/019e0e4f/attachment-0001.bin>


More information about the Gdb-patches mailing list