24 #include <sys/ptrace.h>
85 struct probe *trigger,
struct probe *base);
94 {
"post",
'P', 0, 0,
"Enable post handlers.", 0},
95 {
"quiet",
'q', 0, 0,
"Silent but deadly.", 0},
109 GList *base_target_specs = NULL;
110 GList *overlay_target_specs = NULL;
132 &primary_target_spec, &base_target_specs,
133 &overlay_target_specs);
135 verror(
"could not parse target arguments!\n");
147 overlay_target_specs, evloop, NULL);
149 verror(
"could not instantiate and open targets!\n");
161 "Could not lookup target %d for symbol %s; aborting!\n",
162 task2sym[i].tgtid, task2sym[i].
sym_name);
169 fprintf(stderr,
"could not lookup symbol %s; aborting!\n",
170 task2sym[i].sym_name);
185 fprintf(stderr,
"creating probe failed; aborting!\n");
191 memset(filename, 0, 1024);
192 strcat(filename, task2sym[i].file_name);
193 fprintf(stderr,
"filename == %s\n", filename);
198 fprintf(stderr,
"probe register failed; aborting!\n");
213 fprintf(stderr,
"Starting main debugging loop!\n");
228 fprintf(stderr,
"error in target_monitor_evloop (%d): %s;"
229 " attempting to continue!\n", rc, strerror(errno));
241 "Error handling target '%s'; closing and finalizing!\n",
246 targets = g_list_remove(targets, t);
249 fprintf(stderr,
"Target '%s' finished; finalizing!\n", tname);
253 targets = g_list_remove(targets, t);
256 fprintf(stderr,
"Target '%s' exiting...\n", tname);
259 fprintf(stderr,
"Target '%s' interrupted, resuming...\n",
263 "Could not resume target %s tid %" PRIiTID "\n",
268 targets = g_list_remove(targets, t);
273 "Target '%s' tid %d received unexpected status '%s'"
274 " at 0x%" PRIxADDR "; attempting to continue!\n",
279 "Could not resume target %s tid %" PRIiTID "\n",
284 targets = g_list_remove(targets, t);
289 fprintf(stderr,
"Monitoring completed; exiting!\n");
304 return ARGP_ERR_UNKNOWN;
307 if (state->quoted > 0)
308 opts->
argc = state->quoted - state->next;
310 opts->
argc = state->argc - state->next;
311 if (opts->
argc > 0) {
313 memcpy(opts->
argv, &state->argv[state->next],
314 opts->
argc *
sizeof(
char *));
315 state->next += opts->
argc;
322 case ARGP_KEY_NO_ARGS:
323 case ARGP_KEY_SUCCESS:
335 return ARGP_ERR_UNKNOWN;
342 struct probe * trigger,
struct probe * base) {
346 memset(outbuf, 0, 2048);
358 printf(
"Could not get any symbol!\n");
369 fprintf(stdout,
"RESULT:: (%c:%d) %s (%d) %s \"%s\" () ::RESULT\n",
370 'r',1,
"--",1,
"--", outbuf);
373 if (ipval && errno) {
374 fprintf(stderr,
"ERROR: could not read IP register!\n");
384 printf(
"In unknown function at IP 0x%" PRIxREGVAL "\n", ipval);
395 char *tmpfile, *tmpline, *tmpval;
399 argv_tmp = (
char **)
malloc(
sizeof(
char *) * argc);
400 for (i = 0; i < argc; i++) {
401 argv_tmp[
i] = (
char *)
malloc(128);
402 memset(argv_tmp[i], 0, 128);
403 fprintf(stderr,
"argc %d,argv[%d]==%s\n", argc, i, argv[i]);
404 strcpy(argv_tmp[i], argv[i]);
406 for (i = 0; i < argc; i++) {
408 tmpfile = index(argv_tmp[i],
':');
410 task2sym[
i].
tgtid = atoi(argv_tmp[i]);
411 fprintf(stderr,
"tgtid = %d\n", task2sym[i].tgtid);
414 tmpline = index(tmpfile + 1,
':');
417 fprintf(stderr,
"task name = %s\n", task2sym[i].file_name);
420 tmpval = index(tmpline + 1,
':');
422 task2sym[
i].
line = atoi(tmpline + 1);
423 fprintf(stderr,
"line = %d\n", task2sym[i].line);
427 fprintf(stderr,
"sym_name = %s\n", task2sym[i].sym_name);
429 for (i = 0; i < argc; i++) {
430 fprintf(stderr,
"the tgtid == %d file_name == %s, line == %d, \
432 task2sym[i].tgtid, task2sym[i].file_name, task2sym[i].line,
433 task2sym[i].sym_name);
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
struct dt_argp_state opts
struct argp_option dt_argp_opts[]
int value_snprintf(struct value *value, char *buf, int buflen)
void * target_argp_driver_state(struct argp_state *state)
static uint64_t unsigned int i
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
int target_monitor_evloop(struct evloop *evloop, struct timeval *timeout, struct target **target, target_status_t *status)
void extract_args(int argc, char **argv, struct tgt_sym *task2sym)
int target_resume(struct target *target)
#define v_g_list_foreach(glhead, glcur, elm)
struct target_location_ctxt * target_location_ctxt_create_from_bsymbol(struct target *target, tid_t tid, struct bsymbol *bsymbol)
tid_t target_gettid(struct target *target)
char * bsymbol_get_name(struct bsymbol *bsymbol)
result_t handler_line(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
int target_close(struct target *target)
#define verror(format,...)
int target_install_default_sighandlers(void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
struct tgt_sym task2sym_entry
void target_default_cleanup()
REFCNT bsymbol_release(struct bsymbol *bsymbol)
int target_argp_driver_parse(struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted, struct target_spec **primary_target_spec, GList **base_target_specs, GList **overlay_target_specs)
int target_monitor_was_interrupted(siginfo_t *last_siginfo)
char * target_name(struct target *target)
struct bsymbol * target_lookup_sym_addr(struct target *target, ADDR addr)
error_t dt_argp_parse_opt(int key, char *arg, struct argp_state *state)
struct probe * probe_create(struct target *target, tid_t tid, struct probe_ops *pops, const char *name, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data, int autofree, int tracked)
struct target * probe_target(struct probe *probe)
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
int evloop_maxsize(struct evloop *evloop)
void * calloc(size_t nmemb, size_t size)
struct evloop * evloop_create(evloop_error_handler_t ehandler)
struct target * target_lookup_target_id(int id)
int target_finalize(struct target *target)
GList * target_instantiate_and_open(struct target_spec *primary_target_spec, GList *base_target_specs, GList *overlay_target_specs, struct evloop *evloop, GList **error_specs)
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
int main(int argc, char **argv)
struct probe * probe_register_line(struct probe *probe, char *filename, int line, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
void * malloc(size_t size)
void target_driver_argp_init_children(struct argp_state *state)