11
/* BREAKPOINT_LENGTH is defined in "sysdep.h" */
14
#define MAX_LIBRARY 30
16
#if defined HAVE_LIBIBERTY || defined HAVE_LIBSUPC__
22
extern int exiting; /* =1 if we have to exit ASAP */
24
typedef struct Breakpoint Breakpoint;
27
unsigned char orig_value[BREAKPOINT_LENGTH];
29
struct library_symbol *libsym;
46
ARGTYPE_FLOAT, /* float value, may require index */
47
ARGTYPE_DOUBLE, /* double value, may require index */
50
ARGTYPE_FORMAT, /* printf-like format */
51
ARGTYPE_STRING, /* NUL-terminated string */
52
ARGTYPE_STRING_N, /* String of known maxlen */
53
ARGTYPE_ARRAY, /* Series of values in memory */
54
ARGTYPE_ENUM, /* Enumeration */
55
ARGTYPE_STRUCT, /* Structure of values */
56
ARGTYPE_POINTER, /* Pointer to some other type */
57
ARGTYPE_COUNT /* number of ARGTYPE_* values */
60
typedef struct arg_type_info_t {
72
struct arg_type_info_t *elt_type;
77
/* ARGTYPE_STRING_N */
84
struct arg_type_info_t **fields; /* NULL-terminated */
91
struct arg_type_info_t *info;
108
LT_TOF_FUNCTION, /* A real library function */
109
LT_TOF_FUNCTIONR, /* Return from a real library function */
110
LT_TOF_SYSCALL, /* A syscall */
111
LT_TOF_SYSCALLR, /* Return from a syscall */
112
LT_TOF_STRUCT /* Not a function; read args from struct */
115
typedef struct Function Function;
118
arg_type_info *return_info;
120
arg_type_info *arg_info[MAX_ARGS];
126
LS_TOPLT_NONE = 0, /* PLT not used for this symbol. */
127
LS_TOPLT_EXEC, /* PLT for this symbol is executable. */
128
LS_TOPLT_POINT /* PLT for this symbol is a non-executable. */
131
extern Function *list_of_functions;
132
extern char *PLTs_initialized_by_here;
134
struct library_symbol {
140
struct library_symbol *next;
143
struct callstack_element {
146
struct library_symbol *libfunc;
150
struct timeval time_spent;
153
#define MAX_CALLDEPTH 64
155
typedef enum Process_State Process_State;
159
STATE_IGNORED /* ignore this process (it's a fork and no -f was used) */
1
typedef enum Event_type Event_type;
16
EVENT_NEW, /* in this case, proc is NULL */
162
20
typedef struct Process Process;
165
Process *parent; /* needed by STATE_BEING_CREATED */
168
struct dict *breakpoints;
169
int breakpoints_enabled; /* -1:not enabled yet, 0:disabled, 1:enabled */
170
int mask_32bit; /* 1 if 64-bit ltrace is tracing 32-bit process */
171
unsigned int personality;
172
int tracesysgood; /* signal indicating a PTRACE_SYSCALL trap */
175
struct callstack_element callstack[MAX_CALLDEPTH];
176
struct library_symbol *list_of_symbols;
178
/* Arch-dependent: */
179
void *instruction_pointer;
180
void *stack_pointer; /* To get return addr, args... */
182
Breakpoint *breakpoint_being_enabled;
185
short need_to_reinitialize_breakpoints;
187
int thumb_mode; /* ARM execution mode: 0: ARM, 1: Thumb */
191
enum tof type_being_displayed;
196
21
typedef struct Event Event;
211
EVENT_NEW /* in this case, proc is NULL */
214
int ret_val; /* EVENT_EXIT */
215
int signum; /* EVENT_SIGNAL, EVENT_EXIT_SIGNAL */
216
int sysnum; /* EVENT_SYSCALL, EVENT_SYSRET */
217
void *brk_addr; /* EVENT_BREAKPOINT */
218
int newpid; /* EVENT_CLONE, EVENT_NEW */
26
int ret_val; /* EVENT_EXIT */
27
int signum; /* EVENT_SIGNAL, EVENT_EXIT_SIGNAL */
28
int sysnum; /* EVENT_SYSCALL, EVENT_SYSRET */
29
void * brk_addr; /* EVENT_BREAKPOINT */
30
int newpid; /* EVENT_CLONE, EVENT_NEW */
222
struct opt_c_struct {
226
extern struct dict *dict_opt_c;
228
extern Process *list_of_processes;
230
extern void *instruction_pointer;
232
extern Event *next_event(void);
233
extern Process * pid2proc(pid_t pid);
234
extern void process_event(Event *event);
235
extern void execute_program(Process *, char **);
236
extern int display_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info);
237
extern Breakpoint *address2bpstruct(Process *proc, void *addr);
238
extern void breakpoints_init(Process *proc);
239
extern void insert_breakpoint(Process *proc, void *addr, struct library_symbol *libsym);
240
extern void delete_breakpoint(Process *proc, void *addr);
241
extern void enable_all_breakpoints(Process *proc);
242
extern void disable_all_breakpoints(Process *proc);
243
extern void reinitialize_breakpoints(Process *);
245
extern Process *open_program(char *filename, pid_t pid);
246
extern void open_pid(pid_t pid, int verbose);
247
extern void show_summary(void);
248
extern arg_type_info *lookup_prototype(enum arg_type at);
250
/* Arch-dependent stuff: */
251
extern char *pid2name(pid_t pid);
252
extern void trace_set_options(Process *proc, pid_t pid);
253
extern void trace_me(void);
254
extern int trace_pid(pid_t pid);
255
extern void untrace_pid(pid_t pid);
256
extern void get_arch_dep(Process *proc);
257
extern void *get_instruction_pointer(Process *proc);
258
extern void set_instruction_pointer(Process *proc, void *addr);
259
extern void *get_stack_pointer(Process *proc);
260
extern void *get_return_addr(Process *proc, void *stack_pointer);
261
extern void enable_breakpoint(pid_t pid, Breakpoint *sbp);
262
extern void disable_breakpoint(pid_t pid, const Breakpoint *sbp);
263
extern int syscall_p(Process *proc, int status, int *sysnum);
264
extern void continue_process(pid_t pid);
265
extern void continue_after_signal(pid_t pid, int signum);
266
extern void continue_after_breakpoint(Process *proc, Breakpoint *sbp);
267
extern void continue_enabling_breakpoint(pid_t pid, Breakpoint *sbp);
268
extern long gimme_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info);
269
extern void save_register_args(enum tof type, Process *proc);
270
extern int umovestr(Process *proc, void *addr, int len, void *laddr);
271
extern int umovelong (Process *proc, void *addr, long *result, arg_type_info *info);
272
extern int ffcheck(void *maddr);
273
extern void *sym2addr(Process *, struct library_symbol *);
276
extern int umoven(Process *proc, void *addr, int len, void *laddr);
34
typedef void (*callback_func) (Event *);
36
extern void ltrace_init(int argc, char **argv);
37
extern void ltrace_add_callback(callback_func f, Event_type type);
38
extern void ltrace_main(void);