32 static struct xentt_replay_session *session;
35 static struct bsymbol ssymbol, esymbol;
39 static int check_symbols(
char *statedir,
char *ssym,
char *esym);
40 static int register_probe(
struct target *
t, GHashTable *
probes,
char *symname,
42 static void unregister_probes(GHashTable *
probes);
53 xentt_replay_destroy(session);
55 xc_interface_close(xc);
62 fprintf(stderr,
"handler called\n");
72 main(
int argc,
char **argv)
74 char *name, *statedir;
76 unsigned long long s_brctr, e_brctr;
81 while ((ch = getopt(argc, argv,
"d")) != -1) {
92 fprintf(stderr,
"Usage: trace_task statedir start-sym[:brctr] end-sym[:brctr]\n");
96 if ((cp = index(argv[1],
':')) != 0 && cp[1] !=
'\0') {
98 s_sym = strdup(argv[1]);
99 s_brctr = strtoull(cp+1, NULL, 0);
102 s_sym = strdup(argv[1]);
105 if ((cp = index(argv[2],
':')) != 0 && cp[1] !=
'\0') {
107 e_sym = strdup(argv[2]);
108 e_brctr = strtoull(cp+1, NULL, 0);
111 e_sym = strdup(argv[2]);
115 fprintf(stderr,
"Start: %s:%llu, End: %s:%llu\n",
116 s_sym, s_brctr, e_sym, e_brctr);
123 name = rindex(statedir,
'/');
125 fprintf(stderr,
"Could not determine name from statedir %s\n",
134 if (check_symbols(statedir, s_sym, e_sym)) {
135 fprintf(stderr,
"Could not resolve start/end symbols\n");
142 signal(SIGINT, onexit);
143 signal(SIGTERM, onexit);
144 signal(SIGHUP, onexit);
145 signal(SIGQUIT, onexit);
146 signal(SIGABRT, onexit);
147 signal(SIGKILL, onexit);
148 signal(SIGSEGV, onexit);
149 signal(SIGPIPE, onexit);
150 signal(SIGALRM, onexit);
151 signal(SIGUSR1, onexit);
152 signal(SIGUSR2, onexit);
158 fprintf(stderr,
"Creating replay session %s from %s\n",
161 session = xentt_replay_create(name, statedir);
162 if (session == NULL) {
163 fprintf(stderr,
"Could not create replay session %s from %s\n",
167 if (xentt_replay_start(session, NULL) != 0) {
168 fprintf(stderr,
"Could not start replay session %s\n", name);
174 xa_set_debug_level(
debug);
180 fprintf(stderr,
"xen_vm_attach failed for %s\n", name);
184 fprintf(stderr,
"cannot open target %s!\n", name);
189 if (register_probe(target,
probes, s_sym, &ssymbol) != 0) {
190 fprintf(stderr,
"failed to register start probe\n");
194 xc = xc_interface_open();
196 fprintf(stderr,
"Could not get xc handle\n");
206 printf(
"domain %s interrupted at 0x%" PRIxREGVAL "\n", name,
209 fprintf(stderr,
"Can't resume target dom %s\n", name);
223 static int check_symbols(
char *statedir,
char *ssym,
char *esym)
231 snprintf(buf,
sizeof buf,
"%s/symfile", statedir);
232 if ((fd = fopen(buf,
"r")) == NULL) {
236 rv = fscanf(fd,
"%s", buf);
243 if ((bp = index(buf,
'\n')) != 0)
245 symfile = strdup(buf);
247 memset(map, 0,
sizeof(
struct symmap));
248 map[0].symfile = symfile;
253 fprintf(stderr,
"Looking up symbols in '%s'\n", symfile);
259 fprintf(stderr,
"Found %s\n", ssym);
263 fprintf(stderr,
"Found %s\n", esym);
269 fprintf(stderr,
"Releasing %s\n", ssym);
274 fprintf(stderr,
"Releasing %s\n", esym);
283 register_probe(
struct target *target, GHashTable *
probes,
char *symname,
292 fprintf(stderr,
"Could not find symbol %s!\n", symname);
300 handler, NULL, NULL, 0, 0);
303 "could not create probe for '%s'\n", symname);
304 unregister_probes(probes);
311 fprintf(stderr,
"could not register probe on '%s'\n",
314 unregister_probes(probes);
317 g_hash_table_insert(probes,
324 static void unregister_probes(GHashTable *probes)
330 g_hash_table_iter_init(&iter, probes);
331 while (g_hash_table_iter_next(&iter, (gpointer)&key, (gpointer)&probe)) {
int probe_unregister(struct probe *probe, int force)
REFCNT lsymbol_release(struct lsymbol *lsymbol)
struct target_spec * tspec
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
int target_resume(struct target *target)
int target_pause(struct target *target)
int main(int argc, char **argv)
int target_close(struct target *target)
void vmi_set_log_level(int level)
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
int probe_free(struct probe *probe, int force)
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_spec * target_build_spec(target_type_t type, target_mode_t mode)
struct lsymbol * symlist_lookup_name(char *name)
int target_open(struct target *target)
target_status_t target_monitor(struct target *target)
int symlist_init(struct symmap[], int)
struct target * target_instantiate(struct target_spec *spec, struct evloop *evloop)
struct probe * probe_register_symbol(struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
struct probepoint * probepoint
void symlist_deinit(void)