if (VG_(extend_stack)(tid, addr)) {
stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
+ if (0 && stackseg) {
VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
addr, stackseg->start, stackseg->end);
+ }
}
if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
Vg_UserMsg,
"Can't extend stack to %#lx during signal delivery for thread %u:\n",
addr, tid);
- if (stackseg == NULL)
+ if (stackseg == NULL) {
VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
+ } else {
VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
+ }
/* set SIGSEGV to default handler */
VG_(set_default_handler)(VKI_SIGSEGV);
rsp = VG_ROUNDDN(rsp, 16) - 8;
frame = (struct sigframe *)rsp;
- if (!extend(tst, rsp, sizeof(*frame)))
+ if (!extend(tst, rsp, sizeof(*frame))) {
return rsp_top_of_frame;
+ }
/* retaddr, siginfo, uContext fields are to be written */
VG_TRACK( pre_mem_write, Vg_CoreSignal, tst->tid, "signal handler frame",
SizeT restore_sigframe ( ThreadState *tst,
struct sigframe *frame, Int *sigNo )
{
- if (restore_vg_sigframe(tst, &frame->vg, sigNo))
+ if (restore_vg_sigframe(tst, &frame->vg, sigNo)) {
restore_sigcontext(tst, &frame->uContext.uc_mcontext, &frame->fpstate);
+ }
return sizeof(*frame);
}
// %rsi == retaddr
// %rdx == f
// %rcx == arg1
-asm(
+__asm__(
".text\n"
".globl vgModuleLocal_call_on_new_stack_0_1\n"
"vgModuleLocal_call_on_new_stack_0_1:\n"
case VKI_AMD64_SET_FSBASE:
break;
case VKI_AMD64_GET_FSBASE:
- POST_MEM_WRITE( ARG2, sizeof(void *) );
- break;
case VKI_AMD64_GET_XFPUSTATE:
POST_MEM_WRITE( ARG2, sizeof(void *) );
break;
if (!ML_(fd_allowed)(ARG1, "preadv", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
- if ((Int)ARG3 > 0)
+ if ((Int)ARG3 > 0) {
PRE_MEM_READ( "preadv(iov)", ARG2, ARG3 * sizeof(struct vki_iovec) );
+ }
if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) {
vec = (struct vki_iovec *)(Addr)ARG2;
/* RES holds the number of bytes read. */
for (i = 0; i < (Int)ARG3; i++) {
Int nReadThisBuf = vec[i].iov_len;
- if (nReadThisBuf > remains) nReadThisBuf = remains;
+ if (nReadThisBuf > remains) {
+ nReadThisBuf = remains;
+ }
POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf );
remains -= nReadThisBuf;
- if (remains < 0) VG_(core_panic)("preadv: remains < 0");
+ if (remains < 0) {
+ VG_(core_panic)("preadv: remains < 0");
+ }
}
}
}
if (!ML_(fd_allowed)(ARG1, "pwritev", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
- if ((Int)ARG3 >= 0)
+ if ((Int)ARG3 >= 0) {
PRE_MEM_READ( "pwritev(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
+ }
if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) {
vec = (struct vki_iovec *)(Addr)ARG2;
for (i = 0; i < (Int)ARG3; i++) {
int, fd, int, s, vki_off_t, offset, size_t, nbytes,
void *, hdtr, vki_off_t *, sbytes, int, flags);
- if (ARG5 != 0)
+ if (ARG5 != 0) {
PRE_MEM_READ("sendfile(hdtr)", ARG5, sizeof(struct vki_sf_hdtr));
+ }
- if (ARG6 != 0)
+ if (ARG6 != 0) {
PRE_MEM_WRITE( "sendfile(sbytes)", ARG6, sizeof(vki_off_t) );
+ }
}
POST(sys_sendfile)
// int swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
PRE(sys_swapcontext)
{
- struct vki_ucontext *ucp, *oucp;
+ struct vki_ucontext *ucp;
+ struct vki_ucontext *oucp;
ThreadState* tst;
PRINT("sys_swapcontext ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2);
ThreadState* ptst = VG_(get_ThreadState)(tid);
ThreadState* ctst = VG_(get_ThreadState)(ctid);
SysRes res;
- vki_sigset_t blockall, savedmask;
+ vki_sigset_t blockall;
+ vki_sigset_t savedmask;
struct vki_thr_param tp;
Addr stk;
label below, to clean up. */
VG_TRACK ( pre_thread_ll_create, tid, ctid );
- if (debug)
+ if (debug) {
VG_(printf)("clone child has SETTLS: tls at %#lx\n", (Addr)tp.tls_base);
+ }
ctst->arch.vex.guest_FS_CONST = (UWord)tp.tls_base;
tp.tls_base = 0; /* Don't have the kernel do it too */
between marking it Empty and exiting. Hence the
assembler. */
#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */
- asm volatile (
+ __asm__ volatile (
"movl %1, %0\n" /* set tst->status = VgTs_Empty */
"movl %2, %%eax\n" /* set %eax = __NR_thr_exit */
"movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */
: "eax", "ebx"
);
#elif defined(VGP_amd64_freebsd)
- asm volatile (
+ __asm__ volatile (
"movl %1, %0\n" /* set tst->status = VgTs_Empty */
"movq %2, %%rax\n" /* set %rax = __NR_thr_exit */
"movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */
case a stack hasn't been allocated) or they are both non-zero,
in which case it has. */
- if (tst->os_state.valgrind_stack_base == 0)
+ if (tst->os_state.valgrind_stack_base == 0) {
vg_assert(tst->os_state.valgrind_stack_init_SP == 0);
+ }
- if (tst->os_state.valgrind_stack_base != 0)
+ if (tst->os_state.valgrind_stack_base != 0) {
vg_assert(tst->os_state.valgrind_stack_init_SP != 0);
+ }
/* If no stack is present, allocate one. */
if (SUCCESS && ((Word)RES != -1)) {
UInt i;
struct vki_pollfd* ufds = (struct vki_pollfd *)(Addr)ARG1;
- for (i = 0; i < ARG2; i++)
+ for (i = 0; i < ARG2; i++) {
POST_MEM_WRITE( (Addr)(&ufds[i].revents), sizeof(ufds[i].revents) );
+ }
}
ML_(free_safe_mask) ( (Addr)ARG4 );
}
int, kq, struct vki_kevent *, changelist, int, nchanges,
struct vki_kevent *, eventlist, int, nevents,
struct timespec *, timeout);
- if (ARG2 != 0 && ARG3 != 0)
+ if (ARG2 != 0 && ARG3 != 0) {
PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent)*ARG3 );
- if (ARG4 != 0 && ARG5 != 0)
+ }
+ if (ARG4 != 0 && ARG5 != 0) {
PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent)*ARG5);
- if (ARG5 != 0)
+ }
+ if (ARG5 != 0) {
*flags |= SfMayBlock;
- if (ARG6 != 0)
+ }
+ if (ARG6 != 0) {
PRE_MEM_READ( "kevent(timeout)",
ARG6, sizeof(struct vki_timespec));
+ }
}
POST(sys_kevent)
{
vg_assert(SUCCESS);
if ((Word)RES != -1) {
- if (ARG4 != 0)
+ if (ARG4 != 0) {
POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent)*RES) ;
+ }
}
}
/* Is it in the contiguous initial section of the table? */
if (sysno < syscall_table_size) {
const SyscallTableEntry* sys = &ML_(syscall_table)[sysno];
- if (sys->before == NULL)
+ if (sys->before == NULL) {
return NULL; /* no entry */
- else
- return sys;
+ }
+ return sys;
}
/* Can't find a wrapper */
// 8(%esp) == retaddr
// 12(%esp) == f
// 16(%esp) == arg1
-asm(
+__asm__(
".text\n"
".globl vgModuleLocal_call_on_new_stack_0_1\n"
"vgModuleLocal_call_on_new_stack_0_1:\n"
if (debuglevel >= 1) {
DEBUG (1, "Writing ");
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
PDEBUG (1, "%02x", ((const unsigned char*)myaddr)[i]);
+ }
PDEBUG(1, " to %p\n", (void *) memaddr);
}
errno = 0;
ptrace (PT_WRITE_I, inferior_pid,
(PTRACE_ARG3_TYPE) addr, buffer[i]);
- if (errno)
+ if (errno) {
return errno;
+ }
}
return 0;
if (WIFSIGNALED(status)) {
APPEND ("WIFSIGNALED %d ", WTERMSIG(status));
- if (WCOREDUMP(status)) APPEND ("WCOREDUMP ");
+ if (WCOREDUMP(status)) {
+ APPEND ("WCOREDUMP ");
+ }
}
if (WIFSTOPPED(status))
APPEND ("WIFSTOPPED %d ", WSTOPSIG(status));
#ifdef WIFCONTINUED
- if (WIFCONTINUED(status))
+ if (WIFCONTINUED(status)) {
APPEND ("WIFCONTINUED ");
+ }
#endif
return result;
assert (WIFSTOPPED(status));
signal_received = WSTOPSIG(status);
- if (signal_received == signal_expected)
+ if (signal_received == signal_expected) {
break;
+ }
/* pid received a signal which is not the signal we are waiting for.
If we have not (yet) changed the registers of the inferior
*/
#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \
&& (defined(VGP_arm_linux) \
- || defined(VGP_x86_linux) || defined(VGP_x86_solaris))
+ || defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd))
/* mc_main_asm.c needs visibility on a few things declared in this file.
MC_MAIN_STATIC allows to define them static if ok, i.e. on
platforms that are not using hand-coded asm statements. */
/* See mc_main_asm.c */
#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \
- && (defined(VGP_x86_linux) || defined(VGP_x86_solaris))
+ && (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd))
/* See mc_main_asm.c */
#else
);
#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \
- && (defined(VGP_x86_linux) || defined(VGP_x86_solaris))
+ && (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd))
__asm__(
".text\n"
".align 16\n"