Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (59 sloc) 2.579 kB
20b3b40 @nelhage Add the license to all of the source files.
authored
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 */
648ff26 @nelhage Start to separate ptrace.c into a library.
authored
22 #include <sys/ptrace.h>
23 #include <sys/user.h>
24 #include <unistd.h>
25
26 enum child_state {
27 ptrace_detached = 0,
28 ptrace_at_syscall,
29 ptrace_after_syscall,
30 ptrace_running,
31 ptrace_stopped,
32 ptrace_exited
33 };
34
35 struct ptrace_child {
36 pid_t pid;
37 enum child_state state;
14f8754 @nelhage Change how arch/ works in preparation for 32-on-64 support.
authored
38 int personality;
648ff26 @nelhage Start to separate ptrace.c into a library.
authored
39 int status;
c2c4701 @nelhage ptrace: Make error handling consistent.
authored
40 int error;
9e91662 @nelhage Checkpoint working version.
authored
41 unsigned long forked_pid;
1dfdfbc @nelhage Add architecture hooks for saving and restoring the syscall number.
authored
42 struct user user;
43 unsigned long saved_syscall;
648ff26 @nelhage Start to separate ptrace.c into a library.
authored
44 };
45
35d826e @nelhage Implement memcpy to/from child.
authored
46 typedef unsigned long child_addr_t;
47
648ff26 @nelhage Start to separate ptrace.c into a library.
authored
48 int ptrace_wait(struct ptrace_child *child);
49 int ptrace_attach_child(struct ptrace_child *child, pid_t pid);
9e91662 @nelhage Checkpoint working version.
authored
50 int ptrace_finish_attach(struct ptrace_child *child, pid_t pid);
648ff26 @nelhage Start to separate ptrace.c into a library.
authored
51 int ptrace_detach_child(struct ptrace_child *child);
52 int ptrace_wait(struct ptrace_child *child);
53 int ptrace_advance_to_state(struct ptrace_child *child,
54 enum child_state desired);
55 int ptrace_save_regs(struct ptrace_child *child);
56 int ptrace_restore_regs(struct ptrace_child *child);
57 unsigned long ptrace_remote_syscall(struct ptrace_child *child,
58 unsigned long sysno,
59 unsigned long p0, unsigned long p1,
60 unsigned long p2, unsigned long p3,
61 unsigned long p4, unsigned long p5);
35d826e @nelhage Implement memcpy to/from child.
authored
62
fff1db5 @nelhage const fix for memcpy_to_child
authored
63 int ptrace_memcpy_to_child(struct ptrace_child *, child_addr_t, const void*, size_t);
35d826e @nelhage Implement memcpy to/from child.
authored
64 int ptrace_memcpy_from_child(struct ptrace_child *, void*, child_addr_t, size_t);
Something went wrong with that request. Please try again.