Skip to content

Commit

Permalink
ptrace: move user_enable_single_step & co prototypes to linux/ptrace.h
Browse files Browse the repository at this point in the history
While in theory user_enable_single_step/user_disable_single_step/
user_enable_blockstep could also be provided as an inline or macro there's
no good reason to do so, and having the prototype in one places keeps code
size and confusion down.

Roland said:

  The original thought there was that user_enable_single_step() et al
  might well be only an instruction or three on a sane machine (as if we
  have any of those!), and since there is only one call site inlining
  would be beneficial.  But I agree that there is no strong reason to care
  about inlining it.

  As to the arch changes, there is only one thought I'd add to the
  record.  It was always my thinking that for an arch where
  PTRACE_SINGLESTEP does text-modifying breakpoint insertion,
  user_enable_single_step() should not be provided.  That is,
  arch_has_single_step()=>true means that there is an arch facility with
  "pure" semantics that does not have any unexpected side effects.
  Inserting a breakpoint might do very unexpected strange things in
  multi-threaded situations.  Aside from that, it is a peculiar side
  effect that user_{enable,disable}_single_step() should cause COW
  de-sharing of text pages and so forth.  For PTRACE_SINGLESTEP, all these
  peculiarities are the status quo ante for that arch, so having
  arch_ptrace() itself do those is one thing.  But for building other
  things in the future, it is nicer to have a uniform "pure" semantics
  that arch-independent code can expect.

  OTOH, all such arch issues are really up to the arch maintainer.  As
  of today, there is nothing but ptrace using user_enable_single_step() et
  al so it's a distinction without a practical difference.  If/when there
  are other facilities that use user_enable_single_step() and might care,
  the affected arch's can revisit the question when someone cares about
  the quality of the arch support for said new facility.

Signed-off-by: Christoph Hellwig <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Roland McGrath <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Christoph Hellwig authored and torvalds committed Mar 12, 2010

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b3c1e01 commit dacbe41
Showing 11 changed files with 6 additions and 42 deletions.
2 changes: 0 additions & 2 deletions arch/frv/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -84,8 +84,6 @@ extern void show_regs(struct pt_regs *);
#define task_pt_regs(task) ((task)->thread.frame0)

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
4 changes: 0 additions & 4 deletions arch/ia64/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -319,11 +319,7 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
ptrace_attach_sync_user_rbs(child)

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#define arch_has_block_step() (1)
extern void user_enable_block_step(struct task_struct *);

#endif /* !__KERNEL__ */

8 changes: 0 additions & 8 deletions arch/m68k/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -87,18 +87,10 @@ struct switch_stack {
#define profile_pc(regs) instruction_pointer(regs)
extern void show_regs(struct pt_regs *);

/*
* These are defined as per linux/ptrace.h.
*/
struct task_struct;

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#ifdef CONFIG_MMU
#define arch_has_block_step() (1)
extern void user_enable_block_step(struct task_struct *);
#endif

#endif /* __KERNEL__ */
2 changes: 0 additions & 2 deletions arch/mn10300/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -99,8 +99,6 @@ struct task_struct;
extern void show_regs(struct pt_regs *);

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#endif /* !__ASSEMBLY */

5 changes: 0 additions & 5 deletions arch/parisc/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -47,13 +47,8 @@ struct pt_regs {

#define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS))

struct task_struct;
#define arch_has_single_step() 1
void user_disable_single_step(struct task_struct *task);
void user_enable_single_step(struct task_struct *task);

#define arch_has_block_step() 1
void user_enable_block_step(struct task_struct *task);

/* XXX should we use iaoq[1] or iaoq[0] ? */
#define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0)
7 changes: 0 additions & 7 deletions arch/powerpc/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -137,15 +137,8 @@ do { \
} while (0)
#endif /* __powerpc64__ */

/*
* These are defined as per linux/ptrace.h, which see.
*/
#define arch_has_single_step() (1)
#define arch_has_block_step() (!cpu_has_feature(CPU_FTR_601))
extern void user_enable_single_step(struct task_struct *);
extern void user_enable_block_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#define ARCH_HAS_USER_SINGLE_STEP_INFO

#endif /* __ASSEMBLY__ */
3 changes: 0 additions & 3 deletions arch/s390/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -489,9 +489,6 @@ struct user_regs_struct
* These are defined as per linux/ptrace.h, which see.
*/
#define arch_has_single_step() (1)
struct task_struct;
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);
extern void show_regs(struct pt_regs * regs);

#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
3 changes: 1 addition & 2 deletions arch/score/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -90,8 +90,7 @@ extern int read_tsk_short(struct task_struct *, unsigned long,
unsigned short *);

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

#endif /* __KERNEL__ */

#endif /* _ASM_SCORE_PTRACE_H */
2 changes: 0 additions & 2 deletions arch/sh/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -123,8 +123,6 @@ extern void show_regs(struct pt_regs *);
struct task_struct;

#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

struct perf_event;
struct perf_sample_data;
7 changes: 0 additions & 7 deletions arch/x86/include/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -274,14 +274,7 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
return 0;
}

/*
* These are defined as per linux/ptrace.h, which see.
*/
#define arch_has_single_step() (1)
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);

extern void user_enable_block_step(struct task_struct *);
#ifdef CONFIG_X86_DEBUGCTLMSR
#define arch_has_block_step() (1)
#else
5 changes: 5 additions & 0 deletions include/linux/ptrace.h
Original file line number Diff line number Diff line change
@@ -264,6 +264,9 @@ static inline void user_enable_single_step(struct task_struct *task)
static inline void user_disable_single_step(struct task_struct *task)
{
}
#else
extern void user_enable_single_step(struct task_struct *);
extern void user_disable_single_step(struct task_struct *);
#endif /* arch_has_single_step */

#ifndef arch_has_block_step
@@ -291,6 +294,8 @@ static inline void user_enable_block_step(struct task_struct *task)
{
BUG(); /* This can never be called. */
}
#else
extern void user_enable_block_step(struct task_struct *);
#endif /* arch_has_block_step */

#ifdef ARCH_HAS_USER_SINGLE_STEP_INFO

0 comments on commit dacbe41

Please sign in to comment.