23 #include <sys/types.h>
47 static void os_linux_mm_free(
struct os_linux_mm *olmm);
49 struct probe *trigger,
struct probe *base);
51 struct probe *trigger,
struct probe *base);
60 char *major = NULL,*minor = NULL,*patch = NULL;
74 g_hash_table_lookup(target->
config,
"OS_KERNEL_FILENAME");
77 g_hash_table_lookup(target->
config,
"MAIN_FILENAME");
85 for (i = 0; i < slen; ++i) {
95 verror(
"could not parse kernel version info for %s!\n",
105 kdir = malloc(ksize + 1);
125 "%s/usr/lib/debug/lib/modules/%s/vmlinux",
134 "%s/usr/lib/debug/boot/vmlinux-%s",
143 "%s/boot/vmlinux-%s",
152 "%s/boot/vmlinux-syms-%s",
168 "%s/vmlinux-syms-%s",
175 verror(
"could not find vmlinux binary for %s!\n",
184 g_hash_table_insert(target->
config,strdup(
"OS_KERNEL_FILENAME"),
200 "%s/lib/modules/%s/System.map",
209 "%s/boot/System.map-%s",
225 verror(
"could not find System.map file for %s!\n",
230 g_hash_table_insert(target->
config,strdup(
"OS_KERNEL_SYSMAP_FILE"),
238 "/lib/modules/%s",tmp+strlen(
"vmlinuz-"));
243 "/lib/modules/%s",tmp+strlen(
"vmlinux-syms-"));
248 "/lib/modules/%s",tmp+strlen(
"vmlinux-"));
252 &major,&minor,&patch) == 3) {
253 g_hash_table_insert(target->
config,strdup(
"__VERSION_MAJOR"),major);
254 g_hash_table_insert(target->
config,strdup(
"__VERSION_MINOR"),minor);
255 g_hash_table_insert(target->
config,strdup(
"__VERSION_PATCH"),patch);
274 if (pbuf[0] ==
'\0') {
275 snprintf(pbuf,
sizeof(pbuf),
"%s/lib/modules/%s/config-%s",
279 if (access(pbuf,R_OK))
282 if (pbuf[0] ==
'\0') {
283 snprintf(pbuf,
sizeof(pbuf),
"%s/boot/config-%s",
287 if (access(pbuf,R_OK))
290 if (pbuf[0] ==
'\0') {
291 snprintf(pbuf,
sizeof(pbuf),
"/boot/config-%s",
293 if (access(pbuf,R_OK))
296 if (pbuf[0] ==
'\0') {
297 snprintf(pbuf,
sizeof(pbuf),
"%s/config-%s",
299 if (access(pbuf,R_OK))
303 if (pbuf[0] !=
'\0') {
304 cf = fopen(pbuf,
"r");
306 verror(
"fopen(%s): %s\n",pbuf,strerror(errno));
310 if (!fgets(pbuf,
sizeof(pbuf),cf))
316 if (sscanf(pbuf,
"%m[^ \t=]=\"%ms\"",&k,&v) == 2) {
317 g_hash_table_insert(target->
config,k,v);
328 if (sscanf(pbuf,
"%m[^ \t=]=%ms",&k,&v) == 2) {
329 g_hash_table_insert(target->
config,k,v);
343 vwarn(
"could not read kernel config from %s; strange errors may result!\n",
348 verror(
"could not infer kernel ELF file (vmlinux) from %s; aborting!\n",
359 verror(
"binfile_open %s: %s\n",
369 "loaded ELF arch info for %s (wordsize=%d;endian=%s)\n",
375 g_hash_table_new(g_direct_hash,g_direct_equal);
378 g_hash_table_new(g_direct_hash,g_direct_equal);
380 g_hash_table_new(g_direct_hash,g_direct_equal);
424 g_hash_table_iter_init(&iter,lstate->
processes);
425 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
428 g_hash_table_iter_remove(&iter);
435 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
437 os_linux_mm_free(olmm);
438 g_hash_table_iter_remove(&iter);
523 "could not resolve addr of .text;"
524 " trying startup_(32|64)!\n");
531 "could not find symbol .text; trying startup_(32|64)!\n");
545 "could not resolve addr of startup_32!\n");
552 "could not find symbol startup_32!\n");
563 "could not resolve addr of startup_64!\n");
570 "could not find symbol startup_64!\n");
577 vwarn(
"could not find addr of .text nor startup_(32|64);"
578 " using defaults!\n");
589 g_hash_table_insert(target->
config,
590 strdup(
"OS_KERNEL_START_ADDR"),strdup(buf));
605 "could not resolve addr of hypercall_page!\n");
609 g_hash_table_insert(target->
config,
610 strdup(
"OS_KERNEL_HYPERCALL_PAGE"),strdup(buf));
617 "could not find symbol hypercall_page!\n");
626 vwarn(
"could not lookup init_task in debuginfo; no multithread support!\n");
635 vwarn(
"could not resolve addr of init_task!\n");
639 g_hash_table_insert(target->
config,
640 strdup(
"OS_KERNEL_INIT_TASK_ADDR"),strdup(buf));
654 vwarn(
"could not lookup 'struct mm_struct' in debuginfo;"
655 " userspace vm access might fail!\n");
676 vwarn(
"could not resolve offset of task_struct.tasks!\n");
678 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
679 g_hash_table_insert(target->
config,
680 strdup(
"OS_KERNEL_TASKS_OFFSET"),strdup(buf));
685 vwarn(
"could not resolve offset of task_struct.pid!\n");
687 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
688 g_hash_table_insert(target->
config,
689 strdup(
"OS_KERNEL_PID_OFFSET"),strdup(buf));
694 vwarn(
"could not resolve offset of task_struct.mm!\n");
696 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
697 g_hash_table_insert(target->
config,
698 strdup(
"OS_KERNEL_MM_OFFSET"),strdup(buf));
703 vwarn(
"could not resolve offset of mm_struct.pgd!\n");
705 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
706 g_hash_table_insert(target->
config,
707 strdup(
"OS_KERNEL_MM_PGD_OFFSET"),strdup(buf));
717 "attempting to find per-cpu kernel stack offset\n");
727 verror(
"could not load kernel_stack percpu offset;"
728 " cannot continue!\n");
740 verror(
"could not load per_cpu__kernel_stack percpu offset;"
741 " cannot continue!\n");
751 verror(
"could not get offsetof struct x8664_pda.kernelstack;"
752 " cannot continue!\n");
757 verror(
"could not find x86_64 kernel stack percpu var in debuginfo;"
758 " cannot continue!\n");
769 "attempting to find per-cpu irq_count offset\n");
779 vwarn(
"could not load per_cpu__irq_count percpu offset;"
780 " cannot continue!\n");
791 vwarn(
"could not get offsetof struct x8664_pda.irqcount;"
792 " cannot continue!\n");
798 vwarn(
"could not find x86_64 irq_count percpu var in debuginfo;"
799 " cannot continue!\n");
815 vwarn(
"could not lookup 'struct pt_regs' in debuginfo;"
816 " no multithread support!\n");
864 vwarn(
"could not find (r|e)ip in pt_regs; things will break!\n");
884 vwarn(
"could not find thread_info nor stack member in struct task_struct;"
885 " no multithread support!\n");
904 vwarn(
"could not find uid/gid info in struct task_struct;"
905 " no uid/gid thread context support!\n");
914 vwarn(
"could not lookup 'struct thread_struct' in debuginfo;"
915 " no multithread support!\n");
941 vwarn(
"could not find 'struct thread_struct.(esp0|sp|rsp0)';"
942 " will cause problems!\n");
1017 if (!thread_info_type) {
1018 vwarn(
"could not lookup 'struct thread_info' in debuginfo;"
1019 " no multithread support!\n");
1032 vwarn(
"could not lookup 'struct module'; no module debuginfo support!\n");
1036 vwarn(
"could not lookup modules; not updating modules list!\n");
1048 vwarn(
"could not lookup module_free; active memory updates"
1049 " cannot function!\n");
1057 vwarn(
"could not lookup module_free.mod; active memory updates"
1058 " cannot function!\n");
1075 err_vmiload_meminfo:
1081 vwarn(
"could not lookup MODULE_STATE_* var; active memory updates"
1082 " cannot function!\n");
1086 #ifdef APF_TE_COPY_PROCESS
1090 vwarn(
"could not lookup copy_process;"
1091 " active thread entry updates cannot function!\n");
1108 vwarn(
"could not lookup wake_up_new_task;"
1109 " active thread entry updates cannot function!\n");
1117 vwarn(
"could not lookup wake_up_new_task.p;"
1118 " active thread entry updates might not function!\n");
1125 vwarn(
"could not lookup sched_exit; trying __unhash_process!\n");
1130 vwarn(
"could not lookup __unhash_process;"
1131 " active thread exit updates cannot function!\n");
1138 vwarn(
"could not lookup __unhash_process.p;"
1139 " active thread exit updates cannot function!\n");
1147 vwarn(
"could not lookup sched_exit.p;"
1148 " active thread exit updates cannot function!\n");
1166 if (g_hash_table_lookup(target->
config,
1167 "OS_EMULATE_USERSPACE_EXCEPTIONS"))
1177 vwarn(
"could not resolve addr of swapper_pg_dir!\n");
1181 g_hash_table_insert(target->
config,
1182 strdup(
"OS_KERNEL_PGD_ADDR"),strdup(buf));
1199 g_hash_table_insert(target->
config,
1200 strdup(
"OS_KERNEL_PGD_ADDR"),strdup(buf));
1203 lstate->
pgd_addr = 0xffffffff81c0d000;
1211 vwarn(
"could not find 'swapper_pg_dir' nor 'init_mm.pgd';"
1212 " kernel v2p may fail!\n");
1223 if (ltstate->
pgd == 0)
1245 "could not resolve bounds of __schedule!\n");
1257 &end,NULL,NULL,NULL)) {
1259 "could not resolve bounds of schedule!\n");
1267 int caller_should_free = 0;
1268 unsigned char *cbuf;
1271 &caller_should_free);
1274 "could not load code of __schedule/schedule();"
1275 " will not be able to load IP for sleeping threads!\n");
1286 && (i + 1) < len && cbuf[i + 1] == 0x8b
1287 && (i + 2) < len && cbuf[i + 2] == 0xa6)
1296 "found x86_64 schedule swap %%rsp instruction"
1301 if (caller_should_free) {
1318 vwarn(
"could not resolve addr of ret_from_fork;"
1319 " will not be able to load IP for newly forked"
1320 " sleeping threads!\n");
1341 verror(
"could not lookup do_int3\n");
1348 &start,NULL,NULL,NULL,NULL)) {
1349 verror(
"could not resolve base addr for symbol %s!\n",
1358 verror(
"could not probe do_int3\n");
1364 verror(
"could not probe addr 0x%"PRIxADDR" for do_int3\n",start);
1376 verror(
"could not lookup do_debug\n");
1383 &start,NULL,NULL,NULL,NULL)) {
1384 verror(
"could not resolve base addr for symbol %s!\n",
1393 verror(
"could not probe do_debug\n");
1399 verror(
"could not probe addr 0x%"PRIxADDR" for do_debug\n",start);
1413 verror(
"cannot handle userspace exceptions via do_int3/do_debug!\n");
1431 rc |= os_linux_updateregions(target,space);
1438 struct probe *trigger,
struct probe *base) {
1443 struct target *overlay;
1445 tid_t overlay_leader_tid;
1491 overlay_leader_tid =
1496 "found yet-unknown thread %d with"
1497 " overlay leader %d; will notify!\n",
1498 tthread->
tid,overlay_leader_tid);
1502 "could not find overlay target for tid %d!\n",tid);
1511 "user-mode breakpoint in overlay tid %"PRIiTID
1513 " passing to overlay!\n",
1534 "emulating debug memmod at bp for tid %"PRIiTID
1536 tid,pmmod->
addr,realip);
1539 verror(
"could not emulate debug memmod for"
1540 " tid %"PRIiTID" at paddr 0x%"PRIxADDR
"\n",
1546 verror(
"user-mode debug event (not single step) at 0x%"PRIxADDR";"
1547 " eflags 0x%"PRIxREGVAL
"; skipping handling!\n",
1559 verror(
"could not create return action!\n");
1562 verror(
"could not schedule return action!\n");
1577 struct probe *trigger,
struct probe *base) {
1582 struct target *overlay;
1584 tid_t overlay_leader_tid;
1621 overlay_leader_tid =
1626 "found yet-unknown thread %d with"
1627 " overlay leader %d; will notify!\n",
1628 tthread->
tid,overlay_leader_tid);
1632 "could not find overlay target for tid %d!\n",tid);
1641 "user-mode breakpoint in overlay tid %"PRIiTID
1643 " passing to overlay!\n",
1656 "emulating debug memmod at ss for tid %"PRIiTID
1658 tid,pmmod->
addr,ip);
1661 verror(
"could not emulate debug memmod for"
1662 " tid %"PRIiTID" at paddr 0x%"PRIxADDR
"\n",
1668 verror(
"user-mode debug event (not single step) at 0x%"PRIxADDR";"
1669 " eflags 0x%"PRIxREGVAL
"; skipping handling!\n",
1680 verror(
"could not create return action!\n");
1683 verror(
"could not schedule return action!\n");
1703 GHashTableIter iter;
1718 os_linux_updateregions(target,space);
1728 t1 = g_hash_table_get_values(target->
threads);
1735 "active-probed exiting thread %"PRIiTID" (%s)"
1736 " is still running; not deleting yet!\n",
1741 "active-probed exiting thread %"PRIiTID" (%s)"
1742 " can be deleted; doing it\n",
1761 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
1765 os_linux_mm_free(olmm);
1766 g_hash_table_iter_remove(&iter);
1785 uint64_t retval = 0;
1791 unsigned long int vnum;
1805 verror(
"could not find system_utsname.release"
1806 " nor init_uts_ns.name.release!\n");
1813 verror(
"could not load %s!\n",
1829 vnum = strtoul(next,&endptr,10);
1830 if (endptr == next) {
1831 verror(
"could not determine major release number from '%s'!\n",v->
buf);
1835 retval |= vnum << 16;
1839 vnum = strtoul(next,&endptr,10);
1840 if (endptr == next) {
1841 verror(
"could not determine minor release number from '%s'!\n",v->
buf);
1845 retval |= vnum << 8;
1849 vnum = strtoul(next,&endptr,10);
1850 if (endptr == next) {
1851 verror(
"could not determine patchlevel release number from '%s'!\n",
1859 "version number %"PRIu64
" (0x%"PRIx64
") from '%s'",
1864 target_gkv_dtor_free);
1865 sretval = malloc(
sizeof(*sretval));
1866 *(uint64_t *)sretval = retval;
1868 target_gkv_dtor_free);
1882 if (ourvers == vers)
1884 else if (ourvers < vers)
1927 if (!ltstate->task_struct) {
1929 "thread %d did not have a task struct value!\n",tthread->
tid);
1934 if (
value_addr(ltstate->task_struct) == ltstate->group_leader)
1946 array_list_free(tlist);
1950 array_list_free(tlist);
1955 "trying to load tid %d's group_leader at 0x%"PRIxADDR"\n",
1956 tthread->
tid,ltstate->group_leader);
1961 vwarn(
"could not load tid %d's group_leader at 0x%"PRIxADDR"; BUG?!\n",
1962 tthread->
tid,ltstate->group_leader);
1967 verror(
"could not load thread from task value at 0x%"PRIxADDR"; BUG?\n",
1968 ltstate->group_leader);
1974 "new group leader loaded (%"PRIiTID",%s)\n",
1981 int signo,
void *data) {
1985 struct value *signal_v;
1986 struct value *signal_pending_v;
1987 struct value *signal_pending_signal_v;
1989 uint32_t sigmask = 1UL << (signo - 1);
1995 "thread %d did not have a task struct value!\n",tthread->
tid);
2004 "sending %s (%d) to %d %s\n",
2005 signame,signo,tthread->
tid,tthread->
name);
2018 signal_pending_signal_v =
2023 sizeof(uint32_t))) {
2024 verror(
"could not setup pending signal %s (%d) to %d %s!\n",
2025 signame,signo,tthread->
tid,tthread->
name);
2065 signal_pending_signal_v =
2069 sizeof(uint32_t))) {
2070 verror(
"could not setup pending signal %d!\n",signo);
2076 #define LOCAL_TIF_SIGPENDING (1UL << 2)
2097 {
"SIGHUP",SIGHUP },
2098 {
"SIGINT",SIGINT },
2099 {
"SIGQUIT",SIGQUIT },
2100 {
"SIGILL",SIGILL },
2101 {
"SIGTRAP",SIGTRAP },
2102 {
"SIGABRT",SIGABRT },
2103 {
"SIGIOT",SIGIOT },
2104 {
"SIGBUS",SIGBUS },
2105 {
"SIGFPE",SIGFPE },
2106 {
"SIGKILL",SIGKILL },
2107 {
"SIGUSR1",SIGUSR1 },
2108 {
"SIGSEGV",SIGSEGV },
2109 {
"SIGUSR2",SIGUSR2 },
2110 {
"SIGPIPE",SIGPIPE },
2111 {
"SIGALRM",SIGALRM },
2112 {
"SIGTERM",SIGTERM },
2113 {
"SIGSTKFLT",SIGSTKFLT },
2114 {
"SIGCLD",SIGCLD },
2115 {
"SIGCHLD",SIGCHLD },
2116 {
"SIGCONT",SIGCONT },
2117 {
"SIGSTOP",SIGSTOP },
2118 {
"SIGTSTP",SIGTSTP },
2119 {
"SIGTTIN",SIGTTIN },
2120 {
"SIGTTOU",SIGTTOU },
2121 {
"SIGURG",SIGURG },
2122 {
"SIGXCPU",SIGXCPU },
2123 {
"SIGXFSZ",SIGXFSZ },
2124 {
"SIGVTALRM",SIGVTALRM },
2125 {
"SIGPROF",SIGPROF },
2126 {
"SIGWINCH",SIGWINCH },
2127 {
"SIGPOLL",SIGPOLL },
2129 {
"SIGPWR",SIGPWR },
2130 {
"SIGSYS",SIGSYS },
2138 if (!sigmap[i].
name)
2140 if (sigmap[i].signo == signo)
2141 return sigmap[i].
name;
2149 char *argcopy = NULL;
2154 argcopy = strdup(name);
2155 len = strlen(argcopy);
2156 for (i = 0; i <
len; ++i)
2157 argcopy[i] = toupper(argcopy[i]);
2160 if (!sigmap[i].name)
2162 if (strcmp(sigmap[i].name,argcopy) == 0) {
2164 return sigmap[i].
signo;
2171 len = strlen(name) + 3 + 1;
2172 argcopy = (
char *)malloc(len);
2173 snprintf(argcopy,len,
"SIG%s",name);
2174 for (i = 0; i <
len; ++i)
2175 argcopy[i] = toupper(argcopy[i]);
2177 if (!sigmap[i].name)
2179 if (strcmp(sigmap[i].name,argcopy) == 0) {
2181 return sigmap[i].
signo;
2189 static void __os_linux_syscalls_by_num_dtor(
struct target *
target,
2190 char *key,
void *
value) {
2191 GHashTableIter iter;
2194 GHashTable *syscalls_by_num;
2196 syscalls_by_num = (GHashTable *)value;
2198 if (syscalls_by_num) {
2199 g_hash_table_iter_init(&iter,syscalls_by_num);
2200 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
2208 g_hash_table_destroy(syscalls_by_num);
2212 static void __os_linux_syscalls_by_X_dtor(
struct target *target,
2213 char *key,
void *value) {
2214 GHashTable *syscalls_by_X;
2216 syscalls_by_X = (GHashTable *)value;
2219 g_hash_table_destroy(syscalls_by_X);
2224 struct value *v = NULL;
2227 GHashTable *syscalls_by_num;
2228 GHashTable *syscalls_by_addr;
2229 GHashTable *syscalls_by_name;
2245 verror(
"could not lookup symbol sys_call_table!\n");
2252 verror(
"could not load sys_call_table!\n");
2260 syscalls_by_num = g_hash_table_new(g_direct_hash,g_direct_equal);
2261 syscalls_by_addr = g_hash_table_new(g_direct_hash,g_direct_equal);
2262 syscalls_by_name = g_hash_table_new(g_str_hash,g_str_equal);
2269 __os_linux_syscalls_by_num_dtor);
2271 __os_linux_syscalls_by_X_dtor);
2273 __os_linux_syscalls_by_X_dtor);
2280 while ((current - v->
buf) < v->
bufsiz) {
2281 sc = calloc(1,
sizeof(*sc));
2288 if (strncmp(
"stub_",name,strlen(
"stub_")) == 0) {
2289 wrapped_name = malloc(strlen(name));
2290 sprintf(wrapped_name,
"sys_%s",name + strlen(
"stub_"));
2300 g_hash_table_insert(syscalls_by_num,
2301 (gpointer)(uintptr_t)sc->
num,sc);
2303 g_hash_table_insert(syscalls_by_addr,
2304 (gpointer)(uintptr_t)sc->
addr,sc);
2306 g_hash_table_insert(syscalls_by_name,
2326 GHashTableIter iter;
2329 GHashTable *syscalls_by_num;
2330 GHashTable *syscalls_by_addr;
2331 GHashTable *syscalls_by_name;
2333 syscalls_by_num = (GHashTable *) \
2335 syscalls_by_name = (GHashTable *) \
2337 syscalls_by_addr = (GHashTable *) \
2340 if (syscalls_by_name) {
2341 g_hash_table_destroy(syscalls_by_name);
2344 if (syscalls_by_addr) {
2345 g_hash_table_destroy(syscalls_by_addr);
2348 if (syscalls_by_num) {
2349 g_hash_table_iter_init(&iter,syscalls_by_num);
2350 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
2356 g_slist_free(sc->
args);
2360 g_hash_table_destroy(syscalls_by_num);
2373 GHashTable *syscalls;
2375 if (!(syscalls = (GHashTable *) \
2380 syscalls = (GHashTable *) \
2389 GHashTable *syscalls;
2391 if (!(syscalls = (GHashTable *) \
2396 syscalls = (GHashTable *) \
2401 g_hash_table_lookup(syscalls,(gpointer)(uintptr_t)num);
2406 GHashTable *syscalls;
2408 if (!(syscalls = (GHashTable *) \
2413 syscalls = (GHashTable *) \
2418 g_hash_table_lookup(syscalls,(gpointer)(uintptr_t)addr);
2454 static int _os_linux_syscall_probe_init(
struct target *target) {
2455 struct bsymbol *system_call_bsymbol = NULL;
2456 ADDR system_call_base_addr = 0;
2458 struct array_list *system_call_ret_idata_list = NULL;
2459 int caller_should_free = 0;
2461 unsigned char *cbuf = NULL;
2476 if (!system_call_bsymbol) {
2477 verror(
"could not lookup system_call;"
2478 " smart syscall probing will fail!\n");
2482 system_call_bsymbol);
2484 system_call_bsymbol->
lsymbol,0,
2485 &system_call_base_addr,&end,NULL,
2487 verror(
"could not resolve base addr of system_call;"
2488 " smart syscall probing will fail!\n");
2494 end - system_call_base_addr,
2495 0,0,&caller_should_free))) {
2496 verror(
"could not load code of system_call;"
2497 " smart syscall probing will fail!\n");
2502 cbuf,end - system_call_base_addr,
2503 &system_call_ret_idata_list,
2504 system_call_base_addr,1)) {
2505 verror(
"could not disassemble system_call in range"
2507 " smart syscall probing will fail!\n",
2508 system_call_base_addr,end);
2511 if (!system_call_ret_idata_list
2512 || array_list_len(system_call_ret_idata_list) <= 0) {
2513 verror(
"no IRETs or SYSRETs in system_call;"
2514 " smart syscall probing will fail!\n");
2520 target_gkv_dtor_bsymbol);
2521 ap = calloc(1,
sizeof(*ap));
2522 memcpy(ap,&system_call_base_addr,
sizeof(*ap));
2524 target_gkv_dtor_free);
2526 system_call_ret_idata_list,
2527 target_gkv_dtor_alist_deep_free);
2534 if (system_call_ret_idata_list)
2535 array_list_deep_free(system_call_ret_idata_list);
2536 if (caller_should_free)
2538 if (system_call_bsymbol)
2544 #define SYSCALL_GLOBAL_ENTRY_PROBE "os_linux_syscall_entry_probe"
2545 #define SYSCALL_GLOBAL_RET_PROBE "os_linux_syscall_ret_probe"
2547 static int __global_entry_uncache(
struct probe *
probe) {
2552 static struct probe_ops __global_entry_probe_ops = {
2553 .
fini = __global_entry_uncache,
2556 static int __syscall_entry_uncache(
struct probe *
probe) {
2561 static struct probe_ops __syscall_entry_probe_ops = {
2562 .
fini = __syscall_entry_uncache,
2565 static int __global_ret_uncache(
struct probe *
probe) {
2570 static struct probe_ops __global_ret_probe_ops = {
2571 .
fini = __global_ret_uncache,
2577 struct probe *trigger,
2578 struct probe *base) {
2579 struct target *target;
2597 verror(
"could not record syscall entry in tid %"PRIiTID"!\n",tid);
2606 argvals = array_list_create(6);
2620 array_list_append(argvals,v);
2632 static result_t __global_entry_handler(
struct probe *probe,
tid_t tid,
2634 struct probe *trigger,
2635 struct probe *base) {
2636 struct target *target;
2643 struct symbol *argsym;
2649 static REG regs_x86_64[6] = { 5,4,1,10,8,9 };
2653 static REG regs_i386[6] = { 3,1,2,6,7,5 };
2661 vwarn(
"could not find syscall for eax %d in tid %"PRIiTID"; ignoring!\n",
2668 verror(
"could not record syscall entry in tid %"PRIiTID"!\n",tid);
2681 regvals = array_list_create(6);
2682 for (j = 0; j < 6; ++j) {
2683 array_list_append(regvals,
2692 if (syscall->
args) {
2693 argvals = array_list_create(6);
2697 array_list_append(argvals,NULL);
2702 (
REGVAL)array_list_item(regvals,j),
2704 array_list_append(argvals,v);
2707 array_list_append(argvals,NULL);
2725 static result_t __syscall_ret_handler(
struct probe *probe,
tid_t tid,
2727 struct probe *trigger,
2728 struct probe *base) {
2729 struct target *target;
2737 "could not find a current syscall tid %"PRIiTID"; ignoring!\n",
2743 "current syscall for tid %"PRIiTID" already returned; ignoring!\n",
2755 static struct probe *
2756 os_linux_syscall_probe_init_syscall_entry(
struct target *target,
2758 struct probe *
probe;
2767 snprintf(namebuf,
sizeof(namebuf),
"os_linux_%s_probe",
2773 if (_os_linux_syscall_probe_init(target))
2777 namebuf,__syscall_entry_handler,NULL,syscall,1,1);
2780 verror(
"could not register %s!\n",namebuf);
2791 static struct probe *
2792 os_linux_syscall_probe_init_global_entry(
struct target *target) {
2793 struct bsymbol *system_call_bsymbol;
2794 ADDR *system_call_base_addr = NULL;
2795 struct probe *
probe;
2797 if ((probe = (
struct probe *) \
2801 if (_os_linux_syscall_probe_init(target))
2804 system_call_base_addr = (
ADDR *) \
2806 system_call_bsymbol = (
struct bsymbol *) \
2818 __global_entry_handler,NULL,NULL,1,1);
2822 system_call_bsymbol)) {
2823 verror(
"could not register system_call entry probe at 0x%"PRIxADDR"!\n",
2824 *system_call_base_addr);
2831 target_gkv_dtor_probe);
2836 static struct probe *
2837 os_linux_syscall_probe_init_global_ret(
struct target *target) {
2838 ADDR *system_call_base_addr;
2839 struct array_list *system_call_ret_idata_list;
2840 struct probe *rprobe;
2841 struct probe *
probe;
2847 if ((probe = (
struct probe *) \
2851 if (_os_linux_syscall_probe_init(target))
2854 if (!(system_call_ret_idata_list = (
struct array_list *) \
2856 verror(
"BUG: could not find system_call RET info!\n");
2860 system_call_base_addr = (
ADDR *) \
2870 NULL,__syscall_ret_handler,NULL,1,1);
2876 name_len =
sizeof(
"system_call_SYSRET_+") + 12;
2877 name = malloc(name_len);
2880 snprintf(name,name_len,
2892 rprobe->
name,*system_call_base_addr + idata->
offset);
2899 verror(
"could not register probe %s on source %s!\n",
2909 target_gkv_dtor_probe);
2930 static const char *_os_linux_syscall_probe_gettype(
struct probe *probe) {
2931 return "os_linux_syscall_probe";
2935 .
gettype = _os_linux_syscall_probe_gettype,
2956 void *handler_data) {
2957 struct probe *
probe, *eprobe, *rprobe;
2960 snprintf(namebuf,
sizeof(namebuf),
"os_linux_syscall_probe_%s",
2963 probe =
probe_create(target,tid,&os_linux_syscall_ret_probe_ops,
2964 namebuf,pre_handler,post_handler,handler_data,0,1);
2966 eprobe = os_linux_syscall_probe_init_syscall_entry(target,syscall);
2968 verror(
"could not setup syscall entry probe!\n");
2973 rprobe = os_linux_syscall_probe_init_global_ret(target);
2975 verror(
"could not setup global system_call ret probes!\n");
2987 static const char *_os_linux_global_syscall_probe_gettype(
struct probe *probe) {
2988 return "os_linux_global_syscall_probe";
2992 .
gettype = _os_linux_global_syscall_probe_gettype,
3001 void *handler_data) {
3002 struct probe *
probe, *eprobe, *rprobe;
3004 probe =
probe_create(target,tid,&os_linux_global_syscall_ret_probe_ops,
3005 "os_linux_global_syscall_probe",
3006 pre_handler,post_handler,handler_data,0,1);
3008 eprobe = os_linux_syscall_probe_init_global_entry(target);
3010 verror(
"could not setup global system_call entry probes!\n");
3015 rprobe = os_linux_syscall_probe_init_global_ret(target);
3017 verror(
"could not setup global system_call ret probes!\n");
3032 verror(
"no current thread!\n");
3037 verror(
"current thread not valid; forgot to load it?\n");
3044 verror(
"no personality info for thread %d!\n",tthread->
tid);
3052 static int os_linux_current_gs(
struct target *target,
REGVAL *
gs) {
3057 rgb = gbk = gb = gbu = 0;
3088 "doctoring gs to 0 because ip/sp is usermode\n");
3102 "/gs_base=0x%"PRIxADDR"; cannot get percpu data and current thread!\n",
3133 ADDR kernel_stack_addr;
3147 verror(
"could not read ESP!\n");
3167 os_linux_current_gs(target,&gs_base);
3174 "assuming current->thread_info at 0x%"PRIxADDR"\n",
3177 return kernel_stack_addr;
3181 " cannot infer current thread!\n",
3190 (
unsigned char *)&kernel_stack_addr)) {
3191 verror(
"could not read %%gs:kernel_stack"
3215 verror(
"target does not seem to be loaded!\n");
3229 verror(
"target does not seem to be loaded!\n");
3298 struct symbol *datatype,
3300 struct value *value;
3306 verror(
"could not get current_thread_ptr!\n");
3316 struct value *value;
3326 verror(
"could not load 'pid' of task!\n");
3341 static int match_pid(
struct target *target,
struct value *value,
void *data) {
3343 struct value *mv = NULL;
3349 vwarn(
"could not load pid from task; skipping!\n");
3385 #define DCACHE_AUTOFS_PENDING 0x0001
3386 #define DCACHE_NFSFS_RENAMED 0x0002
3387 #define DCACHE_DISCONNECTED 0x0004
3388 #define DCACHE_REFERENCED 0x0008
3389 #define DCACHE_UNHASHED 0x0010
3390 #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020
3397 struct value *dentry,
struct value *vfsmnt,
3398 struct value *root_dentry,
struct value *root_vfsmnt,
3399 char *buf,
int buflen) {
3402 ADDR root_dentry_addr;
3403 ADDR root_vfsmnt_addr;
3407 struct value *vfsmnt_mnt_parent;
3408 ADDR vfsmnt_mnt_parent_addr;
3409 struct value *orig_dentry = dentry;
3410 struct value *orig_vfsmnt = vfsmnt;
3417 struct value *smnamevalue;
3420 assert(buf != NULL);
3422 dentry_addr =
v_addr(dentry);
3423 vfsmnt_addr =
v_addr(vfsmnt);
3424 root_dentry_addr =
v_addr(root_dentry);
3425 root_vfsmnt_addr =
v_addr(root_vfsmnt);
3434 &parent_addr,NULL,err_vmiload);
3436 &dentry_flags,NULL,err_vmiload);
3442 memcpy(end,
" (deleted)", 10);
3452 if (dentry_addr == root_dentry_addr && vfsmnt_addr == root_vfsmnt_addr)
3455 &mnt_root_addr,NULL,err_vmiload);
3456 if (dentry_addr == mnt_root_addr || dentry_addr == parent_addr) {
3457 vfsmnt_mnt_parent = NULL;
3458 VL(target,tlctxt,vfsmnt,
"mnt_parent",
3460 vfsmnt_mnt_parent_addr =
v_addr(vfsmnt_mnt_parent);
3463 if (vfsmnt_mnt_parent_addr == vfsmnt_addr) {
3465 vfsmnt_mnt_parent = NULL;
3468 if (dentry != orig_dentry) {
3472 VL(target,tlctxt,vfsmnt,
"mnt_mountpoint",
3474 dentry_addr =
v_addr(dentry);
3475 if (vfsmnt != orig_vfsmnt) {
3478 vfsmnt = vfsmnt_mnt_parent;
3479 vfsmnt_addr =
v_addr(vfsmnt);
3480 vfsmnt_mnt_parent = NULL;
3485 &namelen,NULL,err_vmiload);
3497 &nameaddr,NULL,err_vmiload);
3499 if (!nameaddr || (smnamevalue && nameaddr ==
value_addr(smnamevalue))) {
3501 verror(
"dentry.d_name.name invalid!!\n");
3505 namelen = strnlen(smnamevalue->
buf,smnamevalue->
bufsiz);
3507 buflen -= namelen + 1;
3512 memcpy(end,smnamevalue->
buf,namelen);
3519 else if (namelen > 0) {
3520 buflen -= namelen + 1;
3527 memcpy(end,namebuf,namelen);
3534 verror(
"dentry.d_name.len (%"PRIu32
") was invalid!\n",namelen);
3540 &dentry,err_vmiload);
3541 if (ph != orig_dentry) {
3544 dentry_addr =
v_addr(dentry);
3552 &namelen,NULL,err_vmiload);
3557 if (!nameaddr || (smnamevalue && nameaddr ==
value_addr(smnamevalue))) {
3559 verror(
"global_root dentry.d_name.name invalid!!\n");
3563 namelen = strnlen(smnamevalue->
buf,smnamevalue->
bufsiz);
3568 retval -= namelen - 1;
3570 memcpy(retval,smnamevalue->
buf,namelen);
3575 else if (namelen > 0) {
3579 retval -= namelen - 1;
3582 memcpy(retval,namebuf,namelen);
3587 verror(
"dentry.d_name.len (%"PRIu32
") was invalid!\n",namelen);
3600 if (dentry && dentry != orig_dentry) {
3604 if (vfsmnt && vfsmnt != orig_vfsmnt) {
3613 struct value *file,
char *ibuf,
int buflen) {
3614 struct value *dentry = NULL;
3615 struct value *vfsmnt = NULL;
3616 struct value *root_dentry = NULL;
3617 struct value *root_vfsmnt = NULL;
3631 &vfsmnt,err_vmiload);
3633 &dentry,err_vmiload);
3635 &root_vfsmnt,err_vmiload);
3637 &root_dentry,err_vmiload);
3642 &vfsmnt,err_vmiload);
3644 &dentry,err_vmiload);
3646 &root_vfsmnt,err_vmiload);
3648 &root_dentry,err_vmiload);
3651 bufptr =
os_linux_d_path(target,dentry,vfsmnt,root_dentry,root_vfsmnt,
3657 ibuf = malloc(PATH_MAX);
3661 len =
sizeof(buf) - (bufptr - buf);
3662 memcpy(ibuf,bufptr,(len < buflen) ? len : buflen);
3696 char *list_head_member_name,
int nofree,
3698 struct symbol *symbol;
3699 struct symbol *
type;
3700 OFFSET list_head_member_offset;
3703 ADDR current_struct_addr;
3704 struct value *value = NULL;
3718 list_head_member_offset =
3721 verror(
"could not get offset for %s in symbol %s!\n",
3732 current_struct_addr = head =
\
3736 verror(
"could not get the address of bsymbol %s!\n",
3741 head += list_head_member_offset;
3749 verror(
"could not load value in list position %d, aborting!\n",i);
3753 rc = iterator(t,value,data);
3756 else if (rc == -1) {
3761 next_head = *((
ADDR *)(value->
buf + list_head_member_offset));
3768 if (next_head == head)
3771 current_struct_addr = next_head - list_head_member_offset;
3778 if (!nofree && value)
3804 char *list_head_member_name,
int nofree,
3806 struct symbol *
type;
3807 OFFSET list_head_member_offset;
3810 ADDR current_struct_addr;
3811 struct value *value = NULL;
3812 struct value *value_next;
3821 list_head_member_offset =
3824 verror(
"could not get offset for %s in symbol %s!\n",
3845 next_head = *((
ADDR *)value->
buf);
3854 while (next_head != head) {
3856 current_struct_addr = next_head - list_head_member_offset;
3860 verror(
"could not load value in list position %d, aborting!\n",i);
3864 rc = iterator(t,value,data);
3867 else if (rc == -1) {
3872 next_head = *((
ADDR *)(value->
buf + list_head_member_offset));
3879 if (next_head == head)
3882 current_struct_addr = next_head - list_head_member_offset;
3889 if (!nofree && value)
3895 static int __value_get_append_tid(
struct target *target,
struct value *value,
3903 verror(
"could not load pid in task; BUG?\n");
3907 array_list_append(list,(
void *)(uintptr_t)
v_i32(v));
3924 "active probing thread entry/exit, so just reloading cache!\n");
3932 retval = array_list_create(64);
3935 __value_get_append_tid,retval)) {
3936 verror(
"could not load all tids in task list (did %d tasks)\n",
3937 array_list_len(retval));
3938 array_list_free(retval);
3950 static int __value_load_thread(
struct target *target,
struct value *value,
3953 int *load_counter = (
int *)data;
3956 verror(
"could not load thread from task value; BUG?\n");
3966 "loaded tid(%d) (%s)\n",tthread->
tid,tthread->
name,buf);
3990 "active probing thread entry/exit, so just reloading cache!\n");
3995 __value_load_thread,&i)) {
3996 verror(
"could not load all threads in task list (did %d tasks)\n",i);
4005 for (i = 0; i < array_list_len(cthreads); ++i) {
4006 tthread = (
struct target_thread *)array_list_item(cthreads,i);
4009 "evicting invalid thread %"PRIiTID"; no longer exists\n",
4015 event->thread = NULL;
4018 array_list_free(cthreads);
4025 tid_t tid,
int force) {
4029 struct value *taskv = NULL;
4042 verror(
"target not paused; cannot load thread id %d!\n",tid);
4064 "evicting old thread %"PRIiTID"; no longer exists!\n",tid);
4069 event->thread = NULL;
4080 verror(
"could not refresh cached struct; aborting to manual update!\n");
4090 "evicting old thread %"PRIiTID"; no longer exists!\n",
4096 event->thread = NULL;
4110 if (taskv_loaded && taskv)
4117 __os_linux_load_current_thread_from_userspace(
struct target *target,
int force) {
4118 GHashTableIter iter;
4125 #if __WORDSIZE == 64
4138 "ip 0x%"PRIxADDR"; cr3/pgd = 0x%"PRIx64
"\n",ipval,cr3);
4145 g_hash_table_iter_init(&iter,target->
threads);
4146 while (g_hash_table_iter_next(&iter,NULL,(gpointer *)&vp)) {
4150 if (ltstate->
pgd == cr3)
4160 "could not find task match for cr3 0x%"PRIx64
";"
4161 " loading all tasks!\n",cr3);
4168 verror(
"could not load all threads to match on cr3!\n");
4173 g_hash_table_iter_init(&iter,target->
threads);
4174 while (g_hash_table_iter_next(&iter,NULL,(gpointer *)&vp)) {
4178 if (ltstate->
pgd == cr3)
4182 "thread %"PRIiTID" with pgd 0x%"PRIx64
" did not match!\n",
4183 tthread->
tid,ltstate->
pgd);
4190 verror(
"could not find task match for cr3 0x%"PRIx64
4191 " after loading all tasks!\n",cr3);
4202 verror(
"could not load cached thread %"PRIiTID" from value!",
4211 ipval,cr3,tthread->
tid);
4220 struct value *threadinfov = NULL;
4223 struct value *taskv = NULL;
4230 struct value *v = NULL;
4243 int in_hypercall = 0;
4244 ADDR ptregs_stack_addr = 0;
4252 vwarn(
"could not read EIP for user-mode check; continuing anyway.\n");
4271 vwarn(
"could not read SP; continuing anyway.\n");
4323 "at user-mode EIP 0x%"PRIxADDR"; trying to load current kernel"
4324 " thread with kernel_sp 0x%"PRIxADDR"\n",
4374 verror(
"could not load current thread info! cannot get current TID!\n");
4380 threadinfov,
"preempt_count",NULL,
4383 verror(
"could not load thread_info->preempt_count (to check IRQ status)!\n");
4387 preempt_count =
v_num(v);
4399 "loading global thread cause in hard/soft irq (0x%"PRIx64
")\n",
4407 threadinfov,
"task",NULL,
4410 if (!taskv && in_hypercall && lstate->
init_task) {
4419 verror(
"could not load current task! cannot get current TID!\n");
4427 verror(
"could not load pid in current task; BUG?\n");
4438 verror(
"could not load parent in task value; BUG?\n");
4450 taskv,
"parent",NULL,
4453 verror(
"could not load parent value from task;"
4454 " ptid will be invalid!\n");
4459 verror(
"could not load parent thread from value;"
4460 " ptid will be invalid!\n");
4477 ptid = ptthread->tid;
4479 else if (tid != 0) {
4491 verror(
"could not load %s in task value; BUG?\n",
4505 verror(
"could not load %s in task value; BUG?\n",
4518 verror(
"could not load comm in current task; BUG?\n");
4531 verror(
"could not load tgid in current task; BUG?\n");
4542 verror(
"could not load flags in task %"PRIiTID" current task; BUG?\n",
4554 verror(
"could not load group_leader in task %"PRIiTID" current task; BUG?\n",
4559 group_leader =
v_addr(v);
4566 verror(
"could not see if thread %"PRIiTID" was kernel or user\n",tid);
4577 verror(
"could not load thread %"PRIiTID" pgd (for cr3 tracking)\n",
4582 pgd = (uint64_t)
v_unum(v);
4589 taskv,
"active_mm.pgd",NULL,
4592 vwarn(
"could not load thread %"PRIiTID" (active_mm) pgd (for cr3 tracking)\n",
4597 pgd = (uint64_t)
v_unum(v);
4609 verror(
"could not load thread_info->flags in current thread; BUG?\n");
4625 g_hash_table_lookup(target->
threads,(gpointer)(uintptr_t)tid))) {
4634 && (tthread->
tgid != tgid
4637 "deleting non-matching cached old thread %"PRIiTID
4638 " (thread %p, tpc %p)\n",
4639 tid,tthread,tthread->
tpc);
4644 event->thread = NULL;
4651 "found matching cached thread %"PRIiTID" (thread %p, tpc %p)\n",
4652 tid,tthread,tthread->
tpc);
4668 "built new thread %"PRIiTID" (thread %p, tpc %p)\n",
4669 tid,tthread,tthread->
tpc);
4692 os_linux_current_gs(target,&gs_base);
4695 vwarn(
"%%gs is 0x0; cannot check if on irqstack!\n");
4701 (
unsigned char *)&irq_count)) {
4702 vwarn(
"could not read %%gs:irq_count"
4704 "; assuming not on irqstack!\n",
4746 "loading userspace regs from kernel stack for user tid %d"
4747 " currently in kernel (altstack = %d)!\n",
4754 verror(
"could not load stack register save frame task %"PRIiTID"!\n",
4763 while (pp >= v->
buf) {
4841 rv = ((uint64_t *)(v->
buf + ip_offset))[0];
4844 rv = ((uint64_t *)(v->
buf + ip_offset))[1];
4847 rv = ((uint64_t *)(v->
buf + ip_offset))[2];
4850 ssp = rv = ((uint64_t *)(v->
buf + ip_offset))[3];
4853 rv = ((uint64_t *)(v->
buf + ip_offset))[4];
4859 rv = ((uint32_t *)(v->
buf + ip_offset))[0];
4862 rv = ((uint32_t *)(v->
buf + ip_offset))[1];
4865 rv = ((uint32_t *)(v->
buf + ip_offset))[2];
4868 ssp = rv = ((uint32_t *)(v->
buf + ip_offset))[3];
4871 rv = ((uint32_t *)(v->
buf + ip_offset))[4];
4907 (
unsigned char *)&old_rsp)) {
4908 verror(
"could not read %%gs:old_rsp (%%gs+0xbf00)"
4943 vwarn(
"stale task_struct for thread %"PRIiTID"!\n",tid);
4957 vwarn(
"stale thread_struct for thread %"PRIiTID"!\n",tid);
4962 vwarn(
"stale thread_info for thread %"PRIiTID"!\n",tid);
4995 gtstate->task_struct_addr = 0;
4996 gtstate->task_struct = NULL;
4997 gtstate->task_flags = 0;
4998 gtstate->group_leader = 0;
4999 gtstate->thread_struct = NULL;
5001 gtstate->ptregs_stack_addr = 0;
5002 gtstate->mm_addr = 0;
5006 if (gtstate->thread_info) {
5009 gtstate->thread_info = NULL;
5012 gtstate->thread_info_flags = tiflags;
5013 gtstate->thread_info_preempt_count = preempt_count;
5021 free(tthread->
name);
5022 tthread->
name = comm;
5023 tthread->
ptid = ptid;
5024 tthread->
tgid = tgid;
5055 vwarn(
"error loading current thread; trying to use default thread\n");
5092 struct value *taskv) {
5103 struct value *threadinfov = NULL;
5105 num_t preempt_count = 0;
5106 struct value *threadv = NULL;
5107 struct value *v = NULL;
5111 ADDR stack_member_addr;
5124 verror(
"could not load pid in task value; BUG?\n");
5135 verror(
"could not load parent in task value; BUG?\n");
5147 taskv,
"parent",NULL,
5150 verror(
"could not load parent value from task;"
5151 " ptid will be invalid!\n");
5156 verror(
"could not load parent thread from value;"
5157 " ptid will be invalid!\n");
5174 ptid = ptthread->tid;
5176 else if (tid != 0) {
5189 verror(
"could not load %s in task value; BUG?\n",
5203 verror(
"could not load %s in task value; BUG?\n",
5216 verror(
"could not load comm in task value; BUG?\n");
5227 verror(
"could not load tgid in task %"PRIiTID"; BUG?\n",tid);
5238 verror(
"could not load flags in task %"PRIiTID"; BUG?\n",tid);
5249 verror(
"could not load group_leader in task %"PRIiTID"; BUG?\n",tid);
5253 group_leader =
v_addr(v);
5265 if (tthread->
tgid != tgid
5270 event->thread = NULL;
5306 "not loading running, valid current thread %"PRIiTID" from"
5307 " task_struct 0x%"PRIxADDR"; loaded from CPU of course\n",
5315 taskv,
"thread_info",NULL,
5318 verror(
"could not load thread_info in task %"PRIiTID"; BUG?\n",tid);
5327 verror(
"could not load stack (thread_info) in task %"PRIiTID";"
5332 stack_member_addr =
v_addr(v);
5339 verror(
"could not load stack (thread_info) in task %"PRIiTID";"
5345 verror(
"cannot load thread_info/stack; no thread support!\n");
5352 verror(
"could not load thread_info.flags in task %"PRIiTID"; BUG?\n",tid);
5363 verror(
"could not load thread_info.preempt_count in task %"PRIiTID";"
5368 preempt_count =
v_num(v);
5374 tthread->
ptid = ptid;
5377 tthread->
tgid = tgid;
5392 verror(
"could not see if thread %"PRIiTID" was kernel or user\n",tid);
5405 verror(
"could not load thread %"PRIiTID" (mm) pgd (for cr3 tracking)\n",
5415 if (ltstate->
pgd == 0) {
5417 taskv,
"active_mm.pgd",NULL,
5420 vwarn(
"could not load thread %"PRIiTID" (active_mm) pgd (for cr3 tracking)\n",
5473 free(tthread->
name);
5474 tthread->
name = comm;
5485 verror(
"could not load thread_struct for task %"PRIiTID"!\n",tid);
5512 if (iskernel && preempt_count) {
5533 else if (iskernel) {
5556 ",ptregs_stack_addr=%"PRIxADDR"\n",
5563 vwarn(
"could not load thread.%s for task %"PRIiTID"!\n",
5580 vwarn(
"could not load thread.%s for task %"PRIiTID"!\n",
5607 if (tiflags & 0x40000) {
5640 vwarn(
"could not load thread.fs for task %"PRIiTID"!\n",tid);
5664 verror(
"could not load thread.gs for task %"PRIiTID"!\n",tid);
5679 vwarn(
"could not load thread.ds for task %"PRIiTID"!\n",tid);
5696 vwarn(
"could not load thread.es for task %"PRIiTID"!\n",tid);
5750 verror(
"could not load stack register save frame task %"PRIiTID"!\n",
5759 while (pp >= v->
buf) {
5762 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5767 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5837 rv = ((uint64_t *)(v->
buf + ip_offset))[0];
5840 rv = ((uint64_t *)(v->
buf + ip_offset))[1];
5843 rv = ((uint64_t *)(v->
buf + ip_offset))[2];
5846 rv = ((uint64_t *)(v->
buf + ip_offset))[3];
5849 rv = ((uint64_t *)(v->
buf + ip_offset))[4];
5855 rv = ((uint32_t *)(v->
buf + ip_offset))[0];
5858 rv = ((uint32_t *)(v->
buf + ip_offset))[1];
5861 rv = ((uint32_t *)(v->
buf + ip_offset))[2];
5864 rv = ((uint32_t *)(v->
buf + ip_offset))[3];
5867 rv = ((uint32_t *)(v->
buf + ip_offset))[4];
5911 otidctxt = ptregs_tidctxt;
5951 while (pp >= v->
buf) {
5954 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5959 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5968 ltstate->
eflags = ((uint64_t *)v->
buf)[1];
5969 ltstate->
ebp = ((uint64_t *)v->
buf)[0];
5972 ltstate->
eflags = ((uint32_t *)v->
buf)[1];
5973 ltstate->
ebp = ((uint32_t *)v->
buf)[0];
5997 threadv,
"debugreg",NULL,
6000 verror(
"could not load thread->debugreg for task %"PRIiTID"\n",tid);
6006 ((uint64_t *)v->
buf)[0]);
6009 ((uint64_t *)v->
buf)[1]);
6012 ((uint64_t *)v->
buf)[2]);
6015 ((uint64_t *)v->
buf)[3]);
6018 ((uint64_t *)v->
buf)[6]);
6021 ((uint64_t *)v->
buf)[7]);
6026 ((uint32_t *)v->
buf)[0]);
6029 ((uint32_t *)v->
buf)[1]);
6032 ((uint32_t *)v->
buf)[2]);
6035 ((uint32_t *)v->
buf)[3]);
6038 ((uint32_t *)v->
buf)[6]);
6041 ((uint32_t *)v->
buf)[7]);
6050 static const char *dregmembers[8] = {
6051 "debugreg0",
"debugreg1",
"debugreg2",
"debugreg3",
6053 "debugreg6",
"debugreg7"
6056 for (i = 0; i < 8; ++i) {
6057 if (!dregmembers[i])
6061 threadv,dregmembers[i],NULL,
6065 dregmembers[i],tid);
6071 *(uint64_t *)v->
buf);
6075 *(uint32_t *)v->
buf);
6086 threadv,
"debugreg6",NULL,
6089 verror(
"could not load thread->debugreg6 for task %"PRIiTID"\n",tid);
6102 threadv,
"ptrace_dr7",NULL,
6105 verror(
"could not load thread->ptrace_dr7 for task %"PRIiTID"\n",tid);
6119 vwarn(
"could not load debugreg for tid %d; no debuginfo!\n",tid);
6158 verror(
"current thread not loaded!\n");
6172 "tid %d thid %"PRIiTID" not valid (%d) or not dirty (%d)\n",
6217 "writing dirty userspace regs from kernel stack for user tid %d"
6218 " currently in kernel to ptregs_stack_addr 0x%"PRIxADDR"!\n",
6219 tid,ptregs_stack_addr);
6225 verror(
"could not load stack register save frame task %"PRIiTID
"!\n",
6234 while (pp >= v->
buf) {
6287 ((uint32_t *)v->
buf)[0] = (uint32_t)rv;
6290 ((uint32_t *)v->
buf)[1] = (uint32_t)rv;
6293 ((uint32_t *)v->
buf)[2] = (uint32_t)rv;
6296 ((uint32_t *)v->
buf)[3] = (uint32_t)rv;
6299 ((uint32_t *)v->
buf)[4] = (uint32_t)rv;
6302 ((uint32_t *)v->
buf)[5] = (uint32_t)rv;
6305 ((uint32_t *)v->
buf)[6] = (uint32_t)rv;
6325 ((uint64_t *)(v->
buf + ip_offset)) + 0);
6328 ((uint64_t *)(v->
buf + ip_offset)) + 1);
6331 ((uint64_t *)(v->
buf + ip_offset)) + 2);
6334 ((uint64_t *)(v->
buf + ip_offset)) + 3);
6337 ((uint64_t *)(v->
buf + ip_offset)) + 4);
6343 ((uint32_t *)(v->
buf + ip_offset))[0] = (uint32_t)rv;
6346 ((uint32_t *)(v->
buf + ip_offset))[1] = (uint32_t)rv;
6349 ((uint32_t *)(v->
buf + ip_offset))[2] = (uint32_t)rv;
6352 ((uint32_t *)(v->
buf + ip_offset))[3] = (uint32_t)rv;
6355 ((uint32_t *)(v->
buf + ip_offset))[4] = (uint32_t)rv;
6391 while (pp >= v->
buf) {
6443 verror(
"cannot flush unknown thread %"PRIiTID"; you forgot to load?\n",
6451 "target %d tid %"PRIiTID" not valid (%d) or not dirty (%d)\n",
6479 vwarn(
"could not store thread.%s for task %"PRIiTID"!\n",
6516 reg,®val) == 1) {
6532 reg,®val) == 1) {
6538 vwarn(
"could not store thread.fs for task %"PRIiTID"!\n",tid);
6560 reg,®val) == 1) {
6565 vwarn(
"could not store thread.ds for task %"PRIiTID"!\n",tid);
6582 reg,®val) == 1) {
6587 vwarn(
"could not store thread.es for task %"PRIiTID"!\n",tid);
6607 verror(
"could not store stack register save frame task %"PRIiTID"!\n",
6616 while (pp >= v->
buf) {
6669 ((uint32_t *)v->
buf)[0] = (uint32_t)rv;
6672 ((uint32_t *)v->
buf)[1] = (uint32_t)rv;
6675 ((uint32_t *)v->
buf)[2] = (uint32_t)rv;
6678 ((uint32_t *)v->
buf)[3] = (uint32_t)rv;
6681 ((uint32_t *)v->
buf)[4] = (uint32_t)rv;
6684 ((uint32_t *)v->
buf)[5] = (uint32_t)rv;
6687 ((uint32_t *)v->
buf)[6] = (uint32_t)rv;
6707 ((uint64_t *)(v->
buf + ip_offset)) + 0);
6710 ((uint64_t *)(v->
buf + ip_offset)) + 1);
6713 ((uint64_t *)(v->
buf + ip_offset)) + 2);
6716 ((uint64_t *)(v->
buf + ip_offset)) + 3);
6719 ((uint64_t *)(v->
buf + ip_offset)) + 4);
6725 ((uint32_t *)(v->
buf + ip_offset))[0] = (uint32_t)rv;
6728 ((uint32_t *)(v->
buf + ip_offset))[1] = (uint32_t)rv;
6731 ((uint32_t *)(v->
buf + ip_offset))[2] = (uint32_t)rv;
6734 ((uint32_t *)(v->
buf + ip_offset))[3] = (uint32_t)rv;
6737 ((uint32_t *)(v->
buf + ip_offset))[4] = (uint32_t)rv;
6794 ((uint64_t *)v->
buf)[1] = ltstate->
eflags;
6795 ((uint64_t *)v->
buf)[0] = ltstate->
ebp;
6798 ((uint32_t *)v->
buf)[1] = ltstate->
eflags;
6799 ((uint32_t *)v->
buf)[0] = ltstate->
ebp;
6815 verror(
"could not store thread->debugreg for task %"PRIiTID"\n",tid);
6821 ((uint64_t *)v->
buf) + 0);
6824 ((uint64_t *)v->
buf) + 1);
6827 ((uint64_t *)v->
buf) + 2);
6830 ((uint64_t *)v->
buf) + 3);
6833 ((uint64_t *)v->
buf) + 6);
6836 ((uint64_t *)v->
buf) + 7);
6842 ((uint32_t *)v->
buf)[0] = rv;
6845 ((uint32_t *)v->
buf)[1] = rv;
6848 ((uint32_t *)v->
buf)[2] = rv;
6851 ((uint32_t *)v->
buf)[3] = rv;
6854 ((uint32_t *)v->
buf)[6] = rv;
6857 ((uint32_t *)v->
buf)[7] = rv;
6869 static const char *dregmembers[8] = {
6870 "debugreg0",
"debugreg1",
"debugreg2",
"debugreg3",
6872 "debugreg6",
"debugreg7"
6881 for (i = 0; i < 8; ++i) {
6882 if (!dregmembers[i])
6891 dregmembers[i],NULL,
6895 dregmembers[i],tid);
6899 *(uint64_t *)v->
buf = rv;
6901 *(uint32_t *)v->
buf = (uint32_t)rv;
6926 verror(
"could not store thread->debugreg6 for task %"PRIiTID"\n",
6931 *(uint64_t *)v->
buf = rv;
6933 *(uint32_t *)v->
buf = rv;
6951 verror(
"could not store thread->ptrace_dr7 for task %"PRIiTID"\n",
6956 *(uint64_t *)v->
buf = rv;
6958 *(uint32_t *)v->
buf = (uint32_t)rv;
6967 vwarn(
"could not store debugreg for tid %d; no debuginfo!\n",tid);
7028 char *buf,
int bufsiz,
7029 int detail,
char *sep,
char *kvsep) {
7041 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7042 (rc >= bufsiz) ? 0 : bufsiz - rc,
7043 "%stask_flags%s0x%"PRIxNUM "%s"
7044 "thread_info_flags%s0x%"PRIxNUM "%s"
7045 "preempt_count%s0x%"PRIiNUM "%s"
7048 "pgd%s0x%"PRIx64
"%s" "mm%s0x%"PRIxADDR,
7055 kvsep,ltstate->
pgd,sep,kvsep,ltstate->
mm_addr);
7065 (rc >= bufsiz) ? NULL : buf + rc,
7066 (rc >= bufsiz) ? 0 : bufsiz - rc,
7067 detail,sep,kvsep,0);
7083 (rc >= bufsiz) ? NULL : buf + rc,
7084 (rc >= bufsiz) ? 0 : bufsiz - rc,
7085 detail,sep,kvsep,0);
7099 #if __WORDSIZE == 64
7110 char *buf,
int bufsiz,
7111 int detail,
char *sep,
char *kvsep) {
7122 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7123 (rc >= bufsiz) ? 0 :bufsiz - rc,
7125 "thread_info_flags%s0x%"PRIxNUM "%s"
7126 "preempt_count%s0x%"PRIiNUM "%s"
7129 "pgd%s0x%"PRIx64
"%s" "mm%s0x%"PRIxADDR,
7135 kvsep,ltstate->
pgd,sep,kvsep,ltstate->
mm_addr);
7139 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7140 (rc >= bufsiz) ? 0 :bufsiz - rc,
7141 "%s" "ip%s%"RF "%s" "bp%s%"RF "%s" "sp%s%"RF "%s"
7142 "flags%s%"RF "%s" "ax%s%"RF "%s" "bx%s%"RF "%s"
7143 "cx%s%"RF "%s" "dx%s%"RF "%s" "di%s%"RF "%s"
7144 "si%s%"RF "%s" "cs%s%"RIF
"%s" "ss%s%"RIF
"%s"
7145 "ds%s%"RIF
"%s" "es%s%"RIF
"%s"
7146 "fs%s%"RF "%s" "gs%s%"RF,
7147 #
if __WORDSIZE == 64
7226 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7227 (rc >= bufsiz) ? 0 :bufsiz - rc,
7228 "%s" "dr0%s%"DRF "%s" "dr1%s%"DRF
7229 "%s" "dr2%s%"DRF "%s" "dr3%s%"DRF
7230 "%s" "dr6%s%"DRF "%s" "dr7%s%"DRF,
7231 sep,kvsep,drs[0],sep,kvsep,drs[1],
7232 sep,kvsep,drs[1],sep,kvsep,drs[2],
7233 sep,kvsep,drs[6],sep,kvsep,drs[7]);
7251 static int __update_module(
struct target *target,
struct value *value,
void *data) {
7252 struct value *mod_name = NULL;
7253 struct value *vt = NULL;
7262 char *modfilename = NULL;
7278 verror(
"could not load name for module!\n");
7285 verror(
"could not load module_core addr!\n");
7288 mod_core_addr =
v_addr(vt);
7294 verror(
"could not load module_init addr!\n");
7297 mod_init_addr =
v_addr(vt);
7303 verror(
"could not load module core_size!\n");
7306 mod_core_size =
v_unum(vt);
7312 verror(
"could not load module init_size!\n");
7315 mod_init_size =
v_unum(vt);
7320 v_string(mod_name),mod_core_addr,(
unsigned)mod_core_size,
7321 mod_init_addr,(
unsigned)mod_init_size);
7325 "no moddep info for %s; cannot load binfile info!\n",
7329 modfilename = g_hash_table_lookup(ud->
moddep,
v_string(mod_name));
7332 "no moddep info for %s; cannot load binfile info!\n",
7338 if (strcmp(tregion->
name,
7339 (modfilename) ? modfilename :
v_string(mod_name)) == 0) {
7351 (modfilename) ? strdup(modfilename) \
7360 mod_core_addr + mod_core_size,0,0);
7363 verror(
"could not create range for module addr 0x%"PRIxADDR
"!\n",
7375 mod_core_addr,target->
config);
7377 verror(
"could not infer instance for module %s!\n",tregion->
name);
7424 static int os_linux_reload_modules_dep(
struct target *target) {
7427 GHashTable *
moddep = NULL;
7429 char moddep_path[PATH_MAX];
7430 char buf[PATH_MAX * 2];
7437 struct stat statbuf;
7438 time_t moddep_mtime;
7446 if (stat(moddep_path,&statbuf)) {
7448 "stat(%s): %s; aborting!\n",moddep_path,strerror(errno));
7451 moddep_mtime = statbuf.st_mtime;
7455 "cached moddep is valid\n");
7462 if (!(moddep_file = fopen(moddep_path,
"r"))) {
7463 verror(
"fopen(%s): %s\n",moddep_path,strerror(errno));
7467 moddep = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
7469 while (fgets(buf,
sizeof(buf),moddep_file)) {
7470 newline = index(buf,
'\n');
7476 if (!(colon = index(buf,
':')))
7480 if (!(slash = rindex(buf,
'/')))
7484 modfilename = strdup(buf);
7485 if (stat(modfilename,&statbuf)) {
7487 "could not find modules.dep file %s; trying abs path\n",
7494 if (stat(modfilename,&statbuf)) {
7496 "could not find modules.dep file %s at all!\n",
7505 modname = strdup(slash+1);
7506 if ((extension = rindex(modname,
'.')))
7509 g_hash_table_insert(
moddep,modname,modfilename);
7512 "modules.dep: %s -> %s\n",modname,modfilename);
7520 while (fgets(buf,
sizeof(buf),moddep_file)) {
7521 if (index(buf,
'\n'))
7526 fclose(moddep_file);
7532 g_hash_table_destroy(lstate->
moddep);
7537 "updated modules.dep cache (%d entries from %s)\n",
7538 g_hash_table_size(lstate->
moddep),moddep_path);
7546 static int os_linux_updateregions(
struct target *target,
7554 GList *t1,*t2,*t3,*t4;
7574 if (os_linux_reload_modules_dep(target))
7576 "failed to reload modules.dep; trying to continue!\n");
7596 "list",0,__update_module,&ud);
7612 "removing stale range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7626 "removing stale region (%s:0x%"PRIxADDR
":%s:%s)\n",
7627 region->space->name,region->space->tag,
7639 else if (
OBJNEW(region)) {
7642 "new range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7661 struct probe *trigger,
7662 struct probe *base) {
7663 struct target *target;
7665 struct value *mod = NULL;
7674 struct value *name_value = NULL;
7731 vwarn(
"could not load mod in module_free; manually updating"
7746 os_linux_reload_modules_dep(target);
7752 __update_module(target,mod,&ud);
7757 "new range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7775 NULL,&name_value,err_vmiload_name);
7778 modfilename = g_hash_table_lookup(lstate->
moddep,name);
7780 verror(
"could not find modfilename for module '%s'; aborting to"
7781 " manual update!\n",
7787 if (strcmp(region->
name,modfilename) == 0)
7795 "removing stale range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7807 "removing stale region (%s:0x%"PRIxADDR
":%s:%s)\n",
7820 "ignoring untracked departing module '%s'\n",name);
7824 verror(
"unexpected module state %d; reverting to manual update!\n",state);
7836 verror(
"could not load mod->state; aborting to manual update!\n");
7840 verror(
"could not load mod->name for departing module; aborting to manual"
7850 if (os_linux_updateregions(target,space)) {
7851 verror(
"manual module update failed; regions may be wrong!\n");
7900 #define _LINUX_MAX_ERRNO 4095
7901 #define _LINUX_IS_ERR(x) unlikely((x) >= (REGVAL)-_LINUX_MAX_ERRNO)
7905 struct probe *trigger,
7906 struct probe *base) {
7907 struct target *target = probe->
target;
7912 struct value *value;
7915 #ifdef APF_TE_COPY_PROCESS
7922 verror(
"could not read %%ax to get copy_process retval!\n");
7941 vwarn(
"could not load retval in %s; ignoring new thread!\n",
7953 vwarn(
"could not load %s in %s; ignoring new thread!\n",
7961 verror(
"could not load thread from task value; BUG?\n");
8015 struct probe *trigger,
8016 struct probe *base) {
8017 struct target *target = probe->
target;
8021 struct value *value;
8035 vwarn(
"could not load %s in %s; ignoring new thread!\n",
8042 verror(
"could not load thread from task value; BUG?\n");
8055 static void os_linux_mm_free(
struct os_linux_mm *olmm) {
8065 olvma_next = (olvma) ? olvma->
next : NULL;
8070 olvma_next = olvma ? olvma->
next : NULL;
8092 static struct addrspace *os_linux_space_load(
struct target *target,
8102 struct value *vma_prev;
8104 struct os_linux_vma *new_vma,*cached_vma,*cached_vma_prev;
8109 ADDR start,end,offset;
8112 char *prev_vma_member_name;
8113 struct value *file_value;
8170 verror(
"tid %d's task->mm became NULL; impossible -- BUG!!\n",tid);
8186 (gpointer)(uintptr_t)mm_addr);
8189 olmm = (
struct os_linux_mm *)calloc(1,
sizeof(*olmm));
8190 snprintf(nbuf,
sizeof(nbuf),
"os_linux_process(%d)",tid);
8194 (gpointer)(uintptr_t)mm_addr,olmm);
8219 &olmm->
mm_brk,NULL,err_vmiload);
8232 else if (mm_addr && mm_addr != xtstate->
last_mm_addr) {
8233 vwarn(
"tid %d's task->mm changed (0x%"PRIxADDR
" to 0x%"PRIxADDR
");"
8234 " checking cached VMAs like normal!\n",
8250 &vma_addr,NULL,err_vmiload);
8252 cached_vma_prev = NULL;
8258 vma_prev = olmm->
mm;
8259 prev_vma_member_name =
"mmap";
8261 VL(target,tlctxt,vma_prev,prev_vma_member_name,
8264 &start,NULL,err_vmiload);
8267 #warning "generate MOD events!"
8270 while (vma_addr || cached_vma) {
8271 if (vma_addr && !cached_vma) {
8280 VL(target,tlctxt,vma_prev,prev_vma_member_name,
8282 new_vma = calloc(1,
sizeof(*new_vma));
8287 &start,NULL,err_vmiload);
8289 &end,NULL,err_vmiload);
8291 &prot_flags,NULL,err_vmiload);
8293 &offset,NULL,err_vmiload);
8295 &file_addr,NULL,err_vmiload);
8297 &vma_next_addr,NULL,err_vmiload);
8305 if (file_addr != 0) {
8308 &file_value,err_vmiload);
8311 vwarn(
"could not get filepath for struct file for new range;"
8312 " continuing! (file 0x%"PRIxADDR
")\n",file_addr);
8322 && region->
name && *region->
name !=
'\0') {
8324 "found contiguous region (%s) for next anon region at start 0x%"PRIxADDR
"\n",
8325 region->
name,start);
8354 (buf[0] ==
'\0') ? NULL : buf);
8359 "created memregion(%s:0x%"PRIxADDR
":%s:%s)\n",
8372 new_vma->
range = range;
8375 "created memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8395 cached_vma_prev->
next = new_vma;
8399 cached_vma_prev = new_vma;
8401 new_vma->
next = cached_vma;
8403 vma_addr = vma_next_addr;
8407 prev_vma_member_name =
"vm_next";
8411 else if (!vma_addr && cached_vma) {
8416 tmp_cached_vma_d = cached_vma;
8421 if (cached_vma_prev) {
8422 cached_vma_prev->
next = cached_vma->
next;
8438 cached_vma = cached_vma->
next;
8442 "removing stale memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8443 "%"PRIiOFFSET
",%u)\n",
8454 tmp_cached_vma_d->
range);
8461 "removing empty memregion(%s:0x%"PRIxADDR
":%s:%s)\n",
8475 free(tmp_cached_vma_d);
8476 tmp_cached_vma_d = NULL;
8500 "tid %d refreshing vm_area_struct at 0x%"PRIxADDR
"\n",
8505 VLV(target,tlctxt,cached_vma->
vma,
"vm_start",
8507 VLV(target,tlctxt,cached_vma->
vma,
"vm_end",
8509 VLV(target,tlctxt,cached_vma->
vma,
"vm_page_prot",
8511 VLV(target,tlctxt,cached_vma->
vma,
"vm_pgoff",
8513 VLV(target,tlctxt,cached_vma->
vma,
"vm_next",
8522 "no change to memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8523 "%"PRIiOFFSET
",%u)\n",
8540 "update to memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8541 "%"PRIiOFFSET
",%u)\n",
8556 cached_vma_prev = cached_vma;
8557 cached_vma = cached_vma->
next;
8559 vma_addr = vma_next_addr;
8560 vma_prev = cached_vma_prev->
vma;
8563 prev_vma_member_name =
"vm_next";
8584 tmp_cached_vma = cached_vma;
8587 while (tmp_cached_vma) {
8592 tmp_cached_vma = tmp_cached_vma->
next;
8597 goto do_new_unmatched;
8602 tmp_cached_vma = cached_vma;
8604 while (tmp_cached_vma && vma_addr !=
value_addr(tmp_cached_vma->
vma)) {
8608 if (cached_vma_prev) {
8609 cached_vma_prev->
next = tmp_cached_vma->
next;
8610 if (tmp_cached_vma->
next && tmp_cached_vma->
next->
vma)
8618 if (tmp_cached_vma->
next && tmp_cached_vma->
next->
vma)
8625 tmp_cached_vma_d = tmp_cached_vma;
8627 tmp_cached_vma = tmp_cached_vma->
next;
8631 "removing stale memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8632 "%"PRIiOFFSET
",%u)\n",
8645 tmp_cached_vma_d->
range);
8654 free(tmp_cached_vma_d);
8655 tmp_cached_vma_d = NULL;
8658 cached_vma = tmp_cached_vma;
8666 if (cached_vma && vma_addr ==
value_addr(cached_vma->
vma)) {
8668 "continuing loop; cached_vma matches vma_addr (0x%"PRIxADDR
");"
8669 " memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8670 "%"PRIiOFFSET
",%u)\n",
8681 else if (cached_vma) {
8683 "continuing loop; cached_vma does not match vma_addr (0x%"PRIxADDR
");"
8684 " cached_vma memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8685 "%"PRIiOFFSET
",%u)\n",
8694 "continuing loop; no more cached_vmas; all others will"
8735 g_hash_table_lookup(lstate->
processes,(gpointer)(uintptr_t)tthread->
tgid);
8745 verror(
"thread %d no longer exists!\n",othread->
tid);
8751 if (tthread->
tid != tthread->
tgid)
8763 space = os_linux_space_load(target,tthread);
8767 verror(
"could not associate thread %d with process!\n",tthread->
tid);
8774 space = os_linux_space_load(target,tthread);
8775 if (space != process->
space) {
8779 process->
space = space;
8780 RHOLD(space,process);
8786 (gpointer)(uintptr_t)tthread->
tgid,process);
8787 RHOLD(process,target);
8793 if (process && created) {
8818 static result_t os_linux_active_process_memory_post_handler(
struct probe *probe,
8821 struct probe *trigger,
8822 struct probe *base) {
8823 struct target *target = (
struct target *)handler_data;
8835 g_hash_table_lookup(lstate->
processes,(gpointer)(uintptr_t)tthread->
tgid);
8840 verror(
"could not associate thread %d with process!\n",tthread->
tid);
8845 space = os_linux_space_load(target,tthread);
8848 if (space != process->space) {
8852 process->space =
space;
8853 RHOLD(space,process);
8864 struct probe *probe;
8866 int forced_load = 0;
8874 flags &= ~APF_THREAD_ENTRY;
8878 flags &= ~APF_THREAD_EXIT;
8882 flags &= ~APF_MEMORY;
8888 if (flags & APF_OS_MEMORY) {
8898 vwarn(
"could not probe module_free; not enabling"
8899 " active memory updates!\n");
8902 target->
ap_flags &= ~APF_OS_MEMORY;
8916 target->
ap_flags &= ~APF_OS_MEMORY;
8921 != (target->
ap_flags & APF_OS_THREAD_ENTRY)) {
8922 if (flags & APF_OS_THREAD_ENTRY) {
8939 #ifdef APF_TE_COPY_PROCESS
8945 vwarn(
"could not probe %s entry/exits; not enabling"
8946 " active thread entry updates!\n",name);
8949 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
8959 vwarn(
"could not probe %s entry; not enabling"
8960 " active thread entry updates!\n",name);
8963 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
8978 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
8983 != (target->
ap_flags & APF_OS_THREAD_EXIT)) {
8984 if (flags & APF_OS_THREAD_EXIT) {
9004 vwarn(
"could not probe %s; not enabling"
9005 " active thread exit updates!\n",name);
9008 target->
ap_flags &= ~APF_OS_THREAD_EXIT;
9022 target->
ap_flags &= ~APF_OS_THREAD_EXIT;
9027 != (target->
ap_flags & APF_PROCESS_MEMORY)) {
9028 if (flags & APF_PROCESS_MEMORY) {
9049 NULL,os_linux_active_process_memory_post_handler,
9053 verror(
"could not register function entry/exit probe on %s;"
9068 NULL,os_linux_active_process_memory_post_handler,
9072 verror(
"could not register function entry/exit probe on %s;"
9088 NULL,os_linux_active_process_memory_post_handler,
9092 verror(
"could not register function entry/exit probe on %s;"
9108 NULL,os_linux_active_process_memory_post_handler,
9112 verror(
"could not register function entry/exit probe on %s;"
9128 NULL,os_linux_active_process_memory_post_handler,
9132 verror(
"could not register function entry/exit probe on %s;"
9148 NULL,os_linux_active_process_memory_post_handler,
9152 verror(
"could not register function entry/exit probe on %s;"
9168 NULL,os_linux_active_process_memory_post_handler,
9172 verror(
"could not register function entry/exit probe on %s;"
9214 target->
ap_flags &= ~APF_PROCESS_MEMORY;
9222 struct target *overlay,
int force_emulate) {
9230 if (!g_hash_table_lookup(target->
config,
"OS_EMULATE_USERSPACE_EXCEPTIONS")
9260 struct target *overlay,
int force_emulate) {
9268 if (!g_hash_table_lookup(target->
config,
"OS_EMULATE_USERSPACE_EXCEPTIONS")
9360 &os_linux_generic_personality_ops,
9361 &os_linux_generic_os_ops);
unsigned int thread_struct_has_debugreg
int target_thread_snprintf(struct target *target, tid_t tid, char *buf, int bufsiz, int detail, char *sep, char *kvsep)
struct bsymbol * module_type
void * target_os_syscall_probe_summarize_tid(struct probe *probe, tid_t tid)
REFCNT binfile_instance_release(struct binfile_instance *bfi)
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
int addrspace_detach_region(struct addrspace *space, struct memregion *region)
struct symbol * task_struct_type
#define SYSCALL_GLOBAL_RET_PROBE
struct value * target_load_type(struct target *target, struct symbol *type, ADDR addr, load_flags_t flags)
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 action * action_return(REGVAL retval)
#define vwarnopt(level, area, flags, format,...)
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
int(* singlestep)(struct target *target, tid_t tid, int isbp, struct target *overlay)
struct symbol * mm_struct_type
unsigned int thread_struct_has_fs
struct target_os_syscall_state * target_os_syscall_probe_last(struct target *target, tid_t tid)
int value_update_i32(struct value *value, int32_t v)
void target_broadcast_event(struct target *target, struct target_event *event)
int os_linux_syscall_table_load(struct target *target)
int os_linux_set_active_probing(struct target *target, active_probe_flags_t flags)
int target_regcache_zero(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
struct binfile_instance * binfile_infer_instance(char *filename, char *root_prefix, ADDR base, GHashTable *config)
target_personality_t personality
char * os_linux_file_get_path(struct target *target, struct value *task, struct value *file, char *ibuf, int buflen)
REFCNT lsymbol_release(struct lsymbol *lsymbol)
int(* attach)(struct target *target)
#define VLS(target, tlctxt, varstr, loadflags, outvarptr, outvalueptr, errlabel)
int target_load_available_threads(struct target *target, int force)
void * target_os_syscall_probe_summarize(struct probe *probe)
struct array_list * system_call_ret_idata_list
int target_personality_register(char *personality, target_personality_t pt, struct target_personality_ops *ptops, void *pops)
struct probe * active_memory_probe_mremap
struct symbol * os_linux_get_task_struct_type(struct target *target)
struct probe * int3_probe
int addrspace_find_range_real(struct addrspace *space, ADDR addr, struct memregion **region_saveptr, struct memrange **range_saveptr)
unsigned int hypervisor_ignores_userspace_exceptions
struct value * probe_value_get_function_ee(struct probe *probe, tid_t tid, char *name)
GHashTable * task_struct_addr_to_thread
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 os_linux_thread_get_pgd_phys(struct target *target, struct target_thread *tthread, ADDR *pgdp)
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
GHashTable * target_regcache_copy_registers(struct target *target, tid_t tid)
int memregion_detach_range(struct memregion *region, struct memrange *range)
#define VLV(target, tlctxt, invalue, varstr, loadflags, outvarptr, outvalueptr, errlabel)
void probe_values_free_stacked(struct probe *probe)
REFCNT action_release(struct action *action)
int target_bsymbol_resolve_base(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR *o_addr, struct memrange **o_range)
struct symbol * pt_regs_type
#define v_g_slist_foreach(gslhead, gslcur, elm)
struct target_thread * os_linux_load_thread(struct target *target, tid_t tid, int force)
#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)
struct probe_ops os_linux_syscall_ret_probe_ops
const char * task_uid_member_name
#define OBJSLIVE(obj, type)
char * kernel_sysmap_filename
struct bsymbol * thread_entry_f_symbol
ADDR target_addressof_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags, struct memrange **o_range)
const char * thread_sp0_member_name
active_probe_flags_t ap_flags
struct target_personality_ops os_linux_generic_personality_ops
struct probe_ops os_linux_global_syscall_ret_probe_ops
REFCNT target_process_free(struct target_process *process, int force)
struct probe * os_linux_syscall_probe(struct target *target, tid_t tid, struct target_os_syscall *syscall, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
struct target_os_syscall_state * target_os_syscall_record_entry(struct target *target, tid_t tid, struct target_os_syscall *syscall)
struct array_list * os_linux_list_available_tids(struct target *target)
struct target_thread * global_thread
result_t os_linux_active_thread_entry_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
int os_linux_load_available_threads(struct target *target, int force)
struct probe * active_thread_entry_probe
void * target_gkv_steal(struct target *target, char *key)
struct probe * active_memory_probe_madvise
uint32_t symbol_get_bytesize(struct symbol *symbol)
result_t probe_do_sink_post_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
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_os_syscall * os_linux_syscall_lookup_name(struct target *target, char *name)
struct target_process * target_process_create(struct target *target, struct target_thread *tthread, struct addrspace *space)
int target_associate_debugfile(struct target *target, struct memregion *region, struct debugfile *debugfile)
int value_update(struct value *value, const char *buf, int bufsiz)
#define verror(format,...)
result_t probe_do_sink_pre_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
int os_linux_list_for_each_struct(struct target *t, struct bsymbol *bsymbol, char *list_head_member_name, int nofree, os_linux_list_iterator_t iterator, void *data)
struct probe * probe_register_addr(struct probe *probe, ADDR addr, probepoint_type_t type, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize, struct bsymbol *bsymbol)
tid_t target_os_thread_get_leader(struct target *target, tid_t tid)
uint64_t target_os_version(struct target *target)
const char *(* gettype)(struct probe *probe)
struct symbol * symbol_get_datatype(struct symbol *symbol)
struct probe * active_memory_probe_mmap_pgoff
void target_detach_thread(struct target *target, struct target_thread *tthread)
result_t(* probe_handler_t)(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
struct lsymbol * symbol_lookup_sym(struct symbol *symbol, const char *name, const char *delim)
struct memregion * memregion_create(struct addrspace *space, region_type_t type, char *name)
struct binfile * binfile_open(char *filename, char *root_prefix, struct binfile_instance *bfinst)
struct symbol * os_linux_get_task_struct_type_ptr(struct target *target)
#define vwarn(format,...)
struct bsymbol * module_free_symbol
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
int disasm_get_control_flow_offsets(struct target *target, inst_cf_flags_t flags, unsigned char *inst_buf, unsigned int buf_len, struct array_list **offset_list, ADDR base, int noabort)
GHashTable * os_linux_processes_load(struct target *target)
struct probe * active_thread_exit_probe
struct symbol * task_struct_type_ptr
struct target_thread * os_linux_load_current_thread(struct target *target, int force)
struct value * probe_value_get_last_function_ee(struct probe *probe, tid_t tid, char *name)
struct target_thread * os_linux_load_thread_from_value(struct target *target, struct value *taskv)
int target_write_reg_ctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
struct target_thread * target_load_thread(struct target *target, tid_t tid, int force)
struct probe * probe_register_source(struct probe *sink, struct probe *src)
struct probe * syscall_entry_probe
OFFSET irq_count_percpu_offset
target_os_type_t os_linux_type(struct target *target)
int os_linux_handle_exception(struct target *target)
#define array_list_foreach(alist, lpc, placeholder)
char * os_linux_version_string(struct target *target)
int target_os_syscall_record_argv(struct target *target, tid_t tid, struct array_list *regvals, struct array_list *argvals)
num_t os_linux_get_preempt_count(struct target *target)
struct memrange * memrange_create(struct memregion *region, ADDR start, ADDR end, OFFSET offset, unsigned int prot_flags)
int os_linux_get_task_pid(struct target *target, struct value *task)
REFCNT bsymbol_release(struct bsymbol *bsymbol)
struct target_thread * current_thread
unsigned int thread_struct_has_ds_es
struct bsymbol * thread_exit_f_symbol
GHashTable * mm_addr_to_mm_cache
unsigned int thread_struct_has_debugreg0
GHashTable * probe_value_get_raw_table_function_ee(struct probe *probe, tid_t tid)
struct target_memmod * target_memmod_lookup(struct target *target, tid_t tid, ADDR addr, int is_phys)
struct bsymbol * system_call_symbol
struct array_list * target_list_tids(struct target *target)
int target_os_syscall_table_load(struct target *target)
struct value * task_struct
struct symbol * thread_struct_type
struct bsymbol * wrapped_bsymbol
struct bsymbol * thread_entry_v_symbol
struct value * os_linux_load_current_thread_as_type(struct target *target, struct symbol *datatype, REGVAL kernel_esp)
int probe_free(struct probe *probe, int force)
struct target_os_syscall * target_os_syscall_lookup_num(struct target *target, int num)
result_t os_linux_active_thread_exit_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
int value_refresh(struct value *value, int recursive)
int(* os_linux_list_iterator_t)(struct target *t, struct value *value, void *data)
unsigned int thread_struct_has_perf_debugreg
int os_linux_postopened(struct target *target)
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)
struct probe * active_memory_probe
int(* fini)(struct probe *probe)
GHashTable * probe_value_get_table_function_ee(struct probe *probe, tid_t tid)
char * kernel_elf_filename
struct probe * active_memory_probe_mmap
num_t thread_info_preempt_count
#define ERRORDUMPSYMBOL_NL(s)
void value_free(struct value *value)
const char * task_gid_member_name
struct target_location_ctxt * target_global_tlctxt(struct target *target)
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)
int os_linux_invalidate_thread(struct target *target, struct target_thread *tthread)
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)
struct probe * active_memory_probe_uselib
#define THREAD_CTXT_KERNEL
struct value * value_clone(struct value *in)
struct value * target_load_type_regval(struct target *target, struct symbol *type, tid_t tid, REG reg, REGVAL regval, load_flags_t flags)
GHashTable * thread_syscall_state_current
struct os_linux_vma * vma_cache
struct target_memmod * emulating_debug_mmod
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)
char * os_linux_d_path(struct target *target, struct value *dentry, struct value *vfsmnt, struct value *root_dentry, struct value *root_vfsmnt, char *buf, int buflen)
const char * os_linux_signal_to_name(struct target *target, int signo)
result_t os_linux_debug_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
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)
int target_store_value(struct target *target, struct value *value)
#define VLA(target, addr, loadflags, outbufptr, outbuflen, outvalueptr, errlabel)
GHashTable * os_linux_syscall_table_get(struct target *target)
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
struct target_thread * thread
REFCNT symbol_release(struct symbol *symbol)
int os_linux_thread_snprintf(struct target *target, struct target_thread *tthread, char *buf, int bufsiz, int detail, char *sep, char *kvsep)
#define LOCAL_TIF_SIGPENDING
#define v_g_list_foreach_safe(glhead, glcur, glnext, elm)
#define vdebug(devel, areas, flags, format,...)
int target_regcache_readreg_ifdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL *regval)
void probe_value_notify_phase_function_ee(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
ADDR v_addr(struct value *v)
int target_load_all_threads(struct target *target, int force)
struct thread_probepoint_context * tpc
struct probe * syscall_ret_probe
struct probe * probe_register_inlined_symbol(struct probe *probe, struct bsymbol *bsymbol, int do_primary, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
#define REG_X86_64_RFLAGS
int target_regcache_init_reg_tidctxt(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval)
struct memregion * region
struct probe * debug_probe
num_t v_num(struct value *v)
struct debugfile * debugfile_from_instance(struct binfile_instance *bfinst, struct array_list *debugfile_load_opts_list)
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
struct array_list * debugfile_load_opts_list
int value_update_unum(struct value *value, unum_t v)
unsigned int thread_ctxt_t
GHashTable * thread_syscall_state_last
void target_thread_set_status(struct target_thread *tthread, thread_status_t status)
int target_os_syscall_record_return(struct target *target, tid_t tid, REGVAL retval)
int os_linux_signal_enqueue(struct target *target, struct target_thread *tthread, int signo, void *data)
OFFSET kernel_stack_percpu_offset
struct value * thread_info
struct value * probe_value_get_last_raw_function_ee(struct probe *probe, tid_t tid, char *name)
struct target_process * os_linux_process_load(struct target *target, struct target_thread *tthread)
target_status_t target_status(struct target *target)
struct bsymbol * thread_exit_v_symbol
int target_os_update_process_threads_generic(struct target_process *process, int no_event_send)
struct value * probe_value_get_raw_function_ee(struct probe *probe, tid_t tid, char *name)
#define SYSCALL_GLOBAL_ENTRY_PROBE
result_t os_linux_int3_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
int target_regcache_isdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
char * v_string(struct value *v)
unsigned int task_struct_has_thread_info
uint16_t v_u16(struct value *v)
int os_linux_syscall_table_unload(struct target *target)
unsigned int breakpoint_instrs_len
struct symbol * bsymbol_get_symbol(struct bsymbol *bsymbol)
int os_linux_version_cmp(struct target *target, uint64_t vers)
#define REG_X86_64_GS_BASE
const char * target_os_signal_to_name(struct target *target, int signo)
struct target * target_lookup_overlay(struct target *target, tid_t tid)
int(* init)(struct target *target)
REGVAL target_read_reg_ctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
uint64_t v_u64(struct value *v)
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)
GSList * symbol_get_members(struct symbol *symbol, symbol_type_flag_t flags)
ADDR system_call_base_addr
int os_linux_thread_singlestep_end(struct target *target, tid_t tid, struct target *overlay, int force_emulate)
void os_linux_generic_register(void)
int os_linux_postloadinit(struct target *target)
int32_t v_i32(struct value *v)
unsigned int last_thread_count
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)
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
#define VL(target, tlctxt, invalue, varstr, loadflags, outvalueptr, errlabel)
#define KERNEL_STACK_OFFSET
REGVAL target_regcache_readreg(struct target *target, tid_t tid, REG reg)
struct symbol * target_create_synthetic_type_pointer(struct target *target, struct symbol *type)
struct target_spec * spec
const char * thread_sp_member_name
struct probe * active_memory_probe_munmap
unsigned int pt_regs_has_fs_gs
GHashTable * probe_value_get_last_raw_table_function_ee(struct probe *probe, tid_t tid)
result_t target_os_emulate_ss_handler(struct target *target, tid_t tid, thread_ctxt_t tidctxt, struct target_memmod *mmod)
unsigned int task_struct_has_stack
char * symbol_get_name(struct symbol *symbol)
int os_linux_thread_is_user(struct target *target, struct target_thread *tthread)
#define RPUT(x, objtype, hx, rc)
int os_linux_thread_singlestep(struct target *target, tid_t tid, int isbp, struct target *overlay, int force_emulate)
struct bsymbol * module_free_mod_symbol
GHashTable * probe_value_get_last_table_function_ee(struct probe *probe, tid_t tid)
result_t os_linux_active_memory_handler(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
unsigned int pt_regs_has_ds_es
int value_update_zero(struct value *value, const char *buf, int bufsiz)
char * debugfile_root_prefix
struct symbol * thread_info_type
struct target_thread * os_linux_thread_get_leader(struct target *target, struct target_thread *tthread)
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)
struct os_linux_vma * next
int os_linux_flush_current_thread(struct target *target)
struct target_event * target_create_event(struct target *target, struct target_thread *thread, target_event_t type, void *priv)
struct target_os_syscall * os_linux_syscall_lookup_num(struct target *target, int num)
uint32_t v_u32(struct value *v)
int os_linux_list_for_each_entry(struct target *t, struct bsymbol *btype, struct bsymbol *list_head, char *list_head_member_name, int nofree, os_linux_list_iterator_t iterator, void *data)
int(* singlestep_end)(struct target *target, tid_t tid, struct target *overlay)
void target_gkv_remove(struct target *target, char *key)
int os_linux_fini(struct target *target)
struct bsymbol * init_task
void * target_gkv_lookup(struct target *target, char *key)
struct value * thread_struct
ADDR os_linux_current_thread_ptr(struct target *target, REGVAL kernel_esp)
struct memregion * addrspace_find_region(struct addrspace *space, char *name)
void os_linux_free_thread_state(struct target *target, void *state)
struct probe * active_memory_probe_mprotect
struct probe * probe_register_symbol(struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
int target_addr_v2p(struct target *target, tid_t tid, ADDR vaddr, ADDR *paddr)
int vdebug_is_on(int level, log_areas_t areas, log_flags_t flags)
ADDR schedule_swap_new_rsp_addr
int os_linux_flush_thread(struct target *target, tid_t tid)
int os_linux_attach(struct target *target)
unum_t v_unum(struct value *v)
struct target_thread * target_create_thread(struct target *target, tid_t tid, void *tstate, void *tpstate)
ADDR value_addr(struct value *value)
struct array_list * target_list_threads(struct target *target)
int action_sched(struct probe *probe, struct action *action, action_whence_t whence, action_handler_t handler, void *handler_data)
struct target_os_syscall * os_linux_syscall_lookup_addr(struct target *target, ADDR addr)
int target_regcache_writereg(struct target *target, tid_t tid, REG reg, REGVAL value)
struct memregion * region
result_t target_os_emulate_bp_handler(struct target *target, tid_t tid, thread_ctxt_t tidctxt, struct target_memmod *mmod)
uint64_t os_linux_version(struct target *target)
#define REG_X86_64_GS_BASE_USER
struct probe * os_linux_syscall_probe_all(struct target *target, tid_t tid, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
int os_linux_signal_from_name(struct target *target, const char *name)
const char * thread_ip_member_name
struct value * os_linux_get_task(struct target *target, tid_t tid)
struct target_os_ops os_linux_generic_os_ops
#define REG_X86_64_GS_BASE_KERNEL
#define OBJSDEAD(obj, type)
struct addrspace * addrspace_create(struct target *target, char *name, ADDR tag)
target_type_t supported_overlay_types
unsigned char * target_load_code(struct target *target, ADDR start, unsigned int len, int nocache, int force_copy, int *caller_free)