ltrace.h revision f0fdae9e2444c2fb7764774088c574ab53c787f4
1#ifndef _HCK_LTRACE_H 2#define _HCK_LTRACE_H 3 4#include <sys/types.h> 5#include <stdio.h> 6 7#include "defs.h" 8 9/* BREAKPOINT_LENGTH is defined in "sysdep.h" */ 10#include "sysdep.h" 11 12extern char * command; 13 14struct breakpoint { 15 void * addr; 16 unsigned char orig_value[BREAKPOINT_LENGTH]; 17 int enabled; 18}; 19 20enum param_type { 21 LT_PT_UNKNOWN=-1, 22 LT_PT_VOID, 23 LT_PT_INT, 24 LT_PT_UINT, 25 LT_PT_OCTAL, 26 LT_PT_CHAR, 27 LT_PT_ADDR, 28 LT_PT_FILE, 29 LT_PT_FORMAT, /* printf-like format */ 30 LT_PT_STRING, 31 LT_PT_STRING0, /* stringN: string up to (arg N) bytes */ 32 LT_PT_STRING1, 33 LT_PT_STRING2, 34 LT_PT_STRING3 35}; 36 37enum tof { 38 LT_TOF_NONE, 39 LT_TOF_FUNCTION, /* A real library function */ 40 LT_TOF_SYSCALL /* A syscall */ 41}; 42 43struct function { 44 const char * name; 45 enum param_type return_type; 46 int num_params; 47 enum param_type param_types[MAX_ARGS]; 48 int params_right; 49 struct function * next; 50}; 51 52extern struct function * list_of_functions; 53 54struct library_symbol { 55 char * name; 56 struct breakpoint brk; 57 58 struct library_symbol * next; 59}; 60 61struct process { 62 char * filename; 63 pid_t pid; 64 int breakpoints_enabled; /* -1:not enabled yet, 0:disabled, 1:enabled */ 65 66 int current_syscall; /* -1 for none */ 67 struct library_symbol * current_symbol; /* NULL for none */ 68 69 struct breakpoint return_value; 70 struct library_symbol * list_of_symbols; 71 72 /* Arch-dependent: */ 73 void * instruction_pointer; 74 void * stack_pointer; /* To get return addr, args... */ 75 void * return_addr; 76 struct breakpoint * breakpoint_being_enabled; 77 78 /* output: */ 79 enum tof type_being_displayed; 80 81 struct process * next; 82}; 83 84struct event { 85 struct process *proc; 86 enum { 87 LT_EV_UNKNOWN, 88 LT_EV_NONE, 89 LT_EV_SIGNAL, 90 LT_EV_EXIT, 91 LT_EV_EXIT_SIGNAL, 92 LT_EV_SYSCALL, 93 LT_EV_SYSRET, 94 LT_EV_BREAKPOINT 95 } thing; 96 union { 97 int ret_val; /* _EV_EXIT */ 98 int signum; /* _EV_SIGNAL, _EV_EXIT_SIGNAL */ 99 int sysnum; /* _EV_SYSCALL, _EV_SYSRET */ 100 void * brk_addr; /* _EV_BREAKPOINT */ 101 } e_un; 102}; 103 104extern struct process * list_of_processes; 105 106extern void * instruction_pointer; 107 108struct event * wait_for_something(void); 109void process_event(struct event * event); 110void execute_program(struct process *, char **); 111int display_arg(enum tof type, struct process * proc, int arg_num, enum param_type rt); 112void enable_all_breakpoints(struct process * proc); 113void disable_all_breakpoints(struct process * proc); 114 115/* Arch-dependent stuff: */ 116extern void trace_me(void); 117extern void * get_instruction_pointer(int pid); 118extern void * get_stack_pointer(int pid); 119extern void * get_return_addr(int pid, void * stack_pointer); 120extern void insert_breakpoint(int pid, struct breakpoint * sbp); 121extern void delete_breakpoint(int pid, struct breakpoint * sbp); 122extern int child_p(int sysnum); 123extern int syscall_p(struct process * proc, int status); 124extern int sysret_p(struct process * proc, int status); 125extern void continue_process(pid_t pid); 126extern void continue_after_signal(pid_t pid, int signum); 127extern void continue_after_breakpoint(struct process * proc, struct breakpoint * sbp, int delete_it); 128extern void continue_enabling_breakpoint(pid_t pid, struct breakpoint * sbp); 129extern long gimme_arg(enum tof type, struct process * proc, int arg_num); 130extern int umovestr(struct process * proc, void * addr, int len, void * laddr); 131#if 0 /* not yet */ 132extern int umoven(struct process * proc, void * addr, int len, void * laddr); 133#endif 134 135 136#endif 137