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",
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"),
247 "%s/usr/lib/debug/lib/modules/%s",
271 &major,&minor,&patch) == 3) {
272 g_hash_table_insert(target->
config,strdup(
"__VERSION_MAJOR"),major);
273 g_hash_table_insert(target->
config,strdup(
"__VERSION_MINOR"),minor);
274 g_hash_table_insert(target->
config,strdup(
"__VERSION_PATCH"),patch);
293 if (pbuf[0] ==
'\0') {
294 snprintf(pbuf,
sizeof(pbuf),
"%s/lib/modules/%s/config-%s",
298 if (access(pbuf,R_OK))
301 if (pbuf[0] ==
'\0') {
302 snprintf(pbuf,
sizeof(pbuf),
"%s/boot/config-%s",
306 if (access(pbuf,R_OK))
309 if (pbuf[0] ==
'\0') {
310 snprintf(pbuf,
sizeof(pbuf),
"/boot/config-%s",
312 if (access(pbuf,R_OK))
315 if (pbuf[0] ==
'\0') {
316 snprintf(pbuf,
sizeof(pbuf),
"%s/config-%s",
318 if (access(pbuf,R_OK))
322 if (pbuf[0] !=
'\0') {
323 cf = fopen(pbuf,
"r");
325 verror(
"fopen(%s): %s\n",pbuf,strerror(errno));
329 if (!fgets(pbuf,
sizeof(pbuf),cf))
335 if (sscanf(pbuf,
"%m[^ \t=]=\"%ms\"",&k,&v) == 2) {
336 g_hash_table_insert(target->
config,k,v);
347 if (sscanf(pbuf,
"%m[^ \t=]=%ms",&k,&v) == 2) {
348 g_hash_table_insert(target->
config,k,v);
362 vwarn(
"could not read kernel config from %s; strange errors may result!\n",
367 verror(
"could not infer kernel ELF file (vmlinux) from %s; aborting!\n",
378 verror(
"binfile_open %s: %s\n",
388 "loaded ELF arch info for %s (wordsize=%d;endian=%s)\n",
394 g_hash_table_new(g_direct_hash,g_direct_equal);
397 g_hash_table_new(g_direct_hash,g_direct_equal);
399 g_hash_table_new(g_direct_hash,g_direct_equal);
443 g_hash_table_iter_init(&iter,lstate->
processes);
444 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
447 g_hash_table_iter_remove(&iter);
454 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
456 os_linux_mm_free(olmm);
457 g_hash_table_iter_remove(&iter);
519 "os_linux_generic_decoder_lib",NULL) == 0) {
521 "autoinitialized the os_linux_generic decoders!\n");
524 verror(
"failed to autoinitialize the os_linux_generic decoders!\n");
552 "could not resolve addr of .text;"
553 " trying startup_(32|64)!\n");
560 "could not find symbol .text; trying startup_(32|64)!\n");
574 "could not resolve addr of startup_32!\n");
581 "could not find symbol startup_32!\n");
592 "could not resolve addr of startup_64!\n");
599 "could not find symbol startup_64!\n");
606 vwarn(
"could not find addr of .text nor startup_(32|64);"
607 " using defaults!\n");
618 g_hash_table_insert(target->
config,
619 strdup(
"OS_KERNEL_START_ADDR"),strdup(buf));
634 "could not resolve addr of hypercall_page!\n");
638 g_hash_table_insert(target->
config,
639 strdup(
"OS_KERNEL_HYPERCALL_PAGE"),strdup(buf));
646 "could not find symbol hypercall_page!\n");
655 vwarn(
"could not lookup init_task in debuginfo; no multithread support!\n");
664 vwarn(
"could not resolve addr of init_task!\n");
668 g_hash_table_insert(target->
config,
669 strdup(
"OS_KERNEL_INIT_TASK_ADDR"),strdup(buf));
683 vwarn(
"could not lookup 'struct mm_struct' in debuginfo;"
684 " userspace vm access might fail!\n");
705 vwarn(
"could not resolve offset of task_struct.tasks!\n");
707 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
708 g_hash_table_insert(target->
config,
709 strdup(
"OS_KERNEL_TASKS_OFFSET"),strdup(buf));
714 vwarn(
"could not resolve offset of task_struct.pid!\n");
716 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
717 g_hash_table_insert(target->
config,
718 strdup(
"OS_KERNEL_PID_OFFSET"),strdup(buf));
723 vwarn(
"could not resolve offset of task_struct.mm!\n");
725 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
726 g_hash_table_insert(target->
config,
727 strdup(
"OS_KERNEL_MM_OFFSET"),strdup(buf));
732 vwarn(
"could not resolve offset of mm_struct.pgd!\n");
734 snprintf(buf,
sizeof(buf),
"0x%"PRIxOFFSET,offset);
735 g_hash_table_insert(target->
config,
736 strdup(
"OS_KERNEL_MM_PGD_OFFSET"),strdup(buf));
746 "attempting to find per-cpu kernel stack offset\n");
756 verror(
"could not load kernel_stack percpu offset;"
757 " cannot continue!\n");
769 verror(
"could not load per_cpu__kernel_stack percpu offset;"
770 " cannot continue!\n");
780 verror(
"could not get offsetof struct x8664_pda.kernelstack;"
781 " cannot continue!\n");
786 verror(
"could not find x86_64 kernel stack percpu var in debuginfo;"
787 " cannot continue!\n");
798 "attempting to find per-cpu irq_count offset\n");
808 vwarn(
"could not load per_cpu__irq_count percpu offset;"
809 " cannot continue!\n");
822 vwarn(
"could not load per_cpu__preempt_count percpu offset;"
823 " cannot continue!\n");
834 vwarn(
"could not get offsetof struct x8664_pda.irqcount;"
835 " cannot continue!\n");
841 vwarn(
"could not find x86_64 irq_count percpu var in debuginfo;"
842 " cannot continue!\n");
858 vwarn(
"could not lookup 'struct pt_regs' in debuginfo;"
859 " no multithread support!\n");
907 vwarn(
"could not find (r|e)ip in pt_regs; things will break!\n");
927 vwarn(
"could not find thread_info nor stack member in struct task_struct;"
928 " no multithread support!\n");
947 vwarn(
"could not find uid/gid info in struct task_struct;"
948 " no uid/gid thread context support!\n");
957 vwarn(
"could not lookup 'struct thread_struct' in debuginfo;"
958 " no multithread support!\n");
984 vwarn(
"could not find 'struct thread_struct.(esp0|sp|rsp0)';"
985 " will cause problems!\n");
1060 if (!thread_info_type) {
1061 vwarn(
"could not lookup 'struct thread_info' in debuginfo;"
1062 " no multithread support!\n");
1086 vwarn(
"could not lookup 'struct module'; no module debuginfo support!\n");
1090 vwarn(
"could not lookup modules; not updating modules list!\n");
1102 vwarn(
"could not lookup module_free; active memory updates"
1103 " cannot function!\n");
1111 vwarn(
"could not lookup module_free.mod; active memory updates"
1112 " cannot function!\n");
1129 err_vmiload_meminfo:
1135 vwarn(
"could not lookup MODULE_STATE_* var; active memory updates"
1136 " cannot function!\n");
1140 #ifdef APF_TE_COPY_PROCESS
1144 vwarn(
"could not lookup copy_process;"
1145 " active thread entry updates cannot function!\n");
1162 vwarn(
"could not lookup wake_up_new_task;"
1163 " active thread entry updates cannot function!\n");
1171 vwarn(
"could not lookup wake_up_new_task.p;"
1172 " active thread entry updates might not function!\n");
1179 vwarn(
"could not lookup sched_exit; trying __unhash_process!\n");
1184 vwarn(
"could not lookup __unhash_process;"
1185 " active thread exit updates cannot function!\n");
1192 vwarn(
"could not lookup __unhash_process.p;"
1193 " active thread exit updates cannot function!\n");
1201 vwarn(
"could not lookup sched_exit.p;"
1202 " active thread exit updates cannot function!\n");
1220 if (g_hash_table_lookup(target->
config,
1221 "OS_EMULATE_USERSPACE_EXCEPTIONS"))
1231 vwarn(
"could not resolve addr of swapper_pg_dir!\n");
1235 g_hash_table_insert(target->
config,
1236 strdup(
"OS_KERNEL_PGD_ADDR"),strdup(buf));
1253 g_hash_table_insert(target->
config,
1254 strdup(
"OS_KERNEL_PGD_ADDR"),strdup(buf));
1257 lstate->
pgd_addr = 0xffffffff81c0d000;
1265 vwarn(
"could not find 'swapper_pg_dir' nor 'init_mm.pgd';"
1266 " kernel v2p may fail!\n");
1277 if (ltstate->
pgd == 0)
1299 "could not resolve bounds of __schedule!\n");
1311 &end,NULL,NULL,NULL)) {
1313 "could not resolve bounds of schedule!\n");
1321 int caller_should_free = 0;
1322 unsigned char *cbuf;
1325 &caller_should_free);
1328 "could not load code of __schedule/schedule();"
1329 " will not be able to load IP for sleeping threads!\n");
1340 && (i + 1) < len && cbuf[i + 1] == 0x8b
1341 && (i + 2) < len && cbuf[i + 2] == 0xa6)
1350 "found x86_64 schedule swap %%rsp instruction"
1355 if (caller_should_free) {
1372 vwarn(
"could not resolve addr of ret_from_fork;"
1373 " will not be able to load IP for newly forked"
1374 " sleeping threads!\n");
1395 verror(
"could not lookup do_int3\n");
1402 &start,NULL,NULL,NULL,NULL)) {
1403 verror(
"could not resolve base addr for symbol %s!\n",
1412 verror(
"could not probe do_int3\n");
1418 verror(
"could not probe addr 0x%"PRIxADDR" for do_int3\n",start);
1430 verror(
"could not lookup do_debug\n");
1437 &start,NULL,NULL,NULL,NULL)) {
1438 verror(
"could not resolve base addr for symbol %s!\n",
1447 verror(
"could not probe do_debug\n");
1453 verror(
"could not probe addr 0x%"PRIxADDR" for do_debug\n",start);
1467 verror(
"cannot handle userspace exceptions via do_int3/do_debug!\n");
1484 vwarn(
"target %s not writeable; cannot snag hypervisor-ignored"
1485 " userspace exceptions via emulation!\n",target->
name);
1489 rc |= os_linux_updateregions(target,space);
1496 struct probe *trigger,
struct probe *base) {
1501 struct target *overlay;
1503 tid_t overlay_leader_tid;
1549 overlay_leader_tid =
1554 "found yet-unknown thread %d with"
1555 " overlay leader %d; will notify!\n",
1556 tthread->
tid,overlay_leader_tid);
1560 "could not find overlay target for tid %d!\n",tid);
1569 "user-mode breakpoint in overlay tid %"PRIiTID
1571 " passing to overlay!\n",
1592 "emulating debug memmod at bp for tid %"PRIiTID
1594 tid,pmmod->
addr,realip);
1597 verror(
"could not emulate debug memmod for"
1598 " tid %"PRIiTID" at paddr 0x%"PRIxADDR
"\n",
1604 verror(
"user-mode debug event (not single step) at 0x%"PRIxADDR";"
1605 " eflags 0x%"PRIxREGVAL
"; skipping handling!\n",
1617 verror(
"could not create return action!\n");
1620 verror(
"could not schedule return action!\n");
1635 struct probe *trigger,
struct probe *base) {
1640 struct target *overlay;
1642 tid_t overlay_leader_tid;
1679 overlay_leader_tid =
1684 "found yet-unknown thread %d with"
1685 " overlay leader %d; will notify!\n",
1686 tthread->
tid,overlay_leader_tid);
1690 "could not find overlay target for tid %d!\n",tid);
1699 "user-mode breakpoint in overlay tid %"PRIiTID
1701 " passing to overlay!\n",
1714 "emulating debug memmod at ss for tid %"PRIiTID
1716 tid,pmmod->
addr,ip);
1719 verror(
"could not emulate debug memmod for"
1720 " tid %"PRIiTID" at paddr 0x%"PRIxADDR
"\n",
1726 verror(
"user-mode debug event (not single step) at 0x%"PRIxADDR";"
1727 " eflags 0x%"PRIxREGVAL
"; skipping handling!\n",
1738 verror(
"could not create return action!\n");
1741 verror(
"could not schedule return action!\n");
1761 GHashTableIter iter;
1776 os_linux_updateregions(target,space);
1786 t1 = g_hash_table_get_values(target->
threads);
1793 "active-probed exiting thread %"PRIiTID" (%s)"
1794 " is still running; not deleting yet!\n",
1799 "active-probed exiting thread %"PRIiTID" (%s)"
1800 " can be deleted; doing it\n",
1819 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
1823 os_linux_mm_free(olmm);
1824 g_hash_table_iter_remove(&iter);
1843 uint64_t retval = 0;
1849 unsigned long int vnum;
1863 verror(
"could not find system_utsname.release"
1864 " nor init_uts_ns.name.release!\n");
1871 verror(
"could not load %s!\n",
1887 vnum = strtoul(next,&endptr,10);
1888 if (endptr == next) {
1889 verror(
"could not determine major release number from '%s'!\n",v->
buf);
1893 retval |= vnum << 16;
1897 vnum = strtoul(next,&endptr,10);
1898 if (endptr == next) {
1899 verror(
"could not determine minor release number from '%s'!\n",v->
buf);
1903 retval |= vnum << 8;
1907 vnum = strtoul(next,&endptr,10);
1908 if (endptr == next) {
1909 verror(
"could not determine patchlevel release number from '%s'!\n",
1917 "version number %"PRIu64
" (0x%"PRIx64
") from '%s'",
1922 target_gkv_dtor_free);
1923 sretval =
malloc(
sizeof(*sretval));
1924 *(uint64_t *)sretval = retval;
1926 target_gkv_dtor_free);
1940 if (ourvers == vers)
1942 else if (ourvers < vers)
1985 if (!ltstate->task_struct) {
1987 "thread %d did not have a task struct value!\n",tthread->
tid);
1992 if (
value_addr(ltstate->task_struct) == ltstate->group_leader)
2004 array_list_free(tlist);
2008 array_list_free(tlist);
2013 "trying to load tid %d's group_leader at 0x%"PRIxADDR"\n",
2014 tthread->
tid,ltstate->group_leader);
2019 vwarn(
"could not load tid %d's group_leader at 0x%"PRIxADDR"; BUG?!\n",
2020 tthread->
tid,ltstate->group_leader);
2025 verror(
"could not load thread from task value at 0x%"PRIxADDR"; BUG?\n",
2026 ltstate->group_leader);
2032 "new group leader loaded (%"PRIiTID",%s)\n",
2039 int signo,
void *data) {
2043 struct value *signal_v;
2044 struct value *signal_pending_v;
2045 struct value *signal_pending_signal_v;
2047 uint32_t sigmask = 1UL << (signo - 1);
2054 "thread %d did not have a task struct value!\n",tthread->
tid);
2063 "sending %s (%d) to %d %s\n",
2064 signame,signo,tthread->
tid,tthread->
name);
2077 signal_pending_signal_v =
2082 sizeof(uint32_t))) {
2083 verror(
"could not setup pending signal %s (%d) to %d %s!\n",
2084 signame,signo,tthread->
tid,tthread->
name);
2092 verror(
"could not store signal pending value; aborting!\n");
2128 verror(
"could not store group stop count!\n");
2135 signal_pending_signal_v =
2139 sizeof(uint32_t))) {
2140 verror(
"could not setup pending signal %d!\n",signo);
2147 verror(
"could not store pending signal!\n");
2151 #define LOCAL_TIF_SIGPENDING (1UL << 2)
2172 {
"SIGHUP",SIGHUP },
2173 {
"SIGINT",SIGINT },
2174 {
"SIGQUIT",SIGQUIT },
2175 {
"SIGILL",SIGILL },
2176 {
"SIGTRAP",SIGTRAP },
2177 {
"SIGABRT",SIGABRT },
2178 {
"SIGIOT",SIGIOT },
2179 {
"SIGBUS",SIGBUS },
2180 {
"SIGFPE",SIGFPE },
2181 {
"SIGKILL",SIGKILL },
2182 {
"SIGUSR1",SIGUSR1 },
2183 {
"SIGSEGV",SIGSEGV },
2184 {
"SIGUSR2",SIGUSR2 },
2185 {
"SIGPIPE",SIGPIPE },
2186 {
"SIGALRM",SIGALRM },
2187 {
"SIGTERM",SIGTERM },
2188 {
"SIGSTKFLT",SIGSTKFLT },
2189 {
"SIGCLD",SIGCLD },
2190 {
"SIGCHLD",SIGCHLD },
2191 {
"SIGCONT",SIGCONT },
2192 {
"SIGSTOP",SIGSTOP },
2193 {
"SIGTSTP",SIGTSTP },
2194 {
"SIGTTIN",SIGTTIN },
2195 {
"SIGTTOU",SIGTTOU },
2196 {
"SIGURG",SIGURG },
2197 {
"SIGXCPU",SIGXCPU },
2198 {
"SIGXFSZ",SIGXFSZ },
2199 {
"SIGVTALRM",SIGVTALRM },
2200 {
"SIGPROF",SIGPROF },
2201 {
"SIGWINCH",SIGWINCH },
2202 {
"SIGPOLL",SIGPOLL },
2204 {
"SIGPWR",SIGPWR },
2205 {
"SIGSYS",SIGSYS },
2213 if (!sigmap[i].
name)
2215 if (sigmap[i].signo == signo)
2216 return sigmap[
i].
name;
2224 char *argcopy = NULL;
2229 argcopy = strdup(name);
2230 len = strlen(argcopy);
2231 for (i = 0; i <
len; ++
i)
2232 argcopy[i] = toupper(argcopy[i]);
2235 if (!sigmap[i].name)
2237 if (strcmp(sigmap[i].name,argcopy) == 0) {
2246 len = strlen(name) + 3 + 1;
2247 argcopy = (
char *)
malloc(len);
2248 snprintf(argcopy,len,
"SIG%s",name);
2249 for (i = 0; i <
len; ++
i)
2250 argcopy[i] = toupper(argcopy[i]);
2252 if (!sigmap[i].name)
2254 if (strcmp(sigmap[i].name,argcopy) == 0) {
2264 static void __os_linux_syscalls_by_num_dtor(
struct target *
target,
2265 char *key,
void *
value) {
2266 GHashTableIter iter;
2269 GHashTable *syscalls_by_num;
2271 syscalls_by_num = (GHashTable *)value;
2273 if (syscalls_by_num) {
2274 g_hash_table_iter_init(&iter,syscalls_by_num);
2275 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
2283 g_hash_table_destroy(syscalls_by_num);
2287 static void __os_linux_syscalls_by_X_dtor(
struct target *target,
2288 char *key,
void *value) {
2289 GHashTable *syscalls_by_X;
2291 syscalls_by_X = (GHashTable *)value;
2294 g_hash_table_destroy(syscalls_by_X);
2299 struct value *v = NULL;
2302 GHashTable *syscalls_by_num;
2303 GHashTable *syscalls_by_addr;
2304 GHashTable *syscalls_by_name;
2320 verror(
"could not lookup symbol sys_call_table!\n");
2327 verror(
"could not load sys_call_table!\n");
2335 syscalls_by_num = g_hash_table_new(g_direct_hash,g_direct_equal);
2336 syscalls_by_addr = g_hash_table_new(g_direct_hash,g_direct_equal);
2337 syscalls_by_name = g_hash_table_new(g_str_hash,g_str_equal);
2344 __os_linux_syscalls_by_num_dtor);
2346 __os_linux_syscalls_by_X_dtor);
2348 __os_linux_syscalls_by_X_dtor);
2355 while ((current - v->
buf) < v->
bufsiz) {
2356 sc =
calloc(1,
sizeof(*sc));
2363 if (strncmp(
"stub_",name,strlen(
"stub_")) == 0) {
2364 wrapped_name =
malloc(strlen(name));
2365 sprintf(wrapped_name,
"sys_%s",name + strlen(
"stub_"));
2375 g_hash_table_insert(syscalls_by_num,
2376 (gpointer)(uintptr_t)sc->
num,sc);
2378 g_hash_table_insert(syscalls_by_addr,
2379 (gpointer)(uintptr_t)sc->
addr,sc);
2381 g_hash_table_insert(syscalls_by_name,
2401 GHashTableIter iter;
2404 GHashTable *syscalls_by_num;
2405 GHashTable *syscalls_by_addr;
2406 GHashTable *syscalls_by_name;
2408 syscalls_by_num = (GHashTable *) \
2410 syscalls_by_name = (GHashTable *) \
2412 syscalls_by_addr = (GHashTable *) \
2415 if (syscalls_by_name) {
2416 g_hash_table_destroy(syscalls_by_name);
2419 if (syscalls_by_addr) {
2420 g_hash_table_destroy(syscalls_by_addr);
2423 if (syscalls_by_num) {
2424 g_hash_table_iter_init(&iter,syscalls_by_num);
2425 while (g_hash_table_iter_next(&iter,NULL,&vp)) {
2431 g_slist_free(sc->
args);
2435 g_hash_table_destroy(syscalls_by_num);
2448 GHashTable *syscalls;
2450 if (!(syscalls = (GHashTable *) \
2455 syscalls = (GHashTable *) \
2464 GHashTable *syscalls;
2466 if (!(syscalls = (GHashTable *) \
2471 syscalls = (GHashTable *) \
2476 g_hash_table_lookup(syscalls,(gpointer)(uintptr_t)num);
2481 GHashTable *syscalls;
2483 if (!(syscalls = (GHashTable *) \
2488 syscalls = (GHashTable *) \
2493 g_hash_table_lookup(syscalls,(gpointer)(uintptr_t)addr);
2529 static int _os_linux_syscall_probe_init(
struct target *target) {
2530 struct bsymbol *system_call_bsymbol = NULL;
2531 ADDR system_call_base_addr = 0;
2533 struct array_list *system_call_ret_idata_list = NULL;
2534 int caller_should_free = 0;
2536 unsigned char *cbuf = NULL;
2551 if (!system_call_bsymbol) {
2552 verror(
"could not lookup system_call;"
2553 " smart syscall probing will fail!\n");
2557 system_call_bsymbol);
2559 system_call_bsymbol->
lsymbol,0,
2560 &system_call_base_addr,&end,NULL,
2562 verror(
"could not resolve base addr of system_call;"
2563 " smart syscall probing will fail!\n");
2569 end - system_call_base_addr,
2570 0,0,&caller_should_free))) {
2571 verror(
"could not load code of system_call;"
2572 " smart syscall probing will fail!\n");
2577 cbuf,end - system_call_base_addr,
2578 &system_call_ret_idata_list,
2579 system_call_base_addr,1)) {
2580 verror(
"could not disassemble system_call in range"
2582 " smart syscall probing will fail!\n",
2583 system_call_base_addr,end);
2586 if (!system_call_ret_idata_list
2587 || array_list_len(system_call_ret_idata_list) <= 0) {
2588 verror(
"no IRETs or SYSRETs in system_call;"
2589 " smart syscall probing will fail!\n");
2595 target_gkv_dtor_bsymbol);
2596 ap =
calloc(1,
sizeof(*ap));
2597 memcpy(ap,&system_call_base_addr,
sizeof(*ap));
2599 target_gkv_dtor_free);
2601 system_call_ret_idata_list,
2602 target_gkv_dtor_alist_deep_free);
2609 if (system_call_ret_idata_list)
2610 array_list_deep_free(system_call_ret_idata_list);
2611 if (caller_should_free)
2613 if (system_call_bsymbol)
2619 #define SYSCALL_GLOBAL_ENTRY_PROBE "os_linux_syscall_entry_probe"
2620 #define SYSCALL_GLOBAL_RET_PROBE "os_linux_syscall_ret_probe"
2622 static int __global_entry_uncache(
struct probe *
probe) {
2627 static struct probe_ops __global_entry_probe_ops = {
2628 .
fini = __global_entry_uncache,
2631 static int __syscall_entry_uncache(
struct probe *
probe) {
2636 static struct probe_ops __syscall_entry_probe_ops = {
2637 .
fini = __syscall_entry_uncache,
2640 static int __global_ret_uncache(
struct probe *
probe) {
2645 static struct probe_ops __global_ret_probe_ops = {
2646 .
fini = __global_ret_uncache,
2652 struct probe *trigger,
2653 struct probe *base) {
2654 struct target *target;
2672 verror(
"could not record syscall entry in tid %"PRIiTID"!\n",tid);
2681 argvals = array_list_create(6);
2695 array_list_append(argvals,v);
2707 static result_t __global_entry_handler(
struct probe *probe,
tid_t tid,
2709 struct probe *trigger,
2710 struct probe *base) {
2711 struct target *target;
2718 struct symbol *argsym;
2724 static REG regs_x86_64[6] = { 5,4,1,10,8,9 };
2728 static REG regs_i386[6] = { 3,1,2,6,7,5 };
2736 vwarn(
"could not find syscall for eax %d in tid %"PRIiTID"; ignoring!\n",
2743 verror(
"could not record syscall entry in tid %"PRIiTID"!\n",tid);
2756 regvals = array_list_create(6);
2757 for (j = 0; j < 6; ++j) {
2758 array_list_append(regvals,
2767 if (syscall->
args) {
2768 argvals = array_list_create(6);
2772 array_list_append(argvals,NULL);
2777 (
REGVAL)array_list_item(regvals,j),
2779 array_list_append(argvals,v);
2782 array_list_append(argvals,NULL);
2800 static result_t __syscall_ret_handler(
struct probe *probe,
tid_t tid,
2802 struct probe *trigger,
2803 struct probe *base) {
2804 struct target *target;
2812 "could not find a current syscall tid %"PRIiTID"; ignoring!\n",
2818 "current syscall for tid %"PRIiTID" already returned; ignoring!\n",
2830 static struct probe *
2831 os_linux_syscall_probe_init_syscall_entry(
struct target *target,
2833 struct probe *
probe;
2842 snprintf(namebuf,
sizeof(namebuf),
"os_linux_%s_probe",
2848 if (_os_linux_syscall_probe_init(target))
2852 namebuf,__syscall_entry_handler,NULL,syscall,1,1);
2855 verror(
"could not register %s!\n",namebuf);
2866 static struct probe *
2867 os_linux_syscall_probe_init_global_entry(
struct target *target) {
2868 struct bsymbol *system_call_bsymbol;
2869 ADDR *system_call_base_addr = NULL;
2870 struct probe *
probe;
2872 if ((probe = (
struct probe *) \
2876 if (_os_linux_syscall_probe_init(target))
2879 system_call_base_addr = (
ADDR *) \
2881 system_call_bsymbol = (
struct bsymbol *) \
2893 __global_entry_handler,NULL,NULL,1,1);
2897 system_call_bsymbol)) {
2898 verror(
"could not register system_call entry probe at 0x%"PRIxADDR"!\n",
2899 *system_call_base_addr);
2906 target_gkv_dtor_probe);
2911 static struct probe *
2912 os_linux_syscall_probe_init_global_ret(
struct target *target) {
2913 ADDR *system_call_base_addr;
2914 struct array_list *system_call_ret_idata_list;
2915 struct probe *rprobe;
2916 struct probe *
probe;
2922 if ((probe = (
struct probe *) \
2926 if (_os_linux_syscall_probe_init(target))
2929 if (!(system_call_ret_idata_list = (
struct array_list *) \
2931 verror(
"BUG: could not find system_call RET info!\n");
2935 system_call_base_addr = (
ADDR *) \
2945 NULL,__syscall_ret_handler,NULL,1,1);
2951 name_len =
sizeof(
"system_call_SYSRET_+") + 12;
2955 snprintf(name,name_len,
2967 rprobe->
name,*system_call_base_addr + idata->
offset);
2974 verror(
"could not register probe %s on source %s!\n",
2984 target_gkv_dtor_probe);
3005 static const char *_os_linux_syscall_probe_gettype(
struct probe *probe) {
3006 return "os_linux_syscall_probe";
3010 .
gettype = _os_linux_syscall_probe_gettype,
3031 void *handler_data) {
3032 struct probe *
probe, *eprobe, *rprobe;
3035 snprintf(namebuf,
sizeof(namebuf),
"os_linux_syscall_probe_%s",
3038 probe =
probe_create(target,tid,&os_linux_syscall_ret_probe_ops,
3039 namebuf,pre_handler,post_handler,handler_data,0,1);
3041 eprobe = os_linux_syscall_probe_init_syscall_entry(target,syscall);
3043 verror(
"could not setup syscall entry probe!\n");
3048 rprobe = os_linux_syscall_probe_init_global_ret(target);
3050 verror(
"could not setup global system_call ret probes!\n");
3062 static const char *_os_linux_global_syscall_probe_gettype(
struct probe *probe) {
3063 return "os_linux_global_syscall_probe";
3067 .
gettype = _os_linux_global_syscall_probe_gettype,
3076 void *handler_data) {
3077 struct probe *
probe, *eprobe, *rprobe;
3079 probe =
probe_create(target,tid,&os_linux_global_syscall_ret_probe_ops,
3080 "os_linux_global_syscall_probe",
3081 pre_handler,post_handler,handler_data,0,1);
3083 eprobe = os_linux_syscall_probe_init_global_entry(target);
3085 verror(
"could not setup global system_call entry probes!\n");
3090 rprobe = os_linux_syscall_probe_init_global_ret(target);
3092 verror(
"could not setup global system_call ret probes!\n");
3107 verror(
"no current thread!\n");
3112 verror(
"current thread not valid; forgot to load it?\n");
3119 verror(
"no personality info for thread %d!\n",tthread->
tid);
3127 static int os_linux_current_gs(
struct target *target,
REGVAL *
gs) {
3132 rgb = gbk = gb = gbu = 0;
3163 "doctoring gs to 0 because ip/sp is usermode\n");
3177 "/gs_base=0x%"PRIxADDR"; cannot get percpu data and current thread!\n",
3208 ADDR kernel_stack_addr;
3222 verror(
"could not read ESP!\n");
3242 os_linux_current_gs(target,&gs_base);
3249 "assuming current->thread_info at 0x%"PRIxADDR"\n",
3252 return kernel_stack_addr;
3256 " cannot infer current thread!\n",
3265 (
unsigned char *)&kernel_stack_addr)) {
3266 verror(
"could not read %%gs:kernel_stack"
3290 verror(
"target does not seem to be loaded!\n");
3304 verror(
"target does not seem to be loaded!\n");
3373 struct symbol *datatype,
3375 struct value *value;
3381 verror(
"could not get current_thread_ptr!\n");
3391 struct value *value;
3401 verror(
"could not load 'pid' of task!\n");
3416 static int match_pid(
struct target *target,
struct value *value,
void *data) {
3418 struct value *mv = NULL;
3424 vwarn(
"could not load pid from task; skipping!\n");
3460 #define DCACHE_AUTOFS_PENDING 0x0001
3461 #define DCACHE_NFSFS_RENAMED 0x0002
3462 #define DCACHE_DISCONNECTED 0x0004
3463 #define DCACHE_REFERENCED 0x0008
3464 #define DCACHE_UNHASHED 0x0010
3465 #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020
3472 struct value *dentry,
struct value *vfsmnt,
3473 struct value *root_dentry,
struct value *root_vfsmnt,
3474 char *buf,
int buflen) {
3477 ADDR root_dentry_addr;
3478 ADDR root_vfsmnt_addr;
3482 struct value *vfsmnt_mnt_parent;
3483 ADDR vfsmnt_mnt_parent_addr;
3484 struct value *orig_dentry = dentry;
3485 struct value *orig_vfsmnt = vfsmnt;
3492 struct value *smnamevalue;
3497 dentry_addr =
v_addr(dentry);
3498 vfsmnt_addr =
v_addr(vfsmnt);
3499 root_dentry_addr =
v_addr(root_dentry);
3500 root_vfsmnt_addr =
v_addr(root_vfsmnt);
3509 &parent_addr,NULL,err_vmiload);
3511 &dentry_flags,NULL,err_vmiload);
3517 memcpy(end,
" (deleted)", 10);
3527 if (dentry_addr == root_dentry_addr && vfsmnt_addr == root_vfsmnt_addr)
3530 &mnt_root_addr,NULL,err_vmiload);
3531 if (dentry_addr == mnt_root_addr || dentry_addr == parent_addr) {
3532 vfsmnt_mnt_parent = NULL;
3533 VL(target,tlctxt,vfsmnt,
"mnt_parent",
3535 vfsmnt_mnt_parent_addr =
v_addr(vfsmnt_mnt_parent);
3538 if (vfsmnt_mnt_parent_addr == vfsmnt_addr) {
3540 vfsmnt_mnt_parent = NULL;
3543 if (dentry != orig_dentry) {
3547 VL(target,tlctxt,vfsmnt,
"mnt_mountpoint",
3549 dentry_addr =
v_addr(dentry);
3550 if (vfsmnt != orig_vfsmnt) {
3553 vfsmnt = vfsmnt_mnt_parent;
3554 vfsmnt_addr =
v_addr(vfsmnt);
3555 vfsmnt_mnt_parent = NULL;
3560 &namelen,NULL,err_vmiload);
3572 &nameaddr,NULL,err_vmiload);
3574 if (!nameaddr || (smnamevalue && nameaddr ==
value_addr(smnamevalue))) {
3576 verror(
"dentry.d_name.name invalid!!\n");
3580 namelen = strnlen(smnamevalue->
buf,smnamevalue->
bufsiz);
3582 buflen -= namelen + 1;
3587 memcpy(end,smnamevalue->
buf,namelen);
3594 else if (namelen > 0) {
3595 buflen -= namelen + 1;
3602 memcpy(end,namebuf,namelen);
3609 verror(
"dentry.d_name.len (%"PRIu32
") was invalid!\n",namelen);
3615 &dentry,err_vmiload);
3616 if (ph != orig_dentry) {
3619 dentry_addr =
v_addr(dentry);
3627 &namelen,NULL,err_vmiload);
3632 if (!nameaddr || (smnamevalue && nameaddr ==
value_addr(smnamevalue))) {
3634 verror(
"global_root dentry.d_name.name invalid!!\n");
3638 namelen = strnlen(smnamevalue->
buf,smnamevalue->
bufsiz);
3643 retval -= namelen - 1;
3645 memcpy(retval,smnamevalue->
buf,namelen);
3650 else if (namelen > 0) {
3654 retval -= namelen - 1;
3657 memcpy(retval,namebuf,namelen);
3662 verror(
"dentry.d_name.len (%"PRIu32
") was invalid!\n",namelen);
3675 if (dentry && dentry != orig_dentry) {
3679 if (vfsmnt && vfsmnt != orig_vfsmnt) {
3688 struct value *file,
char *ibuf,
int buflen) {
3689 struct value *dentry = NULL;
3690 struct value *vfsmnt = NULL;
3691 struct value *root_dentry = NULL;
3692 struct value *root_vfsmnt = NULL;
3706 &vfsmnt,err_vmiload);
3708 &dentry,err_vmiload);
3710 &root_vfsmnt,err_vmiload);
3712 &root_dentry,err_vmiload);
3717 &vfsmnt,err_vmiload);
3719 &dentry,err_vmiload);
3721 &root_vfsmnt,err_vmiload);
3723 &root_dentry,err_vmiload);
3726 bufptr =
os_linux_d_path(target,dentry,vfsmnt,root_dentry,root_vfsmnt,
3736 len =
sizeof(buf) - (bufptr - buf);
3737 memcpy(ibuf,bufptr,(len < buflen) ? len : buflen);
3771 char *list_head_member_name,
int nofree,
3773 struct symbol *symbol;
3774 struct symbol *
type;
3775 OFFSET list_head_member_offset;
3778 ADDR current_struct_addr;
3779 struct value *value = NULL;
3793 list_head_member_offset =
3796 verror(
"could not get offset for %s in symbol %s!\n",
3807 current_struct_addr = head =
\
3811 verror(
"could not get the address of bsymbol %s!\n",
3816 head += list_head_member_offset;
3824 verror(
"could not load value in list position %d, aborting!\n",i);
3828 rc = iterator(t,value,data);
3831 else if (rc == -1) {
3836 next_head = *((
ADDR *)(value->
buf + list_head_member_offset));
3843 if (next_head == head)
3846 current_struct_addr = next_head - list_head_member_offset;
3853 if (!nofree && value)
3879 char *list_head_member_name,
int nofree,
3881 struct symbol *
type;
3882 OFFSET list_head_member_offset;
3885 ADDR current_struct_addr;
3886 struct value *value = NULL;
3887 struct value *value_next;
3896 list_head_member_offset =
3899 verror(
"could not get offset for %s in symbol %s!\n",
3920 next_head = *((
ADDR *)value->
buf);
3929 while (next_head != head) {
3931 current_struct_addr = next_head - list_head_member_offset;
3935 verror(
"could not load value in list position %d, aborting!\n",i);
3939 rc = iterator(t,value,data);
3942 else if (rc == -1) {
3947 next_head = *((
ADDR *)(value->
buf + list_head_member_offset));
3954 if (next_head == head)
3957 current_struct_addr = next_head - list_head_member_offset;
3964 if (!nofree && value)
3970 static int __value_get_append_tid(
struct target *target,
struct value *value,
3978 verror(
"could not load pid in task; BUG?\n");
3982 array_list_append(list,(
void *)(uintptr_t)
v_i32(v));
3999 "active probing thread entry/exit, so just reloading cache!\n");
4007 retval = array_list_create(64);
4010 __value_get_append_tid,retval)) {
4011 verror(
"could not load all tids in task list (did %d tasks)\n",
4012 array_list_len(retval));
4013 array_list_free(retval);
4025 static int __value_load_thread(
struct target *target,
struct value *value,
4028 int *load_counter = (
int *)data;
4031 verror(
"could not load thread from task value; BUG?\n");
4041 "loaded tid(%d) (%s)\n",tthread->
tid,tthread->
name,buf);
4065 "active probing thread entry/exit, so just reloading cache!\n");
4070 __value_load_thread,&i)) {
4071 verror(
"could not load all threads in task list (did %d tasks)\n",i);
4080 for (i = 0; i < array_list_len(cthreads); ++
i) {
4081 tthread = (
struct target_thread *)array_list_item(cthreads,i);
4084 "evicting invalid thread %"PRIiTID"; no longer exists\n",
4090 event->thread = NULL;
4093 array_list_free(cthreads);
4100 tid_t tid,
int force) {
4104 struct value *taskv = NULL;
4117 verror(
"target not paused; cannot load thread id %d!\n",tid);
4139 "evicting old thread %"PRIiTID"; no longer exists!\n",tid);
4144 event->thread = NULL;
4155 verror(
"could not refresh cached struct; aborting to manual update!\n");
4165 "evicting old thread %"PRIiTID"; no longer exists!\n",
4171 event->thread = NULL;
4185 if (taskv_loaded && taskv)
4192 __os_linux_load_current_thread_from_userspace(
struct target *target,
int force) {
4193 GHashTableIter iter;
4200 #if __WORDSIZE == 64
4213 "ip 0x%"PRIxADDR"; cr3/pgd = 0x%"PRIx64
"\n",ipval,cr3);
4220 g_hash_table_iter_init(&iter,target->
threads);
4221 while (g_hash_table_iter_next(&iter,NULL,(gpointer *)&vp)) {
4225 if (ltstate->
pgd == cr3)
4235 "could not find task match for cr3 0x%"PRIx64
";"
4236 " loading all tasks!\n",cr3);
4243 verror(
"could not load all threads to match on cr3!\n");
4248 g_hash_table_iter_init(&iter,target->
threads);
4249 while (g_hash_table_iter_next(&iter,NULL,(gpointer *)&vp)) {
4253 if (ltstate->
pgd == cr3)
4257 "thread %"PRIiTID" with pgd 0x%"PRIx64
" did not match!\n",
4258 tthread->
tid,ltstate->
pgd);
4265 verror(
"could not find task match for cr3 0x%"PRIx64
4266 " after loading all tasks!\n",cr3);
4277 verror(
"could not load cached thread %"PRIiTID" from value!",
4286 ipval,cr3,tthread->
tid);
4295 struct value *threadinfov = NULL;
4298 struct value *taskv = NULL;
4305 struct value *v = NULL;
4318 int in_hypercall = 0;
4319 ADDR ptregs_stack_addr = 0;
4327 vwarn(
"could not read EIP for user-mode check; continuing anyway.\n");
4346 vwarn(
"could not read SP; continuing anyway.\n");
4398 "at user-mode EIP 0x%"PRIxADDR"; trying to load current kernel"
4399 " thread with kernel_sp 0x%"PRIxADDR"\n",
4449 verror(
"could not load current thread info! cannot get current TID!\n");
4458 verror(
"could not load thread_info->preempt_count (to check IRQ status)!\n");
4462 preempt_count =
v_num(v);
4474 "loading global thread cause in hard/soft irq (0x%"PRIx64
")\n",
4482 threadinfov,
"task",NULL,
4485 if (!taskv && in_hypercall && lstate->
init_task) {
4494 verror(
"could not load current task! cannot get current TID!\n");
4502 verror(
"could not load pid in current task; BUG?\n");
4513 verror(
"could not load parent in task value; BUG?\n");
4525 taskv,
"parent",NULL,
4528 verror(
"could not load parent value from task;"
4529 " ptid will be invalid!\n");
4534 verror(
"could not load parent thread from value;"
4535 " ptid will be invalid!\n");
4552 ptid = ptthread->tid;
4554 else if (tid != 0) {
4566 verror(
"could not load %s in task value; BUG?\n",
4580 verror(
"could not load %s in task value; BUG?\n",
4593 verror(
"could not load comm in current task; BUG?\n");
4606 verror(
"could not load tgid in current task; BUG?\n");
4617 verror(
"could not load flags in task %"PRIiTID" current task; BUG?\n",
4629 verror(
"could not load group_leader in task %"PRIiTID" current task; BUG?\n",
4634 group_leader =
v_addr(v);
4641 verror(
"could not see if thread %"PRIiTID" was kernel or user\n",tid);
4652 verror(
"could not load thread %"PRIiTID" pgd (for cr3 tracking)\n",
4657 pgd = (uint64_t)
v_unum(v);
4664 taskv,
"active_mm.pgd",NULL,
4667 vwarn(
"could not load thread %"PRIiTID" (active_mm) pgd (for cr3 tracking)\n",
4672 pgd = (uint64_t)
v_unum(v);
4684 verror(
"could not load thread_info->flags in current thread; BUG?\n");
4700 g_hash_table_lookup(target->
threads,(gpointer)(uintptr_t)tid))) {
4709 && (tthread->
tgid != tgid
4712 "deleting non-matching cached old thread %"PRIiTID
4713 " (thread %p, tpc %p)\n",
4714 tid,tthread,tthread->
tpc);
4719 event->thread = NULL;
4726 "found matching cached thread %"PRIiTID" (thread %p, tpc %p)\n",
4727 tid,tthread,tthread->
tpc);
4743 "built new thread %"PRIiTID" (thread %p, tpc %p)\n",
4744 tid,tthread,tthread->
tpc);
4767 os_linux_current_gs(target,&gs_base);
4770 vwarn(
"%%gs is 0x0; cannot check if on irqstack!\n");
4776 (
unsigned char *)&irq_count)) {
4777 vwarn(
"could not read %%gs:irq_count"
4779 "; assuming not on irqstack!\n",
4821 "loading userspace regs from kernel stack for user tid %d"
4822 " currently in kernel (altstack = %d)!\n",
4829 verror(
"could not load stack register save frame task %"PRIiTID"!\n",
4838 while (pp >= v->
buf) {
4916 rv = ((uint64_t *)(v->
buf + ip_offset))[0];
4919 rv = ((uint64_t *)(v->
buf + ip_offset))[1];
4922 rv = ((uint64_t *)(v->
buf + ip_offset))[2];
4925 ssp = rv = ((uint64_t *)(v->
buf + ip_offset))[3];
4928 rv = ((uint64_t *)(v->
buf + ip_offset))[4];
4934 rv = ((uint32_t *)(v->
buf + ip_offset))[0];
4937 rv = ((uint32_t *)(v->
buf + ip_offset))[1];
4940 rv = ((uint32_t *)(v->
buf + ip_offset))[2];
4943 ssp = rv = ((uint32_t *)(v->
buf + ip_offset))[3];
4946 rv = ((uint32_t *)(v->
buf + ip_offset))[4];
4982 (
unsigned char *)&old_rsp)) {
4983 verror(
"could not read %%gs:old_rsp (%%gs+0xbf00)"
5018 vwarn(
"stale task_struct for thread %"PRIiTID"!\n",tid);
5032 vwarn(
"stale thread_struct for thread %"PRIiTID"!\n",tid);
5037 vwarn(
"stale thread_info for thread %"PRIiTID"!\n",tid);
5070 gtstate->task_struct_addr = 0;
5071 gtstate->task_struct = NULL;
5072 gtstate->task_flags = 0;
5073 gtstate->group_leader = 0;
5074 gtstate->thread_struct = NULL;
5076 gtstate->ptregs_stack_addr = 0;
5077 gtstate->mm_addr = 0;
5081 if (gtstate->thread_info) {
5084 gtstate->thread_info = NULL;
5087 gtstate->thread_info_flags = tiflags;
5088 gtstate->thread_info_preempt_count = preempt_count;
5097 tthread->
name = comm;
5098 tthread->
ptid = ptid;
5099 tthread->
tgid = tgid;
5130 vwarn(
"error loading current thread; trying to use default thread\n");
5167 struct value *taskv) {
5178 struct value *threadinfov = NULL;
5180 num_t preempt_count = 0;
5181 struct value *threadv = NULL;
5182 struct value *v = NULL;
5186 ADDR stack_member_addr;
5199 verror(
"could not load pid in task value; BUG?\n");
5210 verror(
"could not load parent in task value; BUG?\n");
5222 taskv,
"parent",NULL,
5225 verror(
"could not load parent value from task;"
5226 " ptid will be invalid!\n");
5231 verror(
"could not load parent thread from value;"
5232 " ptid will be invalid!\n");
5249 ptid = ptthread->tid;
5251 else if (tid != 0) {
5264 verror(
"could not load %s in task value; BUG?\n",
5278 verror(
"could not load %s in task value; BUG?\n",
5291 verror(
"could not load comm in task value; BUG?\n");
5302 verror(
"could not load tgid in task %"PRIiTID"; BUG?\n",tid);
5313 verror(
"could not load flags in task %"PRIiTID"; BUG?\n",tid);
5324 verror(
"could not load group_leader in task %"PRIiTID"; BUG?\n",tid);
5328 group_leader =
v_addr(v);
5340 if (tthread->
tgid != tgid
5345 event->thread = NULL;
5381 "not loading running, valid current thread %"PRIiTID" from"
5382 " task_struct 0x%"PRIxADDR"; loaded from CPU of course\n",
5390 taskv,
"thread_info",NULL,
5393 verror(
"could not load thread_info in task %"PRIiTID"; BUG?\n",tid);
5402 verror(
"could not load stack (thread_info) in task %"PRIiTID";"
5407 stack_member_addr =
v_addr(v);
5414 verror(
"could not load stack (thread_info) in task %"PRIiTID";"
5420 verror(
"cannot load thread_info/stack; no thread support!\n");
5427 verror(
"could not load thread_info.flags in task %"PRIiTID"; BUG?\n",tid);
5438 verror(
"could not load thread_info.preempt_count in task %"PRIiTID";"
5443 preempt_count =
v_num(v);
5449 tthread->
ptid = ptid;
5452 tthread->
tgid = tgid;
5467 verror(
"could not see if thread %"PRIiTID" was kernel or user\n",tid);
5480 verror(
"could not load thread %"PRIiTID" (mm) pgd (for cr3 tracking)\n",
5490 if (ltstate->
pgd == 0) {
5492 taskv,
"active_mm.pgd",NULL,
5495 vwarn(
"could not load thread %"PRIiTID" (active_mm) pgd (for cr3 tracking)\n",
5549 tthread->
name = comm;
5560 verror(
"could not load thread_struct for task %"PRIiTID"!\n",tid);
5587 if (iskernel && preempt_count) {
5608 else if (iskernel) {
5631 ",ptregs_stack_addr=%"PRIxADDR"\n",
5638 vwarn(
"could not load thread.%s for task %"PRIiTID"!\n",
5655 vwarn(
"could not load thread.%s for task %"PRIiTID"!\n",
5682 if (tiflags & 0x40000) {
5715 vwarn(
"could not load thread.fs for task %"PRIiTID"!\n",tid);
5739 verror(
"could not load thread.gs for task %"PRIiTID"!\n",tid);
5754 vwarn(
"could not load thread.ds for task %"PRIiTID"!\n",tid);
5771 vwarn(
"could not load thread.es for task %"PRIiTID"!\n",tid);
5825 verror(
"could not load stack register save frame task %"PRIiTID"!\n",
5834 while (pp >= v->
buf) {
5837 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5842 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
5912 rv = ((uint64_t *)(v->
buf + ip_offset))[0];
5915 rv = ((uint64_t *)(v->
buf + ip_offset))[1];
5918 rv = ((uint64_t *)(v->
buf + ip_offset))[2];
5921 rv = ((uint64_t *)(v->
buf + ip_offset))[3];
5924 rv = ((uint64_t *)(v->
buf + ip_offset))[4];
5930 rv = ((uint32_t *)(v->
buf + ip_offset))[0];
5933 rv = ((uint32_t *)(v->
buf + ip_offset))[1];
5936 rv = ((uint32_t *)(v->
buf + ip_offset))[2];
5939 rv = ((uint32_t *)(v->
buf + ip_offset))[3];
5942 rv = ((uint32_t *)(v->
buf + ip_offset))[4];
5986 otidctxt = ptregs_tidctxt;
6026 while (pp >= v->
buf) {
6029 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
6034 " 0x%"PRIxADDR
" == %"PRIxADDR
"\n",
6043 ltstate->
eflags = ((uint64_t *)v->
buf)[1];
6044 ltstate->
ebp = ((uint64_t *)v->
buf)[0];
6047 ltstate->
eflags = ((uint32_t *)v->
buf)[1];
6048 ltstate->
ebp = ((uint32_t *)v->
buf)[0];
6072 threadv,
"debugreg",NULL,
6075 verror(
"could not load thread->debugreg for task %"PRIiTID"\n",tid);
6081 ((uint64_t *)v->
buf)[0]);
6084 ((uint64_t *)v->
buf)[1]);
6087 ((uint64_t *)v->
buf)[2]);
6090 ((uint64_t *)v->
buf)[3]);
6093 ((uint64_t *)v->
buf)[6]);
6096 ((uint64_t *)v->
buf)[7]);
6101 ((uint32_t *)v->
buf)[0]);
6104 ((uint32_t *)v->
buf)[1]);
6107 ((uint32_t *)v->
buf)[2]);
6110 ((uint32_t *)v->
buf)[3]);
6113 ((uint32_t *)v->
buf)[6]);
6116 ((uint32_t *)v->
buf)[7]);
6125 static const char *dregmembers[8] = {
6126 "debugreg0",
"debugreg1",
"debugreg2",
"debugreg3",
6128 "debugreg6",
"debugreg7"
6131 for (i = 0; i < 8; ++
i) {
6132 if (!dregmembers[i])
6136 threadv,dregmembers[i],NULL,
6140 dregmembers[i],tid);
6146 *(uint64_t *)v->
buf);
6150 *(uint32_t *)v->
buf);
6161 threadv,
"debugreg6",NULL,
6164 verror(
"could not load thread->debugreg6 for task %"PRIiTID"\n",tid);
6177 threadv,
"ptrace_dr7",NULL,
6180 verror(
"could not load thread->ptrace_dr7 for task %"PRIiTID"\n",tid);
6194 vwarn(
"could not load debugreg for tid %d; no debuginfo!\n",tid);
6233 verror(
"current thread not loaded!\n");
6247 "tid %d thid %"PRIiTID" not valid (%d) or not dirty (%d)\n",
6258 verror(
"target %s not writeable!\n",target->
name);
6298 "writing dirty userspace regs from kernel stack for user tid %d"
6299 " currently in kernel to ptregs_stack_addr 0x%"PRIxADDR"!\n",
6300 tid,ptregs_stack_addr);
6306 verror(
"could not load stack register save frame task %"PRIiTID
"!\n",
6315 while (pp >= v->
buf) {
6368 ((uint32_t *)v->
buf)[0] = (uint32_t)rv;
6371 ((uint32_t *)v->
buf)[1] = (uint32_t)rv;
6374 ((uint32_t *)v->
buf)[2] = (uint32_t)rv;
6377 ((uint32_t *)v->
buf)[3] = (uint32_t)rv;
6380 ((uint32_t *)v->
buf)[4] = (uint32_t)rv;
6383 ((uint32_t *)v->
buf)[5] = (uint32_t)rv;
6386 ((uint32_t *)v->
buf)[6] = (uint32_t)rv;
6406 ((uint64_t *)(v->
buf + ip_offset)) + 0);
6409 ((uint64_t *)(v->
buf + ip_offset)) + 1);
6412 ((uint64_t *)(v->
buf + ip_offset)) + 2);
6415 ((uint64_t *)(v->
buf + ip_offset)) + 3);
6418 ((uint64_t *)(v->
buf + ip_offset)) + 4);
6424 ((uint32_t *)(v->
buf + ip_offset))[0] = (uint32_t)rv;
6427 ((uint32_t *)(v->
buf + ip_offset))[1] = (uint32_t)rv;
6430 ((uint32_t *)(v->
buf + ip_offset))[2] = (uint32_t)rv;
6433 ((uint32_t *)(v->
buf + ip_offset))[3] = (uint32_t)rv;
6436 ((uint32_t *)(v->
buf + ip_offset))[4] = (uint32_t)rv;
6472 while (pp >= v->
buf) {
6524 verror(
"cannot flush unknown thread %"PRIiTID"; you forgot to load?\n",
6532 "target %d tid %"PRIiTID" not valid (%d) or not dirty (%d)\n",
6538 verror(
"target %s not writeable!\n",target->
name);
6566 vwarn(
"could not store thread.%s for task %"PRIiTID"!\n",
6603 reg,®val) == 1) {
6619 reg,®val) == 1) {
6625 vwarn(
"could not store thread.fs for task %"PRIiTID"!\n",tid);
6647 reg,®val) == 1) {
6652 vwarn(
"could not store thread.ds for task %"PRIiTID"!\n",tid);
6669 reg,®val) == 1) {
6674 vwarn(
"could not store thread.es for task %"PRIiTID"!\n",tid);
6694 verror(
"could not store stack register save frame task %"PRIiTID"!\n",
6703 while (pp >= v->
buf) {
6756 ((uint32_t *)v->
buf)[0] = (uint32_t)rv;
6759 ((uint32_t *)v->
buf)[1] = (uint32_t)rv;
6762 ((uint32_t *)v->
buf)[2] = (uint32_t)rv;
6765 ((uint32_t *)v->
buf)[3] = (uint32_t)rv;
6768 ((uint32_t *)v->
buf)[4] = (uint32_t)rv;
6771 ((uint32_t *)v->
buf)[5] = (uint32_t)rv;
6774 ((uint32_t *)v->
buf)[6] = (uint32_t)rv;
6794 ((uint64_t *)(v->
buf + ip_offset)) + 0);
6797 ((uint64_t *)(v->
buf + ip_offset)) + 1);
6800 ((uint64_t *)(v->
buf + ip_offset)) + 2);
6803 ((uint64_t *)(v->
buf + ip_offset)) + 3);
6806 ((uint64_t *)(v->
buf + ip_offset)) + 4);
6812 ((uint32_t *)(v->
buf + ip_offset))[0] = (uint32_t)rv;
6815 ((uint32_t *)(v->
buf + ip_offset))[1] = (uint32_t)rv;
6818 ((uint32_t *)(v->
buf + ip_offset))[2] = (uint32_t)rv;
6821 ((uint32_t *)(v->
buf + ip_offset))[3] = (uint32_t)rv;
6824 ((uint32_t *)(v->
buf + ip_offset))[4] = (uint32_t)rv;
6881 ((uint64_t *)v->
buf)[1] = ltstate->
eflags;
6882 ((uint64_t *)v->
buf)[0] = ltstate->
ebp;
6885 ((uint32_t *)v->
buf)[1] = ltstate->
eflags;
6886 ((uint32_t *)v->
buf)[0] = ltstate->
ebp;
6902 verror(
"could not store thread->debugreg for task %"PRIiTID"\n",tid);
6908 ((uint64_t *)v->
buf) + 0);
6911 ((uint64_t *)v->
buf) + 1);
6914 ((uint64_t *)v->
buf) + 2);
6917 ((uint64_t *)v->
buf) + 3);
6920 ((uint64_t *)v->
buf) + 6);
6923 ((uint64_t *)v->
buf) + 7);
6929 ((uint32_t *)v->
buf)[0] = rv;
6932 ((uint32_t *)v->
buf)[1] = rv;
6935 ((uint32_t *)v->
buf)[2] = rv;
6938 ((uint32_t *)v->
buf)[3] = rv;
6941 ((uint32_t *)v->
buf)[6] = rv;
6944 ((uint32_t *)v->
buf)[7] = rv;
6956 static const char *dregmembers[8] = {
6957 "debugreg0",
"debugreg1",
"debugreg2",
"debugreg3",
6959 "debugreg6",
"debugreg7"
6968 for (i = 0; i < 8; ++
i) {
6969 if (!dregmembers[i])
6978 dregmembers[i],NULL,
6982 dregmembers[i],tid);
6986 *(uint64_t *)v->
buf = rv;
6988 *(uint32_t *)v->
buf = (uint32_t)rv;
7013 verror(
"could not store thread->debugreg6 for task %"PRIiTID"\n",
7018 *(uint64_t *)v->
buf = rv;
7020 *(uint32_t *)v->
buf = rv;
7038 verror(
"could not store thread->ptrace_dr7 for task %"PRIiTID"\n",
7043 *(uint64_t *)v->
buf = rv;
7045 *(uint32_t *)v->
buf = (uint32_t)rv;
7054 vwarn(
"could not store debugreg for tid %d; no debuginfo!\n",tid);
7115 char *buf,
int bufsiz,
7116 int detail,
char *sep,
char *kvsep) {
7128 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7129 (rc >= bufsiz) ? 0 : bufsiz - rc,
7130 "%stask_flags%s0x%"PRIxNUM "%s"
7131 "thread_info_flags%s0x%"PRIxNUM "%s"
7132 "preempt_count%s0x%"PRIiNUM "%s"
7135 "pgd%s0x%"PRIx64
"%s" "mm%s0x%"PRIxADDR,
7142 kvsep,ltstate->
pgd,sep,kvsep,ltstate->
mm_addr);
7152 (rc >= bufsiz) ? NULL : buf + rc,
7153 (rc >= bufsiz) ? 0 : bufsiz - rc,
7154 detail,sep,kvsep,0);
7170 (rc >= bufsiz) ? NULL : buf + rc,
7171 (rc >= bufsiz) ? 0 : bufsiz - rc,
7172 detail,sep,kvsep,0);
7186 #if __WORDSIZE == 64
7197 char *buf,
int bufsiz,
7198 int detail,
char *sep,
char *kvsep) {
7209 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7210 (rc >= bufsiz) ? 0 :bufsiz - rc,
7212 "thread_info_flags%s0x%"PRIxNUM "%s"
7213 "preempt_count%s0x%"PRIiNUM "%s"
7216 "pgd%s0x%"PRIx64
"%s" "mm%s0x%"PRIxADDR,
7222 kvsep,ltstate->
pgd,sep,kvsep,ltstate->
mm_addr);
7226 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7227 (rc >= bufsiz) ? 0 :bufsiz - rc,
7228 "%s" "ip%s%"RF "%s" "bp%s%"RF "%s" "sp%s%"RF "%s"
7229 "flags%s%"RF "%s" "ax%s%"RF "%s" "bx%s%"RF "%s"
7230 "cx%s%"RF "%s" "dx%s%"RF "%s" "di%s%"RF "%s"
7231 "si%s%"RF "%s" "cs%s%"RIF
"%s" "ss%s%"RIF
"%s"
7232 "ds%s%"RIF
"%s" "es%s%"RIF
"%s"
7233 "fs%s%"RF "%s" "gs%s%"RF,
7234 #
if __WORDSIZE == 64
7313 rc += snprintf((rc >= bufsiz) ? NULL : buf + rc,
7314 (rc >= bufsiz) ? 0 :bufsiz - rc,
7315 "%s" "dr0%s%"DRF "%s" "dr1%s%"DRF
7316 "%s" "dr2%s%"DRF "%s" "dr3%s%"DRF
7317 "%s" "dr6%s%"DRF "%s" "dr7%s%"DRF,
7318 sep,kvsep,drs[0],sep,kvsep,drs[1],
7319 sep,kvsep,drs[1],sep,kvsep,drs[2],
7320 sep,kvsep,drs[6],sep,kvsep,drs[7]);
7338 static int __update_module(
struct target *target,
struct value *value,
void *data) {
7339 struct value *mod_name = NULL;
7340 struct value *vt = NULL;
7349 char *modfilename = NULL;
7365 verror(
"could not load name for module!\n");
7372 verror(
"could not load module_core addr!\n");
7375 mod_core_addr =
v_addr(vt);
7381 verror(
"could not load module_init addr!\n");
7384 mod_init_addr =
v_addr(vt);
7390 verror(
"could not load module core_size!\n");
7393 mod_core_size =
v_unum(vt);
7399 verror(
"could not load module init_size!\n");
7402 mod_init_size =
v_unum(vt);
7407 v_string(mod_name),mod_core_addr,(
unsigned)mod_core_size,
7408 mod_init_addr,(
unsigned)mod_init_size);
7412 "no moddep info for %s; cannot load binfile info!\n",
7416 modfilename = g_hash_table_lookup(ud->
moddep,
v_string(mod_name));
7419 "no moddep info for %s; cannot load binfile info!\n",
7425 if (strcmp(tregion->
name,
7426 (modfilename) ? modfilename :
v_string(mod_name)) == 0) {
7438 (modfilename) ? strdup(modfilename) \
7447 mod_core_addr + mod_core_size,0,0);
7450 verror(
"could not create range for module addr 0x%"PRIxADDR
"!\n",
7462 mod_core_addr,target->
config);
7464 verror(
"could not infer instance for module %s!\n",tregion->
name);
7514 static int os_linux_reload_modules_dep(
struct target *target) {
7517 GHashTable *
moddep = NULL;
7519 char moddep_path[PATH_MAX];
7520 char buf[PATH_MAX * 2];
7527 struct stat statbuf;
7528 time_t moddep_mtime;
7536 if (stat(moddep_path,&statbuf)) {
7538 "stat(%s): %s; aborting!\n",moddep_path,strerror(errno));
7541 moddep_mtime = statbuf.st_mtime;
7545 "cached moddep is valid\n");
7552 if (!(moddep_file = fopen(moddep_path,
"r"))) {
7553 verror(
"fopen(%s): %s\n",moddep_path,strerror(errno));
7557 moddep = g_hash_table_new_full(g_str_hash,g_str_equal,
free,
free);
7559 while (fgets(buf,
sizeof(buf),moddep_file)) {
7560 newline = index(buf,
'\n');
7566 if (!(colon = index(buf,
':')))
7570 if (!(slash = rindex(buf,
'/')))
7574 modfilename = strdup(buf);
7575 if (stat(modfilename,&statbuf)) {
7577 "could not find modules.dep file %s; trying abs path\n",
7584 if (stat(modfilename,&statbuf)) {
7586 "could not find modules.dep file %s at all!\n",
7595 modname = strdup(slash+1);
7596 if ((extension = rindex(modname,
'.')))
7599 g_hash_table_insert(
moddep,modname,modfilename);
7602 "modules.dep: %s -> %s\n",modname,modfilename);
7610 while (fgets(buf,
sizeof(buf),moddep_file)) {
7611 if (index(buf,
'\n'))
7616 fclose(moddep_file);
7622 g_hash_table_destroy(lstate->
moddep);
7627 "updated modules.dep cache (%d entries from %s)\n",
7628 g_hash_table_size(lstate->
moddep),moddep_path);
7636 static int os_linux_updateregions(
struct target *target,
7644 GList *t1,*t2,*t3,*t4;
7664 if (os_linux_reload_modules_dep(target))
7666 "failed to reload modules.dep; trying to continue!\n");
7686 "list",0,__update_module,&ud);
7702 "removing stale range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7716 "removing stale region (%s:0x%"PRIxADDR
":%s:%s)\n",
7717 region->space->name,region->space->tag,
7729 else if (
OBJNEW(region)) {
7732 "new range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7751 struct probe *trigger,
7752 struct probe *base) {
7753 struct target *target;
7755 struct value *mod = NULL;
7764 struct value *name_value = NULL;
7821 vwarn(
"could not load mod in module_free; manually updating"
7836 os_linux_reload_modules_dep(target);
7842 __update_module(target,mod,&ud);
7847 "new range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7865 NULL,&name_value,err_vmiload_name);
7868 modfilename = g_hash_table_lookup(lstate->
moddep,name);
7870 verror(
"could not find modfilename for module '%s'; aborting to"
7871 " manual update!\n",
7877 if (strcmp(region->
name,modfilename) == 0)
7885 "removing stale range 0x%"PRIxADDR
"-0x%"PRIxADDR
":%"PRIiOFFSET"\n",
7897 "removing stale region (%s:0x%"PRIxADDR
":%s:%s)\n",
7910 "ignoring untracked departing module '%s'\n",name);
7914 verror(
"unexpected module state %d; reverting to manual update!\n",state);
7926 verror(
"could not load mod->state; aborting to manual update!\n");
7930 verror(
"could not load mod->name for departing module; aborting to manual"
7940 if (os_linux_updateregions(target,space)) {
7941 verror(
"manual module update failed; regions may be wrong!\n");
7990 #define _LINUX_MAX_ERRNO 4095
7991 #define _LINUX_IS_ERR(x) unlikely((x) >= (REGVAL)-_LINUX_MAX_ERRNO)
7995 struct probe *trigger,
7996 struct probe *base) {
7997 struct target *target = probe->
target;
8002 struct value *value;
8005 #ifdef APF_TE_COPY_PROCESS
8012 verror(
"could not read %%ax to get copy_process retval!\n");
8031 vwarn(
"could not load retval in %s; ignoring new thread!\n",
8043 vwarn(
"could not load %s in %s; ignoring new thread!\n",
8051 verror(
"could not load thread from task value; BUG?\n");
8105 struct probe *trigger,
8106 struct probe *base) {
8107 struct target *target = probe->
target;
8111 struct value *value;
8125 vwarn(
"could not load %s in %s; ignoring new thread!\n",
8132 verror(
"could not load thread from task value; BUG?\n");
8145 static void os_linux_mm_free(
struct os_linux_mm *olmm) {
8155 olvma_next = (olvma) ? olvma->
next : NULL;
8160 olvma_next = olvma ? olvma->
next : NULL;
8182 static struct addrspace *os_linux_space_load(
struct target *target,
8192 struct value *vma_prev;
8194 struct os_linux_vma *new_vma,*cached_vma,*cached_vma_prev;
8199 ADDR start,end,offset;
8202 char *prev_vma_member_name;
8203 struct value *file_value;
8209 ADDR vm_mm_addr = 0;
8261 verror(
"tid %d's task->mm became NULL; impossible -- BUG!!\n",tid);
8277 (gpointer)(uintptr_t)mm_addr);
8281 snprintf(nbuf,
sizeof(nbuf),
"os_linux_process(%d)",tid);
8285 (gpointer)(uintptr_t)mm_addr,olmm);
8310 &olmm->
mm_brk,NULL,err_vmiload);
8323 else if (mm_addr && mm_addr != xtstate->
last_mm_addr) {
8324 vwarn(
"tid %d's task->mm changed (0x%"PRIxADDR
" to 0x%"PRIxADDR
");"
8325 " checking cached VMAs like normal!\n",
8341 &vma_addr,NULL,err_vmiload);
8343 cached_vma_prev = NULL;
8349 vma_prev = olmm->
mm;
8350 prev_vma_member_name =
"mmap";
8352 VL(target,tlctxt,vma_prev,prev_vma_member_name,
8355 &start,NULL,err_vmiload);
8358 #warning "generate MOD events!"
8361 while (vma_addr || cached_vma) {
8362 if (vma_addr && !cached_vma) {
8371 VL(target,tlctxt,vma_prev,prev_vma_member_name,
8373 new_vma =
calloc(1,
sizeof(*new_vma));
8378 &start,NULL,err_vmiload);
8380 &end,NULL,err_vmiload);
8382 &prot_flags,NULL,err_vmiload);
8384 &offset,NULL,err_vmiload);
8386 &file_addr,NULL,err_vmiload);
8388 &vma_next_addr,NULL,err_vmiload);
8390 &vm_mm_addr,NULL,err_vmiload);
8398 if (file_addr != 0) {
8401 &file_value,err_vmiload);
8404 vwarn(
"could not get filepath for struct file for new range;"
8405 " continuing! (file 0x%"PRIxADDR
")\n",file_addr);
8415 && region->
name && *region->
name !=
'\0') {
8417 "found contiguous region (%s) for next anon region at start 0x%"PRIxADDR
"\n",
8418 region->
name,start);
8433 else if (vm_mm_addr == 0)
8448 (buf[0] ==
'\0') ? NULL : buf);
8453 "created memregion(%s:0x%"PRIxADDR
":%s:%s)\n",
8466 new_vma->
range = range;
8469 "created memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8488 else if (cached_vma_prev) {
8489 cached_vma_prev->
next = new_vma;
8499 cached_vma_prev = new_vma;
8501 new_vma->
next = cached_vma;
8503 vma_addr = vma_next_addr;
8507 prev_vma_member_name =
"vm_next";
8511 else if (!vma_addr && cached_vma) {
8516 tmp_cached_vma_d = cached_vma;
8521 if (cached_vma_prev) {
8522 cached_vma_prev->
next = cached_vma->
next;
8538 cached_vma = cached_vma->
next;
8542 "removing stale memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8543 "%"PRIiOFFSET
",%u)\n",
8554 tmp_cached_vma_d->
range);
8561 "removing empty memregion(%s:0x%"PRIxADDR
":%s:%s)\n",
8575 free(tmp_cached_vma_d);
8576 tmp_cached_vma_d = NULL;
8600 "tid %d refreshing vm_area_struct at 0x%"PRIxADDR
"\n",
8605 VLV(target,tlctxt,cached_vma->
vma,
"vm_start",
8607 VLV(target,tlctxt,cached_vma->
vma,
"vm_end",
8609 VLV(target,tlctxt,cached_vma->
vma,
"vm_flags",
8611 VLV(target,tlctxt,cached_vma->
vma,
"vm_pgoff",
8613 VLV(target,tlctxt,cached_vma->
vma,
"vm_next",
8622 "no change to memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8623 "%"PRIiOFFSET
",%u)\n",
8640 "update to memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8641 "%"PRIiOFFSET
",%u)\n",
8656 cached_vma_prev = cached_vma;
8657 cached_vma = cached_vma->
next;
8659 vma_addr = vma_next_addr;
8660 vma_prev = cached_vma_prev->
vma;
8663 prev_vma_member_name =
"vm_next";
8684 tmp_cached_vma = cached_vma;
8687 while (tmp_cached_vma) {
8692 tmp_cached_vma = tmp_cached_vma->
next;
8697 goto do_new_unmatched;
8702 tmp_cached_vma = cached_vma;
8704 while (tmp_cached_vma && vma_addr !=
value_addr(tmp_cached_vma->
vma)) {
8708 if (cached_vma_prev) {
8709 cached_vma_prev->
next = tmp_cached_vma->
next;
8710 if (tmp_cached_vma->
next && tmp_cached_vma->
next->
vma)
8718 if (tmp_cached_vma->
next && tmp_cached_vma->
next->
vma)
8725 tmp_cached_vma_d = tmp_cached_vma;
8727 tmp_cached_vma = tmp_cached_vma->
next;
8731 "removing stale memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8732 "%"PRIiOFFSET
",%u)\n",
8745 tmp_cached_vma_d->
range);
8754 free(tmp_cached_vma_d);
8755 tmp_cached_vma_d = NULL;
8758 cached_vma = tmp_cached_vma;
8766 if (cached_vma && vma_addr ==
value_addr(cached_vma->
vma)) {
8768 "continuing loop; cached_vma matches vma_addr (0x%"PRIxADDR
");"
8769 " memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8770 "%"PRIiOFFSET
",%u)\n",
8781 else if (cached_vma) {
8783 "continuing loop; cached_vma does not match vma_addr (0x%"PRIxADDR
");"
8784 " cached_vma memrange(%s:%s:0x%"PRIxADDR
",0x%"PRIxADDR
","
8785 "%"PRIiOFFSET
",%u)\n",
8794 "continuing loop; no more cached_vmas; all others will"
8835 g_hash_table_lookup(lstate->
processes,(gpointer)(uintptr_t)tthread->
tgid);
8845 verror(
"thread %d no longer exists!\n",othread->
tid);
8851 if (tthread->
tid != tthread->
tgid)
8863 space = os_linux_space_load(target,tthread);
8867 verror(
"could not associate thread %d with process!\n",tthread->
tid);
8874 space = os_linux_space_load(target,tthread);
8875 if (space != process->
space) {
8879 process->
space = space;
8880 RHOLD(space,process);
8886 (gpointer)(uintptr_t)tthread->
tgid,process);
8887 RHOLD(process,target);
8893 if (process && created) {
8918 static result_t os_linux_active_process_memory_post_handler(
struct probe *probe,
8921 struct probe *trigger,
8922 struct probe *base) {
8923 struct target *target = (
struct target *)handler_data;
8935 g_hash_table_lookup(lstate->
processes,(gpointer)(uintptr_t)tthread->
tgid);
8940 verror(
"could not associate thread %d with process!\n",tthread->
tid);
8945 space = os_linux_space_load(target,tthread);
8948 if (space != process->space) {
8952 process->space =
space;
8953 RHOLD(space,process);
8964 struct probe *probe;
8966 int forced_load = 0;
8971 verror(
"target %s not writeable!\n",target->
name);
8980 flags &= ~APF_THREAD_ENTRY;
8984 flags &= ~APF_THREAD_EXIT;
8988 flags &= ~APF_MEMORY;
8993 != (target->
ap_flags & APF_OS_MEMORY)) {
8994 if (flags & APF_OS_MEMORY) {
9004 vwarn(
"could not probe module_free; not enabling"
9005 " active memory updates!\n");
9008 target->
ap_flags &= ~APF_OS_MEMORY;
9022 target->
ap_flags &= ~APF_OS_MEMORY;
9027 != (target->
ap_flags & APF_OS_THREAD_ENTRY)) {
9028 if (flags & APF_OS_THREAD_ENTRY) {
9045 #ifdef APF_TE_COPY_PROCESS
9051 vwarn(
"could not probe %s entry/exits; not enabling"
9052 " active thread entry updates!\n",name);
9055 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
9065 vwarn(
"could not probe %s entry; not enabling"
9066 " active thread entry updates!\n",name);
9069 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
9084 target->
ap_flags &= ~APF_OS_THREAD_ENTRY;
9089 != (target->
ap_flags & APF_OS_THREAD_EXIT)) {
9090 if (flags & APF_OS_THREAD_EXIT) {
9110 vwarn(
"could not probe %s; not enabling"
9111 " active thread exit updates!\n",name);
9114 target->
ap_flags &= ~APF_OS_THREAD_EXIT;
9128 target->
ap_flags &= ~APF_OS_THREAD_EXIT;
9133 != (target->
ap_flags & APF_PROCESS_MEMORY)) {
9134 if (flags & APF_PROCESS_MEMORY) {
9155 NULL,os_linux_active_process_memory_post_handler,
9159 verror(
"could not register function entry/exit probe on %s;"
9174 NULL,os_linux_active_process_memory_post_handler,
9178 verror(
"could not register function entry/exit probe on %s;"
9194 NULL,os_linux_active_process_memory_post_handler,
9198 verror(
"could not register function entry/exit probe on %s;"
9214 NULL,os_linux_active_process_memory_post_handler,
9218 verror(
"could not register function entry/exit probe on %s;"
9234 NULL,os_linux_active_process_memory_post_handler,
9238 verror(
"could not register function entry/exit probe on %s;"
9254 NULL,os_linux_active_process_memory_post_handler,
9258 verror(
"could not register function entry/exit probe on %s;"
9274 NULL,os_linux_active_process_memory_post_handler,
9278 verror(
"could not register function entry/exit probe on %s;"
9320 target->
ap_flags &= ~APF_PROCESS_MEMORY;
9328 struct target *overlay,
int force_emulate) {
9336 if (!g_hash_table_lookup(target->
config,
"OS_EMULATE_USERSPACE_EXCEPTIONS")
9341 verror(
"target %s not writeable!\n",target->
name);
9372 struct target *overlay,
int force_emulate) {
9380 if (!g_hash_table_lookup(target->
config,
"OS_EMULATE_USERSPACE_EXCEPTIONS")
9385 verror(
"target %s not writeable!\n",target->
name);
9478 &os_linux_generic_personality_ops,
9479 &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)
static uint64_t unsigned int i
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
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
int target_decoder_lib_bind(struct target *target, char *decoder_lib, char *decoder_lib_lib)
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)
void * calloc(size_t nmemb, size_t size)
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)
void os_linux_generic_register(void)
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)
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)
const char * thread_info_preempt_count_name
#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
void * malloc(size_t size)
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)