diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-03-23 18:02:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:40 -0400 |
commit | 86b6c1f301faf085de5a3f9ce16b8de6e69c729b (patch) | |
tree | 115a168d533a54f4e3dc1ed195c58b65a71d8627 /include | |
parent | 8c5cf9e5c50dc902713897e10201aa71f3546aa1 (diff) |
ptrace: simplify PTRACE_foo constants and PTRACE_SETOPTIONS code
Exchange PT_TRACESYSGOOD and PT_PTRACE_CAP bit positions, which makes
PT_option bits contiguous and therefore makes code in
ptrace_setoptions() much simpler.
Every PTRACE_O_TRACEevent is defined to (1 << PTRACE_EVENT_event)
instead of using explicit numeric constants, to ensure we don't mess up
relationship between bit positions and event ids.
PT_EVENT_FLAG_SHIFT was not particularly useful, PT_OPT_FLAG_SHIFT with
value of PT_EVENT_FLAG_SHIFT-1 is easier to use.
PT_TRACE_MASK constant is nuked, the only its use is replaced by
(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ptrace.h | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 6fdb196caa3e..6f1260ee5be5 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -54,17 +54,6 @@ | |||
54 | /* flags in @data for PTRACE_SEIZE */ | 54 | /* flags in @data for PTRACE_SEIZE */ |
55 | #define PTRACE_SEIZE_DEVEL 0x80000000 /* temp flag for development */ | 55 | #define PTRACE_SEIZE_DEVEL 0x80000000 /* temp flag for development */ |
56 | 56 | ||
57 | /* options set using PTRACE_SETOPTIONS */ | ||
58 | #define PTRACE_O_TRACESYSGOOD 0x00000001 | ||
59 | #define PTRACE_O_TRACEFORK 0x00000002 | ||
60 | #define PTRACE_O_TRACEVFORK 0x00000004 | ||
61 | #define PTRACE_O_TRACECLONE 0x00000008 | ||
62 | #define PTRACE_O_TRACEEXEC 0x00000010 | ||
63 | #define PTRACE_O_TRACEVFORKDONE 0x00000020 | ||
64 | #define PTRACE_O_TRACEEXIT 0x00000040 | ||
65 | |||
66 | #define PTRACE_O_MASK 0x0000007f | ||
67 | |||
68 | /* Wait extended result codes for the above trace options. */ | 57 | /* Wait extended result codes for the above trace options. */ |
69 | #define PTRACE_EVENT_FORK 1 | 58 | #define PTRACE_EVENT_FORK 1 |
70 | #define PTRACE_EVENT_VFORK 2 | 59 | #define PTRACE_EVENT_VFORK 2 |
@@ -74,6 +63,17 @@ | |||
74 | #define PTRACE_EVENT_EXIT 6 | 63 | #define PTRACE_EVENT_EXIT 6 |
75 | #define PTRACE_EVENT_STOP 7 | 64 | #define PTRACE_EVENT_STOP 7 |
76 | 65 | ||
66 | /* options set using PTRACE_SETOPTIONS */ | ||
67 | #define PTRACE_O_TRACESYSGOOD 1 | ||
68 | #define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK) | ||
69 | #define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK) | ||
70 | #define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE) | ||
71 | #define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC) | ||
72 | #define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE) | ||
73 | #define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT) | ||
74 | |||
75 | #define PTRACE_O_MASK 0x0000007f | ||
76 | |||
77 | #include <asm/ptrace.h> | 77 | #include <asm/ptrace.h> |
78 | 78 | ||
79 | #ifdef __KERNEL__ | 79 | #ifdef __KERNEL__ |
@@ -88,13 +88,12 @@ | |||
88 | #define PT_SEIZED 0x00010000 /* SEIZE used, enable new behavior */ | 88 | #define PT_SEIZED 0x00010000 /* SEIZE used, enable new behavior */ |
89 | #define PT_PTRACED 0x00000001 | 89 | #define PT_PTRACED 0x00000001 |
90 | #define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ | 90 | #define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ |
91 | #define PT_TRACESYSGOOD 0x00000004 | 91 | #define PT_PTRACE_CAP 0x00000004 /* ptracer can follow suid-exec */ |
92 | #define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ | ||
93 | 92 | ||
93 | #define PT_OPT_FLAG_SHIFT 3 | ||
94 | /* PT_TRACE_* event enable flags */ | 94 | /* PT_TRACE_* event enable flags */ |
95 | #define PT_EVENT_FLAG_SHIFT 4 | 95 | #define PT_EVENT_FLAG(event) (1 << (PT_OPT_FLAG_SHIFT + (event))) |
96 | #define PT_EVENT_FLAG(event) (1 << (PT_EVENT_FLAG_SHIFT + (event) - 1)) | 96 | #define PT_TRACESYSGOOD PT_EVENT_FLAG(0) |
97 | |||
98 | #define PT_TRACE_FORK PT_EVENT_FLAG(PTRACE_EVENT_FORK) | 97 | #define PT_TRACE_FORK PT_EVENT_FLAG(PTRACE_EVENT_FORK) |
99 | #define PT_TRACE_VFORK PT_EVENT_FLAG(PTRACE_EVENT_VFORK) | 98 | #define PT_TRACE_VFORK PT_EVENT_FLAG(PTRACE_EVENT_VFORK) |
100 | #define PT_TRACE_CLONE PT_EVENT_FLAG(PTRACE_EVENT_CLONE) | 99 | #define PT_TRACE_CLONE PT_EVENT_FLAG(PTRACE_EVENT_CLONE) |
@@ -102,8 +101,6 @@ | |||
102 | #define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE) | 101 | #define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE) |
103 | #define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) | 102 | #define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) |
104 | 103 | ||
105 | #define PT_TRACE_MASK 0x000003f4 | ||
106 | |||
107 | /* single stepping state bits (used on ARM and PA-RISC) */ | 104 | /* single stepping state bits (used on ARM and PA-RISC) */ |
108 | #define PT_SINGLESTEP_BIT 31 | 105 | #define PT_SINGLESTEP_BIT 31 |
109 | #define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT) | 106 | #define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT) |