Skip to content
Newer
Older
100644 116 lines (106 sloc) 3.72 KB
20b3b40 @nelhage Add the license to all of the source files.
authored Feb 12, 2011
1 /*
2 * Copyright (C) 2011 by Nelson Elhage
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
a17b08f @heckendorfc Initial platform abstractions.
heckendorfc authored Nov 15, 2014
22 #ifndef PTRACE_H
23 #define PTRACE_H
24
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
25 #include <sys/ptrace.h>
f47503a @albertux Update ptrace.h
albertux authored Jan 22, 2015
26 #include <sys/types.h>
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
27 #include <sys/user.h>
28 #include <unistd.h>
29
b594ca3 @nelhage Replace linux/ptrace.h include with manual #define's.
authored Aug 18, 2013
30 /*
4ecbc57 @nelhage Fix some stupid typos in the previous commit.
authored Aug 19, 2013
31 * See https://github.com/nelhage/reptyr/issues/25 and
32 * https://github.com/nelhage/reptyr/issues/26.
b594ca3 @nelhage Replace linux/ptrace.h include with manual #define's.
authored Aug 19, 2013
33 *
34 * Older glibc's don't define PTRACE_{SETOPTIONS,GETEVENTMSG}, (but do
35 * in linux/ptrace.h), but on newer systems sys/ptrace.h and
36 * linux/ptrace.h conflict. If we were using autoconf or something, we
37 * could potentially detect the right headers at configure-time, but
38 * I'd like to avoid adding autoconf. These numbers can't ever change
39 * for ABI-compatibility reasons, at least.
40 */
41 #ifndef PTRACE_SETOPTIONS
42 #define PTRACE_SETOPTIONS 0x4200
43 #endif
44 #ifndef PTRACE_GETEVENTMSG
4ecbc57 @nelhage Fix some stupid typos in the previous commit.
authored Aug 19, 2013
45 #define PTRACE_GETEVENTMSG 0x4201
b594ca3 @nelhage Replace linux/ptrace.h include with manual #define's.
authored Aug 19, 2013
46 #endif
47
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
48 enum child_state {
49 ptrace_detached = 0,
50 ptrace_at_syscall,
51 ptrace_after_syscall,
52 ptrace_running,
53 ptrace_stopped,
54 ptrace_exited
55 };
56
57 struct ptrace_child {
58 pid_t pid;
59 enum child_state state;
14f8754 @nelhage Change how arch/ works in preparation for 32-on-64 support.
authored Apr 15, 2011
60 int personality;
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
61 int status;
c2c4701 @nelhage ptrace: Make error handling consistent.
authored Jan 21, 2011
62 int error;
9e91662 @nelhage Checkpoint working version.
authored Jan 17, 2011
63 unsigned long forked_pid;
1dfdfbc @nelhage Add architecture hooks for saving and restoring the syscall number.
authored Jan 26, 2011
64 unsigned long saved_syscall;
a17b08f @heckendorfc Initial platform abstractions.
heckendorfc authored Nov 15, 2014
65 #ifdef __linux__
66 struct user user;
67 #endif
68 #ifdef __FreeBSD__
69 struct reg regs;
70 #endif
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
71 };
72
ed3ecb0 @nelhage Abstract out syscall numbers similarly to registers.
authored Apr 15, 2011
73 struct syscall_numbers {
74 long nr_mmap;
75 long nr_mmap2;
76 long nr_munmap;
77 long nr_getsid;
78 long nr_setsid;
79 long nr_setpgid;
80 long nr_fork;
81 long nr_wait4;
82 long nr_signal;
83 long nr_rt_sigaction;
84 long nr_open;
85 long nr_close;
86 long nr_ioctl;
87 long nr_dup2;
d456a99 @nelhage proof-of-concept of stealing an entire pty from an xterm
authored Oct 5, 2013
88 long nr_socket;
89 long nr_connect;
90 long nr_sendmsg;
e80f7dd @nelhage Implement support for personalities that use socketcall.
authored Sep 2, 2014
91 long nr_socketcall;
ed3ecb0 @nelhage Abstract out syscall numbers similarly to registers.
authored Apr 15, 2011
92 };
93
35d826e @nelhage Implement memcpy to/from child.
authored Jan 17, 2011
94 typedef unsigned long child_addr_t;
95
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
96 int ptrace_wait(struct ptrace_child *child);
97 int ptrace_attach_child(struct ptrace_child *child, pid_t pid);
9e91662 @nelhage Checkpoint working version.
authored Jan 18, 2011
98 int ptrace_finish_attach(struct ptrace_child *child, pid_t pid);
648ff26 @nelhage Start to separate ptrace.c into a library.
authored Jan 17, 2011
99 int ptrace_detach_child(struct ptrace_child *child);
100 int ptrace_wait(struct ptrace_child *child);
101 int ptrace_advance_to_state(struct ptrace_child *child,
102 enum child_state desired);
103 int ptrace_save_regs(struct ptrace_child *child);
104 int ptrace_restore_regs(struct ptrace_child *child);
105 unsigned long ptrace_remote_syscall(struct ptrace_child *child,
106 unsigned long sysno,
107 unsigned long p0, unsigned long p1,
108 unsigned long p2, unsigned long p3,
109 unsigned long p4, unsigned long p5);
35d826e @nelhage Implement memcpy to/from child.
authored Jan 18, 2011
110
fff1db5 @nelhage const fix for memcpy_to_child
authored Jan 17, 2011
111 int ptrace_memcpy_to_child(struct ptrace_child *, child_addr_t, const void*, size_t);
35d826e @nelhage Implement memcpy to/from child.
authored Jan 18, 2011
112 int ptrace_memcpy_from_child(struct ptrace_child *, void*, child_addr_t, size_t);
ed3ecb0 @nelhage Abstract out syscall numbers similarly to registers.
authored Apr 15, 2011
113 struct syscall_numbers *ptrace_syscall_numbers(struct ptrace_child *child);
a17b08f @heckendorfc Initial platform abstractions.
heckendorfc authored Nov 15, 2014
114
115 #endif
Something went wrong with that request. Please try again.