38 #ifdef ENABLE_XENSUPPORT
60 static int next_target_id = 1;
62 static int init_done = 0;
64 static GHashTable *target_id_tab = NULL;
65 static GHashTable *target_personality_tab = NULL;
73 target_id_tab = g_hash_table_new_full(g_direct_hash,g_direct_equal,
75 target_personality_tab = g_hash_table_new_full(g_str_hash,g_str_equal,
93 while (g_hash_table_size(target_id_tab) > 0) {
94 g_hash_table_iter_init(&iter,target_id_tab);
95 while (g_hash_table_iter_next(&iter,NULL,(gpointer)&t)) {
100 g_hash_table_destroy(target_id_tab);
101 target_id_tab = NULL;
107 g_hash_table_iter_init(&iter,target_personality_tab);
108 while (g_hash_table_iter_next(&iter,&kp,&vp)) {
113 g_hash_table_destroy(target_personality_tab);
114 target_personality_tab = NULL;
122 static int cleaning = 0;
132 targets = g_hash_table_get_values(target_id_tab);
152 g_list_free(targets);
155 static sigset_t user_ignored,user_interrupt,user_exit;
156 static void (*user_sighandler)(
int signo,siginfo_t *siginfo,
void *x);
157 static int __target_global_interrupt = 0;
158 static siginfo_t __target_monitor_last_siginfo;
159 static struct sigaction __target_default_sigaction = {
161 .sa_flags = SA_SIGINFO,
163 static struct sigaction __target_default_sigaction_ign = {
164 .sa_handler = SIG_IGN,
168 static int handling = 0;
179 __target_monitor_last_siginfo = *siginfo;
181 memset(&__target_monitor_last_siginfo,0,
182 sizeof(__target_monitor_last_siginfo));
183 __target_monitor_last_siginfo.si_signo = signo;
187 user_sighandler(signo,siginfo,x);
189 if (sigismember(&user_interrupt,signo)) {
191 __target_global_interrupt = 1;
197 g_hash_table_iter_init(&iter,target_id_tab);
198 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
199 target = (
struct target *)vp;
215 sigaction(signo,&__target_default_sigaction,NULL);
220 if (__target_global_interrupt) {
222 *last_siginfo = __target_monitor_last_siginfo;
225 return __target_global_interrupt;
229 __target_global_interrupt = 0;
233 (
void (*sighandler)(
int signo,siginfo_t *siginfo,
void *x)) {
237 sigemptyset(&ignored);
239 sigemptyset(&interrupt);
241 sigaddset(&exit,SIGHUP);
242 sigaddset(&exit,SIGINT);
243 sigaddset(&exit,SIGQUIT);
244 sigaddset(&exit,SIGILL);
245 sigaddset(&exit,SIGABRT);
246 sigaddset(&exit,SIGFPE);
247 sigaddset(&exit,SIGSEGV);
248 sigaddset(&exit,SIGPIPE);
249 sigaddset(&exit,SIGTERM);
250 sigaddset(&exit,SIGBUS);
251 sigaddset(&exit,SIGXCPU);
252 sigaddset(&exit,SIGXFSZ);
254 sigaddset(&ignored,SIGUSR1);
255 sigaddset(&ignored,SIGUSR2);
256 sigaddset(&ignored,SIGALRM);
264 void (*sighandler)(
int signo,siginfo_t *siginfo,
void *x)) {
271 if ((ignored && sigismember(ignored,SIGCHLD))
272 || (exit && sigismember(exit,SIGCHLD))) {
273 verror(
"cannot specify SIGCHLD in any mask");
281 sigemptyset(&user_ignored);
285 sigemptyset(&user_interrupt);
289 sigemptyset(&user_exit);
291 user_sighandler = sighandler;
293 for (i = 1; i < 32; ++i) {
294 if ((i == SIGKILL || i == SIGSTOP)
295 && (sigismember(&user_ignored,i) || sigismember(&user_interrupt,i)
296 || sigismember(&user_exit,i))) {
297 vwarn(
"cannot catch, block, nor ignore SIGKILL nor SIGSTOP; ignoring!\n");
301 if (sigismember(&user_ignored,i))
302 sigaction(i,&__target_default_sigaction_ign,NULL);
303 else if (sigismember(&user_interrupt,i) || sigismember(&user_exit,i))
304 sigaction(i,&__target_default_sigaction,NULL);
315 __target_global_interrupt = 1;
329 return (
struct target *) \
330 g_hash_table_lookup(target_id_tab,(gpointer)(uintptr_t)
id);
355 #define TARGET_ARGP_BASE 0x333331
356 #define TARGET_ARGP_OVERLAY 0x333332
357 #define TARGET_ARGP_PERSONALITY 0x333333
358 #define TARGET_ARGP_PERSONALITY_LIB 0x333334
359 #define TARGET_ARGP_START_PAUSED 0x333335
361 #ifdef ENABLE_XENSUPPORT
362 #define __XEN_ARGP_TYPE ",xen"
364 #define __XEN_ARGP_TYPE
367 #define TARGET_ARGP_CORE_OPTS \
368 { "debug",'d',"LEVEL",0,"Set/increase the debugging level.",-3 }, \
369 { "log-flags",'l',"FLAG,FLAG,...",0,"Set the debugging flags",-3 }, \
370 { "warn",'w',"LEVEL",0,"Set/increase the warning level.",-3 }, \
371 { "target-type",'t',"TYPENAME",0, \
372 "Forcibly set the target type (ptrace" __XEN_ARGP_TYPE ",gdb,os-process,php).",-3 }, \
373 { "personality",TARGET_ARGP_PERSONALITY,"PERSONALITY",0, \
374 "Forcibly set the target personality (linux,process,php).",-3 }, \
375 { "personality-lib",TARGET_ARGP_PERSONALITY_LIB,"PERSONALITY_LIB_FILENAME",0, \
376 "Specify a shared library where the personality specified by --personality should be loaded from.",-3 }, \
377 { "start-paused",TARGET_ARGP_START_PAUSED,0,0,"Leave target paused after launch.",-3 }, \
378 { "stay-paused",'P',0,0,"Keep target paused at detach.",-3 }, \
379 { "soft-breakpoints",'s',0,0,"Force software breakpoints.",-3 }, \
380 { "debugfile-load-opts",'F',"LOAD-OPTS",0,"Add a set of debugfile load options.",-3 }, \
381 { "breakpoint-mode",'L',"STRICT-LEVEL",0,"Set/increase the breakpoint mode level.",-3 }, \
382 { "target-id",'i',"ID",0,"Specify a numeric ID for the target.",0 }, \
383 { "in-file",'I',"FILE",0,"Deliver contents of FILE to target on stdin (if avail).",-4 }, \
384 { "out-file",'O',"FILE",0,"Log stdout (if avail) to FILE.",-4 }, \
385 { "err-file",'E',"FILE",0,"Log stderr (if avail) to FILE.",-4 }, \
386 { "kill-on-close",'k',NULL,0,"Destroy target on close (SIGKILL).",-4 }, \
387 { "debugfile-root-prefix",'R',"DIR",0, \
388 "Set an alternate root prefix for debuginfo and binfile resolution.",0 }, \
389 { "active-probing",'a',"FLAG,FLAG,...",0, \
390 "A list of active probing flags to enable (disabled by default)" \
391 " (thread_entry thread_exit memory other)",0 }
396 "Specify an entire base target in a single argument. Any standard target option other than --base and --overlay may be used.",-3 },
398 "Specify an entire overlay target in a single argument. Your argument must be of the form [<base_target_id>:]<thread_name_or_id>:TARGET_OPTIONS",-3 },
408 int *argc,
char ***argv) {
410 char **backend_argv = NULL;
411 int backend_argc = 0;
421 verror(
"linux_userproc_spec_to_argv failed!\n");
425 #ifdef ENABLE_XENSUPPORT
428 verror(
"xen_vm_spec_to_argv failed!\n");
453 verror(
"gdb_spec_to_argv failed!\n");
508 av = calloc(ac + 1,
sizeof(
char *));
516 av[j++] = strdup(arg0);
522 av[j++] = strdup(
"-t");
524 av[j++] = strdup(
"ptrace");
525 #ifdef ENABLE_XENSUPPORT
527 av[j++] = strdup(
"xen");
530 av[j++] = strdup(
"gdb");
532 av[j++] = strdup(
"os-process");
534 av[j++] = strdup(
"php");
536 av[j++] = strdup(
"UNKNOWN");
540 av[j++] = strdup(
"--start-paused");
543 av[j++] = strdup(
"--stay-paused");
546 av[j++] = strdup(
"-s");
549 av[j++] = strdup(
"-L");
551 snprintf(av[j],11,
"%d",spec->
bpmode);
555 av[j++] = strdup(
"-i");
561 av[j++] = strdup(
"-I");
562 av[j++] = strdup(spec->
infile);
565 av[j++] = strdup(
"-O");
566 av[j++] = strdup(spec->
outfile);
569 av[j++] = strdup(
"-E");
570 av[j++] = strdup(spec->
errfile);
573 av[j++] = strdup(
"-k");
576 av[j++] = strdup(
"--personality");
580 av[j++] = strdup(
"--personality-lib");
584 av[j++] = strdup(
"-R");
588 av[j++] = strdup(
"-a");
592 len +=
sizeof(
"thread_entry,");
594 len +=
sizeof(
"thread_exit,");
596 len +=
sizeof(
"memory,");
598 len +=
sizeof(
"other,");
601 len +=
sizeof(
"os_thread_entry,");
603 len +=
sizeof(
"os_thread_exit,");
605 len +=
sizeof(
"os_memory,");
607 len +=
sizeof(
"os_other,");
610 len +=
sizeof(
"process_thread_entry,");
612 len +=
sizeof(
"process_thread_exit,");
614 len +=
sizeof(
"process_memory,");
616 len +=
sizeof(
"process_other,");
619 len +=
sizeof(
"app_thread_entry,");
621 len +=
sizeof(
"app_thread_exit,");
623 len +=
sizeof(
"app_memory,");
625 len +=
sizeof(
"app_other,");
632 rc += snprintf(av[j] + rc,len - rc,
"%s",
"thread_entry,");
634 rc += snprintf(av[j] + rc,len - rc,
"%s",
"thread_exit,");
636 rc += snprintf(av[j] + rc,len - rc,
"%s",
"memory,");
638 rc += snprintf(av[j] + rc,len - rc,
"%s",
"other,");
641 rc += snprintf(av[j] + rc,len - rc,
"%s",
"os_thread_entry,");
643 rc += snprintf(av[j] + rc,len - rc,
"%s",
"os_thread_exit,");
645 rc += snprintf(av[j] + rc,len - rc,
"%s",
"os_memory,");
647 rc += snprintf(av[j] + rc,len - rc,
"%s",
"os_other,");
650 rc += snprintf(av[j] + rc,len - rc,
"%s",
"process_thread_entry,");
652 rc += snprintf(av[j] + rc,len - rc,
"%s",
"process_thread_exit,");
654 rc += snprintf(av[j] + rc,len - rc,
"%s",
"process_memory,");
656 rc += snprintf(av[j] + rc,len - rc,
"%s",
"process_other,");
659 rc += snprintf(av[j] + rc,len - rc,
"%s",
"app_thread_entry,");
661 rc += snprintf(av[j] + rc,len - rc,
"%s",
"app_thread_exit,");
663 rc += snprintf(av[j] + rc,len - rc,
"%s",
"app_memory,");
665 rc += snprintf(av[j] + rc,len - rc,
"%s",
"app_other,");
670 for (i = 0; i < backend_argc; ++i)
671 av[j++] = backend_argv[i];
675 if (backend_argc > 0)
691 #ifdef ENABLE_XENSUPPORT
708 state->input)->driver_state;
711 static int __str2argvlist(
char *argptr,
struct array_list *argv_list) {
714 char *nargptr,*vargptr;
716 while (*argptr ==
' ')
724 while (*argptr !=
'\0') {
725 if (*argptr ==
'\\') {
744 else if (inquote && *argptr == quotechar) {
751 else if (*argptr ==
'\'' || *argptr ==
'"') {
757 else if (!inquote && *argptr ==
' ') {
758 *nargptr = *argptr =
'\0';
760 array_list_append(argv_list,vargptr);
781 array_list_append(argv_list,vargptr);
784 array_list_append(argv_list,NULL);
791 int argc,
char **argv,
801 struct argp_child target_argp_children[4];
806 struct argp target_argp = {
808 NULL,NULL,target_argp_children,NULL,NULL
814 struct argp_child target_argp_child[] = {
815 { &target_argp,0,
"Generic Target Options",0 },
824 memset(&tstate,0,
sizeof(tstate));
832 for (i = 0; i < argc; ++i) {
833 if (strncmp(
"--",argv[i],2) == 0 && argv[i][2] ==
'\0') {
854 #ifdef ENABLE_XENSUPPORT
873 target_argp_children[tstate.
num_children].header = NULL;
877 driver_parser->children = target_argp_child;
879 retval = argp_parse(driver_parser,argc,argv,0,NULL,&tstate);
881 driver_parser->children = NULL;
884 retval = argp_parse(&target_argp,argc,argv,0,NULL,&tstate);
901 int argc,
char **argv,
904 GList **base_target_specs,
905 GList **overlay_target_specs) {
915 struct argp_child target_argp_children[4];
920 struct argp target_argp = {
922 NULL,NULL,target_argp_children,NULL,NULL
928 struct argp_child target_argp_child[] = {
929 { &target_argp,0,
"Generic Target Options",0 },
938 memset(&tstate,0,
sizeof(tstate));
946 for (i = 0; i < argc; ++i) {
947 if (strncmp(
"--",argv[i],2) == 0 && argv[i][2] ==
'\0') {
968 #ifdef ENABLE_XENSUPPORT
987 target_argp_children[tstate.
num_children].header = NULL;
991 driver_parser->children = target_argp_child;
993 retval = argp_parse(driver_parser,argc,argv,0,NULL,&tstate);
995 driver_parser->children = NULL;
998 retval = argp_parse(&target_argp,argc,argv,0,NULL,&tstate);
1001 if (tstate.
spec && !primary_target_spec) {
1002 verror(
"primary target specification supplied, but not allowed!\n");
1008 if (base_target_specs && *base_target_specs) {
1014 g_list_free(*base_target_specs);
1015 *base_target_specs = NULL;
1018 if (overlay_target_specs && *overlay_target_specs) {
1024 g_list_free(*overlay_target_specs);
1025 *overlay_target_specs = NULL;
1038 *primary_target_spec = tstate.
spec;
1045 state->child_inputs[0] = state->input;
1060 char *argptr,*argptr2;
1061 char *base_thread_name_or_id;
1062 int base_target_id = -1;
1071 return ARGP_ERR_UNKNOWN;
1074 state->child_inputs[i] = tstate;
1077 case ARGP_KEY_NO_ARGS:
1078 case ARGP_KEY_SUCCESS:
1079 case ARGP_KEY_ERROR:
1090 tstate->
spec = NULL;
1093 verror(
"you must specify at least one kind of target!\n");
1103 if (strcmp(arg,
"ptrace") == 0)
1105 #ifdef ENABLE_XENSUPPORT
1106 else if (strcmp(arg,
"xen") == 0)
1109 else if (strcmp(arg,
"os-process") == 0)
1111 else if (strcmp(arg,
"php") == 0)
1113 else if (strcmp(arg,
"gdb") == 0)
1116 verror(
"bad target type %s!\n",arg);
1122 verror(
"target type already inferred or set; cannot set type %s!\n",
1130 #ifdef ENABLE_XENSUPPORT
1131 else if (strcmp(arg,
"xen") == 0)
1134 else if (strcmp(arg,
"os-process") == 0)
1136 else if (strcmp(arg,
"php") == 0)
1148 while (*arg ==
'd') {
1164 while (*arg ==
'w') {
1177 verror(
"bad log level flag in '%s'!\n",arg);
1186 argcopy = strdup(arg);
1191 verror(
"bad debugfile_load_opts '%s'!\n",argcopy);
1244 argcopy = strdup(arg);
1246 while ((token = strtok_r((!saveptr) ? argcopy : NULL,
",",&saveptr))) {
1247 if (strncmp(token,
"os_",2) == 0) {
1251 else if (strncmp(token,
"process_",8) == 0) {
1255 else if (strncmp(token,
"proc_",5) == 0) {
1259 else if (strncmp(token,
"app_",4) == 0) {
1266 if (strcmp(
"thread_entry",token) == 0)
1268 else if (strcmp(
"thread_exit",token) == 0)
1270 else if (strcmp(
"memory",token) == 0)
1272 else if (strcmp(
"other",token) == 0)
1275 verror(
"unrecognized active probe flag '%s'!\n",token);
1282 verror(
"program does not support extra base target specs!\n");
1286 argcopy = strdup(arg);
1288 argv_list = array_list_create(32);
1289 array_list_append(argv_list,
"target_argp_base_parse_one");
1291 __str2argvlist(argcopy,argv_list);
1294 array_list_len(argv_list) - 1,
1295 (
char **)argv_list->
list,
1298 verror(
"could not parse base spec %d!\n",
1301 array_list_free(argv_list);
1305 bspec->spec_was_base = 1;
1311 array_list_free(argv_list);
1315 verror(
"program does not support extra overlay target specs!\n");
1325 argcopy = strdup(arg);
1326 argptr = index(argcopy,
':');
1328 verror(
"bad overlay spec!\n");
1332 argv_list = array_list_create(32);
1333 array_list_append(argv_list,
"target_argp_overlay_parse_one");
1335 base_thread_name_or_id = argcopy;
1339 argptr2 = index(argptr,
':');
1341 base_target_id = atoi(base_thread_name_or_id);
1342 base_thread_name_or_id = argptr;
1347 __str2argvlist(argptr,argv_list);
1350 array_list_len(argv_list) - 1,
1351 (
char **)argv_list->
list,
1354 verror(
"could not parse overlay spec %d!\n",
1357 array_list_free(argv_list);
1362 if (isdigit(*base_thread_name_or_id)) {
1376 array_list_free(argv_list);
1380 return ARGP_ERR_UNKNOWN;
1395 if (g_hash_table_lookup_extended(target->
gkv_store,key,NULL,NULL) == TRUE) {
1400 gkvi = calloc(1,
sizeof(*gkvi));
1404 g_hash_table_insert(target->
gkv_store,strdup(key),gkvi);
1413 g_hash_table_lookup(target->
gkv_store,key))) {
1425 if (g_hash_table_lookup_extended(target->
gkv_store,key,
1426 NULL,&rval) == FALSE) {
1431 g_hash_table_remove(target->
gkv_store,key);
1432 value = gkvi->
value;
1442 if (g_hash_table_lookup_extended(target->
gkv_store,key,
1443 NULL,&rval) == FALSE) {
1448 g_hash_table_remove(target->
gkv_store,key);
1457 GHashTableIter iter;
1465 g_hash_table_iter_init(&iter,target->
gkv_store);
1466 while (g_hash_table_iter_next(&iter,&kp,&vp)) {
1474 g_hash_table_iter_steal(&iter);
1481 g_hash_table_destroy(target->
gkv_store);
1492 char *key,
void *
value,
1500 verror(
"could not lookup thread %"PRIiTID"; forgot to load?\n",tid);
1504 if (g_hash_table_lookup_extended(tthread->
gkv_store,key,NULL,NULL) == TRUE) {
1509 gkvi = calloc(1,
sizeof(*gkvi));
1510 gkvi->
value = value;
1514 g_hash_table_insert(tthread->
gkv_store,strdup(key),gkvi);
1526 verror(
"could not lookup thread %"PRIiTID"; forgot to load?\n",tid);
1531 g_hash_table_lookup(tthread->
gkv_store,key))) {
1547 verror(
"could not lookup thread %"PRIiTID"; forgot to load?\n",tid);
1551 if (g_hash_table_lookup_extended(tthread->
gkv_store,key,
1552 NULL,&rval) == FALSE) {
1557 g_hash_table_remove(tthread->
gkv_store,key);
1558 value = gkvi->
value;
1572 verror(
"could not lookup thread %"PRIiTID"; forgot to load?\n",tid);
1576 if (g_hash_table_lookup_extended(tthread->
gkv_store,key,
1577 NULL,&rval) == FALSE) {
1582 g_hash_table_remove(tthread->
gkv_store,key);
1592 GHashTableIter iter;
1600 g_hash_table_iter_init(&iter,tthread->
gkv_store);
1601 while (g_hash_table_iter_next(&iter,&kp,&vp)) {
1609 g_hash_table_iter_steal(&iter);
1616 g_hash_table_destroy(tthread->
gkv_store);
1626 GHashTableIter iter;
1627 struct target *overlay;
1638 verror(
"cannot free (%d refs) target %s\n",
1643 vwarn(
"forcing free (%d refs) target %s\n",
1658 "target(%s) not closed; closing first!\n",target->
name);
1671 while (g_hash_table_size(target->
overlays) > 0) {
1672 g_hash_table_iter_init(&iter,target->
overlays);
1673 g_hash_table_iter_next(&iter,NULL,(gpointer)&overlay);
1675 tmpname = strdup(overlay->name);
1677 "detaching overlay target(%s)\n",tmpname);
1680 "detached overlay target(%s)\n",tmpname);
1683 g_hash_table_destroy(target->
overlays);
1694 RPUTW(target->
base,target,target,trefcnt);
1695 target->
base = NULL;
1722 list = g_hash_table_get_values(target->
actions);
1728 g_hash_table_destroy(target->
actions);
1731 list = g_hash_table_get_values(target->
probes);
1736 g_hash_table_destroy(target->
probes);
1744 g_hash_table_destroy(target->
mmods);
1745 target->
mmods = NULL;
1755 list = g_hash_table_get_values(target->
threads);
1767 g_list_free(target->
spaces);
1778 verror(
"fini target(%s) (personality) failed; continuing anyway!!\n",
1791 verror(
"cannot free (%d wrefs) target %s\n",
1796 vwarn(
"forcing free (%d wrefs) target %s\n",
1802 if ((rc = target->
ops->
fini(target))) {
1803 verror(
"fini target(%s) failed; continuing anyway!\n",target->
name);
1808 g_hash_table_destroy(target->
threads);
1811 g_hash_table_destroy(target->
config);
1822 target->
name = NULL;
1835 #ifdef ENABLE_XENSUPPORT
1855 verror(
"could not find target_ops for target type %d!\n",
1861 retval = calloc(1,
sizeof(*retval));
1864 retval->
id = next_target_id++;
1867 && g_hash_table_lookup(target_id_tab,
1868 (gpointer)(uintptr_t)spec->
target_id)) {
1882 retval->
config = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
1885 retval->
gkv_store = g_hash_table_new_full(g_str_hash,g_str_equal,free,NULL);
1889 retval->
overlays = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1891 retval->
overlay_aliases = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1894 retval->
threads = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1898 retval->
actions = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1900 retval->
probes = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1905 retval->
soft_probepoints = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1908 retval->
mmods = g_hash_table_new_full(g_direct_hash,g_direct_equal,NULL,NULL);
1910 retval->
phys_mmods = g_hash_table_new_full(g_direct_hash,g_direct_equal,
1916 if (target_id_tab) {
1917 g_hash_table_insert(target_id_tab,
1918 (gpointer)(uintptr_t)retval->
id,retval);
1919 RHOLD(retval,target_id_tab);
1934 RPUTW(target->
base,target,target,trefcnt);
1935 target->
base = NULL;
1943 if (!target_id_tab) {
1948 if (g_hash_table_lookup(target_id_tab,(gpointer)(uintptr_t)target->
id)
1954 g_hash_table_remove(target_id_tab,(gpointer)(uintptr_t)target->
id);
1955 RPUT(target,target,target_id_tab,trefcnt);
1969 verror(
"debugfile(%s) already in use in region(%s) in space (%s:0x%"PRIxADDR")!\n",
1975 RHOLD(debugfile,region);
1980 "loaded and associated debugfile(%s) for region(%s,"
1982 " in space (%s:0x%PRIxADDR)\n",
1994 GHashTableIter iter;
2003 "trying to find debugfile for address 0x%"PRIxADDR"\n",addr);
2015 g_hash_table_iter_init(&iter,region->
debugfiles);
2016 while (g_hash_table_iter_next(&iter,
2017 (gpointer)&key,(gpointer)&debugfile))
2029 GHashTableIter iter, iter2;
2048 g_hash_table_iter_init(&iter,region->
debugfiles);
2049 while (g_hash_table_iter_next(&iter,NULL,&value)) {
2050 g_hash_table_iter_init(&iter2,((
struct debugfile *)value)->srcfiles);
2051 while (g_hash_table_iter_next(&iter2,NULL,(gpointer *)&root)) {
2067 GHashTableIter iter;
2075 "trying to find symbol at address 0x%"PRIxADDR"\n",
2088 g_hash_table_iter_init(&iter,region->
debugfiles);
2089 while (g_hash_table_iter_next(&iter,
2090 (gpointer)&key,(gpointer)&debugfile)) {
2097 RHOLD(bsymbol,bsymbol);
2109 GHashTableIter iter;
2113 struct lsymbol *primary_ls,*alt_ls;
2121 "trying to find symbol at address 0x%"PRIxADDR"\n",
2134 g_hash_table_iter_init(&iter,region->
debugfiles);
2135 while (g_hash_table_iter_next(&iter,
2136 (gpointer)&key,(gpointer)&debugfile)) {
2137 primary_ls = alt_ls = NULL;
2141 (primary) ? &primary_ls : NULL,
2142 (alt) ? &alt_ls : NULL))
2150 RHOLD(bsymbol,bsymbol);
2159 RHOLD(bsymbol,bsymbol);
2170 const char *name,
const char *delim,
2178 GHashTableIter iter;
2192 g_hash_table_iter_init(&iter,region->
debugfiles);
2193 while (g_hash_table_iter_next(&iter,(gpointer)&key,
2194 (gpointer)&debugfile)) {
2211 RHOLD(bsymbol,bsymbol);
2220 const char *name,
const char *delim) {
2221 struct bsymbol *bsymbol_new;
2232 RHOLD(bsymbol_new,bsymbol_new);
2238 char *filename,
int line,
2246 GHashTableIter iter;
2256 g_hash_table_iter_init(&iter,region->
debugfiles);
2257 while (g_hash_table_iter_next(&iter,(gpointer)&key,
2258 (gpointer)&debugfile)) {
2280 RHOLD(bsymbol,bsymbol);
2293 GHashTableIter iter;
2303 "trying to find line for address 0x%"PRIxADDR"\n",
2316 g_hash_table_iter_init(&iter,region->
debugfiles);
2317 while (g_hash_table_iter_next(&iter,
2318 (gpointer)&key,(gpointer)&debugfile)) {
2329 ADDR addr,
char **filename,
int *line) {
2332 GHashTableIter iter;
2343 "trying to find line for address 0x%"PRIxADDR"\n",
2356 g_hash_table_iter_init(&iter,region->
debugfiles);
2357 while (g_hash_table_iter_next(&iter,
2358 (gpointer)&key,(gpointer)&debugfile)) {
2379 verror(
"must supply a context (tid,region) for raw symbol resolution!\n");
2384 start,end,is_noncontiguous,alt_start,alt_end);
2394 verror(
"must supply a context (tid,region) for raw lsymbol resolution!\n");
2399 start,end,is_noncontiguous,alt_start,alt_end);
2409 verror(
"must supply a context (tid,region) for bsymbol resolution!\n");
2414 start,end,is_noncontiguous,alt_start,alt_end);
2427 struct symbol **o_datatype,
2440 verror(
"must supply a context (tid,region) for raw lsymbol resolution!\n");
2446 memset(&tloc,0,
sizeof(tloc));
2453 " for symbol %s: %s!\n",
2461 "failed to resolve location type %s (%d)!\n",LOCTYPE(-rc),rc);
2465 symbol = lsymbol_last_symbol(lsymbol);
2489 " resolved to: %s!\n",
2497 "could not find memory for 0x%"PRIxADDR
2498 " for symbol %s: %s!\n",
2504 "ptr var (in reg) %s = 0x%"PRIxADDR"\n",
2519 verror(
"unexpected implicit value instead of pointer!\n");
2525 flags,&datatype,&range);
2527 verror(
"could not load pointer for symbol %s\n",
2533 "autoloaded pointer(s) for var %s = 0x%"PRIxADDR"\n",
2539 "could not find memory for 0x%"PRIxADDR
2540 " for symbol %s: %s!\n",
2546 verror(
"unexpected location type %s for pointer!\n",
2560 *o_datatype = datatype;
2566 *o_datatype = datatype;
2572 *o_datatype = datatype;
2593 verror(
"must supply a context (tid,region) for bsymbol resolution!\n");
2597 memset(&tloc,0,
sizeof(tloc));
2602 "could not resolve base for symbol %s: %s (%d)\n",
2628 verror(
"symbol %s is not a full type (is %s)!\n",
2634 if (datatype != type)
2654 verror(
"failed to autoload pointers for type %s at addr 0x%"PRIxADDR"\n",
2660 verror(
"last pointer was NULL!\n");
2678 verror(
"could not create value: %s\n",strerror(errno));
2685 verror(
"failed to autoload char * for type %s at addr 0x%"PRIxADDR"\n",
2693 "autoloaded char * with len %d\n",value->
bufsiz);
2701 verror(
"could not create value for type (ptr is %p) %s\n",
2702 datatype,datatype ? datatype->
name : NULL);
2707 (
unsigned char *)value->
buf,
2740 verror(
"could not lookup thread %"PRIiTID"; forgot to load?\n",tid);
2747 verror(
"symbol %s is not a full type (is %s)!\n",
2753 if (datatype != type)
2780 verror(
"failed to autoload pointers for type %s"
2787 verror(
"last pointer was NULL!\n");
2806 && (flags & LOAD_FLAG_AUTO_STRING)
2811 verror(
"could not create value: %s\n",strerror(errno));
2815 if (!(value->
buf = (
char *) \
2817 verror(
"failed to autoload char * for type %s"
2818 " at regval ptr addr 0x%"PRIxADDR"\n",
2826 "autoloaded char * with len %d\n",value->
bufsiz);
2834 verror(
"could not create value for type (ptr is %p) %s\n",
2835 datatype,datatype ? datatype->
name : NULL);
2840 (
unsigned char *)value->
buf,
2851 verror(
"could not create value for type (ptr is %p) %s\n",
2852 datatype,datatype ? datatype->
name : NULL);
2860 memcpy(value->
buf,®val,sz);
2888 const char *member,
const char *delim,
2890 struct bsymbol *bmember;
2891 struct value *retval = NULL;
2895 verror(
"could not find member '%s' in symbol %s!\n",
2909 struct value *old_value,
2910 const char *member,
const char *delim,
2914 struct symbol *tdatatype;
2930 tthread = old_value->
thread;
2936 "looking up '%s' in type ",member);
2939 " (skipping to type ");
2942 memset(&tloc,0,
sizeof(tloc));
2961 oldaddr =
v_addr(old_value);
2964 "datatype is ptr; skipping to real type ");
2967 " starting at addr 0x%"PRIxADDR"\n",oldaddr);
2970 oldaddr = old_value->
res.
addr;
2973 "datatype is not ptr; starting at addr 0x%"PRIxADDR"\n",
2978 vwarn(
"symbol %s: not a full struct/union/class type (is %s)!\n",
2993 symbol = lsymbol_last_symbol(ls);
3006 "symbol %s: loaded const value len %d\n",
3025 flags,&tloc,&datatype,&range);
3044 verror(
"symbol %s: could not create value: %s\n",
3053 "symbol %s: failed to autostring char pointer\n",
3063 "symbol %s: autoloaded char * value with len %d\n",
3078 else if (addr >= oldaddr
3079 && ((addr + newlen) - oldaddr) < (
unsigned)old_value->
bufsiz) {
3083 verror(
"symbol %s: could not create value: %s\n",
3087 memcpy(value->
buf,old_value->
buf + (addr - oldaddr),
3092 "symbol %s: forced member value copy with len %d\n",
3098 verror(
"symbol %s: could not create value: %s\n",
3105 "symbol %s: loaded member value as child with len %d\n",
3114 verror(
"symbol %s: could not create value: %s\n",
3120 (
unsigned char *)value->
buf,
3123 "symbol %s: failed to load value at 0x%"PRIxADDR"\n",
3133 "symbol %s: loaded value with len %d\n",
3143 verror(
"symbol %s: could not read reg %d value in tid %"PRIiTID"\n",
3157 else if (__WORDSIZE == 32)
3166 verror(
"symbol %s: could not create value: %s\n",
3186 else if (__WORDSIZE == 32)
3195 verror(
"symbol %s: could not create value: %s\n",
3205 verror(
"symbol %s: failed to compute location (%d %s)\n",
3210 verror(
"symbol %s: computed location not register nor address (%d)"
3246 struct symbol *tdatatype;
3255 verror(
"must supply a context (tid,region) for bsymbol load!\n");
3258 tthread = tlctxt->
thread;
3262 symbol = lsymbol_last_symbol(lsymbol);
3265 verror(
"symbol %s is not a variable (is %s)!\n",
3285 "symbol %s: loaded const value len %d\n",
3298 memset(&tloc,0,
sizeof(tloc));
3300 flags,&tloc,&datatype,&range);
3314 verror(
"symbol %s: could not create value: %s\n",
3323 "symbol %s: failed to autostring char pointer\n",
3333 "symbol %s: autoloaded char * value with len %d\n",
3339 verror(
"symbol %s: could not create value: %s\n",
3345 (
unsigned char *)value->
buf,
3348 "symbol %s: failed to load value at 0x%"PRIxADDR"\n",
3358 "symbol %s: loaded value with len %d\n",
3368 "symbol %s: could not read reg %d value in tid %"PRIiTID"\n",
3382 else if (__WORDSIZE == 32)
3391 verror(
"symbol %s: could not create value: %s\n",
3412 else if (__WORDSIZE == 32)
3421 verror(
"symbol %s: could not create value: %s\n",
3431 verror(
"symbol %s: computed location not register nor address (%d)"
3450 char *member,
const char *delim) {
3469 memset(&tloc,0,
sizeof(tloc));
3471 flags,&tloc,NULL,o_range);
3473 verror(
"symbol %s: failed to compute location: %s (%d)\n",
3488 "symbol %s: computed location is register %"PRIiREG"\n",
3494 "symbol %s: computed location is implicit value 0x%"PRIxADDR"\n",
3499 verror(
"symbol %s: computed location not register nor address (%d)"
3522 else if (value->
isreg) {
3527 (
unsigned long)value->
bufsiz,
3528 (
unsigned char *)value->
buf)
3529 != (
unsigned long)value->
bufsiz) {
3548 region_saveptr,range_saveptr)) {
3550 *space_saveptr = space;
3581 for (i = 0; i < count; ++i ) {
3583 verror(
"failed to follow NULL pointer #%d\n",i);
3589 "loading ptr #%d at 0x%"PRIxADDR"\n",i,paddr);
3610 "loaded next ptr value 0x%"PRIxADDR" (#%d)\n",
3614 if (i == count && range) {
3616 *range_saveptr = range;
3628 struct symbol **datatype_saveptr,
3641 verror(
"failed to follow NULL pointer #%d\n",nptrs);
3647 "loading ptr at 0x%"PRIxADDR"\n",paddr);
3661 (
unsigned char *)&paddr,
3670 "loaded next ptr value 0x%"PRIxADDR" (#%d)\n",
3683 *range_saveptr = range;
3684 if (datatype_saveptr)
3685 *datatype_saveptr = datatype;
3722 verror(
"could not find range containing addr 0x%"PRIxADDR"!\n",addr);
3728 verror(
"could not create raw value of len %d for addr 0x%"PRIxADDR"!\n",
3734 (
unsigned char *)value->
buf,value->
bufsiz)) {
3750 verror(
"could not find range containing addr 0x%"PRIxADDR"!\n",addr);
3756 (
unsigned char *)buf,bufsiz);
3762 unsigned char *buf,
int bufsiz) {
3774 addr,bufsiz,range->
start,range->
end);
3858 #define CODE_CACHE_BUF_PAD 5
3869 int nocache,
int force_copy,
int *caller_free) {
3870 unsigned char *buf = NULL;
3871 unsigned int llen = 0;
3876 unsigned char *tbuf;
3883 while (llen < len) {
3904 if (!buf && (nextaddr + len) <= (ccd->
start + ccd->
len)) {
3906 return ccd->
code + (nextaddr - ccd->
start);
3917 tlen = ccd->
len - (nextaddr - ccd->
start);
3918 if ((len - llen) < tlen)
3921 memcpy(buf + llen,ccd->
code + (nextaddr - ccd->
start),tlen);
3932 verror(
"no safe disasm range contains 0x%"PRIxADDR"!\n",nextaddr);
3939 verror(
"could not load code in safe disasm range"
3945 verror(
"could not load even 1 byte of code in safe disasm range"
3946 " 0x%"PRIxADDR
",0x%"PRIxADDR
"!\n",cstart,cend);
3949 verror(
"BUT could load 1 byte of code in safe disasm range"
3950 " 0x%"PRIxADDR
",0x%"PRIxADDR
"!\n",cstart,cend);
3957 ccd->
start = cstart;
3958 ccd->
len = cend - cstart;
3984 (gpointer)(
ptr_t)tid);
4010 g_hash_table_lookup(target->
threads,(gpointer)(
ptr_t)tid);
4012 verror(
"could not set status for nonexistent tid %d -- BUG!\n",tid);
4022 void *tstate,
void *tpstate) {
4049 t->
gkv_store = g_hash_table_new_full(g_str_hash,g_str_equal,free,NULL);
4056 g_hash_table_insert(target->
threads,(gpointer)(
ptr_t)tid,t);
4069 RHOLD(thread,target);
4074 GHashTableIter iter;
4096 while (g_hash_table_iter_next(&iter,NULL,(gpointer)&probepoint)) {
4112 g_hash_table_remove(target->
threads,(gpointer)(uintptr_t)tthread->
tid);
4157 if (target &&
OBJLIVE(tthread))
4216 if (target && tthread->
state) {
4220 free(tthread->
state);
4222 tthread->
state = NULL;
4226 RPUTW(target,target,tthread,trefcnt);
4279 if (strncmp(tfr->
value_name,
"tidhier",strlen(
"tidhier")) == 0) {
4282 tmpthread = tthread;
4285 rc += snprintf(vstrbuf + rc,
sizeof(vstrbuf) - rc,
4288 rc += snprintf(vstrbuf + rc,
sizeof(vstrbuf) - rc,
4292 if (tmpthread->
ptid == -1)
4300 }
while (tmpthread);
4302 else if (strncmp(tfr->
value_name,
"tid",strlen(
"tid")) == 0) {
4303 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%"PRIiTID,tthread->
tid);
4305 else if (strncmp(tfr->
value_name,
"tgid",strlen(
"tgid")) == 0) {
4306 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%"PRIiTID,tthread->
tgid);
4308 else if (strncmp(tfr->
value_name,
"ptid",strlen(
"ptid")) == 0) {
4309 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%"PRIiTID,tthread->
ptid);
4311 else if (strncmp(tfr->
value_name,
"namehier",strlen(
"namehier")) == 0) {
4314 tmpthread = tthread;
4317 rc += snprintf(vstrbuf + rc,
sizeof(vstrbuf) - rc,
4318 ",%s",tmpthread->
name ? tmpthread->
name :
"");
4320 rc += snprintf(vstrbuf + rc,
sizeof(vstrbuf) - rc,
4321 "%s",tmpthread->
name ? tmpthread->
name :
"");
4324 if (tmpthread->
ptid == -1)
4332 }
while (tmpthread);
4334 else if (strncmp(tfr->
value_name,
"name",strlen(
"name")) == 0) {
4335 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%s",
4336 tthread->
name ? tthread->
name :
"");
4338 else if (strncmp(tfr->
value_name,
"uid",strlen(
"uid")) == 0) {
4339 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%d",tthread->
uid);
4341 else if (strncmp(tfr->
value_name,
"gid",strlen(
"gid")) == 0) {
4342 rc = snprintf(vstrbuf,
sizeof(vstrbuf),
"%d",tthread->
gid);
4345 vwarn(
"unrecognized thread filter key '%s'; skipping!\n",
4350 if (regexec(&tfr->
regex,(
const char *)vstrbuf,0,NULL,0) == REG_NOMATCH) {
4352 "failed to match name %s value '%s' with regex!\n",
4358 "matched name %s value '%s' with regex\n",
4394 static int __target_invalidate_all_threads(
struct target *
target) {
4395 GHashTableIter iter;
4399 g_hash_table_iter_init(&iter,target->
threads);
4400 while (g_hash_table_iter_next(&iter,NULL,(gpointer)&tthread)) {
4412 if (tthread->regcaches[i]) {
4420 vwarn(
"invalidated dirty thread %"PRIiTID"; BUG?\n",tthread->tid);
4427 GHashTableIter iter;
4428 struct target *overlay;
4432 "invalidating all target(%s) threads\n",target->
name);
4437 g_hash_table_iter_init(&iter,target->
overlays);
4438 while (g_hash_table_iter_next(&iter,NULL,(gpointer)&overlay)) {
4440 "invalidating all overlay target(%s) threads\n",overlay->name);
4443 "invalidating all overlay target(%s) threads (%d)\n",overlay->name,rc);
4446 return __target_invalidate_all_threads(target);
4456 struct target *overlay;
4458 overlay = (
struct target *) \
4459 g_hash_table_lookup(target->
overlays,(gpointer)(uintptr_t)tid);
4461 overlay = (
struct target *) \
4462 g_hash_table_lookup(target->
overlay_aliases,(gpointer)(uintptr_t)tid);
4468 GHashTableIter iter;
4469 struct target *overlay;
4473 overlay = (
struct target *) \
4474 g_hash_table_lookup(base->
overlays,(gpointer)(uintptr_t)overlaytid);
4475 g_hash_table_remove(base->
overlays,(gpointer)(uintptr_t)overlaytid);
4479 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
4481 g_hash_table_iter_remove(&iter);
4484 RPUT(overlay,target,base,trefcnt);
4492 if (overlay->
base != base || newtid == overlay->
base_tid) {
4509 g_hash_table_insert(base->
overlay_aliases,(gpointer)(uintptr_t)newtid,
4552 if (((space->
name && strcmp(space->
name,lpc->
name) == 0)
4553 || (space->
name == NULL && lpc->
name == NULL))
4554 && space->
tag == lpc->
tag) {
4555 verror(
"addrspace(%s:0x%"PRIxADDR") already attached to target %s!\n",
4563 RHOLD(space,target);
4574 space->
name,space->
tag,target ? target->
name : NULL);
4579 t1 = g_list_find(target->
spaces,space);
4582 space->
name,space->
tag,target ? target->
name : NULL);
4587 target->
spaces = g_list_remove_link(target->
spaces,t1);
4614 "no probepoint at 0x%"PRIxADDR"\n",addr);
4624 (gpointer)probepoint->
addr,(gpointer)probepoint);
4625 probepoint->thread = tthread;
4629 (gpointer)probepoint->
addr,(gpointer)probepoint);
4630 probepoint->thread = tthread;
4633 verror(
"bad probepoint state %d; must be HW/SW!\n",probepoint->
state);
4640 probepoint->
addr,tthread->
tid);
4650 probepoint->
thread = NULL;
4654 probepoint->
thread = NULL;
4657 verror(
"bad probepoint state %d; must be HW/SW!\n",probepoint->
state);
4664 probepoint->
addr,tthread->
tid);
4676 g_hash_table_insert(target->
probes,(gpointer)(uintptr_t)probe->
id,probe);
4683 g_hash_table_remove(target->
probes,(gpointer)(uintptr_t)probe->
id);
4696 g_hash_table_insert(target->
actions,(gpointer)(uintptr_t)action->
id,action);
4702 g_hash_table_remove(target->
actions,(gpointer)(uintptr_t)action->
id);
4712 switch (mmod->
state) {
4729 unsigned char *code,
4730 unsigned int code_len,
int nowrite) {
4732 unsigned char *ibuf = NULL;
4733 unsigned int ibuf_len;
4745 mmod = calloc(1,
sizeof(*mmod));
4749 mmod->
threads = array_list_create(1);
4762 ibuf_len = code_len;
4765 ibuf = calloc(1,ibuf_len);
4773 array_list_free(mmod->
threads);
4786 mmod->
mod = malloc(code_len);
4798 array_list_free(mmod->
threads);
4809 g_hash_table_insert(target->
phys_mmods,(gpointer)addr,mmod);
4811 g_hash_table_insert(target->
mmods,(gpointer)addr,mmod);
4813 array_list_append(mmod->
threads,tthread);
4817 "created memmod at 0x%"PRIxADDR" (is_phys=%d,no_write=%d) tid %"PRIiTID";"
4818 " inserted new bytes (orig mem: %02hhx %02hhx %02hhx %02hhx"
4819 " %02hhx %02hhx %02hhx %02hhx)\n",
4820 mmod->
addr,is_phys,nowrite,tid,
4821 (
int)ibuf[0],(
int)ibuf[1],(
int)ibuf[2],(
int)ibuf[3],
4822 (
int)ibuf[4],(
int)ibuf[5],(
int)ibuf[6],(
int)ibuf[7]);
4826 "created (fake) memmod at 0x%"PRIxADDR" (is_phys=%d) tid %"PRIiTID"\n",
4827 mmod->
addr,is_phys,tid);
4861 g_hash_table_lookup(target->
mmods,(gpointer)
addr);
4865 "found mmod 0x%"PRIxADDR" (phys=%d)\n",
4895 if (array_list_remove_item(mmod->
threads,tthread) != tthread) {
4897 " BUG?!\n",tid,addr);
4907 if (array_list_len(mmod->
threads) == 0) {
4911 return array_list_len(mmod->
threads);
4919 unsigned long (*writer)(
struct target *target,
ADDR paddr,
4920 unsigned long length,
unsigned char *buf);
4927 retval = array_list_len(mmod->
threads);
4931 if (force || array_list_len(mmod->
threads) == 0) {
4933 g_hash_table_remove(target->
phys_mmods,(gpointer)addr);
4935 g_hash_table_remove(target->
mmods,(gpointer)addr);
4946 " but cannot do anything!\n",addr);
4955 array_list_free(mmod->
threads);
4970 unsigned long (*writer)(
struct target *target,
ADDR paddr,
4971 unsigned long length,
unsigned char *buf);
4994 switch (mmod->
state) {
4997 "(was already) memmod 0x%"PRIxADDR" (is_phys=%d)"
5006 rc = writer(target,addr,mmod->
mod_len,mmod->
mod);
5008 verror(
"could not insert subst memory at 0x%"PRIxADDR"!\n",addr);
5013 "(was orig) memmod 0x%"PRIxADDR" (is_phys=%d)"
5014 " tid %"PRIiTID
"\n",
5027 rc = writer(target,addr,mmod->
mod_len,mmod->
mod);
5029 verror(
"could not insert subst memory at 0x%"PRIxADDR"!\n",addr);
5034 "(was tmp) memmod 0x%"PRIxADDR" (is_phys=%d)"
5035 " tid %"PRIiTID
"\n",
5051 unsigned long (*writer)(
struct target *target,
ADDR paddr,
5052 unsigned long length,
unsigned char *buf);
5075 switch (mmod->
state) {
5078 "(was already) memmod 0x%"PRIxADDR" (is_phys=%d)"
5081 mmod->
owner = tthread;
5089 verror(
"could not restore orig memory at 0x%"PRIxADDR"!\n",addr);
5094 "(was set) memmod 0x%"PRIxADDR" (is_phys=%d)"
5095 " tid %"PRIiTID
"\n",
5097 mmod->
owner = tthread;
5110 verror(
"could not restore orig memory at 0x%"PRIxADDR"!\n",addr);
5114 mmod->
owner = tthread;
5125 unsigned char *code,
unsigned long code_len) {
5130 unsigned int new_len;
5131 unsigned long (*writer)(
struct target *target,
ADDR paddr,
5132 unsigned long length,
unsigned char *buf);
5164 mmod->
orig = realloc(mmod->
orig,code_len);
5167 verror(
"could not increase original saved bytes at 0x%"PRIxADDR"!\n",
5174 switch (mmod->
state) {
5176 if (code_len < mmod->tmp_len) {
5179 memcpy(
new,mmod->
orig,new_len);
5182 new = malloc(code_len);
5184 memcpy(
new,code,code_len);
5189 "(was tmp) memmod 0x%"PRIxADDR" (is_phys=%d)"
5194 if (code_len < mmod->mod_len) {
5197 memcpy(
new,mmod->
orig,new_len);
5200 new = malloc(code_len);
5202 memcpy(
new,code,code_len);
5205 "(was set) memmod 0x%"PRIxADDR" (is_phys=%d)"
5206 " tid %"PRIiTID
"\n",
5210 new = malloc(code_len);
5212 memcpy(
new,code,code_len);
5214 "(was orig) memmod 0x%"PRIxADDR" (is_phys=%d)"
5215 " tid %"PRIiTID
"\n",
5227 rc = writer(target,addr,new_len,
new);
5228 if (rc != new_len) {
5238 mmod->
owner = tthread;
5252 tlctxt = calloc(1,
sizeof(*tlctxt));
5273 tlctxt = calloc(1,
sizeof(*tlctxt));
5304 struct bsymbol *alt_bsymbol = NULL;
5326 verror(
"could not find symbol for IP addr 0x%"PRIxADDR"!\n",ipval);
5327 errno = EADDRNOTAVAIL;
5334 bsymbol ? bsymbol : alt_bsymbol);
5335 tlctxt->
frames = array_list_create(8);
5345 tlctxtf = calloc(1,
sizeof(*tlctxtf));
5346 tlctxtf->
tlctxt = tlctxt;
5350 tlctxtf->
registers = g_hash_table_new(g_direct_hash,g_direct_equal);
5354 (gpointer)(uintptr_t)ipval);
5356 array_list_append(tlctxt->
frames,tlctxtf);
5362 struct target *target;
5367 struct bsymbol *alt_bsymbol = NULL;
5390 verror(
"could not find symbol for IP addr 0x%"PRIxADDR"!\n",ipval);
5391 errno = EADDRNOTAVAIL;
5398 tlctxt->
frames = array_list_create(8);
5408 tlctxtf = calloc(1,
sizeof(*tlctxtf));
5409 tlctxtf->
tlctxt = tlctxt;
5413 tlctxtf->
registers = g_hash_table_new(g_direct_hash,g_direct_equal);
5417 (gpointer)(uintptr_t)ipval);
5419 array_list_append(tlctxt->
frames,tlctxtf);
5426 char *frame_sep,
char *ksep) {
5434 char *srcfile = NULL;
5488 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
"%s",frame_sep);
5491 "snprintf(frame_sep %d): %s\n",
5512 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
5516 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
5518 j,ksep,ipval,ksep,name,ksep);
5520 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
5522 j,ksep,ipval,ksep,name,ksep);
5540 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
"%s",ksep);
5543 "snprintf(ksep %d): %s\n",
5571 snprintf(vbuf,
sizeof(vbuf),
"0x");
5572 for (k = 0; k < v->
bufsiz && k < (int)
sizeof(vbuf); ++k) {
5573 snprintf(vbuf + 2 + 2 * k,
sizeof(vbuf) - 2 - 2 * k,
5574 "%02hhx",v->
buf[k]);
5580 snprintf(vbuf,
sizeof(vbuf),
"?");
5584 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
"%s=%s",name,vbuf);
5586 retval = snprintf(buf + rc,((buflen - rc) > 0) ? buflen - rc : 0,
"%s",vbuf);
5607 retval = snprintf(buf + rc, ((buflen - rc) > 0) ? buflen - rc : 0,
5608 ") at %s:%d",srcfile,srcline);
5610 retval = snprintf(buf + rc, ((buflen - rc) > 0) ? buflen - rc : 0,
5611 ")%ssrcfile=%s%ssrcline=%d",
5612 ksep,srcfile,ksep,srcline);
5614 retval = snprintf(buf + rc, ((buflen - rc) > 0) ? buflen - rc : 0,
5616 ksep,srcfile,ksep,srcline);
5647 array_list_item(tlctxt->
frames,frame);
5692 if (g_hash_table_lookup_extended(tlctxtf->
registers,
5693 (gpointer)(uintptr_t)reg,NULL,&v) == TRUE) {
5719 ADDR current_ip = 0;
5722 struct bsymbol *alt_bsymbol = NULL;
5725 ADDR bp = 0,sp = 0,old_bp = 0,old_sp = 0;
5760 (
unsigned char *)tmp);
5765 sp + (pp - tmp),*(uint64_t *)pp);
5769 sp + (pp - tmp),(
ADDR)*(uint32_t *)pp);
5784 (
unsigned char *)tmp);
5807 "could not read retaddr in current_frame %d from symbol;"
5814 "no symbol in current frame; will try to infer retaddr"
5815 " and next symbol!\n");
5823 verror(
"target %s has no frame pointer register!\n",
5830 vwarn(
"could not read %%bp to manually unwind; halting!\n");
5837 (
unsigned char *)&old_bp);
5841 (
unsigned char *)&retaddr);
5849 bp,sp,retaddr,old_bp,old_sp);
5853 "retaddr of current frame %d is 0x%"PRIxADDR"\n",
5856 if (current_ip == 0 && retaddr == 0) {
5857 verror(
"aborting stack trace; two 0x0 retaddrs in a row!\n");
5865 &bsymbol,&alt_bsymbol);
5867 vwarn(
"could not find symbol for IP addr 0x%"PRIxADDR"!\n",retaddr);
5877 new = calloc(1,
sizeof(*
new));
5879 new->frame = array_list_len(tlctxt->
frames);
5882 new->registers = g_hash_table_new(g_direct_hash,g_direct_equal);
5884 g_hash_table_insert(new->registers,
5886 (gpointer)(uintptr_t)retaddr);
5889 g_hash_table_insert(new->registers,
5890 (gpointer)(uintptr_t)rbp,
5891 (gpointer)(uintptr_t)old_bp);
5892 g_hash_table_insert(new->registers,
5893 (gpointer)(uintptr_t)rsp,
5894 (gpointer)(uintptr_t)old_sp);
5897 array_list_append(tlctxt->
frames,
new);
5908 "created new previous frame %d with IP 0x%"PRIxADDR"\n",
5918 unsigned int current_size;
5921 current_size = g_hash_table_size(target_personality_tab);
5927 lib = dlopen(filename,RTLD_NOW | RTLD_GLOBAL);
5929 verror(
"could not load '%s': %s (%s)\n",
5930 filename,dlerror(),strerror(errno));
5935 if (g_hash_table_size(target_personality_tab) == current_size) {
5936 vwarn(
"loaded library %s, but it did not add itself to the"
5937 " personality table! Duplicate personality ID?\n",filename);
5947 if (g_hash_table_lookup(target_personality_tab,(gpointer)personality)) {
5948 verror(
"Personality %s already registered; cannot register.\n",
5954 tpi = calloc(1,
sizeof(*tpi));
5960 g_hash_table_insert(target_personality_tab,(gpointer)tpi->
personality,
5971 if (!target_personality_tab) {
5972 verror(
"Target library improperly initialized -- call target_init!\n");
5980 if (personality_lib) {
5982 vwarn(
"failed to load library '%s'; will try to find"
5983 " personality '%s' elsewhere!\n",personality_lib,personality);
5988 g_hash_table_lookup(target_personality_tab,(gpointer)
personality);
5991 else if (personality_lib) {
5992 vwarn(
"could not find personality '%s' after trying to load"
5993 " personality library '%s'\n",personality,personality_lib);
6005 bufsiz = strlen(personality) + strlen(
".so") + strlen(
"stackdb") + 1;
6006 buf = malloc(bufsiz);
6007 snprintf(buf,bufsiz,
"%s.so",personality);
6010 g_hash_table_lookup(target_personality_tab,(gpointer)personality))) {
6015 vwarn(
"loaded library '%s', but it did not provide personality '%s'!\n",
6020 snprintf(buf,bufsiz,
"stackdb_%s.so",personality);
6023 g_hash_table_lookup(target_personality_tab,(gpointer)personality))) {
6028 vwarn(
"loaded library '%s', but it did not provide personality '%s'!\n",
6033 snprintf(buf,bufsiz,
"vmi_%s.so",personality);
6036 g_hash_table_lookup(target_personality_tab,(gpointer)personality))) {
6041 vwarn(
"loaded library '%s', but it did not provide personality '%s'!\n",
6047 verror(
"could not find personality '%s'!\n",personality);
6053 vwarn(
"Failed to attach personality '%s' on target %d!\n",
6054 personality,target->
id);
6062 "initialized personality '%s' for target %d!\n",
6063 personality,target->
id);
6074 #define TARGET_REGCACHE_ALLOC(tctxt,errretval) \
6076 if (tctxt > target->max_thread_ctxt) { \
6077 verror("target %d only has max thread ctxt %d (%d specified)!\n", \
6078 target->id,target->max_thread_ctxt,tctxt); \
6082 tthread = target_load_thread(target,tid,0); \
6084 verror("target %d could not load thread %d!\n",target->id,tid); \
6086 return (errretval); \
6088 if (!tthread->regcaches[tctxt]) { \
6089 tthread->regcaches[tctxt] = regcache_create(target->arch); \
6091 regcache = tthread->regcaches[tctxt]; \
6094 #define TARGET_REGCACHE_ALLOC_NT(tctxt,errretval) \
6096 if (tctxt > target->max_thread_ctxt) { \
6097 verror("target %d only has max thread ctxt %d (%d specified)!\n", \
6098 target->id,target->max_thread_ctxt,tctxt); \
6102 if (!tthread->regcaches[tctxt]) { \
6103 tthread->regcaches[tctxt] = regcache_create(target->arch); \
6105 regcache = tthread->regcaches[tctxt]; \
6108 #define TARGET_REGCACHE_GET(tctxt,errretval) \
6110 if (tctxt > target->max_thread_ctxt) { \
6111 verror("target %d only has max thread ctxt %d (%d specified)!\n", \
6112 target->id,target->max_thread_ctxt,tctxt); \
6116 tthread = target_load_thread(target,tid,0); \
6118 verror("target %d could not load thread %d!\n",target->id,tid); \
6120 return (errretval); \
6122 if (!tthread->regcaches[tctxt]) { \
6123 verror("target %d could not load thread %d!\n",target->id,tid); \
6124 errno = EADDRNOTAVAIL; \
6125 return (errretval); \
6127 regcache = tthread->regcaches[tctxt]; \
6137 "target %d init reg %s in thid %d ctxt %d 0x%"PRIxREGVAL"\n",
6143 verror(
"target %d thread %d reg %d: could not init reg!\n",
6144 target->
id,tthread->
tid,reg);
6159 vwarn(
"failed -- target %d thid %d tctxt %d\n",target->
id,tid,tctxt);
6164 "target %d thid %d tctxt %d\n",target->
id,tid,tctxt);
6179 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6185 if (!(regcache = tthread->
regcaches[tctxt]))
6200 rawh(target,tthread,tctxt,i,(
void *)regcache->
values[i],
6203 regh(target,tthread,tctxt,i,regcache->
values[i],priv);
6216 verror(
"target %d could not load thread %d!\n",target->
id,tid);
6222 verror(
"target %d only has max thread ctxt %d (thid %d currently %d)!\n",
6229 "target %d reading reg %s in thid %d ctxt %d\n",
6234 "target %d could not load thread %d!\n",target->
id,tid);
6235 errno = EADDRNOTAVAIL;
6242 "target %d thread %d reg %d: could not read!\n",
6243 target->
id,tid,reg);
6257 verror(
"target %d could not load thread %d!\n",target->
id,tid);
6263 verror(
"target %d only has max thread ctxt %d (thid %d currently %d)!\n",
6270 "target %d reading reg %s in thid %d ctxt %d 0x%"PRIxREGVAL"\n",
6274 verror(
"target %d could not load thread %d!\n",target->
id,tid);
6275 errno = EADDRNOTAVAIL;
6281 verror(
"target %d thread %d reg %d: could not write!\n",
6282 target->
id,tid,reg);
6295 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6311 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6327 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6343 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6359 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6370 int detail,
char *sep,
char *kvsep,
int flags) {
6375 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6384 rc = snprintf(buf,bufsiz,
"%stctxt%s%d",sep,kvsep,tctxt);
6388 (rc >= bufsiz) ? NULL : buf + rc,
6389 (rc >= bufsiz) ? 0 : bufsiz - rc,
6390 detail,sep,kvsep,flags);
6401 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6419 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6437 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6455 struct target *target = sthread->
target;
6459 verror(
"target %d only has max thread ctxt %d (%d/%d specified)!\n",
6466 "copying thid %d ctxt %d to thid %d ctxt %d\n",
6467 sthread->
tid,stidctxt,dthread->
tid,dtidctxt);
6483 struct target *target = sthread->
target;
6487 verror(
"target %d only has max thread ctxt %d (%d/%d specified)!\n",
6502 struct target *target = dthread->
target;
6505 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6512 "copying regcache to thid %d ctxt %d\n",
6513 dthread->
tid,dtidctxt);
6524 struct target *target = sthread->
target;
6527 verror(
"target %d only has max thread ctxt %d (%d specified)!\n",
6534 "copying regcache to thid %d ctxt %d\n",
6535 sthread->
tid,stidctxt);
6555 "target %d copying in thid %d ctxt %d\n",
6556 target->
id,tid,tidctxt);
6574 "target %d reading reg %s in thid %d ctxt %d\n",
6580 verror(
"target %d thread %d reg %d ctxt %d: could not read!\n",
6581 target->
id,tid,reg,tidctxt);
6595 "target %d writing reg %s in thid %d ctxt %d 0x%"PRIxREGVAL"\n",
6601 verror(
"target %d thread %d reg %d ctxt %d: could not write!\n",
6602 target->
id,tid,reg,tidctxt);
6621 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
6633 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
6653 "unknown",
"heap",
"stack",
"vdso",
"vsyscall",
"anon",
"main",
"lib",
struct bsymbol * bsymbol_create(struct lsymbol *lsymbol, struct memregion *region)
#define LOCATION_ADDR(loc)
REFCNT target_thread_free(struct target_thread *tthread, int force)
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
int regcache_isdirty_reg_range(struct regcache *regcache, REG start, REG end)
#define RPUTW(x, objtype, hx, rc)
int memregion_contains_real(struct memregion *region, ADDR addr)
struct value * target_load_type(struct target *target, struct symbol *type, ADDR addr, load_flags_t flags)
char * THREAD_STATUS_STRINGS[]
REGVAL target_regcache_readreg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
OFFSET symbol_offsetof(struct symbol *symbol, const char *name, const char *delim)
struct array_list * threads
#define vwarnopt(level, area, flags, format,...)
struct value * value_create_noalloc(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
int(* fini)(struct target *target)
int(* fini)(struct target *target)
GHashTable * regcache_copy_registers(struct regcache *regcache)
unsigned long target_memmod_length(struct target *target, struct target_memmod *mmod)
struct argp_option target_argp_opts_only_one[]
#define TARGET_ARGP_CORE_OPTS
void location_ctxt_free(struct location_ctxt *lctxt)
struct bsymbol * target_lookup_sym_line(struct target *target, char *filename, int line, SMOFFSET *offset, ADDR *addr)
void target_monitor_schedule_global_interrupt(void)
void regcache_mark_flushed(struct regcache *regcache)
struct lsymbol * debugfile_lookup_sym__int(struct debugfile *debugfile, char *name, const char *delim, struct rfilter *srcfile_filter, symbol_type_flag_t flags)
char * linux_userproc_argp_header
int value_snprintf(struct value *value, char *buf, int buflen)
struct lsymbol * lsymbol_lookup_sym__int(struct lsymbol *lsymbol, const char *name, const char *delim)
void value_set_strlen(struct value *value, int len)
target_status_t target_get_status(struct target *target)
struct argp_option target_argp_opts[]
int(* target_regcache_regval_handler_t)(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval, void *priv)
void target_default_sighandler(int signo, siginfo_t *siginfo, void *x)
int target_regcache_zero(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
struct array_list * frames
void * target_argp_driver_state(struct argp_state *state)
REFCNT lsymbol_release(struct lsymbol *lsymbol)
ADDR memregion_unrelocate(struct memregion *region, ADDR real_addr, struct memrange **range_saveptr)
GSList * symbol_get_ordered_members(struct symbol *symbol, symbol_type_flag_t flags)
struct lsymbol * debugfile_lookup_addr__int(struct debugfile *debugfile, ADDR addr)
int(* attach)(struct target *target)
#define TARGET_TYPE_MASK_BASE
REFCNT action_free(struct action *action, int force)
int target_insert_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
struct value * target_load_type_reg(struct target *target, struct symbol *type, tid_t tid, REG reg, load_flags_t flags)
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 regcache_init_done(struct regcache *regcache)
#define TARGET_ARGP_OVERLAY
int target_personality_register(char *personality, target_personality_t pt, struct target_personality_ops *ptops, void *pops)
void target_thread_gkv_remove(struct target *target, tid_t tid, char *key)
struct memregion * region
#define TARGET_TYPE_MASK_OVERLAY
int gdb_spec_to_argv(struct target_spec *spec, int *argc, char ***argv)
struct target_location_ctxt * target_unwind(struct target *target, tid_t tid)
int addrspace_find_range_real(struct addrspace *space, ADDR addr, struct memregion **region_saveptr, struct memrange **range_saveptr)
int target_detach_probe(struct target *target, struct probe *probe)
int target_regcache_copy_all(struct target_thread *sthread, thread_ctxt_t stidctxt, struct target_thread *dthread, thread_ctxt_t dtidctxt)
struct scope * symbol_read_owned_scope(struct symbol *symbol)
int target_lsymbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
int regcache_write_reg(struct regcache *regcache, REG reg, REGVAL regval)
struct linux_userproc_spec * linux_userproc_build_spec(void)
int target_regcache_copy_dirty_to(struct target_thread *sthread, thread_ctxt_t stidctxt, struct regcache *dregcache)
struct target_location_ctxt_frame *(* unwind_prev)(struct target_location_ctxt *tlctxt)
GHashTable * soft_probepoints
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
struct target_personality_ops * personality_ops
struct target_thread * owner
GHashTable * target_regcache_copy_registers(struct target *target, tid_t tid)
OFFSET target_offsetof_symbol(struct target *target, struct bsymbol *bsymbol, char *member, const char *delim)
int symbol_get_srcline(struct symbol *symbol)
struct probepoint * target_lookup_probepoint(struct target *target, struct target_thread *tthread, ADDR addr)
int target_bsymbol_resolve_base(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR *o_addr, struct memrange **o_range)
void vmi_inc_log_level(void)
#define v_g_slist_foreach(gslhead, gslcur, elm)
void location_internal_free(struct location *location)
#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)
unsigned int arch_regsize(struct arch *arch, REG reg)
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
ADDR target_addressof_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags, struct memrange **o_range)
struct target_ops gdb_ops
struct target_thread * base_thread
int target_regcache_copy_from(struct target_thread *dthread, thread_ctxt_t dtidctxt, struct regcache *sregcache)
struct os_process_spec * os_process_build_spec(void)
int target_regcache_init_done(struct target *target, tid_t tid, thread_ctxt_t tctxt)
struct target_location_ctxt * tlctxt
struct php_spec * php_build_spec(void)
int target_pause(struct target *target)
struct target_memmod * target_memmod_create(struct target *target, tid_t tid, ADDR addr, int is_phys, target_memmod_type_t mmt, unsigned char *code, unsigned int code_len, int nowrite)
int vmi_add_log_area_flaglist(char *flaglist, char *separator)
#define TARGET_ARGP_PERSONALITY_LIB
int lsymbol_resolve_bounds(struct lsymbol *lsymbol, ADDR base_addr, struct location_ctxt *lctxt, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
struct scope * target_lookup_addr(struct target *target, uint64_t addr)
int target_cregno(struct target *target, common_reg_t creg, REG *reg)
int(* unwind_read_reg)(struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
int regcache_init_reg(struct regcache *regcache, REG reg, REGVAL regval)
int target_detach_space(struct target *target, struct addrspace *space)
struct target_thread * global_thread
struct regcache * target_regcache_get(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
struct target * target_create(char *type, struct target_spec *spec)
void * target_gkv_steal(struct target *target, char *key)
#define TARGET_REGCACHE_ALLOC_NT(tctxt, errretval)
target_memmod_state_t state
uint32_t symbol_get_bytesize(struct symbol *symbol)
struct debugfile * target_lookup_debugfile(struct target *target, ADDR addr)
int target_regcache_writereg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
char * bsymbol_get_name(struct bsymbol *bsymbol)
struct target_ops os_process_ops
int target_remove_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
#define CODE_CACHE_BUF_PAD
int target_associate_debugfile(struct target *target, struct memregion *region, struct debugfile *debugfile)
int target_close(struct target *target)
struct bsymbol * alt_bsymbol
int target_detach_action(struct target *target, struct action *action)
ADDR target_autoload_pointers(struct target *target, struct symbol *datatype, ADDR addr, load_flags_t flags, struct symbol **datatype_saveptr, struct memrange **range_saveptr)
struct target_ops linux_userspace_process_ops
struct target_thread * thread
#define verror(format,...)
target_personality_t ptype
int target_install_default_sighandlers(void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
struct target_memmod * mmod
unsigned char * __target_load_addr_real(struct target *target, struct memrange *range, ADDR addr, load_flags_t flags, unsigned char *buf, int bufsiz)
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
int location_ctxt_read_retaddr(struct location_ctxt *lctxt, ADDR *o_retaddr)
int target_attach_space(struct target *target, struct addrspace *space)
int target_install_custom_sighandlers(sigset_t *ignored, sigset_t *interrupt, sigset_t *exit, void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
char * symbol_get_srcfile(struct symbol *symbol)
struct symbol * symbol_get_datatype(struct symbol *symbol)
int target_find_memory_real(struct target *target, ADDR addr, struct addrspace **space_saveptr, struct memregion **region_saveptr, struct memrange **range_saveptr)
struct clf_range_data * clrange_find_loosest(clrange_t *clf, Word_t index, struct array_list **al_saveptr)
int linux_userproc_spec_to_argv(struct target_spec *spec, int *argc, char ***argv)
int regcache_copy_all(struct regcache *sregcache, struct regcache *dregcache)
#define LOGDUMPSYMBOL_NL(dl, lt, lf, s)
void probepoint_free_ext(struct probepoint *probepoint)
int location_ctxt_read_reg(struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
void target_detach_thread(struct target *target, struct target_thread *tthread)
int target_regcache_isdirty_reg(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg)
void target_location_ctxt_retarget_bsymbol(struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol)
int(* target_regcache_rawval_handler_t)(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, void *rawval, int rawlen, void *priv)
int symbol_resolve_bounds(struct symbol *symbol, struct location_ctxt *lctxt, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *o_alt_start, ADDR *o_alt_end)
struct lsymbol * symbol_lookup_sym(struct symbol *symbol, const char *name, const char *delim)
int target_invalidate_thread(struct target *target, struct target_thread *tthread)
void vmi_set_log_level(int level)
int target_personality_attach(struct target *target, char *personality, char *personality_lib)
#define vwarn(format,...)
unsigned char * target_read_physaddr(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
struct target_thread * thread
#define LOCATION_WORD(loc)
int location_set_implicit_word(struct location *loc, ADDR word)
int target_lookup_sym_addr_alt(struct target *target, ADDR addr, struct bsymbol **primary, struct bsymbol **alt)
int symbol_type_is_char(struct symbol *type)
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
struct target_location_ctxt_frame * target_location_ctxt_get_frame(struct target_location_ctxt *tlctxt, int frame)
void regcache_invalidate(struct regcache *regcache)
int target_regcache_foreach_dirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, target_regcache_regval_handler_t regh, target_regcache_rawval_handler_t rawh, void *priv)
struct lsymbol * lsymbol_create_from_member(struct lsymbol *parent, struct symbol *member)
struct target_thread * target_load_thread(struct target *target, tid_t tid, int force)
void regcache_zero(struct regcache *regcache)
struct clf_range_data * clrange_find_next_loosest(clrange_t *clf, Word_t index, struct array_list **al_saveptr)
struct regcache ** regcaches
void(* target_gkv_dtor_t)(struct target *target, char *key, void *value)
int(* write_symbol)(struct target *target, struct value *value)
char * lsymbol_get_name(struct lsymbol *lsymbol)
int target_thread_gkv_insert(struct target *target, tid_t tid, char *key, void *value, target_thread_gkv_dtor_t dtor)
int target_bsymbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR base_addr, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
void target_monitor_clear_global_interrupt(void)
void target_default_cleanup()
struct xen_vm_spec * xen_vm_build_spec(void)
int location_set_reg(struct location *l, REG reg)
int regcache_read_reg_ifdirty(struct regcache *regcache, REG reg, REGVAL *regval)
REFCNT bsymbol_release(struct bsymbol *bsymbol)
struct target_thread * current_thread
datatype_code_t datatype_code
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 value * value_create_raw(struct target *target, struct target_thread *thread, struct memrange *range, int len)
struct target_memmod * target_memmod_lookup(struct target *target, tid_t tid, ADDR addr, int is_phys)
void(* target_thread_gkv_dtor_t)(struct target *target, tid_t tid, char *key, void *value)
void target_memmod_set_writeable(struct target *target, struct target_memmod *mmod, int writeable)
unsigned char * target_load_raw_addr_real(struct target *target, ADDR addr, load_flags_t flags, unsigned char *buf, int bufsiz)
int target_location_ctxt_read_reg(struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
int probe_free(struct probe *probe, int force)
struct target_location_ctxt_frame * target_location_ctxt_prev(struct target_location_ctxt *tlctxt)
struct dt_argp_state opts
int target_attach_overlay_thread(struct target *base, struct target *overlay, tid_t newtid)
struct memrange * memregion_find_range_real(struct memregion *region, ADDR real_addr)
struct debugfile_load_opts * debugfile_load_opts_parse(char *optstr)
void target_free_spec(struct target_spec *spec)
target_memmod_type_t type
void(* free_thread_state)(struct target *target, void *state)
struct target_location_ctxt * global_tlctxt
int target_spec_to_argv(struct target_spec *spec, char *arg0, int *argc, char ***argv)
int value_set_child(struct value *value, struct value *parent_value, ADDR addr)
unsigned long target_write_physaddr(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
int target_symbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct symbol *symbol, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
#define SYMBOL_IST_PTR(sym)
int target_lookup_filename_line_addr(struct target *target, ADDR addr, char **filename, int *line)
const char * target_regname(struct target *target, REG reg)
#define TARGET_ARGP_PERSONALITY
#define TARGET_ARGP_START_PAUSED
int target_memmod_unset(struct target *target, tid_t tid, struct target_memmod *mmod)
struct location_ctxt * location_ctxt_create(struct location_ops *ops, void *priv)
struct value * value_create_type(struct target_thread *thread, struct memrange *range, struct symbol *type)
void value_free(struct value *value)
struct target_location_ctxt * target_global_tlctxt(struct target *target)
int target_regcache_copy_all_zero(struct target_thread *sthread, thread_ctxt_t stidctxt, struct target_thread *dthread, thread_ctxt_t dtidctxt)
struct target_spec * spec
void vmi_set_warn_level(int level)
#define TARGET_REGCACHE_GET(tctxt, errretval)
struct value * target_load_value_member(struct target *target, struct target_location_ctxt *tlctxt, struct value *old_value, const char *member, const char *delim, load_flags_t flags)
#define LOGDUMPPROBEPOINT_NL(dl, la, lt, p)
struct bsymbol * target_lookup_sym_addr(struct target *target, ADDR addr)
int target_gkv_insert(struct target *target, char *key, void *value, target_gkv_dtor_t dtor)
int target_location_ctxt_unwind(struct target_location_ctxt *tlctxt)
char * REGION_TYPE_STRINGS[]
#define SYMBOL_IST_STUNC(sym)
struct value * target_load_type_regval(struct target *target, struct symbol *type, tid_t tid, REG reg, REGVAL regval, load_flags_t flags)
void vmi_inc_warn_level(void)
error_t target_argp_parse_opt(int key, char *arg, struct argp_state *state)
int target_regcache_snprintf(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, char *buf, int bufsiz, int detail, char *sep, char *kvsep, int flags)
target_type_t target_type
int location_set_addr(struct location *l, ADDR addr)
int target_store_value(struct target *target, struct value *value)
struct target_thread * thread
ADDR target_load_pointers(struct target *target, ADDR addr, int count, struct memrange **range_saveptr)
struct target_ops php_ops
struct array_list * tpc_stack
#define v_g_list_foreach_safe(glhead, glcur, glnext, elm)
int value_set_addr(struct value *value, ADDR addr)
int target_attach_probe(struct target *target, struct target_thread *thread, struct probe *probe)
#define vdebug(devel, areas, flags, format,...)
int(* attach_overlay_thread)(struct target *base, struct target *overlay, tid_t newtid)
ADDR memrange_unrelocate(struct memrange *range, ADDR real)
int target_regcache_readreg_ifdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL *regval)
REFCNT target_free(struct target *target, int force)
ADDR v_addr(struct value *v)
struct thread_probepoint_context * tpc
struct symbol * symbol_type_skip_qualifiers(struct symbol *type)
int regcache_read_reg(struct regcache *regcache, REG reg, REGVAL *regval)
GList ** base_target_specs
int target_regcache_init_reg_tidctxt(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval)
int target_personality_load(char *filename)
GSList * value_regex_list
struct memregion * region
#define vdebugc(devel, areas, flags, format,...)
#define SYMBOL_IS_TYPE(sym)
struct target_ops * target_get_ops(target_type_t target_type)
struct target_location_ctxt_frame * target_location_ctxt_current_frame(struct target_location_ctxt *tlctxt)
void target_detach_overlay(struct target *base, tid_t overlaytid)
void(* free_thread_state)(struct target *target, void *state)
struct value * value_create(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
int target_detach_overlay_thread(struct target *base, struct target *overlay, tid_t tid)
struct target_personality_ops * ptops
struct array_list * debugfile_load_opts_list
int value_set_reg(struct value *value, REG reg)
int target_regcache_mark_flushed(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
unsigned int thread_ctxt_t
void target_thread_set_status(struct target_thread *tthread, thread_status_t status)
#define list_for_each_entry_safe(pos, n, head, member)
GHashTable * overlay_aliases
target_thread_gkv_dtor_t dtor
struct lsymbol * debugfile_lookup_sym_line__int(struct debugfile *debugfile, char *filename, int line, SMOFFSET *offset, ADDR *addr)
void regcache_destroy(struct regcache *regcache)
void * target_thread_gkv_lookup(struct target *target, tid_t tid, char *key)
#define THREAD_CTXT_DEFAULT
struct list_head ss_actions
REFCNT binfile_release(struct binfile *binfile)
int target_memmod_release(struct target *target, tid_t tid, struct target_memmod *mmod)
struct target * target_lookup_target_id(int id)
uint32_t needmonitorinterrupt
int target_attach_action(struct target *target, struct action *action)
unsigned int symbol_type_full_bytesize(struct symbol *type)
int target_invalidate_all_threads(struct target *target)
int(* invalidate_thread)(struct target *target, struct target_thread *tthread)
struct value * target_load_addr_obj(struct target *target, struct memregion *region, ADDR obj_addr, load_flags_t flags, int len)
struct location_ops target_location_ops
int memrange_contains_real(struct memrange *range, ADDR real_addr)
struct target_spec * target_build_spec(target_type_t type, target_mode_t mode)
struct target_ops xen_vm_ops
int target_regcache_isdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
struct symbol * symbol_type_skip_ptrs(struct symbol *type)
int regcache_isdirty_reg(struct regcache *regcache, REG reg)
void target_reuse_thread_as_global(struct target *target, struct target_thread *thread)
#define TARGET_REGCACHE_ALLOC(tctxt, errretval)
int debugfile_lookup_line_addr(struct debugfile *debugfile, char *filename, ADDR addr)
struct lsymbol * bsymbol_get_lsymbol(struct bsymbol *bsymbol)
struct target_location_ctxt * target_location_ctxt_create(struct target *target, tid_t tid, struct memregion *region)
void target_thread_gkv_destroy(struct target *target, struct target_thread *tthread)
int target_finalize(struct target *target)
GList ** overlay_target_specs
GHashTable * hard_probepoints
struct symbol * bsymbol_get_symbol(struct bsymbol *bsymbol)
loctype_t lsymbol_resolve_location(struct lsymbol *lsymbol, ADDR base_addr, struct location_ctxt *lctxt, struct location *o_loc)
struct target * target_lookup_overlay(struct target *target, tid_t tid)
void * __personality_specific_ops
int target_memmod_set(struct target *target, tid_t tid, struct target_memmod *mmod)
struct value * target_load_addr_real(struct target *target, ADDR addr, load_flags_t flags, int len)
target_status_t target_notify_overlay(struct target *overlay, target_exception_flags_t flags, tid_t tid, ADDR ipval, int *again)
struct scope * scope_lookup_addr(struct scope *scope, ADDR pc)
int(* detach_overlay_thread)(struct target *base, struct target *overlay, tid_t tid)
void os_linux_generic_register(void)
int(* invalidate_thread)(struct target *target, struct target_thread *tthread)
ADDR memregion_relocate(struct memregion *region, ADDR obj_addr, struct memrange **range_saveptr)
void target_gkv_destroy(struct target *target)
int target_regcache_isdirty_reg_range(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG start, REG end)
int target_lookup_line_addr(struct target *target, char *srcfile, ADDR addr)
struct target_spec * target_argp_target_spec(struct argp_state *state)
int debugfile_lookup_filename_line_addr(struct debugfile *debugfile, ADDR addr, char **filename, int *line)
struct value * target_load_symbol_member(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, const char *member, const char *delim, load_flags_t flags)
int target_regcache_invalidate(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
int target_contains_real(struct target *target, ADDR addr)
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
#define SYMBOL_IS_ROOT(sym)
char * SYMBOL_TYPE(int n)
REGVAL target_regcache_readreg(struct target *target, tid_t tid, REG reg)
void target_tid_set_status(struct target *target, tid_t tid, thread_status_t status)
struct target_spec * spec
int target_monitor_schedule_interrupt(struct target *target)
#define LOCATION_REG(loc)
ADDR memrange_relocate(struct memrange *range, ADDR obj)
int target_memmod_set_tmp(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
struct target_location_ctxt *(* unwind)(struct target *target, tid_t tid)
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)
char * symbol_get_name(struct symbol *symbol)
#define RPUT(x, objtype, hx, rc)
void debugfile_load_opts_free(struct debugfile_load_opts *opts)
struct location_ops * location_ops
struct symbol_root * root
char * debugfile_root_prefix
struct regcache * regcache_create(struct arch *arch)
int regcache_snprintf(struct regcache *regcache, char *buf, int bufsiz, int detail, char *sep, char *kvsep, int flags)
unsigned int max_thread_ctxt
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)
void target_set_status(struct target *target, target_status_t status)
void * clrange_find(clrange_t *clf, Word_t index)
struct target_thread * thread
target_type_t target_type(struct target *target)
unsigned long target_write_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
struct gdb_spec * gdb_build_spec(void)
void value_set_const(struct value *value)
int target_lookup_safe_disasm_range(struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
target_status_t(* handle_overlay_exception)(struct target *overlay, target_exception_flags_t flags, tid_t tid, ADDR ipval, int *again)
int regcache_copy_dirty(struct regcache *sregcache, struct regcache *dregcache)
struct bsymbol * target_lookup_sym_member(struct target *target, struct bsymbol *bsymbol, const char *name, const char *delim)
void target_gkv_remove(struct target *target, char *key)
void * target_gkv_lookup(struct target *target, char *key)
int target_monitor_handling_exception(struct target *target)
GHashTable * target_regcache_copy_registers_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt)
int target_thread_filter_check(struct target *target, tid_t tid, struct target_nv_filter *tf)
int target_lookup_next_safe_disasm_range(struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
#define INIT_LIST_HEAD(ptr)
struct argp linux_userproc_argp
int vdebug_is_on(int level, log_areas_t areas, log_flags_t flags)
struct target_thread * target_create_thread(struct target *target, tid_t tid, void *tstate, void *tpstate)
int clrange_add(clrange_t *clf, Word_t start, Word_t end, void *data)
int debugfile_lookup_addr_alt__int(struct debugfile *debugfile, ADDR addr, struct lsymbol **primary, struct lsymbol **alt)
int target_regcache_writereg(struct target *target, tid_t tid, REG reg, REGVAL value)
int target_write_reg(struct target *target, tid_t tid, REG reg, REGVAL value)
void * target_thread_gkv_steal(struct target *target, tid_t tid, char *key)
struct location_ctxt * lctxt
int regcache_isdirty(struct regcache *regcache)
int target_thread_obj_flags_propagate(struct target_thread *tthread, obj_flags_t orf, obj_flags_t nandf)
int target_memmod_free(struct target *target, tid_t tid, struct target_memmod *mmod, int force)
struct memregion * region
void target_driver_argp_init_children(struct argp_state *state)
#define LOGDUMPSYMBOL(dl, lt, lf, s)
#define SYMBOL_IS_VAR(sym)
loctype_t target_lsymbol_resolve_location(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, load_flags_t flags, struct location *o_loc, struct symbol **o_datatype, struct memrange **o_range)
int xen_vm_spec_to_argv(struct target_spec *spec, int *argc, char ***argv)
clrange_t clrange_create(void)
active_probe_flags_t ap_flags
#define OBJSDEAD(obj, type)
char * xen_vm_argp_header
struct value *(* read_symbol)(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
unsigned char * target_load_code(struct target *target, ADDR start, unsigned int len, int nocache, int force_copy, int *caller_free)