Skip to content

Commit

Permalink
ARM: 6668/1: ptrace: remove single-step emulation code
Browse files Browse the repository at this point in the history
PTRACE_SINGLESTEP is a ptrace request designed to offer single-stepping
support to userspace when the underlying architecture has hardware
support for this operation.

On ARM, we set arch_has_single_step() to 1 and attempt to emulate hardware
single-stepping by disassembling the current instruction to determine the
next pc and placing a software breakpoint on that location.

Unfortunately this has the following problems:

1.) Only a subset of ARMv7 instructions are supported
2.) Thumb-2 is unsupported
3.) The code is not SMP safe

We could try to fix this code, but it turns out that because of the above
issues it is rarely used in practice.  GDB, for example, uses PTRACE_POKETEXT
and PTRACE_PEEKTEXT to manage breakpoints itself and does not require any
kernel assistance.

This patch removes the single-step emulation code from ptrace meaning that
the PTRACE_SINGLESTEP request will return -EIO on ARM. Portable code must
check the return value from a ptrace call and handle the failure gracefully.

Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Will Deacon authored and Russell King committed Feb 23, 2011
1 parent 5637a12 commit 425fc47
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 443 deletions.
12 changes: 0 additions & 12 deletions arch/arm/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,7 @@
#define STACK_TOP_MAX TASK_SIZE
#endif

union debug_insn {
u32 arm;
u16 thumb;
};

struct debug_entry {
u32 address;
union debug_insn insn;
};

struct debug_info {
int nsaved;
struct debug_entry bp[2];
#ifdef CONFIG_HAVE_HW_BREAKPOINT
struct perf_event *hbp[ARM_MAX_HBP_SLOTS];
#endif
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ struct pt_regs {

#ifdef __KERNEL__

#define arch_has_single_step() (1)

#define user_mode(regs) \
(((regs)->ARM_cpsr & 0xf) == 0)

Expand Down
1 change: 1 addition & 0 deletions arch/arm/include/asm/traps.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static inline int in_exception_text(unsigned long ptr)

extern void __init early_trap_init(void);
extern void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame);
extern void ptrace_break(struct task_struct *tsk, struct pt_regs *regs);

extern void *vectors_page;

Expand Down
Loading

0 comments on commit 425fc47

Please sign in to comment.