int sys_rt_sigpending(struct tcb *tcp) { if (exiting(tcp)) { /* * One of the few syscalls where sigset size (arg[1]) * is allowed to be <= NSIG / 8, not strictly ==. * This allows non-rt sigpending() syscall * to reuse rt_sigpending() code in kernel. */ if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[0]); else print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]); tprintf(", %lu", tcp->u_arg[1]); } return 0; }
int sys_fanotify_init(struct tcb *tcp) { unsigned flags; if (exiting(tcp)) return 0; flags = tcp->u_arg[0]; printxval(fan_classes, flags & FAN_ALL_CLASS_BITS, "FAN_CLASS_???"); flags &= ~FAN_ALL_CLASS_BITS; if (flags) { tprints("|"); printflags(fan_init_flags, flags, "FAN_???"); } tprints(", "); tprint_open_modes((unsigned) tcp->u_arg[1]); return 0; }
static int do_pipe(struct tcb *tcp, int flags_arg) { if (exiting(tcp)) { if (syserror(tcp)) { tprintf("%#lx", tcp->u_arg[0]); } else { #ifdef HAVE_GETRVAL2 if (flags_arg < 0) tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); else #endif printpair_int(tcp, tcp->u_arg[0], "%u"); } if (flags_arg >= 0) { tprints(", "); printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); } } return 0; }
static int do_pipe(struct tcb *tcp, int flags_arg) { if (exiting(tcp)) { if (syserror(tcp)) { printaddr(tcp->u_arg[0]); } else { #ifdef HAVE_GETRVAL2 if (flags_arg < 0) { printpair_fd(tcp, tcp->u_rval, getrval2(tcp)); } else #endif decode_pair_fd(tcp, tcp->u_arg[0]); } if (flags_arg >= 0) { tprints(", "); printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); } } return 0; }
int sys_shmat(struct tcb *tcp) { if (exiting(tcp)) { tprintf("%lu", tcp->u_arg[0]); if (indirect_ipccall(tcp)) { tprintf(", %#lx, ", tcp->u_arg[3]); printflags(shm_flags, tcp->u_arg[1], "SHM_???"); } else { tprintf(", %#lx, ", tcp->u_arg[1]); printflags(shm_flags, tcp->u_arg[2], "SHM_???"); } if (syserror(tcp)) return 0; if (indirect_ipccall(tcp)) { unsigned long raddr; if (umove(tcp, tcp->u_arg[2], &raddr) < 0) return RVAL_NONE; tcp->u_rval = raddr; } return RVAL_HEX; } return 0; }
int sys_times(struct tcb *tcp) { struct tms tbuf; if (exiting(tcp)) { if (tcp->u_arg[0] == 0) tprints("NULL"); else if (syserror(tcp)) tprintf("%#lx", tcp->u_arg[0]); else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0) tprints("{...}"); else { tprintf("{tms_utime=%llu, tms_stime=%llu, ", (unsigned long long) tbuf.tms_utime, (unsigned long long) tbuf.tms_stime); tprintf("tms_cutime=%llu, tms_cstime=%llu}", (unsigned long long) tbuf.tms_cutime, (unsigned long long) tbuf.tms_cstime); } } return 0; }
static void print_cap_data(struct tcb *tcp, unsigned long addr) { union { cap_user_data_t p; long *a; char *c; } arg; long a[sizeof(*arg.p) / sizeof(long) + 1]; arg.a = a; if (!addr) tprints("NULL"); else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) || umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0) tprintf("%#lx", addr); else { tprints("{"); printflags(capabilities, arg.p->effective, "CAP_???"); tprints(", "); printflags(capabilities, arg.p->permitted, "CAP_???"); tprints(", "); printflags(capabilities, arg.p->inheritable, "CAP_???"); tprints("}"); } }
static void print_affinitylist(struct tcb *const tcp, const kernel_ulong_t addr, const unsigned int len) { const unsigned int max_size = get_cpuset_size(); const unsigned int umove_size = len < max_size ? len : max_size; const unsigned int size = (umove_size + current_wordsize - 1) & -current_wordsize; const unsigned int ncpu = size * 8; void *cpu; if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) || !addr || !len || !(cpu = calloc(size, 1))) { printaddr(addr); return; } if (!umoven_or_printaddr(tcp, addr, umove_size, cpu)) { int i = 0; const char *sep = ""; tprints("["); for (;; i++) { i = next_set_bit(cpu, i, ncpu); if (i < 0) break; tprintf("%s%d", sep, i); sep = ", "; } if (size < len) tprintf("%s...", sep); tprints("]"); } free(cpu); }
void ConnectionInitiator::startClients() { QList< User* > friends = qSql->getFriends(); foreach(User* frien_d, friends) { ControlPlaneClient* c = new ControlPlaneClient(*(frien_d->cert), key, QHostAddress(*(frien_d->ipv6)), CONTROLPLANELISTENPORT, *(frien_d->uid), this); c->run(); clients.append(c); QThread* dcThread = new QThread(); // dataplane is threaded DataPlaneConnection* con = this->getDpConnection(QString(*(frien_d->uid))); DataPlaneClient* dc = new DataPlaneClient(QHostAddress(*(frien_d->ipv6)), con); connect(dcThread, SIGNAL(started()), dc, SLOT(run())); connect(dcThread, SIGNAL(finished()), dcThread, SLOT(deleteLater())); UnixSignalHandler* u = UnixSignalHandler::getInstance(); connect(u, SIGNAL(exiting()), dcThread, SLOT(quit())); dc->moveToThread(dcThread); /* we start the thread when the control plane connection is connected! */ ControlPlaneConnection* controlPlane = this->getConnection(QString(*(frien_d->uid))); connect(controlPlane, SIGNAL(connected()), dcThread, SLOT(start())); delete frien_d; }
static void decode_rlimit(struct tcb *tcp, unsigned long addr) { if (!addr) tprints("NULL"); else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) tprintf("%#lx", addr); else { # if defined(X86_64) || defined(X32) /* * i386 is the only personality on X86_64 and X32 * with 32-bit rlim_t. * When current_personality is X32, current_wordsize * equals to 4 but rlim_t is 64-bit. */ if (current_personality == 1) # else if (current_wordsize == 4) # endif print_rlimit32(tcp, addr); else print_rlimit64(tcp, addr); } }
int ptp_ioctl(struct tcb *tcp, const unsigned int code, long arg) { if (!verbose(tcp)) return 0; switch (code) { case PTP_CLOCK_GETCAPS: /* decode on exit */ { struct ptp_clock_caps caps; if (entering(tcp) || syserror(tcp) || umove(tcp, arg, &caps) < 0) return 0; tprintf(", {max_adj=%d, n_alarm=%d, n_ext_ts=%d, n_per_out=%d, pps=%d}", caps.max_adj, caps.n_alarm, caps.n_ext_ts, caps.n_per_out, caps.pps); return 1; } case PTP_EXTTS_REQUEST: /* decode on enter */ { struct ptp_extts_request extts; if (exiting(tcp)) return 1; if (umove(tcp, arg, &extts) < 0) { tprintf(", %#lx", arg); return 0; } tprintf(", {index=%d, flags=", extts.index); printflags(ptp_flags_options, extts.flags, "PTP_???"); tprints("}"); return 1; } case PTP_PEROUT_REQUEST: /* decode on enter */ { struct ptp_perout_request perout; if (exiting(tcp)) return 1; if (umove(tcp, arg, &perout) < 0) { tprintf(", %#lx", arg); return 0; } tprintf(", {start={%" PRId64 ", %" PRIu32 "}" ", period={%" PRId64 ", %" PRIu32 "}" ", index=%d, flags=", (int64_t)perout.start.sec, perout.start.nsec, (int64_t)perout.period.sec, perout.period.nsec, perout.index); printflags(ptp_flags_options, perout.flags, "PTP_???"); tprints("}"); return 1; } case PTP_ENABLE_PPS: /* decode on enter */ if (entering(tcp)) tprintf(", %ld", arg); return 1; case PTP_SYS_OFFSET: /* decode on exit */ { struct ptp_sys_offset sysoff; unsigned int i; if (entering(tcp) || umove(tcp, arg, &sysoff) < 0) return 0; tprintf(", {n_samples=%u, ts={", sysoff.n_samples); if (syserror(tcp)) { tprints("...}}"); return 1; } if (sysoff.n_samples > PTP_MAX_SAMPLES) sysoff.n_samples = PTP_MAX_SAMPLES; tprintf("{%" PRId64 ", %" PRIu32 "}", (int64_t)sysoff.ts[0].sec, sysoff.ts[0].nsec); for (i = 1; i < 2*sysoff.n_samples+1; ++i) tprintf(", {%" PRId64 ", %" PRIu32 "}", (int64_t)sysoff.ts[i].sec, sysoff.ts[i].nsec); tprints("}}"); return 1; } default: /* decode on exit */ return 0; } }
static void decode_new_sigaction(struct tcb *tcp, long addr) { struct new_sigaction sa; int r; if (!addr) { tprints("NULL"); return; } if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) { tprintf("%#lx", addr); return; } #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) { struct new_sigaction32 sa32; r = umove(tcp, addr, &sa32); if (r >= 0) { memset(&sa, 0, sizeof(sa)); sa.__sa_handler = (void*)(unsigned long)sa32.__sa_handler; sa.sa_flags = sa32.sa_flags; sa.sa_restorer = (void*)(unsigned long)sa32.sa_restorer; /* Kernel treats sa_mask as an array of longs. * For 32-bit process, "long" is uint32_t, thus, for example, * 32th bit in sa_mask will end up as bit 0 in sa_mask[1]. * But for (64-bit) kernel, 32th bit in sa_mask is * 32th bit in 0th (64-bit) long! * For little-endian, it's the same. * For big-endian, we swap 32-bit words. */ sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32); } } else #endif { r = umove(tcp, addr, &sa); } if (r < 0) { tprints("{...}"); return; } /* Architectures using function pointers, like * hppa, may need to manipulate the function pointer * to compute the result of a comparison. However, * the __sa_handler function pointer exists only in * the address space of the traced process, and can't * be manipulated by strace. In order to prevent the * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ if ((long)sa.__sa_handler == (long)SIG_ERR) tprints("{SIG_ERR, "); else if ((long)sa.__sa_handler == (long)SIG_DFL) tprints("{SIG_DFL, "); else if ((long)sa.__sa_handler == (long)SIG_IGN) tprints("{SIG_IGN, "); else tprintf("{%#lx, ", (long) sa.__sa_handler); /* * Sigset size is in tcp->u_arg[4] (SPARC) * or in tcp->u_arg[3] (all other), * but kernel won't handle sys_rt_sigaction * with wrong sigset size (just returns EINVAL instead). * We just fetch the right size, which is NSIG / 8. */ tprintsigmask_val("", sa.sa_mask); tprints(", "); printflags(sigact_flags, sa.sa_flags, "SA_???"); #ifdef SA_RESTORER if (sa.sa_flags & SA_RESTORER) tprintf(", %p", sa.sa_restorer); #endif tprints("}"); }
static void decode_old_sigaction(struct tcb *tcp, long addr) { struct old_sigaction sa; int r; if (!addr) { tprints("NULL"); return; } if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) { tprintf("%#lx", addr); return; } #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 if (current_wordsize != sizeof(sa.__sa_handler) && current_wordsize == 4) { struct old_sigaction32 sa32; r = umove(tcp, addr, &sa32); if (r >= 0) { memset(&sa, 0, sizeof(sa)); sa.__sa_handler = (void*)(uintptr_t)sa32.__sa_handler; sa.sa_flags = sa32.sa_flags; sa.sa_restorer = (void*)(uintptr_t)sa32.sa_restorer; sa.sa_mask = sa32.sa_mask; } } else #endif { r = umove(tcp, addr, &sa); } if (r < 0) { tprints("{...}"); return; } /* Architectures using function pointers, like * hppa, may need to manipulate the function pointer * to compute the result of a comparison. However, * the __sa_handler function pointer exists only in * the address space of the traced process, and can't * be manipulated by strace. In order to prevent the * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ if ((long)sa.__sa_handler == (long)SIG_ERR) tprints("{SIG_ERR, "); else if ((long)sa.__sa_handler == (long)SIG_DFL) tprints("{SIG_DFL, "); else if ((long)sa.__sa_handler == (long)SIG_IGN) tprints("{SIG_IGN, "); else tprintf("{%#lx, ", (long) sa.__sa_handler); #ifdef MIPS tprintsigmask_addr("", sa.sa_mask); #else tprintsigmask_val("", sa.sa_mask); #endif tprints(", "); printflags(sigact_flags, sa.sa_flags, "SA_???"); #ifdef SA_RESTORER if (sa.sa_flags & SA_RESTORER) tprintf(", %p", sa.sa_restorer); #endif tprints("}"); }
int block_ioctl(struct tcb *tcp, long code, long arg) { switch (code) { /* take arg as a value, not as a pointer */ case BLKRASET: case BLKFRASET: if (entering(tcp)) tprintf(", %ld", arg); break; /* take a signed int */ case BLKROSET: case BLKBSZSET: if (entering(tcp)) { int val; if (umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %d", val); } break; /* returns an unsigned short */ case BLKSECTGET: if (exiting(tcp)) { unsigned short val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %hu", val); } break; /* return a signed int */ case BLKROGET: case BLKBSZGET: case BLKSSZGET: case BLKALIGNOFF: if (exiting(tcp)) { int val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %d", val); } break; /* return an unsigned int */ case BLKPBSZGET: case BLKIOMIN: case BLKIOOPT: case BLKDISCARDZEROES: if (exiting(tcp)) { unsigned int val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %u", val); } break; /* return a signed long */ case BLKRAGET: case BLKFRAGET: if (exiting(tcp)) { long val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %ld", val); } break; /* returns an unsigned long */ case BLKGETSIZE: if (exiting(tcp)) { unsigned long val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %lu", val); } break; /* return an uint64_t */ case BLKGETSIZE64: if (exiting(tcp)) { uint64_t val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %" PRIu64, val); } break; /* More complex types */ case BLKDISCARD: case BLKSECDISCARD: if (entering(tcp)) { uint64_t range[2]; if (umove(tcp, arg, range) < 0) tprintf(", %#lx", arg); else tprintf(", {%" PRIx64 ", %" PRIx64 "}", range[0], range[1]); } break; case HDIO_GETGEO: if (exiting(tcp)) { struct hd_geometry geo; if (syserror(tcp) || umove(tcp, arg, &geo) < 0) tprintf(", %#lx", arg); else tprintf(", {heads=%hhu, sectors=%hhu, " "cylinders=%hu, start=%lu}", geo.heads, geo.sectors, geo.cylinders, geo.start); } break; case BLKPG: if (entering(tcp)) { struct blkpg_ioctl_arg blkpg; if (umove(tcp, arg, &blkpg) < 0) tprintf(", %#lx", arg); else { tprintf(", "); print_blkpg_req(tcp, &blkpg); } } break; case BLKTRACESETUP: if (entering(tcp)) { struct blk_user_trace_setup buts; if (umove(tcp, arg, &buts) < 0) tprintf(", %#lx", arg); else tprintf(", {act_mask=%hu, buf_size=%u, " "buf_nr=%u, start_lba=%" PRIu64 ", " "end_lba=%" PRIu64 ", pid=%u}", buts.act_mask, buts.buf_size, buts.buf_nr, buts.start_lba, buts.end_lba, buts.pid); } if (exiting(tcp)) { struct blk_user_trace_setup buts; if (syserror(tcp) || umove(tcp, arg, &buts) < 0) tprintf(", %#lx", arg); else tprintf(", {name=\"%.*s\"}", (int) sizeof(buts.name), buts.name); } break; /* No arguments or unhandled */ case BLKTRACESTART: case BLKTRACESTOP: case BLKTRACETEARDOWN: case BLKFLSBUF: /* Requires driver knowlege */ case BLKRRPART: /* No args */ default: if (entering(tcp)) tprintf(", %#lx", arg); break; }; return 1; }
void Network_Kill() { exiting(1); }
int block_ioctl(struct tcb *tcp, const unsigned int code, long arg) { switch (code) { /* take arg as a value, not as a pointer */ case BLKRASET: case BLKFRASET: if (entering(tcp)) tprintf(", %ld", arg); break; /* take a signed int */ case BLKROSET: case BLKBSZSET: #ifdef FIFREEZE /* First seen in linux-2.6.29 */ case FIFREEZE: case FITHAW: #endif if (entering(tcp)) { int val; if (umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %d", val); } break; /* returns an unsigned short */ case BLKSECTGET: if (exiting(tcp)) { unsigned short val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %u", (unsigned)val); } break; /* return a signed int */ case BLKROGET: case BLKBSZGET: case BLKSSZGET: case BLKALIGNOFF: if (exiting(tcp)) { int val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %d", val); } break; /* return an unsigned int */ case BLKPBSZGET: case BLKIOMIN: case BLKIOOPT: case BLKDISCARDZEROES: if (exiting(tcp)) { unsigned int val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %u", val); } break; /* return a signed long */ case BLKRAGET: case BLKFRAGET: if (exiting(tcp)) { long val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %ld", val); } break; /* returns an unsigned long */ case BLKGETSIZE: if (exiting(tcp)) { unsigned long val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %lu", val); } break; #ifdef HAVE_BLKGETSIZE64 /* return an uint64_t */ case BLKGETSIZE64: if (exiting(tcp)) { uint64_t val; if (syserror(tcp) || umove(tcp, arg, &val) < 0) tprintf(", %#lx", arg); else tprintf(", %" PRIu64, val); } break; #endif /* More complex types */ case BLKDISCARD: case BLKSECDISCARD: if (entering(tcp)) { uint64_t range[2]; if (umove(tcp, arg, range) < 0) tprintf(", %#lx", arg); else tprintf(", {%" PRIx64 ", %" PRIx64 "}", range[0], range[1]); } break; case HDIO_GETGEO: if (exiting(tcp)) { struct hd_geometry geo; if (syserror(tcp) || umove(tcp, arg, &geo) < 0) tprintf(", %#lx", arg); else tprintf(", {heads=%u, sectors=%u, " "cylinders=%u, start=%lu}", (unsigned)geo.heads, (unsigned)geo.sectors, (unsigned)geo.cylinders, geo.start); } break; case BLKPG: if (entering(tcp)) { struct blkpg_ioctl_arg blkpg; if (umove(tcp, arg, &blkpg) < 0) tprintf(", %#lx", arg); else { tprints(", "); print_blkpg_req(tcp, &blkpg); } } break; case BLKTRACESETUP: if (entering(tcp)) { struct blk_user_trace_setup buts; if (umove(tcp, arg, &buts) < 0) tprintf(", %#lx", arg); else tprintf(", {act_mask=%u, buf_size=%u, " "buf_nr=%u, start_lba=%" PRIu64 ", " "end_lba=%" PRIu64 ", pid=%u}", (unsigned)buts.act_mask, buts.buf_size, buts.buf_nr, buts.start_lba, buts.end_lba, buts.pid); } if (exiting(tcp)) { struct blk_user_trace_setup buts; if (syserror(tcp) || umove(tcp, arg, &buts) < 0) tprintf(", %#lx", arg); else { tprints(", {name="); print_quoted_string(buts.name, sizeof(buts.name), QUOTE_0_TERMINATED); tprints("}"); } } break; #ifdef FITRIM /* First seen in linux-2.6.37 */ case FITRIM: if (entering(tcp)) { struct fstrim_range fstrim; if (umove(tcp, arg, &fstrim)) tprintf(", %#lx", arg); else tprintf(", {start=%#" PRIx64 ", len=%#" PRIx64 ", " "minlen=%#" PRIx64 "}", (uint64_t) fstrim.start, (uint64_t) fstrim.len, (uint64_t) fstrim.minlen); } break; #endif /* No arguments or unhandled */ case BLKTRACESTART: case BLKTRACESTOP: case BLKTRACETEARDOWN: case BLKFLSBUF: /* Requires driver knowlege */ case BLKRRPART: /* No args */ default: if (entering(tcp)) tprintf(", %#lx", arg); break; }; return 1; }
/* * There are two different modes of operation: * * - Get buffer size. In this case, the callee sets ifc_buf to NULL, * and the kernel returns the buffer size in ifc_len. * - Get actual data. In this case, the callee specifies the buffer address * in ifc_buf and its size in ifc_len. The kernel fills the buffer with * the data, and its amount is returned in ifc_len. * * Note that, technically, the whole struct ifconf is overwritten, * so ifc_buf could be different on exit, but current ioctl handler * implementation does not touch it. */ static int decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr) { struct_ifconf *entering_ifc = NULL; struct_ifconf *ifc = entering(tcp) ? malloc(sizeof(*ifc)) : alloca(sizeof(*ifc)); if (exiting(tcp)) { entering_ifc = get_tcb_priv_data(tcp); if (!entering_ifc) { error_msg("decode_ifconf: where is my ifconf?"); return 0; } } if (!ifc || umove(tcp, addr, ifc) < 0) { if (entering(tcp)) { free(ifc); tprints(", "); printaddr(addr); } else { /* * We failed to fetch the structure on exiting syscall, * print whatever was fetched on entering syscall. */ if (!entering_ifc->ifc_buf) print_ifc_len(entering_ifc->ifc_len); tprints(", ifc_buf="); printaddr(ptr_to_kulong(entering_ifc->ifc_buf)); tprints("}"); } return RVAL_DECODED | 1; } if (entering(tcp)) { tprints(", {ifc_len="); if (ifc->ifc_buf) print_ifc_len(ifc->ifc_len); set_tcb_priv_data(tcp, ifc, free); return 1; } /* exiting */ if (entering_ifc->ifc_buf && (entering_ifc->ifc_len != ifc->ifc_len)) tprints(" => "); if (!entering_ifc->ifc_buf || (entering_ifc->ifc_len != ifc->ifc_len)) print_ifc_len(ifc->ifc_len); tprints(", ifc_buf="); if (!entering_ifc->ifc_buf || syserror(tcp)) { printaddr(ptr_to_kulong(entering_ifc->ifc_buf)); if (entering_ifc->ifc_buf != ifc->ifc_buf) { tprints(" => "); printaddr(ptr_to_kulong(ifc->ifc_buf)); } } else { struct_ifreq ifr; print_array(tcp, ptr_to_kulong(ifc->ifc_buf), ifc->ifc_len / sizeof(struct_ifreq), &ifr, sizeof(ifr), umoven_or_printaddr, print_ifconf_ifreq, NULL); } tprints("}"); return RVAL_DECODED | 1; }
static void abort_handler(int sig) { DWORD Error = GetLastError(); exiting(); SetLastError(Error); }
int file_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg) { switch (code) { case FICLONE: /* W */ tprintf(", %d", (int) arg); break; case FICLONERANGE: { /* W */ struct file_clone_range args; tprints(", "); if (umove_or_printaddr(tcp, arg, &args)) break; tprints("{src_fd="); printfd(tcp, args.src_fd); tprintf(", src_offset=%" PRIu64 ", src_length=%" PRIu64 ", dest_offset=%" PRIu64 "}", (uint64_t) args.src_offset, (uint64_t) args.src_length, (uint64_t) args.dest_offset); break; } case FIDEDUPERANGE: { /* RW */ struct file_dedupe_range args; struct file_dedupe_range_info info; unsigned int *limit = NULL; unsigned int count = 2; bool rc; if (entering(tcp)) tprints(", "); else if (syserror(tcp)) break; else tprints(" => "); if (umove_or_printaddr(tcp, arg, &args)) break; tprints("{"); if (entering(tcp)) { tprintf("src_offset=%" PRIu64 ", src_length=%" PRIu64 ", dest_count=%hu, ", (uint64_t) args.src_offset, (uint64_t) args.src_length, (uint16_t) args.dest_count); } tprints("info="); /* Limit how many elements we print in abbrev mode. */ if (abbrev(tcp) && args.dest_count > count) limit = &count; rc = print_array(tcp, arg + offsetof(typeof(args), info), args.dest_count, &info, sizeof(info), tfetch_mem, print_file_dedupe_range_info, limit); tprints("}"); if (!rc || exiting(tcp)) break; return 0; } #ifdef HAVE_LINUX_FIEMAP_H case FS_IOC_FIEMAP: { struct fiemap args; if (entering(tcp)) tprints(", "); else if (syserror(tcp)) break; else tprints(" => "); if (umove_or_printaddr(tcp, arg, &args)) break; if (entering(tcp)) { tprintf("{fm_start=%" PRI__u64 ", " "fm_length=%" PRI__u64 ", " "fm_flags=", args.fm_start, args.fm_length); printflags64(fiemap_flags, args.fm_flags, "FIEMAP_FLAG_???"); tprintf(", fm_extent_count=%u}", args.fm_extent_count); return 0; } tprints("{fm_flags="); printflags64(fiemap_flags, args.fm_flags, "FIEMAP_FLAG_???"); tprintf(", fm_mapped_extents=%u", args.fm_mapped_extents); if (abbrev(tcp)) { tprints(", ..."); } else { struct fiemap_extent fe; tprints(", fm_extents="); print_array(tcp, arg + offsetof(typeof(args), fm_extents), args.fm_mapped_extents, &fe, sizeof(fe), tfetch_mem, print_fiemap_extent, 0); } tprints("}"); break; } #endif /* HAVE_LINUX_FIEMAP_H */ default: return RVAL_DECODED; }; return RVAL_IOCTL_DECODED; }
static void halt(int argc, char **argv) { exiting(); exit(0); }
LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) { exiting(); return EXCEPTION_EXECUTE_HANDLER; }
void KateAppAdaptor::emitExiting () { emit exiting (); }
int trace_syscall(struct tcb *tcp, unsigned int *signo) { return exiting(tcp) ? trace_syscall_exiting(tcp) : trace_syscall_entering(tcp, signo); }
void StandaloneMenu::quit () { emit exiting(); }
// test iterating objects in slabs void MemoryManager::checkHeap(const char* phase) { size_t bytes=0; std::vector<Header*> hdrs; std::unordered_set<FreeNode*> free_blocks; std::unordered_set<APCLocalArray*> apc_arrays; std::unordered_set<StringData*> apc_strings; size_t counts[NumHeaderKinds]; for (unsigned i=0; i < NumHeaderKinds; i++) counts[i] = 0; forEachHeader([&](Header* h) { hdrs.push_back(&*h); bytes += h->size(); counts[(int)h->kind()]++; switch (h->kind()) { case HeaderKind::Free: free_blocks.insert(&h->free_); break; case HeaderKind::Apc: if (h->apc_.m_sweep_index != kInvalidSweepIndex) { apc_arrays.insert(&h->apc_); } break; case HeaderKind::String: if (h->str_.isProxy()) apc_strings.insert(&h->str_); break; case HeaderKind::Packed: case HeaderKind::Struct: case HeaderKind::Mixed: case HeaderKind::Empty: case HeaderKind::Globals: case HeaderKind::Proxy: case HeaderKind::Object: case HeaderKind::WaitHandle: case HeaderKind::ResumableObj: case HeaderKind::AwaitAllWH: case HeaderKind::Vector: case HeaderKind::Map: case HeaderKind::Set: case HeaderKind::Pair: case HeaderKind::ImmVector: case HeaderKind::ImmMap: case HeaderKind::ImmSet: case HeaderKind::Resource: case HeaderKind::Ref: case HeaderKind::ResumableFrame: case HeaderKind::NativeData: case HeaderKind::SmallMalloc: case HeaderKind::BigMalloc: break; case HeaderKind::BigObj: case HeaderKind::Hole: assert(false && "forEachHeader skips these kinds"); break; } }); // check the free lists for (auto i = 0; i < kNumSmallSizes; i++) { for (auto n = m_freelists[i].head; n; n = n->next) { assert(free_blocks.find(n) != free_blocks.end()); free_blocks.erase(n); } } assert(free_blocks.empty()); // check the apc array list assert(apc_arrays.size() == m_apc_arrays.size()); for (auto a : m_apc_arrays) { assert(apc_arrays.find(a) != apc_arrays.end()); apc_arrays.erase(a); } assert(apc_arrays.empty()); // check the apc string list for (StringDataNode *next, *n = m_strings.next; n != &m_strings; n = next) { next = n->next; auto const s = StringData::node2str(n); assert(s->isProxy()); assert(apc_strings.find(s) != apc_strings.end()); apc_strings.erase(s); } assert(apc_strings.empty()); // heap check is done. If we are not exiting, check pointers using HeapGraph if (Trace::moduleEnabled(Trace::heapreport)) { auto g = makeHeapGraph(); if (!exiting()) checkPointers(g, phase); if (Trace::moduleEnabled(Trace::heapreport, 2)) { printHeapReport(g, phase); } } }
int sys_move_pages(struct tcb *tcp) { if (entering(tcp)) { unsigned long npages = tcp->u_arg[1]; tprintf("%ld, %lu, ", tcp->u_arg[0], npages); if (tcp->u_arg[2] == 0) tprints("NULL, "); else { unsigned int i; long puser = tcp->u_arg[2]; tprints("{"); for (i = 0; i < npages; ++i) { void *p; if (i > 0) tprints(", "); if (umove(tcp, puser, &p) < 0) { tprints("???"); break; } tprintf("%p", p); puser += sizeof(void *); } tprints("}, "); } if (tcp->u_arg[3] == 0) tprints("NULL, "); else { unsigned int i; long nodeuser = tcp->u_arg[3]; tprints("{"); for (i = 0; i < npages; ++i) { int node; if (i > 0) tprints(", "); if (umove(tcp, nodeuser, &node) < 0) { tprints("???"); break; } tprintf("%#x", node); nodeuser += sizeof(int); } tprints("}, "); } } if (exiting(tcp)) { unsigned long npages = tcp->u_arg[1]; if (tcp->u_arg[4] == 0) tprints("NULL, "); else { unsigned int i; long statususer = tcp->u_arg[4]; tprints("{"); for (i = 0; i < npages; ++i) { int status; if (i > 0) tprints(", "); if (umove(tcp, statususer, &status) < 0) { tprints("???"); break; } tprintf("%#x", status); statususer += sizeof(int); } tprints("}, "); } printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); } return 0; }
int trace_syscall(struct tcb *tcp) { return exiting(tcp) ? trace_syscall_exiting(tcp) : trace_syscall_entering(tcp); }
void Tracker::spin() { ros::Rate loopRateTracking(100); tf::Transform transform; std_msgs::Header lastHeader; while (!exiting()) { // When a camera sequence is played several times, // the seq id will decrease, in this case we want to // continue the tracking. if (header_.seq < lastHeader.seq) lastTrackedImage_ = 0; if (lastTrackedImage_ < header_.seq) { lastTrackedImage_ = header_.seq; // If we can estimate the camera displacement using tf, // we update the cMo to compensate for robot motion. if (compensateRobotMotion_) try { tf::StampedTransform stampedTransform; listener_.lookupTransform (header_.frame_id, // camera frame name header_.stamp, // current image time header_.frame_id, // camera frame name lastHeader.stamp, // last processed image time worldFrameId_, // frame attached to the environment stampedTransform ); vpHomogeneousMatrix newMold; transformToVpHomogeneousMatrix (newMold, stampedTransform); cMo_ = newMold * cMo_; mutex_.lock(); tracker_->setPose(image_, cMo_); mutex_.unlock(); } catch(tf::TransformException& e) { mutex_.unlock(); } // If we are lost but an estimation of the object position // is provided, use it to try to reinitialize the system. if (state_ == LOST) { // If the last received message is recent enough, // use it otherwise do nothing. if (ros::Time::now () - objectPositionHint_.header.stamp < ros::Duration (1.)) transformToVpHomogeneousMatrix (cMo_, objectPositionHint_.transform); mutex_.lock(); tracker_->setPose(image_, cMo_); mutex_.unlock(); } // We try to track the image even if we are lost, // in the case the tracker recovers... if (state_ == TRACKING || state_ == LOST) try { mutex_.lock(); // tracker_->setPose(image_, cMo_); // Removed as it is not necessary when the pose is not modified from outside. tracker_->track(image_); tracker_->getPose(cMo_); mutex_.unlock(); } catch(...) { mutex_.unlock(); ROS_WARN_THROTTLE(10, "tracking lost"); state_ = LOST; } // Publish the tracking result. if (state_ == TRACKING) { geometry_msgs::Transform transformMsg; vpHomogeneousMatrixToTransform(transformMsg, cMo_); // Publish position. if (transformationPublisher_.getNumSubscribers () > 0) { geometry_msgs::TransformStampedPtr objectPosition (new geometry_msgs::TransformStamped); objectPosition->header = header_; objectPosition->child_frame_id = childFrameId_; objectPosition->transform = transformMsg; transformationPublisher_.publish(objectPosition); } // Publish result. if (resultPublisher_.getNumSubscribers () > 0) { geometry_msgs::PoseWithCovarianceStampedPtr result (new geometry_msgs::PoseWithCovarianceStamped); result->header = header_; result->pose.pose.position.x = transformMsg.translation.x; result->pose.pose.position.y = transformMsg.translation.y; result->pose.pose.position.z = transformMsg.translation.z; result->pose.pose.orientation.x = transformMsg.rotation.x; result->pose.pose.orientation.y = transformMsg.rotation.y; result->pose.pose.orientation.z = transformMsg.rotation.z; result->pose.pose.orientation.w = transformMsg.rotation.w; const vpMatrix& covariance = tracker_->getCovarianceMatrix(); for (unsigned i = 0; i < covariance.getRows(); ++i) for (unsigned j = 0; j < covariance.getCols(); ++j) { unsigned idx = i * covariance.getCols() + j; if (idx >= 36) continue; result->pose.covariance[idx] = covariance[i][j]; } resultPublisher_.publish(result); } // Publish moving edge sites. if (movingEdgeSitesPublisher_.getNumSubscribers () > 0) { visp_tracker::MovingEdgeSitesPtr sites (new visp_tracker::MovingEdgeSites); updateMovingEdgeSites(sites); sites->header = header_; movingEdgeSitesPublisher_.publish(sites); } // Publish KLT points. if (kltPointsPublisher_.getNumSubscribers () > 0) { visp_tracker::KltPointsPtr klt (new visp_tracker::KltPoints); updateKltPoints(klt); klt->header = header_; kltPointsPublisher_.publish(klt); } // Publish to tf. transform.setOrigin (tf::Vector3(transformMsg.translation.x, transformMsg.translation.y, transformMsg.translation.z)); transform.setRotation (tf::Quaternion (transformMsg.rotation.x, transformMsg.rotation.y, transformMsg.rotation.z, transformMsg.rotation.w)); transformBroadcaster_.sendTransform (tf::StampedTransform (transform, header_.stamp, header_.frame_id, childFrameId_)); } } lastHeader = header_; spinOnce(); loopRateTracking.sleep(); } }
HomePage::HomePage(MApplicationWindow* wind):MApplicationPage() { this->setTitle("Home Page"); VLay=new QGraphicsGridLayout(this->centralWidget()); im=new MImageWidget(this->centralWidget()); QString logo_image( KVP_THEMES_STYLE_DIR ); logo_image += KVP_THEMES_LOGO; QPixmap pp( logo_image ); im->setPixmap(pp); VLay=new QGraphicsGridLayout(this->centralWidget()); con_list=new MButton("Contact list"); settings=new MButton("Settings"); registration=new MButton("Registration"); login=new MButton("Login / Relogin"); exit = new MButton("Exit"); about =new MButton("About"); //settings->setEnabled(false); empty_label=new MLabel(""); size_but = wind->size().width()/2; size = wind->size().height()/5.7; empty_label->setMinimumWidth(size_but); empty_label->setMaximumWidth(size_but); exit->setMinimumWidth(size_but); exit->setMaximumWidth(size_but); login->setMaximumHeight(size); login->setMinimumHeight(size); con_list->setMaximumHeight(size); con_list->setMinimumHeight(size); registration->setMaximumHeight(size); registration->setMinimumHeight(size); settings->setMaximumHeight(size); settings->setMinimumHeight(size); exit->setMaximumHeight(size); exit->setMinimumHeight(size); about->setMaximumHeight(size); about->setMinimumHeight(size); login->setMaximumWidth(size_but); login->setMinimumWidth(size_but); con_list->setMaximumWidth(size_but); con_list->setMinimumWidth(size_but); registration->setMaximumWidth(size_but); registration->setMinimumWidth(size_but); settings->setMaximumWidth(size_but); settings->setMinimumWidth(size_but); exit->setMaximumWidth(size_but); exit->setMinimumWidth(size_but); about->setMaximumWidth(size_but); about->setMinimumWidth(size_but); VLay->addItem(im,1,1,4,1); // VLay->addItem(empty_label,1,1,4,1); VLay->addItem(con_list,1,2); VLay->addItem(login,2,2); VLay->addItem(settings,3,2); VLay->addItem(registration,4,2); VLay->addItem(about,5,2); VLay->addItem(exit,5,1); VLay->setSpacing(-11); connect(login,SIGNAL(clicked()),SIGNAL(goLoginPage())); connect(con_list,SIGNAL(clicked()),SIGNAL(goContactListPage())); connect(registration,SIGNAL(clicked()),SIGNAL(goRegistrationPage())); connect(settings,SIGNAL(clicked()),SIGNAL(goSettingPage())); connect(about,SIGNAL(clicked()),SIGNAL(goInfoPage())); connect(exit,SIGNAL(clicked()),SIGNAL(exiting())); }
void DataPlaneServer::readyRead(int) { memset(&client_addr, 0, sizeof(struct sockaddr_storage)); /* Create BIO */ bio = BIO_new_dgram(fd, BIO_NOCLOSE); /* Set and activate timeouts */ timeout.tv_sec = 5; timeout.tv_usec = 0; BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout); ssl = SSL_new(ctx); SSL_set_bio(ssl, bio, bio); SSL_set_options(ssl, SSL_OP_COOKIE_EXCHANGE); int dtlsRet; errno = 0; while ((dtlsRet = DTLSv1_listen(ssl, &client_addr)) <= 0) { if (errno != EAGAIN) { qWarning() << "DTLSv1_listen error"; qWarning() << SSL_get_error(ssl, dtlsRet); qWarning() << "Errno is" << errno; if (errno == EINVAL) { qWarning() << "!!!!!!!!!!! Your openssl library does not support DTLSv1_listen !!!!!!!!!!!"; qWarning() << "Cannot accept new connection"; SSL_shutdown(ssl); close(fd); SSL_free(ssl); ERR_remove_state(0); return; } } } QThread* workerThread = new QThread(); threads.append(workerThread); addrUnion infServer_addr; addrUnion infClient_addr; memcpy(&infServer_addr, &server_addr, sizeof(struct sockaddr_storage)); memcpy(&infClient_addr, &client_addr, sizeof(struct sockaddr_storage)); // get UID from friend using his IP to create worker thread // if IP is not in DB we close the connection char friendIp[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &infClient_addr.s6.sin6_addr, friendIp, INET6_ADDRSTRLEN); ConnectionInitiator* init = ConnectionInitiator::getInstance(); QString friendUid = qSql->getUidFromIP(QHostAddress(QString(friendIp))); ControlPlaneConnection* cp = init->getConnection(friendUid); if (friendUid.isEmpty() || cp->getMode() == Closed) { qDebug() << "friendUId NOT in DB or no control plane connection!"; SSL_shutdown(ssl); close(fd); //free(info); SSL_free(ssl); ERR_remove_state(0); qDebug("done, connection closed."); fflush(stdout); return; } // associate with dataplaneconnection DataPlaneConnection* dpc = init->getDpConnection(friendUid); ServerWorker* worker = new ServerWorker(infServer_addr, infClient_addr, ssl, dpc); worker->moveToThread(workerThread); connect(workerThread, SIGNAL(started()), worker, SLOT(connection_handle())); connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); //connect(worker, SIGNAL(bufferReady(const char*, int)), dpc, SLOT(readBuffer(const char*, int))); UnixSignalHandler* u = UnixSignalHandler::getInstance(); connect(u, SIGNAL(exiting()), workerThread, SLOT(quit())); workerThread->start(); }