27 #include <sys/ptrace.h>
38 #ifdef ENABLE_XENACCESS
58 void sigu(siginfo_t *siginfo) {
66 if (siginfo->si_signo != SIGALRM)
77 fprintf(stdout,
"Cannot examine target %s; handling an exception!\n",
82 fprintf(stdout,
"Threads in target %s:\n",target->
name);
98 fprintf(stdout,
"\nthread %"PRIiTID": (error!)\n",tid);
100 fprintf(stdout,
"\nthread %"PRIiTID": (nothing)\n",tid);
102 fprintf(stdout,
"\nthread %"PRIiTID": \n%s\n",tid,buf);
105 array_list_free(tids);
118 #define BT_ARGP_INTERVAL 0x444443
119 #define BT_ARGP_DETAIL 0x444444
122 {
"loop-interval",
BT_ARGP_INTERVAL,
"INTERVAL",0,
"Loop infinitely using the given interval.",0 },
123 {
"dump-detail",
BT_ARGP_DETAIL,
"DETAIL",0,
"Thread detail level (default 0).",0 },
134 return ARGP_ERR_UNKNOWN;
137 if (state->quoted > 0)
138 opts->
argc = state->quoted - state->next;
140 opts->
argc = state->argc - state->next;
141 if (opts->
argc > 0) {
143 memcpy(opts->
argv,&state->argv[state->next],opts->
argc*
sizeof(
char *));
144 state->next += opts->
argc;
151 case ARGP_KEY_NO_ARGS:
152 case ARGP_KEY_SUCCESS:
166 return ARGP_ERR_UNKNOWN;
176 int main(
int argc,
char **argv) {
178 GList *base_target_specs = NULL;
179 GList *overlay_target_specs = NULL;
191 sigemptyset(&ignored);
192 sigemptyset(&exitset);
193 sigemptyset(&interrupt);
195 sigaddset(&exitset,SIGHUP);
196 sigaddset(&exitset,SIGINT);
197 sigaddset(&exitset,SIGQUIT);
198 sigaddset(&exitset,SIGILL);
199 sigaddset(&exitset,SIGABRT);
200 sigaddset(&exitset,SIGFPE);
201 sigaddset(&exitset,SIGSEGV);
202 sigaddset(&exitset,SIGPIPE);
203 sigaddset(&exitset,SIGTERM);
204 sigaddset(&exitset,SIGBUS);
205 sigaddset(&exitset,SIGXCPU);
206 sigaddset(&exitset,SIGXFSZ);
208 sigaddset(&ignored,SIGUSR1);
209 sigaddset(&ignored,SIGUSR2);
210 sigaddset(&interrupt,SIGALRM);
218 &primary_target_spec,&base_target_specs,
219 &overlay_target_specs);
222 verror(
"could not parse target arguments!\n");
229 base_target_specs,overlay_target_specs,
232 verror(
"could not instantiate and open targets!\n");
237 siginfo.si_signo = SIGALRM;
247 fprintf(stdout,
"Starting thread watch loop!\n");
264 fprintf(stderr,
"error in target_monitor_evloop (%d): %s; aborting!\n",
279 "Error handling target '%s'; closing and finalizing!\n",
288 "Target '%s' finished; finalizing!\n",
296 fprintf(stderr,
"Target '%s' exiting...\n",tname);
299 fprintf(stderr,
"Target '%s' interrupted, resuming...\n",tname);
301 fprintf(stderr,
"Could not resume target %s tid %"PRIiTID"\n",
311 "Target '%s' tid %d received unexpected status '%s'"
312 " at 0x%"PRIxADDR"; attempting to continue!\n",
315 fprintf(stderr,
"Could not resume target %s tid %"PRIiTID"\n",
int main(int argc, char **argv)
struct argp_option bt_argp_opts[]
void * target_argp_driver_state(struct argp_state *state)
int target_unwind_snprintf(char *buf, int buflen, struct target *target, tid_t tid, target_unwind_style_t fstyle, char *frame_sep, char *ksep)
int target_load_available_threads(struct target *target, int force)
static uint64_t unsigned int i
int target_monitor_evloop(struct evloop *evloop, struct timeval *timeout, struct target **target, target_status_t *status)
int target_resume(struct target *target)
#define v_g_list_foreach(glhead, glcur, elm)
int target_pause(struct target *target)
struct bt_argp_state opts
tid_t target_gettid(struct target *target)
int target_close(struct target *target)
#define verror(format,...)
int target_install_custom_sighandlers(sigset_t *ignored, sigset_t *interrupt, sigset_t *exit, void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
void target_default_cleanup()
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)
struct array_list * target_list_tids(struct target *target)
char * target_name(struct target *target)
void sigu(siginfo_t *siginfo)
int evloop_maxsize(struct evloop *evloop)
void * calloc(size_t nmemb, size_t size)
struct evloop * evloop_create(evloop_error_handler_t ehandler)
target_status_t target_status(struct target *target)
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_dump_all_threads(struct target *target, FILE *stream, int detail)
#define array_list_foreach_fakeptr_t(alist, lpc, placeholder, intertype)
int target_monitor_handling_exception(struct target *target)
void target_driver_argp_init_children(struct argp_state *state)
error_t bt_argp_parse_opt(int key, char *arg, struct argp_state *state)