26 #include <sys/ptrace.h>
46 g_hash_table_iter_init(&iter,
probes);
47 while (g_hash_table_iter_next(&iter,
53 g_hash_table_destroy(
probes);
63 struct probe *trigger,
struct probe *base) {
65 struct timeval tv = { 0,0 };
67 struct dump_info ud = { .
stream = stdout,.prefix =
"",.detail = 0,.meta = 0 };
73 verror(
"could not get syscall state!\n");
78 gettimeofday(&tv,NULL);
80 printf(
"%11ld.%-6ld (%d) tid %6"PRIiTID" %s ",
118 struct probe *trigger,
struct probe *base) {
120 struct timeval tv = { 0,0 };
124 verror(
"could not get syscall state!\n");
129 gettimeofday(&tv,NULL);
157 return ARGP_ERR_UNKNOWN;
160 if (state->quoted > 0)
161 opts->
argc = state->quoted - state->next;
163 opts->
argc = state->argc - state->next;
164 if (opts->
argc > 0) {
166 memcpy(opts->
argv,&state->argv[state->next],opts->
argc*
sizeof(
char *));
167 state->next += opts->
argc;
174 case ARGP_KEY_NO_ARGS:
175 case ARGP_KEY_SUCCESS:
182 return ARGP_ERR_UNKNOWN;
192 int main(
int argc,
char **argv) {
210 verror(
"could not parse target arguments!\n");
216 verror(
"could not instantiate target!\n");
221 fprintf(stderr,
"could not open target!\n");
231 targetstr = strdup(
"<UNNAMED_TARGET>");
233 targetstr = strdup(targetstr);
241 probes = g_hash_table_new(g_direct_hash,g_direct_equal);
262 g_hash_table_insert(
probes,p,p);
270 verror(
"could not probe global syscall entry/exit path!\n");
273 g_hash_table_insert(
probes,p,p);
292 fprintf(stderr,
"could not resume target %s thread %"PRIiTID"\n",
302 printf(
"%s exiting, removing probes safely...\n",targetstr);
306 fprintf(stderr,
"could not resume target %s thread %"PRIiTID"\n",
321 printf(
"%s finished.\n",targetstr);
326 printf(
"%s monitoring failed!\n",targetstr);
331 printf(
"%s monitoring failed with %d!\n",targetstr,tstat);
346 printf(
"%s finished.\n",targetstr);
struct target_os_syscall_state * target_os_syscall_probe_last(struct target *target, tid_t tid)
int probe_unregister(struct probe *probe, int force)
void sigh_cleanup_probes(int signo, siginfo_t *siginfo, void *x)
void * target_argp_driver_state(struct argp_state *state)
void value_dump_simple(struct value *value, struct dump_info *ud)
struct target_spec * tspec
static uint64_t unsigned int i
struct array_list * argvals
int target_resume(struct target *target)
int target_pause(struct target *target)
tid_t target_gettid(struct target *target)
struct argp_option strace_argp_opts[]
char * bsymbol_get_name(struct bsymbol *bsymbol)
struct target_os_syscall * target_os_syscall_lookup_name(struct target *target, char *name)
#define verror(format,...)
int target_install_default_sighandlers(void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
void cleanup_probes(void)
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
int main(int argc, char **argv)
#define array_list_foreach(alist, lpc, placeholder)
void target_default_cleanup()
int target_os_syscall_table_load(struct target *target)
struct probe * target_os_syscall_probe(struct target *target, tid_t tid, struct target_os_syscall *syscall, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
int probe_free(struct probe *probe, int force)
#define array_list_foreach_is_last(alist, lpc)
char * target_name(struct target *target)
result_t syscall_post_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
struct target_os_syscall * syscall
struct target * probe_target(struct probe *probe)
void * calloc(size_t nmemb, size_t size)
struct strace_argp_state opts
struct probe * target_os_syscall_probe_all(struct target *target, tid_t tid, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
error_t strace_argp_parse_opt(int key, char *arg, struct argp_state *state)
int target_open(struct target *target)
target_status_t target_monitor(struct target *target)
struct target_spec * target_argp_driver_parse_one(struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted)
struct target * target_instantiate(struct target_spec *spec, struct evloop *evloop)
struct array_list * regvals
result_t syscall_pre_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
void target_driver_argp_init_children(struct argp_state *state)