-
Notifications
You must be signed in to change notification settings - Fork 2
/
trace.h
49 lines (41 loc) · 1.3 KB
/
trace.h
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
/*
* itrace
*
* Trace specific routines header
*
*/
#ifndef ITRACE_TRACE_H
#define ITRACE_TRACE_H
#include <sys/types.h>
#include <sys/user.h>
#include <stdint.h>
#define iprintf(fmt, ...) do { if (tracee.flags & QUIET_MODE) break; printf(fmt, ##__VA_ARGS__); } while(0)
/*
* Possible flags passed to itrace
*/
typedef enum {
SHOW_REGISTERS = 1<<0, /* -r */
SHOW_STACK = 1<<1, /* -s */
SHOW_COMMENTS = 1<<2, /* -C */
SHOW_MAPS = 1<<3, /* -m */
IGNORE_LIBS = 1<<4, /* -i */
SHOW_COUNT = 1<<5, /* -I */
QUIET_MODE = 1<<6 /* -q */
} trace_flags;
/*
* General information of tracee and argument options
*/
typedef struct {
const char *prog; /* program to start and trace */
char * const *prog_args; /* program arguments */
pid_t pid; /* pid of tracee program */
uintptr_t offset; /* eip offset to start tracing */
unsigned int num_inst; /* Max number of instruction to trace */
int syntax; /* Assembly syntax (0 = at&t, 1 = intel) */
int flags; /* Flags to handle options */
} trace_info;
pid_t trace_pid();
pid_t trace_program();
void trace_loop();
extern trace_info tracee;
#endif /* ITRACE_TRACE_H */