Skip to content

Commit c17497f

Browse files
nixprimeshentubot
authored andcommitted
Move ptrace constants to abi/linux.
PiperOrigin-RevId: 204188763
1 parent 513d48f commit c17497f

File tree

4 files changed

+179
-99
lines changed

4 files changed

+179
-99
lines changed

pkg/abi/linux/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ go_library(
4848
"netlink_route.go",
4949
"poll.go",
5050
"prctl.go",
51+
"ptrace.go",
5152
"rusage.go",
5253
"sched.go",
5354
"seccomp.go",

pkg/abi/linux/ptrace.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 2018 Google Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package linux
16+
17+
// ptrace commands from include/uapi/linux/ptrace.h.
18+
const (
19+
PTRACE_TRACEME = 0
20+
PTRACE_PEEKTEXT = 1
21+
PTRACE_PEEKDATA = 2
22+
PTRACE_PEEKUSR = 3
23+
PTRACE_POKETEXT = 4
24+
PTRACE_POKEDATA = 5
25+
PTRACE_POKEUSR = 6
26+
PTRACE_CONT = 7
27+
PTRACE_KILL = 8
28+
PTRACE_SINGLESTEP = 9
29+
PTRACE_ATTACH = 16
30+
PTRACE_DETACH = 17
31+
PTRACE_SYSCALL = 24
32+
PTRACE_SETOPTIONS = 0x4200
33+
PTRACE_GETEVENTMSG = 0x4201
34+
PTRACE_GETSIGINFO = 0x4202
35+
PTRACE_SETSIGINFO = 0x4203
36+
PTRACE_GETREGSET = 0x4204
37+
PTRACE_SETREGSET = 0x4205
38+
PTRACE_SEIZE = 0x4206
39+
PTRACE_INTERRUPT = 0x4207
40+
PTRACE_LISTEN = 0x4208
41+
PTRACE_PEEKSIGINFO = 0x4209
42+
PTRACE_GETSIGMASK = 0x420a
43+
PTRACE_SETSIGMASK = 0x420b
44+
PTRACE_SECCOMP_GET_FILTER = 0x420c
45+
PTRACE_SECCOMP_GET_METADATA = 0x420d
46+
)
47+
48+
// ptrace commands from arch/x86/include/uapi/asm/ptrace-abi.h.
49+
const (
50+
PTRACE_GETREGS = 12
51+
PTRACE_SETREGS = 13
52+
PTRACE_GETFPREGS = 14
53+
PTRACE_SETFPREGS = 15
54+
PTRACE_GETFPXREGS = 18
55+
PTRACE_SETFPXREGS = 19
56+
PTRACE_OLDSETOPTIONS = 21
57+
PTRACE_GET_THREAD_AREA = 25
58+
PTRACE_SET_THREAD_AREA = 26
59+
PTRACE_ARCH_PRCTL = 30
60+
PTRACE_SYSEMU = 31
61+
PTRACE_SYSEMU_SINGLESTEP = 32
62+
PTRACE_SINGLEBLOCK = 33
63+
)
64+
65+
// ptrace event codes from include/uapi/linux/ptrace.h.
66+
const (
67+
PTRACE_EVENT_FORK = 1
68+
PTRACE_EVENT_VFORK = 2
69+
PTRACE_EVENT_CLONE = 3
70+
PTRACE_EVENT_EXEC = 4
71+
PTRACE_EVENT_VFORK_DONE = 5
72+
PTRACE_EVENT_EXIT = 6
73+
PTRACE_EVENT_SECCOMP = 7
74+
PTRACE_EVENT_STOP = 128
75+
)
76+
77+
// PTRACE_SETOPTIONS options from include/uapi/linux/ptrace.h.
78+
const (
79+
PTRACE_O_TRACESYSGOOD = 1
80+
PTRACE_O_TRACEFORK = 1 << PTRACE_EVENT_FORK
81+
PTRACE_O_TRACEVFORK = 1 << PTRACE_EVENT_VFORK
82+
PTRACE_O_TRACECLONE = 1 << PTRACE_EVENT_CLONE
83+
PTRACE_O_TRACEEXEC = 1 << PTRACE_EVENT_EXEC
84+
PTRACE_O_TRACEVFORKDONE = 1 << PTRACE_EVENT_VFORK_DONE
85+
PTRACE_O_TRACEEXIT = 1 << PTRACE_EVENT_EXIT
86+
PTRACE_O_TRACESECCOMP = 1 << PTRACE_EVENT_SECCOMP
87+
PTRACE_O_EXITKILL = 1 << 20
88+
PTRACE_O_SUSPEND_SECCOMP = 1 << 21
89+
)

0 commit comments

Comments
 (0)