-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebuglib.h
More file actions
53 lines (35 loc) · 1.3 KB
/
debuglib.h
File metadata and controls
53 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Code sample: simplistic "library" of debugging tools.
**
**
** This code is in the public domain.
*/
#include <sys/types.h>
/* Print out a message, prefixed by the process ID.
*/
void procmsg(const char* format, ...);
/* Run the given program in a child process with exec() and tracing
** enabled.
*/
void run_target(const char* programname);
/* Retrieve the child process's current instruction pointer value.
*/
long get_child_eip(pid_t pid);
/* Display memory contents in the inclusive range [from_addr:to_addr] from the
** given process's address space.
*/
void dump_process_memory(pid_t pid, unsigned from_addr, unsigned to_addr);
struct debug_breakpoint_t;
typedef struct debug_breakpoint_t debug_breakpoint;
/* Create a breakpoint for the child process pid, at the given address.
*/
debug_breakpoint* create_breakpoint(pid_t pid, void* addr);
/* Clean up the memory allocated for the given breakpoint.
** Note: this doesn't disable the breakpoint, just deallocates it.
*/
void cleanup_breakpoint(debug_breakpoint* bp);
/* Given a process that's currently stopped at breakpoint bp, resume
** its execution and re-establish the breakpoint.
** Return 0 if the process exited while running, 1 if it has stopped
** again, -1 in case of an error.
*/
int resume_from_breakpoint(pid_t pid, debug_breakpoint* bp);