From: Paul Floyd Date: Sat, 22 Apr 2023 14:08:28 +0000 (+0200) Subject: Typo in NEWS X-Git-Tag: VALGRIND_3_21_0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf347551c99313a4af9c38bdeda9b946c9795945;p=thirdparty%2Fvalgrind.git Typo in NEWS Thanks Tobias, on valgrind-developers --- diff --git a/NEWS b/NEWS index bff5b5d760..35a9ce3cd2 100644 --- a/NEWS +++ b/NEWS @@ -37,7 +37,7 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. * The vgdb utility now supports extended-remote protocol when invoked with --multi. In this mode the GDB run command is supported. Which means you don't need to run gdb and valgrind - from different terminals. So for example to start you program + from different terminals. So for example to start your program in gdb and run it under valgrind you can do: $ gdb prog (gdb) set remote exec-file prog diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index fd4dff4da4..bde7430bf3 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -29,62 +29,57 @@ #if defined(VGO_freebsd) -#include "pub_core_basics.h" -#include "pub_core_vki.h" -#include "pub_core_vkiscnums.h" -#include "pub_core_threadstate.h" #include "pub_core_aspacemgr.h" -#include "pub_core_debuginfo.h" // VG_(di_notify_*) -#include "pub_core_transtab.h" // VG_(discard_translations) -#include "pub_core_xarray.h" +#include "pub_core_basics.h" #include "pub_core_clientstate.h" +#include "pub_core_debuginfo.h" // VG_(di_notify_*) #include "pub_core_debuglog.h" -#include "pub_core_libcbase.h" +#include "pub_core_inner.h" #include "pub_core_libcassert.h" +#include "pub_core_libcbase.h" #include "pub_core_libcfile.h" #include "pub_core_libcprint.h" #include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_machine.h" #include "pub_core_mallocfree.h" -#include "pub_core_tooliface.h" #include "pub_core_options.h" +#include "pub_core_pathscan.h" #include "pub_core_scheduler.h" #include "pub_core_signals.h" #include "pub_core_stacks.h" #include "pub_core_syscall.h" #include "pub_core_syswrap.h" -#include "pub_core_inner.h" -#include "pub_core_pathscan.h" +#include "pub_core_threadstate.h" +#include "pub_core_tooliface.h" +#include "pub_core_transtab.h" // VG_(discard_translations) +#include "pub_core_vki.h" +#include "pub_core_vkiscnums.h" +#include "pub_core_xarray.h" #if defined(ENABLE_INNER_CLIENT_REQUEST) #include "pub_core_clreq.h" #endif -#include "priv_types_n_macros.h" +#include "priv_syswrap-freebsd.h" #include "priv_syswrap-generic.h" #include "priv_syswrap-main.h" -#include "priv_syswrap-freebsd.h" +#include "priv_types_n_macros.h" static Bool capabiltyMode = False; -Bool VG_(get_capability_mode)(void) -{ - return capabiltyMode; -} - +Bool VG_(get_capability_mode)(void) { return capabiltyMode; } // Run a thread from beginning to end and return the thread's // scheduler-return-code. static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) { VgSchedReturnCode ret; - ThreadId tid = (ThreadId)tidW; - Int lwpid = VG_(gettid)(); - ThreadState* tst = VG_(get_ThreadState)(tid); + ThreadId tid = (ThreadId)tidW; + Int lwpid = VG_(gettid)(); + ThreadState* tst = VG_(get_ThreadState)(tid); VG_(debugLog)(1, "syswrap-freebsd", - "thread_wrapper(tid=%u,lwpid=%d): entry\n", - tid, lwpid); + "thread_wrapper(tid=%u,lwpid=%d): entry\n", tid, lwpid); vg_assert(tst->status == VgTs_Init); @@ -92,8 +87,7 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)"); if (0) { - VG_(printf)("thread tid %u started: stack = %p\n", - tid, (void*)&tid); + VG_(printf)("thread tid %u started: stack = %p\n", tid, (void*)&tid); } /* Make sure error reporting is enabled in the new thread. */ @@ -124,27 +118,24 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) return ret; } - /* --------------------------------------------------------------------- clone-related stuff ------------------------------------------------------------------ */ /* Run a thread all the way to the end, then do appropriate exit actions (this is the last-one-out-turn-off-the-lights bit). */ -__attribute__((noreturn)) -static void run_a_thread_NORETURN ( Word tidW ) +__attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) { ThreadId tid = (ThreadId)tidW; VgSchedReturnCode src; Int c; ThreadState* tst; #ifdef ENABLE_INNER_CLIENT_REQUEST - Int registered_vgstack_id; + Int registered_vgstack_id; #endif VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", - tid); + "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", tid); tst = VG_(get_ThreadState)(tid); vg_assert(tst); @@ -157,17 +148,15 @@ static void run_a_thread_NORETURN ( Word tidW ) When Valgrind runs as an inner, it must signals that its (real) stack is the stack to use by the outer to e.g. do stacktraces. */ - INNER_REQUEST - (registered_vgstack_id - = VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST(registered_vgstack_id = VALGRIND_STACK_REGISTER( + tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); /* Run the thread all the way through. */ src = thread_wrapper(tid); VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", - tid); + "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", tid); c = VG_(count_living_threads)(); vg_assert(c >= 1); /* stay sane */ @@ -178,7 +167,7 @@ static void run_a_thread_NORETURN ( Word tidW ) } // Tell the tool this thread is exiting - VG_TRACK( pre_thread_ll_exit, tid ); + VG_TRACK(pre_thread_ll_exit, tid); /* If the thread is exiting with errors disabled, complain loudly; doing so is bad (does the user know this has happened?) Also, @@ -187,17 +176,13 @@ static void run_a_thread_NORETURN ( Word tidW ) should be unnecessary since the flag should be cleared when the slot is reallocated, in thread_wrapper(). */ if (tst->err_disablement_level > 0) { - VG_(umsg)( - "WARNING: exiting thread has error reporting disabled.\n" - "WARNING: possibly as a result of some mistake in the use\n" - "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n" - ); - VG_(debugLog)( - 1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): " - "WARNING: exiting thread has err_disablement_level = %u\n", - tid, tst->err_disablement_level - ); + VG_(umsg)("WARNING: exiting thread has error reporting disabled.\n" + "WARNING: possibly as a result of some mistake in the use\n" + "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"); + VG_(debugLog)(1, "syswrap-freebsd", + "run_a_thread_NORETURN(tid=%u): " + "WARNING: exiting thread has err_disablement_level = %u\n", + tid, tst->err_disablement_level); } tst->err_disablement_level = 0; @@ -211,7 +196,7 @@ static void run_a_thread_NORETURN ( Word tidW ) /* We are the last one standing. Keep hold of the lock and carry on to show final tool results, then exit the entire system. Use the continuation pointer set at startup in m_main. */ - ( * VG_(address_of_m_main_shutdown_actions_NORETURN) ) (tid, src); + (*VG_(address_of_m_main_shutdown_actions_NORETURN))(tid, src); } else { VG_(debugLog)(1, "syswrap-freebsd", @@ -227,7 +212,7 @@ static void run_a_thread_NORETURN ( Word tidW ) vg_assert(sizeof(tst->status) == 4); vg_assert(sizeof(tst->os_state.exitcode) == sizeof(Word)); - INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id)); + INNER_REQUEST(VALGRIND_STACK_DEREGISTER(registered_vgstack_id)); /* We have to use this sequence to terminate the thread to prevent a subtle race. If VG_(exit_thread)() had left the @@ -237,34 +222,32 @@ static void run_a_thread_NORETURN ( Word tidW ) reallocation. We need to make sure we don't touch the stack between marking it Empty and exiting. Hence the assembler. */ -#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ - __asm__ volatile ( +#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ + __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 */ - "pushl %%ebx\n" /* arg on stack */ - "pushl %%ebx\n" /* fake return address */ - "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ - "popl %%ebx\n" /* fake return address */ - "popl %%ebx\n" /* arg off stack */ - : "=m" (tst->status) - : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) - : "eax", "ebx" - ); + "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */ + "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */ + "pushl %%ebx\n" /* arg on stack */ + "pushl %%ebx\n" /* fake return address */ + "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ + "popl %%ebx\n" /* fake return address */ + "popl %%ebx\n" /* arg off stack */ + : "=m"(tst->status) + : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(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 */ - "pushq %%rdi\n" /* fake return address */ - "syscall\n" /* thr_exit(tst->os_state.exitcode) */ - "popq %%rdi\n" /* fake return address */ - : "=m" (tst->status) - : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) - : "rax", "rdi" - ); + "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */ + "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */ + "pushq %%rdi\n" /* fake return address */ + "syscall\n" /* thr_exit(tst->os_state.exitcode) */ + "popq %%rdi\n" /* fake return address */ + : "=m"(tst->status) + : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(tst->os_state.exitcode) + : "rax", "rdi"); #else -# error Unknown platform +#error Unknown platform #endif VG_(core_panic)("Thread exit failed?\n"); @@ -274,12 +257,12 @@ static void run_a_thread_NORETURN ( Word tidW ) vg_assert(0); } -Word ML_(start_thread_NORETURN) ( void* arg ) +Word ML_(start_thread_NORETURN)(void* arg) { ThreadState* tst = (ThreadState*)arg; ThreadId tid = tst->tid; - run_a_thread_NORETURN ( (Word)tid ); + run_a_thread_NORETURN((Word)tid); /*NOTREACHED*/ vg_assert(0); } @@ -308,7 +291,7 @@ Addr ML_(allocstack)(ThreadId tid) /* If no stack is present, allocate one. */ if (tst->os_state.valgrind_stack_base == 0) { - stack = VG_(am_alloc_VgStack)( &initial_SP ); + stack = VG_(am_alloc_VgStack)(&initial_SP); if (stack) { tst->os_state.valgrind_stack_base = (Addr)stack; tst->os_state.valgrind_stack_init_SP = initial_SP; @@ -316,10 +299,9 @@ Addr ML_(allocstack)(ThreadId tid) } if (0) { - VG_(printf)( "stack for tid %u at %p; init_SP=%p\n", - tid, - (void*)tst->os_state.valgrind_stack_base, - (void*)tst->os_state.valgrind_stack_init_SP ); + VG_(printf)("stack for tid %u at %p; init_SP=%p\n", tid, + (void*)tst->os_state.valgrind_stack_base, + (void*)tst->os_state.valgrind_stack_init_SP); } return tst->os_state.valgrind_stack_init_SP; @@ -330,8 +312,7 @@ Addr ML_(allocstack)(ThreadId tid) (VG_(interim_stack)) it's better to allocate a new one, so that overflow detection works uniformly for all threads. */ -__attribute__((noreturn)) -void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) +__attribute__((noreturn)) void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) { Addr sp; VG_(debugLog)(1, "syswrap-freebsd", @@ -344,10 +325,9 @@ void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind // reports 'write error' on the non registered stack. ThreadState* tst = VG_(get_ThreadState)(tid); - INNER_REQUEST - ((void) - VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST( + (void)VALGRIND_STACK_REGISTER(tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); } #endif @@ -356,22 +336,20 @@ void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) vg_assert2(sp != 0, "%s", "Cannot allocate main thread's stack."); /* shouldn't be any other threads around yet */ - vg_assert( VG_(count_living_threads)() == 1 ); + vg_assert(VG_(count_living_threads)() == 1); - ML_(call_on_new_stack_0_1)( - (Addr)sp, /* stack */ - 0, /* bogus return address */ - run_a_thread_NORETURN, /* fn to call */ - (Word)tid /* arg to give it */ + ML_(call_on_new_stack_0_1)((Addr)sp, /* stack */ + 0, /* bogus return address */ + run_a_thread_NORETURN, /* fn to call */ + (Word)tid /* arg to give it */ ); /*NOTREACHED*/ vg_assert(0); } - /* Do a fork() */ -SysRes ML_(do_fork) ( ThreadId tid ) +SysRes ML_(do_fork)(ThreadId tid) { vki_sigset_t fork_saved_mask; vki_sigset_t mask; @@ -384,7 +362,7 @@ SysRes ML_(do_fork) ( ThreadId tid ) VG_(do_atfork_pre)(tid); - res = VG_(do_syscall0)( __NR_fork ); + res = VG_(do_syscall0)(__NR_fork); if (!sr_isError(res)) { if (sr_Res(res) == 0) { @@ -411,15 +389,15 @@ SysRes ML_(do_fork) ( ThreadId tid ) return res; } -static Addr ML_(make_safe_mask) ( const HChar* malloc_message, Addr mask_pointer ) +static Addr ML_(make_safe_mask)(const HChar* malloc_message, Addr mask_pointer) { - vki_sigset_t* new_mask; - const vki_sigset_t* old_mask = (vki_sigset_t *)mask_pointer; + vki_sigset_t* new_mask; + const vki_sigset_t* old_mask = (vki_sigset_t*)mask_pointer; if (!ML_(safe_to_deref)(old_mask, sizeof(vki_sigset_t))) { new_mask = (vki_sigset_t*)1; /* Something recognisable to POST() hook. */ } else { - new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); + new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); *new_mask = *old_mask; VG_(sanitize_client_sigmask)(new_mask); } @@ -427,14 +405,13 @@ static Addr ML_(make_safe_mask) ( const HChar* malloc_message, Addr mask_pointer return (Addr)new_mask; } -static void ML_(free_safe_mask) ( Addr mask_pointer ) +static void ML_(free_safe_mask)(Addr mask_pointer) { if (mask_pointer != 0 && mask_pointer != 1) { - VG_(free)((vki_sigset_t *) mask_pointer); + VG_(free)((vki_sigset_t*)mask_pointer); } } - /* --------------------------------------------------------------------- PRE/POST wrappers for arch-generic, FreeBSD-specific syscalls ------------------------------------------------------------------ */ @@ -442,8 +419,8 @@ static void ML_(free_safe_mask) ( Addr mask_pointer ) // Nb: See the comment above the generic PRE/POST wrappers in // m_syswrap/syswrap-generic.c for notes about how they work. -#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) -#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) +#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) +#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) /* On FreeBSD, if any thread calls exit(2), then they are all shut down, pretty * much like linux's exit_group(). @@ -452,25 +429,25 @@ static void ML_(free_safe_mask) ( Addr mask_pointer ) // void exit(int status); PRE(sys_exit) { - ThreadId t; + ThreadId t; PRINT("exit( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(void, "exit", int, status); /* Mark all threads (including this one) to exit. */ for (t = 1; t < VG_N_THREADS; t++) { - if ( /* not alive */ VG_(threads)[t].status == VgTs_Empty ) { + if (/* not alive */ VG_(threads)[t].status == VgTs_Empty) { continue; } - //VG_(threads)[t].exitreason = VgSrc_ExitThread; + // VG_(threads)[t].exitreason = VgSrc_ExitThread; VG_(threads)[t].os_state.exitcode = ARG1; // if (t != tid) // VG_(get_thread_out_of_syscall)(t); /* unblock it, if blocked */ } - VG_(nuke_all_threads_except)( tid, VgSrc_ExitProcess ); + VG_(nuke_all_threads_except)(tid, VgSrc_ExitProcess); VG_(reap_threads)(tid); VG_(threads)[tid].exitreason = VgSrc_ExitThread; @@ -485,7 +462,7 @@ PRE(sys_fork) PRINT("%s", "sys_fork ()"); PRE_REG_READ0(pid_t, "fork"); - SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); + SET_STATUS_from_SysRes(ML_(do_fork)(tid)); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -542,12 +519,13 @@ PRE(sys_mount) // We are conservative and check everything, except the memory pointed to // by 'data'. *flags |= SfMayBlock; - PRINT( "sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "mount", - const char *, type, char *, dir, int, flags, - void *, data); - PRE_MEM_RASCIIZ( "mount(type)", ARG1); - PRE_MEM_RASCIIZ( "mount(path)", ARG2); + PRINT("sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "mount", const char*, type, char*, dir, int, flags, void*, + data); + PRE_MEM_RASCIIZ("mount(type)", ARG1); + PRE_MEM_RASCIIZ("mount(path)", ARG2); } // SYS_unmount 22 @@ -555,8 +533,8 @@ PRE(sys_mount) PRE(sys_unmount) { PRINT("sys_umount( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "unmount", const char *, dir, int, flags); - PRE_MEM_RASCIIZ( "unmount(path)", ARG1); + PRE_REG_READ2(int, "unmount", const char*, dir, int, flags); + PRE_MEM_RASCIIZ("unmount(path)", ARG1); } // SYS_setuid 23 @@ -572,10 +550,13 @@ PRE(sys_unmount) // int ptrace(int request, pid_t pid, caddr_t addr, int data); PRE(sys_ptrace) { - struct vki_ptrace_io_desc *io_desc; - PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %" FMT_REGWORD "u)", ARG1, ARG2, ARG3, ARG4); + struct vki_ptrace_io_desc* io_desc; + PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD + "x, %" FMT_REGWORD "u)", + ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, data); + PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, + data); switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -587,15 +568,15 @@ PRE(sys_ptrace) case VKI_PTRACE_IO: PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_ptrace_io_desc)); - io_desc = (struct vki_ptrace_io_desc *)ARG3; + io_desc = (struct vki_ptrace_io_desc*)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: - PRE_MEM_WRITE( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_WRITE("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; case VKI_PIOD_WRITE_D: case VKI_PIOD_WRITE_I: - PRE_MEM_READ( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_READ("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; } break; @@ -639,7 +620,7 @@ PRE(sys_ptrace) break; case VKI_PTRACE_GETLWPLIST: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); break; case VKI_PTRACE_SETSTEP: @@ -652,14 +633,14 @@ PRE(sys_ptrace) case VKI_PTRACE_VM_TIMESTAMP: break; case VKI_PTRACE_VM_ENTRY: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); break; } } POST(sys_ptrace) { - struct vki_ptrace_io_desc *io_desc; + struct vki_ptrace_io_desc* io_desc; switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -670,7 +651,7 @@ POST(sys_ptrace) break; case VKI_PTRACE_IO: - io_desc = (struct vki_ptrace_io_desc *)ARG3; + io_desc = (struct vki_ptrace_io_desc*)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: @@ -756,15 +737,18 @@ POST(sys_ptrace) PRE(sys_recvmsg) { *flags |= SfMayBlock; - PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )",SARG1,ARG2,SARG3); - PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr *, msg, int, flags); - ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2); + PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "d )", + SARG1, ARG2, SARG3); + PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr*, msg, int, + flags); + ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2); } POST(sys_recvmsg) { - ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2, RES); + ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2, RES); } // SYS_sendmsg 28 @@ -772,30 +756,34 @@ POST(sys_recvmsg) PRE(sys_sendmsg) { *flags |= SfMayBlock; - PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(ssize_t, "sendmsg", - int, s, const struct msghdr *, msg, int, flags); - ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr *)ARG2); + PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(ssize_t, "sendmsg", int, s, const struct msghdr*, msg, int, + flags); + ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr*)ARG2); } // SYS_recvfrom 29 // ssize_t recvfrom(int s, void *buf, size_t len, int flags, -// struct sockaddr * restrict from, socklen_t * restrict fromlen); +// struct sockaddr * restrict from, socklen_t * restrict +// fromlen); PRE(sys_recvfrom) { *flags |= SfMayBlock; - PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3,SARG4,ARG5,ARG6); - PRE_REG_READ6(ssize_t, "recvfrom", - int, s, void *, buf, size_t, len, int, flags, - struct sockaddr *, from, int *, fromlen); - ML_(generic_PRE_sys_recvfrom)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3, SARG4, ARG5, ARG6); + PRE_REG_READ6(ssize_t, "recvfrom", int, s, void*, buf, size_t, len, int, + flags, struct sockaddr*, from, int*, fromlen); + ML_(generic_PRE_sys_recvfrom)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); } POST(sys_recvfrom) { vg_assert(SUCCESS); - ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), ARG1, ARG2, + ARG3, ARG4, ARG5, ARG6); } // SYS_accept 30 @@ -804,18 +792,19 @@ POST(sys_recvfrom) PRE(sys_accept) { *flags |= SfMayBlock; - PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "accept", - int, s, struct sockaddr *, addr, int, *addrlen); - ML_(generic_PRE_sys_accept)(tid, ARG1,ARG2,ARG3); + PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "accept", int, s, struct sockaddr*, addr, int, *addrlen); + ML_(generic_PRE_sys_accept)(tid, ARG1, ARG2, ARG3); } POST(sys_accept) { SysRes r; vg_assert(SUCCESS); - r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); SET_STATUS_from_SysRes(r); } @@ -824,17 +813,19 @@ POST(sys_accept) // socklen_t * restrict namelen); PRE(sys_getpeername) { - PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "getpeername", - int, s, struct sockaddr *, name, socklen_t *, namelen); - ML_(generic_PRE_sys_getpeername)(tid, ARG1,ARG2,ARG3); + PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "getpeername", int, s, struct sockaddr*, name, socklen_t*, + namelen); + ML_(generic_PRE_sys_getpeername)(tid, ARG1, ARG2, ARG3); } POST(sys_getpeername) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); } // SYS_getsockname 32 @@ -842,17 +833,19 @@ POST(sys_getpeername) // socklen_t * restrict namelen); PRE(sys_getsockname) { - PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3); - PRE_REG_READ3(long, "getsockname", - int, s, struct sockaddr *, name, int *, namelen); - ML_(generic_PRE_sys_getsockname)(tid, ARG1,ARG2,ARG3); + PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(long, "getsockname", int, s, struct sockaddr*, name, int*, + namelen); + ML_(generic_PRE_sys_getsockname)(tid, ARG1, ARG2, ARG3); } POST(sys_getsockname) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); } // SYS_access 33 @@ -862,17 +855,17 @@ POST(sys_getsockname) // int chflags(const char *path, unsigned long flags) PRE(sys_chflags) { - PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "chflags", - const char *, path, unsigned long, flags); - PRE_MEM_RASCIIZ( "chflags(path)", ARG1 ); + PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "chflags", const char*, path, unsigned long, flags); + PRE_MEM_RASCIIZ("chflags(path)", ARG1); } // SYS_fchflags 35 // int fchflags(int fd, unsigned long flags); PRE(sys_fchflags) { - PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2); + PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(int, "fchflags", int, fd, unsigned long, flags); } @@ -891,18 +884,15 @@ PRE(sys_fchflags) // Pipe on freebsd doesn't have args, and uses dual returns! // SYS_freebsd10_pipe 42 // int pipe(void); -PRE(sys_pipe) -{ - PRINT("%s", "sys_pipe ()"); -} +PRE(sys_pipe) { PRINT("%s", "sys_pipe ()"); } POST(sys_pipe) { if (!ML_(fd_allowed)(RES, "pipe", tid, True) || - !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { + !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { VG_(close)(RES); VG_(close)(RESHI); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); @@ -930,23 +920,20 @@ POST(sys_pipe) // so let's go with those names PRE(sys_getlogin) { - PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); - PRE_REG_READ2(int, "getlogin", char *, buf, u_int, len); - PRE_MEM_WRITE( "getlogin(name)", ARG1, ARG2 ); + PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); + PRE_REG_READ2(int, "getlogin", char*, buf, u_int, len); + PRE_MEM_WRITE("getlogin(name)", ARG1, ARG2); } -POST(sys_getlogin) -{ - POST_MEM_WRITE(ARG1, ARG2 ); -} +POST(sys_getlogin) { POST_MEM_WRITE(ARG1, ARG2); } // SYS_setlogin 50 // int setlogin(const char *name); PRE(sys_setlogin) { - PRINT("sys_setlogin ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ1(long, "setlogin", char *, buf); - PRE_MEM_RASCIIZ( "setlogin(buf)", ARG1 ); + PRINT("sys_setlogin ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(long, "setlogin", char*, buf); + PRE_MEM_RASCIIZ("setlogin(buf)", ARG1); } // SYS_acct 51 @@ -963,27 +950,31 @@ PRE(sys_ioctl) UInt size = _VKI_IOC_SIZE(ARG2); *flags |= SfMayBlock; // @todo PJF presumably the presence of ARG3 depends on ARG2 - PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "ioctl", - int, fd, unsigned long, request, unsigned long, arg); + PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "ioctl", int, fd, unsigned long, request, unsigned long, + arg); - /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */ + /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder + */ if (SimHintiS(SimHint_lax_ioctls, VG_(clo_sim_hints))) { /* - * Be very lax about ioctl handling; the only - * assumption is that the size is correct. Doesn't - * require the full buffer to be initialized when - * writing. Without this, using some device - * drivers with a large number of strange ioctl - * commands becomes very tiresome. - */ + * Be very lax about ioctl handling; the only + * assumption is that the size is correct. Doesn't + * require the full buffer to be initialized when + * writing. Without this, using some device + * drivers with a large number of strange ioctl + * commands becomes very tiresome. + */ } else if (dir == _VKI_IOC_NONE && size > 0) { static UWord unknown_ioctl[10]; - static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); + static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); if (moans > 0 && !VG_(clo_xml)) { /* Check if have not already moaned for this request. */ UInt i; - for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) { + for (i = 0; i < sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); + i++) { if (unknown_ioctl[i] == ARG2) { break; } @@ -991,20 +982,22 @@ PRE(sys_ioctl) unknown_ioctl[i] = ARG2; moans--; VG_(umsg)("Warning: noted but unhandled ioctl 0x%lx" - " with no direction hints.\n", ARG2); - VG_(umsg)(" This could cause spurious value errors to appear.\n"); + " with no direction hints.\n", + ARG2); + VG_(umsg)( + " This could cause spurious value errors to appear.\n"); VG_(umsg)(" See README_MISSING_SYSCALL_OR_IOCTL for " - "guidance on writing a proper wrapper.\n" ); + "guidance on writing a proper wrapper.\n"); return; } } } } else { if ((dir & _VKI_IOC_WRITE) && size > 0) { - PRE_MEM_READ( "ioctl(generic)", ARG3, size); + PRE_MEM_READ("ioctl(generic)", ARG3, size); } if ((dir & _VKI_IOC_READ) && size > 0) { - PRE_MEM_WRITE( "ioctl(generic)", ARG3, size); + PRE_MEM_WRITE("ioctl(generic)", ARG3, size); } } @@ -1075,8 +1068,7 @@ POST(sys_ioctl) UInt dir = _VKI_IOC_DIR(ARG2); UInt size = _VKI_IOC_SIZE(ARG2); vg_assert(SUCCESS); - if (size > 0 && (dir & _VKI_IOC_READ) - && RES == 0 && ARG3 != (Addr)NULL) { + if (size > 0 && (dir & _VKI_IOC_READ) && RES == 0 && ARG3 != (Addr)NULL) { POST_MEM_WRITE(ARG3, size); } @@ -1132,57 +1124,61 @@ PRE(sys_reboot) PRE(sys_revoke) { PRINT("sys_revoke ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); - PRE_REG_READ1(long, "revoke", const char *, path); - PRE_MEM_RASCIIZ( "revoke(path)", ARG1); + PRE_REG_READ1(long, "revoke", const char*, path); + PRE_MEM_RASCIIZ("revoke(path)", ARG1); } // SYS_symlink 57 // generic -static void do_readlink(const HChar* path, HChar *buf, SizeT bufsize, SyscallStatus* status, Bool* curproc_file) +static void do_readlink(const HChar* path, + HChar* buf, + SizeT bufsize, + SyscallStatus* status, + Bool* curproc_file) { HChar name[30]; VG_(sprintf)(name, "/proc/%d/file", VG_(getpid)()); - if (ML_(safe_to_deref)(path, 1) - && (VG_(strcmp)(path, name) == 0 - || VG_(strcmp)(path, "/proc/curproc/file") == 0)) { + if (ML_(safe_to_deref)(path, 1) && + (VG_(strcmp)(path, name) == 0 || + VG_(strcmp)(path, "/proc/curproc/file") == 0)) { vg_assert(VG_(resolved_exename)); - Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); + Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); SET_STATUS_Success(len); *curproc_file = True; } } // SYS_readlink 58 -// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsiz); +// ssize_t readlink(const char *restrict path, char *restrict buf, size_t +// bufsiz); PRE(sys_readlink) { FUSE_COMPATIBLE_MAY_BLOCK(); - Word saved = SYSNO; + Word saved = SYSNO; Bool curproc_file = False; PRINT("sys_readlink ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %llu )", ARG1, (char*)(Addr)ARG1, ARG2, (ULong)ARG3); - PRE_REG_READ3(long, "readlink", - const char *, path, char *, buf, int, bufsiz); - PRE_MEM_RASCIIZ( "readlink(path)", ARG1 ); - PRE_MEM_WRITE( "readlink(buf)", ARG2,ARG3 ); + PRE_REG_READ3(long, "readlink", const char*, path, char*, buf, int, bufsiz); + PRE_MEM_RASCIIZ("readlink(path)", ARG1); + PRE_MEM_WRITE("readlink(buf)", ARG2, ARG3); - if (VG_(have_slash_proc) == True) - { + if (VG_(have_slash_proc) == True) { /* * Handle the case where readlink is looking at /proc/curproc/file or * /proc//file */ - do_readlink((const HChar *)ARG1, (HChar *)ARG2, (SizeT)ARG3, status, &curproc_file); + do_readlink((const HChar*)ARG1, (HChar*)ARG2, (SizeT)ARG3, status, + &curproc_file); } if (!curproc_file) { /* Normal case */ - SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); + SET_STATUS_from_SysRes(VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); } if (SUCCESS && RES > 0) { - POST_MEM_WRITE( ARG2, RES ); + POST_MEM_WRITE(ARG2, RES); } } @@ -1206,7 +1202,7 @@ PRE(sys_vfork) PRE_REG_READ0(pid_t, "vfork"); /* Pretend vfork == fork. Not true, but will have to do. */ - SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); + SET_STATUS_from_SysRes(ML_(do_fork)(tid)); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -1218,7 +1214,7 @@ PRE(sys_vfork) // void * sbrk(intptr_t incr); PRE(sys_sbrk) { - PRINT("sys_sbrk ( %#" FMT_REGWORD "x )",ARG1); + PRINT("sys_sbrk ( %#" FMT_REGWORD "x )", ARG1); PRE_REG_READ1(void*, "sbrk", vki_intptr_t, incr); } @@ -1256,9 +1252,9 @@ PRE(sys_sbrk) // int swapon(const char *special); PRE(sys_swapon) { - PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1,(char*)ARG1); - PRE_REG_READ1(int, "swapon", const char*, special ); - PRE_MEM_RASCIIZ( "swapon(special)", ARG1 ); + PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "swapon", const char*, special); + PRE_MEM_RASCIIZ("swapon(special)", ARG1); } // SYS_getitimer 86 @@ -1286,7 +1282,7 @@ PRE(sys_fcntl) case VKI_F_GETOWN: case VKI_F_GET_SEALS: case VKI_F_ISUNIONSTACK: - PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2); + PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); PRE_REG_READ2(int, "fcntl", int, fd, int, cmd); break; @@ -1299,9 +1295,10 @@ PRE(sys_fcntl) case VKI_F_READAHEAD: case VKI_F_RDAHEAD: case VKI_F_ADD_SEALS: - PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2,SARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, int, arg); + PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %" FMT_REGWORD "d )", + SARG1, SARG2, SARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, int, arg); break; // These ones use ARG3 as "lock" - obsolete. @@ -1310,20 +1307,20 @@ PRE(sys_fcntl) /* FALLTHROUGH */ case VKI_F_OGETLK: case VKI_F_OSETLK: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct oflock *, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct oflock*, lock); break; // This one uses ARG3 as "oldd" and ARG4 as "newd". case VKI_F_DUP2FD: case VKI_F_DUP2FD_CLOEXEC: - PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", - ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "fcntl", - int, fd, int, cmd, - unsigned long, oldd, unsigned long, newd); + PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD + "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "fcntl", int, fd, int, cmd, unsigned long, oldd, + unsigned long, newd); break; // These ones use ARG3 as "lock". @@ -1333,24 +1330,26 @@ PRE(sys_fcntl) case VKI_F_GETLK: case VKI_F_SETLK: case VKI_F_SETLK_REMOTE: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct flock *, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct flock*, lock); break; case VKI_F_KINFO: - PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct vki_kinfo_file *, kinfo); + PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct vki_kinfo_file*, + kinfo); if (ARG3) { struct vki_kinfo_file* p_kinfo_file = (struct vki_kinfo_file*)ARG3; - PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, p_kinfo_file->vki_kf_structsize); + PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, + p_kinfo_file->vki_kf_structsize); } break; default: - PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1,ARG2,ARG3); + PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1, ARG2, ARG3); I_die_here; } } @@ -1361,7 +1360,7 @@ POST(sys_fcntl) if (ARG2 == VKI_F_DUPFD) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1370,7 +1369,7 @@ POST(sys_fcntl) } else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1392,7 +1391,9 @@ POST(sys_fcntl) // int socket(int domain, int type, int protocol); PRE(sys_socket) { - PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2,SARG3); + PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD + "d )", + SARG1, SARG2, SARG3); PRE_REG_READ3(int, "socket", int, domain, int, type, int, protocol); } @@ -1409,10 +1410,12 @@ POST(sys_socket) PRE(sys_connect) { *flags |= SfMayBlock; - PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "connect", - int, s, const struct sockaddr *, name, int, namelen); - ML_(generic_PRE_sys_connect)(tid, ARG1,ARG2,ARG3); + PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "connect", int, s, const struct sockaddr*, name, int, + namelen); + ML_(generic_PRE_sys_connect)(tid, ARG1, ARG2, ARG3); } // SYS_getpriority 100 @@ -1422,10 +1425,11 @@ PRE(sys_connect) // int bind(int s, const struct sockaddr *addr, socklen_t addrlen); PRE(sys_bind) { - PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "bind", - int, s, struct sockaddr *, addr, int, addrlen); - ML_(generic_PRE_sys_bind)(tid, ARG1,ARG2,ARG3); + PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "bind", int, s, struct sockaddr*, addr, int, addrlen); + ML_(generic_PRE_sys_bind)(tid, ARG1, ARG2, ARG3); } // SYS_setsockopt 105 @@ -1433,23 +1437,24 @@ PRE(sys_bind) // socklen_t optlen); PRE(sys_setsockopt) { - PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",SARG1,SARG2,SARG3,ARG4,ARG5); - PRE_REG_READ5(int, "setsockopt", - int, s, int, level, int, optname, - const void *, optval, vki_socklen_t, optlen); - ML_(generic_PRE_sys_setsockopt)(tid, ARG1,ARG2,ARG3,ARG4,ARG5); + PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + SARG1, SARG2, SARG3, ARG4, ARG5); + PRE_REG_READ5(int, "setsockopt", int, s, int, level, int, optname, + const void*, optval, vki_socklen_t, optlen); + ML_(generic_PRE_sys_setsockopt)(tid, ARG1, ARG2, ARG3, ARG4, ARG5); } // SYS_listen 106 // int listen(int s, int backlog); PRE(sys_listen) { - PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2); + PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); PRE_REG_READ2(int, "listen", int, s, int, backlog); } -//SYS_gettimeofday 116 -// generic +// SYS_gettimeofday 116 +// generic // SYS_getrusage 117 // generic @@ -1461,14 +1466,14 @@ PRE(sys_getsockopt) { Addr optval_p = ARG4; Addr optlen_p = ARG5; - PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(int, "getsockopt", - int, s, int, level, int, optname, - void *, optval, int, *optlen); + PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "getsockopt", int, s, int, level, int, optname, void*, + optval, int, *optlen); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_pre_check) ( tid, optval_p, optlen_p, - "getsockopt(optval)", - "getsockopt(optlen)" ); + ML_(buf_and_len_pre_check)(tid, optval_p, optlen_p, "getsockopt(optval)", + "getsockopt(optlen)"); } } @@ -1478,9 +1483,8 @@ POST(sys_getsockopt) Addr optlen_p = ARG5; vg_assert(SUCCESS); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_post_check) ( tid, VG_(mk_SysRes_Success)(RES), - optval_p, optlen_p, - "getsockopt(optlen_out)" ); + ML_(buf_and_len_post_check)(tid, VG_(mk_SysRes_Success)(RES), optval_p, + optlen_p, "getsockopt(optlen_out)"); } } @@ -1515,9 +1519,11 @@ POST(sys_getsockopt) // int mkfifo(const char *path, mode_t mode); PRE(sys_mkfifo) { - PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1, (char *)ARG1, ARG2, ARG3 ); - PRE_REG_READ2(int, "mkfifo", const char *, path, int, mode); - PRE_MEM_RASCIIZ( "mkfifo(path)", ARG1 ); + PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD + "x, 0x%" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ2(int, "mkfifo", const char*, path, int, mode); + PRE_MEM_RASCIIZ("mkfifo(path)", ARG1); } // SYS_sendto 133 @@ -1526,12 +1532,12 @@ PRE(sys_mkfifo) PRE(sys_sendto) { *flags |= SfMayBlock; - PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - PRE_REG_READ6(ssize_t, "sendto", - int, s, const void *, msg, int, len, - int, flags, - const struct sockaddr *, to, socklen_t, tolen); - ML_(generic_PRE_sys_sendto)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(ssize_t, "sendto", int, s, const void*, msg, int, len, int, + flags, const struct sockaddr*, to, socklen_t, tolen); + ML_(generic_PRE_sys_sendto)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); } // SYS_shutdown 134 @@ -1539,7 +1545,7 @@ PRE(sys_sendto) PRE(sys_shutdown) { *flags |= SfMayBlock; - PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2); + PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(int, "shutdown", int, s, int, how); } @@ -1547,17 +1553,19 @@ PRE(sys_shutdown) // int socketpair(int domain, int type, int protocol, int *sv); PRE(sys_socketpair) { - PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "socketpair", - int, domain, int, type, int, protocol, int *, sv); - ML_(generic_PRE_sys_socketpair)(tid, ARG1,ARG2,ARG3,ARG4); + PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "socketpair", int, domain, int, type, int, protocol, int*, + sv); + ML_(generic_PRE_sys_socketpair)(tid, ARG1, ARG2, ARG3, ARG4); } POST(sys_socketpair) { vg_assert(SUCCESS); - ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3,ARG4); + ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3, ARG4); } // SYS_mkdir 136 @@ -1573,9 +1581,9 @@ POST(sys_socketpair) // int adjtime(const struct timeval *delta, struct timeval *olddelta); PRE(sys_adjtime) { - PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "adjtime", - const struct vki_timeval *, delta, struct vki_timeval *, olddelta); + PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "adjtime", const struct vki_timeval*, delta, + struct vki_timeval*, olddelta); PRE_MEM_READ("adjtime(delta)", ARG1, sizeof(struct vki_timeval)); if (ARG2) { PRE_MEM_WRITE("adjtime(olddelta)", ARG1, sizeof(struct vki_timeval)); @@ -1596,31 +1604,31 @@ POST(sys_adjtime) /* int quotactl(const char *path, int cmd, int id, void *addr); */ PRE(sys_quotactl) { - PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3, ARG4); + PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); switch (ARG2) { case VKI_Q_QUOTAON: case VKI_Q_SETQUOTA: case VKI_Q_SETUSE: case VKI_Q_GETQUOTASIZE: - PRE_REG_READ4(int, "quotactl", - const char *, path, int, cmd, int, id, - void *, addr); - PRE_MEM_RASCIIZ( "quotactl(path)", ARG1 ); + PRE_REG_READ4(int, "quotactl", const char*, path, int, cmd, int, id, + void*, addr); + PRE_MEM_RASCIIZ("quotactl(path)", ARG1); break; case VKI_Q_GETQUOTA: if (VG_(tdict).track_pre_reg_read) { - \ + PRRSN; - PRA1("quotactl",const char*,path); - PRA2("quotactl",int,cmd); - PRA4("quotactl",void*,addr); + PRA1("quotactl", const char*, path); + PRA2("quotactl", int, cmd); + PRA4("quotactl", void*, addr); } break; case VKI_Q_QUOTAOFF: case VKI_Q_SYNC: - PRE_REG_READ2(int, "quotactl", - const char *, path, int, cmd); + PRE_REG_READ2(int, "quotactl", const char*, path, int, cmd); break; default: break; @@ -1642,14 +1650,11 @@ PRE(sys_lgetfh) { PRINT("sys_lgetfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "lgetfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ( "lgetfh(path)", ARG1 ); + PRE_MEM_RASCIIZ("lgetfh(path)", ARG1); PRE_MEM_WRITE("lgetfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_lgetfh) -{ - POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); -} +POST(sys_lgetfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } // SYS_getfh 161 // int getfh(const char *path, fhandle_t *fhp); @@ -1657,30 +1662,27 @@ PRE(sys_getfh) { PRINT("sys_getfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "getfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ( "getfh(path)", ARG1 ); + PRE_MEM_RASCIIZ("getfh(path)", ARG1); PRE_MEM_WRITE("getfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_getfh) -{ - POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); -} +POST(sys_getfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } #if (FREEBSD_VERS <= FREEBSD_10) // 162 // int getdomainname(char *domainname, int len); PRE(sys_freebsd4_getdomainname) { - PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); - PRE_REG_READ2(int, "getdomainname", - char *, domainname, int, len); - PRE_MEM_WRITE( "getdomainname(domainname)", ARG1, ARG2 ); + PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, ARG2); + PRE_REG_READ2(int, "getdomainname", char*, domainname, int, len); + PRE_MEM_WRITE("getdomainname(domainname)", ARG1, ARG2); } POST(sys_freebsd4_getdomainname) { if (ARG1 != 0) { - POST_MEM_WRITE( ARG1, ARG2 ); + POST_MEM_WRITE(ARG1, ARG2); } } @@ -1688,9 +1690,9 @@ POST(sys_freebsd4_getdomainname) // int setdomainname(char *domainname, int len); PRE(sys_freebsd4_setdomainname) { - PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ2(int, "setdomainname", char *, domainname, int, len); - PRE_MEM_RASCIIZ( "setdomainname(domainname)", ARG1 ); + PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ2(int, "setdomainname", char*, domainname, int, len); + PRE_MEM_RASCIIZ("setdomainname(domainname)", ARG1); } // 164 @@ -1698,14 +1700,14 @@ PRE(sys_freebsd4_setdomainname) PRE(sys_freebsd4_uname) { PRINT("sys_freebsd4_uname ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "uname", struct utsname *, name); - PRE_MEM_WRITE( "uname(name)", ARG1, sizeof(struct vki_utsname) ); + PRE_REG_READ1(int, "uname", struct utsname*, name); + PRE_MEM_WRITE("uname(name)", ARG1, sizeof(struct vki_utsname)); } POST(sys_freebsd4_uname) { if (ARG1 != 0) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_utsname) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_utsname)); } } #endif @@ -1716,13 +1718,14 @@ POST(sys_freebsd4_uname) // SYS_rtprio 166 PRE(sys_rtprio) { - PRINT( "sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3 ); - PRE_REG_READ3(int, "rtprio", - int, function, pid_t, pid, struct rtprio *, rtp); + PRINT("sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "rtprio", int, function, pid_t, pid, struct rtprio*, rtp); if (ARG1 == VKI_RTP_SET) { - PRE_MEM_READ( "rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_READ("rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); } else if (ARG1 == VKI_RTP_LOOKUP) { - PRE_MEM_WRITE( "rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_WRITE("rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); } else { /* PHK ?? */ } @@ -1731,7 +1734,7 @@ PRE(sys_rtprio) POST(sys_rtprio) { if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); + POST_MEM_WRITE(ARG3, sizeof(struct vki_rtprio)); } } @@ -1772,53 +1775,55 @@ PRE(sys_seteuid) PRE_REG_READ1(long, "seteuid", vki_uid_t, uid); } - #if (FREEBSD_VERS >= FREEBSD_12) // SYS_freebsd11_stat 188 // int stat(char *path, struct freebsd11_stat *sb); PRE(sys_freebsd11_stat) { - PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "stat", char *, path, struct freebsd11_stat *, sb); - PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); - PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2); + PRE_REG_READ2(int, "stat", char*, path, struct freebsd11_stat*, sb); + PRE_MEM_RASCIIZ("stat(path)", ARG1); + PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_stat) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } // SYS_freebsd11_fstat 189 // int fstat(int fd, struct stat *sb); PRE(sys_freebsd11_fstat) { - PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); - PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "fstat", int, fd, struct stat*, sb); + PRE_MEM_WRITE("fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_fstat) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } // SYS_freebsd11_lstat 190 // int lstat(const char * restrict path, struct stat * restrict sb); PRE(sys_freebsd11_lstat) { - PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(sb, "lstat", const char *, path, struct freebsd11_stat *, sb); - PRE_MEM_RASCIIZ( "lstat(path)", ARG1 ); - PRE_MEM_WRITE( "lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2); + PRE_REG_READ2(sb, "lstat", const char*, path, struct freebsd11_stat*, sb); + PRE_MEM_RASCIIZ("lstat(path)", ARG1); + PRE_MEM_WRITE("lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_lstat) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } } @@ -1826,43 +1831,38 @@ POST(sys_freebsd11_lstat) PRE(sys_stat) { - PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "stat", char *, path, struct stat *, sb); - PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); - PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); -} - -POST(sys_stat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "stat", char*, path, struct stat*, sb); + PRE_MEM_RASCIIZ("stat(path)", ARG1); + PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } +POST(sys_stat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } PRE(sys_fstat) { - PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); - PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); + PRE_REG_READ2(int, "fstat", int, fd, struct stat*, sb); + PRE_MEM_WRITE("fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } -POST(sys_fstat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); -} +POST(sys_fstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } PRE(sys_lstat) { - PRINT("sys_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "lstat", const char *, path, struct stat *, sb); - PRE_MEM_RASCIIZ( "lstat(path)", ARG1 ); - PRE_MEM_WRITE( "lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "lstat", const char*, path, struct stat*, sb); + PRE_MEM_RASCIIZ("lstat(path)", ARG1); + PRE_MEM_WRITE("lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_lstat) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } } @@ -1872,16 +1872,17 @@ POST(sys_lstat) // long pathconf(const char *path, int name); PRE(sys_pathconf) { - PRINT("sys_pathconf ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(long, "pathconf", char *, path, int, name); - PRE_MEM_RASCIIZ( "pathconf(path)", ARG1 ); + PRINT("sys_pathconf ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(long, "pathconf", char*, path, int, name); + PRE_MEM_RASCIIZ("pathconf(path)", ARG1); } // SYS_fpathconf 192 // long fpathconf(int fd, int name); PRE(sys_fpathconf) { - PRINT("sys_fpathconf ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2); + PRINT("sys_fpathconf ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(long, "fpathconf", int, fd, int, name); } @@ -1891,21 +1892,20 @@ PRE(sys_fpathconf) // SYS_setrlimit 195 // generic - // SYS_freebsd11_getdirentries 196 // int getdirentries(int fd, char *buf, int nbytes, long *basep); #if (FREEBSD_VERS >= FREEBSD_12) PRE(sys_freebsd11_getdirentries) { *flags |= SfMayBlock; - PRINT("sys_freebsd11_getdirentries ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3); - PRE_REG_READ4(int, "getdirentries", - int, fd, char *, buf, - int, nbytes, - long *, basep); - PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 ); + PRINT("sys_freebsd11_getdirentries ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ4(int, "getdirentries", int, fd, char*, buf, int, nbytes, long*, + basep); + PRE_MEM_WRITE("getdirentries(buf)", ARG2, ARG3); if (ARG4) { - PRE_MEM_WRITE( "getdirentries(basep)", ARG4, sizeof(long) ); + PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof(long)); } } @@ -1913,9 +1913,9 @@ POST(sys_freebsd11_getdirentries) { vg_assert(SUCCESS); if (RES > 0) { - POST_MEM_WRITE( ARG2, RES ); - if ( ARG4 != 0 ) { - POST_MEM_WRITE( ARG4, sizeof (long)); + POST_MEM_WRITE(ARG2, RES); + if (ARG4 != 0) { + POST_MEM_WRITE(ARG4, sizeof(long)); } } } @@ -1923,23 +1923,23 @@ POST(sys_freebsd11_getdirentries) PRE(sys_getdirentries) { *flags |= SfMayBlock; - PRINT("sys_getdirentries ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3); - PRE_REG_READ4(int, "getdirentries", - int, fd, char *, buf, - int, nbytes, - long *, basep); - PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 ); + PRINT("sys_getdirentries ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ4(int, "getdirentries", int, fd, char*, buf, int, nbytes, long*, + basep); + PRE_MEM_WRITE("getdirentries(buf)", ARG2, ARG3); if (ARG4) - PRE_MEM_WRITE( "getdirentries(basep)", ARG4, sizeof(long) ); + PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof(long)); } POST(sys_getdirentries) { vg_assert(SUCCESS); if (RES > 0) { - POST_MEM_WRITE( ARG2, RES ); - if ( ARG4 != 0 ) - POST_MEM_WRITE( ARG4, sizeof (long)); + POST_MEM_WRITE(ARG2, RES); + if (ARG4 != 0) + POST_MEM_WRITE(ARG4, sizeof(long)); } } #endif @@ -1947,7 +1947,6 @@ POST(sys_getdirentries) // SYS_freebsd6_mmap 197 // amd64 / x86 - // SYS___syscall 198 // special handling @@ -1962,14 +1961,15 @@ POST(sys_getdirentries) static Bool sysctl_kern_ps_strings(SizeT* out, SizeT* outlen) { - Word tmp = -1; - const struct auxv *cauxv; + Word tmp = -1; + const struct auxv* cauxv; - for (cauxv = (struct auxv*)VG_(client_auxv); cauxv->a_type != VKI_AT_NULL; cauxv++) { + for (cauxv = (struct auxv*)VG_(client_auxv); cauxv->a_type != VKI_AT_NULL; + cauxv++) { if (cauxv->a_type == VKI_AT_PS_STRINGS) { tmp = (Word)cauxv->u.a_ptr; - *out = tmp; + *out = tmp; *outlen = sizeof(size_t); return True; } @@ -1979,28 +1979,32 @@ static Bool sysctl_kern_ps_strings(SizeT* out, SizeT* outlen) static void sysctl_kern_usrstack(SizeT* out, SizeT* outlen) { - *out = VG_(get_usrstack)(); + *out = VG_(get_usrstack)(); *outlen = sizeof(ULong); } -static Bool sysctl_kern_proc_pathname(HChar *out, SizeT *len) +static Bool sysctl_kern_proc_pathname(HChar* out, SizeT* len) { - const HChar *exe_name = VG_(resolved_exename); + const HChar* exe_name = VG_(resolved_exename); if (!VG_(realpath)(exe_name, out)) { return False; } - *len = VG_(strlen)(out)+1; + *len = VG_(strlen)(out) + 1; return True; } // SYS___sysctl 202 -/* int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); */ -/* ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 */ +/* int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void + * *newp, size_t newlen); */ +/* ARG1 ARG2 ARG3 ARG4 ARG5 + * ARG6 */ PRE(sys___sysctl) { - PRINT("sys_sysctl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,SARG2,ARG3,ARG4,ARG5,ARG6 ); + PRINT("sys_sysctl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4, ARG5, ARG6); int* name = (int*)ARG1; if (ML_(safe_to_deref)(name, sizeof(int))) { @@ -2034,7 +2038,7 @@ PRE(sys___sysctl) case 8: // CTL _USER PRINT("user"); break; - case 9: //CTL_P1003_1B + case 9: // CTL_P1003_1B PRINT("p1003_b1b"); break; default: @@ -2042,7 +2046,7 @@ PRE(sys___sysctl) break; } } - if (SARG2 >= 2 && ML_(safe_to_deref)(name, 2*sizeof(int))) { + if (SARG2 >= 2 && ML_(safe_to_deref)(name, 2 * sizeof(int))) { PRINT(" mib[1]: %d\n", name[1]); } } @@ -2060,7 +2064,7 @@ PRE(sys___sysctl) * saved to file static variables in that file, so we call * VG_(get_usrstack)() to retrieve them from there. */ - if (SARG2 == 2 && ML_(safe_to_deref)(name, 2*sizeof(int))) { + if (SARG2 == 2 && ML_(safe_to_deref)(name, 2 * sizeof(int))) { if (name[0] == 1 && name[1] == 33) { // kern.usrstack sysctl_kern_usrstack((SizeT*)ARG3, (SizeT*)ARG4); @@ -2071,10 +2075,10 @@ PRE(sys___sysctl) /* * 2. kern.ps_strings */ - if (SARG2 == 2 && ML_(safe_to_deref)(name, 2*sizeof(int))) { + if (SARG2 == 2 && ML_(safe_to_deref)(name, 2 * sizeof(int))) { if (name[0] == 1 && name[1] == 32) { if (sysctl_kern_ps_strings((SizeT*)ARG3, (SizeT*)ARG4)) { - SET_STATUS_Success(0); + SET_STATUS_Success(0); } } } @@ -2082,18 +2086,18 @@ PRE(sys___sysctl) /* * 3. kern.proc.pathname */ - if (SARG2 == 4 && ML_(safe_to_deref)(name, 4*sizeof(int))) { + if (SARG2 == 4 && ML_(safe_to_deref)(name, 4 * sizeof(int))) { if (name[0] == 1 && name[1] == 14 && name[2] == 12) { vki_pid_t pid = (vki_pid_t)name[3]; if (pid == -1 || pid == VG_(getpid)()) { - sysctl_kern_proc_pathname((HChar *)ARG3, (SizeT *)ARG4); + sysctl_kern_proc_pathname((HChar*)ARG3, (SizeT*)ARG4); SET_STATUS_Success(0); } } } - PRE_REG_READ6(int, "__sysctl", int *, name, vki_u_int32_t, namelen, void *, oldp, - vki_size_t *, oldlenp, void *, newp, vki_size_t, newlen); + PRE_REG_READ6(int, "__sysctl", int*, name, vki_u_int32_t, namelen, void*, + oldp, vki_size_t*, oldlenp, void*, newp, vki_size_t, newlen); // read number of ints specified in ARG2 from mem pointed to by ARG1 PRE_MEM_READ("sysctl(name)", (Addr)ARG1, ARG2 * sizeof(int)); @@ -2123,11 +2127,11 @@ PRE(sys___sysctl) PRE_MEM_READ("sysctl(oldlenp)", (Addr)ARG4, sizeof(vki_size_t)); PRE_MEM_WRITE("sysctl(oldlenp)", (Addr)ARG4, sizeof(vki_size_t)); if (ML_(safe_to_deref)((void*)(Addr)ARG4, sizeof(vki_size_t))) { - PRE_MEM_WRITE("sysctl(oldp)", (Addr)ARG3, *(vki_size_t *)ARG4); + PRE_MEM_WRITE("sysctl(oldp)", (Addr)ARG3, *(vki_size_t*)ARG4); } else { VG_(dmsg)("Warning: Bad oldlenp address %p in sysctl\n", - (void *)(Addr)ARG4); - SET_STATUS_Failure ( VKI_EFAULT ); + (void*)(Addr)ARG4); + SET_STATUS_Failure(VKI_EFAULT); } } else { // case 1 above @@ -2141,7 +2145,7 @@ POST(sys___sysctl) if (ARG4 != (UWord)NULL) { if (ARG3 != (UWord)NULL) { POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); - POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4); + POST_MEM_WRITE((Addr)ARG3, *(vki_size_t*)ARG4); } else { POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); } @@ -2159,19 +2163,19 @@ POST(sys___sysctl) PRE(sys_undelete) { *flags |= SfMayBlock; - PRINT("sys_undelete ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1); - PRE_REG_READ1(int, "undelete", const char *, path); - PRE_MEM_RASCIIZ( "undelete(path)", ARG1 ); + PRINT("sys_undelete ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "undelete", const char*, path); + PRE_MEM_RASCIIZ("undelete(path)", ARG1); } // SYS_futimes 206 // int futimes(int fd, const struct timeval *times); PRE(sys_futimes) { - PRINT("sys_lutimes ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2); - PRE_REG_READ2(long, "futimes", int, fd, struct timeval *, times); + PRINT("sys_lutimes ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(long, "futimes", int, fd, struct timeval*, times); if (ARG2 != 0) { - PRE_MEM_READ( "futimes(times)", ARG2, sizeof(struct vki_timeval) ); + PRE_MEM_READ("futimes(times)", ARG2, sizeof(struct vki_timeval)); } } @@ -2188,42 +2192,51 @@ PRE(sys_freebsd7___semctl) switch (ARG3) { case VKI_IPC_INFO: case VKI_SEM_INFO: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "semctl", - int, semid, int, semnum, int, cmd, struct seminfo *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "semctl", int, semid, int, semnum, int, cmd, + struct seminfo*, arg); break; case VKI_IPC_STAT: case VKI_SEM_STAT: case VKI_IPC_SET: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "semctl", - int, semid, int, semnum, int, cmd, struct vki_semid_ds_old *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "semctl", int, semid, int, semnum, int, cmd, + struct vki_semid_ds_old*, arg); break; case VKI_GETALL: case VKI_SETALL: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "semctl", - int, semid, int, semnum, int, cmd, unsigned short *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "semctl", int, semid, int, semnum, int, cmd, + unsigned short*, arg); break; default: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "semctl", - int, semid, int, semnum, int, cmd); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "semctl", int, semid, int, semnum, int, cmd); break; } - ML_(generic_PRE_sys_semctl)(tid, ARG1,ARG2,ARG3,ARG4); + ML_(generic_PRE_sys_semctl)(tid, ARG1, ARG2, ARG3, ARG4); } POST(sys_freebsd7___semctl) { - ML_(generic_POST_sys_semctl)(tid, RES,ARG1,ARG2,ARG3,ARG4); + ML_(generic_POST_sys_semctl)(tid, RES, ARG1, ARG2, ARG3, ARG4); } // SYS_semget 221 // int semget(key_t key, int nsems, int flag); PRE(sys_semget) { - PRINT("sys_semget ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRINT("sys_semget ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); PRE_REG_READ3(int, "semget", vki_key_t, key, int, nsems, int, flag); } @@ -2232,28 +2245,33 @@ PRE(sys_semget) PRE(sys_semop) { *flags |= SfMayBlock; - PRINT("sys_semop ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "semop", - int, semid, struct sembuf *, array, unsigned, nops); - ML_(generic_PRE_sys_semop)(tid, ARG1,ARG2,ARG3); + PRINT("sys_semop ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "semop", int, semid, struct sembuf*, array, unsigned, + nops); + ML_(generic_PRE_sys_semop)(tid, ARG1, ARG2, ARG3); } // SYS_freebsd7_msgctl 224 // int msgctl(int msqid, int cmd, struct msqid_ds_old *buf); PRE(sys_freebsd7_msgctl) { - PRINT("sys_freebsd7_msgctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3 ); + PRINT("sys_freebsd7_msgctl ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + SARG1, SARG2, ARG3); - PRE_REG_READ3(int, "msgctl", int, msqid, int, cmd, struct msqid_ds_old *, buf); + PRE_REG_READ3(int, "msgctl", int, msqid, int, cmd, struct msqid_ds_old*, + buf); switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)", - ARG3, sizeof(struct vki_msqid_ds_old) ); + PRE_MEM_WRITE("msgctl(IPC_STAT, buf)", ARG3, + sizeof(struct vki_msqid_ds_old)); break; case VKI_IPC_SET: - PRE_MEM_READ( "msgctl(IPC_SET, buf)", - ARG3, sizeof(struct vki_msqid_ds_old) ); + PRE_MEM_READ("msgctl(IPC_SET, buf)", ARG3, + sizeof(struct vki_msqid_ds_old)); break; } } @@ -2262,7 +2280,7 @@ POST(sys_freebsd7_msgctl) { switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - POST_MEM_WRITE( ARG3, sizeof(struct vki_msqid_ds_old) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_msqid_ds_old)); break; } } @@ -2271,7 +2289,7 @@ POST(sys_freebsd7_msgctl) // int msgget(key_t key, int msgflg); PRE(sys_msgget) { - PRINT("sys_msgget ( %" FMT_REGWORD"d, %" FMT_REGWORD"d )",SARG1,SARG2); + PRINT("sys_msgget ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); PRE_REG_READ2(int, "msgget", key_t, key, int, msgflg); } @@ -2279,31 +2297,38 @@ PRE(sys_msgget) // int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg); PRE(sys_msgsnd) { - PRINT("sys_msgsnd ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,ARG2,SARG3,SARG4 ); - PRE_REG_READ4(int, "msgsnd", int, msqid, struct msgbuf *, msgp, size_t, msgsz, int, msgflg); - struct vki_msgbuf *msgp = (struct vki_msgbuf *)ARG2; - PRE_MEM_READ( "msgsnd(msgp->mtype)", (Addr)&msgp->mtype, sizeof(msgp->mtype) ); - PRE_MEM_READ( "msgsnd(msgp->mtext)", (Addr)&msgp->mtext, ARG3 ); + PRINT("sys_msgsnd ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %" FMT_REGWORD "d )", + SARG1, ARG2, SARG3, SARG4); + PRE_REG_READ4(int, "msgsnd", int, msqid, struct msgbuf*, msgp, size_t, msgsz, + int, msgflg); + struct vki_msgbuf* msgp = (struct vki_msgbuf*)ARG2; + PRE_MEM_READ("msgsnd(msgp->mtype)", (Addr)&msgp->mtype, sizeof(msgp->mtype)); + PRE_MEM_READ("msgsnd(msgp->mtext)", (Addr)&msgp->mtext, ARG3); } // SYS_msgrcv 227 -// ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg); +// ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int +// msgflg); PRE(sys_msgrcv) { *flags |= SfMayBlock; - PRINT("sys_msgrcv ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,ARG2,ARG3,SARG4,SARG5 ); - PRE_REG_READ5(ssize_t, "msgrcv", int, msqid, struct msgbuf *, msgp, size_t, msgsz, - long, msgtyp, int, msgflg); - struct vki_msgbuf *msgp = (struct vki_msgbuf *)ARG2; - PRE_MEM_WRITE( "msgrcv(msgp->mtype)", (Addr)&msgp->mtype, sizeof(msgp->mtype) ); - PRE_MEM_WRITE( "msgrcv(msgp->mtext)", (Addr)&msgp->mtext, ARG3 ); + PRINT("sys_msgrcv ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", + SARG1, ARG2, ARG3, SARG4, SARG5); + PRE_REG_READ5(ssize_t, "msgrcv", int, msqid, struct msgbuf*, msgp, size_t, + msgsz, long, msgtyp, int, msgflg); + struct vki_msgbuf* msgp = (struct vki_msgbuf*)ARG2; + PRE_MEM_WRITE("msgrcv(msgp->mtype)", (Addr)&msgp->mtype, + sizeof(msgp->mtype)); + PRE_MEM_WRITE("msgrcv(msgp->mtext)", (Addr)&msgp->mtext, ARG3); } POST(sys_msgrcv) { - struct vki_msgbuf *msgp = (struct vki_msgbuf *)ARG2; - POST_MEM_WRITE( (Addr)&msgp->mtype, sizeof(msgp->mtype) ); - POST_MEM_WRITE( (Addr)&msgp->mtext, RES ); + struct vki_msgbuf* msgp = (struct vki_msgbuf*)ARG2; + POST_MEM_WRITE((Addr)&msgp->mtype, sizeof(msgp->mtype)); + POST_MEM_WRITE((Addr)&msgp->mtext, RES); } // SYS_shmat 228 @@ -2311,37 +2336,37 @@ POST(sys_msgrcv) PRE(sys_shmat) { UWord arg2tmp; - PRINT("sys_shmat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(void *, "shmat", - int, shmid, const void *, addr, int, flag); - arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1,ARG2,ARG3); + PRINT("sys_shmat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(void*, "shmat", int, shmid, const void*, addr, int, flag); + arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1, ARG2, ARG3); if (arg2tmp == 0) { - SET_STATUS_Failure( VKI_EINVAL ); + SET_STATUS_Failure(VKI_EINVAL); } else { ARG2 = arg2tmp; } } -POST(sys_shmat) -{ - ML_(generic_POST_sys_shmat)(tid, RES,ARG1,ARG2,ARG3); -} +POST(sys_shmat) { ML_(generic_POST_sys_shmat)(tid, RES, ARG1, ARG2, ARG3); } // SYS_freebsd7_shmctl 229 // int shmctl(int shmid, int cmd, struct shmid_ds *buf); PRE(sys_freebsd7_shmctl) { - PRINT("sys_freebsd7_shmctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,SARG2,ARG3); - PRE_REG_READ3(int, "shmctl", - int, shmid, int, cmd, struct vki_shmid_ds_old *, buf); + PRINT("sys_freebsd7_shmctl ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(int, "shmctl", int, shmid, int, cmd, struct vki_shmid_ds_old*, + buf); switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - PRE_MEM_WRITE( "shmctl7(IPC_STAT, buf)", - ARG3, sizeof(struct vki_shmid_ds_old) ); + PRE_MEM_WRITE("shmctl7(IPC_STAT, buf)", ARG3, + sizeof(struct vki_shmid_ds_old)); break; case VKI_IPC_SET: - PRE_MEM_READ( "shmctl7(IPC_SET, buf)", - ARG3, sizeof(struct vki_shmid_ds_old) ); + PRE_MEM_READ("shmctl7(IPC_SET, buf)", ARG3, + sizeof(struct vki_shmid_ds_old)); break; } } @@ -2349,7 +2374,7 @@ PRE(sys_freebsd7_shmctl) POST(sys_freebsd7_shmctl) { if (ARG2 == VKI_IPC_STAT) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_shmid_ds_old) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_shmid_ds_old)); } } @@ -2357,70 +2382,68 @@ POST(sys_freebsd7_shmctl) // int shmdt(const void *addr); PRE(sys_shmdt) { - PRINT("sys_shmdt ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ1(int, "shmdt", const void *, addr); + PRINT("sys_shmdt ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(int, "shmdt", const void*, addr); if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1)) { - SET_STATUS_Failure( VKI_EINVAL ); + SET_STATUS_Failure(VKI_EINVAL); } } -POST(sys_shmdt) -{ - ML_(generic_POST_sys_shmdt)(tid, RES,ARG1); -} +POST(sys_shmdt) { ML_(generic_POST_sys_shmdt)(tid, RES, ARG1); } // SYS_shmget 231 // int shmget(key_t key, size_t size, int flag); PRE(sys_shmget) { - PRINT("sys_shmget ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRINT("sys_shmget ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); PRE_REG_READ3(int, "shmget", vki_key_t, key, vki_size_t, size, int, flag); } - // SYS_clock_gettime 232 // int clock_gettime(clockid_t clock_id, struct timespec *tp); PRE(sys_clock_gettime) { - PRINT("sys_clock_gettime( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2); - PRE_REG_READ2(int, "clock_gettime", - vki_clockid_t, clk_id, struct timespec *, tp); - PRE_MEM_WRITE( "clock_gettime(tp)", ARG2, sizeof(struct vki_timespec) ); + PRINT("sys_clock_gettime( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, + ARG2); + PRE_REG_READ2(int, "clock_gettime", vki_clockid_t, clk_id, struct timespec*, + tp); + PRE_MEM_WRITE("clock_gettime(tp)", ARG2, sizeof(struct vki_timespec)); } -POST(sys_clock_gettime) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); -} +POST(sys_clock_gettime) { POST_MEM_WRITE(ARG2, sizeof(struct vki_timespec)); } // SYS_clock_settime 233 // int clock_settime(clockid_t clock_id, const struct timespec *tp); PRE(sys_clock_settime) { - PRINT("sys_clock_settime( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2); - PRE_REG_READ2(int, "clock_settime", - vki_clockid_t, clk_id, const struct timespec *, tp); - PRE_MEM_READ( "clock_settime(tp)", ARG2, sizeof(struct vki_timespec) ); + PRINT("sys_clock_settime( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, + ARG2); + PRE_REG_READ2(int, "clock_settime", vki_clockid_t, clk_id, + const struct timespec*, tp); + PRE_MEM_READ("clock_settime(tp)", ARG2, sizeof(struct vki_timespec)); } // SYS_clock_getres 234 // int clock_getres(clockid_t clock_id, struct timespec *tp); PRE(sys_clock_getres) { - PRINT("sys_clock_getres( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2); + PRINT("sys_clock_getres( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, + ARG2); // Nb: we can't use "RES" as the param name because that's a macro // defined above! - PRE_REG_READ2(int, "clock_getres", - vki_clockid_t, clock_id, struct timespec *, tp); + PRE_REG_READ2(int, "clock_getres", vki_clockid_t, clock_id, struct timespec*, + tp); if (ARG2 != 0) { - PRE_MEM_WRITE( "clock_getres(tp)", ARG2, sizeof(struct vki_timespec) ); + PRE_MEM_WRITE("clock_getres(tp)", ARG2, sizeof(struct vki_timespec)); } } POST(sys_clock_getres) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_timespec)); } } @@ -2429,20 +2452,18 @@ POST(sys_clock_getres) // timer_t *restrict timerid); PRE(sys_timer_create) { - PRINT("sys_timer_create( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", SARG1,ARG2,ARG3); - PRE_REG_READ3(int, "timer_create", - vki_clockid_t, clockid, struct sigevent *, evp, - vki_timer_t *, timerid); + PRINT("sys_timer_create( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(int, "timer_create", vki_clockid_t, clockid, struct sigevent*, + evp, vki_timer_t*, timerid); if (ARG2 != 0) { - PRE_MEM_READ( "timer_create(evp)", ARG2, sizeof(struct vki_sigevent) ); + PRE_MEM_READ("timer_create(evp)", ARG2, sizeof(struct vki_sigevent)); } - PRE_MEM_WRITE( "timer_create(timerid)", ARG3, sizeof(vki_timer_t) ); + PRE_MEM_WRITE("timer_create(timerid)", ARG3, sizeof(vki_timer_t)); } -POST(sys_timer_create) -{ - POST_MEM_WRITE( ARG3, sizeof(vki_timer_t) ); -} +POST(sys_timer_create) { POST_MEM_WRITE(ARG3, sizeof(vki_timer_t)); } // SYS_ktimer_delete 236 // int timer_delete(timer_t timerid); @@ -2458,23 +2479,22 @@ PRE(sys_timer_delete) // struct itimerspec *restrict ovalue); PRE(sys_timer_settime) { - PRINT("sys_timer_settime( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,SARG2,ARG3,ARG4); - PRE_REG_READ4(int, "timer_settime", - vki_timer_t, timerid, int, flags, - const struct itimerspec *, value, - struct itimerspec *, ovalue); - PRE_MEM_READ( "timer_settime(value)", ARG3, - sizeof(struct vki_itimerspec) ); + PRINT("sys_timer_settime( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, SARG2, ARG3, ARG4); + PRE_REG_READ4(int, "timer_settime", vki_timer_t, timerid, int, flags, + const struct itimerspec*, value, struct itimerspec*, ovalue); + PRE_MEM_READ("timer_settime(value)", ARG3, sizeof(struct vki_itimerspec)); if (ARG4 != 0) { - PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4, - sizeof(struct vki_itimerspec) ); + PRE_MEM_WRITE("timer_settime(ovalue)", ARG4, + sizeof(struct vki_itimerspec)); } } POST(sys_timer_settime) { if (ARG4 != 0) { - POST_MEM_WRITE( ARG4, sizeof(struct vki_itimerspec) ); + POST_MEM_WRITE(ARG4, sizeof(struct vki_itimerspec)); } } @@ -2482,17 +2502,14 @@ POST(sys_timer_settime) // int timer_gettime(timer_t timerid, struct itimerspec *value); PRE(sys_timer_gettime) { - PRINT("sys_timer_gettime( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2); - PRE_REG_READ2(long, "timer_gettime", - vki_timer_t, timerid, struct itimerspec *, value); - PRE_MEM_WRITE( "timer_gettime(value)", ARG2, - sizeof(struct vki_itimerspec)); + PRINT("sys_timer_gettime( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, + ARG2); + PRE_REG_READ2(long, "timer_gettime", vki_timer_t, timerid, + struct itimerspec*, value); + PRE_MEM_WRITE("timer_gettime(value)", ARG2, sizeof(struct vki_itimerspec)); } -POST(sys_timer_gettime) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_itimerspec) ); -} +POST(sys_timer_gettime) { POST_MEM_WRITE(ARG2, sizeof(struct vki_itimerspec)); } // SYS_ktimer_getoverrun 239 // int timer_getoverrun(timer_t timerid); @@ -2522,32 +2539,29 @@ PRE(sys_timer_getoverrun) // const struct timespec *rqtp, struct timespec *rmtp); PRE(sys_clock_nanosleep) { - *flags |= SfMayBlock|SfPostOnFail; - PRINT("sys_clock_nanosleep ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + *flags |= SfMayBlock | SfPostOnFail; + PRINT("sys_clock_nanosleep ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", SARG1, SARG2, ARG3, ARG4); PRE_REG_READ4(int, "clock_nanosleep", clockid_t, clock_id, int, flags, - const struct timespec *, rqtp, struct timespec *, rmtp); + const struct timespec*, rqtp, struct timespec*, rmtp); PRE_MEM_READ("clock_nanosleep(rqtp)", ARG1, sizeof(struct vki_timespec)); if (ARG2 != 0) { - PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec) ); + PRE_MEM_WRITE("clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec)); } } POST(sys_clock_nanosleep) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_timespec)); } } // SYS_clock_getcpuclockid2 247 // x86/amd64 -POST(sys_clock_getcpuclockid2) -{ - POST_MEM_WRITE(ARG3, sizeof(vki_clockid_t)); -} - +POST(sys_clock_getcpuclockid2) { POST_MEM_WRITE(ARG3, sizeof(vki_clockid_t)); } // SYS_ntp_gettime 248 // int ntp_gettime(struct ntptimeval *); @@ -2557,18 +2571,19 @@ POST(sys_clock_getcpuclockid2) // int minherit(void *addr, size_t len, int inherit); PRE(sys_minherit) { - PRINT("sys_minherit( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "minherit", - void *, addr, vki_size_t, len, int, inherit); + PRINT("sys_minherit( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "minherit", void*, addr, vki_size_t, len, int, inherit); if (ARG2 != 0) { - PRE_MEM_WRITE( "minherit(addr)", ARG1,ARG2 ); + PRE_MEM_WRITE("minherit(addr)", ARG1, ARG2); } } POST(sys_minherit) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG1, ARG2 ); + POST_MEM_WRITE(ARG1, ARG2); } } @@ -2591,18 +2606,19 @@ PRE(sys_issetugid) PRE(sys_aio_read) { PRINT("sys_aio_read ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "aio_read", struct vki_aiocb *, iocb); + PRE_REG_READ1(int, "aio_read", struct vki_aiocb*, iocb); PRE_MEM_READ("aio_read(iocb)", ARG1, sizeof(struct vki_aiocb)); - if (ML_(safe_to_deref)((struct vki_aiocb *)ARG1, sizeof(struct vki_aiocb))) { - struct vki_aiocb *iocb = (struct vki_aiocb *)ARG1; - PRE_MEM_WRITE( "aio_read(iocb->aio_offset)", (Addr)iocb, sizeof(struct vki_aiocb)); + if (ML_(safe_to_deref)((struct vki_aiocb*)ARG1, sizeof(struct vki_aiocb))) { + struct vki_aiocb* iocb = (struct vki_aiocb*)ARG1; + PRE_MEM_WRITE("aio_read(iocb->aio_offset)", (Addr)iocb, + sizeof(struct vki_aiocb)); } } POST(sys_aio_read) { - if (ML_(safe_to_deref)((struct vki_aiocb *)ARG1, sizeof(struct vki_aiocb))) { - struct vki_aiocb *iocb = (struct vki_aiocb *)ARG1; + if (ML_(safe_to_deref)((struct vki_aiocb*)ARG1, sizeof(struct vki_aiocb))) { + struct vki_aiocb* iocb = (struct vki_aiocb*)ARG1; POST_MEM_WRITE((Addr)iocb, sizeof(struct vki_aiocb)); } } @@ -2612,19 +2628,21 @@ POST(sys_aio_read) PRE(sys_aio_write) { PRINT("sys_aio_write ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "aio_write", struct vki_aiocb *, iocb); + PRE_REG_READ1(int, "aio_write", struct vki_aiocb*, iocb); PRE_MEM_READ("aio_read(iocb)", ARG1, sizeof(struct vki_aiocb)); - if (ML_(safe_to_deref)((struct vki_aiocb *)ARG1, sizeof(struct vki_aiocb))) { - struct vki_aiocb *iocb = (struct vki_aiocb *)ARG1; - PRE_MEM_WRITE( "aio_write(iocb->aio_offset)", (Addr)iocb, sizeof(struct vki_aiocb)); + if (ML_(safe_to_deref)((struct vki_aiocb*)ARG1, sizeof(struct vki_aiocb))) { + struct vki_aiocb* iocb = (struct vki_aiocb*)ARG1; + PRE_MEM_WRITE("aio_write(iocb->aio_offset)", (Addr)iocb, + sizeof(struct vki_aiocb)); } } POST(sys_aio_write) { - if (ML_(safe_to_deref)((struct vki_aiocb *)ARG1, sizeof(struct vki_aiocb))) { - struct vki_aiocb *iocb = (struct vki_aiocb *)ARG1; - PRE_MEM_WRITE( "aio_write(iocb->aio_offset)", (Addr)iocb, sizeof(struct vki_aiocb)); + if (ML_(safe_to_deref)((struct vki_aiocb*)ARG1, sizeof(struct vki_aiocb))) { + struct vki_aiocb* iocb = (struct vki_aiocb*)ARG1; + PRE_MEM_WRITE("aio_write(iocb->aio_offset)", (Addr)iocb, + sizeof(struct vki_aiocb)); } } @@ -2633,23 +2651,26 @@ POST(sys_aio_write) // struct sigevent *sig); PRE(sys_lio_listio) { - PRINT("sys_lio_listio ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + PRINT("sys_lio_listio ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", SARG1, ARG2, SARG3, ARG4); - PRE_REG_READ4(int, "lio_listio", int, mode, struct aiocb * const *, list, int, nent, - struct sigevent *,sig); - PRE_MEM_READ("lio_listio(list)", ARG2, ARG3*sizeof(struct vki_aiocb *)); + PRE_REG_READ4(int, "lio_listio", int, mode, struct aiocb* const*, list, int, + nent, struct sigevent*, sig); + PRE_MEM_READ("lio_listio(list)", ARG2, ARG3 * sizeof(struct vki_aiocb*)); // loop check elements - if (ML_(safe_to_deref)((struct vki_aiocb **)ARG2, ARG3*sizeof(struct vki_aiocb *))) { - struct vki_aiocb** list = (struct vki_aiocb **)ARG2; + if (ML_(safe_to_deref)((struct vki_aiocb**)ARG2, + ARG3 * sizeof(struct vki_aiocb*))) { + struct vki_aiocb** list = (struct vki_aiocb**)ARG2; for (int i = 0; i < (int)ARG3; ++i) { if (list[i]) { - PRE_MEM_READ("lio_listio(list[?])", (Addr)list[i], ARG3*sizeof(struct vki_aiocb)); + PRE_MEM_READ("lio_listio(list[?])", (Addr)list[i], + ARG3 * sizeof(struct vki_aiocb)); } // @todo // figure out what gets read/written // when list[i]->aio_lio_opcode == VKI_LIO_READ and // when list[i]->aio_lio_opcode == VKI_LIO_WRITE - //if (ML_(safe_to_deref)(list[i], ARG3*sizeof(struct vki_aiocb))) { + // if (ML_(safe_to_deref)(list[i], ARG3*sizeof(struct vki_aiocb))) { //} } } @@ -2670,20 +2691,22 @@ PRE(sys_lio_listio) // int lchmod(const char *path, mode_t mode); PRE(sys_lchmod) { - PRINT("sys_lchmod ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "lchmod", const char *, path, vki_mode_t, mode); - PRE_MEM_RASCIIZ( "lchmod(path)", ARG1 ); + PRINT("sys_lchmod ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "lchmod", const char*, path, vki_mode_t, mode); + PRE_MEM_RASCIIZ("lchmod(path)", ARG1); } // SYS_lutimes 276 // int lutimes(const char *path, const struct timeval *times); PRE(sys_lutimes) { - PRINT("sys_lutimes ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "lutimes", char *, path, struct timeval *, times); - PRE_MEM_RASCIIZ( "lutimes(path)", ARG1 ); + PRINT("sys_lutimes ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "lutimes", char*, path, struct timeval*, times); + PRE_MEM_RASCIIZ("lutimes(path)", ARG1); if (ARG2 != 0) { - PRE_MEM_READ( "lutimes(times)", ARG2, sizeof(struct vki_timeval) ); + PRE_MEM_READ("lutimes(times)", ARG2, sizeof(struct vki_timeval)); } } @@ -2706,10 +2729,9 @@ PRE(sys_lutimes) // int fhopen(const fhandle_t *fhp, int flags); PRE(sys_fhopen) { - PRINT("sys_open ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); - PRE_REG_READ2(int, "fhopen", - struct fhandle_t *, fhp, int, flags); - PRE_MEM_READ( "fhopen(fhp)", ARG1, sizeof(struct vki_fhandle) ); + PRINT("sys_open ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); + PRE_REG_READ2(int, "fhopen", struct fhandle_t*, fhp, int, flags); + PRE_MEM_READ("fhopen(fhp)", ARG1, sizeof(struct vki_fhandle)); /* Otherwise handle normally */ *flags |= SfMayBlock; @@ -2720,7 +2742,7 @@ POST(sys_fhopen) vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "fhopen", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); @@ -2733,29 +2755,28 @@ POST(sys_fhopen) #if (FREEBSD_VERS >= FREEBSD_12) PRE(sys_freebsd11_fhstat) { - PRINT("sys_freebsd11_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fhstat", struct fhandle *, fhp, struct freebd11_stat *, sb); - PRE_MEM_READ( "fhstat(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, ARG2); + PRE_REG_READ2(int, "fhstat", struct fhandle*, fhp, struct freebd11_stat*, + sb); + PRE_MEM_READ("fhstat(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_fhstat) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } #else PRE(sys_fhstat) { - PRINT("sys_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fhstat", struct fhandle *, fhp, struct stat *, sb); - PRE_MEM_READ( "fhstat(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "fhstat", struct fhandle*, fhp, struct stat*, sb); + PRE_MEM_READ("fhstat(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } -POST(sys_fhstat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); -} +POST(sys_fhstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } #endif @@ -2763,7 +2784,7 @@ POST(sys_fhstat) // int modnext(int modid); PRE(sys_modnext) { - PRINT("sys_modnext ( %" FMT_REGWORD "d )",SARG1); + PRINT("sys_modnext ( %" FMT_REGWORD "d )", SARG1); PRE_REG_READ1(int, "modnext", int, modid); } @@ -2771,21 +2792,18 @@ PRE(sys_modnext) // int modstat(int modid, struct module_stat *stat); PRE(sys_modstat) { - PRINT("sys_modstat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "modstat", int, modid, struct module_stat *, buf); - PRE_MEM_WRITE( "modstat(stat)", ARG2, sizeof(struct vki_module_stat) ); + PRINT("sys_modstat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "modstat", int, modid, struct module_stat*, buf); + PRE_MEM_WRITE("modstat(stat)", ARG2, sizeof(struct vki_module_stat)); } -POST(sys_modstat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_module_stat) ); -} +POST(sys_modstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_module_stat)); } // SYS_modfnext 302 // int modfnext(int modid); PRE(sys_modfnext) { - PRINT("sys_modfnext ( %" FMT_REGWORD "d )",SARG1); + PRINT("sys_modfnext ( %" FMT_REGWORD "d )", SARG1); PRE_REG_READ1(int, "modfnext", int, modid); } @@ -2793,18 +2811,18 @@ PRE(sys_modfnext) // int modfind(const char *modname); PRE(sys_modfind) { - PRINT("sys_modfind ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ1(long, "modfind", char *, modname); - PRE_MEM_RASCIIZ( "modfind(modname)", ARG1 ); + PRINT("sys_modfind ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(long, "modfind", char*, modname); + PRE_MEM_RASCIIZ("modfind(modname)", ARG1); } // SYS_kldload 304 // int kldload(const char *file); PRE(sys_kldload) { - PRINT("sys_kldload ( %#" FMT_REGWORD "x(%s) )", ARG1, (char *)ARG1); - PRE_REG_READ1(int, "kldload", const char *, "file"); - PRE_MEM_RASCIIZ( "kldload(file)", ARG1 ); + PRINT("sys_kldload ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "kldload", const char*, "file"); + PRE_MEM_RASCIIZ("kldload(file)", ARG1); } // SYS_kldunload 305 @@ -2819,9 +2837,9 @@ PRE(sys_kldunload) // int kldfind(const char *file); PRE(sys_kldfind) { - PRINT("sys_kldfind ( %#" FMT_REGWORD "x(%s) )", ARG1, (char *)ARG1); - PRE_REG_READ1(int, "kldfind", const char *, file); - PRE_MEM_RASCIIZ( "kldfind(file)", ARG1 ); + PRINT("sys_kldfind ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "kldfind", const char*, file); + PRE_MEM_RASCIIZ("kldfind(file)", ARG1); } // SYS_kldnext 307 @@ -2841,10 +2859,7 @@ PRE(sys_kldstat) PRE_MEM_WRITE("kldstat(stat)", ARG2, sizeof(struct vki_kld_file_stat)); } -POST(sys_kldstat) -{ - POST_MEM_WRITE(ARG2, sizeof(struct vki_kld_file_stat)); -} +POST(sys_kldstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_kld_file_stat)); } // SYS_kldfirstmod 309 // int kldfirstmod(int fileid); @@ -2858,18 +2873,22 @@ PRE(sys_kldfirstmod) // int setresuid(uid_t *ruid, uid_t *euid, uid_t *suid); PRE(sys_setresuid) { - PRINT("sys_setresuid ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "setresuid", - vki_uid_t, ruid, vki_uid_t, euid, vki_uid_t, suid); + PRINT("sys_setresuid ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "setresuid", vki_uid_t, ruid, vki_uid_t, euid, vki_uid_t, + suid); } // SYS_setresgid 312 // int setresgid(gid_t rgid, gid_t egid, gid_t sgid); PRE(sys_setresgid) { - PRINT("sys_setresgid ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "setresgid", - vki_gid_t, rgid, vki_gid_t, egid, vki_gid_t, sgid); + PRINT("sys_setresgid ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "setresgid", vki_gid_t, rgid, vki_gid_t, egid, vki_gid_t, + sgid); } // SYS_aio_return 314 @@ -2877,7 +2896,7 @@ PRE(sys_setresgid) PRE(sys_aio_return) { PRINT("sys_aio_return ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(ssize_t, "aio_return", struct aiocb *, iocb); + PRE_REG_READ1(ssize_t, "aio_return", struct aiocb*, iocb); // not too clear if this is read-only, sounds like it from the man page // but it isn't const PRE_MEM_READ("aio_return(iocb)", ARG1, sizeof(struct vki_aiocb)); @@ -2889,8 +2908,9 @@ PRE(sys_aio_return) PRE(sys_aio_suspend) { PRINT("sys_aio_suspend ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ3(int, "aio_suspend", struct aiocb **, iocbs, int, nbiocb, const struct timespec*, timeout); - PRE_MEM_READ("aio_suspend(iocbs)", ARG1, ARG2*sizeof(struct vki_aiocb)); + PRE_REG_READ3(int, "aio_suspend", struct aiocb**, iocbs, int, nbiocb, + const struct timespec*, timeout); + PRE_MEM_READ("aio_suspend(iocbs)", ARG1, ARG2 * sizeof(struct vki_aiocb)); PRE_MEM_READ("aio_suspend(timeout)", ARG3, sizeof(struct vki_timespec)); } @@ -2898,8 +2918,9 @@ PRE(sys_aio_suspend) // int aio_cancel(int fildes, struct aiocb *iocb); PRE(sys_aio_cancel) { - PRINT("sys_aio_cancel ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); - PRE_REG_READ2(int, "aio_cancel", int, fildex, struct aiocb *, iocb); + PRINT("sys_aio_cancel ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "aio_cancel", int, fildex, struct aiocb*, iocb); if (ARG2) { PRE_MEM_READ("aio_cancel(iocb)", ARG2, sizeof(struct vki_aiocb)); } @@ -2910,7 +2931,7 @@ PRE(sys_aio_cancel) PRE(sys_aio_error) { PRINT("sys_aio_error ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(ssize_t, "aio_error", struct aiocb *, iocb); + PRE_REG_READ1(ssize_t, "aio_error", struct aiocb*, iocb); PRE_MEM_READ("aio_error(iocb)", ARG1, sizeof(struct vki_aiocb)); } @@ -2939,9 +2960,9 @@ PRE(sys_munlockall) // int __getcwd(char *buf, size_t buflen); PRE(sys___getcwd) { - PRINT("sys___getcwd ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2); - PRE_REG_READ2(long, "__getcwd", char *, buf, unsigned int, buflen); - PRE_MEM_WRITE( "__getcwd(buf)", ARG1, ARG2 ); + PRINT("sys___getcwd ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); + PRE_REG_READ2(long, "__getcwd", char*, buf, unsigned int, buflen); + PRE_MEM_WRITE("__getcwd(buf)", ARG1, ARG2); } POST(sys___getcwd) @@ -2951,39 +2972,41 @@ POST(sys___getcwd) // QQQ it is unclear if this is legal or not, but the // QQQ kernel just wrote it there... // QQQ Why oh why didn't phk return the length from __getcwd()? - UInt len = VG_(strlen) ( (char *)ARG1 ) + 1; - POST_MEM_WRITE( ARG1, len ); + UInt len = VG_(strlen)((char*)ARG1) + 1; + POST_MEM_WRITE(ARG1, len); } } -//SYS_sched_setparam 327 -// int sched_setparam(pid_t pid, const struct sched_param *param); +// SYS_sched_setparam 327 +// int sched_setparam(pid_t pid, const struct sched_param *param); PRE(sys_sched_setparam) { - PRINT("sched_setparam ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2 ); - PRE_REG_READ2(int, "sched_setparam", - vki_pid_t, pid, struct sched_param *, param); - PRE_MEM_READ( "sched_setparam(param)", ARG2, sizeof(struct vki_sched_param) ); + PRINT("sched_setparam ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "sched_setparam", vki_pid_t, pid, struct sched_param*, + param); + PRE_MEM_READ("sched_setparam(param)", ARG2, sizeof(struct vki_sched_param)); } POST(sys_sched_setparam) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_sched_param) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_sched_param)); } // SYS_sched_getparam 328 // int sched_getparam(pid_t pid, struct sched_param *param); PRE(sys_sched_getparam) { - PRINT("sched_getparam ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2 ); - PRE_REG_READ2(int, "sched_getparam", - vki_pid_t, pid, struct sched_param *, param); - PRE_MEM_WRITE( "sched_getparam(param)", ARG2, sizeof(struct vki_sched_param) ); + PRINT("sched_getparam ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "sched_getparam", vki_pid_t, pid, struct sched_param*, + param); + PRE_MEM_WRITE("sched_getparam(param)", ARG2, sizeof(struct vki_sched_param)); } POST(sys_sched_getparam) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_sched_param) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_sched_param)); } // SYS_sched_setscheduler 329 @@ -2991,12 +3014,14 @@ POST(sys_sched_getparam) // const struct sched_param *param); PRE(sys_sched_setscheduler) { - PRINT("sys_sched_setscheduler ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3); - PRE_REG_READ3(int, "sched_setscheduler", - vki_pid_t, pid, int, policy, struct sched_param *, param); + PRINT("sys_sched_setscheduler ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(int, "sched_setscheduler", vki_pid_t, pid, int, policy, + struct sched_param*, param); if (ARG3 != 0) { - PRE_MEM_READ("sched_setscheduler(param)", - ARG3, sizeof(struct vki_sched_param)); + PRE_MEM_READ("sched_setscheduler(param)", ARG3, + sizeof(struct vki_sched_param)); } } @@ -3037,9 +3062,12 @@ PRE(sys_sched_get_priority_min) // int sched_rr_get_interval(pid_t pid, struct timespec *interval); PRE(sys_sched_rr_get_interval) { - PRINT("sys_sched_rr_get_interval ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); - PRE_REG_READ2(int, "sched_rr_get_interval", vki_pid_t, pid, struct vki_timespec *,interval); - PRE_MEM_WRITE("sys_sched_rr_get_interval(interval)", ARG2, sizeof(struct vki_timespec)); + PRINT("sys_sched_rr_get_interval ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + SARG1, ARG2); + PRE_REG_READ2(int, "sched_rr_get_interval", vki_pid_t, pid, + struct vki_timespec*, interval); + PRE_MEM_WRITE("sys_sched_rr_get_interval(interval)", ARG2, + sizeof(struct vki_timespec)); } POST(sys_sched_rr_get_interval) @@ -3052,28 +3080,30 @@ POST(sys_sched_rr_get_interval) PRE(sys_utrace) { PRINT("sys_utrace ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "utrace", const void *, addr, vki_size_t, len); - PRE_MEM_READ( "utrace(addr)", ARG2, ARG3 ); + PRE_REG_READ2(int, "utrace", const void*, addr, vki_size_t, len); + PRE_MEM_READ("utrace(addr)", ARG2, ARG3); } // SYS_kldsym 337 // int kldsym(int fileid, int cmd, void *data); PRE(sys_kldsym) { - PRINT("sys_kldsym ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3 ); + PRINT("sys_kldsym ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3); PRE_REG_READ3(int, "kldsym", int, fileid, int, cmd, void*, data); - PRE_MEM_READ( "kldsym(data)", ARG3, sizeof(struct vki_kld_sym_lookup) ); - struct vki_kld_sym_lookup *kslp = (struct vki_kld_sym_lookup *)ARG3; + PRE_MEM_READ("kldsym(data)", ARG3, sizeof(struct vki_kld_sym_lookup)); + struct vki_kld_sym_lookup* kslp = (struct vki_kld_sym_lookup*)ARG3; if (ML_(safe_to_deref)(kslp, sizeof(struct vki_kld_sym_lookup))) { - PRE_MEM_RASCIIZ( "kldsym(data.symname)", (Addr)kslp->symname ); + PRE_MEM_RASCIIZ("kldsym(data.symname)", (Addr)kslp->symname); } } POST(sys_kldsym) { - struct vki_kld_sym_lookup *kslp = (struct vki_kld_sym_lookup *)ARG3; - POST_MEM_WRITE( (Addr)&kslp->symvalue, sizeof(kslp->symvalue) ); - POST_MEM_WRITE( (Addr)&kslp->symsize, sizeof(kslp->symsize) ); + struct vki_kld_sym_lookup* kslp = (struct vki_kld_sym_lookup*)ARG3; + POST_MEM_WRITE((Addr)&kslp->symvalue, sizeof(kslp->symvalue)); + POST_MEM_WRITE((Addr)&kslp->symsize, sizeof(kslp->symsize)); } // SYS_jail 338 @@ -3081,8 +3111,8 @@ POST(sys_kldsym) PRE(sys_jail) { PRINT("sys_jail ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "jail", struct jail *, jail); - PRE_MEM_READ( "jail(jail)", ARG1, sizeof(struct vki_jail) ); + PRE_REG_READ1(int, "jail", struct jail*, jail); + PRE_MEM_READ("jail(jail)", ARG1, sizeof(struct vki_jail)); } // SYS_nnpfs_syscall 338 @@ -3093,30 +3123,32 @@ PRE(sys_jail) // sigset_t * restrict oset); PRE(sys_sigprocmask) { - PRINT("sys_sigprocmask ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "sigprocmask", - int, how, vki_sigset_t *, set, vki_sigset_t *, oset); + PRINT("sys_sigprocmask ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "sigprocmask", int, how, vki_sigset_t*, set, + vki_sigset_t*, oset); if (ARG2 != 0) { - PRE_MEM_READ( "sigprocmask(set)", ARG2, sizeof(vki_sigset_t)); + PRE_MEM_READ("sigprocmask(set)", ARG2, sizeof(vki_sigset_t)); } if (ARG3 != 0) { - PRE_MEM_WRITE( "sigprocmask(oset)", ARG3, sizeof(vki_sigset_t)); + PRE_MEM_WRITE("sigprocmask(oset)", ARG3, sizeof(vki_sigset_t)); } - if (ARG2 != 0 && - !ML_(safe_to_deref)((void *)(Addr)ARG2, sizeof(vki_sigset_t))) { + if (ARG2 != 0 && + !ML_(safe_to_deref)((void*)(Addr)ARG2, sizeof(vki_sigset_t))) { VG_(dmsg)("Warning: Bad set handler address %p in sigprocmask\n", - (void *)(Addr)ARG2); - SET_STATUS_Failure ( VKI_EFAULT ); + (void*)(Addr)ARG2); + SET_STATUS_Failure(VKI_EFAULT); } else if (ARG3 != 0 && - !ML_(safe_to_deref)((void *)(Addr)ARG3, sizeof(vki_sigset_t))) { + !ML_(safe_to_deref)((void*)(Addr)ARG3, sizeof(vki_sigset_t))) { VG_(dmsg)("Warning: Bad oldset address %p in sigprocmask\n", - (void *)(Addr)ARG3); - SET_STATUS_Failure ( VKI_EFAULT ); + (void*)(Addr)ARG3); + SET_STATUS_Failure(VKI_EFAULT); } else { - SET_STATUS_from_SysRes(VG_(do_sys_sigprocmask)(tid, ARG1 /*how*/, - (vki_sigset_t*)(Addr)ARG2, - (vki_sigset_t*)(Addr)ARG3)); + SET_STATUS_from_SysRes( + VG_(do_sys_sigprocmask)(tid, ARG1 /*how*/, (vki_sigset_t*)(Addr)ARG2, + (vki_sigset_t*)(Addr)ARG3)); } if (SUCCESS) { @@ -3128,7 +3160,7 @@ POST(sys_sigprocmask) { vg_assert(SUCCESS); if (RES == 0 && ARG3 != 0) { - POST_MEM_WRITE( ARG3, sizeof(vki_sigset_t)); + POST_MEM_WRITE(ARG3, sizeof(vki_sigset_t)); } } @@ -3137,33 +3169,26 @@ POST(sys_sigprocmask) PRE(sys_sigsuspend) { *flags |= SfMayBlock; - PRINT("sys_sigsuspend ( %#" FMT_REGWORD "x )", ARG1 ); - PRE_REG_READ1(int, "sigsuspend", const vki_sigset_t *, sigmask); - PRE_MEM_READ( "sigsuspend(sigmask)", ARG1, sizeof(vki_sigset_t) ); + PRINT("sys_sigsuspend ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(int, "sigsuspend", const vki_sigset_t*, sigmask); + PRE_MEM_READ("sigsuspend(sigmask)", ARG1, sizeof(vki_sigset_t)); if (ARG1) { ARG1 = ML_(make_safe_mask)("syswrap.sigsuspend.1", (Addr)ARG1); } } -POST(sys_sigsuspend) -{ - ML_(free_safe_mask) ( (Addr)ARG1 ); -} +POST(sys_sigsuspend) { ML_(free_safe_mask)((Addr)ARG1); } // SYS_sigpending 343 // int sigpending(sigset_t *set); PRE(sys_sigpending) { - PRINT( "sys_sigpending ( %#" FMT_REGWORD "x )", ARG1 ); - PRE_REG_READ1(int, "sigpending", vki_sigset_t *, set); - PRE_MEM_WRITE( "sigpending(set)", ARG1, sizeof(vki_sigset_t)); -} - -POST(sys_sigpending) -{ - POST_MEM_WRITE( ARG1, sizeof(vki_sigset_t) ) ; + PRINT("sys_sigpending ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(int, "sigpending", vki_sigset_t*, set); + PRE_MEM_WRITE("sigpending(set)", ARG1, sizeof(vki_sigset_t)); } +POST(sys_sigpending) { POST_MEM_WRITE(ARG1, sizeof(vki_sigset_t)); } // SYS_sigtimedwait 345 // int sigtimedwait(const sigset_t *restrict set, siginfo_t *restrict info, @@ -3171,27 +3196,26 @@ POST(sys_sigpending) PRE(sys_sigtimedwait) { *flags |= SfMayBlock; - PRINT("sys_sigtimedwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "sigtimedwait", - const vki_sigset_t *, set, vki_siginfo_t *, info, - const struct timespec *, timeout); + PRINT("sys_sigtimedwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "sigtimedwait", const vki_sigset_t*, set, vki_siginfo_t*, + info, const struct timespec*, timeout); if (ARG1 != 0) { - PRE_MEM_READ( "sigtimedwait(set)", ARG1, sizeof(vki_sigset_t)); + PRE_MEM_READ("sigtimedwait(set)", ARG1, sizeof(vki_sigset_t)); } if (ARG2 != 0) { - PRE_MEM_WRITE( "sigtimedwait(info)", ARG2, sizeof(vki_siginfo_t) ); + PRE_MEM_WRITE("sigtimedwait(info)", ARG2, sizeof(vki_siginfo_t)); } if (ARG3 != 0) { - PRE_MEM_READ( "sigtimedwait(timeout)", - ARG3, sizeof(struct vki_timespec) ); + PRE_MEM_READ("sigtimedwait(timeout)", ARG3, sizeof(struct vki_timespec)); } } POST(sys_sigtimedwait) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) ); + POST_MEM_WRITE(ARG2, sizeof(vki_siginfo_t)); } } @@ -3200,22 +3224,22 @@ POST(sys_sigtimedwait) PRE(sys_sigwaitinfo) { *flags |= SfMayBlock; - PRINT("sys_sigwaitinfo ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - ARG1,ARG2); - PRE_REG_READ2(int, "sigwaitinfo", - const vki_sigset_t *, set, vki_siginfo_t *, info); + PRINT("sys_sigwaitinfo ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, + ARG2); + PRE_REG_READ2(int, "sigwaitinfo", const vki_sigset_t*, set, vki_siginfo_t*, + info); if (ARG1 != 0) { - PRE_MEM_READ( "sigwaitinfo(set)", ARG1, sizeof(vki_sigset_t)); + PRE_MEM_READ("sigwaitinfo(set)", ARG1, sizeof(vki_sigset_t)); } if (ARG2 != 0) { - PRE_MEM_WRITE( "sigwaitinfo(info)", ARG2, sizeof(vki_siginfo_t) ); + PRE_MEM_WRITE("sigwaitinfo(info)", ARG2, sizeof(vki_siginfo_t)); } } POST(sys_sigwaitinfo) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) ); + POST_MEM_WRITE(ARG2, sizeof(vki_siginfo_t)); } } @@ -3223,18 +3247,20 @@ POST(sys_sigwaitinfo) // int __acl_get_file(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_get_file) { - PRINT("sys___acl_get_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_get_file", - const char *, path, int, type, struct vki_acl *, aclp); + PRINT("sys___acl_get_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_get_file", const char*, path, int, type, + struct vki_acl*, aclp); PRE_MEM_RASCIIZ("acl_get_file(path", ARG1); - PRE_MEM_WRITE( "acl_get_file(aclp)", ARG3, sizeof(struct vki_acl) ); + PRE_MEM_WRITE("acl_get_file(aclp)", ARG3, sizeof(struct vki_acl)); } POST(sys___acl_get_file) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_acl) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_acl)); } } @@ -3242,28 +3268,31 @@ POST(sys___acl_get_file) // int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_set_file) { - PRINT("sys___acl_set_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_set_file", - const char *, path, int, type, struct vki_acl *, aclp); + PRINT("sys___acl_set_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_set_file", const char*, path, int, type, + struct vki_acl*, aclp); PRE_MEM_RASCIIZ("acl_set_file(path", ARG1); - PRE_MEM_READ("acl_set_file(aclp)", ARG3, sizeof(struct vki_acl) ); + PRE_MEM_READ("acl_set_file(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS___acl_get_fd 349 // int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp); PRE(sys___acl_get_fd) { - PRINT("sys___acl_get_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_get_fd", - int, fd, int, type, struct vki_acl *, aclp); - PRE_MEM_WRITE( "acl_get_file(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_get_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_get_fd", int, fd, int, type, struct vki_acl*, aclp); + PRE_MEM_WRITE("acl_get_file(aclp)", ARG3, sizeof(struct vki_acl)); } POST(sys___acl_get_fd) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_acl) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_acl)); } } @@ -3271,59 +3300,69 @@ POST(sys___acl_get_fd) // int __acl_set_fd(int filedes, acl_type_t type, struct acl *aclp); PRE(sys___acl_set_fd) { - PRINT("sys___acl_set_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_set_fd", - int, filedes, int, type, struct vki_acl *, aclp); - PRE_MEM_READ( "acl_get_file(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_set_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_set_fd", int, filedes, int, type, struct vki_acl*, + aclp); + PRE_MEM_READ("acl_get_file(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS___acl_delete_file 351 // int __acl_delete_file(const char *path, acl_type_t type); PRE(sys___acl_delete_file) { - PRINT("sys___acl_delete_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1,ARG2); + PRINT("sys___acl_delete_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", + ARG1, (char*)ARG1, ARG2); PRE_MEM_RASCIIZ("acl_set_file(path", ARG1); - PRE_REG_READ2(int, "acl_delete_file", - const char *, path, int, type); + PRE_REG_READ2(int, "acl_delete_file", const char*, path, int, type); } // SYS___acl_delete_fd 352 // int __acl_delete_fd(int filedes, acl_type_t type); PRE(sys___acl_delete_fd) { - PRINT("sys___acl_delete_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2); - PRE_REG_READ2(int, "acl_delete_fd", - int, filedes, int, acltype); + PRINT("sys___acl_delete_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, + ARG2); + PRE_REG_READ2(int, "acl_delete_fd", int, filedes, int, acltype); } // SYS___acl_aclcheck_file 353 // int __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_aclcheck_file) { - PRINT("sys___acl_aclcheck_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_aclcheck_file", - const char *, path, int, type, struct vki_acl *, aclp); + PRINT("sys___acl_aclcheck_file ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_aclcheck_file", const char*, path, int, type, + struct vki_acl*, aclp); PRE_MEM_RASCIIZ("acl_set_file(path", ARG1); - PRE_MEM_READ( "acl_aclcheck_file(aclp)", ARG3, sizeof(struct vki_acl) ); + PRE_MEM_READ("acl_aclcheck_file(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS___acl_aclcheck_fd 354 // int __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp); PRE(sys___acl_aclcheck_fd) { - PRINT("sys___acl_aclcheck_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "acl_aclcheck_fd", - int, fd, int, type, struct vki_acl *, aclp); - PRE_MEM_READ( "acl_aclcheck_fd(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_aclcheck_fd ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "acl_aclcheck_fd", int, fd, int, type, struct vki_acl*, + aclp); + PRE_MEM_READ("acl_aclcheck_fd(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS_extattrctl 355 // no manpage? -// syscalls.master: int extattrctl(_In_z_ const char *path, int cmd, _In_z_opt_ const char *filename, int attrnamespace, _In_z_ const char *attrname); +// syscalls.master: int extattrctl(_In_z_ const char *path, int cmd, _In_z_opt_ +// const char *filename, int attrnamespace, _In_z_ const char *attrname); PRE(sys_extattrctl) { - PRINT("sys_extattrctl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", ARG1,SARG2,ARG3,SARG4,ARG5); - PRE_REG_READ5(ssize_t, "extattrctl", - const char *, path, int, cmd, const char *, filename, int, attrnamespace, const char *, attrname); + PRINT("sys_extattrctl ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + ARG1, SARG2, ARG3, SARG4, ARG5); + PRE_REG_READ5(ssize_t, "extattrctl", const char*, path, int, cmd, + const char*, filename, int, attrnamespace, const char*, + attrname); PRE_MEM_RASCIIZ("extattrctl(path)", ARG1); PRE_MEM_RASCIIZ("extattrctl(filename)", ARG3); PRE_MEM_RASCIIZ("extattrctl(attrname)", ARG5); @@ -3331,12 +3370,16 @@ PRE(sys_extattrctl) // SYS_extattr_set_file 356 // ssize_t extattr_set_file(const char *path, int attrnamespace, -// const char *attrname, const void *data, size_t nbytes); +// const char *attrname, const void *data, size_t +// nbytes); PRE(sys_extattr_set_file) { - PRINT("sys_extattr_set_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(ssize_t, "extattr_set_file", - const char *, path, int, attrnamespace, const char *, attrname, const void *, data, size_t, nbytes); + PRINT("sys_extattr_set_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(ssize_t, "extattr_set_file", const char*, path, int, + attrnamespace, const char*, attrname, const void*, data, + size_t, nbytes); PRE_MEM_RASCIIZ("extattr_set_file(path)", ARG1); PRE_MEM_RASCIIZ("extattr_set_file(attrname)", ARG3); PRE_MEM_READ("extattr_set_file(data)", ARG4, ARG5); @@ -3347,9 +3390,12 @@ PRE(sys_extattr_set_file) // const char *attrname, void *data, size_t nbytes); PRE(sys_extattr_get_file) { - PRINT("sys_extattr_get_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(ssize_t, "extattr_get_file", - const char *, path, int, attrnamespace, const char *, attrname, void *, data, size_t, nbytes); + PRINT("sys_extattr_get_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(ssize_t, "extattr_get_file", const char*, path, int, + attrnamespace, const char*, attrname, void*, data, size_t, + nbytes); PRE_MEM_RASCIIZ("extattr_get_file(path)", ARG1); PRE_MEM_RASCIIZ("extattr_get_file(attrname)", ARG3); if (ARG4) { @@ -3369,9 +3415,11 @@ POST(sys_extattr_get_file) // const char *attrname); PRE(sys_extattr_delete_file) { - PRINT("sys_extattr_delete_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", ARG1,SARG2,ARG3); - PRE_REG_READ3(ssize_t, "extattr_delete_file", - const char *, path, int, attrnamespace, const char *, attrname); + PRINT("sys_extattr_delete_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + ARG1, SARG2, ARG3); + PRE_REG_READ3(ssize_t, "extattr_delete_file", const char*, path, int, + attrnamespace, const char*, attrname); PRE_MEM_RASCIIZ("extattr_delete_file(path)", ARG1); PRE_MEM_RASCIIZ("extattr_delete_file(attrname)", ARG3); } @@ -3381,38 +3429,40 @@ PRE(sys_extattr_delete_file) PRE(sys_aio_waitcomplete) { *flags |= SfMayBlock; - PRINT("sys_aio_waitcomplete ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2); - PRE_REG_READ2(ssize_t, "aio_waitcomplete", struct aiocb **, iocbp, struct timespec *, timeout); + PRINT("sys_aio_waitcomplete ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, ARG2); + PRE_REG_READ2(ssize_t, "aio_waitcomplete", struct aiocb**, iocbp, + struct timespec*, timeout); if (ARG2) { - PRE_MEM_READ("aio_waitcomplete(timeout", ARG2, sizeof(struct vki_timespec)); + PRE_MEM_READ("aio_waitcomplete(timeout", ARG2, + sizeof(struct vki_timespec)); } - PRE_MEM_WRITE( "aio_waitcomplete(iocbp)", ARG1, sizeof(struct aiocb *)); + PRE_MEM_WRITE("aio_waitcomplete(iocbp)", ARG1, sizeof(struct aiocb*)); } -POST(sys_aio_waitcomplete) -{ - POST_MEM_WRITE(ARG1, sizeof(struct aiocb *)); -} +POST(sys_aio_waitcomplete) { POST_MEM_WRITE(ARG1, sizeof(struct aiocb*)); } // SYS_getresuid 360 // int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); PRE(sys_getresuid) { - PRINT("sys_getresuid ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "getresuid", - vki_uid_t *, ruid, vki_uid_t *, euid, vki_uid_t *, suid); - PRE_MEM_WRITE( "getresuid(ruid)", ARG1, sizeof(vki_uid_t) ); - PRE_MEM_WRITE( "getresuid(euid)", ARG2, sizeof(vki_uid_t) ); - PRE_MEM_WRITE( "getresuid(suid)", ARG3, sizeof(vki_uid_t) ); + PRINT("sys_getresuid ( %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "getresuid", vki_uid_t*, ruid, vki_uid_t*, euid, + vki_uid_t*, suid); + PRE_MEM_WRITE("getresuid(ruid)", ARG1, sizeof(vki_uid_t)); + PRE_MEM_WRITE("getresuid(euid)", ARG2, sizeof(vki_uid_t)); + PRE_MEM_WRITE("getresuid(suid)", ARG3, sizeof(vki_uid_t)); } POST(sys_getresuid) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG1, sizeof(vki_uid_t) ); - POST_MEM_WRITE( ARG2, sizeof(vki_uid_t) ); - POST_MEM_WRITE( ARG3, sizeof(vki_uid_t) ); + POST_MEM_WRITE(ARG1, sizeof(vki_uid_t)); + POST_MEM_WRITE(ARG2, sizeof(vki_uid_t)); + POST_MEM_WRITE(ARG3, sizeof(vki_uid_t)); } } @@ -3420,21 +3470,23 @@ POST(sys_getresuid) // int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); PRE(sys_getresgid) { - PRINT("sys_getresgid ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "getresgid", - vki_gid_t *, rgid, vki_gid_t *, egid, vki_gid_t *, sgid); - PRE_MEM_WRITE( "getresgid(rgid)", ARG1, sizeof(vki_gid_t) ); - PRE_MEM_WRITE( "getresgid(egid)", ARG2, sizeof(vki_gid_t) ); - PRE_MEM_WRITE( "getresgid(sgid)", ARG3, sizeof(vki_gid_t) ); + PRINT("sys_getresgid ( %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "getresgid", vki_gid_t*, rgid, vki_gid_t*, egid, + vki_gid_t*, sgid); + PRE_MEM_WRITE("getresgid(rgid)", ARG1, sizeof(vki_gid_t)); + PRE_MEM_WRITE("getresgid(egid)", ARG2, sizeof(vki_gid_t)); + PRE_MEM_WRITE("getresgid(sgid)", ARG3, sizeof(vki_gid_t)); } POST(sys_getresgid) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG1, sizeof(vki_gid_t) ); - POST_MEM_WRITE( ARG2, sizeof(vki_gid_t) ); - POST_MEM_WRITE( ARG3, sizeof(vki_gid_t) ); + POST_MEM_WRITE(ARG1, sizeof(vki_gid_t)); + POST_MEM_WRITE(ARG2, sizeof(vki_gid_t)); + POST_MEM_WRITE(ARG3, sizeof(vki_gid_t)); } } @@ -3450,7 +3502,7 @@ POST(sys_kqueue) { if (!ML_(fd_allowed)(RES, "kqueue", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); @@ -3465,23 +3517,26 @@ POST(sys_kqueue) #if (FREEBSD_VERS >= FREEBSD_12) PRE(sys_freebsd11_kevent) { - PRINT("sys_freebsd11_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - PRE_REG_READ6(int, "kevent", - int, fd, const struct vki_kevent_freebsd11 *, changelist, int, nchanges, - struct vki_kevent_freebsd11 *, eventlist, int, nevents, - struct timespec *, timeout); + PRINT("sys_freebsd11_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )\n", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(int, "kevent", int, fd, const struct vki_kevent_freebsd11*, + changelist, int, nchanges, struct vki_kevent_freebsd11*, + eventlist, int, nevents, struct timespec*, timeout); if (ARG2 != 0 && ARG3 != 0) { - PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent_freebsd11)*ARG3 ); + PRE_MEM_READ("kevent(changelist)", ARG2, + sizeof(struct vki_kevent_freebsd11) * ARG3); } if (ARG4 != 0 && ARG5 != 0) { - PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent_freebsd11)*ARG5); + PRE_MEM_WRITE("kevent(eventlist)", ARG4, + sizeof(struct vki_kevent_freebsd11) * ARG5); } if (ARG5 != 0) { *flags |= SfMayBlock; } if (ARG6 != 0) { - PRE_MEM_READ( "kevent(timeout)", - ARG6, sizeof(struct vki_timespec)); + PRE_MEM_READ("kevent(timeout)", ARG6, sizeof(struct vki_timespec)); } } @@ -3490,7 +3545,7 @@ POST(sys_freebsd11_kevent) vg_assert(SUCCESS); if ((Word)RES != -1) { if (ARG4 != 0) { - POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent_freebsd11)*RES) ; + POST_MEM_WRITE(ARG4, sizeof(struct vki_kevent_freebsd11) * RES); } } } @@ -3498,18 +3553,20 @@ POST(sys_freebsd11_kevent) PRE(sys_kevent) { *flags |= SfMayBlock; - PRINT("sys_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - PRE_REG_READ6(int, "kevent", - int, fd, struct vki_kevent_freebsd11 *, changelist, int, nchanges, - struct vki_kevent_freebsd11 *, eventlist, int, nevents, - struct timespec *, timeout); + PRINT("sys_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(int, "kevent", int, fd, struct vki_kevent_freebsd11*, + changelist, int, nchanges, struct vki_kevent_freebsd11*, + eventlist, int, nevents, struct timespec*, timeout); if (ARG2 != 0 && ARG3 != 0) - PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent_freebsd11)*ARG3 ); + PRE_MEM_READ("kevent(changelist)", ARG2, + sizeof(struct vki_kevent_freebsd11) * ARG3); if (ARG4 != 0 && ARG5 != 0) - PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent_freebsd11)*ARG5); + PRE_MEM_WRITE("kevent(eventlist)", ARG4, + sizeof(struct vki_kevent_freebsd11) * ARG5); if (ARG6 != 0) - PRE_MEM_READ( "kevent(timeout)", - ARG6, sizeof(struct vki_timespec)); + PRE_MEM_READ("kevent(timeout)", ARG6, sizeof(struct vki_timespec)); } POST(sys_kevent) @@ -3517,7 +3574,7 @@ POST(sys_kevent) vg_assert(SUCCESS); if ((Word)RES != -1) { if (ARG4 != 0) - POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent_freebsd11)*RES) ; + POST_MEM_WRITE(ARG4, sizeof(struct vki_kevent_freebsd11) * RES); } } #endif @@ -3527,9 +3584,12 @@ POST(sys_kevent) // const void *data, size_t nbytes); PRE(sys_extattr_set_fd) { - PRINT("sys_extattr_set_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", SARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(int, "extattr_set_fd", int, fd, int, attrnamespace, const char *,attrname, const void *,data, size_t, nbytes); - PRE_MEM_RASCIIZ( "extattr_set_fd(attrname)", ARG3 ); + PRINT("sys_extattr_set_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + SARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "extattr_set_fd", int, fd, int, attrnamespace, + const char*, attrname, const void*, data, size_t, nbytes); + PRE_MEM_RASCIIZ("extattr_set_fd(attrname)", ARG3); PRE_MEM_READ("extattr_set_fd(data)", ARG4, ARG5); } @@ -3538,24 +3598,27 @@ PRE(sys_extattr_set_fd) // void *data, size_t nbytes); PRE(sys_extattr_get_fd) { - PRINT("sys_extattr_get_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", SARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(int, "extattr_get_fd", int, fd, int, attrnamespace, const char *,attrname, const void *,data, size_t, nbytes); - PRE_MEM_RASCIIZ( "extattr_get_fd(attrname)", ARG3 ); + PRINT("sys_extattr_get_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + SARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "extattr_get_fd", int, fd, int, attrnamespace, + const char*, attrname, const void*, data, size_t, nbytes); + PRE_MEM_RASCIIZ("extattr_get_fd(attrname)", ARG3); PRE_MEM_WRITE("extattr_get_fd(data)", ARG4, ARG5); } -POST(sys_extattr_get_fd) -{ - POST_MEM_WRITE(ARG4, ARG5); -} +POST(sys_extattr_get_fd) { POST_MEM_WRITE(ARG4, ARG5); } // SYS_extattr_delete_fd 373 // int extattr_delete_fd(int fd, int attrnamespace, const char *attrname); PRE(sys_extattr_delete_fd) { - PRINT("sys_extattr_delete_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3); - PRE_REG_READ3(int, "extattr_delete_fd", int, fd, int, attrnamespace, const char *,attrname); - PRE_MEM_RASCIIZ( "extattr_delete_fd(attrname)", ARG3 ); + PRINT("sys_extattr_delete_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(int, "extattr_delete_fd", int, fd, int, attrnamespace, + const char*, attrname); + PRE_MEM_RASCIIZ("extattr_delete_fd(attrname)", ARG3); } // SYS___setugid 374 @@ -3571,9 +3634,10 @@ PRE(sys___setugid) // int eaccess(const char *path, int mode); PRE(sys_eaccess) { - PRINT("sys_eaccess ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char*)ARG1,ARG2); - PRE_REG_READ2(int, "eaccess", const char *, path, int, mode); - PRE_MEM_RASCIIZ( "eaccess(path)", ARG1 ); + PRINT("sys_eaccess ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "eaccess", const char*, path, int, mode); + PRE_MEM_RASCIIZ("eaccess(path)", ARG1); } // SYS_afs3_syscall 377 @@ -3583,9 +3647,11 @@ PRE(sys_eaccess) // int nmount(struct iovec *iov, u_int niov, int flags); PRE(sys_nmount) { - PRINT("sys_nmount ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d )", ARG1, ARG2, SARG3); - PRE_REG_READ3(int, "nmount", struct iovec *, iov, u_int, niov, int, flags); - PRE_MEM_READ( "nmount(pathname)", ARG1, ARG2*sizeof(struct vki_iovec) ); + PRINT("sys_nmount ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "d )", + ARG1, ARG2, SARG3); + PRE_REG_READ3(int, "nmount", struct iovec*, iov, u_int, niov, int, flags); + PRE_MEM_READ("nmount(pathname)", ARG1, ARG2 * sizeof(struct vki_iovec)); } // SYS___mac_get_proc 384 @@ -3610,9 +3676,11 @@ PRE(sys_nmount) // int kenv(int action, const char *name, char *value, int len); PRE(sys_kenv) { - PRINT("sys_kenv ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "kenv", - int, action, const char *, name, char *, value, int, len); + PRINT("sys_kenv ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "kenv", int, action, const char*, name, char*, value, int, + len); switch (ARG1) { case VKI_KENV_GET: case VKI_KENV_SET: @@ -3646,26 +3714,25 @@ POST(sys_kenv) // int lchflags(const char *path, unsigned long flags); PRE(sys_lchflags) { - PRINT("sys_lchflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "lchflags", - const char *, path, unsigned long, flags); - PRE_MEM_RASCIIZ( "lchflags(path)", ARG1 ); + PRINT("sys_lchflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "lchflags", const char*, path, unsigned long, flags); + PRE_MEM_RASCIIZ("lchflags(path)", ARG1); } // SYS_uuidgen 392 // int uuidgen(struct uuid *store, int count); PRE(sys_uuidgen) { - PRINT("sys_uuidgen ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2); - PRE_REG_READ2(int, "uuidgen", - struct vki_uuid *, store, int, count); - PRE_MEM_WRITE( "uuidgen(store)", ARG1, ARG2 * sizeof(struct vki_uuid)); + PRINT("sys_uuidgen ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); + PRE_REG_READ2(int, "uuidgen", struct vki_uuid*, store, int, count); + PRE_MEM_WRITE("uuidgen(store)", ARG1, ARG2 * sizeof(struct vki_uuid)); } POST(sys_uuidgen) { if (SUCCESS) { - POST_MEM_WRITE( ARG1, ARG2 * sizeof(struct vki_uuid) ); + POST_MEM_WRITE(ARG1, ARG2 * sizeof(struct vki_uuid)); } } @@ -3682,16 +3749,19 @@ POST(sys_uuidgen) PRE(sys_freebsd11_getfsstat) { - PRINT("sys_freebsd11_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs *, buf, long, bufsize, int, mode); - PRE_MEM_WRITE( "getfsstat(buf)", ARG1, ARG2 ); + PRINT("sys_freebsd11_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs*, buf, long, + bufsize, int, mode); + PRE_MEM_WRITE("getfsstat(buf)", ARG1, ARG2); } POST(sys_freebsd11_getfsstat) { vg_assert(SUCCESS); if ((Word)RES != -1) { - POST_MEM_WRITE( ARG1, RES * sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG1, RES * sizeof(struct vki_freebsd11_statfs)); } } @@ -3699,107 +3769,100 @@ POST(sys_freebsd11_getfsstat) // int statfs(const char *path, struct statfs *buf); PRE(sys_freebsd11_statfs) { - PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "statfs", const char *, path, struct statfs *, buf); - PRE_MEM_RASCIIZ( "statfs(path)", ARG1 ); - PRE_MEM_WRITE( "statfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "statfs", const char*, path, struct statfs*, buf); + PRE_MEM_RASCIIZ("statfs(path)", ARG1); + PRE_MEM_WRITE("statfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } POST(sys_freebsd11_statfs) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } // SYS_freebsd11_fstatfs 397 // int fstatfs(int fd, struct statfs *buf); PRE(sys_freebsd11_fstatfs) { - PRINT("sys_fstatfs ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fstatfs", - unsigned int, fd, struct statfs *, buf); - PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_fstatfs ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "fstatfs", unsigned int, fd, struct statfs*, buf); + PRE_MEM_WRITE("fstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } POST(sys_freebsd11_fstatfs) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } // SYS_freebsd11_fhstatfs 398 // int fhstatfs(const fhandle_t *fhp, struct statfs *buf); PRE(sys_freebsd11_fhstatfs) { - PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fhstatfs", - struct fhandle *, fhp, struct statfs *, buf); - PRE_MEM_READ( "fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "fhstatfs", struct fhandle*, fhp, struct statfs*, buf); + PRE_MEM_READ("fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } POST(sys_freebsd11_fhstatfs) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } - #else PRE(sys_getfsstat) { - PRINT("sys_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs *, buf, long, bufsize, int, mode); - PRE_MEM_WRITE( "getfsstat(buf)", ARG1, ARG2 ); + PRINT("sys_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs*, buf, long, + bufsize, int, mode); + PRE_MEM_WRITE("getfsstat(buf)", ARG1, ARG2); } POST(sys_getfsstat) { vg_assert(SUCCESS); if ((Word)RES != -1) { - POST_MEM_WRITE( ARG1, RES * sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG1, RES * sizeof(struct vki_freebsd11_statfs)); } } PRE(sys_statfs) { - PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "statfs", const char *, path, struct statfs *, buf); - PRE_MEM_RASCIIZ( "statfs(path)", ARG1 ); - PRE_MEM_WRITE( "statfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "statfs", const char*, path, struct statfs*, buf); + PRE_MEM_RASCIIZ("statfs(path)", ARG1); + PRE_MEM_WRITE("statfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } -POST(sys_statfs) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); -} +POST(sys_statfs) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } PRE(sys_fstatfs) { - PRINT("sys_fstatfs ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fstatfs", - unsigned int, fd, struct statfs *, buf); - PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_fstatfs ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "fstatfs", unsigned int, fd, struct statfs*, buf); + PRE_MEM_WRITE("fstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } -POST(sys_fstatfs) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); -} +POST(sys_fstatfs) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } PRE(sys_fhstatfs) { - PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "fhstatfs", - struct fhandle *, fhp, struct statfs *, buf); - PRE_MEM_READ( "fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) ); + PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "fhstatfs", struct fhandle*, fhp, struct statfs*, buf); + PRE_MEM_READ("fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs)); } POST(sys_fhstatfs) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_statfs)); } - #endif // SYS_ksem_close 400 @@ -3840,12 +3903,16 @@ POST(sys_fhstatfs) // SYS_extattr_set_link 412 // ssize_t extattr_set_link(const char *path, int attrnamespace, -// const char *attrname, const void *data, size_t nbytes); +// const char *attrname, const void *data, size_t +// nbytes); PRE(sys_extattr_set_link) { - PRINT("sys_extattr_set_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(ssize_t, "extattr_set_link", - const char *, path, int, attrnamespace, const char *, attrname, const void *, data, size_t, nbytes); + PRINT("sys_extattr_set_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(ssize_t, "extattr_set_link", const char*, path, int, + attrnamespace, const char*, attrname, const void*, data, + size_t, nbytes); PRE_MEM_RASCIIZ("extattr_set_link(path)", ARG1); PRE_MEM_RASCIIZ("extattr_set_link(attrname)", ARG3); PRE_MEM_READ("extattr_set_link(data)", ARG4, ARG5); @@ -3856,9 +3923,12 @@ PRE(sys_extattr_set_link) // const char *attrname, void *data, size_t nbytes); PRE(sys_extattr_get_link) { - PRINT("sys_extattr_get_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,SARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(ssize_t, "extattr_get_link", - const char *, path, int, attrnamespace, const char *, attrname, void *, data, size_t, nbytes); + PRINT("sys_extattr_get_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(ssize_t, "extattr_get_link", const char*, path, int, + attrnamespace, const char*, attrname, void*, data, size_t, + nbytes); PRE_MEM_RASCIIZ("extattr_get_link(path)", ARG1); PRE_MEM_RASCIIZ("extattr_get_link(attrname)", ARG3); if (ARG4) { @@ -3878,9 +3948,11 @@ POST(sys_extattr_get_link) // const char *attrname); PRE(sys_extattr_delete_link) { - PRINT("sys_extattr_delete_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", ARG1,SARG2,ARG3); - PRE_REG_READ3(ssize_t, "extattr_delete_link", - const char *, path, int, attrnamespace, const char *, attrname); + PRINT("sys_extattr_delete_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + ARG1, SARG2, ARG3); + PRE_REG_READ3(ssize_t, "extattr_delete_link", const char*, path, int, + attrnamespace, const char*, attrname); PRE_MEM_RASCIIZ("extattr_delete_link(path)", ARG1); PRE_MEM_RASCIIZ("extattr_delete_link(attrname)", ARG3); } @@ -3889,67 +3961,67 @@ PRE(sys_extattr_delete_link) // @todo // SYS_sigaction 416 -//int sigaction(int sig, const struct sigaction * restrict act, +// int sigaction(int sig, const struct sigaction * restrict act, // struct sigaction * restrict oact); PRE(sys_sigaction) { - vki_sigaction_toK_t new; - vki_sigaction_toK_t *newp; - vki_sigaction_fromK_t old; - vki_sigaction_fromK_t *oldp; + vki_sigaction_toK_t new; + vki_sigaction_toK_t* newp; + vki_sigaction_fromK_t old; + vki_sigaction_fromK_t* oldp; - PRINT("sys_sigaction ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - SARG1,ARG2,ARG3); - PRE_REG_READ3(long, "sigaction", - int, sign, const struct sigaction *, act, - struct sigaction *, oact); + PRINT("sys_sigaction ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(long, "sigaction", int, sign, const struct sigaction*, act, + struct sigaction*, oact); newp = oldp = NULL; if (ARG2 != 0) { - struct vki_sigaction *sa = (struct vki_sigaction *)ARG2; - PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, sizeof(sa->ksa_handler)); - PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr)&sa->sa_mask, sizeof(sa->sa_mask)); - PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr)&sa->sa_flags, sizeof(sa->sa_flags)); + struct vki_sigaction* sa = (struct vki_sigaction*)ARG2; + PRE_MEM_READ("sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, + sizeof(sa->ksa_handler)); + PRE_MEM_READ("sigaction(act->sa_mask)", (Addr)&sa->sa_mask, + sizeof(sa->sa_mask)); + PRE_MEM_READ("sigaction(act->sa_flags)", (Addr)&sa->sa_flags, + sizeof(sa->sa_flags)); } if (ARG3 != 0) { - PRE_MEM_WRITE( "sigaction(oact)", ARG3, sizeof(struct vki_sigaction)); + PRE_MEM_WRITE("sigaction(oact)", ARG3, sizeof(struct vki_sigaction)); oldp = &old; } - if (ARG2 != 0 - && ! ML_(safe_to_deref)((void *)(Addr)ARG2, - sizeof(struct vki_sigaction))) { + if (ARG2 != 0 && + !ML_(safe_to_deref)((void*)(Addr)ARG2, sizeof(struct vki_sigaction))) { VG_(umsg)("Warning: bad act handler address %p in sigaction()\n", - (void *)(Addr)ARG2); - SET_STATUS_Failure ( VKI_EFAULT ); - } else if ((ARG3 != 0 - && ! ML_(safe_to_deref)((void *)(Addr)ARG3, - sizeof(struct vki_sigaction)))) { + (void*)(Addr)ARG2); + SET_STATUS_Failure(VKI_EFAULT); + } else if ((ARG3 != 0 && + !ML_(safe_to_deref)((void*)(Addr)ARG3, + sizeof(struct vki_sigaction)))) { VG_(umsg)("Warning: bad oact handler address %p in sigaction()\n", - (void *)(Addr)ARG3); - SET_STATUS_Failure ( VKI_EFAULT ); + (void*)(Addr)ARG3); + SET_STATUS_Failure(VKI_EFAULT); } else { if (ARG2 != 0) { - struct vki_sigaction *oldnew = - (struct vki_sigaction *)(Addr)ARG2; + struct vki_sigaction* oldnew = (struct vki_sigaction*)(Addr)ARG2; new.ksa_handler = oldnew->ksa_handler; - new.sa_flags = oldnew->sa_flags; - new.sa_mask = oldnew->sa_mask; - newp = &new; + new.sa_flags = oldnew->sa_flags; + new.sa_mask = oldnew->sa_mask; + newp = &new; } - SET_STATUS_from_SysRes( VG_(do_sys_sigaction)(ARG1, newp, oldp) ); + SET_STATUS_from_SysRes(VG_(do_sys_sigaction)(ARG1, newp, oldp)); if (ARG3 != 0 && SUCCESS && RES == 0) { - struct vki_sigaction *oldold = - (struct vki_sigaction *)(Addr)ARG3; + struct vki_sigaction* oldold = (struct vki_sigaction*)(Addr)ARG3; oldold->ksa_handler = oldp->ksa_handler; - oldold->sa_flags = oldp->sa_flags; - oldold->sa_mask = oldp->sa_mask; + oldold->sa_flags = oldp->sa_flags; + oldold->sa_mask = oldp->sa_mask; } } } @@ -3958,7 +4030,7 @@ POST(sys_sigaction) { vg_assert(SUCCESS); if (RES == 0 && ARG3 != 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_sigaction)); + POST_MEM_WRITE(ARG3, sizeof(struct vki_sigaction)); } } @@ -3970,15 +4042,12 @@ POST(sys_sigaction) // SYS_swapcontext 423 // PRE in x86/amd64 -POST(sys_getcontext) -{ - POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) ); -} +POST(sys_getcontext) { POST_MEM_WRITE(ARG1, sizeof(struct vki_ucontext)); } POST(sys_swapcontext) { if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_ucontext)); } } @@ -3987,18 +4056,18 @@ POST(sys_swapcontext) // int swapoff(const char *special); PRE(sys_freebsd13_swapoff) { - PRINT("sys_freebsd13_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1); - PRE_REG_READ1(int, "swapoff", const char *, special); - PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); + PRINT("sys_freebsd13_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "swapoff", const char*, special); + PRE_MEM_RASCIIZ("swapoff(special)", ARG1); } #else // SYS_swapoff 424 // int swapoff(const char *special); PRE(sys_swapoff) { - PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1); - PRE_REG_READ1(int, "swapoff", const char *, special); - PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); + PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "swapoff", const char*, special); + PRE_MEM_RASCIIZ("swapoff(special)", ARG1); } #endif @@ -4006,18 +4075,20 @@ PRE(sys_swapoff) // int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_get_link) { - PRINT("sys___acl_get_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "__acl_get_link", - const char *, path, int, acltype, struct vki_acl *, aclp); - PRE_MEM_RASCIIZ( "__acl_get_link(path)", ARG1 ); - PRE_MEM_WRITE( "__acl_get_link(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_get_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "__acl_get_link", const char*, path, int, acltype, + struct vki_acl*, aclp); + PRE_MEM_RASCIIZ("__acl_get_link(path)", ARG1); + PRE_MEM_WRITE("__acl_get_link(aclp)", ARG3, sizeof(struct vki_acl)); } POST(sys___acl_get_link) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_acl) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_acl)); } } @@ -4025,31 +4096,35 @@ POST(sys___acl_get_link) // int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_set_link) { - PRINT("sys___acl_set_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "__acl_set_link", - const char *, path, int, acltype, struct vki_acl *, aclp); - PRE_MEM_RASCIIZ( "__acl_set_link(path)", ARG1 ); - PRE_MEM_READ( "__acl_set_link(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_set_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "__acl_set_link", const char*, path, int, acltype, + struct vki_acl*, aclp); + PRE_MEM_RASCIIZ("__acl_set_link(path)", ARG1); + PRE_MEM_READ("__acl_set_link(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS___acl_delete_link 427 // int __acl_delete_link(const char *path, acl_type_t type); PRE(sys___acl_delete_link) { - PRINT("sys___acl_delete_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1,ARG2); - PRE_MEM_RASCIIZ( "__acl_delete_link(path)", ARG1 ); - PRE_REG_READ2(int, "__acl_delete_link", - const char *, path, int, acltype); + PRINT("sys___acl_delete_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", + ARG1, (char*)ARG1, ARG2); + PRE_MEM_RASCIIZ("__acl_delete_link(path)", ARG1); + PRE_REG_READ2(int, "__acl_delete_link", const char*, path, int, acltype); } // SYS___acl_aclcheck_link 428 // int __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp); PRE(sys___acl_aclcheck_link) { - PRINT("sys___acl_aclcheck_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "__acl_aclcheck_link", - const char *, path, int, acltype, struct vki_acl *, aclp); - PRE_MEM_RASCIIZ( "__acl_check_link(path)", ARG1 ); - PRE_MEM_READ( "__acl_aclcheck_link(aclp)", ARG3, sizeof(struct vki_acl) ); + PRINT("sys___acl_aclcheck_link ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "__acl_aclcheck_link", const char*, path, int, acltype, + struct vki_acl*, aclp); + PRE_MEM_RASCIIZ("__acl_check_link(path)", ARG1); + PRE_MEM_READ("__acl_aclcheck_link(aclp)", ARG3, sizeof(struct vki_acl)); } // SYS_sigwait 429 @@ -4057,32 +4132,34 @@ PRE(sys___acl_aclcheck_link) PRE(sys_sigwait) { *flags |= SfMayBlock; - PRINT("sys_sigwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - ARG1,ARG2); - PRE_REG_READ2(int, "sigwait", - const vki_sigset_t *, set, int *, sig); + PRINT("sys_sigwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "sigwait", const vki_sigset_t*, set, int*, sig); if (ARG1 != 0) { - PRE_MEM_READ( "sigwait(set)", ARG1, sizeof(vki_sigset_t)); + PRE_MEM_READ("sigwait(set)", ARG1, sizeof(vki_sigset_t)); } if (ARG2 != 0) { - PRE_MEM_WRITE( "sigwait(sig)", ARG2, sizeof(int)); + PRE_MEM_WRITE("sigwait(sig)", ARG2, sizeof(int)); } } POST(sys_sigwait) { if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(int)); + POST_MEM_WRITE(ARG2, sizeof(int)); } } // SYS_thr_create 430 // no manpage? -// syscalls.master: int thr_create(_In_ ucontext_t *ctx, _Out_ long *id, int flags ); +// syscalls.master: int thr_create(_In_ ucontext_t *ctx, _Out_ long *id, int +// flags ); PRE(sys_thr_create) { - PRINT( "sys_thr_create ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )", ARG1, ARG2, SARG3 ); - PRE_REG_READ3(int, "thr_create", /*ucontext_t*/void *, ctx, long *, id, int, flags ); + PRINT("sys_thr_create ( %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %" FMT_REGWORD "d )", + ARG1, ARG2, SARG3); + PRE_REG_READ3(int, "thr_create", /*ucontext_t*/ void*, ctx, long*, id, int, + flags); VG_(message)(Vg_UserMsg, "thr_create() not implemented"); VG_(unimplemented)("Valgrind does not support thr_create()."); @@ -4094,17 +4171,17 @@ PRE(sys_thr_create) // void thr_exit(long *state); PRE(sys_thr_exit) { - ThreadState *tst; + ThreadState* tst; - PRINT( "sys_thr_exit ( %#" FMT_REGWORD "x )", ARG1 ); - PRE_REG_READ1(void, "thr_exit", long *, state); + PRINT("sys_thr_exit ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(void, "thr_exit", long*, state); if (ARG1) { - PRE_MEM_WRITE( "thr_exit(state)", ARG1, sizeof(long) ); + PRE_MEM_WRITE("thr_exit(state)", ARG1, sizeof(long)); } - tst = VG_(get_ThreadState)(tid); - tst->exitreason = VgSrc_ExitThread; + tst = VG_(get_ThreadState)(tid); + tst->exitreason = VgSrc_ExitThread; tst->os_state.exitcode = ARG1; SET_STATUS_Success(0); } @@ -4113,31 +4190,28 @@ PRE(sys_thr_exit) // int thr_self(long *id); PRE(sys_thr_self) { - PRINT( "sys_thr_self ( %#" FMT_REGWORD "x )", ARG1 ); - PRE_REG_READ1(int, "thr_self", long *, id); - PRE_MEM_WRITE( "thr_self()", ARG1, sizeof(long)); + PRINT("sys_thr_self ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(int, "thr_self", long*, id); + PRE_MEM_WRITE("thr_self()", ARG1, sizeof(long)); } -POST(sys_thr_self) -{ - POST_MEM_WRITE( ARG1, sizeof(long)); -} +POST(sys_thr_self) { POST_MEM_WRITE(ARG1, sizeof(long)); } // SYS_thr_kill 433 // int thr_kill(long id, int sig); PRE(sys_thr_kill) { - PRINT("sys_thr_kill ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2); + PRINT("sys_thr_kill ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(long, "thr_kill", long, id, int, sig); if (!ML_(client_signal_OK)(ARG2)) { - SET_STATUS_Failure( VKI_EINVAL ); + SET_STATUS_Failure(VKI_EINVAL); return; } /* Check to see if this kill gave us a pending signal */ *flags |= SfPollAfter; - if (VG_(clo_trace_signals)) { + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "thr_kill: sending signal %lu to tid %lu\n", ARG2, ARG1); } @@ -4164,8 +4238,8 @@ PRE(sys_thr_kill) POST(sys_thr_kill) { if (VG_(clo_trace_signals)) { - VG_(message)(Vg_DebugMsg, "thr_kill: sent signal %lu to tid %lu\n", - ARG2, ARG1); + VG_(message)(Vg_DebugMsg, "thr_kill: sent signal %lu to tid %lu\n", ARG2, + ARG1); } } @@ -4173,10 +4247,10 @@ POST(sys_thr_kill) // SYS__umtx_lock 434 PRE(sys__umtx_lock) { - PRINT( "sys__umtx_lock ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(long, "_umtx_lock", struct vki_umtx *, umtx); - PRE_MEM_READ( "_umtx_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); - PRE_MEM_WRITE( "_umtx_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); + PRINT("sys__umtx_lock ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(long, "_umtx_lock", struct vki_umtx*, umtx); + PRE_MEM_READ("_umtx_lock(mtx)", ARG1, sizeof(struct vki_umtx)); + PRE_MEM_WRITE("_umtx_lock(mtx)", ARG1, sizeof(struct vki_umtx)); } POST(sys__umtx_lock) @@ -4189,10 +4263,10 @@ POST(sys__umtx_lock) // SYS__umtx_unlock 434 PRE(sys__umtx_unlock) { - PRINT( "sys__umtx_unlock ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(long, "_umtx_unlock", struct vki_umtx *, umtx); - PRE_MEM_READ( "_umtx_unlock(mtx)", ARG1, sizeof(struct vki_umtx) ); - PRE_MEM_WRITE( "_umtx_unlock(mtx)", ARG1, sizeof(struct vki_umtx) ); + PRINT("sys__umtx_unlock ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(long, "_umtx_unlock", struct vki_umtx*, umtx); + PRE_MEM_READ("_umtx_unlock(mtx)", ARG1, sizeof(struct vki_umtx)); + PRE_MEM_WRITE("_umtx_unlock(mtx)", ARG1, sizeof(struct vki_umtx)); } POST(sys__umtx_unlock) @@ -4212,50 +4286,51 @@ PRE(sys_jail_attach) } // SYS_extattr_list_fd 437 -// ssize_t extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); +// ssize_t extattr_list_fd(int fd, int attrnamespace, void *data, size_t +// nbytes); PRE(sys_extattr_list_fd) { - PRINT("extattr_list_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", SARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(ssize_t, "extattr_list_fd", int, id, int, attrnamespace, void *,data, size_t, nbytes); + PRINT("extattr_list_fd ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + SARG1, SARG2, ARG3, ARG4); + PRE_REG_READ4(ssize_t, "extattr_list_fd", int, id, int, attrnamespace, void*, + data, size_t, nbytes); PRE_MEM_WRITE("extattr_list_fd(data)", ARG3, ARG4); } -POST(sys_extattr_list_fd) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_extattr_list_fd) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_extattr_list_file 438 // ssize_t extattr_list_file(const char *path, int attrnamespace, void *data, // size_t nbytes); PRE(sys_extattr_list_file) { - PRINT("extattr_list_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(ssize_t, "extattr_list_file", const char *, path, int, attrnamespace, void *,data, size_t, nbytes); + PRINT("extattr_list_file ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4); + PRE_REG_READ4(ssize_t, "extattr_list_file", const char*, path, int, + attrnamespace, void*, data, size_t, nbytes); PRE_MEM_RASCIIZ("extattr_list_file(path)", ARG1); PRE_MEM_WRITE("extattr_list_file(data)", ARG3, ARG4); } -POST(sys_extattr_list_file) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_extattr_list_file) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_extattr_list_link 439 // ssize_t extattr_get_link(const char *path, int attrnamespace, // const char *attrname, void *data, size_t nbytes); PRE(sys_extattr_list_link) { - PRINT("extattr_list_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(ssize_t, "extattr_list_link", const char *, path, int, attrnamespace, void *,data, size_t, nbytes); + PRINT("extattr_list_link ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, SARG2, ARG3, ARG4); + PRE_REG_READ4(ssize_t, "extattr_list_link", const char*, path, int, + attrnamespace, void*, data, size_t, nbytes); PRE_MEM_RASCIIZ("extattr_list_link(path)", ARG1); PRE_MEM_WRITE("extattr_list_link(data)", ARG3, ARG4); } -POST(sys_extattr_list_link) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_extattr_list_link) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_ksem_timedwait 441 // @todo @@ -4265,7 +4340,7 @@ POST(sys_extattr_list_link) PRE(sys_thr_suspend) { PRINT("sys_thr_suspend ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "thr_suspend", struct timespec *, timeout); + PRE_REG_READ1(int, "thr_suspend", struct timespec*, timeout); PRE_MEM_READ("thr_suspend(timeout)", ARG1, sizeof(struct vki_timespec)); VG_(message)(Vg_UserMsg, "thr_supend() not implemented"); @@ -4293,7 +4368,8 @@ PRE(sys_thr_wake) // int kldunloadf(int fileid, int flags); PRE(sys_kldunloadf) { - PRINT("sys_kldunloadf ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); + PRINT("sys_kldunloadf ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, + SARG2); PRE_REG_READ2(int, "kldunloadf", int, fileid, int, flags); } @@ -4338,276 +4414,348 @@ PRE(sys__umtx_op) { /* 5 args are always passed through. The last two can vary, but they're always pointers. They may not be used though. */ - switch(ARG2) { + switch (ARG2) { case VKI_UMTX_OP_LOCK: // marked as COMPAT10 - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, LOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_lock", - struct umtx *, obj, int, op, unsigned long, id, - size_t, timeout_size, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, LOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_lock", struct umtx*, obj, int, op, + unsigned long, id, size_t, timeout_size, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_lock(timespec)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_lock(timespec)", ARG5, ARG4); } - PRE_MEM_WRITE( "_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); + PRE_MEM_WRITE("_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_UNLOCK: // marked as COMPAT10 - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, UNLOCK, %" FMT_REGWORD "u)", ARG1, ARG3); - PRE_REG_READ3(long, "_umtx_op_unlock", - struct umtx *, obj, int, op, unsigned long, id); - PRE_MEM_READ( "_umtx_op_unlock(mtx)", ARG1, sizeof(struct vki_umtx) ); - PRE_MEM_WRITE( "_umtx_op_unlock(mtx)", ARG1, sizeof(struct vki_umtx) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, UNLOCK, %" FMT_REGWORD "u)", + ARG1, ARG3); + PRE_REG_READ3(long, "_umtx_op_unlock", struct umtx*, obj, int, op, + unsigned long, id); + PRE_MEM_READ("_umtx_op_unlock(mtx)", ARG1, sizeof(struct vki_umtx)); + PRE_MEM_WRITE("_umtx_op_unlock(mtx)", ARG1, sizeof(struct vki_umtx)); break; case VKI_UMTX_OP_WAIT: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_wait", - long *, obj, int, op, unsigned long, val, - size_t, timeout_size, struct vki_timespec *, timeout); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, WAIT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_wait", long*, obj, int, op, unsigned long, + val, size_t, timeout_size, struct vki_timespec*, timeout); if (ARG1) { - PRE_MEM_READ( "_umtx_op_wait(val)", ARG1, sizeof(long) ); + PRE_MEM_READ("_umtx_op_wait(val)", ARG1, sizeof(long)); if (*(long*)ARG1 == (long)ARG3) { *flags |= SfMayBlock; } } if (ARG5) { - PRE_MEM_READ( "_umtx_op_wait(timeout)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_wait(timeout)", ARG5, ARG4); } break; case VKI_UMTX_OP_WAKE: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, WAKE, %" FMT_REGWORD "u)", ARG1, ARG3); - PRE_REG_READ3(long, "_umtx_op_wake", - vki_uintptr_t *, obj, int, op, int, val); - // PJF I don't think that the value of obj gets read, the address is being used as a key - //PRE_MEM_READ("_umtx_op_wake(obj)", ARG1, sizeof(vki_uintptr_t)); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, WAKE, %" FMT_REGWORD "u)", ARG1, + ARG3); + PRE_REG_READ3(long, "_umtx_op_wake", vki_uintptr_t*, obj, int, op, int, + val); + // PJF I don't think that the value of obj gets read, the address is being + // used as a key + // PRE_MEM_READ("_umtx_op_wake(obj)", ARG1, sizeof(vki_uintptr_t)); break; case VKI_UMTX_OP_MUTEX_TRYLOCK: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_TRYLOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_mutex_trylock", struct umutex *, obj, int, op); - PRE_MEM_READ( "_umtx_op_mutex_trylock(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_mutex_trylock(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_TRYLOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_mutex_trylock", struct umutex*, obj, int, + op); + PRE_MEM_READ("_umtx_op_mutex_trylock(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_mutex_trylock(mutex)", ARG1, + sizeof(struct vki_umutex)); /* not too sure about the restart here * it's hard to test as if the mutex is locked this returns EBUSY - * so there is only a small window where the syscall could be interrupted */ + * so there is only a small window where the syscall could be interrupted + */ *flags |= SfMayBlock | SfKernelRestart; break; case VKI_UMTX_OP_MUTEX_LOCK: // called by pthread_mutex_lock // when the atribute UMUTEX_PRIO_PROTECT or UMUTEX_PRIO_INHERIT is set - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_LOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_mutex_lock", - struct umutex *, obj, int, op, unsigned long, noid, - size_t, timeout_size, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_mutex_lock(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_LOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_mutex_lock", struct umutex*, obj, int, op, + unsigned long, noid, size_t, timeout_size, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_mutex_lock(mutex)", ARG1, + sizeof(struct vki_umutex)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_mutex_lock(timespec)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_mutex_lock(timespec)", ARG5, ARG4); } else { *flags |= SfKernelRestart; } - PRE_MEM_WRITE( "_umtx_op_mutex_lock(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRE_MEM_WRITE("_umtx_op_mutex_lock(mutex)", ARG1, + sizeof(struct vki_umutex)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_MUTEX_UNLOCK: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_UNLOCK)", ARG1); - PRE_REG_READ2(long, "_umtx_op_mutex_unlock", - struct umutex *, obj, int, op); - PRE_MEM_READ( "_umtx_op_mutex_unlock(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_mutex_unlock(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_UNLOCK)", ARG1); + PRE_REG_READ2(long, "_umtx_op_mutex_unlock", struct umutex*, obj, int, + op); + PRE_MEM_READ("_umtx_op_mutex_unlock(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_mutex_unlock(mutex)", ARG1, + sizeof(struct vki_umutex)); break; case VKI_UMTX_OP_SET_CEILING: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SET_CEILING, %" FMT_REGWORD "u, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4); - PRE_REG_READ4(long, "_umtx_op_set_ceiling", - struct umutex *, obj, int, op, unsigned int, ceiling, - unsigned int *, old_ceiling); - PRE_MEM_READ( "_umtx_op_set_ceiling(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_set_ceiling(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SET_CEILING, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4); + PRE_REG_READ4(long, "_umtx_op_set_ceiling", struct umutex*, obj, int, op, + unsigned int, ceiling, unsigned int*, old_ceiling); + PRE_MEM_READ("_umtx_op_set_ceiling(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_set_ceiling(mutex)", ARG1, + sizeof(struct vki_umutex)); if (ARG4) { - PRE_MEM_WRITE( "_umtx_op_set_ceiling(old_ceiling)", ARG4, sizeof(vki_uint32_t) ); + PRE_MEM_WRITE("_umtx_op_set_ceiling(old_ceiling)", ARG4, + sizeof(vki_uint32_t)); } break; case VKI_UMTX_OP_CV_WAIT: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_cv_wait", - struct ucond *, obj, int, op, unsigned long, wflags, - struct umutex *, umtx, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_cv_wait(cond)", ARG1, sizeof(struct vki_ucond) ); - PRE_MEM_WRITE( "_umtx_op_cv_wait(cond)", ARG1, sizeof(struct vki_ucond) ); - PRE_MEM_READ( "_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_cv_wait", struct ucond*, obj, int, op, + unsigned long, wflags, struct umutex*, umtx, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_cv_wait(cond)", ARG1, sizeof(struct vki_ucond)); + PRE_MEM_WRITE("_umtx_op_cv_wait(cond)", ARG1, sizeof(struct vki_ucond)); + PRE_MEM_READ("_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_cv_wait(timespec)", ARG5, sizeof(struct vki_timespec) ); + PRE_MEM_READ("_umtx_op_cv_wait(timespec)", ARG5, + sizeof(struct vki_timespec)); } *flags |= SfMayBlock; break; case VKI_UMTX_OP_CV_SIGNAL: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_SIGNAL)", ARG1); - PRE_REG_READ2(long, "_umtx_op_cv_signal", - struct ucond *, obj, int, op); - PRE_MEM_READ( "_umtx_op_cv_signal(cond)", ARG1, sizeof(struct vki_ucond) ); - PRE_MEM_WRITE( "_umtx_op_cv_signal(cond)", ARG1, sizeof(struct vki_ucond) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, CV_SIGNAL)", ARG1); + PRE_REG_READ2(long, "_umtx_op_cv_signal", struct ucond*, obj, int, op); + PRE_MEM_READ("_umtx_op_cv_signal(cond)", ARG1, sizeof(struct vki_ucond)); + PRE_MEM_WRITE("_umtx_op_cv_signal(cond)", ARG1, sizeof(struct vki_ucond)); break; case VKI_UMTX_OP_CV_BROADCAST: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_BROADCAST, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_cv_broadcast", - struct ucond *, obj, int, op); - PRE_MEM_READ( "_umtx_op_cv_broadcast(cond)", ARG1, sizeof(struct vki_ucond) ); - PRE_MEM_WRITE( "_umtx_op_cv_broadcast(cond)", ARG1, sizeof(struct vki_ucond) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, CV_BROADCAST, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_cv_broadcast", struct ucond*, obj, int, op); + PRE_MEM_READ("_umtx_op_cv_broadcast(cond)", ARG1, + sizeof(struct vki_ucond)); + PRE_MEM_WRITE("_umtx_op_cv_broadcast(cond)", ARG1, + sizeof(struct vki_ucond)); break; case VKI_UMTX_OP_WAIT_UINT: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT_UINT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_wait_uint", - int *, obj, int, op, unsigned long, id, - size_t, timeout_wait, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_wait(uint)", ARG1, sizeof(int) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT_UINT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_wait_uint", int*, obj, int, op, + unsigned long, id, size_t, timeout_wait, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_wait(uint)", ARG1, sizeof(int)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_wait(timespec)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_wait(timespec)", ARG5, ARG4); } *flags |= SfMayBlock; break; case VKI_UMTX_OP_RW_RDLOCK: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, RW_RDLOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_rw_rdlock", - struct urwlock *, obj, int, op, unsigned long, noid, - void *, zero, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_rw_rdlock(rw)", ARG1, sizeof(struct vki_urwlock) ); - PRE_MEM_WRITE( "_umtx_op_rw_rdlock(rw)", ARG1, sizeof(struct vki_urwlock) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, RW_RDLOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_rw_rdlock", struct urwlock*, obj, int, op, + unsigned long, noid, void*, zero, struct vki_timespec*, + timeout); + PRE_MEM_READ("_umtx_op_rw_rdlock(rw)", ARG1, sizeof(struct vki_urwlock)); + PRE_MEM_WRITE("_umtx_op_rw_rdlock(rw)", ARG1, sizeof(struct vki_urwlock)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_RW_WRLOCK: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, RW_WRLOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_rw_wrlock", - struct urwlock *, obj, int, op, unsigned long, noid, - void *, zero, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_rw_wrlock(rw)", ARG1, sizeof(struct vki_urwlock) ); - PRE_MEM_WRITE( "_umtx_op_rw_wrlock(rw)", ARG1, sizeof(struct vki_urwlock) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, RW_WRLOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_rw_wrlock", struct urwlock*, obj, int, op, + unsigned long, noid, void*, zero, struct vki_timespec*, + timeout); + PRE_MEM_READ("_umtx_op_rw_wrlock(rw)", ARG1, sizeof(struct vki_urwlock)); + PRE_MEM_WRITE("_umtx_op_rw_wrlock(rw)", ARG1, sizeof(struct vki_urwlock)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_RW_UNLOCK: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, RW_UNLOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_rw_unlock", - struct urwlock *, obj, int, op); - PRE_MEM_READ( "_umtx_op_rw_unlock(rw)", ARG1, sizeof(struct vki_urwlock) ); - PRE_MEM_WRITE( "_umtx_op_rw_unlock(rw)", ARG1, sizeof(struct vki_urwlock) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, RW_UNLOCK, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_rw_unlock", struct urwlock*, obj, int, op); + PRE_MEM_READ("_umtx_op_rw_unlock(rw)", ARG1, sizeof(struct vki_urwlock)); + PRE_MEM_WRITE("_umtx_op_rw_unlock(rw)", ARG1, sizeof(struct vki_urwlock)); break; case VKI_UMTX_OP_WAIT_UINT_PRIVATE: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT_UINT_PRIVATE, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_wait_uint_private", - int *, obj, int, op, unsigned long, id, - size_t, timeout_size, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_wait_private(uint)", ARG1, sizeof(int) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD + "x, CV_WAIT_UINT_PRIVATE, %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_wait_uint_private", int*, obj, int, op, + unsigned long, id, size_t, timeout_size, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_wait_private(uint)", ARG1, sizeof(int)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_wait_private(umtx_time)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_wait_private(umtx_time)", ARG5, ARG4); } *flags |= SfMayBlock; break; case VKI_UMTX_OP_WAKE_PRIVATE: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAKE_PRIVATE, %" FMT_REGWORD "u)", ARG1, ARG3); - PRE_REG_READ3(long, "_umtx_op_wake_private", - vki_uintptr_t *, obj, int, op, int, val); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAKE_PRIVATE, %" FMT_REGWORD + "u)", + ARG1, ARG3); + PRE_REG_READ3(long, "_umtx_op_wake_private", vki_uintptr_t*, obj, int, op, + int, val); // PJF like OP_WAKE contents of obj not read - //PRE_MEM_READ("_umtx_op_wake_private(obj)", ARG1, sizeof(vki_uintptr_t)); + // PRE_MEM_READ("_umtx_op_wake_private(obj)", ARG1, + // sizeof(vki_uintptr_t)); break; case VKI_UMTX_OP_MUTEX_WAIT: // pthread_mutex_lock without prio flags // does not need to be restarted - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_mutex_wait", - struct umutex *, obj, int, op); - PRE_MEM_READ( "_umtx_op_mutex_wait(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_mutex_wait(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAIT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_mutex_wait", struct umutex*, obj, int, op); + PRE_MEM_READ("_umtx_op_mutex_wait(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_mutex_wait(mutex)", ARG1, + sizeof(struct vki_umutex)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_MUTEX_WAKE: // marked as deprecated - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAKE, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_mutex_wake", - struct umutex *, obj, int, op); - PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAKE, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_mutex_wake", struct umutex*, obj, int, op); + PRE_MEM_READ("_umtx_op_mutex_wake(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_mutex_wake(mutex)", ARG1, + sizeof(struct vki_umutex)); break; case VKI_UMTX_OP_SEM_WAIT: // marked as deprecated - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SEM_WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ5(long, "_umtx_op_sem_wait", - struct usem *, obj, int, op, unsigned long, id, - size_t, timeout_size, struct vki_timespec *, timeout); - PRE_MEM_READ( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) ); - PRE_MEM_WRITE( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SEM_WAIT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ5(long, "_umtx_op_sem_wait", struct usem*, obj, int, op, + unsigned long, id, size_t, timeout_size, + struct vki_timespec*, timeout); + PRE_MEM_READ("_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem)); + PRE_MEM_WRITE("_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem)); if (ARG5) { - PRE_MEM_READ( "_umtx_op_sem_wait(umtx_time)", ARG5, ARG4 ); + PRE_MEM_READ("_umtx_op_sem_wait(umtx_time)", ARG5, ARG4); } *flags |= SfMayBlock; break; case VKI_UMTX_OP_SEM_WAKE: // marked as deprecated - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SEM_WAKE, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ2(long, "_umtx_op_sem_wake", - struct umutex *, obj, int, op); - PRE_MEM_READ( "_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem) ); - PRE_MEM_WRITE( "_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SEM_WAKE, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ2(long, "_umtx_op_sem_wake", struct umutex*, obj, int, op); + PRE_MEM_READ("_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem)); + PRE_MEM_WRITE("_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem)); break; case VKI_UMTX_OP_NWAKE_PRIVATE: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, NWAKE_PRIVATE, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ3(long, "_umtx_op_nwake_private", - struct umutex *, obj, int, op, int, count); - PRE_MEM_READ( "_umtx_op_nwake_private(mtxs)", ARG1, ARG3 * sizeof(void *) ); - PRE_MEM_WRITE( "_umtx_op_mutex_wake(mtxs)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, NWAKE_PRIVATE, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ3(long, "_umtx_op_nwake_private", struct umutex*, obj, int, + op, int, count); + PRE_MEM_READ("_umtx_op_nwake_private(mtxs)", ARG1, ARG3 * sizeof(void*)); + PRE_MEM_WRITE("_umtx_op_mutex_wake(mtxs)", ARG1, + sizeof(struct vki_umutex)); break; case VKI_UMTX_OP_MUTEX_WAKE2: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAKE2, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ3(long, "_umtx_op_mutex_wake2", - struct umutex *, obj, int, op, unsigned long, flags); - PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) ); - PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_WAKE2, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ3(long, "_umtx_op_mutex_wake2", struct umutex*, obj, int, op, + unsigned long, flags); + PRE_MEM_READ("_umtx_op_mutex_wake(mutex)", ARG1, + sizeof(struct vki_umutex)); + PRE_MEM_WRITE("_umtx_op_mutex_wake(mutex)", ARG1, + sizeof(struct vki_umutex)); break; case VKI_UMTX_OP_SEM2_WAIT: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SEM2_WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ3(long, "_umtx_op_sem2_wake", - struct _usem2 *, obj, int, op, unsigned long, flags); - PRE_MEM_READ( "_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2) ); - PRE_MEM_WRITE( "_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SEM2_WAIT, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ3(long, "_umtx_op_sem2_wake", struct _usem2*, obj, int, op, + unsigned long, flags); + PRE_MEM_READ("_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2)); + PRE_MEM_WRITE("_umtx_op_sem2_wait(mutex)", ARG1, + sizeof(struct vki_usem2)); *flags |= SfMayBlock; break; case VKI_UMTX_OP_SEM2_WAKE: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SEM2_WAKE, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ3(long, "_umtx_op_sem2_wake", - struct _usem2 *, obj, int, op, unsigned long, flags); - PRE_MEM_READ( "_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2) ); - PRE_MEM_WRITE( "_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2) ); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SEM2_WAKE, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ3(long, "_umtx_op_sem2_wake", struct _usem2*, obj, int, op, + unsigned long, flags); + PRE_MEM_READ("_umtx_op_sem2_wait(mutex)", ARG1, sizeof(struct vki_usem2)); + PRE_MEM_WRITE("_umtx_op_sem2_wait(mutex)", ARG1, + sizeof(struct vki_usem2)); break; case VKI_UMTX_OP_SHM: - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, SHM, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); - PRE_REG_READ4(long, "_umtx_op_shm", - void *, obj, int, op, unsigned long, val, void*, uaddr); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, SHM, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); + PRE_REG_READ4(long, "_umtx_op_shm", void*, obj, int, op, unsigned long, + val, void*, uaddr); break; case VKI_UMTX_OP_ROBUST_LISTS: - // val (ARG2) ought to be the same as sizeof(struct vki_umtx_robust_lists_params) - // then the structure contains a pointer to mutex structures + // val (ARG2) ought to be the same as sizeof(struct + // vki_umtx_robust_lists_params) then the structure contains a pointer to + // mutex structures if (ARG1 != sizeof(struct vki_umtx_robust_lists_params)) { - SET_STATUS_Failure( VKI_ENOSYS ); + SET_STATUS_Failure(VKI_ENOSYS); } - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, ROBUST_LISTS, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, ROBUST_LISTS, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", + ARG1, ARG3, ARG4, ARG5); PRE_REG_READ3(long, "_umtx_op_robust_lists", - struct umtx_robust_lists_params *, obj, int, op, unsigned long, flags); - PRE_MEM_READ( "_umtx_op_robust_lists(mutex)", ARG3, sizeof(struct vki_umtx_robust_lists_params) ); + struct umtx_robust_lists_params*, obj, int, op, + unsigned long, flags); + PRE_MEM_READ("_umtx_op_robust_lists(mutex)", ARG3, + sizeof(struct vki_umtx_robust_lists_params)); break; default: VG_(umsg)("WARNING: _umtx_op unsupported value.\n"); - PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u(UNKNOWN), %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3, ARG4, ARG5); + PRINT("sys__umtx_op ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "u(UNKNOWN), %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3, ARG4, ARG5); break; } } POST(sys__umtx_op) { - switch(ARG2) { + switch (ARG2) { case VKI_UMTX_OP_LOCK: case VKI_UMTX_OP_UNLOCK: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_umtx) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_umtx)); } break; case VKI_UMTX_OP_WAIT: @@ -4619,43 +4767,43 @@ POST(sys__umtx_op) case VKI_UMTX_OP_MUTEX_TRYLOCK: case VKI_UMTX_OP_MUTEX_LOCK: case VKI_UMTX_OP_MUTEX_UNLOCK: - case VKI_UMTX_OP_MUTEX_WAIT: /* Sets/clears contested bits */ - case VKI_UMTX_OP_MUTEX_WAKE: /* Sets/clears contested bits */ + case VKI_UMTX_OP_MUTEX_WAIT: /* Sets/clears contested bits */ + case VKI_UMTX_OP_MUTEX_WAKE: /* Sets/clears contested bits */ if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(vki_uintptr_t) ); + POST_MEM_WRITE(ARG1, sizeof(vki_uintptr_t)); } break; case VKI_UMTX_OP_SET_CEILING: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_umutex) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_umutex)); if (ARG4) { - POST_MEM_WRITE( ARG4, sizeof(vki_uint32_t) ); + POST_MEM_WRITE(ARG4, sizeof(vki_uint32_t)); } } break; case VKI_UMTX_OP_CV_WAIT: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) ); - POST_MEM_WRITE( ARG4, sizeof(struct vki_umutex) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_ucond)); + POST_MEM_WRITE(ARG4, sizeof(struct vki_umutex)); } break; case VKI_UMTX_OP_CV_SIGNAL: case VKI_UMTX_OP_CV_BROADCAST: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_ucond)); } break; case VKI_UMTX_OP_RW_RDLOCK: case VKI_UMTX_OP_RW_WRLOCK: case VKI_UMTX_OP_RW_UNLOCK: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_urwlock) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_urwlock)); } break; case VKI_UMTX_OP_SEM2_WAIT: case VKI_UMTX_OP_SEM2_WAKE: if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_usem2) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_usem2)); } break; case VKI_UMTX_OP_SHM: @@ -4672,37 +4820,41 @@ POST(sys__umtx_op) // int sigqueue(pid_t pid, int signo, const union sigval value); PRE(sys_sigqueue) { - PRINT("sys_sigqueue ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", - SARG1,SARG2,ARG3); - PRE_REG_READ3(int, "sigqueue", vki_pid_t, pid, int, signo, const union vki_sigval, value); + PRINT("sys_sigqueue ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD + "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(int, "sigqueue", vki_pid_t, pid, int, signo, + const union vki_sigval, value); } // SYS_kmq_open 457 // mqd_t mq_open(const char *name, int oflag, ...); -// int kmq_open(_In_z_ const char *path, int flags, mode_t mode, _In_opt_ const struct mq_attr *attr); +// int kmq_open(_In_z_ const char *path, int flags, mode_t mode, _In_opt_ const +// struct mq_attr *attr); PRE(sys_kmq_open) { if (ARG2 & VKI_O_CREAT) { - PRINT("sys_kmq_open( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %hu, %#" FMT_REGWORD "x )", - ARG1,(char *)ARG1,ARG2,(vki_mode_t)ARG3,ARG4); - PRE_REG_READ4(long, "mq_open", - const char *, name, int, oflag, vki_mode_t, mode, - struct mq_attr *, attr); + PRINT("sys_kmq_open( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %hu, %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, (vki_mode_t)ARG3, ARG4); + PRE_REG_READ4(long, "mq_open", const char*, name, int, oflag, vki_mode_t, + mode, struct mq_attr*, attr); } else { PRINT("sys_kmq_open( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %hu)", - ARG1,(char *)ARG1,ARG2,(vki_mode_t)ARG3); - PRE_REG_READ3(long, "mq_open", - const char *, name, int, oflag, vki_mode_t, mode); + ARG1, (char*)ARG1, ARG2, (vki_mode_t)ARG3); + PRE_REG_READ3(long, "mq_open", const char*, name, int, oflag, vki_mode_t, + mode); } - PRE_MEM_RASCIIZ( "mq_open(name)", ARG1 ); + PRE_MEM_RASCIIZ("mq_open(name)", ARG1); if (ARG2 & VKI_O_CREAT) { PRE_MEM_READ("mq_open(attr)", ARG4, sizeof(struct vki_mq_attr)); - if (ML_(safe_to_deref)((struct vki_mq_attr *)ARG4, sizeof(struct vki_mq_attr))) { - const struct vki_mq_attr *attr = (struct vki_mq_attr *)ARG4; - PRE_MEM_READ("mq_open(attr->mq_maxmsg)", - (Addr)&attr->mq_maxmsg, sizeof(attr->mq_maxmsg) ); - PRE_MEM_READ("mq_open(attr->mq_msgsize)", - (Addr)&attr->mq_msgsize, sizeof(attr->mq_msgsize) ); + if (ML_(safe_to_deref)((struct vki_mq_attr*)ARG4, + sizeof(struct vki_mq_attr))) { + const struct vki_mq_attr* attr = (struct vki_mq_attr*)ARG4; + PRE_MEM_READ("mq_open(attr->mq_maxmsg)", (Addr)&attr->mq_maxmsg, + sizeof(attr->mq_maxmsg)); + PRE_MEM_READ("mq_open(attr->mq_msgsize)", (Addr)&attr->mq_msgsize, + sizeof(attr->mq_msgsize)); } } } @@ -4712,7 +4864,7 @@ POST(sys_kmq_open) vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "mq_open", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (const HChar*)ARG1); @@ -4725,55 +4877,56 @@ POST(sys_kmq_open) // struct mq_attr *restrict omqstat); PRE(sys_kmq_setattr) { - PRINT("sys_kmq_getattr( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3 ); - PRE_REG_READ3(int, "mq_setattr", - vki_mqd_t, mqdes, const struct mq_attr *, mqstat, - struct mq_attr *, omqstat); + PRINT("sys_kmq_getattr( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "mq_setattr", vki_mqd_t, mqdes, const struct mq_attr*, + mqstat, struct mq_attr*, omqstat); if (!ML_(fd_allowed)(ARG1, "mq_getattr", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); + SET_STATUS_Failure(VKI_EBADF); } else { - if (ML_(safe_to_deref)((struct vki_mq_attr *)ARG2, sizeof(struct vki_mq_attr))) { - const struct vki_mq_attr *attr = (struct vki_mq_attr *)ARG2; - PRE_MEM_READ( "mq_setattr(mqstat->mq_flags)", - (Addr)&attr->mq_flags, sizeof(attr->mq_flags) ); + if (ML_(safe_to_deref)((struct vki_mq_attr*)ARG2, + sizeof(struct vki_mq_attr))) { + const struct vki_mq_attr* attr = (struct vki_mq_attr*)ARG2; + PRE_MEM_READ("mq_setattr(mqstat->mq_flags)", (Addr)&attr->mq_flags, + sizeof(attr->mq_flags)); } - PRE_MEM_WRITE( "mq_setattr(omqstat)", ARG3, - sizeof(struct vki_mq_attr) ); + PRE_MEM_WRITE("mq_setattr(omqstat)", ARG3, sizeof(struct vki_mq_attr)); } } // SYS_kmq_timedreceive 459 // ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, -// unsigned *msg_prio, const struct timespec *abs_timeout); +// unsigned *msg_prio, const struct timespec +// *abs_timeout); PRE(sys_kmq_timedreceive) { *flags |= SfMayBlock; - PRINT("sys_kmq_timedreceive( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %llu, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - ARG1,ARG2,(ULong)ARG3,ARG4,ARG5); - PRE_REG_READ5(ssize_t, "mq_timedreceive", - vki_mqd_t, mqdes, char *, msg_ptr, vki_size_t, msg_len, - unsigned int *, msg_prio, - const struct timespec *, abs_timeout); + PRINT("sys_kmq_timedreceive( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %llu, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, (ULong)ARG3, ARG4, ARG5); + PRE_REG_READ5(ssize_t, "mq_timedreceive", vki_mqd_t, mqdes, char*, msg_ptr, + vki_size_t, msg_len, unsigned int*, msg_prio, + const struct timespec*, abs_timeout); if (!ML_(fd_allowed)(ARG1, "mq_timedreceive", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); + SET_STATUS_Failure(VKI_EBADF); } else { - PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2, ARG3 ); + PRE_MEM_WRITE("mq_timedreceive(msg_ptr)", ARG2, ARG3); if (ARG4 != 0) { - PRE_MEM_WRITE( "mq_timedreceive(msg_prio)", - ARG4, sizeof(unsigned int) ); + PRE_MEM_WRITE("mq_timedreceive(msg_prio)", ARG4, sizeof(unsigned int)); } if (ARG5 != 0) { - PRE_MEM_READ( "mq_timedreceive(abs_timeout)", - ARG5, sizeof(struct vki_timespec) ); + PRE_MEM_READ("mq_timedreceive(abs_timeout)", ARG5, + sizeof(struct vki_timespec)); } } } POST(sys_kmq_timedreceive) { - POST_MEM_WRITE( ARG2, ARG3 ); + POST_MEM_WRITE(ARG2, ARG3); if (ARG4 != 0) { - POST_MEM_WRITE( ARG4, sizeof(unsigned int) ); + POST_MEM_WRITE(ARG4, sizeof(unsigned int)); } } @@ -4783,18 +4936,19 @@ POST(sys_kmq_timedreceive) PRE(sys_kmq_timedsend) { *flags |= SfMayBlock; - PRINT("sys_kmq_timedsend ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %llu, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", - ARG1,ARG2,(ULong)ARG3,ARG4,ARG5); - PRE_REG_READ5(int, "mq_timedsend", - vki_mqd_t, mqdes, const char *, msg_ptr, vki_size_t, msg_len, - unsigned int, msg_prio, const struct timespec *, abs_timeout); + PRINT("sys_kmq_timedsend ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %llu, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, (ULong)ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "mq_timedsend", vki_mqd_t, mqdes, const char*, msg_ptr, + vki_size_t, msg_len, unsigned int, msg_prio, + const struct timespec*, abs_timeout); if (!ML_(fd_allowed)(ARG1, "mq_timedsend", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); + SET_STATUS_Failure(VKI_EBADF); } else { - PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2, ARG3 ); + PRE_MEM_READ("mq_timedsend(msg_ptr)", ARG2, ARG3); if (ARG5 != 0) { - PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5, - sizeof(struct vki_timespec) ); + PRE_MEM_READ("mq_timedsend(abs_timeout)", ARG5, + sizeof(struct vki_timespec)); } } } @@ -4803,15 +4957,14 @@ PRE(sys_kmq_timedsend) // int mq_notify(mqd_t mqdes, const struct sigevent *notification); PRE(sys_kmq_notify) { - PRINT("sys_kmq_notify( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2 ); - PRE_REG_READ2(int, "mq_notify", - vki_mqd_t, mqdes, const struct sigevent *, notification); + PRINT("sys_kmq_notify( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "mq_notify", vki_mqd_t, mqdes, const struct sigevent*, + notification); if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); - } - else if (ARG2 != 0) { - PRE_MEM_READ( "mq_notify(notification)", - ARG2, sizeof(struct vki_sigevent) ); + SET_STATUS_Failure(VKI_EBADF); + } else if (ARG2 != 0) { + PRE_MEM_READ("mq_notify(notification)", ARG2, + sizeof(struct vki_sigevent)); } } @@ -4819,36 +4972,40 @@ PRE(sys_kmq_notify) // int kmq_unlink(const char *path); PRE(sys_kmq_unlink) { - PRINT("sys_kmq_unlink ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1); - PRE_REG_READ1(int, "mq_unlink", const char *, name); - PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1 ); + PRINT("sys_kmq_unlink ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "mq_unlink", const char*, name); + PRE_MEM_RASCIIZ("mq_unlink(name)", ARG1); } // SYS_abort2 463 // void abort2(const char *why, int nargs, void **args); PRE(sys_abort2) { - PRINT( "sys_abort2 ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", ARG1, SARG2, ARG3 ); - PRE_REG_READ3(void, "abort2", const char *, why, int, nargs, void **, args); + PRINT("sys_abort2 ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD + "x )", + ARG1, SARG2, ARG3); + PRE_REG_READ3(void, "abort2", const char*, why, int, nargs, void**, args); // max length of 'why' is 128 - PRE_MEM_RASCIIZ( "abort2(why)", ARG2); + PRE_MEM_RASCIIZ("abort2(why)", ARG2); // max val for nargs is 16 - PRE_MEM_READ("abort2(args", ARG3, ARG2*sizeof(void*)); + PRE_MEM_READ("abort2(args", ARG3, ARG2 * sizeof(void*)); } // SYS_thr_set_name 464 // int thr_set_name(long id, const char *name); PRE(sys_thr_set_name) { - PRINT( "sys_thr_set_name ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2 ); - PRE_REG_READ2(int, "thr_set_name", long, id, const char *, name); - PRE_MEM_RASCIIZ( "thr_set_name(name)", ARG2); + PRINT("sys_thr_set_name ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, + ARG2); + PRE_REG_READ2(int, "thr_set_name", long, id, const char*, name); + PRE_MEM_RASCIIZ("thr_set_name(name)", ARG2); if (ML_(safe_to_deref)((void*)ARG2, 1)) { - const HChar* new_name = (const HChar*) (Addr)ARG2; - ThreadState* tst = VG_(get_ThreadState)(tid); - SizeT new_len = VG_(strnlen)(new_name, VKI_MAXCOMLEN+1); - tst->thread_name = VG_(realloc)("syswrap.thr_set_name", tst->thread_name, new_len + 1); + const HChar* new_name = (const HChar*)(Addr)ARG2; + ThreadState* tst = VG_(get_ThreadState)(tid); + SizeT new_len = VG_(strnlen)(new_name, VKI_MAXCOMLEN + 1); + tst->thread_name = + VG_(realloc)("syswrap.thr_set_name", tst->thread_name, new_len + 1); VG_(strlcpy)(tst->thread_name, new_name, new_len + 1); } } @@ -4857,22 +5014,25 @@ PRE(sys_thr_set_name) // int aio_fsync(int op, struct aiocb *iocb); PRE(sys_aio_fsync) { - PRINT("aio_fsync ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,ARG2); - PRE_REG_READ2(int, "aio_fsync", int, op, struct vki_aiocb *, iocb); - PRE_MEM_READ( "aio_fsync(iocb)", ARG2, sizeof(struct vki_aiocb) ); + PRINT("aio_fsync ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); + PRE_REG_READ2(int, "aio_fsync", int, op, struct vki_aiocb*, iocb); + PRE_MEM_READ("aio_fsync(iocb)", ARG2, sizeof(struct vki_aiocb)); } // SYS_rtprio_thread 466 // int rtprio_thread(int function, lwpid_t lwpid, struct rtprio *rtp); PRE(sys_rtprio_thread) { - PRINT( "sys_rtprio_thread ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3 ); - PRE_REG_READ3(int, "rtprio_thread", - int, function, __vki_lwpid_t, lwpid, struct vki_rtprio *, rtp); + PRINT("sys_rtprio_thread ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "rtprio_thread", int, function, __vki_lwpid_t, lwpid, + struct vki_rtprio*, rtp); if (ARG1 == VKI_RTP_SET) { - PRE_MEM_READ( "rtprio_thread(rtp#set)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_READ("rtprio_thread(rtp#set)", ARG3, sizeof(struct vki_rtprio)); } else if (ARG1 == VKI_RTP_LOOKUP) { - PRE_MEM_WRITE( "rtprio_thread(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_WRITE("rtprio_thread(rtp#lookup)", ARG3, + sizeof(struct vki_rtprio)); } else { /* PHK ?? */ } @@ -4881,7 +5041,7 @@ PRE(sys_rtprio_thread) POST(sys_rtprio_thread) { if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); + POST_MEM_WRITE(ARG3, sizeof(struct vki_rtprio)); } } @@ -4889,33 +5049,38 @@ POST(sys_rtprio_thread) // int sctp_peeloff(int s, sctp_assoc_t id); // @todo - // SYS_sctp_generic_sendmsg 472 // int sctp_generic_sendmsg(int s, void *msg, int msglen, struct sockaddr *to, -// socklen_t len, struct sctp_sndrcvinfo *sinfo, int flags); +// socklen_t len, struct sctp_sndrcvinfo *sinfo, int +// flags); // // Not called directly from libc PRE(sys_sctp_generic_sendmsg) { *flags |= SfMayBlock; - PRINT("sys_sctp_generic_sendmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )",SARG1,ARG2,SARG3,ARG4,SARG5,ARG6,SARG7); - PRE_REG_READ7(ssize_t, "sctp_generic_sendmsg", - int, s, void *, msg, int, msglen, - struct sockaddr *, to, socklen_t, len, - struct sctp_sndrcvinfo *, sinfo, int, flags); + PRINT("sys_sctp_generic_sendmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )", + SARG1, ARG2, SARG3, ARG4, SARG5, ARG6, SARG7); + PRE_REG_READ7(ssize_t, "sctp_generic_sendmsg", int, s, void*, msg, int, + msglen, struct sockaddr*, to, socklen_t, len, + struct sctp_sndrcvinfo*, sinfo, int, flags); - PRE_MEM_READ( "sctp_generic_sendmsg(msg)", ARG2, ARG3); + PRE_MEM_READ("sctp_generic_sendmsg(msg)", ARG2, ARG3); - ML_(pre_mem_read_sockaddr) (tid, "sctp_generic_sendmsg(to)", (struct vki_sockaddr *)ARG4, ARG5); + ML_(pre_mem_read_sockaddr)(tid, "sctp_generic_sendmsg(to)", + (struct vki_sockaddr*)ARG4, ARG5); if (ARG6 != (Addr)NULL) { - PRE_MEM_READ( "sctp_generic_sendmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo)); + PRE_MEM_READ("sctp_generic_sendmsg(sinfo)", ARG6, + sizeof(struct vki_sctp_sndrcvinfo)); } } // SYS_sctp_generic_sendmsg_iov 473 // int sctp_generic_sendmsg_iov(int s, struct iovec *iov, int iovlen, -// struct sockaddr *to, struct sctp_sndrcvinfo *sinfo, int flags); +// struct sockaddr *to, struct sctp_sndrcvinfo +// *sinfo, int flags); // @todo // SYS_sctp_generic_recvmsg 474 @@ -4927,29 +5092,33 @@ PRE(sys_sctp_generic_sendmsg) PRE(sys_sctp_generic_recvmsg) { *flags |= SfMayBlock; - PRINT("sys_sctp_generic_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,SARG3,ARG4,ARG5,ARG6,ARG7); - PRE_REG_READ7(ssize_t, "sctp_generic_recvmsg", - int, s, struct iovec *, iov, int, iovlen, - struct sockaddr *, from, socklen_t *, fromlen, - struct sctp_sndrcvinfo *, sinfo, int *, msgflags); + PRINT("sys_sctp_generic_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, SARG3, ARG4, ARG5, ARG6, ARG7); + PRE_REG_READ7(ssize_t, "sctp_generic_recvmsg", int, s, struct iovec*, iov, + int, iovlen, struct sockaddr*, from, socklen_t*, fromlen, + struct sctp_sndrcvinfo*, sinfo, int*, msgflags); // in the sctp_recvmsg libc wrapper this is always 1 if ((Int)ARG3 > 0) { - PRE_MEM_READ( "sctp_generic_recvmsg(iov)", ARG2, ARG3 * sizeof(struct vki_iovec) ); + PRE_MEM_READ("sctp_generic_recvmsg(iov)", ARG2, + ARG3 * sizeof(struct vki_iovec)); } if (ML_(safe_to_deref)((const void*)ARG2, ARG3 * sizeof(struct vki_iovec))) { struct vki_iovec* iovec = (struct vki_iovec*)ARG2; - PRE_MEM_WRITE("sctp_generic_recvmsg(iov.iov_base)", (Addr)iovec->iov_base, iovec->iov_len); + PRE_MEM_WRITE("sctp_generic_recvmsg(iov.iov_base)", (Addr)iovec->iov_base, + iovec->iov_len); } if (ARG4 != (Addr)NULL) { - ML_(buf_and_len_pre_check) (tid, ARG4, ARG5, - "sctp_generic_recvmsg(from)", - "sctp_generic_recvmsg(fromlen_in)"); + ML_(buf_and_len_pre_check)(tid, ARG4, ARG5, "sctp_generic_recvmsg(from)", + "sctp_generic_recvmsg(fromlen_in)"); } if (ARG6 != (Addr)NULL) { - PRE_MEM_WRITE("sctp_generic_recvmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo)); + PRE_MEM_WRITE("sctp_generic_recvmsg(sinfo)", ARG6, + sizeof(struct vki_sctp_sndrcvinfo)); } if (ARG7 != (Addr)NULL) { @@ -4963,11 +5132,11 @@ POST(sys_sctp_generic_recvmsg) struct vki_iovec* iovec = (struct vki_iovec*)ARG2; POST_MEM_WRITE((Addr)iovec->iov_base, iovec->iov_len); - POST_MEM_WRITE( ARG2, ARG3*sizeof(struct vki_iovec) ); + POST_MEM_WRITE(ARG2, ARG3 * sizeof(struct vki_iovec)); if (ARG4 != (Addr)NULL) { - ML_(buf_and_len_post_check) (tid, VG_(mk_SysRes_Success)(RES), ARG4, ARG5, - "sctp_generic_recvmsg(fromlen_out)"); + ML_(buf_and_len_post_check)(tid, VG_(mk_SysRes_Success)(RES), ARG4, ARG5, + "sctp_generic_recvmsg(fromlen_out)"); } if (ARG6 != (Addr)NULL) { @@ -4991,8 +5160,8 @@ POST(sys_sctp_generic_recvmsg) // SYS_lseek 478 // x86/amd64 -//SYS_truncate 479 -// x86/amd64 +// SYS_truncate 479 +// x86/amd64 // SYS_ftruncate 480 // x86/amd64 @@ -5001,10 +5170,12 @@ POST(sys_sctp_generic_recvmsg) // int thr_kill2(pid_t pid, long id, int sig); PRE(sys_thr_kill2) { - PRINT("sys_thr_kill2 ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3); + PRINT("sys_thr_kill2 ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); PRE_REG_READ3(int, "thr_kill2", pid_t, pid, long, tid, int, sig); if (!ML_(client_signal_OK)(ARG3)) { - SET_STATUS_Failure( VKI_EINVAL ); + SET_STATUS_Failure(VKI_EINVAL); return; } @@ -5012,8 +5183,9 @@ PRE(sys_thr_kill2) *flags |= SfPollAfter; if (VG_(clo_trace_signals)) { - VG_(message)(Vg_DebugMsg, "thr_kill2: sending signal %lu to pid %lu/%lu\n", - ARG3, ARG1, ARG2); + VG_(message)(Vg_DebugMsg, + "thr_kill2: sending signal %lu to pid %lu/%lu\n", ARG3, ARG1, + ARG2); } /* If we're sending SIGKILL, check to see if the target is one of @@ -5047,13 +5219,16 @@ POST(sys_thr_kill2) // int shm_open(const char *path, int flags, mode_t mode); PRE(sys_shm_open) { - PRE_REG_READ3(int, "shm_open", - const char *, path, int, flags, vki_mode_t, mode); + PRE_REG_READ3(int, "shm_open", const char*, path, int, flags, vki_mode_t, + mode); if (ARG1 == VKI_SHM_ANON) { - PRINT("sys_shm_open(%#" FMT_REGWORD "x(SHM_ANON), %" FMT_REGWORD "u, %hu)", ARG1, ARG2, (vki_mode_t)ARG3); + PRINT("sys_shm_open(%#" FMT_REGWORD "x(SHM_ANON), %" FMT_REGWORD + "u, %hu)", + ARG1, ARG2, (vki_mode_t)ARG3); } else { - PRINT("sys_shm_open(%#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %hu)", ARG1, (HChar *)ARG1, ARG2, (vki_mode_t)ARG3); - PRE_MEM_RASCIIZ( "shm_open(path)", ARG1 ); + PRINT("sys_shm_open(%#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %hu)", + ARG1, (HChar*)ARG1, ARG2, (vki_mode_t)ARG3); + PRE_MEM_RASCIIZ("shm_open(path)", ARG1); } *flags |= SfMayBlock; } @@ -5063,7 +5238,7 @@ POST(sys_shm_open) vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "shm_open", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1); @@ -5075,11 +5250,10 @@ POST(sys_shm_open) // int shm_unlink(const char *path); PRE(sys_shm_unlink) { - PRINT("sys_shm_unlink(%#" FMT_REGWORD "x(%s))", ARG1, (char *)ARG1); - PRE_REG_READ1(int, "shm_unlink", - const char *, path); + PRINT("sys_shm_unlink(%#" FMT_REGWORD "x(%s))", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "shm_unlink", const char*, path); - PRE_MEM_RASCIIZ( "shm_unlink(path)", ARG1 ); + PRE_MEM_RASCIIZ("shm_unlink(path)", ARG1); *flags |= SfMayBlock; } @@ -5089,14 +5263,11 @@ PRE(sys_shm_unlink) PRE(sys_cpuset) { PRINT("sys_cpuset ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "cpuset", vki_cpusetid_t *, setid); + PRE_REG_READ1(int, "cpuset", vki_cpusetid_t*, setid); PRE_MEM_WRITE("cpuset(setid)", ARG1, sizeof(vki_cpusetid_t)); } -POST(sys_cpuset) -{ - POST_MEM_WRITE(ARG1, sizeof(vki_cpusetid_t)); -} +POST(sys_cpuset) { POST_MEM_WRITE(ARG1, sizeof(vki_cpusetid_t)); } // SYS_cpuset_setid 485 // amd64 / x86 @@ -5114,50 +5285,53 @@ POST(sys_cpuset) // int faccessat(int fd, const char *path, int mode, int flag); PRE(sys_faccessat) { - PRINT("sys_faccessat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ3(int, "faccessat", - int, fd, const char *, path, int, flag); - PRE_MEM_RASCIIZ( "faccessat(path)", ARG2 ); + PRINT("sys_faccessat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ3(int, "faccessat", int, fd, const char*, path, int, flag); + PRE_MEM_RASCIIZ("faccessat(path)", ARG2); } // SYS_fchmodat 490 // int fchmodat(int fd, const char *path, mode_t mode, int flag); PRE(sys_fchmodat) { - PRINT("sys_fchmodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ4(int, "fchmodat", - int, fd, const char *, path, vki_mode_t, mode, int, flag); - PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 ); + PRINT("sys_fchmodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ4(int, "fchmodat", int, fd, const char*, path, vki_mode_t, mode, + int, flag); + PRE_MEM_RASCIIZ("fchmodat(path)", ARG2); } // SYS_fchownat 491 // int fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); PRE(sys_fchownat) { - PRINT("sys_fchownat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x, %" FMT_REGWORD "d )", - ARG1,ARG2,(char*)ARG2,ARG3,ARG4, SARG5); - PRE_REG_READ5(int, "fchownat", - int, fd, const char *, path, - vki_uid_t, owner, vki_gid_t, group, int, flag); - PRE_MEM_RASCIIZ( "fchownat(path)", ARG2 ); + PRINT("sys_fchownat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x, %" FMT_REGWORD "d )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4, SARG5); + PRE_REG_READ5(int, "fchownat", int, fd, const char*, path, vki_uid_t, owner, + vki_gid_t, group, int, flag); + PRE_MEM_RASCIIZ("fchownat(path)", ARG2); } // SYS_fexecve 492 // int fexecve(int fd, char *const argv[], char *const envp[]); PRE(sys_fexecve) { - PRINT("sys_fexecve ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - SARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fexecve", - int, fd, char * const *, argv, - char * const *, envp); + PRINT("sys_fexecve ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fexecve", int, fd, char* const*, argv, char* const*, + envp); if (!ML_(fd_allowed)(ARG1, "fexecve", tid, False)) { SET_STATUS_Failure(VKI_EBADF); return; } - const HChar *fname; + const HChar* fname; if (VG_(resolve_filename)(ARG1, &fname) == False) { SET_STATUS_Failure(VKI_ENOENT); @@ -5187,8 +5361,8 @@ PRE(sys_fexecve) Bool isScript = False; SysRes res; - res = VG_(open)(fname, VKI_O_RDONLY, - VKI_S_IRUSR|VKI_S_IRGRP|VKI_S_IROTH); + res = + VG_(open)(fname, VKI_O_RDONLY, VKI_S_IRUSR | VKI_S_IRGRP | VKI_S_IROTH); if (sr_isError(res)) { SET_STATUS_Failure(VKI_ENOENT); return; @@ -5208,7 +5382,7 @@ PRE(sys_fexecve) } } else { if (!((openFlags & VKI_O_EXEC) || - (stats.mode & (VKI_S_IXUSR|VKI_S_IXGRP|VKI_S_IXOTH)))) { + (stats.mode & (VKI_S_IXUSR | VKI_S_IXGRP | VKI_S_IXOTH)))) { SET_STATUS_Failure(VKI_EACCES); return; } @@ -5217,7 +5391,8 @@ PRE(sys_fexecve) Addr arg_2 = (Addr)ARG2; Addr arg_3 = (Addr)ARG3; - handle_pre_sys_execve(tid, status, (Addr)fname, arg_2, arg_3, FEXECVE, False); + handle_pre_sys_execve(tid, status, (Addr)fname, arg_2, arg_3, FEXECVE, + False); } // SYS_freebsd11_fstatat 493 @@ -5225,45 +5400,48 @@ PRE(sys_fexecve) #if (FREEBSD_VERS >= FREEBSD_12) PRE(sys_freebsd11_fstatat) { - PRINT("sys_freebsd11_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ4(int, "fstatat", - int, fd, const char *, path, struct freebsd11_stat *, buf, int, flag); - PRE_MEM_RASCIIZ( "fstatat(path)", ARG2 ); - PRE_MEM_WRITE( "fstatat(sb)", ARG3, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ4(int, "fstatat", int, fd, const char*, path, + struct freebsd11_stat*, buf, int, flag); + PRE_MEM_RASCIIZ("fstatat(path)", ARG2); + PRE_MEM_WRITE("fstatat(sb)", ARG3, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_fstatat) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_freebsd11_stat)); } #else PRE(sys_fstatat) { - PRINT("sys_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ4(int, "fstatat", - int, fd, const char *, path, struct stat *, buf, int, flag); - PRE_MEM_RASCIIZ( "fstatat(path)", ARG2 ); - PRE_MEM_WRITE( "fstatat(sb)", ARG3, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ4(int, "fstatat", int, fd, const char*, path, struct stat*, buf, + int, flag); + PRE_MEM_RASCIIZ("fstatat(path)", ARG2); + PRE_MEM_WRITE("fstatat(sb)", ARG3, sizeof(struct vki_freebsd11_stat)); } -POST(sys_fstatat) -{ - POST_MEM_WRITE( ARG3, sizeof(struct vki_freebsd11_stat) ); -} +POST(sys_fstatat) { POST_MEM_WRITE(ARG3, sizeof(struct vki_freebsd11_stat)); } #endif // SYS_futimesat 494 // int futimesat(int fd, const char *path, const struct timeval times[2]); PRE(sys_futimesat) { - PRINT("sys_futimesat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ3(int, "futimesat", - int, fd, const char *, path, struct timeval *, times); + PRINT("sys_futimesat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ3(int, "futimesat", int, fd, const char*, path, struct timeval*, + times); if (ARG2 != 0) { - PRE_MEM_RASCIIZ( "futimesat(path)", ARG2 ); + PRE_MEM_RASCIIZ("futimesat(path)", ARG2); } if (ARG3 != 0) { - PRE_MEM_READ( "futimesat(times)", ARG3, 2 * sizeof(struct vki_timeval) ); + PRE_MEM_READ("futimesat(times)", ARG3, 2 * sizeof(struct vki_timeval)); } } @@ -5272,13 +5450,13 @@ PRE(sys_futimesat) PRE(sys_linkat) { *flags |= SfMayBlock; - PRINT("sys_linkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )",ARG1,ARG2,(char*)ARG2,ARG3,ARG4,(char*)ARG4,ARG5); - PRE_REG_READ5(int, "linkat", - int, fd1, const char *, name1, - int, fd2, const char *, name2, - int, flag); - PRE_MEM_RASCIIZ( "linkat(name1)", ARG2); - PRE_MEM_RASCIIZ( "linkat(name2)", ARG4); + PRINT("sys_linkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4, (char*)ARG4, ARG5); + PRE_REG_READ5(int, "linkat", int, fd1, const char*, name1, int, fd2, + const char*, name2, int, flag); + PRE_MEM_RASCIIZ("linkat(name1)", ARG2); + PRE_MEM_RASCIIZ("linkat(name2)", ARG4); } // SYS_mkdirat 496 @@ -5286,21 +5464,22 @@ PRE(sys_linkat) PRE(sys_mkdirat) { *flags |= SfMayBlock; - PRINT("sys_mkdirat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ3(int, "mkdirat", - int, fd, const char *, path, int, mode); - PRE_MEM_RASCIIZ( "mkdirat(path)", ARG2 ); + PRINT("sys_mkdirat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ3(int, "mkdirat", int, fd, const char*, path, int, mode); + PRE_MEM_RASCIIZ("mkdirat(path)", ARG2); } // SYS_mkfifoat 497 // int mkfifoat(int fd, const char *path, mode_t mode); PRE(sys_mkfifoat) { - PRINT("sys_mkfifoat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", - SARG1,ARG2,(HChar*)ARG2,ARG3 ); - PRE_REG_READ3(int, "mkfifoat", - int, fd, const char *, path, vki_mode_t, mode); - PRE_MEM_RASCIIZ( "mkfifoat(path)", ARG2 ); + PRINT("sys_mkfifoat ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x(%s), 0x%" FMT_REGWORD "x )", + SARG1, ARG2, (HChar*)ARG2, ARG3); + PRE_REG_READ3(int, "mkfifoat", int, fd, const char*, path, vki_mode_t, mode); + PRE_MEM_RASCIIZ("mkfifoat(path)", ARG2); } // SYS_freebsd11_mknodat 498 @@ -5308,18 +5487,22 @@ PRE(sys_mkfifoat) #if (FREEBSD_VERS >= FREEBSD_12) PRE(sys_freebsd11_mknodat) { - PRINT("sys_freebsd11_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4 ); - PRE_REG_READ4(long, "mknodat", - int, dfd, const char *, pathname, int, mode, unsigned, dev); - PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 ); + PRINT("sys_freebsd11_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4); + PRE_REG_READ4(long, "mknodat", int, dfd, const char*, pathname, int, mode, + unsigned, dev); + PRE_MEM_RASCIIZ("mknodat(pathname)", ARG2); } #else PRE(sys_mknodat) { - PRINT("sys_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4 ); - PRE_REG_READ4(long, "mknodat", - int, dfd, const char *, pathname, int, mode, unsigned, dev); - PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 ); + PRINT("sys_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4); + PRE_REG_READ4(long, "mknodat", int, dfd, const char*, pathname, int, mode, + unsigned, dev); + PRE_MEM_RASCIIZ("mknodat(pathname)", ARG2); } #endif @@ -5330,20 +5513,24 @@ PRE(sys_openat) if (ARG3 & VKI_O_CREAT) { // 4-arg version - PRINT("sys_openat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,(char*)ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "openat", - int, fd, const char *, path, int, flags, vki_mode_t, mode); + PRINT("sys_openat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "openat", int, fd, const char*, path, int, flags, + vki_mode_t, mode); } else { // 3-arg version - PRINT("sys_openat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )",ARG1,ARG2,(char*)ARG2,ARG3); - PRE_REG_READ3(int, "openat", - int, fd, const char *, path, int, flags); + PRINT("sys_openat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u )", + ARG1, ARG2, (char*)ARG2, ARG3); + PRE_REG_READ3(int, "openat", int, fd, const char*, path, int, flags); } - if (ARG1 != (unsigned)VKI_AT_FDCWD && !ML_(fd_allowed)(ARG1, "openat", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); + if (ARG1 != (unsigned)VKI_AT_FDCWD && + !ML_(fd_allowed)(ARG1, "openat", tid, False)) { + SET_STATUS_Failure(VKI_EBADF); } else { - PRE_MEM_RASCIIZ( "openat(path)", ARG2 ); + PRE_MEM_RASCIIZ("openat(path)", ARG2); } /* Otherwise handle normally */ @@ -5355,7 +5542,7 @@ POST(sys_openat) vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "openat", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG2); @@ -5368,21 +5555,24 @@ POST(sys_openat) // size_t bufsize); PRE(sys_readlinkat) { - Word saved = SYSNO; + Word saved = SYSNO; Bool curproc_file = False; - PRINT("sys_readlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %llu )", ARG1,ARG2,(char*)ARG2,ARG3,(ULong)ARG4); - PRE_REG_READ4(ssize_t, "readlinkat", - int, fd, const char *, path, char *, buf, int, bufsize); - PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2 ); - PRE_MEM_WRITE( "readlinkat(buf)", ARG3,ARG4 ); + PRINT("sys_readlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x, %llu )", + ARG1, ARG2, (char*)ARG2, ARG3, (ULong)ARG4); + PRE_REG_READ4(ssize_t, "readlinkat", int, fd, const char*, path, char*, buf, + int, bufsize); + PRE_MEM_RASCIIZ("readlinkat(path)", ARG2); + PRE_MEM_WRITE("readlinkat(buf)", ARG3, ARG4); if (VG_(have_slash_proc) == True && (Int)ARG1 == VKI_AT_FDCWD) { /* * Handle the case where readlinkat is looking at /proc/curproc/file or * /proc//file. */ - do_readlink((const HChar *)ARG2, (HChar *)ARG3, (SizeT)ARG4, status, &curproc_file); + do_readlink((const HChar*)ARG2, (HChar*)ARG3, (SizeT)ARG4, status, + &curproc_file); } // @todo PJF there is still the case where fd refers to /proc or /proc/pid @@ -5390,28 +5580,26 @@ PRE(sys_readlinkat) if (!curproc_file) { /* Normal case */ - SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, ARG2, ARG3, ARG4)); + SET_STATUS_from_SysRes(VG_(do_syscall4)(saved, ARG1, ARG2, ARG3, ARG4)); } if (SUCCESS && RES > 0) { - POST_MEM_WRITE( ARG3, RES ); + POST_MEM_WRITE(ARG3, RES); } } -POST(sys_readlinkat) -{ - POST_MEM_WRITE( ARG3, RES ); -} +POST(sys_readlinkat) { POST_MEM_WRITE(ARG3, RES); } // SYS_renameat 501 // int renameat(int fromfd, const char *from, int tofd, const char *to); PRE(sys_renameat) { - PRINT("sys_renameat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s) )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4,(char*)ARG4); - PRE_REG_READ4(int, "renameat", - int, fromfd, const char *, from, - int, tofd, const char *, to); - PRE_MEM_RASCIIZ( "renameat(oldpath)", ARG2 ); - PRE_MEM_RASCIIZ( "renameat(newpath)", ARG4 ); + PRINT("sys_renameat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s) )", + ARG1, ARG2, (char*)ARG2, ARG3, ARG4, (char*)ARG4); + PRE_REG_READ4(int, "renameat", int, fromfd, const char*, from, int, tofd, + const char*, to); + PRE_MEM_RASCIIZ("renameat(oldpath)", ARG2); + PRE_MEM_RASCIIZ("renameat(newpath)", ARG4); } // SYS_symlinkat 502 @@ -5419,11 +5607,13 @@ PRE(sys_renameat) PRE(sys_symlinkat) { *flags |= SfMayBlock; - PRINT("sys_symlinkat ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s) )",ARG1,(char*)ARG1,ARG2,ARG3,(char*)ARG3); - PRE_REG_READ3(int, "symlinkat", - const char *, name1, int, fd, const char *, name2); - PRE_MEM_RASCIIZ( "symlinkat(name1)", ARG1 ); - PRE_MEM_RASCIIZ( "symlinkat(name2)", ARG3 ); + PRINT("sys_symlinkat ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %#" FMT_REGWORD "x(%s) )", + ARG1, (char*)ARG1, ARG2, ARG3, (char*)ARG3); + PRE_REG_READ3(int, "symlinkat", const char*, name1, int, fd, const char*, + name2); + PRE_MEM_RASCIIZ("symlinkat(name1)", ARG1); + PRE_MEM_RASCIIZ("symlinkat(name2)", ARG3); } // SYS_unlinkat 503 @@ -5431,10 +5621,11 @@ PRE(sys_symlinkat) PRE(sys_unlinkat) { *flags |= SfMayBlock; - PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u ", + PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u ", ARG1, ARG2, (char*)ARG2, ARG3); - PRE_REG_READ3(int, "unlinkat", int, fd, const char *, path, int, flag); - PRE_MEM_RASCIIZ( "unlinkat(path)", ARG2 ); + PRE_REG_READ3(int, "unlinkat", int, fd, const char*, path, int, flag); + PRE_MEM_RASCIIZ("unlinkat(path)", ARG2); } // SYS_posix_openpt 504 @@ -5454,9 +5645,11 @@ PRE(sys_posix_openpt) // int jail_get(struct iovec *iov, u_int niov, int flags); PRE(sys_jail_get) { - PRINT("sys_jail_get ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "jail_get", struct vki_iovec *, iov, unsigned int, - niov, int, flags); + PRINT("sys_jail_get ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "jail_get", struct vki_iovec*, iov, unsigned int, niov, + int, flags); PRE_MEM_READ("jail_get(iov)", ARG1, ARG2 * sizeof(struct vki_iovec)); } @@ -5464,9 +5657,11 @@ PRE(sys_jail_get) // int jail_set(struct iovec *iov, u_int niov, int flags); PRE(sys_jail_set) { - PRINT("sys_jail_set ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "jail_set", struct vki_iovec *, iov, unsigned int, - niov, int, flags); + PRINT("sys_jail_set ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "jail_set", struct vki_iovec*, iov, unsigned int, niov, + int, flags); PRE_MEM_READ("jail_set(iovs)", ARG1, ARG2 * sizeof(struct vki_iovec)); } @@ -5505,53 +5700,60 @@ PRE(sys___semctl) switch (ARG3) { case VKI_IPC_INFO: case VKI_SEM_INFO: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "semctl", - int, semid, int, semnum, int, cmd, struct seminfo *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "semctl", int, semid, int, semnum, int, cmd, + struct seminfo*, arg); break; case VKI_IPC_STAT: case VKI_SEM_STAT: case VKI_IPC_SET: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(long, "semctl", - int, semid, int, semnum, int, cmd, struct semid_ds *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(long, "semctl", int, semid, int, semnum, int, cmd, + struct semid_ds*, arg); break; case VKI_GETALL: case VKI_SETALL: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(long, "semctl", - int, semid, int, semnum, int, cmd, unsigned short *, arg); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(long, "semctl", int, semid, int, semnum, int, cmd, + unsigned short*, arg); break; default: - PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "semctl", - int, semid, int, semnum, int, cmd); + PRINT("sys_semctl ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "semctl", int, semid, int, semnum, int, cmd); break; } - ML_(generic_PRE_sys_semctl)(tid, ARG1,ARG2,ARG3,ARG4); + ML_(generic_PRE_sys_semctl)(tid, ARG1, ARG2, ARG3, ARG4); } POST(sys___semctl) { - ML_(generic_POST_sys_semctl)(tid, RES,ARG1,ARG2,ARG3,ARG4); + ML_(generic_POST_sys_semctl)(tid, RES, ARG1, ARG2, ARG3, ARG4); } // SYS_msgctl 511 // int msgctl(int msqid, int cmd, struct msqid_ds *buf); PRE(sys_msgctl) { - PRINT("sys_msgctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3 ); + PRINT("sys_msgctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD + "x )", + SARG1, SARG2, ARG3); - PRE_REG_READ3(int, "msgctl", int, msqid, int, cmd, struct msqid_ds *, buf); + PRE_REG_READ3(int, "msgctl", int, msqid, int, cmd, struct msqid_ds*, buf); switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)", - ARG3, sizeof(struct vki_msqid_ds) ); + PRE_MEM_WRITE("msgctl(IPC_STAT, buf)", ARG3, sizeof(struct vki_msqid_ds)); break; case VKI_IPC_SET: - PRE_MEM_READ( "msgctl(IPC_SET, buf)", - ARG3, sizeof(struct vki_msqid_ds) ); + PRE_MEM_READ("msgctl(IPC_SET, buf)", ARG3, sizeof(struct vki_msqid_ds)); break; } } @@ -5560,27 +5762,26 @@ POST(sys_msgctl) { switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - POST_MEM_WRITE( ARG3, sizeof(struct vki_msqid_ds) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_msqid_ds)); break; } } - // SYS_shmctl 512 // int shmctl(int shmid, int cmd, struct shmid_ds *buf); PRE(sys_shmctl) { - PRINT("sys_shmctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,SARG2,ARG3); - PRE_REG_READ3(int, "shmctl", - int, shmid, int, cmd, struct vki_shmid_ds *, buf); + PRINT("sys_shmctl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD + "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(int, "shmctl", int, shmid, int, cmd, struct vki_shmid_ds*, + buf); switch (ARG2 /* cmd */) { case VKI_IPC_STAT: - PRE_MEM_WRITE( "shmctl(IPC_STAT, buf)", - ARG3, sizeof(struct vki_shmid_ds) ); + PRE_MEM_WRITE("shmctl(IPC_STAT, buf)", ARG3, sizeof(struct vki_shmid_ds)); break; case VKI_IPC_SET: - PRE_MEM_READ( "shmctl(IPC_SET, buf)", - ARG3, sizeof(struct vki_shmid_ds) ); + PRE_MEM_READ("shmctl(IPC_SET, buf)", ARG3, sizeof(struct vki_shmid_ds)); break; } } @@ -5588,7 +5789,7 @@ PRE(sys_shmctl) POST(sys_shmctl) { if (ARG2 == VKI_IPC_STAT) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_shmid_ds) ); + POST_MEM_WRITE(ARG3, sizeof(struct vki_shmid_ds)); } } @@ -5597,7 +5798,7 @@ POST(sys_shmctl) PRE(sys_lpathconf) { PRINT("sys_lpathconf ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d)", ARG1, SARG2); - PRE_REG_READ2(long, "lpathconf", const char *, path, int, name); + PRE_REG_READ2(long, "lpathconf", const char*, path, int, name); PRE_MEM_RASCIIZ("lpathconf(path)", ARG1); } @@ -5607,15 +5808,15 @@ PRE(sys_lpathconf) // int __cap_rights_get(int version, int fd, cap_rights_t *rights); PRE(sys_cap_rights_get) { - PRINT("sys_cap_rights_get ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, SARG2, ARG3); - PRE_REG_READ3(long, "cap_rights_get", int, version, int, fd, vki_cap_rights_t*, rights); + PRINT("sys_cap_rights_get ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x )", + SARG1, SARG2, ARG3); + PRE_REG_READ3(long, "cap_rights_get", int, version, int, fd, + vki_cap_rights_t*, rights); PRE_MEM_WRITE("cap_rights_get(rights)", ARG3, sizeof(vki_cap_rights_t)); } -POST(sys_cap_rights_get) -{ - POST_MEM_WRITE(ARG2, sizeof(vki_cap_rights_t)); -} +POST(sys_cap_rights_get) { POST_MEM_WRITE(ARG2, sizeof(vki_cap_rights_t)); } // SYS_cap_enter 516 // int cap_enter(void); @@ -5629,8 +5830,11 @@ PRE(sys_cap_enter) capabiltyMode = True; VG_(umsg)( "WARNING: Valgrind may not operate correctly in capability mode.\n" - " Please consider disabling capability by using the RUNNING_ON_VALGRIND mechanism.\n" - " See http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq\n"); + " Please consider disabling capability by using the " + "RUNNING_ON_VALGRIND mechanism.\n" + " See " + "http://valgrind.org/docs/manual/" + "manual-core-adv.html#manual-core-adv.clientreq\n"); } } @@ -5643,10 +5847,7 @@ PRE(sys_cap_getmode) PRE_MEM_WRITE("cap_getmode(modep)", ARG1, sizeof(u_int)); } -POST(sys_cap_getmode) -{ - POST_MEM_WRITE(ARG1, sizeof(u_int)); -} +POST(sys_cap_getmode) { POST_MEM_WRITE(ARG1, sizeof(u_int)); } static vki_sigset_t pdfork_saved_mask; @@ -5654,8 +5855,8 @@ static vki_sigset_t pdfork_saved_mask; // pid_t pdfork(int *fdp, int flags); PRE(sys_pdfork) { - Bool is_child; - Int child_pid; + Bool is_child; + Int child_pid; vki_sigset_t mask; PRINT("sys_pdfork ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); @@ -5668,15 +5869,15 @@ PRE(sys_pdfork) VG_(do_atfork_pre)(tid); - SET_STATUS_from_SysRes( VG_(do_syscall2)(__NR_pdfork, ARG1, ARG2) ); + SET_STATUS_from_SysRes(VG_(do_syscall2)(__NR_pdfork, ARG1, ARG2)); if (!SUCCESS) { return; } // RES is 0 for child, non-0 (the child's PID) for parent. - is_child = ( RES == 0 ? True : False ); - child_pid = ( is_child ? -1 : (Int)RES ); + is_child = (RES == 0 ? True : False); + child_pid = (is_child ? -1 : (Int)RES); if (is_child) { VG_(do_atfork_child)(tid); @@ -5693,26 +5894,26 @@ PRE(sys_pdfork) } if (ARG1) { - PRE_MEM_WRITE( "pdfork(fdp)", ARG1, sizeof(int) ); + PRE_MEM_WRITE("pdfork(fdp)", ARG1, sizeof(int)); } } POST(sys_pdfork) { if (ARG1) { - POST_MEM_WRITE( ARG1, sizeof(int) ); + POST_MEM_WRITE(ARG1, sizeof(int)); } } // pdkill 519 -//int pdkill(int fd, int signum) +// int pdkill(int fd, int signum) PRE(sys_pdkill) { PRINT("sys_pdkill ( %" FMT_REGWORD "u, %" FMT_REGWORD "d )", ARG1, SARG2); PRE_REG_READ2(int, "pdkill", int, fd, int, signum); if (!ML_(client_signal_OK)(ARG2)) { - SET_STATUS_Failure( VKI_EINVAL ); + SET_STATUS_Failure(VKI_EINVAL); return; } @@ -5742,14 +5943,13 @@ PRE(sys_pdkill) SET_STATUS_from_SysRes(VG_(do_syscall2)(SYSNO, ARG1, ARG2)); if (VG_(clo_trace_signals)) { - VG_(message)(Vg_DebugMsg, "pdkill: sent signal %ld to fd %ld\n", - SARG2, SARG1); + VG_(message)(Vg_DebugMsg, "pdkill: sent signal %ld to fd %ld\n", SARG2, + SARG1); } /* This kill might have given us a pending signal. Ask for a check once the syscall is done. */ *flags |= SfPollAfter; - } // SYS_pdgetpid 520 @@ -5757,15 +5957,11 @@ PRE(sys_pdkill) PRE(sys_pdgetpid) { PRINT("pdgetpid ( %" FMT_REGWORD "d, %#lx )", SARG1, ARG2); - PRE_REG_READ2(int, "pdgetpid", - int, fd, pid_t*, pidp); - PRE_MEM_WRITE( "pdgetpid(pidp))", ARG2, sizeof(vki_pid_t) ); + PRE_REG_READ2(int, "pdgetpid", int, fd, pid_t*, pidp); + PRE_MEM_WRITE("pdgetpid(pidp))", ARG2, sizeof(vki_pid_t)); } -POST(sys_pdgetpid) -{ - POST_MEM_WRITE( ARG2, sizeof(vki_pid_t) ); -} +POST(sys_pdgetpid) { POST_MEM_WRITE(ARG2, sizeof(vki_pid_t)); } // SYS_pselect 522 @@ -5776,62 +5972,53 @@ POST(sys_pdgetpid) PRE(sys_pselect) { *flags |= SfMayBlock | SfPostOnFail; - PRINT("sys_pselect ( %ld, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" - FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + PRINT("sys_pselect ( %ld, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", SARG1, ARG2, ARG3, ARG4, ARG5, ARG6); - PRE_REG_READ6(int, "pselect", - int, nfds, vki_fd_set *, readfds, vki_fd_set *, writefds, - vki_fd_set *, exceptfds, struct vki_timespec *, timeout, - const sigset_t *, newsigmask); + PRE_REG_READ6(int, "pselect", int, nfds, vki_fd_set*, readfds, vki_fd_set*, + writefds, vki_fd_set*, exceptfds, struct vki_timespec*, + timeout, const sigset_t*, newsigmask); // XXX: this possibly understates how much memory is read. if (ARG2 != 0) { - PRE_MEM_READ( "pselect(readfds)", - ARG2, ARG1/8 /* __FD_SETSIZE/8 */ ); + PRE_MEM_READ("pselect(readfds)", ARG2, ARG1 / 8 /* __FD_SETSIZE/8 */); } if (ARG3 != 0) { - PRE_MEM_READ( "pselect(writefds)", - ARG3, ARG1/8 /* __FD_SETSIZE/8 */ ); + PRE_MEM_READ("pselect(writefds)", ARG3, ARG1 / 8 /* __FD_SETSIZE/8 */); } if (ARG4 != 0) { - PRE_MEM_READ( "pselect(exceptfds)", - ARG4, ARG1/8 /* __FD_SETSIZE/8 */ ); + PRE_MEM_READ("pselect(exceptfds)", ARG4, ARG1 / 8 /* __FD_SETSIZE/8 */); } if (ARG5 != 0) { - PRE_MEM_READ( "pselect(timeout)", ARG5, sizeof(struct vki_timeval) ); + PRE_MEM_READ("pselect(timeout)", ARG5, sizeof(struct vki_timeval)); } if (ARG6 != 0) { - PRE_MEM_READ( "pselect(sig)", ARG6, sizeof(vki_sigset_t) ); + PRE_MEM_READ("pselect(sig)", ARG6, sizeof(vki_sigset_t)); ARG6 = ML_(make_safe_mask)("syswrap.pselect.1", (Addr)ARG6); } } -POST(sys_pselect) -{ - ML_(free_safe_mask) ( (Addr)ARG6 ); -} +POST(sys_pselect) { ML_(free_safe_mask)((Addr)ARG6); } // SYS_getloginclass 523 // int getloginclass(char *name, size_t len); PRE(sys_getloginclass) { - PRINT("sys_getloginclass ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "getloginclass", char *, name, size_t, len); + PRINT("sys_getloginclass ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, + ARG2); + PRE_REG_READ2(int, "getloginclass", char*, name, size_t, len); // The buffer should be at least MAXLOGNAME bytes in length. PRE_MEM_WRITE("getloginclass(name)", ARG1, ARG2); } -POST(sys_getloginclass) -{ - POST_MEM_WRITE(ARG1, ARG2); -} +POST(sys_getloginclass) { POST_MEM_WRITE(ARG1, ARG2); } // SYS_setloginclass 524 // int setloginclass(const char *name); PRE(sys_setloginclass) { PRINT("sys_setloginclass ( %#" FMT_REGWORD "x(%s) )", ARG1, (HChar*)ARG1); - PRE_REG_READ1(int, "setloginclass", const char *, name); + PRE_REG_READ1(int, "setloginclass", const char*, name); PRE_MEM_RASCIIZ("rctl_setloginclass(name)", ARG1); } @@ -5840,68 +6027,67 @@ PRE(sys_setloginclass) // size_t outbuflen); PRE(sys_rctl_get_racct) { - PRINT("sys_rctl_get_racct ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "rctl_get_racct", const char *, inbufp, size_t, inbuflen, char *, outbufp, - size_t, outbuflen); + PRINT("sys_rctl_get_racct ( %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "rctl_get_racct", const char*, inbufp, size_t, inbuflen, + char*, outbufp, size_t, outbuflen); PRE_MEM_READ("rctl_get_racct(inbufp)", ARG1, ARG2); PRE_MEM_WRITE("rctl_get_racct(outbufp)", ARG3, ARG4); } -POST(sys_rctl_get_racct) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_rctl_get_racct) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_rctl_get_rules 526 // int rctl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp, // size_t outbuflen); PRE(sys_rctl_get_rules) { - PRINT("sys_rctl_get_rules ( %#" FMT_REGWORD "xd, %" FMT_REGWORD "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "rctl_get_rules", const char *, inbufp, size_t, inbuflen, char *, outbufp, - size_t, outbuflen); + PRINT("sys_rctl_get_rules ( %#" FMT_REGWORD "xd, %" FMT_REGWORD + "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "rctl_get_rules", const char*, inbufp, size_t, inbuflen, + char*, outbufp, size_t, outbuflen); PRE_MEM_READ("rctl_get_rules(inbufp)", ARG1, ARG2); PRE_MEM_WRITE("rctl_get_rules(outbufp)", ARG3, ARG4); } -POST(sys_rctl_get_rules) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_rctl_get_rules) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_rctl_get_limits 527 // int rctl_get_limits(const char *inbufp, size_t inbuflen, char *outbufp, // size_t outbuflen); PRE(sys_rctl_get_limits) { - PRINT("sys_rctl_get_limits ( %#" FMT_REGWORD "xd, %" FMT_REGWORD "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "rctl_get_limits", const char *, inbufp, size_t, inbuflen, char *, outbufp, - size_t, outbuflen); + PRINT("sys_rctl_get_limits ( %#" FMT_REGWORD "xd, %" FMT_REGWORD + "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "rctl_get_limits", const char*, inbufp, size_t, inbuflen, + char*, outbufp, size_t, outbuflen); PRE_MEM_READ("rctl_get_limits(inbufp)", ARG1, ARG2); PRE_MEM_WRITE("rctl_get_limits(outbufp)", ARG3, ARG4); } -POST(sys_rctl_get_limits) -{ - POST_MEM_WRITE(ARG3, ARG4); -} +POST(sys_rctl_get_limits) { POST_MEM_WRITE(ARG3, ARG4); } // SYS_rctl_add_rule 528 // int rctl_add_rule(const char *inbufp, size_t inbuflen, char *outbufp, // size_t outbuflen); PRE(sys_rctl_add_rule) { - PRINT("sys_rctl_add_rule ( %#" FMT_REGWORD "xd, %" FMT_REGWORD "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ2(int, "rctl_add_rule", const char *, inbufp, size_t, inbuflen); + PRINT("sys_rctl_add_rule ( %#" FMT_REGWORD "xd, %" FMT_REGWORD + "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ2(int, "rctl_add_rule", const char*, inbufp, size_t, inbuflen); PRE_MEM_READ("rctl_add_rule(inbufp)", ARG1, ARG2); // man page says // The outbufp and outbuflen arguments are unused - //PRE_MEM_WRITE("rctl_add_rule(outbufp)", ARG3, ARG4); + // PRE_MEM_WRITE("rctl_add_rule(outbufp)", ARG3, ARG4); } POST(sys_rctl_add_rule) { - //POST_MEM_WRITE(ARG3, ARG4); + // POST_MEM_WRITE(ARG3, ARG4); } // SYS_rctl_remove_rule 529 @@ -5909,17 +6095,20 @@ POST(sys_rctl_add_rule) // size_t outbuflen); PRE(sys_rctl_remove_rule) { - PRINT("sys_rctl_remove_rule ( %#" FMT_REGWORD "xd, %" FMT_REGWORD "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ2(int, "rctl_remove_rule", const char *, inbufp, size_t, inbuflen); + PRINT("sys_rctl_remove_rule ( %#" FMT_REGWORD "xd, %" FMT_REGWORD + "u, %#" FMT_REGWORD "xd, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ2(int, "rctl_remove_rule", const char*, inbufp, size_t, + inbuflen); PRE_MEM_READ("rctl_remove_rule(inbufp)", ARG1, ARG2); // man page says // The outbufp and outbuflen arguments are unused - //PRE_MEM_WRITE("rctl_remove_rule(outbufp)", ARG3, ARG4); + // PRE_MEM_WRITE("rctl_remove_rule(outbufp)", ARG3, ARG4); } POST(sys_rctl_remove_rule) { - //POST_MEM_WRITE(ARG3, ARG4); + // POST_MEM_WRITE(ARG3, ARG4); } // SYS_posix_fallocate 530 @@ -5932,25 +6121,29 @@ POST(sys_rctl_remove_rule) // amd64 / x86 // SYS_cap_rights_limit 533 -//int cap_rights_limit(int fd, const cap_rights_t *rights); +// int cap_rights_limit(int fd, const cap_rights_t *rights); PRE(sys_cap_rights_limit) { - PRINT("sys_cap_rights_limit ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); - PRE_REG_READ2(int, "cap_rights_limit", - int, fd, const cap_rights_t *, rights); - PRE_MEM_READ( "cap_rights_limit(rights)", ARG2, sizeof(struct vki_cap_rights) ); + PRINT("sys_cap_rights_limit ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + SARG1, ARG2); + PRE_REG_READ2(int, "cap_rights_limit", int, fd, const cap_rights_t*, rights); + PRE_MEM_READ("cap_rights_limit(rights)", ARG2, + sizeof(struct vki_cap_rights)); } // SYS_cap_ioctls_limit 534 // int cap_ioctls_limit(int fd, const unsigned long *cmds, size_t ncmds); PRE(sys_cap_ioctls_limit) { - PRINT("cap_ioctls_limit ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "cap_ioctls_limit", - int, fd, unsigned long*, rights, vki_size_t, ncmds); + PRINT("cap_ioctls_limit ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "cap_ioctls_limit", int, fd, unsigned long*, rights, + vki_size_t, ncmds); // "can be up to 256" taking that to not be inclusive - if (ARG3 < 256 ) { - PRE_MEM_READ( "cap_ioctls_limit(cmds))", ARG2, ARG3*sizeof(unsigned long) ); + if (ARG3 < 256) { + PRE_MEM_READ("cap_ioctls_limit(cmds))", ARG2, + ARG3 * sizeof(unsigned long)); } // else fail? } @@ -5959,51 +6152,53 @@ PRE(sys_cap_ioctls_limit) // int cap_ioctls_get(int fd, unsigned long *cmds, size_t maxcmds); PRE(sys_cap_ioctls_get) { - PRINT("sys_cap_ioctls_get ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", SARG1, ARG2, ARG3); - PRE_REG_READ3(int, "cap_ioctls_get", int, fd, unsigned long *, cmds, size_t, maxcmds); + PRINT("sys_cap_ioctls_get ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(int, "cap_ioctls_get", int, fd, unsigned long*, cmds, size_t, + maxcmds); if (ARG3 < 256) { - PRE_MEM_WRITE("cap_ioctls_get(cmds)", ARG2, ARG3*sizeof(unsigned long)); + PRE_MEM_WRITE("cap_ioctls_get(cmds)", ARG2, ARG3 * sizeof(unsigned long)); } } POST(sys_cap_ioctls_get) { if (ARG3 < 256) { - POST_MEM_WRITE(ARG2, ARG3*sizeof(unsigned long)); + POST_MEM_WRITE(ARG2, ARG3 * sizeof(unsigned long)); } } - // SYS_cap_fcntls_limit 536 -//int cap_fcntls_limit(int fd, uint32_t fcntlrights); +// int cap_fcntls_limit(int fd, uint32_t fcntlrights); PRE(sys_cap_fcntls_limit) { - PRINT("cap_fcntls_limit ( %" FMT_REGWORD "d, %" FMT_REGWORD "u )", SARG1, ARG2); - PRE_REG_READ2(long, "cap_fcntls_limit", - int, fd, vki_uint32_t, fcntlrights); + PRINT("cap_fcntls_limit ( %" FMT_REGWORD "d, %" FMT_REGWORD "u )", SARG1, + ARG2); + PRE_REG_READ2(long, "cap_fcntls_limit", int, fd, vki_uint32_t, fcntlrights); } // SYS_cap_fcntls_get 537 // int cap_fcntls_get(int fd, uint32_t *fcntlrightsp); PRE(sys_cap_fcntls_get) { - PRINT("sys_cap_fcntls_get ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); - PRE_REG_READ2(int, "cap_fcntls_get", int, fd, uint32_t *, fcntlrightsp); + PRINT("sys_cap_fcntls_get ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "cap_fcntls_get", int, fd, uint32_t*, fcntlrightsp); PRE_MEM_WRITE("cap_fcntls_get(fcntlrightsp)", ARG2, sizeof(uint32_t)); } -POST(sys_cap_fcntls_get) -{ - POST_MEM_WRITE(ARG2, sizeof(uint32_t)); -} +POST(sys_cap_fcntls_get) { POST_MEM_WRITE(ARG2, sizeof(uint32_t)); } // SYS_bindat 538 // int bindat(int fd, int s, const struct sockaddr *addr, socklen_t addrlen); PRE(sys_bindat) { - PRINT("sys_bindat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + PRINT("sys_bindat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", SARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(int, "bindat", int, fd, int, s, const struct vki_sockaddr *, name, vki_socklen_t, namelen); + PRE_REG_READ4(int, "bindat", int, fd, int, s, const struct vki_sockaddr*, + name, vki_socklen_t, namelen); PRE_MEM_READ("bindat(name)", ARG3, ARG4); } @@ -6011,9 +6206,11 @@ PRE(sys_bindat) // int connectat(int fd, int s, const struct sockaddr *name, socklen_t namelen); PRE(sys_connectat) { - PRINT("sys_connectat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + PRINT("sys_connectat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u )", SARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(int, "connectat", int, fd, int, s, const struct vki_sockaddr *, name, vki_socklen_t, namelen); + PRE_REG_READ4(int, "connectat", int, fd, int, s, const struct vki_sockaddr*, + name, vki_socklen_t, namelen); PRE_MEM_READ("connectat(name)", ARG3, ARG4); } @@ -6021,9 +6218,11 @@ PRE(sys_connectat) // int chflagsat(int fd, const char *path, unsigned long flags, int atflag); PRE(sys_chflagsat) { - PRINT("sys_chglagsat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d )", + PRINT("sys_chglagsat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "d )", SARG1, ARG2, ARG3, SARG4); - PRE_REG_READ4(int, "chflagsat", int, fd, const char *, path, unsigned long, flags, int, atflag); + PRE_REG_READ4(int, "chflagsat", int, fd, const char*, path, unsigned long, + flags, int, atflag); PRE_MEM_RASCIIZ("chflagsat(path)", ARG2); } @@ -6033,18 +6232,20 @@ PRE(sys_chflagsat) PRE(sys_accept4) { *flags |= SfMayBlock; - PRINT("sys_accept4 ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u)",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "accept4", - int, s, struct sockaddr *, addr, int, *addrlen, int, flags); - ML_(generic_PRE_sys_accept)(tid, ARG1,ARG2,ARG3); + PRINT("sys_accept4 ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "u)", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "accept4", int, s, struct sockaddr*, addr, int, *addrlen, + int, flags); + ML_(generic_PRE_sys_accept)(tid, ARG1, ARG2, ARG3); } POST(sys_accept4) { SysRes r; vg_assert(SUCCESS); - r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); SET_STATUS_from_SysRes(r); } @@ -6053,28 +6254,26 @@ POST(sys_accept4) PRE(sys_pipe2) { PRINT("sys_pipe2 ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "pipe2", - int *, fildes, int, flags); + PRE_REG_READ2(int, "pipe2", int*, fildes, int, flags); PRE_MEM_WRITE("pipe2(fildes)", ARG1, 2 * sizeof(int)); - } POST(sys_pipe2) { - int *fildes; + int* fildes; if (RES != 0) { return; } POST_MEM_WRITE(ARG1, 2 * sizeof(int)); - fildes = (int *)ARG1; + fildes = (int*)ARG1; if (!ML_(fd_allowed)(fildes[0], "pipe2", tid, True) || - !ML_(fd_allowed)(fildes[1], "pipe2", tid, True)) { + !ML_(fd_allowed)(fildes[1], "pipe2", tid, True)) { VG_(close)(fildes[0]); VG_(close)(fildes[1]); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, fildes[0]); ML_(record_fd_open_nameless)(tid, fildes[1]); @@ -6086,7 +6285,7 @@ POST(sys_pipe2) PRE(sys_aio_mlock) { PRINT("sys_aio_mlock ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "aio_mlock", struct vki_aiocb *, iocb); + PRE_REG_READ1(int, "aio_mlock", struct vki_aiocb*, iocb); PRE_MEM_READ("aio_mlock(iocb", ARG1, sizeof(struct vki_aiocb)); // this locks memory into RAM, don't think that we need to do // anything extra @@ -6104,30 +6303,27 @@ PRE(sys_ppoll) PRINT("sys_ppoll ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3, ARG4); - UInt i; - struct vki_pollfd* fds = (struct vki_pollfd *)(Addr)ARG1; + UInt i; + struct vki_pollfd* fds = (struct vki_pollfd*)(Addr)ARG1; *flags |= SfMayBlock | SfPostOnFail; - PRE_REG_READ4(long, "ppoll", - struct vki_pollfd *, fds, unsigned int, nfds, - struct vki_timespec *, timeout, vki_sigset_t *, newsigmask); + PRE_REG_READ4(long, "ppoll", struct vki_pollfd*, fds, unsigned int, nfds, + struct vki_timespec*, timeout, vki_sigset_t*, newsigmask); - if (ML_(safe_to_deref)(fds, ARG2*sizeof(struct vki_pollfd))) { + if (ML_(safe_to_deref)(fds, ARG2 * sizeof(struct vki_pollfd))) { for (i = 0; i < ARG2; i++) { - PRE_MEM_READ( "ppoll(fds.fd)", - (Addr)(&fds[i].fd), sizeof(fds[i].fd) ); - PRE_MEM_READ( "ppoll(fds.events)", - (Addr)(&fds[i].events), sizeof(fds[i].events) ); - PRE_MEM_WRITE( "ppoll(fds.revents)", - (Addr)(&fds[i].revents), sizeof(fds[i].revents) ); + PRE_MEM_READ("ppoll(fds.fd)", (Addr)(&fds[i].fd), sizeof(fds[i].fd)); + PRE_MEM_READ("ppoll(fds.events)", (Addr)(&fds[i].events), + sizeof(fds[i].events)); + PRE_MEM_WRITE("ppoll(fds.revents)", (Addr)(&fds[i].revents), + sizeof(fds[i].revents)); } } if (ARG3) { - PRE_MEM_READ( "ppoll(timeout)", ARG3, - sizeof(struct vki_timespec) ); + PRE_MEM_READ("ppoll(timeout)", ARG3, sizeof(struct vki_timespec)); } if (ARG4) { - PRE_MEM_READ( "ppoll(newsigmask)", ARG4, sizeof(vki_sigset_t)); + PRE_MEM_READ("ppoll(newsigmask)", ARG4, sizeof(vki_sigset_t)); ARG4 = ML_(make_safe_mask)("syswrap.ppoll.1", (Addr)ARG4); } } @@ -6135,13 +6331,13 @@ PRE(sys_ppoll) POST(sys_ppoll) { if (SUCCESS && ((Word)RES != -1)) { - UInt i; - struct vki_pollfd* ufds = (struct vki_pollfd *)(Addr)ARG1; + UInt i; + struct vki_pollfd* ufds = (struct vki_pollfd*)(Addr)ARG1; for (i = 0; i < ARG2; i++) { - POST_MEM_WRITE( (Addr)(&ufds[i].revents), sizeof(ufds[i].revents) ); + POST_MEM_WRITE((Addr)(&ufds[i].revents), sizeof(ufds[i].revents)); } } - ML_(free_safe_mask) ( (Addr)ARG4 ); + ML_(free_safe_mask)((Addr)ARG4); } // SYS_futimens 546 @@ -6149,8 +6345,8 @@ POST(sys_ppoll) PRE(sys_futimens) { PRINT("sys_futimens ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); - PRE_REG_READ2(int, "futimens", int, fd, const struct timespec *, times); - PRE_MEM_READ("futimens(times)", ARG2, 2*sizeof(struct vki_timespec)); + PRE_REG_READ2(int, "futimens", int, fd, const struct timespec*, times); + PRE_MEM_READ("futimens(times)", ARG2, 2 * sizeof(struct vki_timespec)); } // SYS_utimensat 547 @@ -6158,19 +6354,20 @@ PRE(sys_futimens) // int flag); PRE(sys_utimensat) { - PRINT("sys_utimensat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )", + PRINT("sys_utimensat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD + "x, %" FMT_REGWORD "d )", SARG1, ARG2, ARG3, SARG4); - PRE_REG_READ4(int, "utimensat", int, fd, const char *,path, const struct timespec *, times, - int, flag); + PRE_REG_READ4(int, "utimensat", int, fd, const char*, path, + const struct timespec*, times, int, flag); PRE_MEM_RASCIIZ("utimensat(path)", ARG2); - PRE_MEM_READ("utimensat(times)", ARG3, 2*sizeof(struct vki_timespec)); + PRE_MEM_READ("utimensat(times)", ARG3, 2 * sizeof(struct vki_timespec)); } // SYS_fdatasync 550 // int fdatasync(int fd); PRE(sys_fdatasync) { - PRINT("sys_fdatasync ( %" FMT_REGWORD "d )",SARG1); + PRINT("sys_fdatasync ( %" FMT_REGWORD "d )", SARG1); PRE_REG_READ1(int, "fdatasync", int, fd); } @@ -6179,59 +6376,52 @@ PRE(sys_fdatasync) // int fstat(int fd, struct stat *sb); PRE(sys_fstat) { - PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); - PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_stat) ); + PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); + PRE_REG_READ2(int, "fstat", int, fd, struct stat*, sb); + PRE_MEM_WRITE("fstat(sb)", ARG2, sizeof(struct vki_stat)); } -POST(sys_fstat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) ); -} +POST(sys_fstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_stat)); } // SYS_fstatat 552 // int fstatat(int fd, const char *path, struct stat *sb, int flag); PRE(sys_fstatat) { - PRINT("sys_fstatat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %" FMT_REGWORD "d )", SARG1,ARG2,(char*)ARG2,ARG3,SARG4); - PRE_REG_READ4(int, "fstatat", - int, fd, const char *, path, struct stat *, sb, int, flag); - PRE_MEM_RASCIIZ( "fstatat(path)", ARG2 ); - PRE_MEM_WRITE( "fstatat(sb)", ARG3, sizeof(struct vki_stat) ); + PRINT("sys_fstatat ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x, %" FMT_REGWORD "d )", + SARG1, ARG2, (char*)ARG2, ARG3, SARG4); + PRE_REG_READ4(int, "fstatat", int, fd, const char*, path, struct stat*, sb, + int, flag); + PRE_MEM_RASCIIZ("fstatat(path)", ARG2); + PRE_MEM_WRITE("fstatat(sb)", ARG3, sizeof(struct vki_stat)); } -POST(sys_fstatat) -{ - POST_MEM_WRITE( ARG3, sizeof(struct vki_stat) ); -} +POST(sys_fstatat) { POST_MEM_WRITE(ARG3, sizeof(struct vki_stat)); } // SYS_fhstat 553 // int fhstat(const fhandle_t *fhp, struct stat *sb); PRE(sys_fhstat) { - PRINT("sys_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(long, "fhstat", const vki_fhandle_t *, fhp, struct stat *, sb); - PRE_MEM_READ( "fhstat(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstat(sb)", ARG2, sizeof(struct vki_stat) ); + PRINT("sys_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(long, "fhstat", const vki_fhandle_t*, fhp, struct stat*, sb); + PRE_MEM_READ("fhstat(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstat(sb)", ARG2, sizeof(struct vki_stat)); } -POST(sys_fhstat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) ); -} +POST(sys_fhstat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_stat)); } // SYS_getdirentries 554 // ssize_t getdirentries(int fd, char *buf, size_t nbytes, off_t *basep); PRE(sys_getdirentries) { *flags |= SfMayBlock; - PRINT("sys_getdirentries ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", SARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(ssize_t, "getdirentries", - int, fd, char *, buf, - size_t, nbytes, - off_t *, basep); - PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 ); + PRINT("sys_getdirentries ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(ssize_t, "getdirentries", int, fd, char*, buf, size_t, nbytes, + off_t*, basep); + PRE_MEM_WRITE("getdirentries(buf)", ARG2, ARG3); if (ARG4) { - PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof (vki_off_t)); + PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof(vki_off_t)); } } @@ -6239,9 +6429,9 @@ POST(sys_getdirentries) { vg_assert(SUCCESS); if (RES > 0) { - POST_MEM_WRITE( ARG2, RES ); - if ( ARG4 != 0 ) { - POST_MEM_WRITE( ARG4, sizeof (vki_off_t)); + POST_MEM_WRITE(ARG2, RES); + if (ARG4 != 0) { + POST_MEM_WRITE(ARG4, sizeof(vki_off_t)); } } } @@ -6250,46 +6440,43 @@ POST(sys_getdirentries) // int statfs(const char *path, struct statfs *buf); PRE(sys_statfs) { - PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "statfs", const char *, path, struct statfs *, buf); - PRE_MEM_RASCIIZ( "statfs(path)", ARG1 ); - PRE_MEM_WRITE( "statfs(buf)", ARG2, sizeof(struct vki_statfs) ); + PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "statfs", const char*, path, struct statfs*, buf); + PRE_MEM_RASCIIZ("statfs(path)", ARG1); + PRE_MEM_WRITE("statfs(buf)", ARG2, sizeof(struct vki_statfs)); } -POST(sys_statfs) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs) ); -} +POST(sys_statfs) { POST_MEM_WRITE(ARG2, sizeof(struct vki_statfs)); } // SYS_fstatfs 556 // int fstatfs(int fd, struct statfs *buf); PRE(sys_fstatfs) { - PRINT("sys_fstatfs ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstatfs", - int, fd, struct vki_statfs *, buf); - PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_statfs) ); + PRINT("sys_fstatfs ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); + PRE_REG_READ2(int, "fstatfs", int, fd, struct vki_statfs*, buf); + PRE_MEM_WRITE("fstatfs(buf)", ARG2, sizeof(struct vki_statfs)); } -POST(sys_fstatfs) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs) ); -} +POST(sys_fstatfs) { POST_MEM_WRITE(ARG2, sizeof(struct vki_statfs)); } // SYS_getfsstat 557 // int getfsstat(struct statfs *buf, long bufsize, int mode); PRE(sys_getfsstat) { - PRINT("sys_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(long, "getfsstat", struct vki_statfs *, buf, long, len, int, flags); - PRE_MEM_WRITE( "getfsstat(buf)", ARG1, ARG2 ); + PRINT("sys_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "getfsstat", struct vki_statfs*, buf, long, len, int, + flags); + PRE_MEM_WRITE("getfsstat(buf)", ARG1, ARG2); } POST(sys_getfsstat) { vg_assert(SUCCESS); if ((Word)RES != -1) { - POST_MEM_WRITE( ARG1, RES * sizeof(struct vki_statfs) ); + POST_MEM_WRITE(ARG1, RES * sizeof(struct vki_statfs)); } } @@ -6297,17 +6484,13 @@ POST(sys_getfsstat) // int fhstatfs(const fhandle_t *fhp, struct statfs *buf); PRE(sys_fhstatfs) { - PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(long, "fhstatfs", - struct fhandle *, fhp, struct statfs *, buf); - PRE_MEM_READ( "fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle) ); - PRE_MEM_WRITE( "fhstatfs(buf)", ARG2, sizeof(struct vki_statfs) ); + PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(long, "fhstatfs", struct fhandle*, fhp, struct statfs*, buf); + PRE_MEM_READ("fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle)); + PRE_MEM_WRITE("fhstatfs(buf)", ARG2, sizeof(struct vki_statfs)); } -POST(sys_fhstatfs) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs) ); -} +POST(sys_fhstatfs) { POST_MEM_WRITE(ARG2, sizeof(struct vki_statfs)); } // SYS_mknodat 559 // x86 / amd64 @@ -6318,23 +6501,25 @@ POST(sys_fhstatfs) // const struct timespec *timeout); PRE(sys_kevent) { - PRINT("sys_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - PRE_REG_READ6(int, "kevent", - int, kq, struct vki_kevent *, changelist, int, nchanges, - struct vki_kevent *, eventlist, int, nevents, - struct timespec *, timeout); + PRINT("sys_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(int, "kevent", int, kq, struct vki_kevent*, changelist, int, + nchanges, struct vki_kevent*, eventlist, int, nevents, + struct timespec*, timeout); if (ARG2 != 0 && ARG3 != 0) { - PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent)*ARG3 ); + PRE_MEM_READ("kevent(changelist)", ARG2, + sizeof(struct vki_kevent) * ARG3); } if (ARG4 != 0 && ARG5 != 0) { - PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent)*ARG5); + PRE_MEM_WRITE("kevent(eventlist)", ARG4, + sizeof(struct vki_kevent) * ARG5); } if (ARG5 != 0) { *flags |= SfMayBlock; } if (ARG6 != 0) { - PRE_MEM_READ( "kevent(timeout)", - ARG6, sizeof(struct vki_timespec)); + PRE_MEM_READ("kevent(timeout)", ARG6, sizeof(struct vki_timespec)); } } @@ -6343,7 +6528,7 @@ POST(sys_kevent) vg_assert(SUCCESS); if ((Word)RES != -1) { if (ARG4 != 0) { - POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent)*RES) ; + POST_MEM_WRITE(ARG4, sizeof(struct vki_kevent) * RES); } } } @@ -6358,42 +6543,41 @@ POST(sys_kevent) // ssize_t getrandom(void *buf, size_t buflen, unsigned int flags); PRE(sys_getrandom) { - PRINT("sys_getrandom ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); - PRE_REG_READ3(ssize_t, "getrandom", - void *, buf, vki_size_t, buflen, unsigned int, flags); - PRE_MEM_WRITE( "getrandom(buf)", ARG1, ARG2 ); + PRINT("sys_getrandom ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(ssize_t, "getrandom", void*, buf, vki_size_t, buflen, + unsigned int, flags); + PRE_MEM_WRITE("getrandom(buf)", ARG1, ARG2); if ((ARG3 & VKI_GRND_NONBLOCK) == 0) { *flags |= SfMayBlock; } } -POST(sys_getrandom) -{ - POST_MEM_WRITE( ARG1, ARG2 ); -} +POST(sys_getrandom) { POST_MEM_WRITE(ARG1, ARG2); } // SYS_getfhat 564 // int getfhat(int fd, const char *path, fhandle_t *fhp, int flag); PRE(sys_getfhat) { - PRINT("sys_getfhat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "x, %" FMT_REGWORD "d ", SARG1, ARG2, ARG3, SARG4); - PRE_REG_READ4(int, "getfhat", int, fd, const char*, path, vki_fhandle_t*, fhp, int, flag); - PRE_MEM_RASCIIZ( "getfhat(path)", ARG2 ); + PRINT("sys_getfhat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "x, %" FMT_REGWORD "d ", + SARG1, ARG2, ARG3, SARG4); + PRE_REG_READ4(int, "getfhat", int, fd, const char*, path, vki_fhandle_t*, + fhp, int, flag); + PRE_MEM_RASCIIZ("getfhat(path)", ARG2); PRE_MEM_WRITE("getfhat(fhp)", ARG3, sizeof(vki_fhandle_t)); } -POST(sys_getfhat) -{ - POST_MEM_WRITE(ARG3, sizeof(vki_fhandle_t)); -} +POST(sys_getfhat) { POST_MEM_WRITE(ARG3, sizeof(vki_fhandle_t)); } // SYS_fhlink 565 // int fhlink(fhandle_t *fhp, const char *to); PRE(sys_fhlink) { PRINT("sys_fhlink ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); - PRE_REG_READ2(int, "fhlink", vki_fhandle_t *, fhp, const char *, to); - PRE_MEM_READ( "fhlink(fhp)", ARG1, sizeof(vki_fhandle_t)); + PRE_REG_READ2(int, "fhlink", vki_fhandle_t*, fhp, const char*, to); + PRE_MEM_READ("fhlink(fhp)", ARG1, sizeof(vki_fhandle_t)); PRE_MEM_RASCIIZ("fhlink(buf)", ARG2); } @@ -6401,9 +6585,12 @@ PRE(sys_fhlink) // int fhlinkat(fhandle_t *fhp, int tofd, const char *to); PRE(sys_fhlinkat) { - PRINT("sys_fhlinkat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "xu ", ARG1, SARG2, ARG3); - PRE_REG_READ3(int, "fhlinkat", vki_fhandle_t *, fhp, int, tofd, const char *, to); - PRE_MEM_READ( "fhlinkat(fhp)", ARG1, sizeof(vki_fhandle_t)); + PRINT("sys_fhlinkat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD + "xu ", + ARG1, SARG2, ARG3); + PRE_REG_READ3(int, "fhlinkat", vki_fhandle_t*, fhp, int, tofd, const char*, + to); + PRE_MEM_READ("fhlinkat(fhp)", ARG1, sizeof(vki_fhandle_t)); PRE_MEM_RASCIIZ("fhreadlink(to)", ARG3); } @@ -6411,16 +6598,16 @@ PRE(sys_fhlinkat) // int fhreadlink(fhandle_t *fhp, char *buf, size_t bufsize); PRE(sys_fhreadlink) { - PRINT("sys_fhreadlink ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x, %" FMT_REGWORD "u ", ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "fhreadlink", vki_fhandle_t *, fhp, char *, buf, size_t, bufsize); - PRE_MEM_READ( "fhreadlink(fhp)", ARG1, sizeof(vki_fhandle_t)); + PRINT("sys_fhreadlink ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x, %" FMT_REGWORD + "u ", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fhreadlink", vki_fhandle_t*, fhp, char*, buf, size_t, + bufsize); + PRE_MEM_READ("fhreadlink(fhp)", ARG1, sizeof(vki_fhandle_t)); PRE_MEM_WRITE("fhreadlink(buf)", ARG2, ARG3); } -POST(sys_fhreadlink) -{ - POST_MEM_WRITE(ARG2, ARG3); -} +POST(sys_fhreadlink) { POST_MEM_WRITE(ARG2, ARG3); } #endif @@ -6431,10 +6618,12 @@ POST(sys_fhreadlink) PRE(sys_funlinkat) { *flags |= SfMayBlock; - PRINT("sys_funlinkat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD"u )", + PRINT("sys_funlinkat ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD "u )", SARG1, ARG2, (char*)ARG2, ARG4, ARG5); - PRE_REG_READ4(int, "funlinkat", int, dfd, const char *, path, int, fd, int, flag); - PRE_MEM_RASCIIZ( "funlinkat(path)", ARG2 ); + PRE_REG_READ4(int, "funlinkat", int, dfd, const char*, path, int, fd, int, + flag); + PRE_MEM_RASCIIZ("funlinkat(path)", ARG2); } // SYS_copy_file_range 569 @@ -6442,54 +6631,52 @@ PRE(sys_funlinkat) // size_t len, unsigned int flags); PRE(sys_copy_file_range) { - PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)", + PRINT("sys_copy_file_range (%" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "d, %" FMT_REGWORD "d)", SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6); - PRE_REG_READ6(vki_ssize_t, "copy_file_range", - int, "infd", - vki_off_t *, "inoffp", - int, "outfd", - vki_off_t *, "outoffp", - vki_size_t, "len", - unsigned int, "flags"); + PRE_REG_READ6(vki_ssize_t, "copy_file_range", int, "infd", vki_off_t*, + "inoffp", int, "outfd", vki_off_t*, "outoffp", vki_size_t, + "len", unsigned int, "flags"); /* File descriptors are "specially" tracked by valgrind. valgrind itself uses some, so make sure someone didn't put in one of our own... */ if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) || !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); + SET_STATUS_Failure(VKI_EBADF); } else { /* Now see if the offsets are defined. PRE_MEM_READ will double check it can dereference them. */ if (ARG2 != 0) { - PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); + PRE_MEM_READ("copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); } if (ARG4 != 0) { - PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); + PRE_MEM_READ("copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); } } } - // SYS___sysctlbyname 570 // int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, // const void *newp, size_t newlen); // syscalls.master: // int __sysctlbyname(_In_reads_(namelen) const char *name, size_t namelen, // _Out_writes_bytes_opt_(*oldlenp) void *old, -// _Inout_opt_ size_t *oldlenp, _In_reads_bytes_opt_(newlen) void *new, -// size_t newlen ); +// _Inout_opt_ size_t *oldlenp, _In_reads_bytes_opt_(newlen) +// void *new, size_t newlen ); PRE(sys___sysctlbyname) { // this is very much like SYS___sysctl, instead of having an OID with length // here threre is an ascii string with length // @todo PJF factor out the common functionality of the two - PRINT("sys___sysctlbyname ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,(const char*)ARG1,ARG2,ARG3,ARG4,ARG5 ); - PRE_REG_READ6(int, "__sysctlbyname", const char *, name, vki_size_t, namelen, - void *, oldp, vki_size_t *, oldlenp, - void *, newp, vki_size_t, newlen); - + PRINT("sys___sysctlbyname ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, (const char*)ARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ6(int, "__sysctlbyname", const char*, name, vki_size_t, namelen, + void*, oldp, vki_size_t*, oldlenp, void*, newp, vki_size_t, + newlen); const char* name = (const char*)ARG1; if (ML_(safe_to_deref)(name, sizeof("kern.ps_strings")) && @@ -6500,7 +6687,7 @@ PRE(sys___sysctlbyname) } if (ML_(safe_to_deref)(name, sizeof("kern.usrstack")) && - VG_(strcmp)(name, "kern.usrstack") == 0) { + VG_(strcmp)(name, "kern.usrstack") == 0) { sysctl_kern_usrstack((SizeT*)ARG3, (SizeT*)ARG4); SET_STATUS_Success(0); } @@ -6528,17 +6715,20 @@ PRE(sys___sysctlbyname) if (ARG4 != (UWord)NULL) { if (ARG3 != (UWord)NULL) { // case 2 above - PRE_MEM_READ("__sysctlbyname(oldlenp)", (Addr)ARG4, sizeof(vki_size_t)); + PRE_MEM_READ("__sysctlbyname(oldlenp)", (Addr)ARG4, + sizeof(vki_size_t)); if (ML_(safe_to_deref)((void*)(Addr)ARG4, sizeof(vki_size_t))) { - PRE_MEM_WRITE("__sysctlbyname(oldp)", (Addr)ARG3, *(vki_size_t *)ARG4); + PRE_MEM_WRITE("__sysctlbyname(oldp)", (Addr)ARG3, + *(vki_size_t*)ARG4); } else { VG_(dmsg)("Warning: Bad oldlenp address %p in sysctlbyname\n", - (void *)(Addr)ARG4); - SET_STATUS_Failure ( VKI_EFAULT ); + (void*)(Addr)ARG4); + SET_STATUS_Failure(VKI_EFAULT); } } else { // case 1 above - PRE_MEM_WRITE("__sysctlbyname(oldlenp)", (Addr)ARG4, sizeof(vki_size_t)); + PRE_MEM_WRITE("__sysctlbyname(oldlenp)", (Addr)ARG4, + sizeof(vki_size_t)); } } } @@ -6547,8 +6737,8 @@ POST(sys___sysctlbyname) { if (ARG4 != (UWord)NULL) { if (ARG3 != (UWord)NULL) { - //POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); - POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4); + // POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); + POST_MEM_WRITE((Addr)ARG3, *(vki_size_t*)ARG4); } else { POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); } @@ -6568,19 +6758,22 @@ POST(sys___sysctlbyname) // _In_z_ const char *name); PRE(sys_shm_open2) { - PRE_REG_READ5(int, "shm_open2", - const char *, path, int, flags, vki_mode_t, mode, int, shmflags, const char*, name); + PRE_REG_READ5(int, "shm_open2", const char*, path, int, flags, vki_mode_t, + mode, int, shmflags, const char*, name); if (ARG1 == VKI_SHM_ANON) { - PRINT("sys_shm_open2(%#" FMT_REGWORD "x(SHM_ANON), %" FMT_REGWORD "u, %hu, %d, %#" FMT_REGWORD "x(%s))", + PRINT("sys_shm_open2(%#" FMT_REGWORD "x(SHM_ANON), %" FMT_REGWORD + "u, %hu, %d, %#" FMT_REGWORD "x(%s))", ARG1, ARG2, (vki_mode_t)ARG3, (Int)ARG4, ARG5, (HChar*)ARG5); } else { - PRINT("sys_shm_open2(%#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %hu, %d, %#" FMT_REGWORD "x(%s))", - ARG1, (HChar *)ARG1, ARG2, (vki_mode_t)ARG3, (Int)ARG4, ARG5, (HChar*)ARG5); - PRE_MEM_RASCIIZ( "shm_open2(path)", ARG1 ); + PRINT("sys_shm_open2(%#" FMT_REGWORD "x(%s), %" FMT_REGWORD + "u, %hu, %d, %#" FMT_REGWORD "x(%s))", + ARG1, (HChar*)ARG1, ARG2, (vki_mode_t)ARG3, (Int)ARG4, ARG5, + (HChar*)ARG5); + PRE_MEM_RASCIIZ("shm_open2(path)", ARG1); } if (ARG5) { - PRE_MEM_RASCIIZ( "shm_open2(name)", ARG5 ); + PRE_MEM_RASCIIZ("shm_open2(name)", ARG5); } *flags |= SfMayBlock; } @@ -6590,7 +6783,7 @@ POST(sys_shm_open2) vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "shm_open2", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1); @@ -6602,7 +6795,8 @@ POST(sys_shm_open2) // int sigfastblock(int cmd, void *ptr); PRE(sys_sigfastblock) { - PRINT("sys_sigfastblock ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, ARG2); + PRINT("sys_sigfastblock ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); PRE_REG_READ2(int, "sigfasblock", int, cmd, void*, ptr); } @@ -6615,18 +6809,16 @@ PRE(sys_sigfastblock) // int flags) PRE(sys___realpathat) { - PRINT("sys___realpathat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %" FMT_REGWORD "u %" FMT_REGWORD "d )", - SARG1,ARG2,(const char*)ARG2,ARG3,ARG4,SARG5 ); - PRE_REG_READ5(int, "__realpathat", int, fd, const char *, path, - char *, buf, vki_size_t, size, int, flags); + PRINT("sys___realpathat ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x(%s), %#" FMT_REGWORD "x, %" FMT_REGWORD "u %" FMT_REGWORD "d )", + SARG1, ARG2, (const char*)ARG2, ARG3, ARG4, SARG5); + PRE_REG_READ5(int, "__realpathat", int, fd, const char*, path, char*, buf, + vki_size_t, size, int, flags); PRE_MEM_RASCIIZ("__realpathat(path)", (Addr)ARG2); PRE_MEM_WRITE("__realpathat(buf)", (Addr)ARG3, ARG4); } -POST(sys___realpathat) -{ - POST_MEM_WRITE((Addr)ARG3, ARG4); -} +POST(sys___realpathat) { POST_MEM_WRITE((Addr)ARG3, ARG4); } // SYS___specialfd 577 // syscalls.master @@ -6635,9 +6827,11 @@ POST(sys___realpathat) // size_t len); PRE(sys___specialfd) { - PRINT("sys___specialfd ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", - SARG1,ARG2,(const char*)ARG2,ARG3 ); - PRE_REG_READ3(int, "__specialfd", int, type, const void *, req, vki_size_t, len); + PRINT("sys___specialfd ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x(%s), %" FMT_REGWORD "u )", + SARG1, ARG2, (const char*)ARG2, ARG3); + PRE_REG_READ3(int, "__specialfd", int, type, const void*, req, vki_size_t, + len); PRE_MEM_READ("__specialfd(req)", (Addr)ARG2, ARG3); } @@ -6649,9 +6843,10 @@ PRE(sys___specialfd) // int swapoff(const char *special, u_int flags); PRE(sys_swapoff) { - PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1, ARG2); - PRE_REG_READ2(int, "swapoff", const char *, special, u_int, flags); - PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); + PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "swapoff", const char*, special, u_int, flags); + PRE_MEM_RASCIIZ("swapoff(special)", ARG1); } #endif @@ -6661,137 +6856,137 @@ PRE(sys_swapoff) const SyscallTableEntry ML_(syscall_table)[] = { // syscall (handled specially) // 0 - BSDX_(__NR_exit, sys_exit), // 1 - BSDX_(__NR_fork, sys_fork), // 2 - GENXY(__NR_read, sys_read), // 3 + BSDX_(__NR_exit, sys_exit), // 1 + BSDX_(__NR_fork, sys_fork), // 2 + GENXY(__NR_read, sys_read), // 3 - GENX_(__NR_write, sys_write), // 4 - GENXY(__NR_open, sys_open), // 5 - GENXY(__NR_close, sys_close), // 6 - GENXY(__NR_wait4, sys_wait4), // 7 + GENX_(__NR_write, sys_write), // 4 + GENXY(__NR_open, sys_open), // 5 + GENXY(__NR_close, sys_close), // 6 + GENXY(__NR_wait4, sys_wait4), // 7 // 4.3 creat 8 - GENX_(__NR_link, sys_link), // 9 - GENX_(__NR_unlink, sys_unlink), // 10 + GENX_(__NR_link, sys_link), // 9 + GENX_(__NR_unlink, sys_unlink), // 10 // obsol execv 11 - GENX_(__NR_chdir, sys_chdir), // 12 - GENX_(__NR_fchdir, sys_fchdir), // 13 - GENX_(__NR_freebsd11_mknod, sys_mknod), // 14 - GENX_(__NR_chmod, sys_chmod), // 15 + GENX_(__NR_chdir, sys_chdir), // 12 + GENX_(__NR_fchdir, sys_fchdir), // 13 + GENX_(__NR_freebsd11_mknod, sys_mknod), // 14 + GENX_(__NR_chmod, sys_chmod), // 15 - GENX_(__NR_chown, sys_chown), // 16 - GENX_(__NR_break, sys_brk), // 17 + GENX_(__NR_chown, sys_chown), // 16 + GENX_(__NR_break, sys_brk), // 17 // freebsd 4 getfsstat 18 // 4.3 lseek 19 - GENX_(__NR_getpid, sys_getpid), // 20 - BSDX_(__NR_mount, sys_mount), // 21 - BSDX_(__NR_unmount, sys_unmount), // 22 - GENX_(__NR_setuid, sys_setuid), // 23 + GENX_(__NR_getpid, sys_getpid), // 20 + BSDX_(__NR_mount, sys_mount), // 21 + BSDX_(__NR_unmount, sys_unmount), // 22 + GENX_(__NR_setuid, sys_setuid), // 23 - GENX_(__NR_getuid, sys_getuid), // 24 - GENX_(__NR_geteuid, sys_geteuid), // 25 - BSDXY(__NR_ptrace, sys_ptrace), // 26 - BSDXY(__NR_recvmsg, sys_recvmsg), // 27 + GENX_(__NR_getuid, sys_getuid), // 24 + GENX_(__NR_geteuid, sys_geteuid), // 25 + BSDXY(__NR_ptrace, sys_ptrace), // 26 + BSDXY(__NR_recvmsg, sys_recvmsg), // 27 - BSDX_(__NR_sendmsg, sys_sendmsg), // 28 - BSDXY(__NR_recvfrom, sys_recvfrom), // 29 - BSDXY(__NR_accept, sys_accept), // 30 - BSDXY(__NR_getpeername, sys_getpeername), // 31 + BSDX_(__NR_sendmsg, sys_sendmsg), // 28 + BSDXY(__NR_recvfrom, sys_recvfrom), // 29 + BSDXY(__NR_accept, sys_accept), // 30 + BSDXY(__NR_getpeername, sys_getpeername), // 31 - BSDXY(__NR_getsockname, sys_getsockname), // 32 - GENX_(__NR_access, sys_access), // 33 - BSDX_(__NR_chflags, sys_chflags), // 34 - BSDX_(__NR_fchflags, sys_fchflags), // 35 + BSDXY(__NR_getsockname, sys_getsockname), // 32 + GENX_(__NR_access, sys_access), // 33 + BSDX_(__NR_chflags, sys_chflags), // 34 + BSDX_(__NR_fchflags, sys_fchflags), // 35 - GENX_(__NR_sync, sys_sync), // 36 - GENX_(__NR_kill, sys_kill), // 37 + GENX_(__NR_sync, sys_sync), // 36 + GENX_(__NR_kill, sys_kill), // 37 // 4.3 stat 38 - GENX_(__NR_getppid, sys_getppid), // 39 + GENX_(__NR_getppid, sys_getppid), // 39 // 4.3 lstat 40 - GENXY(__NR_dup, sys_dup), // 41 + GENXY(__NR_dup, sys_dup), // 41 - BSDXY(__NR_freebsd10_pipe, sys_pipe), // 42 - GENX_(__NR_getegid, sys_getegid), // 43 + BSDXY(__NR_freebsd10_pipe, sys_pipe), // 42 + GENX_(__NR_getegid, sys_getegid), // 43 - GENX_(__NR_profil, sys_ni_syscall), // 44 - GENX_(__NR_ktrace, sys_ni_syscall), // 45 + GENX_(__NR_profil, sys_ni_syscall), // 44 + GENX_(__NR_ktrace, sys_ni_syscall), // 45 // 4.3 sigaction 46 - GENX_(__NR_getgid, sys_getgid), // 47 + GENX_(__NR_getgid, sys_getgid), // 47 // 4.3 sigaction (int sigset) 48 - BSDXY(__NR_getlogin, sys_getlogin), // 49 - BSDX_(__NR_setlogin, sys_setlogin), // 50 - GENX_(__NR_acct, sys_acct), // 51 + BSDXY(__NR_getlogin, sys_getlogin), // 49 + BSDX_(__NR_setlogin, sys_setlogin), // 50 + GENX_(__NR_acct, sys_acct), // 51 // 4.3 sigpending 52 - GENXY(__NR_sigaltstack, sys_sigaltstack), // 53 - BSDXY(__NR_ioctl, sys_ioctl), // 54 - BSDX_(__NR_reboot, sys_reboot), // 55 + GENXY(__NR_sigaltstack, sys_sigaltstack), // 53 + BSDXY(__NR_ioctl, sys_ioctl), // 54 + BSDX_(__NR_reboot, sys_reboot), // 55 - BSDX_(__NR_revoke, sys_revoke), // 56 - GENX_(__NR_symlink, sys_symlink), // 57 - BSDX_(__NR_readlink, sys_readlink), // 58 - GENX_(__NR_execve, sys_execve), // 59 + BSDX_(__NR_revoke, sys_revoke), // 56 + GENX_(__NR_symlink, sys_symlink), // 57 + BSDX_(__NR_readlink, sys_readlink), // 58 + GENX_(__NR_execve, sys_execve), // 59 - GENX_(__NR_umask, sys_umask), // 60 - GENX_(__NR_chroot, sys_chroot), // 61 + GENX_(__NR_umask, sys_umask), // 60 + GENX_(__NR_chroot, sys_chroot), // 61 // 4.3 fstat 62 // 4.3 getgerninfo 63 // 4.3 getpagesize 64 - GENX_(__NR_msync, sys_msync), // 65 - BSDX_(__NR_vfork, sys_vfork), // 66 + GENX_(__NR_msync, sys_msync), // 65 + BSDX_(__NR_vfork, sys_vfork), // 66 // obsol vread 67 // obsol vwrite 68 - BSDX_(__NR_sbrk, sys_sbrk), // 69 + BSDX_(__NR_sbrk, sys_sbrk), // 69 // not implemented in OS sstk 70 // 4.3 mmap 71 // freebsd11 vadvise 72 - GENXY(__NR_munmap, sys_munmap), // 73 - GENXY(__NR_mprotect, sys_mprotect), // 74 - GENX_(__NR_madvise, sys_madvise), // 75 + GENXY(__NR_munmap, sys_munmap), // 73 + GENXY(__NR_mprotect, sys_mprotect), // 74 + GENX_(__NR_madvise, sys_madvise), // 75 // obsol vhangup 76 // obsol vlimit 77 - GENXY(__NR_mincore, sys_mincore), // 78 - GENXY(__NR_getgroups, sys_getgroups), // 79 + GENXY(__NR_mincore, sys_mincore), // 78 + GENXY(__NR_getgroups, sys_getgroups), // 79 - GENX_(__NR_setgroups, sys_setgroups), // 80 - GENX_(__NR_getpgrp, sys_getpgrp), // 81 - GENX_(__NR_setpgid, sys_setpgid), // 82 - GENXY(__NR_setitimer, sys_setitimer), // 83 + GENX_(__NR_setgroups, sys_setgroups), // 80 + GENX_(__NR_getpgrp, sys_getpgrp), // 81 + GENX_(__NR_setpgid, sys_setpgid), // 82 + GENXY(__NR_setitimer, sys_setitimer), // 83 // 4.3 wait 84 - BSDX_(__NR_swapon, sys_swapon), // 85 - GENXY(__NR_getitimer, sys_getitimer), // 86 + BSDX_(__NR_swapon, sys_swapon), // 85 + GENXY(__NR_getitimer, sys_getitimer), // 86 // 4.3 gethostname 87 // 4.3 sethostname 88 - BSDX_(__NR_getdtablesize, sys_getdtablesize), // 89 - GENXY(__NR_dup2, sys_dup2), // 90 + BSDX_(__NR_getdtablesize, sys_getdtablesize), // 89 + GENXY(__NR_dup2, sys_dup2), // 90 - BSDXY(__NR_fcntl, sys_fcntl), // 92 - GENX_(__NR_select, sys_select), // 93 - GENX_(__NR_fsync, sys_fsync), // 95 + BSDXY(__NR_fcntl, sys_fcntl), // 92 + GENX_(__NR_select, sys_select), // 93 + GENX_(__NR_fsync, sys_fsync), // 95 - GENX_(__NR_setpriority, sys_setpriority), // 96 - BSDXY(__NR_socket, sys_socket), // 97 - BSDX_(__NR_connect, sys_connect), // 98 + GENX_(__NR_setpriority, sys_setpriority), // 96 + BSDXY(__NR_socket, sys_socket), // 97 + BSDX_(__NR_connect, sys_connect), // 98 // 4.3 accept 99 - GENX_(__NR_getpriority, sys_getpriority), // 100 + GENX_(__NR_getpriority, sys_getpriority), // 100 // 4.3 send 101 // 4.3 recv 102 // 4.3 sigreturn 103 - BSDX_(__NR_bind, sys_bind), // 104 - BSDX_(__NR_setsockopt, sys_setsockopt), // 105 - BSDX_(__NR_listen, sys_listen), // 106 + BSDX_(__NR_bind, sys_bind), // 104 + BSDX_(__NR_setsockopt, sys_setsockopt), // 105 + BSDX_(__NR_listen, sys_listen), // 106 // obsol vtimes 107 // 4.3 sigvec 108 @@ -6804,36 +6999,36 @@ const SyscallTableEntry ML_(syscall_table)[] = { // 4.3 sendmsg 114 // 4.3 vtrace 115 - GENXY(__NR_gettimeofday, sys_gettimeofday), // 116 - GENXY(__NR_getrusage, sys_getrusage), // 117 - BSDXY(__NR_getsockopt, sys_getsockopt), // 118 + GENXY(__NR_gettimeofday, sys_gettimeofday), // 116 + GENXY(__NR_getrusage, sys_getrusage), // 117 + BSDXY(__NR_getsockopt, sys_getsockopt), // 118 - GENXY(__NR_readv, sys_readv), // 120 - GENX_(__NR_writev, sys_writev), // 121 - GENX_(__NR_settimeofday, sys_settimeofday), // 122 - GENX_(__NR_fchown, sys_fchown), // 123 + GENXY(__NR_readv, sys_readv), // 120 + GENX_(__NR_writev, sys_writev), // 121 + GENX_(__NR_settimeofday, sys_settimeofday), // 122 + GENX_(__NR_fchown, sys_fchown), // 123 - GENX_(__NR_fchmod, sys_fchmod), // 124 + GENX_(__NR_fchmod, sys_fchmod), // 124 // 4.3 recvfrom 125 - GENX_(__NR_setreuid, sys_setreuid), // 126 - GENX_(__NR_setregid, sys_setregid), // 127 + GENX_(__NR_setreuid, sys_setreuid), // 126 + GENX_(__NR_setregid, sys_setregid), // 127 - GENX_(__NR_rename, sys_rename), // 128 + GENX_(__NR_rename, sys_rename), // 128 // 4.3 truncate 129 // 4.3 ftruncate 130 - GENX_(__NR_flock, sys_flock), // 131 + GENX_(__NR_flock, sys_flock), // 131 - BSDX_(__NR_mkfifo, sys_mkfifo), // 132 - BSDX_(__NR_sendto, sys_sendto), // 133 - BSDX_(__NR_shutdown, sys_shutdown), // 134 - BSDXY(__NR_socketpair, sys_socketpair), // 135 + BSDX_(__NR_mkfifo, sys_mkfifo), // 132 + BSDX_(__NR_sendto, sys_sendto), // 133 + BSDX_(__NR_shutdown, sys_shutdown), // 134 + BSDXY(__NR_socketpair, sys_socketpair), // 135 - GENX_(__NR_mkdir, sys_mkdir), // 136 - GENX_(__NR_rmdir, sys_rmdir), // 137 - GENX_(__NR_utimes, sys_utimes), // 138 + GENX_(__NR_mkdir, sys_mkdir), // 136 + GENX_(__NR_rmdir, sys_rmdir), // 137 + GENX_(__NR_utimes, sys_utimes), // 138 // 4.2 sigreturn 139 - BSDXY(__NR_adjtime, sys_adjtime), // 140 + BSDXY(__NR_adjtime, sys_adjtime), // 140 // 4.3 getpeername 141 // 4.3 gethostid 142 // 4.3 sethostid 143 @@ -6841,9 +7036,9 @@ const SyscallTableEntry ML_(syscall_table)[] = { // 4.3 getrlimit` 144 // 4.3 setrlimit 145 // 4.3 killpg 146 - GENX_(__NR_setsid, sys_setsid), // 147 + GENX_(__NR_setsid, sys_setsid), // 147 - BSDX_(__NR_quotactl, sys_quotactl), // 148 + BSDX_(__NR_quotactl, sys_quotactl), // 148 // 4.3 quota 149 // 4.3 getsockname 150 // bsd/os sem_lock 151 @@ -6863,26 +7058,26 @@ const SyscallTableEntry ML_(syscall_table)[] = { // freebsd 4 statfs 157 // freebsd 4 fstatfs 158 - BSDXY(__NR_lgetfh, sys_lgetfh), // 160 - BSDXY(__NR_getfh, sys_getfh), // 161 + BSDXY(__NR_lgetfh, sys_lgetfh), // 160 + BSDXY(__NR_getfh, sys_getfh), // 161 #if (FREEBSD_VERS <= FREEBSD_10) BSDXY(__NR_freebsd4_getdomainname, sys_freebsd4_getdomainname), // 162 BSDX_(__NR_freebsd4_setdomainname, sys_freebsd4_setdomainname), // 163 - BSDXY(__NR_freebsd4_uname, sys_freebsd4_uname), // 164 + BSDXY(__NR_freebsd4_uname, sys_freebsd4_uname), // 164 #endif - BSDXY(__NR_sysarch, sys_sysarch), // 165 - BSDXY(__NR_rtprio, sys_rtprio), // 166 + BSDXY(__NR_sysarch, sys_sysarch), // 165 + BSDXY(__NR_rtprio, sys_rtprio), // 166 - // the following 3 seem only to be defines in a header - // semsys 169 - // msgsys 170 - // shmsys 171 +// the following 3 seem only to be defines in a header +// semsys 169 +// msgsys 170 +// shmsys 171 #if (FREEBSD_VERS <= FREEBSD_10) - BSDXY(__NR_freebsd6_pread, sys_freebsd6_pread), // 173 - BSDX_(__NR_freebsd6_pwrite, sys_freebsd6_pwrite), // 174 + BSDXY(__NR_freebsd6_pread, sys_freebsd6_pread), // 173 + BSDX_(__NR_freebsd6_pwrite, sys_freebsd6_pwrite), // 174 #endif - BSDX_(__NR_setfib, sys_setfib), // 175 + BSDX_(__NR_setfib, sys_setfib), // 175 // @todo PJF this exists on Darwin and Solaris as well // and it isn't implememented on either @@ -6894,197 +7089,197 @@ const SyscallTableEntry ML_(syscall_table)[] = { // bsd/os getdescriptor 178 // bsd/os setdescriptor 179 - GENX_(__NR_setgid, sys_setgid), // 181 - BSDX_(__NR_setegid, sys_setegid), // 182 - BSDX_(__NR_seteuid, sys_seteuid), // 183 + GENX_(__NR_setgid, sys_setgid), // 181 + BSDX_(__NR_setegid, sys_setegid), // 182 + BSDX_(__NR_seteuid, sys_seteuid), // 183 - // obs lfs_bmapv 184 - // obs lfs_markv 185 - // obs lfs_segclean 186 - // obs lfs_segwait 187 +// obs lfs_bmapv 184 +// obs lfs_markv 185 +// obs lfs_segclean 186 +// obs lfs_segwait 187 #if (FREEBSD_VERS >= FREEBSD_12) - BSDXY(__NR_freebsd11_stat, sys_freebsd11_stat), // 188 - BSDXY(__NR_freebsd11_fstat, sys_freebsd11_fstat), // 189 - BSDXY(__NR_freebsd11_lstat, sys_freebsd11_lstat), // 190 + BSDXY(__NR_freebsd11_stat, sys_freebsd11_stat), // 188 + BSDXY(__NR_freebsd11_fstat, sys_freebsd11_fstat), // 189 + BSDXY(__NR_freebsd11_lstat, sys_freebsd11_lstat), // 190 #else - BSDXY(__NR_stat, sys_stat), // 188 - BSDXY(__NR_fstat, sys_fstat), // 189 - BSDXY(__NR_lstat, sys_lstat), // 190 + BSDXY(__NR_stat, sys_stat), // 188 + BSDXY(__NR_fstat, sys_fstat), // 189 + BSDXY(__NR_lstat, sys_lstat), // 190 #endif - BSDX_(__NR_pathconf, sys_pathconf), // 191 - BSDX_(__NR_fpathconf, sys_fpathconf), // 192 - GENXY(__NR_getrlimit, sys_getrlimit), // 194 - GENX_(__NR_setrlimit, sys_setrlimit), // 195 + BSDX_(__NR_pathconf, sys_pathconf), // 191 + BSDX_(__NR_fpathconf, sys_fpathconf), // 192 + GENXY(__NR_getrlimit, sys_getrlimit), // 194 + GENX_(__NR_setrlimit, sys_setrlimit), // 195 #if (FREEBSD_VERS >= FREEBSD_12) BSDXY(__NR_freebsd11_getdirentries, sys_freebsd11_getdirentries), // 196 #else - BSDXY(__NR_getdirentries, sys_getdirentries), // 196 + BSDXY(__NR_getdirentries, sys_getdirentries), // 196 #endif #if (FREEBSD_VERS <= FREEBSD_10) - BSDX_(__NR_freebsd6_mmap, sys_freebsd6_mmap), // 197 + BSDX_(__NR_freebsd6_mmap, sys_freebsd6_mmap), // 197 #endif - // __syscall (handled specially) // 198 +// __syscall (handled specially) // 198 #if (FREEBSD_VERS <= FREEBSD_10) - BSDX_(__NR_freebsd6_lseek, sys_freebsd6_lseek), // 199 - BSDX_(__NR_freebsd6_truncate, sys_freebsd6_truncate), // 200 + BSDX_(__NR_freebsd6_lseek, sys_freebsd6_lseek), // 199 + BSDX_(__NR_freebsd6_truncate, sys_freebsd6_truncate), // 200 BSDX_(__NR_freebsd6_ftruncate, sys_freebsd6_ftruncate), // 201 #endif - BSDXY(__NR___sysctl, sys___sysctl), // 202 - GENX_(__NR_mlock, sys_mlock), // 203 + BSDXY(__NR___sysctl, sys___sysctl), // 202 + GENX_(__NR_mlock, sys_mlock), // 203 - GENX_(__NR_munlock, sys_munlock), // 204 - BSDX_(__NR_undelete, sys_undelete), // 205 - BSDX_(__NR_futimes, sys_futimes), // 206 - GENX_(__NR_getpgid, sys_getpgid), // 207 + GENX_(__NR_munlock, sys_munlock), // 204 + BSDX_(__NR_undelete, sys_undelete), // 205 + BSDX_(__NR_futimes, sys_futimes), // 206 + GENX_(__NR_getpgid, sys_getpgid), // 207 // netbsd newreboot 208 - GENXY(__NR_poll, sys_poll), // 209 + GENXY(__NR_poll, sys_poll), // 209 BSDXY(__NR_freebsd7___semctl, sys_freebsd7___semctl), // 220 - BSDX_(__NR_semget, sys_semget), // 221 - BSDX_(__NR_semop, sys_semop), // 222 + BSDX_(__NR_semget, sys_semget), // 221 + BSDX_(__NR_semop, sys_semop), // 222 // obs semconfig 223 - BSDXY(__NR_freebsd7_msgctl, sys_freebsd7_msgctl), // 224 - BSDX_(__NR_msgget, sys_msgget), // 225 - BSDX_(__NR_msgsnd, sys_msgsnd), // 226 - BSDXY(__NR_msgrcv, sys_msgrcv), // 227 - - BSDXY(__NR_shmat, sys_shmat), // 228 - BSDXY(__NR_freebsd7_shmctl, sys_freebsd7_shmctl), // 229 - BSDXY(__NR_shmdt, sys_shmdt), // 230 - BSDX_(__NR_shmget, sys_shmget), // 231 - - BSDXY(__NR_clock_gettime, sys_clock_gettime), // 232 - BSDX_(__NR_clock_settime, sys_clock_settime), // 233 - BSDXY(__NR_clock_getres, sys_clock_getres), // 234 - BSDXY(__NR_ktimer_create, sys_timer_create), // 235 - BSDX_(__NR_ktimer_delete, sys_timer_delete), // 236 - BSDXY(__NR_ktimer_settime, sys_timer_settime), // 237 - BSDXY(__NR_ktimer_gettime, sys_timer_gettime), // 238 + BSDXY(__NR_freebsd7_msgctl, sys_freebsd7_msgctl), // 224 + BSDX_(__NR_msgget, sys_msgget), // 225 + BSDX_(__NR_msgsnd, sys_msgsnd), // 226 + BSDXY(__NR_msgrcv, sys_msgrcv), // 227 + + BSDXY(__NR_shmat, sys_shmat), // 228 + BSDXY(__NR_freebsd7_shmctl, sys_freebsd7_shmctl), // 229 + BSDXY(__NR_shmdt, sys_shmdt), // 230 + BSDX_(__NR_shmget, sys_shmget), // 231 + + BSDXY(__NR_clock_gettime, sys_clock_gettime), // 232 + BSDX_(__NR_clock_settime, sys_clock_settime), // 233 + BSDXY(__NR_clock_getres, sys_clock_getres), // 234 + BSDXY(__NR_ktimer_create, sys_timer_create), // 235 + BSDX_(__NR_ktimer_delete, sys_timer_delete), // 236 + BSDXY(__NR_ktimer_settime, sys_timer_settime), // 237 + BSDXY(__NR_ktimer_gettime, sys_timer_gettime), // 238 BSDX_(__NR_ktimer_getoverrun, sys_timer_getoverrun), // 239 - GENXY(__NR_nanosleep, sys_nanosleep), // 240 + GENXY(__NR_nanosleep, sys_nanosleep), // 240 // unimpl SYS_ffclock_getcounter 241 // unimpl SYS_ffclock_setestimate 242 // unimpl SYS_ffclock_getestimate 243 - BSDXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 244 + BSDXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 244 BSDXY(__NR_clock_getcpuclockid2, sys_clock_getcpuclockid2), // 247 // unimpl SYS_ntp_gettime 248 - BSDXY(__NR_minherit, sys_minherit), // 250 - BSDX_(__NR_rfork, sys_rfork), // 251 + BSDXY(__NR_minherit, sys_minherit), // 250 + BSDX_(__NR_rfork, sys_rfork), // 251 // openbsd_poll // 252 - BSDX_(__NR_issetugid, sys_issetugid), // 253 - GENX_(__NR_lchown, sys_lchown), // 254 - BSDXY(__NR_aio_read, sys_aio_read), // 255 - BSDXY(__NR_aio_write, sys_aio_write), // 256 - BSDX_(__NR_lio_listio, sys_lio_listio), // 257 - - GENXY(__NR_freebsd11_getdents, sys_getdents), // 272 - BSDX_(__NR_lchmod, sys_lchmod), // 274 + BSDX_(__NR_issetugid, sys_issetugid), // 253 + GENX_(__NR_lchown, sys_lchown), // 254 + BSDXY(__NR_aio_read, sys_aio_read), // 255 + BSDXY(__NR_aio_write, sys_aio_write), // 256 + BSDX_(__NR_lio_listio, sys_lio_listio), // 257 + + GENXY(__NR_freebsd11_getdents, sys_getdents), // 272 + BSDX_(__NR_lchmod, sys_lchmod), // 274 // netbsd_lchown // 275 - BSDX_(__NR_lutimes, sys_lutimes), // 276 + BSDX_(__NR_lutimes, sys_lutimes), // 276 // netbsd msync 277 // unimpl SYS_freebsd11_nstat 278 // unimpl SYS_freebsd11_nfstat 279 // unimpl SYS_freebsd11_nlstat 280 - BSDXY(__NR_preadv, sys_preadv), // 289 - BSDX_(__NR_pwritev, sys_pwritev), // 290 + BSDXY(__NR_preadv, sys_preadv), // 289 + BSDX_(__NR_pwritev, sys_pwritev), // 290 // freebsd 4 fhstatfs 297 - BSDXY(__NR_fhopen, sys_fhopen), // 298 + BSDXY(__NR_fhopen, sys_fhopen), // 298 #if (FREEBSD_VERS >= FREEBSD_12) - BSDXY(__NR_freebsd11_fhstat, sys_freebsd11_fhstat), // 299 + BSDXY(__NR_freebsd11_fhstat, sys_freebsd11_fhstat), // 299 #else - BSDXY(__NR_fhstat, sys_fhstat), // 299 + BSDXY(__NR_fhstat, sys_fhstat), // 299 #endif - BSDX_(__NR_modnext, sys_modnext), // 300 - BSDXY(__NR_modstat, sys_modstat), // 301 - BSDX_(__NR_modfnext, sys_modfnext), // 302 - BSDX_(__NR_modfind, sys_modfind), // 303 + BSDX_(__NR_modnext, sys_modnext), // 300 + BSDXY(__NR_modstat, sys_modstat), // 301 + BSDX_(__NR_modfnext, sys_modfnext), // 302 + BSDX_(__NR_modfind, sys_modfind), // 303 - BSDX_(__NR_kldload, sys_kldload), // 304 - BSDX_(__NR_kldunload, sys_kldunload), // 305 - BSDX_(__NR_kldfind, sys_kldfind), // 306 - BSDX_(__NR_kldnext, sys_kldnext), // 307 + BSDX_(__NR_kldload, sys_kldload), // 304 + BSDX_(__NR_kldunload, sys_kldunload), // 305 + BSDX_(__NR_kldfind, sys_kldfind), // 306 + BSDX_(__NR_kldnext, sys_kldnext), // 307 - BSDXY(__NR_kldstat, sys_kldstat), // 308 - BSDX_(__NR_kldfirstmod, sys_kldfirstmod), // 309 - GENX_(__NR_getsid, sys_getsid), // 310 - BSDX_(__NR_setresuid, sys_setresuid), // 311 + BSDXY(__NR_kldstat, sys_kldstat), // 308 + BSDX_(__NR_kldfirstmod, sys_kldfirstmod), // 309 + GENX_(__NR_getsid, sys_getsid), // 310 + BSDX_(__NR_setresuid, sys_setresuid), // 311 - BSDX_(__NR_setresgid, sys_setresgid), // 312 + BSDX_(__NR_setresgid, sys_setresgid), // 312 // obsol signanosleep 313 - BSDX_(__NR_aio_return, sys_aio_return), // 314 - BSDX_(__NR_aio_suspend, sys_aio_suspend), // 315 + BSDX_(__NR_aio_return, sys_aio_return), // 314 + BSDX_(__NR_aio_suspend, sys_aio_suspend), // 315 - BSDX_(__NR_aio_cancel, sys_aio_cancel), // 316 - BSDX_(__NR_aio_error, sys_aio_error), // 317 + BSDX_(__NR_aio_cancel, sys_aio_cancel), // 316 + BSDX_(__NR_aio_error, sys_aio_error), // 317 // freebsd 6 aio_read 318 // freebsd 6 aio_write 319 // freebsd 6 lio_listio 320 - BSDX_(__NR_yield, sys_yield), // 321 + BSDX_(__NR_yield, sys_yield), // 321 // obs thr_sleep 322 // obs thr_wakeup 323 - GENX_(__NR_mlockall, sys_mlockall), // 324 - BSDX_(__NR_munlockall, sys_munlockall), // 325 - BSDXY(__NR___getcwd, sys___getcwd), // 326 - BSDX_(__NR_sched_setparam, sys_sched_setparam), // 327 - BSDXY(__NR_sched_getparam, sys_sched_getparam), // 328 + GENX_(__NR_mlockall, sys_mlockall), // 324 + BSDX_(__NR_munlockall, sys_munlockall), // 325 + BSDXY(__NR___getcwd, sys___getcwd), // 326 + BSDX_(__NR_sched_setparam, sys_sched_setparam), // 327 + BSDXY(__NR_sched_getparam, sys_sched_getparam), // 328 BSDX_(__NR_sched_setscheduler, sys_sched_setscheduler), // 329 BSDX_(__NR_sched_getscheduler, sys_sched_getscheduler), // 330 - BSDX_(__NR_sched_yield, sys_sched_yield), // 331 + BSDX_(__NR_sched_yield, sys_sched_yield), // 331 BSDX_(__NR_sched_get_priority_max, sys_sched_get_priority_max), // 332 BSDX_(__NR_sched_get_priority_min, sys_sched_get_priority_min), // 333 - BSDXY(__NR_sched_rr_get_interval, sys_sched_rr_get_interval), // 334 - BSDX_(__NR_utrace, sys_utrace), // 335 + BSDXY(__NR_sched_rr_get_interval, sys_sched_rr_get_interval), // 334 + BSDX_(__NR_utrace, sys_utrace), // 335 // freebsd 4 sendfile 336 - BSDXY(__NR_kldsym, sys_kldsym), // 337 - BSDX_(__NR_jail, sys_jail), // 338 + BSDXY(__NR_kldsym, sys_kldsym), // 337 + BSDX_(__NR_jail, sys_jail), // 338 // unimpl SYS_nnpfs_syscall 339 - BSDXY(__NR_sigprocmask, sys_sigprocmask), // 340 - BSDXY(__NR_sigsuspend, sys_sigsuspend), // 341 + BSDXY(__NR_sigprocmask, sys_sigprocmask), // 340 + BSDXY(__NR_sigsuspend, sys_sigsuspend), // 341 // freebsd 4 sigaction 342 - BSDXY(__NR_sigpending, sys_sigpending), // 343 + BSDXY(__NR_sigpending, sys_sigpending), // 343 // freebsd 4 sigreturn 344 - BSDXY(__NR_sigtimedwait, sys_sigtimedwait), // 345 - BSDXY(__NR_sigwaitinfo, sys_sigwaitinfo), // 346 - BSDXY(__NR___acl_get_file, sys___acl_get_file), // 347 + BSDXY(__NR_sigtimedwait, sys_sigtimedwait), // 345 + BSDXY(__NR_sigwaitinfo, sys_sigwaitinfo), // 346 + BSDXY(__NR___acl_get_file, sys___acl_get_file), // 347 - BSDX_(__NR___acl_set_file, sys___acl_set_file), // 348 - BSDXY(__NR___acl_get_fd, sys___acl_get_fd), // 349 - BSDX_(__NR___acl_set_fd, sys___acl_set_fd), // 350 + BSDX_(__NR___acl_set_file, sys___acl_set_file), // 348 + BSDXY(__NR___acl_get_fd, sys___acl_get_fd), // 349 + BSDX_(__NR___acl_set_fd, sys___acl_set_fd), // 350 BSDX_(__NR___acl_delete_file, sys___acl_delete_file), // 351 - BSDX_(__NR___acl_delete_fd, sys___acl_delete_fd), // 352 + BSDX_(__NR___acl_delete_fd, sys___acl_delete_fd), // 352 BSDX_(__NR___acl_aclcheck_file, sys___acl_aclcheck_file), // 353 - BSDX_(__NR___acl_aclcheck_fd, sys___acl_aclcheck_fd), // 354 - BSDX_(__NR_extattrctl, sys_extattrctl), // 355 - BSDX_(__NR_extattr_set_file, sys_extattr_set_file), // 356 - BSDXY(__NR_extattr_get_file, sys_extattr_get_file), // 357 + BSDX_(__NR___acl_aclcheck_fd, sys___acl_aclcheck_fd), // 354 + BSDX_(__NR_extattrctl, sys_extattrctl), // 355 + BSDX_(__NR_extattr_set_file, sys_extattr_set_file), // 356 + BSDXY(__NR_extattr_get_file, sys_extattr_get_file), // 357 BSDX_(__NR_extattr_delete_file, sys_extattr_delete_file), // 358 - BSDXY(__NR_aio_waitcomplete, sys_aio_waitcomplete), // 359 + BSDXY(__NR_aio_waitcomplete, sys_aio_waitcomplete), // 359 - BSDXY(__NR_getresuid, sys_getresuid), // 360 - BSDXY(__NR_getresgid, sys_getresgid), // 361 - BSDXY(__NR_kqueue, sys_kqueue), // 362 + BSDXY(__NR_getresuid, sys_getresuid), // 360 + BSDXY(__NR_getresgid, sys_getresgid), // 361 + BSDXY(__NR_kqueue, sys_kqueue), // 362 #if (FREEBSD_VERS >= FREEBSD_12) - BSDXY(__NR_freebsd11_kevent, sys_freebsd11_kevent), // 363 + BSDXY(__NR_freebsd11_kevent, sys_freebsd11_kevent), // 363 #else - BSDXY(__NR_kevent, sys_kevent), // 363 + BSDXY(__NR_kevent, sys_kevent), // 363 #endif // obs __cap_get_proc 364 // obs __cap_set_proc 365 @@ -7093,15 +7288,15 @@ const SyscallTableEntry ML_(syscall_table)[] = { // obs __cap_set_fd 368 // obs __cap_set_file 369 - BSDX_(__NR_extattr_set_fd, sys_extattr_set_fd), // 371 - BSDXY(__NR_extattr_get_fd, sys_extattr_get_fd), // 372 + BSDX_(__NR_extattr_set_fd, sys_extattr_set_fd), // 371 + BSDXY(__NR_extattr_get_fd, sys_extattr_get_fd), // 372 BSDX_(__NR_extattr_delete_fd, sys_extattr_delete_fd), // 373 - BSDX_(__NR___setugid, sys___setugid), // 374 + BSDX_(__NR___setugid, sys___setugid), // 374 // obs nfsclnt 375 - BSDX_(__NR_eaccess, sys_eaccess), // 376 + BSDX_(__NR_eaccess, sys_eaccess), // 376 // unimpl afs3_syscall 377 - BSDX_(__NR_nmount, sys_nmount), // 378 + BSDX_(__NR_nmount, sys_nmount), // 378 // obs kse_exit 379 // obs kse_wakeup 380 // obs kse_create 381 @@ -7114,23 +7309,23 @@ const SyscallTableEntry ML_(syscall_table)[] = { // unimpl __mac_get_file 387 // unimpl __mac_set_fd 388 // unimpl __mac_set_file 389 - BSDXY(__NR_kenv, sys_kenv), // 390 - BSDX_(__NR_lchflags, sys_lchflags), // 391 + BSDXY(__NR_kenv, sys_kenv), // 390 + BSDX_(__NR_lchflags, sys_lchflags), // 391 - BSDXY(__NR_uuidgen, sys_uuidgen), // 392 - BSDXY(__NR_sendfile, sys_sendfile), // 393 - // unimpl mac_syscall 394 + BSDXY(__NR_uuidgen, sys_uuidgen), // 392 + BSDXY(__NR_sendfile, sys_sendfile), // 393 +// unimpl mac_syscall 394 #if (FREEBSD_VERS >= FREEBSD_12) BSDXY(__NR_freebsd11_getfsstat, sys_freebsd11_getfsstat), // 395 - BSDXY(__NR_freebsd11_statfs, sys_statfs), // 396 - BSDXY(__NR_freebsd11_fstatfs, sys_fstatfs), // 397 - BSDXY(__NR_freebsd11_fhstatfs, sys_fhstatfs), // 398 + BSDXY(__NR_freebsd11_statfs, sys_statfs), // 396 + BSDXY(__NR_freebsd11_fstatfs, sys_fstatfs), // 397 + BSDXY(__NR_freebsd11_fhstatfs, sys_fhstatfs), // 398 #else - BSDXY(__NR_getfsstat, sys_getfsstat), // 395 - BSDXY(__NR_statfs, sys_statfs), // 396 - BSDXY(__NR_fstatfs, sys_fstatfs), // 397 - BSDXY(__NR_fhstatfs, sys_fhstatfs), // 398 + BSDXY(__NR_getfsstat, sys_getfsstat), // 395 + BSDXY(__NR_statfs, sys_statfs), // 396 + BSDXY(__NR_fstatfs, sys_fstatfs), // 397 + BSDXY(__NR_fhstatfs, sys_fhstatfs), // 398 #endif // unimpl ksem_close 400 @@ -7148,49 +7343,49 @@ const SyscallTableEntry ML_(syscall_table)[] = { // unimpl __mac_get_link 410 // unimpl __mac_set_link 411 - BSDX_(__NR_extattr_set_link, sys_extattr_set_link), // 412 - BSDXY(__NR_extattr_get_link, sys_extattr_get_link), // 413 + BSDX_(__NR_extattr_set_link, sys_extattr_set_link), // 412 + BSDXY(__NR_extattr_get_link, sys_extattr_get_link), // 413 BSDX_(__NR_extattr_delete_link, sys_extattr_delete_link), // 414 // unimpl __mac_execve 415 - BSDXY(__NR_sigaction, sys_sigaction), // 416 - BSDX_(__NR_sigreturn, sys_sigreturn), // 417 + BSDXY(__NR_sigaction, sys_sigaction), // 416 + BSDX_(__NR_sigreturn, sys_sigreturn), // 417 - BSDXY(__NR_getcontext, sys_getcontext), // 421 - BSDX_(__NR_setcontext, sys_setcontext), // 422 - BSDXY(__NR_swapcontext, sys_swapcontext), // 423 + BSDXY(__NR_getcontext, sys_getcontext), // 421 + BSDX_(__NR_setcontext, sys_setcontext), // 422 + BSDXY(__NR_swapcontext, sys_swapcontext), // 423 #if (FREEBSD_VERS >= FREEBSD_13_1) BSDX_(__NR_freebsd13_swapoff, sys_freebsd13_swapoff), // 424 #else - BSDX_(__NR_swapoff, sys_swapoff), // 424 + BSDX_(__NR_swapoff, sys_swapoff), // 424 #endif - BSDXY(__NR___acl_get_link, sys___acl_get_link), // 425 - BSDX_(__NR___acl_set_link, sys___acl_set_link), // 426 + BSDXY(__NR___acl_get_link, sys___acl_get_link), // 425 + BSDX_(__NR___acl_set_link, sys___acl_set_link), // 426 BSDX_(__NR___acl_delete_link, sys___acl_delete_link), // 427 BSDX_(__NR___acl_aclcheck_link, sys___acl_aclcheck_link), // 428 - BSDXY(__NR_sigwait, sys_sigwait), // 429 - BSDX_(__NR_thr_create, sys_thr_create), // 430 - BSDX_(__NR_thr_exit, sys_thr_exit), // 431 + BSDXY(__NR_sigwait, sys_sigwait), // 429 + BSDX_(__NR_thr_create, sys_thr_create), // 430 + BSDX_(__NR_thr_exit, sys_thr_exit), // 431 - BSDXY(__NR_thr_self, sys_thr_self), // 432 - BSDXY(__NR_thr_kill, sys_thr_kill), // 433 + BSDXY(__NR_thr_self, sys_thr_self), // 432 + BSDXY(__NR_thr_kill, sys_thr_kill), // 433 #if (FREEBSD_VERS <= FREEBSD_10) - BSDXY(__NR__umtx_lock, sys__umtx_lock), // 434 - BSDXY(__NR__umtx_unlock, sys__umtx_unlock), // 435 + BSDXY(__NR__umtx_lock, sys__umtx_lock), // 434 + BSDXY(__NR__umtx_unlock, sys__umtx_unlock), // 435 #endif - BSDX_(__NR_jail_attach, sys_jail_attach), // 436 - BSDXY(__NR_extattr_list_fd, sys_extattr_list_fd), // 437 + BSDX_(__NR_jail_attach, sys_jail_attach), // 436 + BSDXY(__NR_extattr_list_fd, sys_extattr_list_fd), // 437 BSDXY(__NR_extattr_list_file, sys_extattr_list_file), // 438 BSDXY(__NR_extattr_list_link, sys_extattr_list_link), // 439 // obs kse_switchin 440 // unimpl ksem_timedwait 441 - BSDX_(__NR_thr_suspend, sys_thr_suspend), // 442 - BSDX_(__NR_thr_wake, sys_thr_wake), // 443 - BSDX_(__NR_kldunloadf, sys_kldunloadf), // 444 + BSDX_(__NR_thr_suspend, sys_thr_suspend), // 442 + BSDX_(__NR_thr_wake, sys_thr_wake), // 443 + BSDX_(__NR_kldunloadf, sys_kldunloadf), // 444 // unimpl audit 445 // unimpl auditon 446 // unimpl getauid 447 @@ -7201,121 +7396,121 @@ const SyscallTableEntry ML_(syscall_table)[] = { // unimpl getaudit_addr 451 // unimpl setaudit_addr 452 // unimpl auditctl 453 - BSDXY(__NR__umtx_op, sys__umtx_op), // 454 - BSDX_(__NR_thr_new, sys_thr_new), // 455 + BSDXY(__NR__umtx_op, sys__umtx_op), // 454 + BSDX_(__NR_thr_new, sys_thr_new), // 455 - BSDX_(__NR_sigqueue, sys_sigqueue), // 456 - BSDXY(__NR_kmq_open, sys_kmq_open), // 457 - BSDX_(__NR_kmq_setattr, sys_kmq_setattr), // 458 - BSDXY(__NR_kmq_timedreceive, sys_kmq_timedreceive), // 459 + BSDX_(__NR_sigqueue, sys_sigqueue), // 456 + BSDXY(__NR_kmq_open, sys_kmq_open), // 457 + BSDX_(__NR_kmq_setattr, sys_kmq_setattr), // 458 + BSDXY(__NR_kmq_timedreceive, sys_kmq_timedreceive), // 459 - BSDX_(__NR_kmq_timedsend, sys_kmq_timedsend), // 460 - BSDX_(__NR_kmq_notify, sys_kmq_notify), // 461 - BSDX_(__NR_kmq_unlink, sys_kmq_unlink), // 462 - BSDX_(__NR_abort2, sys_abort2), // 463 + BSDX_(__NR_kmq_timedsend, sys_kmq_timedsend), // 460 + BSDX_(__NR_kmq_notify, sys_kmq_notify), // 461 + BSDX_(__NR_kmq_unlink, sys_kmq_unlink), // 462 + BSDX_(__NR_abort2, sys_abort2), // 463 - BSDX_(__NR_thr_set_name, sys_thr_set_name), // 464 - BSDX_(__NR_aio_fsync, sys_aio_fsync), // 465 - BSDXY(__NR_rtprio_thread, sys_rtprio_thread), // 466 + BSDX_(__NR_thr_set_name, sys_thr_set_name), // 464 + BSDX_(__NR_aio_fsync, sys_aio_fsync), // 465 + BSDXY(__NR_rtprio_thread, sys_rtprio_thread), // 466 // unimpl sctp_peeloff 471 BSDX_(__NR_sctp_generic_sendmsg, sys_sctp_generic_sendmsg), // 472 // unimpl sctp_generic_sendmsg_iov 473 BSDXY(__NR_sctp_generic_recvmsg, sys_sctp_generic_recvmsg), // 474 - BSDXY(__NR_pread, sys_pread), // 475 + BSDXY(__NR_pread, sys_pread), // 475 - BSDX_(__NR_pwrite, sys_pwrite), // 476 - BSDX_(__NR_mmap, sys_mmap), // 477 - BSDX_(__NR_lseek, sys_lseek), // 478 - BSDX_(__NR_truncate, sys_truncate), // 479 - BSDX_(__NR_ftruncate, sys_ftruncate), // 480 - BSDXY(__NR_thr_kill2, sys_thr_kill2), // 481 - BSDXY(__NR_shm_open, sys_shm_open), // 482 - BSDX_(__NR_shm_unlink, sys_shm_unlink), // 483 + BSDX_(__NR_pwrite, sys_pwrite), // 476 + BSDX_(__NR_mmap, sys_mmap), // 477 + BSDX_(__NR_lseek, sys_lseek), // 478 + BSDX_(__NR_truncate, sys_truncate), // 479 + BSDX_(__NR_ftruncate, sys_ftruncate), // 480 + BSDXY(__NR_thr_kill2, sys_thr_kill2), // 481 + BSDXY(__NR_shm_open, sys_shm_open), // 482 + BSDX_(__NR_shm_unlink, sys_shm_unlink), // 483 - BSDXY(__NR_cpuset, sys_cpuset), // 484 - BSDX_(__NR_cpuset_setid, sys_cpuset_setid), // 485 - BSDXY(__NR_cpuset_getid, sys_cpuset_getid), // 486 + BSDXY(__NR_cpuset, sys_cpuset), // 484 + BSDX_(__NR_cpuset_setid, sys_cpuset_setid), // 485 + BSDXY(__NR_cpuset_getid, sys_cpuset_getid), // 486 BSDXY(__NR_cpuset_getaffinity, sys_cpuset_getaffinity), // 487 BSDX_(__NR_cpuset_setaffinity, sys_cpuset_setaffinity), // 488 - BSDX_(__NR_faccessat, sys_faccessat), // 489 - BSDX_(__NR_fchmodat, sys_fchmodat), // 490 - BSDX_(__NR_fchownat, sys_fchownat), // 491 + BSDX_(__NR_faccessat, sys_faccessat), // 489 + BSDX_(__NR_fchmodat, sys_fchmodat), // 490 + BSDX_(__NR_fchownat, sys_fchownat), // 491 - BSDX_(__NR_fexecve, sys_fexecve), // 492 + BSDX_(__NR_fexecve, sys_fexecve), // 492 #if (FREEBSD_VERS >= FREEBSD_12) BSDXY(__NR_freebsd11_fstatat, sys_freebsd11_fstatat), // 493 #else - BSDXY(__NR_fstatat, sys_fstatat), // 493 + BSDXY(__NR_fstatat, sys_fstatat), // 493 #endif - BSDX_(__NR_futimesat, sys_futimesat), // 494 - BSDX_(__NR_linkat, sys_linkat), // 495 + BSDX_(__NR_futimesat, sys_futimesat), // 494 + BSDX_(__NR_linkat, sys_linkat), // 495 - BSDX_(__NR_mkdirat, sys_mkdirat), // 496 - BSDX_(__NR_mkfifoat, sys_mkfifoat), // 497 + BSDX_(__NR_mkdirat, sys_mkdirat), // 496 + BSDX_(__NR_mkfifoat, sys_mkfifoat), // 497 #if (FREEBSD_VERS >= FREEBSD_12) BSDX_(__NR_freebsd11_mknodat, sys_freebsd11_mknodat), // 498 #else - BSDX_(__NR_mknodat, sys_mknodat), // 498 + BSDX_(__NR_mknodat, sys_mknodat), // 498 #endif - BSDXY(__NR_openat, sys_openat), // 499 + BSDXY(__NR_openat, sys_openat), // 499 - BSDXY(__NR_readlinkat, sys_readlinkat), // 500 - BSDX_(__NR_renameat, sys_renameat), // 501 - BSDX_(__NR_symlinkat, sys_symlinkat), // 502 - BSDX_(__NR_unlinkat, sys_unlinkat), // 503 + BSDXY(__NR_readlinkat, sys_readlinkat), // 500 + BSDX_(__NR_renameat, sys_renameat), // 501 + BSDX_(__NR_symlinkat, sys_symlinkat), // 502 + BSDX_(__NR_unlinkat, sys_unlinkat), // 503 - BSDX_(__NR_posix_openpt, sys_posix_openpt), // 504 + BSDX_(__NR_posix_openpt, sys_posix_openpt), // 504 // unimp gssd_syscall 505 - BSDX_(__NR_jail_get, sys_jail_get), // 506 - BSDX_(__NR_jail_set, sys_jail_set), // 507 - BSDX_(__NR_jail_remove, sys_jail_remove), // 508 - BSDX_(__NR_closefrom, sys_closefrom), // 509 - BSDXY(__NR___semctl, sys___semctl), // 510 - BSDXY(__NR_msgctl, sys_msgctl), // 511 - BSDXY(__NR_shmctl, sys_shmctl), // 512 - BSDX_(__NR_lpathconf, sys_lpathconf), // 513 + BSDX_(__NR_jail_get, sys_jail_get), // 506 + BSDX_(__NR_jail_set, sys_jail_set), // 507 + BSDX_(__NR_jail_remove, sys_jail_remove), // 508 + BSDX_(__NR_closefrom, sys_closefrom), // 509 + BSDXY(__NR___semctl, sys___semctl), // 510 + BSDXY(__NR_msgctl, sys_msgctl), // 511 + BSDXY(__NR_shmctl, sys_shmctl), // 512 + BSDX_(__NR_lpathconf, sys_lpathconf), // 513 /* 514 is obsolete cap_new */ - BSDXY(__NR___cap_rights_get, sys_cap_rights_get), // 515 - BSDX_(__NR_cap_enter, sys_cap_enter), // 516 - BSDXY(__NR_cap_getmode, sys_cap_getmode), // 517 - BSDXY(__NR_pdfork, sys_pdfork), // 518 - BSDX_(__NR_pdkill, sys_pdkill), // 519 - BSDXY(__NR_pdgetpid, sys_pdgetpid), // 520 - BSDXY(__NR_pselect, sys_pselect), // 522 - BSDXY(__NR_getloginclass, sys_getloginclass), // 523 - BSDX_(__NR_setloginclass, sys_setloginclass), // 524 - BSDXY(__NR_rctl_get_racct, sys_rctl_get_racct), // 525 - BSDXY(__NR_rctl_get_rules, sys_rctl_get_rules), // 526 - BSDXY(__NR_rctl_get_limits, sys_rctl_get_limits), // 527 - BSDXY(__NR_rctl_add_rule, sys_rctl_add_rule), // 528 - BSDXY(__NR_rctl_remove_rule, sys_rctl_remove_rule), // 529 - BSDX_(__NR_posix_fallocate, sys_posix_fallocate), // 530 - BSDX_(__NR_posix_fadvise, sys_posix_fadvise), // 531 - BSDXY(__NR_wait6, sys_wait6), // 532 - BSDX_(__NR_cap_rights_limit, sys_cap_rights_limit), // 533 - BSDX_(__NR_cap_ioctls_limit, sys_cap_ioctls_limit), // 534 - BSDXY(__NR_cap_ioctls_get, sys_cap_ioctls_get), // 535 - BSDX_(__NR_cap_fcntls_limit, sys_cap_fcntls_limit), // 536 - BSDXY(__NR_cap_fcntls_get, sys_cap_fcntls_get), // 537 - BSDX_(__NR_bindat, sys_bindat), // 538 - BSDX_(__NR_connectat, sys_connectat), // 539 - BSDX_(__NR_chflagsat, sys_chflagsat), // 540 - BSDXY(__NR_accept4, sys_accept4), // 541 - BSDXY(__NR_pipe2, sys_pipe2), // 542 - BSDX_(__NR_aio_mlock, sys_aio_mlock), // 543 - BSDXY(__NR_procctl, sys_procctl), // 544 - - // 544 is the highest syscall on FreeBSD 9 + BSDXY(__NR___cap_rights_get, sys_cap_rights_get), // 515 + BSDX_(__NR_cap_enter, sys_cap_enter), // 516 + BSDXY(__NR_cap_getmode, sys_cap_getmode), // 517 + BSDXY(__NR_pdfork, sys_pdfork), // 518 + BSDX_(__NR_pdkill, sys_pdkill), // 519 + BSDXY(__NR_pdgetpid, sys_pdgetpid), // 520 + BSDXY(__NR_pselect, sys_pselect), // 522 + BSDXY(__NR_getloginclass, sys_getloginclass), // 523 + BSDX_(__NR_setloginclass, sys_setloginclass), // 524 + BSDXY(__NR_rctl_get_racct, sys_rctl_get_racct), // 525 + BSDXY(__NR_rctl_get_rules, sys_rctl_get_rules), // 526 + BSDXY(__NR_rctl_get_limits, sys_rctl_get_limits), // 527 + BSDXY(__NR_rctl_add_rule, sys_rctl_add_rule), // 528 + BSDXY(__NR_rctl_remove_rule, sys_rctl_remove_rule), // 529 + BSDX_(__NR_posix_fallocate, sys_posix_fallocate), // 530 + BSDX_(__NR_posix_fadvise, sys_posix_fadvise), // 531 + BSDXY(__NR_wait6, sys_wait6), // 532 + BSDX_(__NR_cap_rights_limit, sys_cap_rights_limit), // 533 + BSDX_(__NR_cap_ioctls_limit, sys_cap_ioctls_limit), // 534 + BSDXY(__NR_cap_ioctls_get, sys_cap_ioctls_get), // 535 + BSDX_(__NR_cap_fcntls_limit, sys_cap_fcntls_limit), // 536 + BSDXY(__NR_cap_fcntls_get, sys_cap_fcntls_get), // 537 + BSDX_(__NR_bindat, sys_bindat), // 538 + BSDX_(__NR_connectat, sys_connectat), // 539 + BSDX_(__NR_chflagsat, sys_chflagsat), // 540 + BSDXY(__NR_accept4, sys_accept4), // 541 + BSDXY(__NR_pipe2, sys_pipe2), // 542 + BSDX_(__NR_aio_mlock, sys_aio_mlock), // 543 + BSDXY(__NR_procctl, sys_procctl), // 544 + +// 544 is the highest syscall on FreeBSD 9 #if (FREEBSD_VERS >= FREEBSD_10) - BSDXY(__NR_ppoll, sys_ppoll), // 545 - BSDX_(__NR_futimens, sys_futimens), // 546 - BSDX_(__NR_utimensat, sys_utimensat), // 547 + BSDXY(__NR_ppoll, sys_ppoll), // 545 + BSDX_(__NR_futimens, sys_futimens), // 546 + BSDX_(__NR_utimensat, sys_utimensat), // 547 #endif // FREEBSD_VERS >= FREEBSD_10 @@ -7323,65 +7518,65 @@ const SyscallTableEntry ML_(syscall_table)[] = { /* 548 is obsolete numa_getaffinity */ /* 549 is obsolete numa_setaffinity */ - BSDX_(__NR_fdatasync, sys_fdatasync), // 550 + BSDX_(__NR_fdatasync, sys_fdatasync), // 550 #endif // FREEBSD_VERS >= FREEBSD_11 #if (FREEBSD_VERS >= FREEBSD_12) - BSDXY(__NR_fstat, sys_fstat), // 551 - BSDXY(__NR_fstatat, sys_fstatat), // 552 - BSDXY(__NR_fhstat, sys_fhstat), // 553 - BSDXY(__NR_getdirentries, sys_getdirentries), // 554 - BSDXY(__NR_statfs, sys_statfs), // 555 - BSDXY(__NR_fstatfs, sys_fstatfs), // 556 - BSDXY(__NR_getfsstat, sys_getfsstat), // 557 - BSDXY(__NR_fhstatfs, sys_fhstatfs), // 558 - BSDX_(__NR_mknodat, sys_mknodat), // 559 - BSDXY(__NR_kevent, sys_kevent), // 560 - BSDXY(__NR_cpuset_getdomain, sys_cpuset_getdomain), // 561 - BSDX_(__NR_cpuset_setdomain, sys_cpuset_setdomain), // 562 - BSDXY(__NR_getrandom, sys_getrandom), // 563 - BSDXY(__NR_getfhat, sys_getfhat), // 564 - BSDX_(__NR_fhlink, sys_fhlink), // 565 - BSDX_(__NR_fhlinkat, sys_fhlinkat), // 566 - BSDXY(__NR_fhreadlink, sys_fhreadlink), // 567 + BSDXY(__NR_fstat, sys_fstat), // 551 + BSDXY(__NR_fstatat, sys_fstatat), // 552 + BSDXY(__NR_fhstat, sys_fhstat), // 553 + BSDXY(__NR_getdirentries, sys_getdirentries), // 554 + BSDXY(__NR_statfs, sys_statfs), // 555 + BSDXY(__NR_fstatfs, sys_fstatfs), // 556 + BSDXY(__NR_getfsstat, sys_getfsstat), // 557 + BSDXY(__NR_fhstatfs, sys_fhstatfs), // 558 + BSDX_(__NR_mknodat, sys_mknodat), // 559 + BSDXY(__NR_kevent, sys_kevent), // 560 + BSDXY(__NR_cpuset_getdomain, sys_cpuset_getdomain), // 561 + BSDX_(__NR_cpuset_setdomain, sys_cpuset_setdomain), // 562 + BSDXY(__NR_getrandom, sys_getrandom), // 563 + BSDXY(__NR_getfhat, sys_getfhat), // 564 + BSDX_(__NR_fhlink, sys_fhlink), // 565 + BSDX_(__NR_fhlinkat, sys_fhlinkat), // 566 + BSDXY(__NR_fhreadlink, sys_fhreadlink), // 567 #endif // FREEBSD_VERS >= FREEBSD_12 #if (FREEBSD_VERS >= FREEBSD_12_2) - BSDX_(__NR_funlinkat, sys_funlinkat), // 568 - BSDX_(__NR_copy_file_range, sys_copy_file_range), // 569 - BSDXY(__NR___sysctlbyname, sys___sysctlbyname), // 570 + BSDX_(__NR_funlinkat, sys_funlinkat), // 568 + BSDX_(__NR_copy_file_range, sys_copy_file_range), // 569 + BSDXY(__NR___sysctlbyname, sys___sysctlbyname), // 570 #if (FREEBSD_VERS >= FREEBSD_13_0) - BSDXY(__NR_shm_open2, sys_shm_open2), // 571 + BSDXY(__NR_shm_open2, sys_shm_open2), // 571 // unimpl __NR_shm_rename 572 - BSDX_(__NR_sigfastblock, sys_sigfastblock), // 573 - BSDXY( __NR___realpathat, sys___realpathat), // 574 + BSDX_(__NR_sigfastblock, sys_sigfastblock), // 573 + BSDXY(__NR___realpathat, sys___realpathat), // 574 #endif - // unimpl __NR_close_range 575 +// unimpl __NR_close_range 575 #endif #if (FREEBSD_VERS >= FREEBSD_13_0) // unimpl __NR_rpctls_syscall 576 - BSDX_(__NR___specialfd, sys___specialfd), // 577 - // unimpl __NR_aio_writev 578 - // unimpl __NR_aio_readv 579 + BSDX_(__NR___specialfd, sys___specialfd), // 577 +// unimpl __NR_aio_writev 578 +// unimpl __NR_aio_readv 579 #endif #if (FREEBSD_VERS >= FREEBSD_13_1) // unimpl __NR_fspacectl 580 // unimpl __NR_sched_getcpu 581 - BSDX_(__NR_swapoff, sys_swapoff), // 582 + BSDX_(__NR_swapoff, sys_swapoff), // 582 #endif - BSDX_(__NR_fake_sigreturn, sys_fake_sigreturn), // 1000, fake sigreturn + BSDX_(__NR_fake_sigreturn, sys_fake_sigreturn), // 1000, fake sigreturn }; -const SyscallTableEntry* ML_(get_freebsd_syscall_entry) ( UInt sysno ) +const SyscallTableEntry* ML_(get_freebsd_syscall_entry)(UInt sysno) { - const UInt syscall_table_size - = sizeof(ML_(syscall_table)) / sizeof(ML_(syscall_table)[0]); + const UInt syscall_table_size = + sizeof(ML_(syscall_table)) / sizeof(ML_(syscall_table)[0]); /* Is it in the contiguous initial section of the table? */ if (sysno < syscall_table_size) { diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 946813be79..1099dd84cf 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -29,37 +29,36 @@ The GNU General Public License is contained in the file COPYING. */ -#include "pub_tool_basics.h" #include "pub_tool_aspacemgr.h" +#include "pub_tool_basics.h" #include "pub_tool_gdbserver.h" -#include "pub_tool_poolalloc.h" -#include "pub_tool_hashtable.h" // For mc_include.h -#include "pub_tool_libcbase.h" +#include "pub_tool_hashtable.h" // For mc_include.h #include "pub_tool_libcassert.h" +#include "pub_tool_libcbase.h" #include "pub_tool_libcprint.h" #include "pub_tool_machine.h" #include "pub_tool_mallocfree.h" #include "pub_tool_options.h" #include "pub_tool_oset.h" +#include "pub_tool_poolalloc.h" #include "pub_tool_rangemap.h" #include "pub_tool_replacemalloc.h" -#include "pub_tool_tooliface.h" #include "pub_tool_threadstate.h" +#include "pub_tool_tooliface.h" #include "pub_tool_xarray.h" -#include "pub_tool_xtree.h" #include "pub_tool_xtmemory.h" +#include "pub_tool_xtree.h" #include "mc_include.h" -#include "memcheck.h" /* for client requests */ +#include "memcheck.h" /* for client requests */ /* Set to 1 to do a little more sanity checking */ #define VG_DEBUG_MEMORY 0 -#define DEBUG(fmt, args...) //VG_(printf)(fmt, ## args) - -static void ocache_sarp_Set_Origins ( Addr, UWord, UInt ); /* fwds */ -static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ +#define DEBUG(fmt, args...) // VG_(printf)(fmt, ## args) +static void ocache_sarp_Set_Origins(Addr, UWord, UInt); /* fwds */ +static void ocache_sarp_Clear_Origins(Addr, UWord); /* fwds */ /*------------------------------------------------------------*/ /*--- Fast-case knobs ---*/ @@ -68,12 +67,12 @@ static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ // Comment these out to disable the fast cases (don't just set them to zero). /* PERF_FAST_LOADV is in mc_include.h */ -#define PERF_FAST_STOREV 1 +#define PERF_FAST_STOREV 1 -#define PERF_FAST_SARP 1 +#define PERF_FAST_SARP 1 -#define PERF_FAST_STACK 1 -#define PERF_FAST_STACK2 1 +#define PERF_FAST_STACK 1 +#define PERF_FAST_STACK2 1 /* Change this to 1 to enable assertions on origin tracking cache fast paths */ @@ -83,7 +82,6 @@ static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ 8- and 16-bit store handling. */ #define OC_PRECISION_STORE 1 - /*------------------------------------------------------------*/ /*--- Comments on the origin tracking implementation ---*/ /*------------------------------------------------------------*/ @@ -92,7 +90,6 @@ static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ AN OVERVIEW OF THE ORIGIN TRACKING IMPLEMENTATION which is contained further on in this file. */ - /*------------------------------------------------------------*/ /*--- V bits and A bits ---*/ /*------------------------------------------------------------*/ @@ -169,24 +166,22 @@ static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ #if VG_WORDSIZE == 4 /* cover the entire address space */ -# define N_PRIMARY_BITS 16 +#define N_PRIMARY_BITS 16 #else /* Just handle the first 128G fast and the rest via auxiliary primaries. If you change this, Memcheck will assert at startup. See the definition of UNALIGNED_OR_HIGH for extensive comments. */ -# define N_PRIMARY_BITS 21 +#define N_PRIMARY_BITS 21 #endif - /* Do not change this. */ -#define N_PRIMARY_MAP ( ((UWord)1) << N_PRIMARY_BITS) +#define N_PRIMARY_MAP (((UWord)1) << N_PRIMARY_BITS) /* Do not change this. */ -#define MAX_PRIMARY_ADDRESS (Addr)((((Addr)65536) * N_PRIMARY_MAP)-1) - +#define MAX_PRIMARY_ADDRESS (Addr)((((Addr)65536) * N_PRIMARY_MAP) - 1) /* --------------- Secondary maps --------------- */ @@ -235,64 +230,58 @@ static void ocache_sarp_Clear_Origins ( Addr, UWord ); /* fwds */ // few places. // These represent eight bits of memory. -#define VA_BITS2_NOACCESS 0x0 // 00b -#define VA_BITS2_UNDEFINED 0x1 // 01b -#define VA_BITS2_DEFINED 0x2 // 10b -#define VA_BITS2_PARTDEFINED 0x3 // 11b +#define VA_BITS2_NOACCESS 0x0 // 00b +#define VA_BITS2_UNDEFINED 0x1 // 01b +#define VA_BITS2_DEFINED 0x2 // 10b +#define VA_BITS2_PARTDEFINED 0x3 // 11b // These represent 16 bits of memory. -#define VA_BITS4_NOACCESS 0x0 // 00_00b -#define VA_BITS4_UNDEFINED 0x5 // 01_01b -#define VA_BITS4_DEFINED 0xa // 10_10b +#define VA_BITS4_NOACCESS 0x0 // 00_00b +#define VA_BITS4_UNDEFINED 0x5 // 01_01b +#define VA_BITS4_DEFINED 0xa // 10_10b // These represent 32 bits of memory. -#define VA_BITS8_NOACCESS 0x00 // 00_00_00_00b -#define VA_BITS8_UNDEFINED 0x55 // 01_01_01_01b -#define VA_BITS8_DEFINED 0xaa // 10_10_10_10b +#define VA_BITS8_NOACCESS 0x00 // 00_00_00_00b +#define VA_BITS8_UNDEFINED 0x55 // 01_01_01_01b +#define VA_BITS8_DEFINED 0xaa // 10_10_10_10b // These represent 64 bits of memory. -#define VA_BITS16_NOACCESS 0x0000 // 00_00_00_00b x 2 -#define VA_BITS16_UNDEFINED 0x5555 // 01_01_01_01b x 2 -#define VA_BITS16_DEFINED 0xaaaa // 10_10_10_10b x 2 +#define VA_BITS16_NOACCESS 0x0000 // 00_00_00_00b x 2 +#define VA_BITS16_UNDEFINED 0x5555 // 01_01_01_01b x 2 +#define VA_BITS16_DEFINED 0xaaaa // 10_10_10_10b x 2 // These represent 128 bits of memory. -#define VA_BITS32_UNDEFINED 0x55555555 // 01_01_01_01b x 4 +#define VA_BITS32_UNDEFINED 0x55555555 // 01_01_01_01b x 4 - -#define SM_CHUNKS 16384 // Each SM covers 64k of memory. -#define SM_OFF(aaa) (((aaa) & 0xffff) >> 2) -#define SM_OFF_16(aaa) (((aaa) & 0xffff) >> 3) +#define SM_CHUNKS 16384 // Each SM covers 64k of memory. +#define SM_OFF(aaa) (((aaa)&0xffff) >> 2) +#define SM_OFF_16(aaa) (((aaa)&0xffff) >> 3) // Paranoia: it's critical for performance that the requested inlining // occurs. So try extra hard. -#define INLINE inline __attribute__((always_inline)) +#define INLINE inline __attribute__((always_inline)) -static INLINE Addr start_of_this_sm ( Addr a ) { - return (a & (~SM_MASK)); -} -static INLINE Bool is_start_of_sm ( Addr a ) { - return (start_of_this_sm(a) == a); -} +static INLINE Addr start_of_this_sm(Addr a) { return (a & (~SM_MASK)); } +static INLINE Bool is_start_of_sm(Addr a) { return (start_of_this_sm(a) == a); } STATIC_ASSERT(SM_CHUNKS % 2 == 0); -typedef - union { - UChar vabits8[SM_CHUNKS]; - UShort vabits16[SM_CHUNKS/2]; - } - SecMap; +typedef union { + UChar vabits8[SM_CHUNKS]; + UShort vabits16[SM_CHUNKS / 2]; +} SecMap; // 3 distinguished secondary maps, one for no-access, one for // accessible but undefined, and one for accessible and defined. // Distinguished secondaries may never be modified. -#define SM_DIST_NOACCESS 0 -#define SM_DIST_UNDEFINED 1 -#define SM_DIST_DEFINED 2 +#define SM_DIST_NOACCESS 0 +#define SM_DIST_UNDEFINED 1 +#define SM_DIST_DEFINED 2 static SecMap sm_distinguished[3]; -static INLINE Bool is_distinguished_sm ( SecMap* sm ) { +static INLINE Bool is_distinguished_sm(SecMap* sm) +{ return sm >= &sm_distinguished[0] && sm <= &sm_distinguished[2]; } @@ -302,18 +291,18 @@ static void update_SM_counts(SecMap* oldSM, SecMap* newSM); /* dist_sm points to one of our three distinguished secondaries. Make a copy of it so that we can write to it. */ -static SecMap* copy_for_writing ( SecMap* dist_sm ) +static SecMap* copy_for_writing(SecMap* dist_sm) { SecMap* new_sm; - tl_assert(dist_sm == &sm_distinguished[0] - || dist_sm == &sm_distinguished[1] - || dist_sm == &sm_distinguished[2]); + tl_assert(dist_sm == &sm_distinguished[0] || + dist_sm == &sm_distinguished[1] || + dist_sm == &sm_distinguished[2]); SysRes sres = VG_(am_shadow_alloc)(sizeof(SecMap)); if (sr_isError(sres)) - VG_(out_of_memory_NORETURN)( "memcheck:allocate new SecMap", - sizeof(SecMap), sr_Err(sres) ); - new_sm = (void *)(Addr)sr_Res(sres); + VG_(out_of_memory_NORETURN)("memcheck:allocate new SecMap", + sizeof(SecMap), sr_Err(sres)); + new_sm = (void*)(Addr)sr_Res(sres); VG_(memcpy)(new_sm, dist_sm, sizeof(SecMap)); update_SM_counts(dist_sm, new_sm); return new_sm; @@ -321,49 +310,63 @@ static SecMap* copy_for_writing ( SecMap* dist_sm ) /* --------------- Stats --------------- */ -static Int n_issued_SMs = 0; -static Int n_deissued_SMs = 0; -static Int n_noaccess_SMs = N_PRIMARY_MAP; // start with many noaccess DSMs -static Int n_undefined_SMs = 0; -static Int n_defined_SMs = 0; -static Int n_non_DSM_SMs = 0; -static Int max_noaccess_SMs = 0; -static Int max_undefined_SMs = 0; -static Int max_defined_SMs = 0; -static Int max_non_DSM_SMs = 0; +static Int n_issued_SMs = 0; +static Int n_deissued_SMs = 0; +static Int n_noaccess_SMs = N_PRIMARY_MAP; // start with many noaccess DSMs +static Int n_undefined_SMs = 0; +static Int n_defined_SMs = 0; +static Int n_non_DSM_SMs = 0; +static Int max_noaccess_SMs = 0; +static Int max_undefined_SMs = 0; +static Int max_defined_SMs = 0; +static Int max_non_DSM_SMs = 0; /* # searches initiated in auxmap_L1, and # base cmps required */ -static ULong n_auxmap_L1_searches = 0; -static ULong n_auxmap_L1_cmps = 0; +static ULong n_auxmap_L1_searches = 0; +static ULong n_auxmap_L1_cmps = 0; /* # of searches that missed in auxmap_L1 and therefore had to be handed to auxmap_L2. And the number of nodes inserted. */ -static ULong n_auxmap_L2_searches = 0; -static ULong n_auxmap_L2_nodes = 0; +static ULong n_auxmap_L2_searches = 0; +static ULong n_auxmap_L2_nodes = 0; -static Int n_sanity_cheap = 0; -static Int n_sanity_expensive = 0; +static Int n_sanity_cheap = 0; +static Int n_sanity_expensive = 0; -static Int n_secVBit_nodes = 0; -static Int max_secVBit_nodes = 0; +static Int n_secVBit_nodes = 0; +static Int max_secVBit_nodes = 0; static void update_SM_counts(SecMap* oldSM, SecMap* newSM) { - if (oldSM == &sm_distinguished[SM_DIST_NOACCESS ]) n_noaccess_SMs --; - else if (oldSM == &sm_distinguished[SM_DIST_UNDEFINED]) n_undefined_SMs--; - else if (oldSM == &sm_distinguished[SM_DIST_DEFINED ]) n_defined_SMs --; - else { n_non_DSM_SMs --; - n_deissued_SMs ++; } - - if (newSM == &sm_distinguished[SM_DIST_NOACCESS ]) n_noaccess_SMs ++; - else if (newSM == &sm_distinguished[SM_DIST_UNDEFINED]) n_undefined_SMs++; - else if (newSM == &sm_distinguished[SM_DIST_DEFINED ]) n_defined_SMs ++; - else { n_non_DSM_SMs ++; - n_issued_SMs ++; } - - if (n_noaccess_SMs > max_noaccess_SMs ) max_noaccess_SMs = n_noaccess_SMs; - if (n_undefined_SMs > max_undefined_SMs) max_undefined_SMs = n_undefined_SMs; - if (n_defined_SMs > max_defined_SMs ) max_defined_SMs = n_defined_SMs; - if (n_non_DSM_SMs > max_non_DSM_SMs ) max_non_DSM_SMs = n_non_DSM_SMs; + if (oldSM == &sm_distinguished[SM_DIST_NOACCESS]) + n_noaccess_SMs--; + else if (oldSM == &sm_distinguished[SM_DIST_UNDEFINED]) + n_undefined_SMs--; + else if (oldSM == &sm_distinguished[SM_DIST_DEFINED]) + n_defined_SMs--; + else { + n_non_DSM_SMs--; + n_deissued_SMs++; + } + + if (newSM == &sm_distinguished[SM_DIST_NOACCESS]) + n_noaccess_SMs++; + else if (newSM == &sm_distinguished[SM_DIST_UNDEFINED]) + n_undefined_SMs++; + else if (newSM == &sm_distinguished[SM_DIST_DEFINED]) + n_defined_SMs++; + else { + n_non_DSM_SMs++; + n_issued_SMs++; + } + + if (n_noaccess_SMs > max_noaccess_SMs) + max_noaccess_SMs = n_noaccess_SMs; + if (n_undefined_SMs > max_undefined_SMs) + max_undefined_SMs = n_undefined_SMs; + if (n_defined_SMs > max_defined_SMs) + max_defined_SMs = n_defined_SMs; + if (n_non_DSM_SMs > max_non_DSM_SMs) + max_non_DSM_SMs = n_non_DSM_SMs; } /* --------------- Primary maps --------------- */ @@ -372,9 +375,9 @@ static void update_SM_counts(SecMap* oldSM, SecMap* newSM) space, addresses 0 .. (N_PRIMARY_MAP << 16)-1. The rest of it is handled using the auxiliary primary map. */ -#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_arm_linux) \ - || defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)) +#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + (defined(VGP_arm_linux) || 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. */ @@ -384,19 +387,16 @@ static void update_SM_counts(SecMap* oldSM, SecMap* newSM) #endif MC_MAIN_STATIC SecMap* primary_map[N_PRIMARY_MAP]; - /* An entry in the auxiliary primary map. base must be a 64k-aligned value, and sm points at the relevant secondary map. As with the main primary map, the secondary may be either a real secondary, or one of the three distinguished secondaries. DO NOT CHANGE THIS LAYOUT: the first word has to be the key for OSet fast lookups. */ -typedef - struct { - Addr base; - SecMap* sm; - } - AuxMapEnt; +typedef struct { + Addr base; + SecMap* sm; +} AuxMapEnt; /* Tunable parameter: How big is the L1 queue? */ #define N_AUXMAP_L1 24 @@ -406,14 +406,13 @@ typedef #define AUXMAP_L1_INSERT_IX 12 static struct { - Addr base; - AuxMapEnt* ent; // pointer to the matching auxmap_L2 node - } - auxmap_L1[N_AUXMAP_L1]; + Addr base; + AuxMapEnt* ent; // pointer to the matching auxmap_L2 node +} auxmap_L1[N_AUXMAP_L1]; static OSet* auxmap_L2 = NULL; -static void init_auxmap_L1_L2 ( void ) +static void init_auxmap_L1_L2(void) { Int i; for (i = 0; i < N_AUXMAP_L1; i++) { @@ -421,11 +420,11 @@ static void init_auxmap_L1_L2 ( void ) auxmap_L1[i].ent = NULL; } - tl_assert(0 == offsetof(AuxMapEnt,base)); + tl_assert(0 == offsetof(AuxMapEnt, base)); tl_assert(sizeof(Addr) == sizeof(void*)); - auxmap_L2 = VG_(OSetGen_Create)( /*keyOff*/ offsetof(AuxMapEnt,base), - /*fastCmp*/ NULL, - VG_(malloc), "mc.iaLL.1", VG_(free) ); + auxmap_L2 = VG_(OSetGen_Create)(/*keyOff*/ offsetof(AuxMapEnt, base), + /*fastCmp*/ NULL, VG_(malloc), "mc.iaLL.1", + VG_(free)); } /* Check representation invariants; if OK return NULL; else a @@ -433,7 +432,7 @@ static void init_auxmap_L1_L2 ( void ) non-distinguished secondary maps referred to from the auxiliary primary maps. */ -static const HChar* check_auxmap_L1_L2_sanity ( Word* n_secmaps_found ) +static const HChar* check_auxmap_L1_L2_sanity(Word* n_secmaps_found) { Word i, j; /* On a 32-bit platform, the L2 and L1 tables should @@ -457,16 +456,16 @@ static const HChar* check_auxmap_L1_L2_sanity ( Word* n_secmaps_found ) if (VG_(OSetGen_Size)(auxmap_L2) != 0) return "32-bit: auxmap_L2 is non-empty"; for (i = 0; i < N_AUXMAP_L1; i++) - if (auxmap_L1[i].base != 0 || auxmap_L1[i].ent != NULL) - return "32-bit: auxmap_L1 is non-empty"; + if (auxmap_L1[i].base != 0 || auxmap_L1[i].ent != NULL) + return "32-bit: auxmap_L1 is non-empty"; } else { /* 64-bit platform */ - UWord elems_seen = 0; + UWord elems_seen = 0; AuxMapEnt *elem, *res; - AuxMapEnt key; + AuxMapEnt key; /* L2 table */ VG_(OSetGen_ResetIter)(auxmap_L2); - while ( (elem = VG_(OSetGen_Next)(auxmap_L2)) ) { + while ((elem = VG_(OSetGen_Next)(auxmap_L2))) { elems_seen++; if (0 != (elem->base & (Addr)0xFFFF)) return "64-bit: nonzero .base & 0xFFFF in auxmap_L2"; @@ -494,7 +493,7 @@ static const HChar* check_auxmap_L1_L2_sanity ( Word* n_secmaps_found ) /* Look it up in auxmap_L2. */ key.base = auxmap_L1[i].base; key.sm = 0; - res = VG_(OSetGen_Lookup)(auxmap_L2, &key); + res = VG_(OSetGen_Lookup)(auxmap_L2, &key); if (res == NULL) return "64-bit: _L1 .base not found in _L2"; if (res != auxmap_L1[i].ent) @@ -504,7 +503,7 @@ static const HChar* check_auxmap_L1_L2_sanity ( Word* n_secmaps_found ) for (i = 0; i < N_AUXMAP_L1; i++) { if (auxmap_L1[i].base == 0) continue; - for (j = i+1; j < N_AUXMAP_L1; j++) { + for (j = i + 1; j < N_AUXMAP_L1; j++) { if (auxmap_L1[j].base == 0) continue; if (auxmap_L1[j].base == auxmap_L1[i].base) @@ -515,18 +514,18 @@ static const HChar* check_auxmap_L1_L2_sanity ( Word* n_secmaps_found ) return NULL; /* ok */ } -static void insert_into_auxmap_L1_at ( Word rank, AuxMapEnt* ent ) +static void insert_into_auxmap_L1_at(Word rank, AuxMapEnt* ent) { Word i; tl_assert(ent); tl_assert(rank >= 0 && rank < N_AUXMAP_L1); - for (i = N_AUXMAP_L1-1; i > rank; i--) - auxmap_L1[i] = auxmap_L1[i-1]; + for (i = N_AUXMAP_L1 - 1; i > rank; i--) + auxmap_L1[i] = auxmap_L1[i - 1]; auxmap_L1[rank].base = ent->base; auxmap_L1[rank].ent = ent; } -static INLINE AuxMapEnt* maybe_find_in_auxmap ( Addr a ) +static INLINE AuxMapEnt* maybe_find_in_auxmap(Addr a) { AuxMapEnt key; AuxMapEnt* res; @@ -559,16 +558,16 @@ static INLINE AuxMapEnt* maybe_find_in_auxmap ( Addr a ) } tl_assert(i >= 0 && i <= N_AUXMAP_L1); - n_auxmap_L1_cmps += (ULong)(i+1); + n_auxmap_L1_cmps += (ULong)(i + 1); if (i < N_AUXMAP_L1) { if (i > 0) { - Addr t_base = auxmap_L1[i-1].base; - AuxMapEnt* t_ent = auxmap_L1[i-1].ent; - auxmap_L1[i-1].base = auxmap_L1[i-0].base; - auxmap_L1[i-1].ent = auxmap_L1[i-0].ent; - auxmap_L1[i-0].base = t_base; - auxmap_L1[i-0].ent = t_ent; + Addr t_base = auxmap_L1[i - 1].base; + AuxMapEnt* t_ent = auxmap_L1[i - 1].ent; + auxmap_L1[i - 1].base = auxmap_L1[i - 0].base; + auxmap_L1[i - 1].ent = auxmap_L1[i - 0].ent; + auxmap_L1[i - 0].base = t_base; + auxmap_L1[i - 0].ent = t_ent; i--; } return auxmap_L1[i].ent; @@ -582,16 +581,16 @@ static INLINE AuxMapEnt* maybe_find_in_auxmap ( Addr a ) res = VG_(OSetGen_Lookup)(auxmap_L2, &key); if (res) - insert_into_auxmap_L1_at( AUXMAP_L1_INSERT_IX, res ); + insert_into_auxmap_L1_at(AUXMAP_L1_INSERT_IX, res); return res; } -static AuxMapEnt* find_or_alloc_in_auxmap ( Addr a ) +static AuxMapEnt* find_or_alloc_in_auxmap(Addr a) { AuxMapEnt *nyu, *res; /* First see if we already have it. */ - res = maybe_find_in_auxmap( a ); + res = maybe_find_in_auxmap(a); if (LIKELY(res)) return res; @@ -599,11 +598,11 @@ static AuxMapEnt* find_or_alloc_in_auxmap ( Addr a ) to allocate one. */ a &= ~(Addr)0xFFFF; - nyu = (AuxMapEnt*) VG_(OSetGen_AllocNode)( auxmap_L2, sizeof(AuxMapEnt) ); + nyu = (AuxMapEnt*)VG_(OSetGen_AllocNode)(auxmap_L2, sizeof(AuxMapEnt)); nyu->base = a; nyu->sm = &sm_distinguished[SM_DIST_NOACCESS]; - VG_(OSetGen_Insert)( auxmap_L2, nyu ); - insert_into_auxmap_L1_at( AUXMAP_L1_INSERT_IX, nyu ); + VG_(OSetGen_Insert)(auxmap_L2, nyu); + insert_into_auxmap_L1_at(AUXMAP_L1_INSERT_IX, nyu); n_auxmap_L2_nodes++; return nyu; } @@ -613,40 +612,39 @@ static AuxMapEnt* find_or_alloc_in_auxmap ( Addr a ) // In all these, 'low' means it's definitely in the main primary map, // 'high' means it's definitely in the auxiliary table. -static INLINE UWord get_primary_map_low_offset ( Addr a ) +static INLINE UWord get_primary_map_low_offset(Addr a) { - UWord pm_off = a >> 16; - return pm_off; + UWord pm_off = a >> 16; + return pm_off; } -static INLINE SecMap** get_secmap_low_ptr ( Addr a ) +static INLINE SecMap** get_secmap_low_ptr(Addr a) { UWord pm_off = a >> 16; -# if VG_DEBUG_MEMORY >= 1 +#if VG_DEBUG_MEMORY >= 1 tl_assert(pm_off < N_PRIMARY_MAP); -# endif - return &primary_map[ pm_off ]; +#endif + return &primary_map[pm_off]; } -static INLINE SecMap** get_secmap_high_ptr ( Addr a ) +static INLINE SecMap** get_secmap_high_ptr(Addr a) { AuxMapEnt* am = find_or_alloc_in_auxmap(a); return &am->sm; } -static INLINE SecMap** get_secmap_ptr ( Addr a ) +static INLINE SecMap** get_secmap_ptr(Addr a) { - return ( a <= MAX_PRIMARY_ADDRESS - ? get_secmap_low_ptr(a) - : get_secmap_high_ptr(a)); + return (a <= MAX_PRIMARY_ADDRESS ? get_secmap_low_ptr(a) + : get_secmap_high_ptr(a)); } -static INLINE SecMap* get_secmap_for_reading_low ( Addr a ) +static INLINE SecMap* get_secmap_for_reading_low(Addr a) { return *get_secmap_low_ptr(a); } -static INLINE SecMap* get_secmap_for_reading_high ( Addr a ) +static INLINE SecMap* get_secmap_for_reading_high(Addr a) { return *get_secmap_high_ptr(a); } @@ -659,7 +657,7 @@ static INLINE SecMap* get_secmap_for_writing_low(Addr a) return *p; } -static INLINE SecMap* get_secmap_for_writing_high ( Addr a ) +static INLINE SecMap* get_secmap_for_writing_high(Addr a) { SecMap** p = get_secmap_high_ptr(a); if (UNLIKELY(is_distinguished_sm(*p))) @@ -672,11 +670,10 @@ static INLINE SecMap* get_secmap_for_writing_high ( Addr a ) secmap may be a distinguished one as the caller will only want to be able to read it. */ -static INLINE SecMap* get_secmap_for_reading ( Addr a ) +static INLINE SecMap* get_secmap_for_reading(Addr a) { - return ( a <= MAX_PRIMARY_ADDRESS - ? get_secmap_for_reading_low (a) - : get_secmap_for_reading_high(a) ); + return (a <= MAX_PRIMARY_ADDRESS ? get_secmap_for_reading_low(a) + : get_secmap_for_reading_high(a)); } /* Produce the secmap for 'a', either from the primary map or by @@ -686,18 +683,17 @@ static INLINE SecMap* get_secmap_for_reading ( Addr a ) writable copy of it, install it, and return the copy instead. (COW semantics). */ -static INLINE SecMap* get_secmap_for_writing ( Addr a ) +static INLINE SecMap* get_secmap_for_writing(Addr a) { - return ( a <= MAX_PRIMARY_ADDRESS - ? get_secmap_for_writing_low (a) - : get_secmap_for_writing_high(a) ); + return (a <= MAX_PRIMARY_ADDRESS ? get_secmap_for_writing_low(a) + : get_secmap_for_writing_high(a)); } /* If 'a' has a SecMap, produce it. Else produce NULL. But don't allocate one if one doesn't already exist. This is used by the leak checker. */ -static SecMap* maybe_get_secmap_for ( Addr a ) +static SecMap* maybe_get_secmap_for(Addr a) { if (a <= MAX_PRIMARY_ADDRESS) { return get_secmap_for_reading_low(a); @@ -709,40 +705,38 @@ static SecMap* maybe_get_secmap_for ( Addr a ) /* --------------- Fundamental functions --------------- */ -static INLINE -void insert_vabits2_into_vabits8 ( Addr a, UChar vabits2, UChar* vabits8 ) +static INLINE void +insert_vabits2_into_vabits8(Addr a, UChar vabits2, UChar* vabits8) { - UInt shift = (a & 3) << 1; // shift by 0, 2, 4, or 6 - *vabits8 &= ~(0x3 << shift); // mask out the two old bits - *vabits8 |= (vabits2 << shift); // mask in the two new bits + UInt shift = (a & 3) << 1; // shift by 0, 2, 4, or 6 + *vabits8 &= ~(0x3 << shift); // mask out the two old bits + *vabits8 |= (vabits2 << shift); // mask in the two new bits } -static INLINE -void insert_vabits4_into_vabits8 ( Addr a, UChar vabits4, UChar* vabits8 ) +static INLINE void +insert_vabits4_into_vabits8(Addr a, UChar vabits4, UChar* vabits8) { UInt shift; - tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned - shift = (a & 2) << 1; // shift by 0 or 4 - *vabits8 &= ~(0xf << shift); // mask out the four old bits - *vabits8 |= (vabits4 << shift); // mask in the four new bits + tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned + shift = (a & 2) << 1; // shift by 0 or 4 + *vabits8 &= ~(0xf << shift); // mask out the four old bits + *vabits8 |= (vabits4 << shift); // mask in the four new bits } -static INLINE -UChar extract_vabits2_from_vabits8 ( Addr a, UChar vabits8 ) +static INLINE UChar extract_vabits2_from_vabits8(Addr a, UChar vabits8) { - UInt shift = (a & 3) << 1; // shift by 0, 2, 4, or 6 - vabits8 >>= shift; // shift the two bits to the bottom - return 0x3 & vabits8; // mask out the rest + UInt shift = (a & 3) << 1; // shift by 0, 2, 4, or 6 + vabits8 >>= shift; // shift the two bits to the bottom + return 0x3 & vabits8; // mask out the rest } -static INLINE -UChar extract_vabits4_from_vabits8 ( Addr a, UChar vabits8 ) +static INLINE UChar extract_vabits4_from_vabits8(Addr a, UChar vabits8) { UInt shift; - tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned - shift = (a & 2) << 1; // shift by 0 or 4 - vabits8 >>= shift; // shift the four bits to the bottom - return 0xf & vabits8; // mask out the rest + tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned + shift = (a & 2) << 1; // shift by 0 or 4 + vabits8 >>= shift; // shift the four bits to the bottom + return 0xf & vabits8; // mask out the rest } // Note that these four are only used in slow cases. The fast cases do @@ -753,20 +747,18 @@ UChar extract_vabits4_from_vabits8 ( Addr a, UChar vabits8 ) // Any time this function is called, if it is possible that vabits2 // is equal to VA_BITS2_PARTDEFINED, then the corresponding entry in the // sec-V-bits table must also be set! -static INLINE -void set_vabits2 ( Addr a, UChar vabits2 ) +static INLINE void set_vabits2(Addr a, UChar vabits2) { - SecMap* sm = get_secmap_for_writing(a); - UWord sm_off = SM_OFF(a); - insert_vabits2_into_vabits8( a, vabits2, &(sm->vabits8[sm_off]) ); + SecMap* sm = get_secmap_for_writing(a); + UWord sm_off = SM_OFF(a); + insert_vabits2_into_vabits8(a, vabits2, &(sm->vabits8[sm_off])); } -static INLINE -UChar get_vabits2 ( Addr a ) +static INLINE UChar get_vabits2(Addr a) { - SecMap* sm = get_secmap_for_reading(a); - UWord sm_off = SM_OFF(a); - UChar vabits8 = sm->vabits8[sm_off]; + SecMap* sm = get_secmap_for_reading(a); + UWord sm_off = SM_OFF(a); + UChar vabits8 = sm->vabits8[sm_off]; return extract_vabits2_from_vabits8(a, vabits8); } @@ -774,42 +766,42 @@ UChar get_vabits2 ( Addr a ) // Any time this function is called, if it is possible that any of the // 4 2-bit fields in vabits8 are equal to VA_BITS2_PARTDEFINED, then the // corresponding entry(s) in the sec-V-bits table must also be set! -static INLINE -UChar get_vabits8_for_aligned_word32 ( Addr a ) +static INLINE UChar get_vabits8_for_aligned_word32(Addr a) { - SecMap* sm = get_secmap_for_reading(a); - UWord sm_off = SM_OFF(a); - UChar vabits8 = sm->vabits8[sm_off]; + SecMap* sm = get_secmap_for_reading(a); + UWord sm_off = SM_OFF(a); + UChar vabits8 = sm->vabits8[sm_off]; return vabits8; } -static INLINE -void set_vabits8_for_aligned_word32 ( Addr a, UChar vabits8 ) +static INLINE void set_vabits8_for_aligned_word32(Addr a, UChar vabits8) { - SecMap* sm = get_secmap_for_writing(a); - UWord sm_off = SM_OFF(a); + SecMap* sm = get_secmap_for_writing(a); + UWord sm_off = SM_OFF(a); sm->vabits8[sm_off] = vabits8; } - // Forward declarations static UWord get_sec_vbits8(Addr a); static void set_sec_vbits8(Addr a, UWord vbits8); // Returns False if there was an addressability error. -static INLINE -Bool set_vbits8 ( Addr a, UChar vbits8 ) +static INLINE Bool set_vbits8(Addr a, UChar vbits8) { Bool ok = True; UChar vabits2 = get_vabits2(a); - if ( VA_BITS2_NOACCESS != vabits2 ) { + if (VA_BITS2_NOACCESS != vabits2) { // Addressable. Convert in-register format to in-memory format. // Also remove any existing sec V bit entry for the byte if no // longer necessary. - if ( V_BITS8_DEFINED == vbits8 ) { vabits2 = VA_BITS2_DEFINED; } - else if ( V_BITS8_UNDEFINED == vbits8 ) { vabits2 = VA_BITS2_UNDEFINED; } - else { vabits2 = VA_BITS2_PARTDEFINED; - set_sec_vbits8(a, vbits8); } + if (V_BITS8_DEFINED == vbits8) { + vabits2 = VA_BITS2_DEFINED; + } else if (V_BITS8_UNDEFINED == vbits8) { + vabits2 = VA_BITS2_UNDEFINED; + } else { + vabits2 = VA_BITS2_PARTDEFINED; + set_sec_vbits8(a, vbits8); + } set_vabits2(a, vabits2); } else { @@ -823,26 +815,26 @@ Bool set_vbits8 ( Addr a, UChar vbits8 ) // Returns False if there was an addressability error. In that case, we put // all defined bits into vbits8. -static INLINE -Bool get_vbits8 ( Addr a, UChar* vbits8 ) +static INLINE Bool get_vbits8(Addr a, UChar* vbits8) { Bool ok = True; UChar vabits2 = get_vabits2(a); // Convert the in-memory format to in-register format. - if ( VA_BITS2_DEFINED == vabits2 ) { *vbits8 = V_BITS8_DEFINED; } - else if ( VA_BITS2_UNDEFINED == vabits2 ) { *vbits8 = V_BITS8_UNDEFINED; } - else if ( VA_BITS2_NOACCESS == vabits2 ) { - *vbits8 = V_BITS8_DEFINED; // Make V bits defined! - ok = False; + if (VA_BITS2_DEFINED == vabits2) { + *vbits8 = V_BITS8_DEFINED; + } else if (VA_BITS2_UNDEFINED == vabits2) { + *vbits8 = V_BITS8_UNDEFINED; + } else if (VA_BITS2_NOACCESS == vabits2) { + *vbits8 = V_BITS8_DEFINED; // Make V bits defined! + ok = False; } else { - tl_assert( VA_BITS2_PARTDEFINED == vabits2 ); + tl_assert(VA_BITS2_PARTDEFINED == vabits2); *vbits8 = get_sec_vbits8(a); } return ok; } - /* --------------- Secondary V bit table ------------ */ // This table holds the full V bit pattern for partially-defined bytes @@ -904,12 +896,12 @@ static ULong sec_vbits_updates = 0; // the number of total nodes. In practice sometimes they are clustered (eg. // perf/bz2 repeatedly writes then reads more than 20,000 in a contiguous // row), but often not. So we choose something intermediate. -#define BYTES_PER_SEC_VBIT_NODE 16 +#define BYTES_PER_SEC_VBIT_NODE 16 // We make the table bigger by a factor of STEPUP_GROWTH_FACTOR if // more than this many nodes survive a GC. -#define STEPUP_SURVIVOR_PROPORTION 0.5 -#define STEPUP_GROWTH_FACTOR 1.414213562 +#define STEPUP_SURVIVOR_PROPORTION 0.5 +#define STEPUP_GROWTH_FACTOR 1.414213562 // If the above heuristic doesn't apply, then we may make the table // slightly bigger, by a factor of DRIFTUP_GROWTH_FACTOR, if more than @@ -928,30 +920,26 @@ static ULong sec_vbits_updates = 0; // We GC the table when it gets this many nodes in it, ie. it's effectively // the table size. It can change. -static Int secVBitLimit = 1000; +static Int secVBitLimit = 1000; // The number of GCs done, used to age sec-V-bit nodes for eviction. // Because it's unsigned, wrapping doesn't matter -- the right answer will // come out anyway. static UInt GCs_done = 0; -typedef - struct { - Addr a; - UChar vbits8[BYTES_PER_SEC_VBIT_NODE]; - } - SecVBitNode; +typedef struct { + Addr a; + UChar vbits8[BYTES_PER_SEC_VBIT_NODE]; +} SecVBitNode; static OSet* createSecVBitTable(void) { OSet* newSecVBitTable; - newSecVBitTable = VG_(OSetGen_Create_With_Pool) - ( offsetof(SecVBitNode, a), - NULL, // use fast comparisons - VG_(malloc), "mc.cSVT.1 (sec VBit table)", - VG_(free), - 1000, - sizeof(SecVBitNode)); + newSecVBitTable = + VG_(OSetGen_Create_With_Pool)(offsetof(SecVBitNode, a), + NULL, // use fast comparisons + VG_(malloc), "mc.cSVT.1 (sec VBit table)", + VG_(free), 1000, sizeof(SecVBitNode)); return newSecVBitTable; } @@ -968,7 +956,7 @@ static void gcSecVBitTable(void) // Traverse the table, moving fresh nodes into the new table. VG_(OSetGen_ResetIter)(secVBitTable); - while ( (n = VG_(OSetGen_Next)(secVBitTable)) ) { + while ((n = VG_(OSetGen_Next)(secVBitTable))) { // Keep node if any of its bytes are non-stale. Using // get_vabits2() for the lookup is not very efficient, but I don't // think it matters. @@ -994,27 +982,25 @@ static void gcSecVBitTable(void) secVBitTable = secVBitTable2; if (VG_(clo_verbosity) > 1 && n_nodes != 0) { - VG_(message)(Vg_DebugMsg, "memcheck GC: %d nodes, %d survivors (%.1f%%)\n", - n_nodes, n_survivors, n_survivors * 100.0 / n_nodes); + VG_(message)(Vg_DebugMsg, + "memcheck GC: %d nodes, %d survivors (%.1f%%)\n", n_nodes, + n_survivors, n_survivors * 100.0 / n_nodes); } // Increase table size if necessary. - if ((Double)n_survivors - > ((Double)secVBitLimit * STEPUP_SURVIVOR_PROPORTION)) { + if ((Double)n_survivors > + ((Double)secVBitLimit * STEPUP_SURVIVOR_PROPORTION)) { secVBitLimit = (Int)((Double)secVBitLimit * (Double)STEPUP_GROWTH_FACTOR); if (VG_(clo_verbosity) > 1) - VG_(message)(Vg_DebugMsg, - "memcheck GC: %d new table size (stepup)\n", + VG_(message)(Vg_DebugMsg, "memcheck GC: %d new table size (stepup)\n", secVBitLimit); - } - else - if (secVBitLimit < DRIFTUP_MAX_SIZE - && (Double)n_survivors - > ((Double)secVBitLimit * DRIFTUP_SURVIVOR_PROPORTION)) { - secVBitLimit = (Int)((Double)secVBitLimit * (Double)DRIFTUP_GROWTH_FACTOR); + } else if (secVBitLimit < DRIFTUP_MAX_SIZE && + (Double)n_survivors > + ((Double)secVBitLimit * DRIFTUP_SURVIVOR_PROPORTION)) { + secVBitLimit = + (Int)((Double)secVBitLimit * (Double)DRIFTUP_GROWTH_FACTOR); if (VG_(clo_verbosity) > 1) - VG_(message)(Vg_DebugMsg, - "memcheck GC: %d new table size (driftup)\n", + VG_(message)(Vg_DebugMsg, "memcheck GC: %d new table size (driftup)\n", secVBitLimit); } } @@ -1036,13 +1022,13 @@ static UWord get_sec_vbits8(Addr a) static void set_sec_vbits8(Addr a, UWord vbits8) { Addr aAligned = VG_ROUNDDN(a, BYTES_PER_SEC_VBIT_NODE); - Int i, amod = a % BYTES_PER_SEC_VBIT_NODE; - SecVBitNode* n = VG_(OSetGen_Lookup)(secVBitTable, &aAligned); + Int i, amod = a % BYTES_PER_SEC_VBIT_NODE; + SecVBitNode* n = VG_(OSetGen_Lookup)(secVBitTable, &aAligned); // Shouldn't be fully defined or fully undefined -- those cases shouldn't // make it to the secondary V bits table. tl_assert(V_BITS8_DEFINED != vbits8 && V_BITS8_UNDEFINED != vbits8); if (n) { - n->vbits8[amod] = vbits8; // update + n->vbits8[amod] = vbits8; // update sec_vbits_updates++; } else { // Do a table GC if necessary. Nb: do this before creating and @@ -1053,8 +1039,8 @@ static void set_sec_vbits8(Addr a, UWord vbits8) // New node: assign the specific byte, make the rest invalid (they // should never be read as-is, but be cautious). - n = VG_(OSetGen_AllocNode)(secVBitTable, sizeof(SecVBitNode)); - n->a = aAligned; + n = VG_(OSetGen_AllocNode)(secVBitTable, sizeof(SecVBitNode)); + n->a = aAligned; for (i = 0; i < BYTES_PER_SEC_VBIT_NODE; i++) { n->vbits8[i] = V_BITS8_UNDEFINED; } @@ -1074,12 +1060,11 @@ static void set_sec_vbits8(Addr a, UWord vbits8) /* Returns the offset in memory of the byteno-th most significant byte in a wordszB-sized word, given the specified endianness. */ -static INLINE UWord byte_offset_w ( UWord wordszB, Bool bigendian, - UWord byteno ) { - return bigendian ? (wordszB-1-byteno) : byteno; +static INLINE UWord byte_offset_w(UWord wordszB, Bool bigendian, UWord byteno) +{ + return bigendian ? (wordszB - 1 - byteno) : byteno; } - /* --------------- Ignored address ranges --------------- */ /* Denotes the address-error-reportability status for address ranges: @@ -1087,61 +1072,70 @@ static INLINE UWord byte_offset_w ( UWord wordszB, Bool bigendian, IAR_CommandLine: don't report errors -- from command line setting IAR_ClientReq: don't report errors -- from client request */ -typedef - enum { IAR_INVALID=99, - IAR_NotIgnored, - IAR_CommandLine, - IAR_ClientReq } - IARKind; +typedef enum { + IAR_INVALID = 99, + IAR_NotIgnored, + IAR_CommandLine, + IAR_ClientReq +} IARKind; -static const HChar* showIARKind ( IARKind iark ) +static const HChar* showIARKind(IARKind iark) { switch (iark) { - case IAR_INVALID: return "INVALID"; - case IAR_NotIgnored: return "NotIgnored"; - case IAR_CommandLine: return "CommandLine"; - case IAR_ClientReq: return "ClientReq"; - default: return "???"; + case IAR_INVALID: + return "INVALID"; + case IAR_NotIgnored: + return "NotIgnored"; + case IAR_CommandLine: + return "CommandLine"; + case IAR_ClientReq: + return "ClientReq"; + default: + return "???"; } } // RangeMap static RangeMap* gIgnoredAddressRanges = NULL; -static void init_gIgnoredAddressRanges ( void ) +static void init_gIgnoredAddressRanges(void) { if (LIKELY(gIgnoredAddressRanges != NULL)) return; - gIgnoredAddressRanges = VG_(newRangeMap)( VG_(malloc), "mc.igIAR.1", - VG_(free), IAR_NotIgnored ); + gIgnoredAddressRanges = + VG_(newRangeMap)(VG_(malloc), "mc.igIAR.1", VG_(free), IAR_NotIgnored); } -Bool MC_(in_ignored_range) ( Addr a ) +Bool MC_(in_ignored_range)(Addr a) { if (LIKELY(gIgnoredAddressRanges == NULL)) return False; UWord how = IAR_INVALID; UWord key_min = ~(UWord)0; - UWord key_max = (UWord)0; + UWord key_max = (UWord)0; VG_(lookupRangeMap)(&key_min, &key_max, &how, gIgnoredAddressRanges, a); tl_assert(key_min <= a && a <= key_max); switch (how) { - case IAR_NotIgnored: return False; - case IAR_CommandLine: return True; - case IAR_ClientReq: return True; - default: break; /* invalid */ + case IAR_NotIgnored: + return False; + case IAR_CommandLine: + return True; + case IAR_ClientReq: + return True; + default: + break; /* invalid */ } VG_(tool_panic)("MC_(in_ignore_range)"); /*NOTREACHED*/ } -Bool MC_(in_ignored_range_below_sp) ( Addr sp, Addr a, UInt szB ) +Bool MC_(in_ignored_range_below_sp)(Addr sp, Addr a, UInt szB) { if (LIKELY(!MC_(clo_ignore_range_below_sp))) - return False; + return False; tl_assert(szB >= 1 && szB <= 32); - tl_assert(MC_(clo_ignore_range_below_sp__first_offset) - > MC_(clo_ignore_range_below_sp__last_offset)); + tl_assert(MC_(clo_ignore_range_below_sp__first_offset) > + MC_(clo_ignore_range_below_sp__last_offset)); Addr range_lo = sp - MC_(clo_ignore_range_below_sp__first_offset); Addr range_hi = sp - MC_(clo_ignore_range_below_sp__last_offset); if (range_lo >= range_hi) { @@ -1160,15 +1154,15 @@ Bool MC_(in_ignored_range_below_sp) ( Addr sp, Addr a, UInt szB ) /* Parse two Addrs (in hex) separated by a dash, or fail. */ -static Bool parse_Addr_pair ( const HChar** ppc, Addr* result1, Addr* result2 ) +static Bool parse_Addr_pair(const HChar** ppc, Addr* result1, Addr* result2) { - Bool ok = VG_(parse_Addr) (ppc, result1); + Bool ok = VG_(parse_Addr)(ppc, result1); if (!ok) return False; if (**ppc != '-') return False; (*ppc)++; - ok = VG_(parse_Addr) (ppc, result2); + ok = VG_(parse_Addr)(ppc, result2); if (!ok) return False; return True; @@ -1177,15 +1171,15 @@ static Bool parse_Addr_pair ( const HChar** ppc, Addr* result1, Addr* result2 ) /* Parse two UInts (32 bit unsigned, in decimal) separated by a dash, or fail. */ -static Bool parse_UInt_pair ( const HChar** ppc, UInt* result1, UInt* result2 ) +static Bool parse_UInt_pair(const HChar** ppc, UInt* result1, UInt* result2) { - Bool ok = VG_(parse_UInt) (ppc, result1); + Bool ok = VG_(parse_UInt)(ppc, result1); if (!ok) return False; if (**ppc != '-') return False; (*ppc)++; - ok = VG_(parse_UInt) (ppc, result2); + ok = VG_(parse_UInt)(ppc, result2); if (!ok) return False; return True; @@ -1194,7 +1188,7 @@ static Bool parse_UInt_pair ( const HChar** ppc, UInt* result1, UInt* result2 ) /* Parse a set of ranges separated by commas into 'ignoreRanges', or fail. If they are valid, add them to the global set of ignored ranges. */ -static Bool parse_ignore_ranges ( const HChar* str0 ) +static Bool parse_ignore_ranges(const HChar* str0) { init_gIgnoredAddressRanges(); const HChar* str = str0; @@ -1207,7 +1201,7 @@ static Bool parse_ignore_ranges ( const HChar* str0 ) return False; if (start > end) return False; - VG_(bindRangeMap)( gIgnoredAddressRanges, start, end, IAR_CommandLine ); + VG_(bindRangeMap)(gIgnoredAddressRanges, start, end, IAR_CommandLine); if (**ppc == 0) return True; if (**ppc != ',') @@ -1219,7 +1213,7 @@ static Bool parse_ignore_ranges ( const HChar* str0 ) } /* Add or remove [start, +len) from the set of ignored ranges. */ -static Bool modify_ignore_ranges ( Bool addRange, Addr start, Addr len ) +static Bool modify_ignore_ranges(Bool addRange, Addr start, Addr len) { init_gIgnoredAddressRanges(); const Bool verbose = (VG_(clo_verbosity) > 1); @@ -1227,17 +1221,17 @@ static Bool modify_ignore_ranges ( Bool addRange, Addr start, Addr len ) return False; } if (addRange) { - VG_(bindRangeMap)(gIgnoredAddressRanges, - start, start+len-1, IAR_ClientReq); + VG_(bindRangeMap)(gIgnoredAddressRanges, start, start + len - 1, + IAR_ClientReq); if (verbose) - VG_(dmsg)("memcheck: modify_ignore_ranges: add %p %p\n", - (void*)start, (void*)(start+len-1)); + VG_(dmsg)("memcheck: modify_ignore_ranges: add %p %p\n", (void*)start, + (void*)(start + len - 1)); } else { - VG_(bindRangeMap)(gIgnoredAddressRanges, - start, start+len-1, IAR_NotIgnored); + VG_(bindRangeMap)(gIgnoredAddressRanges, start, start + len - 1, + IAR_NotIgnored); if (verbose) - VG_(dmsg)("memcheck: modify_ignore_ranges: del %p %p\n", - (void*)start, (void*)(start+len-1)); + VG_(dmsg)("memcheck: modify_ignore_ranges: del %p %p\n", (void*)start, + (void*)(start + len - 1)); } if (verbose) { VG_(dmsg)("memcheck: now have %u ranges:\n", @@ -1247,26 +1241,22 @@ static Bool modify_ignore_ranges ( Bool addRange, Addr start, Addr len ) UWord val = IAR_INVALID; UWord key_min = ~(UWord)0; UWord key_max = (UWord)0; - VG_(indexRangeMap)( &key_min, &key_max, &val, - gIgnoredAddressRanges, i ); - VG_(dmsg)("memcheck: [%u] %016lx-%016lx %s\n", - i, key_min, key_max, showIARKind(val)); + VG_(indexRangeMap)(&key_min, &key_max, &val, gIgnoredAddressRanges, i); + VG_(dmsg)("memcheck: [%u] %016lx-%016lx %s\n", i, key_min, + key_max, showIARKind(val)); } } return True; } - /* --------------- Load/store slow cases. --------------- */ -static -__attribute__((noinline)) -void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, - Addr a, SizeT nBits, Bool bigendian ) +static __attribute__((noinline)) void mc_LOADV_128_or_256_slow( + /*OUT*/ ULong* res, Addr a, SizeT nBits, Bool bigendian) { - ULong pessim[4]; /* only used when p-l-ok=yes */ - SSizeT szB = nBits / 8; - SSizeT szL = szB / 8; /* Size in Longs (64-bit units) */ + ULong pessim[4]; /* only used when p-l-ok=yes */ + SSizeT szB = nBits / 8; + SSizeT szL = szB / 8; /* Size in Longs (64-bit units) */ SSizeT i, j; /* Must be signed. */ SizeT n_addrs_bad = 0; Addr ai; @@ -1275,7 +1265,7 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, /* Code below assumes load size is a power of two and at least 64 bits. */ - tl_assert((szB & (szB-1)) == 0 && szL > 0); + tl_assert((szB & (szB - 1)) == 0 && szL > 0); /* If this triggers, you probably just need to increase the size of the pessim array. */ @@ -1283,7 +1273,7 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, for (j = 0; j < szL; j++) { pessim[j] = V_BITS64_DEFINED; - res[j] = V_BITS64_UNDEFINED; + res[j] = V_BITS64_UNDEFINED; } /* Make up a result V word, which contains the loaded data for @@ -1294,21 +1284,22 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, --partial-loads-ok=yes. n_addrs_bad is redundant (the relevant info can be gleaned from the pessim array) but is used as a cross-check. */ - for (j = szL-1; j >= 0; j--) { + for (j = szL - 1; j >= 0; j--) { ULong vbits64 = V_BITS64_UNDEFINED; ULong pessim64 = V_BITS64_DEFINED; UWord long_index = byte_offset_w(szL, bigendian, j); - for (i = 8-1; i >= 0; i--) { + for (i = 8 - 1; i >= 0; i--) { PROF_EVENT(MCPE_LOADV_128_OR_256_SLOW_LOOP); - ai = a + 8*long_index + byte_offset_w(8, bigendian, i); + ai = a + 8 * long_index + byte_offset_w(8, bigendian, i); ok = get_vbits8(ai, &vbits8); vbits64 <<= 8; vbits64 |= vbits8; - if (!ok) n_addrs_bad++; + if (!ok) + n_addrs_bad++; pessim64 <<= 8; pessim64 |= (ok ? V_BITS8_DEFINED : V_BITS8_UNDEFINED); } - res[long_index] = vbits64; + res[long_index] = vbits64; pessim[long_index] = pessim64; } @@ -1320,7 +1311,7 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, /* If there's no possibility of getting a partial-loads-ok exemption, report the error and quit. */ if (!MC_(clo_partial_loads_ok)) { - MC_(record_address_error)( VG_(get_running_tid)(), a, szB, False ); + MC_(record_address_error)(VG_(get_running_tid)(), a, szB, False); return; } @@ -1353,17 +1344,17 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, ok |= pessim[j] != V_BITS64_DEFINED; tl_assert(ok); -# if defined(VGP_s390x_linux) +#if defined(VGP_s390x_linux) tl_assert(szB == 16); // s390 doesn't have > 128 bit SIMD /* OK if all loaded bytes are from the same page. */ Bool alignedOK = ((a & 0xfff) <= 0x1000 - szB); -# elif defined(VGA_ppc64be) || defined(VGA_ppc64le) +#elif defined(VGA_ppc64be) || defined(VGA_ppc64le) /* lxvd2x might generate an unaligned 128 bit vector load. */ Bool alignedOK = (szB == 16); -# else +#else /* OK if the address is aligned by the load size. */ Bool alignedOK = (0 == (a & (szB - 1))); -# endif +#endif if (alignedOK && n_addrs_bad < szB) { /* Exemption applies. Use the previously computed pessimising @@ -1374,28 +1365,25 @@ void mc_LOADV_128_or_256_slow ( /*OUT*/ULong* res, tl_assert(V_BIT_UNDEFINED == 1 && V_BIT_DEFINED == 0); /* (really need "UifU" here...) vbits[j] UifU= pessim[j] (is pessimised by it, iow) */ - for (j = szL-1; j >= 0; j--) + for (j = szL - 1; j >= 0; j--) res[j] |= pessim[j]; return; } /* Exemption doesn't apply. Flag an addressing error in the normal way. */ - MC_(record_address_error)( VG_(get_running_tid)(), a, szB, False ); + MC_(record_address_error)(VG_(get_running_tid)(), a, szB, False); } MC_MAIN_STATIC -__attribute__((noinline)) -__attribute__((used)) -VG_REGPARM(3) -ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ); +__attribute__((noinline)) __attribute__((used)) VG_REGPARM(3) ULong + mc_LOADVn_slow(Addr a, SizeT nBits, Bool bigendian); MC_MAIN_STATIC -__attribute__((noinline)) -__attribute__((used)) +__attribute__((noinline)) __attribute__((used)) VG_REGPARM(3) /* make sure we're using a fixed calling convention, since this function may get called from hand written assembly. */ -ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) + ULong mc_LOADVn_slow(Addr a, SizeT nBits, Bool bigendian) { PROF_EVENT(MCPE_LOADVN_SLOW); @@ -1408,11 +1396,11 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) from LOADV64 and LOADV32. */ -# if defined(VGA_mips64) && defined(VGABI_N32) +#if defined(VGA_mips64) && defined(VGABI_N32) if (LIKELY(sizeof(void*) == 4 && nBits == 64 && VG_IS_8_ALIGNED(a))) -# else +#else if (LIKELY(sizeof(void*) == 8 && nBits == 64 && VG_IS_8_ALIGNED(a))) -# endif +#endif { SecMap* sm = get_secmap_for_reading(a); UWord sm_off16 = SM_OFF_16(a); @@ -1424,15 +1412,15 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) /* else fall into the slow case */ } -# if defined(VGA_mips64) && defined(VGABI_N32) +#if defined(VGA_mips64) && defined(VGABI_N32) if (LIKELY(sizeof(void*) == 4 && nBits == 32 && VG_IS_4_ALIGNED(a))) -# else +#else if (LIKELY(sizeof(void*) == 8 && nBits == 32 && VG_IS_4_ALIGNED(a))) -# endif +#endif { - SecMap* sm = get_secmap_for_reading(a); - UWord sm_off = SM_OFF(a); - UWord vabits8 = sm->vabits8[sm_off]; + SecMap* sm = get_secmap_for_reading(a); + UWord sm_off = SM_OFF(a); + UWord vabits8 = sm->vabits8[sm_off]; if (LIKELY(vabits8 == VA_BITS8_DEFINED)) return ((UWord)0xFFFFFFFF00000000ULL | (UWord)V_BITS32_DEFINED); if (LIKELY(vabits8 == VA_BITS8_UNDEFINED)) @@ -1442,10 +1430,10 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) /* ------------ END semi-fast cases ------------ */ - ULong vbits64 = V_BITS64_UNDEFINED; /* result */ - ULong pessim64 = V_BITS64_DEFINED; /* only used when p-l-ok=yes */ - SSizeT szB = nBits / 8; - SSizeT i; /* Must be signed. */ + ULong vbits64 = V_BITS64_UNDEFINED; /* result */ + ULong pessim64 = V_BITS64_DEFINED; /* only used when p-l-ok=yes */ + SSizeT szB = nBits / 8; + SSizeT i; /* Must be signed. */ SizeT n_addrs_bad = 0; Addr ai; UChar vbits8; @@ -1461,13 +1449,14 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) --partial-loads-ok=yes. n_addrs_bad is redundant (the relevant info can be gleaned from pessim64) but is used as a cross-check. */ - for (i = szB-1; i >= 0; i--) { + for (i = szB - 1; i >= 0; i--) { PROF_EVENT(MCPE_LOADVN_SLOW_LOOP); ai = a + byte_offset_w(szB, bigendian, i); ok = get_vbits8(ai, &vbits8); vbits64 <<= 8; vbits64 |= vbits8; - if (!ok) n_addrs_bad++; + if (!ok) + n_addrs_bad++; pessim64 <<= 8; pessim64 |= (ok ? V_BITS8_DEFINED : V_BITS8_UNDEFINED); } @@ -1480,7 +1469,7 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) /* If there's no possibility of getting a partial-loads-ok exemption, report the error and quit. */ if (!MC_(clo_partial_loads_ok)) { - MC_(record_address_error)( VG_(get_running_tid)(), a, szB, False ); + MC_(record_address_error)(VG_(get_running_tid)(), a, szB, False); return vbits64; } @@ -1511,16 +1500,15 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) /* "at least one of the addresses is invalid" */ tl_assert(pessim64 != V_BITS64_DEFINED); -# if defined(VGA_mips64) && defined(VGABI_N32) - if (szB == VG_WORDSIZE * 2 && VG_IS_WORD_ALIGNED(a) - && n_addrs_bad < VG_WORDSIZE * 2) -# elif defined(VGA_ppc64be) || defined(VGA_ppc64le) +#if defined(VGA_mips64) && defined(VGABI_N32) + if (szB == VG_WORDSIZE * 2 && VG_IS_WORD_ALIGNED(a) && + n_addrs_bad < VG_WORDSIZE * 2) +#elif defined(VGA_ppc64be) || defined(VGA_ppc64le) /* On power unaligned loads of words are OK. */ if (szB == VG_WORDSIZE && n_addrs_bad < VG_WORDSIZE) -# else - if (szB == VG_WORDSIZE && VG_IS_WORD_ALIGNED(a) - && n_addrs_bad < VG_WORDSIZE) -# endif +#else + if (szB == VG_WORDSIZE && VG_IS_WORD_ALIGNED(a) && n_addrs_bad < VG_WORDSIZE) +#endif { /* Exemption applies. Use the previously computed pessimising value for vbits64 and return the combined result, but don't @@ -1539,13 +1527,11 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) for this case. Note that the first clause of the conditional (VG_WORDSIZE == 8) is known at compile time, so the whole clause will get folded out in 32 bit builds. */ -# if defined(VGA_mips64) && defined(VGABI_N32) - if (VG_WORDSIZE == 4 - && VG_IS_4_ALIGNED(a) && nBits == 32 && n_addrs_bad < 4) -# else - if (VG_WORDSIZE == 8 - && VG_IS_4_ALIGNED(a) && nBits == 32 && n_addrs_bad < 4) -# endif +#if defined(VGA_mips64) && defined(VGABI_N32) + if (VG_WORDSIZE == 4 && VG_IS_4_ALIGNED(a) && nBits == 32 && n_addrs_bad < 4) +#else + if (VG_WORDSIZE == 8 && VG_IS_4_ALIGNED(a) && nBits == 32 && n_addrs_bad < 4) +#endif { tl_assert(V_BIT_UNDEFINED == 1 && V_BIT_DEFINED == 0); /* (really need "UifU" here...) @@ -1559,15 +1545,13 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian ) /* Exemption doesn't apply. Flag an addressing error in the normal way. */ - MC_(record_address_error)( VG_(get_running_tid)(), a, szB, False ); + MC_(record_address_error)(VG_(get_running_tid)(), a, szB, False); return vbits64; } - -static -__attribute__((noinline)) -void mc_STOREVn_slow ( Addr a, SizeT nBits, ULong vbytes, Bool bigendian ) +static __attribute__((noinline)) void +mc_STOREVn_slow(Addr a, SizeT nBits, ULong vbytes, Bool bigendian) { SizeT szB = nBits / 8; SizeT i, n_addrs_bad = 0; @@ -1586,18 +1570,18 @@ void mc_STOREVn_slow ( Addr a, SizeT nBits, ULong vbytes, Bool bigendian ) is somewhat similar to some cases extensively commented in MC_(helperc_STOREV8). */ -# if defined(VGA_mips64) && defined(VGABI_N32) +#if defined(VGA_mips64) && defined(VGABI_N32) if (LIKELY(sizeof(void*) == 4 && nBits == 64 && VG_IS_8_ALIGNED(a))) -# else +#else if (LIKELY(sizeof(void*) == 8 && nBits == 64 && VG_IS_8_ALIGNED(a))) -# endif +#endif { SecMap* sm = get_secmap_for_reading(a); UWord sm_off16 = SM_OFF_16(a); UWord vabits16 = sm->vabits16[sm_off16]; - if (LIKELY( !is_distinguished_sm(sm) && - (VA_BITS16_DEFINED == vabits16 || - VA_BITS16_UNDEFINED == vabits16) )) { + if (LIKELY(!is_distinguished_sm(sm) && + (VA_BITS16_DEFINED == vabits16 || + VA_BITS16_UNDEFINED == vabits16))) { /* Handle common case quickly: a is suitably aligned, */ /* is mapped, and is addressible. */ // Convert full V-bits in register to compact 2-bit form. @@ -1613,18 +1597,17 @@ void mc_STOREVn_slow ( Addr a, SizeT nBits, ULong vbytes, Bool bigendian ) /* else fall into the slow case */ } -# if defined(VGA_mips64) && defined(VGABI_N32) +#if defined(VGA_mips64) && defined(VGABI_N32) if (LIKELY(sizeof(void*) == 4 && nBits == 32 && VG_IS_4_ALIGNED(a))) -# else +#else if (LIKELY(sizeof(void*) == 8 && nBits == 32 && VG_IS_4_ALIGNED(a))) -# endif +#endif { SecMap* sm = get_secmap_for_reading(a); UWord sm_off = SM_OFF(a); UWord vabits8 = sm->vabits8[sm_off]; - if (LIKELY( !is_distinguished_sm(sm) && - (VA_BITS8_DEFINED == vabits8 || - VA_BITS8_UNDEFINED == vabits8) )) { + if (LIKELY(!is_distinguished_sm(sm) && (VA_BITS8_DEFINED == vabits8 || + VA_BITS8_UNDEFINED == vabits8))) { /* Handle common case quickly: a is suitably aligned, */ /* is mapped, and is addressible. */ // Convert full V-bits in register to compact 2-bit form. @@ -1650,22 +1633,22 @@ void mc_STOREVn_slow ( Addr a, SizeT nBits, ULong vbytes, Bool bigendian ) ai = a + byte_offset_w(szB, bigendian, i); vbits8 = vbytes & 0xff; ok = set_vbits8(ai, vbits8); - if (!ok) n_addrs_bad++; + if (!ok) + n_addrs_bad++; vbytes >>= 8; } /* If an address error has happened, report it. */ if (n_addrs_bad > 0) - MC_(record_address_error)( VG_(get_running_tid)(), a, szB, True ); + MC_(record_address_error)(VG_(get_running_tid)(), a, szB, True); } - /*------------------------------------------------------------*/ /*--- Setting permissions over address ranges. ---*/ /*------------------------------------------------------------*/ -static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, - UWord dsm_num ) +static void +set_address_range_perms(Addr a, SizeT lenT, UWord vabits16, UWord dsm_num) { UWord sm_off, sm_off16; UWord vabits2 = vabits16 & 0x3; @@ -1678,9 +1661,8 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS); /* Check the V+A bits make sense. */ - tl_assert(VA_BITS16_NOACCESS == vabits16 || - VA_BITS16_UNDEFINED == vabits16 || - VA_BITS16_DEFINED == vabits16); + tl_assert(VA_BITS16_NOACCESS == vabits16 || + VA_BITS16_UNDEFINED == vabits16 || VA_BITS16_DEFINED == vabits16); // This code should never write PDBs; ensure this. (See comment above // set_vabits2().) @@ -1692,12 +1674,16 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, if (lenT > 256 * 1024 * 1024) { if (VG_(clo_verbosity) > 0 && !VG_(clo_xml)) { const HChar* s = "unknown???"; - if (vabits16 == VA_BITS16_NOACCESS ) s = "noaccess"; - if (vabits16 == VA_BITS16_UNDEFINED) s = "undefined"; - if (vabits16 == VA_BITS16_DEFINED ) s = "defined"; - VG_(message)(Vg_UserMsg, "Warning: set address range perms: " - "large range [0x%lx, 0x%lx) (%s)\n", - a, a + lenT, s); + if (vabits16 == VA_BITS16_NOACCESS) + s = "noaccess"; + if (vabits16 == VA_BITS16_UNDEFINED) + s = "undefined"; + if (vabits16 == VA_BITS16_DEFINED) + s = "defined"; + VG_(message)(Vg_UserMsg, + "Warning: set address range perms: " + "large range [0x%lx, 0x%lx) (%s)\n", + a, a + lenT, s); } } @@ -1749,9 +1735,9 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, // Break up total length (lenT) into two parts: length in the first // sec-map (lenA), and the rest (lenB); lenT == lenA + lenB. - aNext = start_of_this_sm(a) + SM_SIZE; + aNext = start_of_this_sm(a) + SM_SIZE; len_to_next_secmap = aNext - a; - if ( lenT <= len_to_next_secmap ) { + if (lenT <= len_to_next_secmap) { // Range entirely within one sec-map. Covers almost all cases. PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_SINGLE_SECMAP); lenA = lenT; @@ -1794,30 +1780,34 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, // 1 byte steps while (True) { - if (VG_IS_8_ALIGNED(a)) break; - if (lenA < 1) break; + if (VG_IS_8_ALIGNED(a)) + break; + if (lenA < 1) + break; PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1A); sm_off = SM_OFF(a); - insert_vabits2_into_vabits8( a, vabits2, &(sm->vabits8[sm_off]) ); - a += 1; + insert_vabits2_into_vabits8(a, vabits2, &(sm->vabits8[sm_off])); + a += 1; lenA -= 1; } // 8-aligned, 8 byte steps while (True) { - if (lenA < 8) break; + if (lenA < 8) + break; PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8A); - sm_off16 = SM_OFF_16(a); + sm_off16 = SM_OFF_16(a); sm->vabits16[sm_off16] = vabits16; - a += 8; + a += 8; lenA -= 8; } // 1 byte steps while (True) { - if (lenA < 1) break; + if (lenA < 1) + break; PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1B); sm_off = SM_OFF(a); - insert_vabits2_into_vabits8( a, vabits2, &(sm->vabits8[sm_off]) ); - a += 1; + insert_vabits2_into_vabits8(a, vabits2, &(sm->vabits8[sm_off])); + a += 1; lenA -= 1; } @@ -1828,12 +1818,13 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, //------------------------------------------------------------------------ // Part 2: Fast-set entire sec-maps at a time. //------------------------------------------------------------------------ - part2: +part2: // 64KB-aligned, 64KB steps. // Nb: we can reach here with lenB < SM_SIZE tl_assert(0 == lenA); while (True) { - if (lenB < SM_SIZE) break; + if (lenB < SM_SIZE) + break; tl_assert(is_start_of_sm(a)); PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP64K); sm_ptr = get_secmap_ptr(a); @@ -1842,13 +1833,13 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, // Free the non-distinguished sec-map that we're replacing. This // case happens moderately often, enough to be worthwhile. SysRes sres = VG_(am_munmap_valgrind)((Addr)*sm_ptr, sizeof(SecMap)); - tl_assert2(! sr_isError(sres), "SecMap valgrind munmap failure\n"); + tl_assert2(!sr_isError(sres), "SecMap valgrind munmap failure\n"); } update_SM_counts(*sm_ptr, example_dsm); // Make the sec-map entry point to the example DSM *sm_ptr = example_dsm; lenB -= SM_SIZE; - a += SM_SIZE; + a += SM_SIZE; } // We've finished the whole sec-maps. Is that it? @@ -1877,91 +1868,89 @@ static void set_address_range_perms ( Addr a, SizeT lenT, UWord vabits16, // 8-aligned, 8 byte steps while (True) { - if (lenB < 8) break; + if (lenB < 8) + break; PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8B); - sm_off16 = SM_OFF_16(a); + sm_off16 = SM_OFF_16(a); sm->vabits16[sm_off16] = vabits16; - a += 8; + a += 8; lenB -= 8; } // 1 byte steps while (True) { - if (lenB < 1) return; + if (lenB < 1) + return; PROF_EVENT(MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1C); sm_off = SM_OFF(a); - insert_vabits2_into_vabits8( a, vabits2, &(sm->vabits8[sm_off]) ); - a += 1; + insert_vabits2_into_vabits8(a, vabits2, &(sm->vabits8[sm_off])); + a += 1; lenB -= 1; } } - /* --- Set permissions for arbitrary address ranges --- */ -void MC_(make_mem_noaccess) ( Addr a, SizeT len ) +void MC_(make_mem_noaccess)(Addr a, SizeT len) { PROF_EVENT(MCPE_MAKE_MEM_NOACCESS); DEBUG("MC_(make_mem_noaccess)(%p, %lu)\n", a, len); - set_address_range_perms ( a, len, VA_BITS16_NOACCESS, SM_DIST_NOACCESS ); - if (UNLIKELY( MC_(clo_mc_level) == 3 )) - ocache_sarp_Clear_Origins ( a, len ); + set_address_range_perms(a, len, VA_BITS16_NOACCESS, SM_DIST_NOACCESS); + if (UNLIKELY(MC_(clo_mc_level) == 3)) + ocache_sarp_Clear_Origins(a, len); } -static void make_mem_undefined ( Addr a, SizeT len ) +static void make_mem_undefined(Addr a, SizeT len) { PROF_EVENT(MCPE_MAKE_MEM_UNDEFINED); DEBUG("make_mem_undefined(%p, %lu)\n", a, len); - set_address_range_perms ( a, len, VA_BITS16_UNDEFINED, SM_DIST_UNDEFINED ); + set_address_range_perms(a, len, VA_BITS16_UNDEFINED, SM_DIST_UNDEFINED); } -void MC_(make_mem_undefined_w_otag) ( Addr a, SizeT len, UInt otag ) +void MC_(make_mem_undefined_w_otag)(Addr a, SizeT len, UInt otag) { PROF_EVENT(MCPE_MAKE_MEM_UNDEFINED_W_OTAG); DEBUG("MC_(make_mem_undefined)(%p, %lu)\n", a, len); - set_address_range_perms ( a, len, VA_BITS16_UNDEFINED, SM_DIST_UNDEFINED ); - if (UNLIKELY( MC_(clo_mc_level) == 3 )) - ocache_sarp_Set_Origins ( a, len, otag ); + set_address_range_perms(a, len, VA_BITS16_UNDEFINED, SM_DIST_UNDEFINED); + if (UNLIKELY(MC_(clo_mc_level) == 3)) + ocache_sarp_Set_Origins(a, len, otag); } -static -void make_mem_undefined_w_tid_and_okind ( Addr a, SizeT len, - ThreadId tid, UInt okind ) +static void +make_mem_undefined_w_tid_and_okind(Addr a, SizeT len, ThreadId tid, UInt okind) { UInt ecu; ExeContext* here; /* VG_(record_ExeContext) checks for validity of tid, and asserts if it is invalid. So no need to do it here. */ tl_assert(okind <= 3); - here = VG_(record_ExeContext)( tid, 0/*first_ip_delta*/ ); + here = VG_(record_ExeContext)(tid, 0 /*first_ip_delta*/); tl_assert(here); ecu = VG_(get_ECU_from_ExeContext)(here); tl_assert(VG_(is_plausible_ECU)(ecu)); - MC_(make_mem_undefined_w_otag) ( a, len, ecu | okind ); + MC_(make_mem_undefined_w_otag)(a, len, ecu | okind); } -static -void mc_new_mem_w_tid_make_ECU ( Addr a, SizeT len, ThreadId tid ) +static void mc_new_mem_w_tid_make_ECU(Addr a, SizeT len, ThreadId tid) { - make_mem_undefined_w_tid_and_okind ( a, len, tid, MC_OKIND_UNKNOWN ); + make_mem_undefined_w_tid_and_okind(a, len, tid, MC_OKIND_UNKNOWN); } -static -void mc_new_mem_w_tid_no_ECU ( Addr a, SizeT len, ThreadId tid ) +static void mc_new_mem_w_tid_no_ECU(Addr a, SizeT len, ThreadId tid) { - MC_(make_mem_undefined_w_otag) ( a, len, MC_OKIND_UNKNOWN ); + MC_(make_mem_undefined_w_otag)(a, len, MC_OKIND_UNKNOWN); } -void MC_(make_mem_defined) ( Addr a, SizeT len ) +void MC_(make_mem_defined)(Addr a, SizeT len) { PROF_EVENT(MCPE_MAKE_MEM_DEFINED); DEBUG("MC_(make_mem_defined)(%p, %lu)\n", a, len); - set_address_range_perms ( a, len, VA_BITS16_DEFINED, SM_DIST_DEFINED ); - if (UNLIKELY( MC_(clo_mc_level) == 3 )) - ocache_sarp_Clear_Origins ( a, len ); + set_address_range_perms(a, len, VA_BITS16_DEFINED, SM_DIST_DEFINED); + if (UNLIKELY(MC_(clo_mc_level) == 3)) + ocache_sarp_Clear_Origins(a, len); } -__attribute__((unused)) -static void make_mem_defined_w_tid ( Addr a, SizeT len, ThreadId tid ) +__attribute__((unused)) static void +make_mem_defined_w_tid(Addr a, SizeT len, ThreadId tid) { MC_(make_mem_defined)(a, len); } @@ -1970,34 +1959,34 @@ static void make_mem_defined_w_tid ( Addr a, SizeT len, ThreadId tid ) defined, but if it isn't addressible, leave it alone. In other words a version of MC_(make_mem_defined) that doesn't mess with addressibility. Low-performance implementation. */ -static void make_mem_defined_if_addressable ( Addr a, SizeT len ) +static void make_mem_defined_if_addressable(Addr a, SizeT len) { SizeT i; UChar vabits2; DEBUG("make_mem_defined_if_addressable(%p, %llu)\n", a, (ULong)len); for (i = 0; i < len; i++) { - vabits2 = get_vabits2( a+i ); + vabits2 = get_vabits2(a + i); if (LIKELY(VA_BITS2_NOACCESS != vabits2)) { - set_vabits2(a+i, VA_BITS2_DEFINED); + set_vabits2(a + i, VA_BITS2_DEFINED); if (UNLIKELY(MC_(clo_mc_level) >= 3)) { - MC_(helperc_b_store1)( a+i, 0 ); /* clear the origin tag */ + MC_(helperc_b_store1)(a + i, 0); /* clear the origin tag */ } } } } /* Similarly (needed for mprotect handling ..) */ -static void make_mem_defined_if_noaccess ( Addr a, SizeT len ) +static void make_mem_defined_if_noaccess(Addr a, SizeT len) { SizeT i; UChar vabits2; DEBUG("make_mem_defined_if_noaccess(%p, %llu)\n", a, (ULong)len); for (i = 0; i < len; i++) { - vabits2 = get_vabits2( a+i ); + vabits2 = get_vabits2(a + i); if (LIKELY(VA_BITS2_NOACCESS == vabits2)) { - set_vabits2(a+i, VA_BITS2_DEFINED); + set_vabits2(a + i, VA_BITS2_DEFINED); if (UNLIKELY(MC_(clo_mc_level) >= 3)) { - MC_(helperc_b_store1)( a+i, 0 ); /* clear the origin tag */ + MC_(helperc_b_store1)(a + i, 0); /* clear the origin tag */ } } } @@ -2006,7 +1995,7 @@ static void make_mem_defined_if_noaccess ( Addr a, SizeT len ) /* --- Block-copy permissions (needed for implementing realloc() and sys_mremap). --- */ -void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) +void MC_(copy_address_range_state)(Addr src, Addr dst, SizeT len) { SizeT i, j; UChar vabits2, vabits8; @@ -2019,7 +2008,7 @@ void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) return; aligned = VG_IS_4_ALIGNED(src) && VG_IS_4_ALIGNED(dst); - nooverlap = src+len <= dst || dst+len <= src; + nooverlap = src + len <= dst || dst + len <= src; if (nooverlap && aligned) { @@ -2027,32 +2016,32 @@ void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) /* vector loop */ i = 0; while (len >= 4) { - vabits8 = get_vabits8_for_aligned_word32( src+i ); - set_vabits8_for_aligned_word32( dst+i, vabits8 ); - if (LIKELY(VA_BITS8_DEFINED == vabits8 - || VA_BITS8_UNDEFINED == vabits8 - || VA_BITS8_NOACCESS == vabits8)) { + vabits8 = get_vabits8_for_aligned_word32(src + i); + set_vabits8_for_aligned_word32(dst + i, vabits8); + if (LIKELY(VA_BITS8_DEFINED == vabits8 || + VA_BITS8_UNDEFINED == vabits8 || + VA_BITS8_NOACCESS == vabits8)) { /* do nothing */ } else { /* have to copy secondary map info */ - if (VA_BITS2_PARTDEFINED == get_vabits2( src+i+0 )) - set_sec_vbits8( dst+i+0, get_sec_vbits8( src+i+0 ) ); - if (VA_BITS2_PARTDEFINED == get_vabits2( src+i+1 )) - set_sec_vbits8( dst+i+1, get_sec_vbits8( src+i+1 ) ); - if (VA_BITS2_PARTDEFINED == get_vabits2( src+i+2 )) - set_sec_vbits8( dst+i+2, get_sec_vbits8( src+i+2 ) ); - if (VA_BITS2_PARTDEFINED == get_vabits2( src+i+3 )) - set_sec_vbits8( dst+i+3, get_sec_vbits8( src+i+3 ) ); + if (VA_BITS2_PARTDEFINED == get_vabits2(src + i + 0)) + set_sec_vbits8(dst + i + 0, get_sec_vbits8(src + i + 0)); + if (VA_BITS2_PARTDEFINED == get_vabits2(src + i + 1)) + set_sec_vbits8(dst + i + 1, get_sec_vbits8(src + i + 1)); + if (VA_BITS2_PARTDEFINED == get_vabits2(src + i + 2)) + set_sec_vbits8(dst + i + 2, get_sec_vbits8(src + i + 2)); + if (VA_BITS2_PARTDEFINED == get_vabits2(src + i + 3)) + set_sec_vbits8(dst + i + 3, get_sec_vbits8(src + i + 3)); } i += 4; len -= 4; } /* fixup loop */ while (len >= 1) { - vabits2 = get_vabits2( src+i ); - set_vabits2( dst+i, vabits2 ); + vabits2 = get_vabits2(src + i); + set_vabits2(dst + i, vabits2); if (VA_BITS2_PARTDEFINED == vabits2) { - set_sec_vbits8( dst+i, get_sec_vbits8( src+i ) ); + set_sec_vbits8(dst + i, get_sec_vbits8(src + i)); } i++; len--; @@ -2062,12 +2051,12 @@ void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) /* We have to do things the slow way */ if (src < dst) { - for (i = 0, j = len-1; i < len; i++, j--) { + for (i = 0, j = len - 1; i < len; i++, j--) { PROF_EVENT(MCPE_COPY_ADDRESS_RANGE_STATE_LOOP1); - vabits2 = get_vabits2( src+j ); - set_vabits2( dst+j, vabits2 ); + vabits2 = get_vabits2(src + j); + set_vabits2(dst + j, vabits2); if (VA_BITS2_PARTDEFINED == vabits2) { - set_sec_vbits8( dst+j, get_sec_vbits8( src+j ) ); + set_sec_vbits8(dst + j, get_sec_vbits8(src + j)); } } } @@ -2075,18 +2064,16 @@ void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) if (src > dst) { for (i = 0; i < len; i++) { PROF_EVENT(MCPE_COPY_ADDRESS_RANGE_STATE_LOOP2); - vabits2 = get_vabits2( src+i ); - set_vabits2( dst+i, vabits2 ); + vabits2 = get_vabits2(src + i); + set_vabits2(dst + i, vabits2); if (VA_BITS2_PARTDEFINED == vabits2) { - set_sec_vbits8( dst+i, get_sec_vbits8( src+i ) ); + set_sec_vbits8(dst + i, get_sec_vbits8(src + i)); } } } } - } - /*------------------------------------------------------------*/ /*--- Origin tracking stuff - cache basics ---*/ /*------------------------------------------------------------*/ @@ -2400,35 +2387,37 @@ void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len ) practice. */ -static UWord stats_ocacheL1_find = 0; -static UWord stats_ocacheL1_found_at_1 = 0; -static UWord stats_ocacheL1_found_at_N = 0; -static UWord stats_ocacheL1_misses = 0; -static UWord stats_ocacheL1_lossage = 0; -static UWord stats_ocacheL1_movefwds = 0; +static UWord stats_ocacheL1_find = 0; +static UWord stats_ocacheL1_found_at_1 = 0; +static UWord stats_ocacheL1_found_at_N = 0; +static UWord stats_ocacheL1_misses = 0; +static UWord stats_ocacheL1_lossage = 0; +static UWord stats_ocacheL1_movefwds = 0; -static UWord stats__ocacheL2_finds = 0; -static UWord stats__ocacheL2_adds = 0; -static UWord stats__ocacheL2_dels = 0; -static UWord stats__ocacheL2_misses = 0; -static UWord stats__ocacheL2_n_nodes_max = 0; +static UWord stats__ocacheL2_finds = 0; +static UWord stats__ocacheL2_adds = 0; +static UWord stats__ocacheL2_dels = 0; +static UWord stats__ocacheL2_misses = 0; +static UWord stats__ocacheL2_n_nodes_max = 0; /* Cache of 32-bit values, one every 32 bits of address space */ #define OC_BITS_PER_LINE 5 #define OC_W32S_PER_LINE (1 << (OC_BITS_PER_LINE - 2)) -static INLINE UWord oc_line_offset ( Addr a ) { +static INLINE UWord oc_line_offset(Addr a) +{ return (a >> 2) & (OC_W32S_PER_LINE - 1); } -static INLINE Bool is_valid_oc_tag ( Addr tag ) { +static INLINE Bool is_valid_oc_tag(Addr tag) +{ return 0 == (tag & ((1 << OC_BITS_PER_LINE) - 1)); } #define OC_LINES_PER_SET 2 -#define OC_N_SET_BITS 20 -#define OC_N_SETS (1 << OC_N_SET_BITS) +#define OC_N_SET_BITS 20 +#define OC_N_SETS (1 << OC_N_SET_BITS) /* These settings give: 64 bit host: ocache: 100,663,296 sizeB 67,108,864 useful @@ -2437,7 +2426,6 @@ static INLINE Bool is_valid_oc_tag ( Addr tag ) { #define OC_MOVE_FORWARDS_EVERY_BITS 7 - /* Originally (pre Dec 2021) it was the case that this code had a parameterizable cache line size, set by changing OC_BITS_PER_LINE. However, as a result of the speedup fixes necessitated by bug 446103, that @@ -2464,40 +2452,35 @@ STATIC_ASSERT(OC_LINES_PER_SET == 2); // To ensure that OCacheLine.descr[] will fit in an integral number of ULongs. STATIC_ASSERT(0 == (OC_W32S_PER_LINE % 8)); -#define OC_W64S_PER_MAIN /* "MAIN" meaning "struct OCacheLine_Main" */ \ - (OC_W32S_PER_LINE / 2 /* covers OCacheLine_Main.w32[] */ \ - + OC_W32S_PER_LINE / 8) /* covers OCacheLine_Main.descr[] */ +#define OC_W64S_PER_MAIN /* "MAIN" meaning "struct OCacheLine_Main" */ \ + (OC_W32S_PER_LINE / 2 /* covers OCacheLine_Main.w32[] */ \ + + OC_W32S_PER_LINE / 8) /* covers OCacheLine_Main.descr[] */ STATIC_ASSERT(OC_W64S_PER_MAIN == 5); -typedef - ULong OCacheLine_W64s[OC_W64S_PER_MAIN]; +typedef ULong OCacheLine_W64s[OC_W64S_PER_MAIN]; -typedef - struct { - UInt w32 [OC_W32S_PER_LINE]; - UChar descr[OC_W32S_PER_LINE]; - } - OCacheLine_Main; +typedef struct { + UInt w32[OC_W32S_PER_LINE]; + UChar descr[OC_W32S_PER_LINE]; +} OCacheLine_Main; STATIC_ASSERT(sizeof(OCacheLine_W64s) == sizeof(OCacheLine_Main)); -typedef - struct { - Addr tag; - union { - OCacheLine_W64s w64s; - OCacheLine_Main main; - } u; - } - OCacheLine; +typedef struct { + Addr tag; + union { + OCacheLine_W64s w64s; + OCacheLine_Main main; + } u; +} OCacheLine; /* Classify and also sanity-check 'line'. Return 'e' (empty) if not in use, 'n' (nonzero) if it contains at least one valid origin tag, and 'z' if all the represented tags are zero. */ -static inline UChar classify_OCacheLine ( OCacheLine* line ) +static inline UChar classify_OCacheLine(OCacheLine* line) { UWord i; - if (line->tag == 1/*invalid*/) + if (line->tag == 1 /*invalid*/) return 'e'; /* EMPTY */ tl_assert(is_valid_oc_tag(line->tag)); @@ -2505,9 +2488,9 @@ static inline UChar classify_OCacheLine ( OCacheLine* line ) // zero-ness (case 'z') for a subset of cases that the loop below will, // hence is safe. if (OC_W64S_PER_MAIN == 5) { - if (line->u.w64s[0] == 0 - && line->u.w64s[1] == 0 && line->u.w64s[2] == 0 - && line->u.w64s[3] == 0 && line->u.w64s[4] == 0) { + if (line->u.w64s[0] == 0 && line->u.w64s[1] == 0 && + line->u.w64s[2] == 0 && line->u.w64s[3] == 0 && + line->u.w64s[4] == 0) { return 'z'; } } else { @@ -2523,53 +2506,50 @@ static inline UChar classify_OCacheLine ( OCacheLine* line ) return 'z'; /* ZERO - no useful info */ } -typedef - struct { - OCacheLine line[OC_LINES_PER_SET]; - } - OCacheSet; +typedef struct { + OCacheLine line[OC_LINES_PER_SET]; +} OCacheSet; -typedef - struct { - OCacheSet set[OC_N_SETS]; - } - OCache; +typedef struct { + OCacheSet set[OC_N_SETS]; +} OCache; -static OCache* ocacheL1 = NULL; +static OCache* ocacheL1 = NULL; static UWord ocacheL1_event_ctr = 0; -static void init_ocacheL2 ( void ); /* fwds */ -static void init_OCache ( void ) +static void init_ocacheL2(void); /* fwds */ +static void init_OCache(void) { UWord line, set; tl_assert(MC_(clo_mc_level) >= 3); tl_assert(ocacheL1 == NULL); SysRes sres = VG_(am_shadow_alloc)(sizeof(OCache)); if (sr_isError(sres)) { - VG_(out_of_memory_NORETURN)( "memcheck:allocating ocacheL1", - sizeof(OCache), sr_Err(sres) ); + VG_(out_of_memory_NORETURN)("memcheck:allocating ocacheL1", + sizeof(OCache), sr_Err(sres)); } - ocacheL1 = (void *)(Addr)sr_Res(sres); + ocacheL1 = (void*)(Addr)sr_Res(sres); tl_assert(ocacheL1 != NULL); for (set = 0; set < OC_N_SETS; set++) { for (line = 0; line < OC_LINES_PER_SET; line++) { - ocacheL1->set[set].line[line].tag = 1/*invalid*/; + ocacheL1->set[set].line[line].tag = 1 /*invalid*/; } } init_ocacheL2(); } -static inline void moveLineForwards ( OCacheSet* set, UWord lineno ) +static inline void moveLineForwards(OCacheSet* set, UWord lineno) { OCacheLine tmp; stats_ocacheL1_movefwds++; tl_assert(lineno > 0 && lineno < OC_LINES_PER_SET); - tmp = set->line[lineno-1]; - set->line[lineno-1] = set->line[lineno]; - set->line[lineno] = tmp; + tmp = set->line[lineno - 1]; + set->line[lineno - 1] = set->line[lineno]; + set->line[lineno] = tmp; } -static inline void zeroise_OCacheLine ( OCacheLine* line, Addr tag ) { +static inline void zeroise_OCacheLine(OCacheLine* line, Addr tag) +{ UWord i; if (OC_W32S_PER_LINE == 8) { // BEGIN fast special-case of the loop below @@ -2583,7 +2563,7 @@ static inline void zeroise_OCacheLine ( OCacheLine* line, Addr tag ) { } else { tl_assert2(0, "unsupported line size (zeroise_OCacheLine)"); for (i = 0; i < OC_W32S_PER_LINE; i++) { - line->u.main.w32[i] = 0; /* NO ORIGIN */ + line->u.main.w32[i] = 0; /* NO ORIGIN */ line->u.main.descr[i] = 0; /* REALLY REALLY NO ORIGIN! */ } } @@ -2621,54 +2601,53 @@ static inline void zeroise_OCacheLine ( OCacheLine* line, Addr tag ) { static OSet* ocachesL2[4096]; STATIC_ASSERT((OC_BITS_PER_LINE + 11 + 12) < 32); -static inline UInt HASH_OCACHE_TAG ( Addr tag ) { +static inline UInt HASH_OCACHE_TAG(Addr tag) +{ return (UInt)((tag >> (OC_BITS_PER_LINE + 11)) & 0xFFF); } -static void* ocacheL2_malloc ( const HChar* cc, SizeT szB ) { +static void* ocacheL2_malloc(const HChar* cc, SizeT szB) +{ return VG_(malloc)(cc, szB); } -static void ocacheL2_free ( void* v ) { - VG_(free)( v ); -} +static void ocacheL2_free(void* v) { VG_(free)(v); } /* Stats: # nodes currently in tree */ static UWord stats__ocacheL2_n_nodes = 0; -static void init_ocacheL2 ( void ) +static void init_ocacheL2(void) { tl_assert(sizeof(Word) == sizeof(Addr)); /* since OCacheLine.tag :: Addr */ - tl_assert(0 == offsetof(OCacheLine,tag)); + tl_assert(0 == offsetof(OCacheLine, tag)); for (UInt i = 0; i < 4096; i++) { tl_assert(!ocachesL2[i]); - ocachesL2[i] - = VG_(OSetGen_Create)( offsetof(OCacheLine,tag), - NULL, /* fast cmp */ - ocacheL2_malloc, "mc.ioL2", ocacheL2_free); + ocachesL2[i] = + VG_(OSetGen_Create)(offsetof(OCacheLine, tag), NULL, /* fast cmp */ + ocacheL2_malloc, "mc.ioL2", ocacheL2_free); } stats__ocacheL2_n_nodes = 0; } /* Find line with the given tag in the tree, or NULL if not found. */ -static inline OCacheLine* ocacheL2_find_tag ( Addr tag ) +static inline OCacheLine* ocacheL2_find_tag(Addr tag) { OCacheLine* line; tl_assert(is_valid_oc_tag(tag)); stats__ocacheL2_finds++; OSet* oset = ocachesL2[HASH_OCACHE_TAG(tag)]; - line = VG_(OSetGen_Lookup)( oset, &tag ); + line = VG_(OSetGen_Lookup)(oset, &tag); return line; } /* Delete the line with the given tag from the tree, if it is present, and free up the associated memory. */ -static void ocacheL2_del_tag ( Addr tag ) +static void ocacheL2_del_tag(Addr tag) { OCacheLine* line; tl_assert(is_valid_oc_tag(tag)); stats__ocacheL2_dels++; OSet* oset = ocachesL2[HASH_OCACHE_TAG(tag)]; - line = VG_(OSetGen_Remove)( oset, &tag ); + line = VG_(OSetGen_Remove)(oset, &tag); if (line) { VG_(OSetGen_FreeNode)(oset, line); tl_assert(stats__ocacheL2_n_nodes > 0); @@ -2678,15 +2657,15 @@ static void ocacheL2_del_tag ( Addr tag ) /* Add a copy of the given line to the tree. It must not already be present. */ -static void ocacheL2_add_line ( OCacheLine* line ) +static void ocacheL2_add_line(OCacheLine* line) { OCacheLine* copy; tl_assert(is_valid_oc_tag(line->tag)); OSet* oset = ocachesL2[HASH_OCACHE_TAG(line->tag)]; - copy = VG_(OSetGen_AllocNode)( oset, sizeof(OCacheLine) ); - *copy = *line; + copy = VG_(OSetGen_AllocNode)(oset, sizeof(OCacheLine)); + *copy = *line; stats__ocacheL2_adds++; - VG_(OSetGen_Insert)( oset, copy ); + VG_(OSetGen_Insert)(oset, copy); stats__ocacheL2_n_nodes++; if (stats__ocacheL2_n_nodes > stats__ocacheL2_n_nodes_max) stats__ocacheL2_n_nodes_max = stats__ocacheL2_n_nodes; @@ -2695,15 +2674,14 @@ static void ocacheL2_add_line ( OCacheLine* line ) //// ////////////////////////////////////////////////////////////// -__attribute__((noinline)) -static OCacheLine* find_OCacheLine_SLOW ( Addr a ) +__attribute__((noinline)) static OCacheLine* find_OCacheLine_SLOW(Addr a) { OCacheLine *victim, *inL2; - UChar c; - UWord line; - UWord setno = (a >> OC_BITS_PER_LINE) & (OC_N_SETS - 1); - UWord tagmask = ~((1 << OC_BITS_PER_LINE) - 1); - UWord tag = a & tagmask; + UChar c; + UWord line; + UWord setno = (a >> OC_BITS_PER_LINE) & (OC_N_SETS - 1); + UWord tagmask = ~((1 << OC_BITS_PER_LINE) - 1); + UWord tag = a & tagmask; tl_assert(setno >= 0 && setno < OC_N_SETS); /* we already tried line == 0; skip therefore. */ @@ -2714,9 +2692,9 @@ static OCacheLine* find_OCacheLine_SLOW ( Addr a ) } else { stats_ocacheL1_found_at_N++; } - if (UNLIKELY(0 == (ocacheL1_event_ctr++ - & ((1<set[setno], line ); + if (UNLIKELY(0 == (ocacheL1_event_ctr++ & + ((1 << OC_MOVE_FORWARDS_EVERY_BITS) - 1)))) { + moveLineForwards(&ocacheL1->set[setno], line); line--; } return &ocacheL1->set[setno].line[line]; @@ -2732,38 +2710,38 @@ static OCacheLine* find_OCacheLine_SLOW ( Addr a ) /* First, move the to-be-ejected line to the L2 cache. */ victim = &ocacheL1->set[setno].line[line]; - c = classify_OCacheLine(victim); + c = classify_OCacheLine(victim); switch (c) { - case 'e': - /* the line is empty (has invalid tag); ignore it. */ - break; - case 'z': - /* line contains zeroes. We must ensure the backing store is - updated accordingly, either by copying the line there - verbatim, or by ensuring it isn't present there. We - choose the latter on the basis that it reduces the size of - the backing store. */ - ocacheL2_del_tag( victim->tag ); - break; - case 'n': - /* line contains at least one real, useful origin. Copy it - to the backing store. */ - stats_ocacheL1_lossage++; - inL2 = ocacheL2_find_tag( victim->tag ); - if (inL2) { - *inL2 = *victim; - } else { - ocacheL2_add_line( victim ); - } - break; - default: - tl_assert(0); + case 'e': + /* the line is empty (has invalid tag); ignore it. */ + break; + case 'z': + /* line contains zeroes. We must ensure the backing store is + updated accordingly, either by copying the line there + verbatim, or by ensuring it isn't present there. We + choose the latter on the basis that it reduces the size of + the backing store. */ + ocacheL2_del_tag(victim->tag); + break; + case 'n': + /* line contains at least one real, useful origin. Copy it + to the backing store. */ + stats_ocacheL1_lossage++; + inL2 = ocacheL2_find_tag(victim->tag); + if (inL2) { + *inL2 = *victim; + } else { + ocacheL2_add_line(victim); + } + break; + default: + tl_assert(0); } /* Now we must reload the L1 cache from the backing tree, if possible. */ tl_assert(tag != victim->tag); /* stay sane */ - inL2 = ocacheL2_find_tag( tag ); + inL2 = ocacheL2_find_tag(tag); if (inL2) { /* We're in luck. It's in the L2. */ ocacheL1->set[setno].line[line] = *inL2; @@ -2771,17 +2749,17 @@ static OCacheLine* find_OCacheLine_SLOW ( Addr a ) /* Missed at both levels of the cache hierarchy. We have to declare it as full of zeroes (unknown origins). */ stats__ocacheL2_misses++; - zeroise_OCacheLine( &ocacheL1->set[setno].line[line], tag ); + zeroise_OCacheLine(&ocacheL1->set[setno].line[line], tag); } /* Move it one forwards */ - moveLineForwards( &ocacheL1->set[setno], line ); + moveLineForwards(&ocacheL1->set[setno], line); line--; return &ocacheL1->set[setno].line[line]; } -static INLINE OCacheLine* find_OCacheLine ( Addr a ) +static INLINE OCacheLine* find_OCacheLine(Addr a) { UWord setno = (a >> OC_BITS_PER_LINE) & (OC_N_SETS - 1); UWord tagmask = ~((1 << OC_BITS_PER_LINE) - 1); @@ -2798,29 +2776,29 @@ static INLINE OCacheLine* find_OCacheLine ( Addr a ) return &ocacheL1->set[setno].line[0]; } - return find_OCacheLine_SLOW( a ); + return find_OCacheLine_SLOW(a); } -static INLINE void set_aligned_word64_Origin_to_undef ( Addr a, UInt otag ) +static INLINE void set_aligned_word64_Origin_to_undef(Addr a, UInt otag) { //// BEGIN inlined, specialised version of MC_(helperc_b_store8) //// Set the origins for a+0 .. a+7 - { OCacheLine* line; - UWord lineoff = oc_line_offset(a); - if (OC_ENABLE_ASSERTIONS) { - tl_assert(lineoff >= 0 - && lineoff < OC_W32S_PER_LINE -1/*'cos 8-aligned*/); - } - line = find_OCacheLine( a ); - line->u.main.descr[lineoff+0] = 0xF; - line->u.main.descr[lineoff+1] = 0xF; - line->u.main.w32[lineoff+0] = otag; - line->u.main.w32[lineoff+1] = otag; + { + OCacheLine* line; + UWord lineoff = oc_line_offset(a); + if (OC_ENABLE_ASSERTIONS) { + tl_assert(lineoff >= 0 && + lineoff < OC_W32S_PER_LINE - 1 /*'cos 8-aligned*/); + } + line = find_OCacheLine(a); + line->u.main.descr[lineoff + 0] = 0xF; + line->u.main.descr[lineoff + 1] = 0xF; + line->u.main.w32[lineoff + 0] = otag; + line->u.main.w32[lineoff + 1] = otag; } //// END inlined, specialised version of MC_(helperc_b_store8) } - /*------------------------------------------------------------*/ /*--- Aligned fast case permission setters, ---*/ /*--- for dealing with stacks ---*/ @@ -2830,9 +2808,9 @@ static INLINE void set_aligned_word64_Origin_to_undef ( Addr a, UInt otag ) /* Nb: by "aligned" here we mean 4-byte aligned */ -static INLINE void make_aligned_word32_undefined ( Addr a ) +static INLINE void make_aligned_word32_undefined(Addr a) { - PROF_EVENT(MCPE_MAKE_ALIGNED_WORD32_UNDEFINED); + PROF_EVENT(MCPE_MAKE_ALIGNED_WORD32_UNDEFINED); #ifndef PERF_FAST_STACK2 make_mem_undefined(a, 4); @@ -2854,26 +2832,25 @@ static INLINE void make_aligned_word32_undefined ( Addr a ) #endif } -static INLINE -void make_aligned_word32_undefined_w_otag ( Addr a, UInt otag ) +static INLINE void make_aligned_word32_undefined_w_otag(Addr a, UInt otag) { make_aligned_word32_undefined(a); //// BEGIN inlined, specialised version of MC_(helperc_b_store4) //// Set the origins for a+0 .. a+3 - { OCacheLine* line; - UWord lineoff = oc_line_offset(a); - if (OC_ENABLE_ASSERTIONS) { - tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); - } - line = find_OCacheLine( a ); - line->u.main.descr[lineoff] = 0xF; - line->u.main.w32[lineoff] = otag; + { + OCacheLine* line; + UWord lineoff = oc_line_offset(a); + if (OC_ENABLE_ASSERTIONS) { + tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); + } + line = find_OCacheLine(a); + line->u.main.descr[lineoff] = 0xF; + line->u.main.w32[lineoff] = otag; } //// END inlined, specialised version of MC_(helperc_b_store4) } -static INLINE -void make_aligned_word32_noaccess ( Addr a ) +static INLINE void make_aligned_word32_noaccess(Addr a) { PROF_EVENT(MCPE_MAKE_ALIGNED_WORD32_NOACCESS); @@ -2896,13 +2873,13 @@ void make_aligned_word32_noaccess ( Addr a ) //// BEGIN inlined, specialised version of MC_(helperc_b_store4) //// Set the origins for a+0 .. a+3. - if (UNLIKELY( MC_(clo_mc_level) == 3 )) { + if (UNLIKELY(MC_(clo_mc_level) == 3)) { OCacheLine* line; - UWord lineoff = oc_line_offset(a); + UWord lineoff = oc_line_offset(a); if (OC_ENABLE_ASSERTIONS) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); line->u.main.descr[lineoff] = 0; } //// END inlined, specialised version of MC_(helperc_b_store4) @@ -2914,7 +2891,7 @@ void make_aligned_word32_noaccess ( Addr a ) /* Nb: by "aligned" here we mean 8-byte aligned */ -static INLINE void make_aligned_word64_undefined ( Addr a ) +static INLINE void make_aligned_word64_undefined(Addr a) { PROF_EVENT(MCPE_MAKE_ALIGNED_WORD64_UNDEFINED); @@ -2931,34 +2908,33 @@ static INLINE void make_aligned_word64_undefined ( Addr a ) return; } - sm = get_secmap_for_writing_low(a); - sm_off16 = SM_OFF_16(a); + sm = get_secmap_for_writing_low(a); + sm_off16 = SM_OFF_16(a); sm->vabits16[sm_off16] = VA_BITS16_UNDEFINED; } #endif } -static INLINE -void make_aligned_word64_undefined_w_otag ( Addr a, UInt otag ) +static INLINE void make_aligned_word64_undefined_w_otag(Addr a, UInt otag) { make_aligned_word64_undefined(a); //// BEGIN inlined, specialised version of MC_(helperc_b_store8) //// Set the origins for a+0 .. a+7 - { OCacheLine* line; - UWord lineoff = oc_line_offset(a); - tl_assert(lineoff >= 0 - && lineoff < OC_W32S_PER_LINE -1/*'cos 8-aligned*/); - line = find_OCacheLine( a ); - line->u.main.descr[lineoff+0] = 0xF; - line->u.main.descr[lineoff+1] = 0xF; - line->u.main.w32[lineoff+0] = otag; - line->u.main.w32[lineoff+1] = otag; + { + OCacheLine* line; + UWord lineoff = oc_line_offset(a); + tl_assert(lineoff >= 0 && + lineoff < OC_W32S_PER_LINE - 1 /*'cos 8-aligned*/); + line = find_OCacheLine(a); + line->u.main.descr[lineoff + 0] = 0xF; + line->u.main.descr[lineoff + 1] = 0xF; + line->u.main.w32[lineoff + 0] = otag; + line->u.main.w32[lineoff + 1] = otag; } //// END inlined, specialised version of MC_(helperc_b_store8) } -static INLINE -void make_aligned_word64_noaccess ( Addr a ) +static INLINE void make_aligned_word64_noaccess(Addr a) { PROF_EVENT(MCPE_MAKE_ALIGNED_WORD64_NOACCESS); @@ -2975,35 +2951,34 @@ void make_aligned_word64_noaccess ( Addr a ) return; } - sm = get_secmap_for_writing_low(a); - sm_off16 = SM_OFF_16(a); + sm = get_secmap_for_writing_low(a); + sm_off16 = SM_OFF_16(a); sm->vabits16[sm_off16] = VA_BITS16_NOACCESS; //// BEGIN inlined, specialised version of MC_(helperc_b_store8) //// Clear the origins for a+0 .. a+7. - if (UNLIKELY( MC_(clo_mc_level) == 3 )) { + if (UNLIKELY(MC_(clo_mc_level) == 3)) { OCacheLine* line; - UWord lineoff = oc_line_offset(a); - tl_assert(lineoff >= 0 - && lineoff < OC_W32S_PER_LINE -1/*'cos 8-aligned*/); - line = find_OCacheLine( a ); - line->u.main.descr[lineoff+0] = 0; - line->u.main.descr[lineoff+1] = 0; + UWord lineoff = oc_line_offset(a); + tl_assert(lineoff >= 0 && + lineoff < OC_W32S_PER_LINE - 1 /*'cos 8-aligned*/); + line = find_OCacheLine(a); + line->u.main.descr[lineoff + 0] = 0; + line->u.main.descr[lineoff + 1] = 0; } //// END inlined, specialised version of MC_(helperc_b_store8) } #endif } - /*------------------------------------------------------------*/ /*--- Stack pointer adjustment ---*/ /*------------------------------------------------------------*/ #ifdef PERF_FAST_STACK -# define MAYBE_USED +#define MAYBE_USED #else -# define MAYBE_USED __attribute__((unused)) +#define MAYBE_USED __attribute__((unused)) #endif /*--------------- adjustment by 4 bytes ---------------*/ @@ -3013,10 +2988,11 @@ static void VG_REGPARM(2) mc_new_mem_stack_4_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_4); - if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP, otag ); + if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 4, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 4, otag); } } @@ -3024,10 +3000,10 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_4(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_4); - if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); + if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 4 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 4); } } @@ -3035,10 +3011,10 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_4(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_4); - if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-4 ); + if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 4); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-4, 4 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 4, 4); } } @@ -3049,13 +3025,16 @@ static void VG_REGPARM(2) mc_new_mem_stack_8_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_8); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP, otag ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+4, otag ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 4, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 8, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 8, otag); } } @@ -3063,13 +3042,13 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_8(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_8); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP+4 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP + 4); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 8 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 8); } } @@ -3077,13 +3056,13 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_8(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_8); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-8 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-8 ); - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-4 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 4); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-8, 8 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 8, 8); } } @@ -3094,17 +3073,21 @@ static void VG_REGPARM(2) mc_new_mem_stack_12_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_12); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8, otag ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* from previous test we don't have 8-alignment at offset +0, hence must have 8 alignment at offsets +4/-4. Hence safe to do 4 at +0 and then 8 at +4/. */ - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+4, otag ); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 4, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 12, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 12, otag); } } @@ -3112,17 +3095,17 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_12(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_12); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* from previous test we don't have 8-alignment at offset +0, hence must have 8 alignment at offsets +4/-4. Hence safe to do 4 at +0 and then 8 at +4/. */ - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+4 ); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 4); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 12 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 12); } } @@ -3131,19 +3114,19 @@ static void VG_REGPARM(1) mc_die_mem_stack_12(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_12); /* Note the -12 in the test */ - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP-12 )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP - 12)) { /* We have 8-alignment at -12, hence ok to do 8 at -12 and 4 at -4. */ - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-12 ); - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-4 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 12); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 4); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* We have 4-alignment at +0, but we don't have 8-alignment at -12. So we must have 8-alignment at -8. Hence do 4 at -12 and then 8 at -8. */ - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-12 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-8 ); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 12); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-12, 12 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 12, 12); } } @@ -3154,18 +3137,23 @@ static void VG_REGPARM(2) mc_new_mem_stack_16_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_16); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Have 8-alignment at +0, hence do 8 at +0 and 8 at +8. */ - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8, otag ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Have 4 alignment at +0 but not 8; hence 8 must be at +4. Hence do 4 at +0, 8 at +4, 4 at +12. */ - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+4 , otag ); - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+12, otag ); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 4, + otag); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 12, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 16, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 16, otag); } } @@ -3173,18 +3161,18 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_16(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_16); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Have 8-alignment at +0, hence do 8 at +0 and 8 at +8. */ - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Have 4 alignment at +0 but not 8; hence 8 must be at +4. Hence do 4 at +0, 8 at +4, 4 at +12. */ - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+4 ); - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP+12 ); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 4); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP + 12); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 16 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 16); } } @@ -3192,17 +3180,17 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_16(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_16); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Have 8-alignment at +0, hence do 8 at -16 and 8 at -8. */ - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-8 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* 8 alignment must be at -12. Do 4 at -16, 8 at -12, 4 at -4. */ - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-12 ); - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-4 ); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 12); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 4); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-16, 16 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 16, 16); } } @@ -3213,22 +3201,31 @@ static void VG_REGPARM(2) mc_new_mem_stack_32_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_32); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Straightforward */ - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8 , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+16, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+24, otag ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 16, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 24, + otag); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* 8 alignment must be at +4. Hence do 8 at +4,+12,+20 and 4 at +0,+28. */ - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+4 , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+12, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+20, otag ); - make_aligned_word32_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+28, otag ); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 4, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 12, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 20, + otag); + make_aligned_word32_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 28, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 32, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 32, otag); } } @@ -3236,22 +3233,22 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_32(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_32); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Straightforward */ - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+16 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+24 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 16); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 24); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* 8 alignment must be at +4. Hence do 8 at +4,+12,+20 and 4 at +0,+28. */ - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+4 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+12 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+20 ); - make_aligned_word32_undefined ( -VG_STACK_REDZONE_SZB + new_SP+28 ); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 4); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 12); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 20); + make_aligned_word32_undefined(-VG_STACK_REDZONE_SZB + new_SP + 28); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 32 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 32); } } @@ -3259,22 +3256,22 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_32(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_32); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* Straightforward */ - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-24 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); - } else if (VG_IS_4_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 24); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); + } else if (VG_IS_4_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { /* 8 alignment must be at -4 etc. Hence do 8 at -12,-20,-28 and 4 at -32,-4. */ - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-28 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-20 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-12 ); - make_aligned_word32_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-4 ); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 28); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 20); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 12); + make_aligned_word32_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 4); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-32, 32 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 32, 32); } } @@ -3285,23 +3282,37 @@ static void VG_REGPARM(2) mc_new_mem_stack_112_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_112); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8 , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+16, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+24, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+32, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+40, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+48, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+56, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+64, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+72, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+80, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+88, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+96, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+104, otag ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 16, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 24, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 32, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 40, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 48, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 56, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 64, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 72, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 80, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 88, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 96, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 104, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 112, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 112, otag); } } @@ -3309,23 +3320,23 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_112(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_112); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+16 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+24 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+32 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+40 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+48 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+56 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+64 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+72 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+80 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+88 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+96 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+104 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 16); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 24); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 32); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 40); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 48); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 56); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 64); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 72); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 80); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 88); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 96); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 104); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 112 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 112); } } @@ -3333,23 +3344,23 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_112(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_112); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-112); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-104); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-96 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-88 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-80 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-72 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-64 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-56 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-48 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-40 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-24 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 112); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 104); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 96); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 88); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 80); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 72); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 64); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 56); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 48); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 40); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 24); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-112, 112 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 112, 112); } } @@ -3360,25 +3371,41 @@ static void VG_REGPARM(2) mc_new_mem_stack_128_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_128); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8 , otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+16, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+24, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+32, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+40, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+48, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+56, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+64, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+72, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+80, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+88, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+96, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+104, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+112, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+120, otag ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 16, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 24, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 32, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 40, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 48, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 56, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 64, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 72, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 80, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 88, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 96, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 104, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 112, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 120, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 128, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 128, otag); } } @@ -3386,25 +3413,25 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_128(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_128); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+16 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+24 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+32 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+40 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+48 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+56 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+64 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+72 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+80 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+88 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+96 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+104 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+112 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+120 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 16); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 24); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 32); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 40); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 48); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 56); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 64); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 72); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 80); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 88); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 96); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 104); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 112); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 120); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 128 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 128); } } @@ -3412,25 +3439,25 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_128(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_128); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-128); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-120); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-112); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-104); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-96 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-88 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-80 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-72 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-64 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-56 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-48 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-40 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-24 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 128); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 120); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 112); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 104); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 96); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 88); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 80); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 72); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 64); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 56); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 48); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 40); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 24); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-128, 128 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 128, 128); } } @@ -3441,27 +3468,45 @@ static void VG_REGPARM(2) mc_new_mem_stack_144_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_144); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+16, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+24, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+32, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+40, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+48, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+56, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+64, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+72, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+80, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+88, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+96, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+104, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+112, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+120, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+128, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+136, otag ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 16, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 24, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 32, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 40, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 48, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 56, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 64, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 72, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 80, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 88, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 96, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 104, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 112, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 120, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 128, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 136, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 144, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 144, otag); } } @@ -3469,27 +3514,27 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_144(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_144); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+16 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+24 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+32 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+40 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+48 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+56 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+64 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+72 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+80 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+88 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+96 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+104 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+112 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+120 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+128 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+136 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 16); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 24); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 32); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 40); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 48); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 56); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 64); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 72); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 80); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 88); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 96); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 104); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 112); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 120); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 128); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 136); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 144 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 144); } } @@ -3497,27 +3542,27 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_144(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_144); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-144); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-136); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-128); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-120); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-112); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-104); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-96 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-88 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-80 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-72 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-64 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-56 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-48 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-40 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-24 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 144); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 136); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 128); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 120); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 112); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 104); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 96); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 88); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 80); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 72); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 64); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 56); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 48); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 40); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 24); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-144, 144 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 144, 144); } } @@ -3528,29 +3573,49 @@ static void VG_REGPARM(2) mc_new_mem_stack_160_w_ECU(Addr new_SP, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK_160); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+8, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+16, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+24, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+32, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+40, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+48, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+56, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+64, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+72, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+80, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+88, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+96, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+104, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+112, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+120, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+128, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+136, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+144, otag ); - make_aligned_word64_undefined_w_otag ( -VG_STACK_REDZONE_SZB + new_SP+152, otag ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 8, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 16, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 24, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 32, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 40, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 48, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 56, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 64, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 72, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 80, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 88, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 96, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 104, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 112, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 120, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 128, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 136, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 144, + otag); + make_aligned_word64_undefined_w_otag(-VG_STACK_REDZONE_SZB + new_SP + 152, + otag); } else { - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + new_SP, 160, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + new_SP, 160, otag); } } @@ -3558,29 +3623,29 @@ MAYBE_USED static void VG_REGPARM(1) mc_new_mem_stack_160(Addr new_SP) { PROF_EVENT(MCPE_NEW_MEM_STACK_160); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+8 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+16 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+24 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+32 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+40 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+48 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+56 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+64 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+72 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+80 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+88 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+96 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+104 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+112 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+120 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+128 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+136 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+144 ); - make_aligned_word64_undefined ( -VG_STACK_REDZONE_SZB + new_SP+152 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 8); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 16); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 24); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 32); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 40); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 48); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 56); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 64); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 72); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 80); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 88); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 96); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 104); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 112); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 120); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 128); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 136); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 144); + make_aligned_word64_undefined(-VG_STACK_REDZONE_SZB + new_SP + 152); } else { - make_mem_undefined ( -VG_STACK_REDZONE_SZB + new_SP, 160 ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + new_SP, 160); } } @@ -3588,54 +3653,53 @@ MAYBE_USED static void VG_REGPARM(1) mc_die_mem_stack_160(Addr new_SP) { PROF_EVENT(MCPE_DIE_MEM_STACK_160); - if (VG_IS_8_ALIGNED( -VG_STACK_REDZONE_SZB + new_SP )) { - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-160); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-152); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-144); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-136); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-128); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-120); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-112); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-104); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-96 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-88 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-80 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-72 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-64 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-56 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-48 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-40 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-32 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-24 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP-16 ); - make_aligned_word64_noaccess ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); + if (VG_IS_8_ALIGNED(-VG_STACK_REDZONE_SZB + new_SP)) { + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 160); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 152); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 144); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 136); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 128); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 120); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 112); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 104); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 96); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 88); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 80); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 72); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 64); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 56); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 48); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 40); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 32); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 24); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 16); + make_aligned_word64_noaccess(-VG_STACK_REDZONE_SZB + new_SP - 8); } else { - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + new_SP-160, 160 ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + new_SP - 160, 160); } } /*--------------- adjustment by N bytes ---------------*/ -static void mc_new_mem_stack_w_ECU ( Addr a, SizeT len, UInt ecu ) +static void mc_new_mem_stack_w_ECU(Addr a, SizeT len, UInt ecu) { UInt otag = ecu | MC_OKIND_STACK; PROF_EVENT(MCPE_NEW_MEM_STACK); - MC_(make_mem_undefined_w_otag) ( -VG_STACK_REDZONE_SZB + a, len, otag ); + MC_(make_mem_undefined_w_otag)(-VG_STACK_REDZONE_SZB + a, len, otag); } -static void mc_new_mem_stack ( Addr a, SizeT len ) +static void mc_new_mem_stack(Addr a, SizeT len) { PROF_EVENT(MCPE_NEW_MEM_STACK); - make_mem_undefined ( -VG_STACK_REDZONE_SZB + a, len ); + make_mem_undefined(-VG_STACK_REDZONE_SZB + a, len); } -static void mc_die_mem_stack ( Addr a, SizeT len ) +static void mc_die_mem_stack(Addr a, SizeT len) { PROF_EVENT(MCPE_DIE_MEM_STACK); - MC_(make_mem_noaccess) ( -VG_STACK_REDZONE_SZB + a, len ); + MC_(make_mem_noaccess)(-VG_STACK_REDZONE_SZB + a, len); } - /* The AMD64 ABI says: "The 128-byte area beyond the location pointed to by %rsp is considered @@ -3665,23 +3729,25 @@ static void mc_die_mem_stack ( Addr a, SizeT len ) also needs to be nuked on function calls. */ - /* Here's a simple cache to hold nia -> ECU mappings. It could be improved so as to have a lower miss rate. */ static UWord stats__nia_cache_queries = 0; static UWord stats__nia_cache_misses = 0; -typedef - struct { UWord nia0; UWord ecu0; /* nia0 maps to ecu0 */ - UWord nia1; UWord ecu1; } /* nia1 maps to ecu1 */ - WCacheEnt; +typedef struct { + UWord nia0; + UWord ecu0; /* nia0 maps to ecu0 */ + UWord nia1; + UWord ecu1; +} /* nia1 maps to ecu1 */ +WCacheEnt; #define N_NIA_TO_ECU_CACHE 511 static WCacheEnt nia_to_ecu_cache[N_NIA_TO_ECU_CACHE]; -static void init_nia_to_ecu_cache ( void ) +static void init_nia_to_ecu_cache(void) { UWord i; Addr zero_addr = 0; @@ -3702,26 +3768,31 @@ static void init_nia_to_ecu_cache ( void ) } } -static inline UInt convert_nia_to_ecu ( Addr nia ) +static inline UInt convert_nia_to_ecu(Addr nia) { - UWord i; + UWord i; UInt ecu; ExeContext* ec; - tl_assert( sizeof(nia_to_ecu_cache[0].nia1) == sizeof(nia) ); + tl_assert(sizeof(nia_to_ecu_cache[0].nia1) == sizeof(nia)); stats__nia_cache_queries++; i = nia % N_NIA_TO_ECU_CACHE; tl_assert(i >= 0 && i < N_NIA_TO_ECU_CACHE); - if (LIKELY( nia_to_ecu_cache[i].nia0 == nia )) + if (LIKELY(nia_to_ecu_cache[i].nia0 == nia)) return nia_to_ecu_cache[i].ecu0; - if (LIKELY( nia_to_ecu_cache[i].nia1 == nia )) { -# define SWAP(_w1,_w2) { UWord _t = _w1; _w1 = _w2; _w2 = _t; } - SWAP( nia_to_ecu_cache[i].nia0, nia_to_ecu_cache[i].nia1 ); - SWAP( nia_to_ecu_cache[i].ecu0, nia_to_ecu_cache[i].ecu1 ); -# undef SWAP + if (LIKELY(nia_to_ecu_cache[i].nia1 == nia)) { +#define SWAP(_w1, _w2) \ + { \ + UWord _t = _w1; \ + _w1 = _w2; \ + _w2 = _t; \ + } + SWAP(nia_to_ecu_cache[i].nia0, nia_to_ecu_cache[i].nia1); + SWAP(nia_to_ecu_cache[i].ecu0, nia_to_ecu_cache[i].ecu1); +#undef SWAP return nia_to_ecu_cache[i].ecu0; } @@ -3739,25 +3810,24 @@ static inline UInt convert_nia_to_ecu ( Addr nia ) return ecu; } - /* This marks the stack as addressible but undefined, after a call or return for a target that has an ABI defined stack redzone. It happens quite a lot and needs to be fast. This is the version for origin tracking. The non-origin-tracking version is below. */ VG_REGPARM(3) -void MC_(helperc_MAKE_STACK_UNINIT_w_o) ( Addr base, UWord len, Addr nia ) +void MC_(helperc_MAKE_STACK_UNINIT_w_o)(Addr base, UWord len, Addr nia) { PROF_EVENT(MCPE_MAKE_STACK_UNINIT_W_O); if (0) - VG_(printf)("helperc_MAKE_STACK_UNINIT_w_o (%#lx,%lu,nia=%#lx)\n", - base, len, nia ); + VG_(printf)("helperc_MAKE_STACK_UNINIT_w_o (%#lx,%lu,nia=%#lx)\n", base, + len, nia); - UInt ecu = convert_nia_to_ecu ( nia ); + UInt ecu = convert_nia_to_ecu(nia); tl_assert(VG_(is_plausible_ECU)(ecu)); UInt otag = ecu | MC_OKIND_STACK; -# if 0 +#if 0 /* Slow(ish) version, which is fairly easily seen to be correct. */ if (LIKELY( VG_IS_8_ALIGNED(base) && len==128 )) { @@ -3783,7 +3853,7 @@ void MC_(helperc_MAKE_STACK_UNINIT_w_o) ( Addr base, UWord len, Addr nia ) } else { MC_(make_mem_undefined_w_otag)(base, len, otag); } -# endif +#endif /* Idea is: go fast when * 8-aligned and length is 128 @@ -3793,147 +3863,147 @@ void MC_(helperc_MAKE_STACK_UNINIT_w_o) ( Addr base, UWord len, Addr nia ) directly into the vabits array. (If the sm was distinguished, this will make a copy and then write to it.) */ - if (LIKELY( len == 128 && VG_IS_8_ALIGNED(base) )) { + if (LIKELY(len == 128 && VG_IS_8_ALIGNED(base))) { /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 128 - 1); - tl_assert(a_lo < a_hi); // paranoia: detect overflow + tl_assert(a_lo < a_hi); // paranoia: detect overflow if (LIKELY(a_hi <= MAX_PRIMARY_ADDRESS)) { /* Now we know the entire range is within the main primary map. */ UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off16 = SM_OFF_16(a_lo); UShort* p = &sm->vabits16[v_off16]; - p[ 0] = VA_BITS16_UNDEFINED; - p[ 1] = VA_BITS16_UNDEFINED; - p[ 2] = VA_BITS16_UNDEFINED; - p[ 3] = VA_BITS16_UNDEFINED; - p[ 4] = VA_BITS16_UNDEFINED; - p[ 5] = VA_BITS16_UNDEFINED; - p[ 6] = VA_BITS16_UNDEFINED; - p[ 7] = VA_BITS16_UNDEFINED; - p[ 8] = VA_BITS16_UNDEFINED; - p[ 9] = VA_BITS16_UNDEFINED; - p[10] = VA_BITS16_UNDEFINED; - p[11] = VA_BITS16_UNDEFINED; - p[12] = VA_BITS16_UNDEFINED; - p[13] = VA_BITS16_UNDEFINED; - p[14] = VA_BITS16_UNDEFINED; - p[15] = VA_BITS16_UNDEFINED; - set_aligned_word64_Origin_to_undef( base + 8 * 0, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 1, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 2, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 3, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 4, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 5, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 6, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 7, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 8, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 9, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 10, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 11, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 12, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 13, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 14, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 15, otag ); + p[0] = VA_BITS16_UNDEFINED; + p[1] = VA_BITS16_UNDEFINED; + p[2] = VA_BITS16_UNDEFINED; + p[3] = VA_BITS16_UNDEFINED; + p[4] = VA_BITS16_UNDEFINED; + p[5] = VA_BITS16_UNDEFINED; + p[6] = VA_BITS16_UNDEFINED; + p[7] = VA_BITS16_UNDEFINED; + p[8] = VA_BITS16_UNDEFINED; + p[9] = VA_BITS16_UNDEFINED; + p[10] = VA_BITS16_UNDEFINED; + p[11] = VA_BITS16_UNDEFINED; + p[12] = VA_BITS16_UNDEFINED; + p[13] = VA_BITS16_UNDEFINED; + p[14] = VA_BITS16_UNDEFINED; + p[15] = VA_BITS16_UNDEFINED; + set_aligned_word64_Origin_to_undef(base + 8 * 0, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 1, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 2, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 3, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 4, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 5, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 6, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 7, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 8, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 9, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 10, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 11, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 12, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 13, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 14, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 15, otag); return; } } } /* 288 bytes (36 ULongs) is the magic value for ELF ppc64. */ - if (LIKELY( len == 288 && VG_IS_8_ALIGNED(base) )) { + if (LIKELY(len == 288 && VG_IS_8_ALIGNED(base))) { /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 288 - 1); - tl_assert(a_lo < a_hi); // paranoia: detect overflow + tl_assert(a_lo < a_hi); // paranoia: detect overflow if (a_hi <= MAX_PRIMARY_ADDRESS) { UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off16 = SM_OFF_16(a_lo); UShort* p = &sm->vabits16[v_off16]; - p[ 0] = VA_BITS16_UNDEFINED; - p[ 1] = VA_BITS16_UNDEFINED; - p[ 2] = VA_BITS16_UNDEFINED; - p[ 3] = VA_BITS16_UNDEFINED; - p[ 4] = VA_BITS16_UNDEFINED; - p[ 5] = VA_BITS16_UNDEFINED; - p[ 6] = VA_BITS16_UNDEFINED; - p[ 7] = VA_BITS16_UNDEFINED; - p[ 8] = VA_BITS16_UNDEFINED; - p[ 9] = VA_BITS16_UNDEFINED; - p[10] = VA_BITS16_UNDEFINED; - p[11] = VA_BITS16_UNDEFINED; - p[12] = VA_BITS16_UNDEFINED; - p[13] = VA_BITS16_UNDEFINED; - p[14] = VA_BITS16_UNDEFINED; - p[15] = VA_BITS16_UNDEFINED; - p[16] = VA_BITS16_UNDEFINED; - p[17] = VA_BITS16_UNDEFINED; - p[18] = VA_BITS16_UNDEFINED; - p[19] = VA_BITS16_UNDEFINED; - p[20] = VA_BITS16_UNDEFINED; - p[21] = VA_BITS16_UNDEFINED; - p[22] = VA_BITS16_UNDEFINED; - p[23] = VA_BITS16_UNDEFINED; - p[24] = VA_BITS16_UNDEFINED; - p[25] = VA_BITS16_UNDEFINED; - p[26] = VA_BITS16_UNDEFINED; - p[27] = VA_BITS16_UNDEFINED; - p[28] = VA_BITS16_UNDEFINED; - p[29] = VA_BITS16_UNDEFINED; - p[30] = VA_BITS16_UNDEFINED; - p[31] = VA_BITS16_UNDEFINED; - p[32] = VA_BITS16_UNDEFINED; - p[33] = VA_BITS16_UNDEFINED; - p[34] = VA_BITS16_UNDEFINED; - p[35] = VA_BITS16_UNDEFINED; - set_aligned_word64_Origin_to_undef( base + 8 * 0, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 1, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 2, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 3, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 4, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 5, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 6, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 7, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 8, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 9, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 10, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 11, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 12, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 13, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 14, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 15, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 16, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 17, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 18, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 19, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 20, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 21, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 22, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 23, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 24, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 25, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 26, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 27, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 28, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 29, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 30, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 31, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 32, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 33, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 34, otag ); - set_aligned_word64_Origin_to_undef( base + 8 * 35, otag ); + p[0] = VA_BITS16_UNDEFINED; + p[1] = VA_BITS16_UNDEFINED; + p[2] = VA_BITS16_UNDEFINED; + p[3] = VA_BITS16_UNDEFINED; + p[4] = VA_BITS16_UNDEFINED; + p[5] = VA_BITS16_UNDEFINED; + p[6] = VA_BITS16_UNDEFINED; + p[7] = VA_BITS16_UNDEFINED; + p[8] = VA_BITS16_UNDEFINED; + p[9] = VA_BITS16_UNDEFINED; + p[10] = VA_BITS16_UNDEFINED; + p[11] = VA_BITS16_UNDEFINED; + p[12] = VA_BITS16_UNDEFINED; + p[13] = VA_BITS16_UNDEFINED; + p[14] = VA_BITS16_UNDEFINED; + p[15] = VA_BITS16_UNDEFINED; + p[16] = VA_BITS16_UNDEFINED; + p[17] = VA_BITS16_UNDEFINED; + p[18] = VA_BITS16_UNDEFINED; + p[19] = VA_BITS16_UNDEFINED; + p[20] = VA_BITS16_UNDEFINED; + p[21] = VA_BITS16_UNDEFINED; + p[22] = VA_BITS16_UNDEFINED; + p[23] = VA_BITS16_UNDEFINED; + p[24] = VA_BITS16_UNDEFINED; + p[25] = VA_BITS16_UNDEFINED; + p[26] = VA_BITS16_UNDEFINED; + p[27] = VA_BITS16_UNDEFINED; + p[28] = VA_BITS16_UNDEFINED; + p[29] = VA_BITS16_UNDEFINED; + p[30] = VA_BITS16_UNDEFINED; + p[31] = VA_BITS16_UNDEFINED; + p[32] = VA_BITS16_UNDEFINED; + p[33] = VA_BITS16_UNDEFINED; + p[34] = VA_BITS16_UNDEFINED; + p[35] = VA_BITS16_UNDEFINED; + set_aligned_word64_Origin_to_undef(base + 8 * 0, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 1, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 2, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 3, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 4, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 5, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 6, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 7, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 8, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 9, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 10, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 11, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 12, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 13, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 14, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 15, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 16, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 17, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 18, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 19, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 20, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 21, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 22, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 23, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 24, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 25, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 26, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 27, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 28, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 29, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 30, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 31, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 32, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 33, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 34, otag); + set_aligned_word64_Origin_to_undef(base + 8 * 35, otag); return; } } @@ -3943,18 +4013,16 @@ void MC_(helperc_MAKE_STACK_UNINIT_w_o) ( Addr base, UWord len, Addr nia ) MC_(make_mem_undefined_w_otag)(base, len, otag); } - /* This is a version of MC_(helperc_MAKE_STACK_UNINIT_w_o) that is specialised for the non-origin-tracking case. */ VG_REGPARM(2) -void MC_(helperc_MAKE_STACK_UNINIT_no_o) ( Addr base, UWord len ) +void MC_(helperc_MAKE_STACK_UNINIT_no_o)(Addr base, UWord len) { PROF_EVENT(MCPE_MAKE_STACK_UNINIT_NO_O); if (0) - VG_(printf)("helperc_MAKE_STACK_UNINIT_no_o (%#lx,%lu)\n", - base, len ); + VG_(printf)("helperc_MAKE_STACK_UNINIT_no_o (%#lx,%lu)\n", base, len); -# if 0 +#if 0 /* Slow(ish) version, which is fairly easily seen to be correct. */ if (LIKELY( VG_IS_8_ALIGNED(base) && len==128 )) { @@ -3980,7 +4048,7 @@ void MC_(helperc_MAKE_STACK_UNINIT_no_o) ( Addr base, UWord len ) } else { make_mem_undefined(base, len); } -# endif +#endif /* Idea is: go fast when * 8-aligned and length is 128 @@ -3990,95 +4058,95 @@ void MC_(helperc_MAKE_STACK_UNINIT_no_o) ( Addr base, UWord len ) directly into the vabits array. (If the sm was distinguished, this will make a copy and then write to it.) */ - if (LIKELY( len == 128 && VG_IS_8_ALIGNED(base) )) { + if (LIKELY(len == 128 && VG_IS_8_ALIGNED(base))) { /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 128 - 1); - tl_assert(a_lo < a_hi); // paranoia: detect overflow + tl_assert(a_lo < a_hi); // paranoia: detect overflow if (LIKELY(a_hi <= MAX_PRIMARY_ADDRESS)) { /* Now we know the entire range is within the main primary map. */ UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off16 = SM_OFF_16(a_lo); UShort* p = &sm->vabits16[v_off16]; - p[ 0] = VA_BITS16_UNDEFINED; - p[ 1] = VA_BITS16_UNDEFINED; - p[ 2] = VA_BITS16_UNDEFINED; - p[ 3] = VA_BITS16_UNDEFINED; - p[ 4] = VA_BITS16_UNDEFINED; - p[ 5] = VA_BITS16_UNDEFINED; - p[ 6] = VA_BITS16_UNDEFINED; - p[ 7] = VA_BITS16_UNDEFINED; - p[ 8] = VA_BITS16_UNDEFINED; - p[ 9] = VA_BITS16_UNDEFINED; - p[10] = VA_BITS16_UNDEFINED; - p[11] = VA_BITS16_UNDEFINED; - p[12] = VA_BITS16_UNDEFINED; - p[13] = VA_BITS16_UNDEFINED; - p[14] = VA_BITS16_UNDEFINED; - p[15] = VA_BITS16_UNDEFINED; + p[0] = VA_BITS16_UNDEFINED; + p[1] = VA_BITS16_UNDEFINED; + p[2] = VA_BITS16_UNDEFINED; + p[3] = VA_BITS16_UNDEFINED; + p[4] = VA_BITS16_UNDEFINED; + p[5] = VA_BITS16_UNDEFINED; + p[6] = VA_BITS16_UNDEFINED; + p[7] = VA_BITS16_UNDEFINED; + p[8] = VA_BITS16_UNDEFINED; + p[9] = VA_BITS16_UNDEFINED; + p[10] = VA_BITS16_UNDEFINED; + p[11] = VA_BITS16_UNDEFINED; + p[12] = VA_BITS16_UNDEFINED; + p[13] = VA_BITS16_UNDEFINED; + p[14] = VA_BITS16_UNDEFINED; + p[15] = VA_BITS16_UNDEFINED; return; } } } /* 288 bytes (36 ULongs) is the magic value for ELF ppc64. */ - if (LIKELY( len == 288 && VG_IS_8_ALIGNED(base) )) { + if (LIKELY(len == 288 && VG_IS_8_ALIGNED(base))) { /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 288 - 1); - tl_assert(a_lo < a_hi); // paranoia: detect overflow + tl_assert(a_lo < a_hi); // paranoia: detect overflow if (a_hi <= MAX_PRIMARY_ADDRESS) { UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off16 = SM_OFF_16(a_lo); UShort* p = &sm->vabits16[v_off16]; - p[ 0] = VA_BITS16_UNDEFINED; - p[ 1] = VA_BITS16_UNDEFINED; - p[ 2] = VA_BITS16_UNDEFINED; - p[ 3] = VA_BITS16_UNDEFINED; - p[ 4] = VA_BITS16_UNDEFINED; - p[ 5] = VA_BITS16_UNDEFINED; - p[ 6] = VA_BITS16_UNDEFINED; - p[ 7] = VA_BITS16_UNDEFINED; - p[ 8] = VA_BITS16_UNDEFINED; - p[ 9] = VA_BITS16_UNDEFINED; - p[10] = VA_BITS16_UNDEFINED; - p[11] = VA_BITS16_UNDEFINED; - p[12] = VA_BITS16_UNDEFINED; - p[13] = VA_BITS16_UNDEFINED; - p[14] = VA_BITS16_UNDEFINED; - p[15] = VA_BITS16_UNDEFINED; - p[16] = VA_BITS16_UNDEFINED; - p[17] = VA_BITS16_UNDEFINED; - p[18] = VA_BITS16_UNDEFINED; - p[19] = VA_BITS16_UNDEFINED; - p[20] = VA_BITS16_UNDEFINED; - p[21] = VA_BITS16_UNDEFINED; - p[22] = VA_BITS16_UNDEFINED; - p[23] = VA_BITS16_UNDEFINED; - p[24] = VA_BITS16_UNDEFINED; - p[25] = VA_BITS16_UNDEFINED; - p[26] = VA_BITS16_UNDEFINED; - p[27] = VA_BITS16_UNDEFINED; - p[28] = VA_BITS16_UNDEFINED; - p[29] = VA_BITS16_UNDEFINED; - p[30] = VA_BITS16_UNDEFINED; - p[31] = VA_BITS16_UNDEFINED; - p[32] = VA_BITS16_UNDEFINED; - p[33] = VA_BITS16_UNDEFINED; - p[34] = VA_BITS16_UNDEFINED; - p[35] = VA_BITS16_UNDEFINED; + p[0] = VA_BITS16_UNDEFINED; + p[1] = VA_BITS16_UNDEFINED; + p[2] = VA_BITS16_UNDEFINED; + p[3] = VA_BITS16_UNDEFINED; + p[4] = VA_BITS16_UNDEFINED; + p[5] = VA_BITS16_UNDEFINED; + p[6] = VA_BITS16_UNDEFINED; + p[7] = VA_BITS16_UNDEFINED; + p[8] = VA_BITS16_UNDEFINED; + p[9] = VA_BITS16_UNDEFINED; + p[10] = VA_BITS16_UNDEFINED; + p[11] = VA_BITS16_UNDEFINED; + p[12] = VA_BITS16_UNDEFINED; + p[13] = VA_BITS16_UNDEFINED; + p[14] = VA_BITS16_UNDEFINED; + p[15] = VA_BITS16_UNDEFINED; + p[16] = VA_BITS16_UNDEFINED; + p[17] = VA_BITS16_UNDEFINED; + p[18] = VA_BITS16_UNDEFINED; + p[19] = VA_BITS16_UNDEFINED; + p[20] = VA_BITS16_UNDEFINED; + p[21] = VA_BITS16_UNDEFINED; + p[22] = VA_BITS16_UNDEFINED; + p[23] = VA_BITS16_UNDEFINED; + p[24] = VA_BITS16_UNDEFINED; + p[25] = VA_BITS16_UNDEFINED; + p[26] = VA_BITS16_UNDEFINED; + p[27] = VA_BITS16_UNDEFINED; + p[28] = VA_BITS16_UNDEFINED; + p[29] = VA_BITS16_UNDEFINED; + p[30] = VA_BITS16_UNDEFINED; + p[31] = VA_BITS16_UNDEFINED; + p[32] = VA_BITS16_UNDEFINED; + p[33] = VA_BITS16_UNDEFINED; + p[34] = VA_BITS16_UNDEFINED; + p[35] = VA_BITS16_UNDEFINED; return; } } @@ -4088,17 +4156,16 @@ void MC_(helperc_MAKE_STACK_UNINIT_no_o) ( Addr base, UWord len ) make_mem_undefined(base, len); } - /* And this is an even more specialised case, for the case where there is no origin tracking, and the length is 128. */ VG_REGPARM(1) -void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) +void MC_(helperc_MAKE_STACK_UNINIT_128_no_o)(Addr base) { PROF_EVENT(MCPE_MAKE_STACK_UNINIT_128_NO_O); if (0) - VG_(printf)("helperc_MAKE_STACK_UNINIT_128_no_o (%#lx)\n", base ); + VG_(printf)("helperc_MAKE_STACK_UNINIT_128_no_o (%#lx)\n", base); -# if 0 +#if 0 /* Slow(ish) version, which is fairly easily seen to be correct. */ if (LIKELY( VG_IS_8_ALIGNED(base) )) { @@ -4124,7 +4191,7 @@ void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) } else { make_mem_undefined(base, 128); } -# endif +#endif /* Idea is: go fast when * 16-aligned and length is 128 @@ -4137,33 +4204,33 @@ void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) Typically this applies to amd64 'ret' instructions, since RSP is 16-aligned (0 % 16) after the instruction (per the amd64-ELF ABI). */ - if (LIKELY( VG_IS_16_ALIGNED(base) )) { + if (LIKELY(VG_IS_16_ALIGNED(base))) { /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 128 - 1); /* FIXME: come up with a sane story on the wraparound case (which of course cnanot happen, but still..) */ - /* tl_assert(a_lo < a_hi); */ // paranoia: detect overflow + /* tl_assert(a_lo < a_hi); */ // paranoia: detect overflow if (LIKELY(a_hi <= MAX_PRIMARY_ADDRESS)) { /* Now we know the entire range is within the main primary map. */ UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ PROF_EVENT(MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_16); SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off = SM_OFF(a_lo); UInt* w32 = ASSUME_ALIGNED(UInt*, &sm->vabits8[v_off]); - w32[ 0] = VA_BITS32_UNDEFINED; - w32[ 1] = VA_BITS32_UNDEFINED; - w32[ 2] = VA_BITS32_UNDEFINED; - w32[ 3] = VA_BITS32_UNDEFINED; - w32[ 4] = VA_BITS32_UNDEFINED; - w32[ 5] = VA_BITS32_UNDEFINED; - w32[ 6] = VA_BITS32_UNDEFINED; - w32[ 7] = VA_BITS32_UNDEFINED; + w32[0] = VA_BITS32_UNDEFINED; + w32[1] = VA_BITS32_UNDEFINED; + w32[2] = VA_BITS32_UNDEFINED; + w32[3] = VA_BITS32_UNDEFINED; + w32[4] = VA_BITS32_UNDEFINED; + w32[5] = VA_BITS32_UNDEFINED; + w32[6] = VA_BITS32_UNDEFINED; + w32[7] = VA_BITS32_UNDEFINED; return; } } @@ -4172,22 +4239,22 @@ void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) /* The same, but for when base is 8 % 16, which is the situation with RSP for amd64-ELF immediately after call instructions. */ - if (LIKELY( VG_IS_16_ALIGNED(base+8) )) { // restricts to 8 aligned + if (LIKELY(VG_IS_16_ALIGNED(base + 8))) { // restricts to 8 aligned /* Now we know the address range is suitably sized and aligned. */ UWord a_lo = (UWord)(base); UWord a_hi = (UWord)(base + 128 - 1); /* FIXME: come up with a sane story on the wraparound case (which of course cnanot happen, but still..) */ - /* tl_assert(a_lo < a_hi); */ // paranoia: detect overflow + /* tl_assert(a_lo < a_hi); */ // paranoia: detect overflow if (LIKELY(a_hi <= MAX_PRIMARY_ADDRESS)) { /* Now we know the entire range is within the main primary map. */ UWord pm_off_lo = get_primary_map_low_offset(a_lo); UWord pm_off_hi = get_primary_map_low_offset(a_hi); if (LIKELY(pm_off_lo == pm_off_hi)) { PROF_EVENT(MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_8); - /* Now we know that the entire address range falls within a - single secondary map, and that that secondary 'lives' in - the main primary map. */ + /* Now we know that the entire address range falls within a + single secondary map, and that that secondary 'lives' in + the main primary map. */ SecMap* sm = get_secmap_for_writing_low(a_lo); UWord v_off16 = SM_OFF_16(a_lo); UShort* w16 = &sm->vabits16[v_off16]; @@ -4196,14 +4263,14 @@ void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) performance reasons, but was verified as valid when running the entire testsuite and also Firefox. */ /* tl_assert(VG_IS_4_ALIGNED(w32)); */ - w16[ 0] = VA_BITS16_UNDEFINED; // w16[0] - w32[ 0] = VA_BITS32_UNDEFINED; // w16[1,2] - w32[ 1] = VA_BITS32_UNDEFINED; // w16[3,4] - w32[ 2] = VA_BITS32_UNDEFINED; // w16[5,6] - w32[ 3] = VA_BITS32_UNDEFINED; // w16[7,8] - w32[ 4] = VA_BITS32_UNDEFINED; // w16[9,10] - w32[ 5] = VA_BITS32_UNDEFINED; // w16[11,12] - w32[ 6] = VA_BITS32_UNDEFINED; // w16[13,14] + w16[0] = VA_BITS16_UNDEFINED; // w16[0] + w32[0] = VA_BITS32_UNDEFINED; // w16[1,2] + w32[1] = VA_BITS32_UNDEFINED; // w16[3,4] + w32[2] = VA_BITS32_UNDEFINED; // w16[5,6] + w32[3] = VA_BITS32_UNDEFINED; // w16[7,8] + w32[4] = VA_BITS32_UNDEFINED; // w16[9,10] + w32[5] = VA_BITS32_UNDEFINED; // w16[11,12] + w32[6] = VA_BITS32_UNDEFINED; // w16[13,14] w16[15] = VA_BITS16_UNDEFINED; // w16[15] return; } @@ -4215,19 +4282,11 @@ void MC_(helperc_MAKE_STACK_UNINIT_128_no_o) ( Addr base ) make_mem_undefined(base, 128); } - /*------------------------------------------------------------*/ /*--- Checking memory ---*/ /*------------------------------------------------------------*/ -typedef - enum { - MC_Ok = 5, - MC_AddrErr = 6, - MC_ValueErr = 7 - } - MC_ReadResult; - +typedef enum { MC_Ok = 5, MC_AddrErr = 6, MC_ValueErr = 7 } MC_ReadResult; /* Check permissions for address range. If inadequate permissions exist, *bad_addr is set to the offending address, so the caller can @@ -4237,7 +4296,7 @@ typedef returns False, and if bad_addr is non-NULL, sets *bad_addr to indicate the lowest failing address. Functions below are similar. */ -Bool MC_(check_mem_is_noaccess) ( Addr a, SizeT len, Addr* bad_addr ) +Bool MC_(check_mem_is_noaccess)(Addr a, SizeT len, Addr* bad_addr) { SizeT i; UWord vabits2; @@ -4247,7 +4306,8 @@ Bool MC_(check_mem_is_noaccess) ( Addr a, SizeT len, Addr* bad_addr ) PROF_EVENT(MCPE_CHECK_MEM_IS_NOACCESS_LOOP); vabits2 = get_vabits2(a); if (VA_BITS2_NOACCESS != vabits2) { - if (bad_addr != NULL) *bad_addr = a; + if (bad_addr != NULL) + *bad_addr = a; return False; } a++; @@ -4255,8 +4315,9 @@ Bool MC_(check_mem_is_noaccess) ( Addr a, SizeT len, Addr* bad_addr ) return True; } -static Bool is_mem_addressable ( Addr a, SizeT len, - /*OUT*/Addr* bad_addr ) +static Bool is_mem_addressable(Addr a, + SizeT len, + /*OUT*/ Addr* bad_addr) { SizeT i; UWord vabits2; @@ -4266,7 +4327,8 @@ static Bool is_mem_addressable ( Addr a, SizeT len, PROF_EVENT(MCPE_IS_MEM_ADDRESSABLE_LOOP); vabits2 = get_vabits2(a); if (VA_BITS2_NOACCESS == vabits2) { - if (bad_addr != NULL) *bad_addr = a; + if (bad_addr != NULL) + *bad_addr = a; return False; } a++; @@ -4274,9 +4336,10 @@ static Bool is_mem_addressable ( Addr a, SizeT len, return True; } -static MC_ReadResult is_mem_defined ( Addr a, SizeT len, - /*OUT*/Addr* bad_addr, - /*OUT*/UInt* otag ) +static MC_ReadResult is_mem_defined(Addr a, + SizeT len, + /*OUT*/ Addr* bad_addr, + /*OUT*/ UInt* otag) { SizeT i; UWord vabits2; @@ -4284,8 +4347,10 @@ static MC_ReadResult is_mem_defined ( Addr a, SizeT len, PROF_EVENT(MCPE_IS_MEM_DEFINED); DEBUG("is_mem_defined\n"); - if (otag) *otag = 0; - if (bad_addr) *bad_addr = 0; + if (otag) + *otag = 0; + if (bad_addr) + *bad_addr = 0; for (i = 0; i < len; i++) { PROF_EVENT(MCPE_IS_MEM_DEFINED_LOOP); vabits2 = get_vabits2(a); @@ -4301,7 +4366,7 @@ static MC_ReadResult is_mem_defined ( Addr a, SizeT len, } if (MC_(clo_mc_level) >= 2) { if (otag && MC_(clo_mc_level) == 3) { - *otag = MC_(helperc_b_load1)( a ); + *otag = MC_(helperc_b_load1)(a); } return MC_ValueErr; } @@ -4311,7 +4376,6 @@ static MC_ReadResult is_mem_defined ( Addr a, SizeT len, return MC_Ok; } - /* Like is_mem_defined but doesn't give up at the first uninitialised byte -- the entire range is always checked. This is important for detecting errors in the case where a checked range strays into @@ -4321,14 +4385,15 @@ static MC_ReadResult is_mem_defined ( Addr a, SizeT len, the checked data. This version always checks the entire range and can report both a definedness and an accessbility error, if necessary. */ -static void is_mem_defined_comprehensive ( - Addr a, SizeT len, - /*OUT*/Bool* errorV, /* is there a definedness err? */ - /*OUT*/Addr* bad_addrV, /* if so where? */ - /*OUT*/UInt* otagV, /* and what's its otag? */ - /*OUT*/Bool* errorA, /* is there an addressability err? */ - /*OUT*/Addr* bad_addrA /* if so where? */ - ) +static void is_mem_defined_comprehensive( + Addr a, + SizeT len, + /*OUT*/ Bool* errorV, /* is there a definedness err? */ + /*OUT*/ Addr* bad_addrV, /* if so where? */ + /*OUT*/ UInt* otagV, /* and what's its otag? */ + /*OUT*/ Bool* errorA, /* is there an addressability err? */ + /*OUT*/ Addr* bad_addrA /* if so where? */ +) { SizeT i; UWord vabits2; @@ -4343,47 +4408,48 @@ static void is_mem_defined_comprehensive ( PROF_EVENT(MCPE_IS_MEM_DEFINED_COMPREHENSIVE_LOOP); vabits2 = get_vabits2(a); switch (vabits2) { - case VA_BITS2_DEFINED: - a++; - break; - case VA_BITS2_UNDEFINED: - case VA_BITS2_PARTDEFINED: - if (!already_saw_errV) { - *errorV = True; - *bad_addrV = a; - if (MC_(clo_mc_level) == 3) { - *otagV = MC_(helperc_b_load1)( a ); - } else { - *otagV = 0; - } - already_saw_errV = True; + case VA_BITS2_DEFINED: + a++; + break; + case VA_BITS2_UNDEFINED: + case VA_BITS2_PARTDEFINED: + if (!already_saw_errV) { + *errorV = True; + *bad_addrV = a; + if (MC_(clo_mc_level) == 3) { + *otagV = MC_(helperc_b_load1)(a); + } else { + *otagV = 0; } - a++; /* keep going */ - break; - case VA_BITS2_NOACCESS: - *errorA = True; - *bad_addrA = a; - return; /* give up now. */ - default: - tl_assert(0); + already_saw_errV = True; + } + a++; /* keep going */ + break; + case VA_BITS2_NOACCESS: + *errorA = True; + *bad_addrA = a; + return; /* give up now. */ + default: + tl_assert(0); } } } - /* Check a zero-terminated ascii string. Tricky -- don't want to examine the actual bytes, to find the end, until we're sure it is safe to do so. */ -static Bool mc_is_defined_asciiz ( Addr a, Addr* bad_addr, UInt* otag ) +static Bool mc_is_defined_asciiz(Addr a, Addr* bad_addr, UInt* otag) { UWord vabits2; PROF_EVENT(MCPE_IS_DEFINED_ASCIIZ); DEBUG("mc_is_defined_asciiz\n"); - if (otag) *otag = 0; - if (bad_addr) *bad_addr = 0; + if (otag) + *otag = 0; + if (bad_addr) + *bad_addr = 0; while (True) { PROF_EVENT(MCPE_IS_DEFINED_ASCIIZ_LOOP); vabits2 = get_vabits2(a); @@ -4399,40 +4465,38 @@ static Bool mc_is_defined_asciiz ( Addr a, Addr* bad_addr, UInt* otag ) } if (MC_(clo_mc_level) >= 2) { if (otag && MC_(clo_mc_level) == 3) { - *otag = MC_(helperc_b_load1)( a ); + *otag = MC_(helperc_b_load1)(a); } return MC_ValueErr; } } /* Ok, a is safe to read. */ - if (* ((UChar*)a) == 0) { + if (*((UChar*)a) == 0) { return MC_Ok; } a++; } } - /*------------------------------------------------------------*/ /*--- Memory event handlers ---*/ /*------------------------------------------------------------*/ -static -void check_mem_is_addressable ( CorePart part, ThreadId tid, const HChar* s, - Addr base, SizeT size ) +static void check_mem_is_addressable( + CorePart part, ThreadId tid, const HChar* s, Addr base, SizeT size) { Addr bad_addr; - Bool ok = is_mem_addressable ( base, size, &bad_addr ); + Bool ok = is_mem_addressable(base, size, &bad_addr); if (!ok) { switch (part) { case Vg_CoreSysCall: - MC_(record_memparam_error) ( tid, bad_addr, - /*isAddrErr*/True, s, 0/*otag*/ ); + MC_(record_memparam_error)(tid, bad_addr, + /*isAddrErr*/ True, s, 0 /*otag*/); break; case Vg_CoreSignal: - MC_(record_core_mem_error)( tid, s ); + MC_(record_core_mem_error)(tid, s); break; default: @@ -4441,31 +4505,30 @@ void check_mem_is_addressable ( CorePart part, ThreadId tid, const HChar* s, } } -static -void check_mem_is_defined ( CorePart part, ThreadId tid, const HChar* s, - Addr base, SizeT size ) +static void check_mem_is_defined( + CorePart part, ThreadId tid, const HChar* s, Addr base, SizeT size) { - UInt otag = 0; - Addr bad_addr; - MC_ReadResult res = is_mem_defined ( base, size, &bad_addr, &otag ); + UInt otag = 0; + Addr bad_addr; + MC_ReadResult res = is_mem_defined(base, size, &bad_addr, &otag); if (MC_Ok != res) { - Bool isAddrErr = ( MC_AddrErr == res ? True : False ); + Bool isAddrErr = (MC_AddrErr == res ? True : False); switch (part) { case Vg_CoreSysCall: - MC_(record_memparam_error) ( tid, bad_addr, isAddrErr, s, - isAddrErr ? 0 : otag ); + MC_(record_memparam_error)(tid, bad_addr, isAddrErr, s, + isAddrErr ? 0 : otag); break; case Vg_CoreSysCallArgInMem: - MC_(record_regparam_error) ( tid, s, otag ); + MC_(record_regparam_error)(tid, s, otag); break; /* If we're being asked to jump to a silly address, record an error message before potentially crashing the entire system. */ case Vg_CoreTranslate: - MC_(record_jump_error)( tid, bad_addr ); + MC_(record_jump_error)(tid, bad_addr); break; default: @@ -4474,20 +4537,21 @@ void check_mem_is_defined ( CorePart part, ThreadId tid, const HChar* s, } } -static -void check_mem_is_defined_asciiz ( CorePart part, ThreadId tid, - const HChar* s, Addr str ) +static void check_mem_is_defined_asciiz(CorePart part, + ThreadId tid, + const HChar* s, + Addr str) { MC_ReadResult res; - Addr bad_addr = 0; // shut GCC up - UInt otag = 0; + Addr bad_addr = 0; // shut GCC up + UInt otag = 0; tl_assert(part == Vg_CoreSysCall); - res = mc_is_defined_asciiz ( (Addr)str, &bad_addr, &otag ); + res = mc_is_defined_asciiz((Addr)str, &bad_addr, &otag); if (MC_Ok != res) { - Bool isAddrErr = ( MC_AddrErr == res ? True : False ); - MC_(record_memparam_error) ( tid, bad_addr, isAddrErr, s, - isAddrErr ? 0 : otag ); + Bool isAddrErr = (MC_AddrErr == res ? True : False); + MC_(record_memparam_error)(tid, bad_addr, isAddrErr, s, + isAddrErr ? 0 : otag); } } @@ -4545,9 +4609,8 @@ void check_mem_is_defined_asciiz ( CorePart part, ThreadId tid, See https://bugs.kde.org/show_bug.cgi?id=205541 and https://bugs.kde.org/show_bug.cgi?id=210268 */ -static -void mc_new_mem_mmap ( Addr a, SizeT len, Bool rr, Bool ww, Bool xx, - ULong di_handle ) +static void +mc_new_mem_mmap(Addr a, SizeT len, Bool rr, Bool ww, Bool xx, ULong di_handle) { if (rr || ww || xx) { /* (2) mmap/mprotect other -> defined */ @@ -4558,8 +4621,7 @@ void mc_new_mem_mmap ( Addr a, SizeT len, Bool rr, Bool ww, Bool xx, } } -static -void mc_new_mem_mprotect ( Addr a, SizeT len, Bool rr, Bool ww, Bool xx ) +static void mc_new_mem_mprotect(Addr a, SizeT len, Bool rr, Bool ww, Bool xx) { if (rr || ww || xx) { /* (4) mprotect other -> change any "noaccess" to "defined" */ @@ -4570,10 +4632,8 @@ void mc_new_mem_mprotect ( Addr a, SizeT len, Bool rr, Bool ww, Bool xx ) } } - -static -void mc_new_mem_startup( Addr a, SizeT len, - Bool rr, Bool ww, Bool xx, ULong di_handle ) +static void mc_new_mem_startup( + Addr a, SizeT len, Bool rr, Bool ww, Bool xx, ULong di_handle) { // Because code is defined, initialised variables get put in the data // segment and are defined, and uninitialised variables get put in the @@ -4590,18 +4650,16 @@ void mc_new_mem_startup( Addr a, SizeT len, // without requiring more than one A bit which would slow things down a // lot. But on Darwin the 0th page is mapped but !R and !W and !X. // So we mark any such pages as "unaddressable". - DEBUG("mc_new_mem_startup(%#lx, %llu, rr=%u, ww=%u, xx=%u)\n", - a, (ULong)len, rr, ww, xx); + DEBUG("mc_new_mem_startup(%#lx, %llu, rr=%u, ww=%u, xx=%u)\n", a, (ULong)len, + rr, ww, xx); mc_new_mem_mmap(a, len, rr, ww, xx, di_handle); } -static -void mc_post_mem_write(CorePart part, ThreadId tid, Addr a, SizeT len) +static void mc_post_mem_write(CorePart part, ThreadId tid, Addr a, SizeT len) { MC_(make_mem_defined)(a, len); } - /*------------------------------------------------------------*/ /*--- Register event handlers ---*/ /*------------------------------------------------------------*/ @@ -4609,65 +4667,62 @@ void mc_post_mem_write(CorePart part, ThreadId tid, Addr a, SizeT len) /* Try and get a nonzero origin for the guest state section of thread tid characterised by (offset,size). Return 0 if nothing to show for it. */ -static UInt mb_get_origin_for_guest_offset ( ThreadId tid, - Int offset, SizeT size ) +static UInt mb_get_origin_for_guest_offset(ThreadId tid, Int offset, SizeT size) { - Int sh2off; - UInt area[3]; - UInt otag; - sh2off = MC_(get_otrack_shadow_offset)( offset, size ); + Int sh2off; + UInt area[3]; + UInt otag; + sh2off = MC_(get_otrack_shadow_offset)(offset, size); if (sh2off == -1) - return 0; /* This piece of guest state is not tracked */ + return 0; /* This piece of guest state is not tracked */ tl_assert(sh2off >= 0); tl_assert(0 == (sh2off % 4)); area[0] = 0x31313131; area[2] = 0x27272727; - VG_(get_shadow_regs_area)( tid, (UChar *)&area[1], 2/*shadowno*/,sh2off,4 ); + VG_(get_shadow_regs_area)(tid, (UChar*)&area[1], 2 /*shadowno*/, sh2off, 4); tl_assert(area[0] == 0x31313131); tl_assert(area[2] == 0x27272727); otag = area[1]; return otag; } - /* When some chunk of guest state is written, mark the corresponding shadow area as valid. This is used to initialise arbitrarily large chunks of guest state, hence the _SIZE value, which has to be as big as the biggest guest state. */ -static void mc_post_reg_write ( CorePart part, ThreadId tid, - PtrdiffT offset, SizeT size) +static void +mc_post_reg_write(CorePart part, ThreadId tid, PtrdiffT offset, SizeT size) { -# define MAX_REG_WRITE_SIZE 2264 +#define MAX_REG_WRITE_SIZE 2264 UChar area[MAX_REG_WRITE_SIZE]; tl_assert(size <= MAX_REG_WRITE_SIZE); VG_(memset)(area, V_BITS8_DEFINED, size); - VG_(set_shadow_regs_area)( tid, 1/*shadowNo*/,offset,size, area ); -# undef MAX_REG_WRITE_SIZE + VG_(set_shadow_regs_area)(tid, 1 /*shadowNo*/, offset, size, area); +#undef MAX_REG_WRITE_SIZE } -static -void mc_post_reg_write_clientcall ( ThreadId tid, - PtrdiffT offset, SizeT size, Addr f) +static void +mc_post_reg_write_clientcall(ThreadId tid, PtrdiffT offset, SizeT size, Addr f) { - mc_post_reg_write(/*dummy*/0, tid, offset, size); + mc_post_reg_write(/*dummy*/ 0, tid, offset, size); } /* Look at the definedness of the guest's shadow state for [offset, offset+len). If any part of that is undefined, record a parameter error. */ -static void mc_pre_reg_read ( CorePart part, ThreadId tid, const HChar* s, - PtrdiffT offset, SizeT size) +static void mc_pre_reg_read( + CorePart part, ThreadId tid, const HChar* s, PtrdiffT offset, SizeT size) { - Int i; - Bool bad; - UInt otag; + Int i; + Bool bad; + UInt otag; UChar area[16]; tl_assert(size <= 16); - VG_(get_shadow_regs_area)( tid, area, 1/*shadowNo*/,offset,size ); + VG_(get_shadow_regs_area)(tid, area, 1 /*shadowNo*/, offset, size); bad = False; for (i = 0; i < size; i++) { @@ -4682,114 +4737,111 @@ static void mc_pre_reg_read ( CorePart part, ThreadId tid, const HChar* s, /* We've found some undefinedness. See if we can also find an origin for it. */ - otag = mb_get_origin_for_guest_offset( tid, offset, size ); - MC_(record_regparam_error) ( tid, s, otag ); + otag = mb_get_origin_for_guest_offset(tid, offset, size); + MC_(record_regparam_error)(tid, s, otag); } - /*------------------------------------------------------------*/ /*--- Register-memory event handlers ---*/ /*------------------------------------------------------------*/ -static void mc_copy_mem_to_reg ( CorePart part, ThreadId tid, Addr a, - PtrdiffT guest_state_offset, SizeT size ) +static void mc_copy_mem_to_reg( + CorePart part, ThreadId tid, Addr a, PtrdiffT guest_state_offset, SizeT size) { SizeT i; UChar vbits8; - Int offset; - UInt d32; + Int offset; + UInt d32; /* Slow loop. */ for (i = 0; i < size; i++) { - get_vbits8( a+i, &vbits8 ); - VG_(set_shadow_regs_area)( tid, 1/*shadowNo*/, guest_state_offset+i, - 1, &vbits8 ); + get_vbits8(a + i, &vbits8); + VG_(set_shadow_regs_area)(tid, 1 /*shadowNo*/, guest_state_offset + i, 1, + &vbits8); } if (MC_(clo_mc_level) != 3) return; /* Track origins. */ - offset = MC_(get_otrack_shadow_offset)( guest_state_offset, size ); + offset = MC_(get_otrack_shadow_offset)(guest_state_offset, size); if (offset == -1) return; switch (size) { case 1: - d32 = MC_(helperc_b_load1)( a ); + d32 = MC_(helperc_b_load1)(a); break; case 2: - d32 = MC_(helperc_b_load2)( a ); + d32 = MC_(helperc_b_load2)(a); break; case 4: - d32 = MC_(helperc_b_load4)( a ); + d32 = MC_(helperc_b_load4)(a); break; case 8: - d32 = MC_(helperc_b_load8)( a ); + d32 = MC_(helperc_b_load8)(a); break; case 16: - d32 = MC_(helperc_b_load16)( a ); + d32 = MC_(helperc_b_load16)(a); break; case 32: - d32 = MC_(helperc_b_load32)( a ); + d32 = MC_(helperc_b_load32)(a); break; default: tl_assert(0); } - VG_(set_shadow_regs_area)( tid, 2/*shadowNo*/, offset, 4, (UChar*)&d32 ); + VG_(set_shadow_regs_area)(tid, 2 /*shadowNo*/, offset, 4, (UChar*)&d32); } -static void mc_copy_reg_to_mem ( CorePart part, ThreadId tid, - PtrdiffT guest_state_offset, Addr a, - SizeT size ) +static void mc_copy_reg_to_mem( + CorePart part, ThreadId tid, PtrdiffT guest_state_offset, Addr a, SizeT size) { SizeT i; UChar vbits8; - Int offset; - UInt d32; + Int offset; + UInt d32; /* Slow loop. */ for (i = 0; i < size; i++) { - VG_(get_shadow_regs_area)( tid, &vbits8, 1/*shadowNo*/, - guest_state_offset+i, 1 ); - set_vbits8( a+i, vbits8 ); + VG_(get_shadow_regs_area)(tid, &vbits8, 1 /*shadowNo*/, + guest_state_offset + i, 1); + set_vbits8(a + i, vbits8); } if (MC_(clo_mc_level) != 3) return; /* Track origins. */ - offset = MC_(get_otrack_shadow_offset)( guest_state_offset, size ); + offset = MC_(get_otrack_shadow_offset)(guest_state_offset, size); if (offset == -1) return; - VG_(get_shadow_regs_area)( tid, (UChar*)&d32, 2/*shadowNo*/, offset, 4 ); + VG_(get_shadow_regs_area)(tid, (UChar*)&d32, 2 /*shadowNo*/, offset, 4); switch (size) { case 1: - MC_(helperc_b_store1)( a, d32 ); + MC_(helperc_b_store1)(a, d32); break; case 2: - MC_(helperc_b_store2)( a, d32 ); + MC_(helperc_b_store2)(a, d32); break; case 4: - MC_(helperc_b_store4)( a, d32 ); + MC_(helperc_b_store4)(a, d32); break; case 8: - MC_(helperc_b_store8)( a, d32 ); + MC_(helperc_b_store8)(a, d32); break; case 16: - MC_(helperc_b_store16)( a, d32 ); + MC_(helperc_b_store16)(a, d32); break; case 32: - MC_(helperc_b_store32)( a, d32 ); + MC_(helperc_b_store32)(a, d32); break; default: tl_assert(0); } } - /*------------------------------------------------------------*/ /*--- Some static assertions ---*/ /*------------------------------------------------------------*/ @@ -4802,10 +4854,10 @@ static void mc_copy_reg_to_mem ( CorePart part, ThreadId tid, STATIC_ASSERT(SM_CHUNKS * 4 == 65536); -STATIC_ASSERT(VA_BITS8_DEFINED == 0xAA); +STATIC_ASSERT(VA_BITS8_DEFINED == 0xAA); STATIC_ASSERT(VA_BITS8_UNDEFINED == 0x55); -STATIC_ASSERT(V_BITS32_DEFINED == 0x00000000); +STATIC_ASSERT(V_BITS32_DEFINED == 0x00000000); STATIC_ASSERT(V_BITS32_UNDEFINED == 0xFFFFFFFF); STATIC_ASSERT(VA_BITS4_DEFINED == 0xA); @@ -4820,7 +4872,6 @@ STATIC_ASSERT(VA_BITS2_UNDEFINED == 1); STATIC_ASSERT(V_BITS8_DEFINED == 0x00); STATIC_ASSERT(V_BITS8_UNDEFINED == 0xFF); - /*------------------------------------------------------------*/ /*--- Functions called directly from generated code: ---*/ /*--- Load/store handlers. ---*/ @@ -4842,12 +4893,11 @@ STATIC_ASSERT(V_BITS8_UNDEFINED == 0xFF); primary map. This is all very tricky (and important!), so let's work through the maths by hand (below), *and* assert for these values at startup. */ -#define MASK(_szInBytes) \ - ( ~((0x10000UL-(_szInBytes)) | ((N_PRIMARY_MAP-1) << 16)) ) +#define MASK(_szInBytes) \ + (~((0x10000UL - (_szInBytes)) | ((N_PRIMARY_MAP - 1) << 16))) /* MASK only exists so as to define this macro. */ -#define UNALIGNED_OR_HIGH(_a,_szInBits) \ - ((_a) & MASK((_szInBits>>3))) +#define UNALIGNED_OR_HIGH(_a, _szInBits) ((_a)&MASK((_szInBits >> 3))) /* On a 32-bit machine: @@ -4915,14 +4965,13 @@ STATIC_ASSERT(V_BITS8_UNDEFINED == 0xFF); /*--- LOADV256 and LOADV128 ---*/ /*------------------------------------------------------------*/ -static INLINE -void mc_LOADV_128_or_256 ( /*OUT*/ULong* res, - Addr a, SizeT nBits, Bool isBigEndian ) +static INLINE void +mc_LOADV_128_or_256(/*OUT*/ ULong* res, Addr a, SizeT nBits, Bool isBigEndian) { PROF_EVENT(MCPE_LOADV_128_OR_256); #ifndef PERF_FAST_LOADV - mc_LOADV_128_or_256_slow( res, a, nBits, isBigEndian ); + mc_LOADV_128_or_256_slow(res, a, nBits, isBigEndian); return; #else { @@ -4931,17 +4980,17 @@ void mc_LOADV_128_or_256 ( /*OUT*/ULong* res, UWord nULongs = nBytes / 8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,nBits) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, nBits))) { PROF_EVENT(MCPE_LOADV_128_OR_256_SLOW1); - mc_LOADV_128_or_256_slow( res, a, nBits, isBigEndian ); + mc_LOADV_128_or_256_slow(res, a, nBits, isBigEndian); return; } /* Handle common cases quickly: a (and a+8 and a+16 etc.) is suitably aligned, is mapped, and addressible. */ for (j = 0; j < nULongs; j++) { - sm = get_secmap_for_reading_low(a + 8*j); - sm_off16 = SM_OFF_16(a + 8*j); + sm = get_secmap_for_reading_low(a + 8 * j); + sm_off16 = SM_OFF_16(a + 8 * j); vabits16 = sm->vabits16[sm_off16]; // Convert V bits from compact memory form to expanded @@ -4954,7 +5003,7 @@ void mc_LOADV_128_or_256 ( /*OUT*/ULong* res, /* Slow case: some block of 8 bytes are not all-defined or all-undefined. */ PROF_EVENT(MCPE_LOADV_128_OR_256_SLOW2); - mc_LOADV_128_or_256_slow( res, a, nBits, isBigEndian ); + mc_LOADV_128_or_256_slow(res, a, nBits, isBigEndian); return; } } @@ -4963,20 +5012,20 @@ void mc_LOADV_128_or_256 ( /*OUT*/ULong* res, #endif } -VG_REGPARM(2) void MC_(helperc_LOADV256be) ( /*OUT*/V256* res, Addr a ) +VG_REGPARM(2) void MC_(helperc_LOADV256be)(/*OUT*/ V256* res, Addr a) { mc_LOADV_128_or_256(&res->w64[0], a, 256, True); } -VG_REGPARM(2) void MC_(helperc_LOADV256le) ( /*OUT*/V256* res, Addr a ) +VG_REGPARM(2) void MC_(helperc_LOADV256le)(/*OUT*/ V256* res, Addr a) { mc_LOADV_128_or_256(&res->w64[0], a, 256, False); } -VG_REGPARM(2) void MC_(helperc_LOADV128be) ( /*OUT*/V128* res, Addr a ) +VG_REGPARM(2) void MC_(helperc_LOADV128be)(/*OUT*/ V128* res, Addr a) { mc_LOADV_128_or_256(&res->w64[0], a, 128, True); } -VG_REGPARM(2) void MC_(helperc_LOADV128le) ( /*OUT*/V128* res, Addr a ) +VG_REGPARM(2) void MC_(helperc_LOADV128le)(/*OUT*/ V128* res, Addr a) { mc_LOADV_128_or_256(&res->w64[0], a, 128, False); } @@ -4985,21 +5034,20 @@ VG_REGPARM(2) void MC_(helperc_LOADV128le) ( /*OUT*/V128* res, Addr a ) /*--- LOADV64 ---*/ /*------------------------------------------------------------*/ -static INLINE -ULong mc_LOADV64 ( Addr a, Bool isBigEndian ) +static INLINE ULong mc_LOADV64(Addr a, Bool isBigEndian) { PROF_EVENT(MCPE_LOADV64); #ifndef PERF_FAST_LOADV - return mc_LOADVn_slow( a, 64, isBigEndian ); + return mc_LOADVn_slow(a, 64, isBigEndian); #else { UWord sm_off16, vabits16; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,64) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 64))) { PROF_EVENT(MCPE_LOADV64_SLOW1); - return (ULong)mc_LOADVn_slow( a, 64, isBigEndian ); + return (ULong)mc_LOADVn_slow(a, 64, isBigEndian); } sm = get_secmap_for_reading_low(a); @@ -5016,30 +5064,31 @@ ULong mc_LOADV64 ( Addr a, Bool isBigEndian ) } else { /* Slow case: the 8 bytes are not all-defined or all-undefined. */ PROF_EVENT(MCPE_LOADV64_SLOW2); - return mc_LOADVn_slow( a, 64, isBigEndian ); + return mc_LOADVn_slow(a, 64, isBigEndian); } } #endif } // Generic for all platforms -VG_REGPARM(1) ULong MC_(helperc_LOADV64be) ( Addr a ) +VG_REGPARM(1) ULong MC_(helperc_LOADV64be)(Addr a) { return mc_LOADV64(a, True); } // Non-generic assembly for arm32-linux -#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && defined(VGP_arm_linux) +#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + defined(VGP_arm_linux) /* See mc_main_asm.c */ -#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)) +#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || \ + defined(VGP_x86_freebsd)) /* See mc_main_asm.c */ #else // Generic for all platforms except {arm32,x86}-linux and x86-solaris -VG_REGPARM(1) ULong MC_(helperc_LOADV64le) ( Addr a ) +VG_REGPARM(1) ULong MC_(helperc_LOADV64le)(Addr a) { return mc_LOADV64(a, False); } @@ -5049,23 +5098,22 @@ VG_REGPARM(1) ULong MC_(helperc_LOADV64le) ( Addr a ) /*--- STOREV64 ---*/ /*------------------------------------------------------------*/ -static INLINE -void mc_STOREV64 ( Addr a, ULong vbits64, Bool isBigEndian ) +static INLINE void mc_STOREV64(Addr a, ULong vbits64, Bool isBigEndian) { PROF_EVENT(MCPE_STOREV64); #ifndef PERF_FAST_STOREV // XXX: this slow case seems to be marginally faster than the fast case! // Investigate further. - mc_STOREVn_slow( a, 64, vbits64, isBigEndian ); + mc_STOREVn_slow(a, 64, vbits64, isBigEndian); #else { UWord sm_off16, vabits16; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,64) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 64))) { PROF_EVENT(MCPE_STOREV64_SLOW1); - mc_STOREVn_slow( a, 64, vbits64, isBigEndian ); + mc_STOREVn_slow(a, 64, vbits64, isBigEndian); return; } @@ -5084,7 +5132,7 @@ void mc_STOREV64 ( Addr a, ULong vbits64, Bool isBigEndian ) return; } PROF_EVENT(MCPE_STOREV64_SLOW2); - mc_STOREVn_slow( a, 64, vbits64, isBigEndian ); + mc_STOREVn_slow(a, 64, vbits64, isBigEndian); return; } if (V_BITS64_UNDEFINED == vbits64) { @@ -5096,21 +5144,21 @@ void mc_STOREV64 ( Addr a, ULong vbits64, Bool isBigEndian ) return; } PROF_EVENT(MCPE_STOREV64_SLOW3); - mc_STOREVn_slow( a, 64, vbits64, isBigEndian ); + mc_STOREVn_slow(a, 64, vbits64, isBigEndian); return; } PROF_EVENT(MCPE_STOREV64_SLOW4); - mc_STOREVn_slow( a, 64, vbits64, isBigEndian ); + mc_STOREVn_slow(a, 64, vbits64, isBigEndian); } #endif } -VG_REGPARM(1) void MC_(helperc_STOREV64be) ( Addr a, ULong vbits64 ) +VG_REGPARM(1) void MC_(helperc_STOREV64be)(Addr a, ULong vbits64) { mc_STOREV64(a, vbits64, True); } -VG_REGPARM(1) void MC_(helperc_STOREV64le) ( Addr a, ULong vbits64 ) +VG_REGPARM(1) void MC_(helperc_STOREV64le)(Addr a, ULong vbits64) { mc_STOREV64(a, vbits64, False); } @@ -5119,21 +5167,20 @@ VG_REGPARM(1) void MC_(helperc_STOREV64le) ( Addr a, ULong vbits64 ) /*--- LOADV32 ---*/ /*------------------------------------------------------------*/ -static INLINE -UWord mc_LOADV32 ( Addr a, Bool isBigEndian ) +static INLINE UWord mc_LOADV32(Addr a, Bool isBigEndian) { PROF_EVENT(MCPE_LOADV32); #ifndef PERF_FAST_LOADV - return (UWord)mc_LOADVn_slow( a, 32, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 32, isBigEndian); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,32) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 32))) { PROF_EVENT(MCPE_LOADV32_SLOW1); - return (UWord)mc_LOADVn_slow( a, 32, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 32, isBigEndian); } sm = get_secmap_for_reading_low(a); @@ -5152,30 +5199,30 @@ UWord mc_LOADV32 ( Addr a, Bool isBigEndian ) } else { /* Slow case: the 4 bytes are not all-defined or all-undefined. */ PROF_EVENT(MCPE_LOADV32_SLOW2); - return (UWord)mc_LOADVn_slow( a, 32, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 32, isBigEndian); } } #endif } // Generic for all platforms -VG_REGPARM(1) UWord MC_(helperc_LOADV32be) ( Addr a ) +VG_REGPARM(1) UWord MC_(helperc_LOADV32be)(Addr a) { return mc_LOADV32(a, True); } // Non-generic assembly for arm32-linux -#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && defined(VGP_arm_linux) +#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + defined(VGP_arm_linux) /* See mc_main_asm.c */ -#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) +#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) /* See mc_main_asm.c */ #else // Generic for all platforms except {arm32,x86}-linux and x86-solaris -VG_REGPARM(1) UWord MC_(helperc_LOADV32le) ( Addr a ) +VG_REGPARM(1) UWord MC_(helperc_LOADV32le)(Addr a) { return mc_LOADV32(a, False); } @@ -5185,21 +5232,20 @@ VG_REGPARM(1) UWord MC_(helperc_LOADV32le) ( Addr a ) /*--- STOREV32 ---*/ /*------------------------------------------------------------*/ -static INLINE -void mc_STOREV32 ( Addr a, UWord vbits32, Bool isBigEndian ) +static INLINE void mc_STOREV32(Addr a, UWord vbits32, Bool isBigEndian) { PROF_EVENT(MCPE_STOREV32); #ifndef PERF_FAST_STOREV - mc_STOREVn_slow( a, 32, (ULong)vbits32, isBigEndian ); + mc_STOREVn_slow(a, 32, (ULong)vbits32, isBigEndian); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,32) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 32))) { PROF_EVENT(MCPE_STOREV32_SLOW1); - mc_STOREVn_slow( a, 32, (ULong)vbits32, isBigEndian ); + mc_STOREVn_slow(a, 32, (ULong)vbits32, isBigEndian); return; } @@ -5213,12 +5259,12 @@ void mc_STOREV32 ( Addr a, UWord vbits32, Bool isBigEndian ) if (LIKELY(vabits8 == (UInt)VA_BITS8_DEFINED)) { return; } - if (!is_distinguished_sm(sm) && VA_BITS8_UNDEFINED == vabits8) { + if (!is_distinguished_sm(sm) && VA_BITS8_UNDEFINED == vabits8) { sm->vabits8[sm_off] = (UInt)VA_BITS8_DEFINED; return; } PROF_EVENT(MCPE_STOREV32_SLOW2); - mc_STOREVn_slow( a, 32, (ULong)vbits32, isBigEndian ); + mc_STOREVn_slow(a, 32, (ULong)vbits32, isBigEndian); return; } if (V_BITS32_UNDEFINED == vbits32) { @@ -5230,21 +5276,21 @@ void mc_STOREV32 ( Addr a, UWord vbits32, Bool isBigEndian ) return; } PROF_EVENT(MCPE_STOREV32_SLOW3); - mc_STOREVn_slow( a, 32, (ULong)vbits32, isBigEndian ); + mc_STOREVn_slow(a, 32, (ULong)vbits32, isBigEndian); return; } PROF_EVENT(MCPE_STOREV32_SLOW4); - mc_STOREVn_slow( a, 32, (ULong)vbits32, isBigEndian ); + mc_STOREVn_slow(a, 32, (ULong)vbits32, isBigEndian); } #endif } -VG_REGPARM(2) void MC_(helperc_STOREV32be) ( Addr a, UWord vbits32 ) +VG_REGPARM(2) void MC_(helperc_STOREV32be)(Addr a, UWord vbits32) { mc_STOREV32(a, vbits32, True); } -VG_REGPARM(2) void MC_(helperc_STOREV32le) ( Addr a, UWord vbits32 ) +VG_REGPARM(2) void MC_(helperc_STOREV32le)(Addr a, UWord vbits32) { mc_STOREV32(a, vbits32, False); } @@ -5253,21 +5299,20 @@ VG_REGPARM(2) void MC_(helperc_STOREV32le) ( Addr a, UWord vbits32 ) /*--- LOADV16 ---*/ /*------------------------------------------------------------*/ -static INLINE -UWord mc_LOADV16 ( Addr a, Bool isBigEndian ) +static INLINE UWord mc_LOADV16(Addr a, Bool isBigEndian) { PROF_EVENT(MCPE_LOADV16); #ifndef PERF_FAST_LOADV - return (UWord)mc_LOADVn_slow( a, 16, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 16, isBigEndian); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,16) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 16))) { PROF_EVENT(MCPE_LOADV16_SLOW1); - return (UWord)mc_LOADVn_slow( a, 16, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 16, isBigEndian); } sm = get_secmap_for_reading_low(a); @@ -5276,18 +5321,22 @@ UWord mc_LOADV16 ( Addr a, Bool isBigEndian ) // Handle common case quickly: a is suitably aligned, is mapped, and is // addressible. // Convert V bits from compact memory form to expanded register form - if (LIKELY(vabits8 == VA_BITS8_DEFINED )) { return V_BITS16_DEFINED; } - else if (LIKELY(vabits8 == VA_BITS8_UNDEFINED)) { return V_BITS16_UNDEFINED; } - else { + if (LIKELY(vabits8 == VA_BITS8_DEFINED)) { + return V_BITS16_DEFINED; + } else if (LIKELY(vabits8 == VA_BITS8_UNDEFINED)) { + return V_BITS16_UNDEFINED; + } else { // The 4 (yes, 4) bytes are not all-defined or all-undefined, check // the two sub-bytes. UChar vabits4 = extract_vabits4_from_vabits8(a, vabits8); - if (vabits4 == VA_BITS4_DEFINED ) { return V_BITS16_DEFINED; } - else if (vabits4 == VA_BITS4_UNDEFINED) { return V_BITS16_UNDEFINED; } - else { + if (vabits4 == VA_BITS4_DEFINED) { + return V_BITS16_DEFINED; + } else if (vabits4 == VA_BITS4_UNDEFINED) { + return V_BITS16_UNDEFINED; + } else { /* Slow case: the two bytes are not all-defined or all-undefined. */ PROF_EVENT(MCPE_LOADV16_SLOW2); - return (UWord)mc_LOADVn_slow( a, 16, isBigEndian ); + return (UWord)mc_LOADVn_slow(a, 16, isBigEndian); } } } @@ -5295,112 +5344,116 @@ UWord mc_LOADV16 ( Addr a, Bool isBigEndian ) } // Generic for all platforms -VG_REGPARM(1) UWord MC_(helperc_LOADV16be) ( Addr a ) +VG_REGPARM(1) UWord MC_(helperc_LOADV16be)(Addr a) { return mc_LOADV16(a, True); } // Non-generic assembly for arm32-linux -#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && defined(VGP_arm_linux) -__asm__( /* Derived from NCode template */ -".text \n" -".align 2 \n" -".global vgMemCheck_helperc_LOADV16le \n" -".type vgMemCheck_helperc_LOADV16le, %function \n" -"vgMemCheck_helperc_LOADV16le: \n" // -" tst r0, #1 \n" // -" bne .LLV16LEc12 \n" // if misaligned -" lsr r2, r0, #16 \n" // r2 = pri-map-ix -" movw r3, #:lower16:primary_map \n" // -" uxth r1, r0 \n" // r1 = sec-map-offB -" movt r3, #:upper16:primary_map \n" // -" ldr r2, [r3, r2, lsl #2] \n" // r2 = sec-map -" ldrb r1, [r2, r1, lsr #2] \n" // r1 = sec-map-VABITS8 -" cmp r1, #0xAA \n" // r1 == VA_BITS8_DEFINED? -" bne .LLV16LEc0 \n" // no, goto .LLV16LEc0 -".LLV16LEh9: \n" // -" mov r0, #0xFFFFFFFF \n" // -" lsl r0, r0, #16 \n" // V_BITS16_DEFINED | top16safe -" bx lr \n" // -".LLV16LEc0: \n" // -" cmp r1, #0x55 \n" // VA_BITS8_UNDEFINED -" bne .LLV16LEc4 \n" // -".LLV16LEc2: \n" // -" mov r0, #0xFFFFFFFF \n" // V_BITS16_UNDEFINED | top16safe -" bx lr \n" // -".LLV16LEc4: \n" // - // r1 holds sec-map-VABITS8. r0 holds the address and is 2-aligned. - // Extract the relevant 4 bits and inspect. -" and r2, r0, #2 \n" // addr & 2 -" add r2, r2, r2 \n" // 2 * (addr & 2) -" lsr r1, r1, r2 \n" // sec-map-VABITS8 >> (2 * (addr & 2)) -" and r1, r1, #15 \n" // (sec-map-VABITS8 >> (2 * (addr & 2))) & 15 - -" cmp r1, #0xA \n" // VA_BITS4_DEFINED -" beq .LLV16LEh9 \n" // - -" cmp r1, #0x5 \n" // VA_BITS4_UNDEFINED -" beq .LLV16LEc2 \n" // - -".LLV16LEc12: \n" // -" push {r4, lr} \n" // -" mov r2, #0 \n" // -" mov r1, #16 \n" // -" bl mc_LOADVn_slow \n" // -" pop {r4, pc} \n" // -".size vgMemCheck_helperc_LOADV16le, .-vgMemCheck_helperc_LOADV16le \n" -".previous\n" -); - -#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) -__asm__( -".text\n" -".align 16\n" -".global vgMemCheck_helperc_LOADV16le\n" -".type vgMemCheck_helperc_LOADV16le, @function\n" -"vgMemCheck_helperc_LOADV16le:\n" -" test $0x1, %eax\n" -" jne .LLV16LE5\n" /* jump if not aligned */ -" mov %eax, %edx\n" -" shr $0x10, %edx\n" -" mov primary_map(,%edx,4), %ecx\n" -" movzwl %ax, %edx\n" -" shr $0x2, %edx\n" -" movzbl (%ecx,%edx,1), %edx\n"/* edx = VA bits for 32bit */ -" cmp $0xaa, %edx\n" /* compare to VA_BITS8_DEFINED */ -" jne .LLV16LE2\n" /* jump if not all 32bits defined */ -".LLV16LE1:\n" -" mov $0xffff0000,%eax\n" /* V_BITS16_DEFINED | top16safe */ -" ret\n" -".LLV16LE2:\n" -" cmp $0x55, %edx\n" /* compare to VA_BITS8_UNDEFINED */ -" jne .LLV16LE4\n" /* jump if not all 32bits undefined */ -".LLV16LE3:\n" -" or $0xffffffff,%eax\n" /* V_BITS16_UNDEFINED | top16safe */ -" ret\n" -".LLV16LE4:\n" -" mov %eax, %ecx\n" -" and $0x2, %ecx\n" -" add %ecx, %ecx\n" -" sar %cl, %edx\n" -" and $0xf, %edx\n" -" cmp $0xa, %edx\n" -" je .LLV16LE1\n" /* jump if all 16bits are defined */ -" cmp $0x5, %edx\n" -" je .LLV16LE3\n" /* jump if all 16bits are undefined */ -".LLV16LE5:\n" -" xor %ecx, %ecx\n" /* tail call mc_LOADVn_slow(a, 16, 0) */ -" mov $16, %edx\n" -" jmp mc_LOADVn_slow\n" -".size vgMemCheck_helperc_LOADV16le, .-vgMemCheck_helperc_LOADV16le \n" -".previous\n" -); +#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + defined(VGP_arm_linux) +__asm__(/* Derived from NCode template */ + ".text \n" + ".align 2 \n" + ".global vgMemCheck_helperc_LOADV16le \n" + ".type vgMemCheck_helperc_LOADV16le, %function \n" + "vgMemCheck_helperc_LOADV16le: \n" // + " tst r0, #1 \n" // + " bne .LLV16LEc12 \n" // if misaligned + " lsr r2, r0, #16 \n" // r2 = pri-map-ix + " movw r3, #:lower16:primary_map \n" // + " uxth r1, r0 \n" // r1 = sec-map-offB + " movt r3, #:upper16:primary_map \n" // + " ldr r2, [r3, r2, lsl #2] \n" // r2 = sec-map + " ldrb r1, [r2, r1, lsr #2] \n" // r1 = sec-map-VABITS8 + " cmp r1, #0xAA \n" // r1 == VA_BITS8_DEFINED? + " bne .LLV16LEc0 \n" // no, goto .LLV16LEc0 + ".LLV16LEh9: \n" // + " mov r0, #0xFFFFFFFF \n" // + " lsl r0, r0, #16 \n" // V_BITS16_DEFINED | + // top16safe + " bx lr \n" // + ".LLV16LEc0: \n" // + " cmp r1, #0x55 \n" // VA_BITS8_UNDEFINED + " bne .LLV16LEc4 \n" // + ".LLV16LEc2: \n" // + " mov r0, #0xFFFFFFFF \n" // V_BITS16_UNDEFINED | + // top16safe + " bx lr \n" // + ".LLV16LEc4: \n" // + // r1 holds sec-map-VABITS8. + // r0 holds the address and + // is 2-aligned. Extract the + // relevant 4 bits and + // inspect. + " and r2, r0, #2 \n" // addr & 2 + " add r2, r2, r2 \n" // 2 * (addr & 2) + " lsr r1, r1, r2 \n" // sec-map-VABITS8 >> (2 * (addr & + // 2)) + " and r1, r1, #15 \n" // (sec-map-VABITS8 >> (2 * (addr & + // 2))) & 15 + + " cmp r1, #0xA \n" // VA_BITS4_DEFINED + " beq .LLV16LEh9 \n" // + + " cmp r1, #0x5 \n" // VA_BITS4_UNDEFINED + " beq .LLV16LEc2 \n" // + + ".LLV16LEc12: \n" // + " push {r4, lr} \n" // + " mov r2, #0 \n" // + " mov r1, #16 \n" // + " bl mc_LOADVn_slow \n" // + " pop {r4, pc} \n" // + ".size vgMemCheck_helperc_LOADV16le, .-vgMemCheck_helperc_LOADV16le \n" + ".previous\n"); + +#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) +__asm__(".text\n" + ".align 16\n" + ".global vgMemCheck_helperc_LOADV16le\n" + ".type vgMemCheck_helperc_LOADV16le, @function\n" + "vgMemCheck_helperc_LOADV16le:\n" + " test $0x1, %eax\n" + " jne .LLV16LE5\n" /* jump if not aligned */ + " mov %eax, %edx\n" + " shr $0x10, %edx\n" + " mov primary_map(,%edx,4), %ecx\n" + " movzwl %ax, %edx\n" + " shr $0x2, %edx\n" + " movzbl (%ecx,%edx,1), %edx\n" /* edx = VA bits for 32bit */ + " cmp $0xaa, %edx\n" /* compare to VA_BITS8_DEFINED */ + " jne .LLV16LE2\n" /* jump if not all 32bits defined */ + ".LLV16LE1:\n" + " mov $0xffff0000,%eax\n" /* V_BITS16_DEFINED | top16safe */ + " ret\n" + ".LLV16LE2:\n" + " cmp $0x55, %edx\n" /* compare to VA_BITS8_UNDEFINED */ + " jne .LLV16LE4\n" /* jump if not all 32bits undefined */ + ".LLV16LE3:\n" + " or $0xffffffff,%eax\n" /* V_BITS16_UNDEFINED | top16safe */ + " ret\n" + ".LLV16LE4:\n" + " mov %eax, %ecx\n" + " and $0x2, %ecx\n" + " add %ecx, %ecx\n" + " sar %cl, %edx\n" + " and $0xf, %edx\n" + " cmp $0xa, %edx\n" + " je .LLV16LE1\n" /* jump if all 16bits are defined */ + " cmp $0x5, %edx\n" + " je .LLV16LE3\n" /* jump if all 16bits are undefined */ + ".LLV16LE5:\n" + " xor %ecx, %ecx\n" /* tail call mc_LOADVn_slow(a, 16, 0) */ + " mov $16, %edx\n" + " jmp mc_LOADVn_slow\n" + ".size vgMemCheck_helperc_LOADV16le, .-vgMemCheck_helperc_LOADV16le \n" + ".previous\n"); #else // Generic for all platforms except {arm32,x86}-linux and x86-solaris -VG_REGPARM(1) UWord MC_(helperc_LOADV16le) ( Addr a ) +VG_REGPARM(1) UWord MC_(helperc_LOADV16le)(Addr a) { return mc_LOADV16(a, False); } @@ -5411,33 +5464,31 @@ VG_REGPARM(1) UWord MC_(helperc_LOADV16le) ( Addr a ) /*------------------------------------------------------------*/ /* True if the vabits4 in vabits8 indicate a and a+1 are accessible. */ -static INLINE -Bool accessible_vabits4_in_vabits8 ( Addr a, UChar vabits8 ) +static INLINE Bool accessible_vabits4_in_vabits8(Addr a, UChar vabits8) { UInt shift; - tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned - shift = (a & 2) << 1; // shift by 0 or 4 - vabits8 >>= shift; // shift the four bits to the bottom - // check 2 x vabits2 != VA_BITS2_NOACCESS - return ((0x3 & vabits8) != VA_BITS2_NOACCESS) - && ((0xc & vabits8) != VA_BITS2_NOACCESS << 2); + tl_assert(VG_IS_2_ALIGNED(a)); // Must be 2-aligned + shift = (a & 2) << 1; // shift by 0 or 4 + vabits8 >>= shift; // shift the four bits to the bottom + // check 2 x vabits2 != VA_BITS2_NOACCESS + return ((0x3 & vabits8) != VA_BITS2_NOACCESS) && + ((0xc & vabits8) != VA_BITS2_NOACCESS << 2); } -static INLINE -void mc_STOREV16 ( Addr a, UWord vbits16, Bool isBigEndian ) +static INLINE void mc_STOREV16(Addr a, UWord vbits16, Bool isBigEndian) { PROF_EVENT(MCPE_STOREV16); #ifndef PERF_FAST_STOREV - mc_STOREVn_slow( a, 16, (ULong)vbits16, isBigEndian ); + mc_STOREVn_slow(a, 16, (ULong)vbits16, isBigEndian); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,16) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 16))) { PROF_EVENT(MCPE_STOREV16_SLOW1); - mc_STOREVn_slow( a, 16, (ULong)vbits16, isBigEndian ); + mc_STOREVn_slow(a, 16, (ULong)vbits16, isBigEndian); return; } @@ -5451,42 +5502,41 @@ void mc_STOREV16 ( Addr a, UWord vbits16, Bool isBigEndian ) if (LIKELY(vabits8 == VA_BITS8_DEFINED)) { return; } - if (!is_distinguished_sm(sm) - && accessible_vabits4_in_vabits8(a, vabits8)) { - insert_vabits4_into_vabits8( a, VA_BITS4_DEFINED, - &(sm->vabits8[sm_off]) ); + if (!is_distinguished_sm(sm) && + accessible_vabits4_in_vabits8(a, vabits8)) { + insert_vabits4_into_vabits8(a, VA_BITS4_DEFINED, + &(sm->vabits8[sm_off])); return; } PROF_EVENT(MCPE_STOREV16_SLOW2); - mc_STOREVn_slow( a, 16, (ULong)vbits16, isBigEndian ); + mc_STOREVn_slow(a, 16, (ULong)vbits16, isBigEndian); } if (V_BITS16_UNDEFINED == vbits16) { if (vabits8 == VA_BITS8_UNDEFINED) { return; } - if (!is_distinguished_sm(sm) - && accessible_vabits4_in_vabits8(a, vabits8)) { - insert_vabits4_into_vabits8( a, VA_BITS4_UNDEFINED, - &(sm->vabits8[sm_off]) ); + if (!is_distinguished_sm(sm) && + accessible_vabits4_in_vabits8(a, vabits8)) { + insert_vabits4_into_vabits8(a, VA_BITS4_UNDEFINED, + &(sm->vabits8[sm_off])); return; } PROF_EVENT(MCPE_STOREV16_SLOW3); - mc_STOREVn_slow( a, 16, (ULong)vbits16, isBigEndian ); + mc_STOREVn_slow(a, 16, (ULong)vbits16, isBigEndian); return; } PROF_EVENT(MCPE_STOREV16_SLOW4); - mc_STOREVn_slow( a, 16, (ULong)vbits16, isBigEndian ); + mc_STOREVn_slow(a, 16, (ULong)vbits16, isBigEndian); } #endif } - -VG_REGPARM(2) void MC_(helperc_STOREV16be) ( Addr a, UWord vbits16 ) +VG_REGPARM(2) void MC_(helperc_STOREV16be)(Addr a, UWord vbits16) { mc_STOREV16(a, vbits16, True); } -VG_REGPARM(2) void MC_(helperc_STOREV16le) ( Addr a, UWord vbits16 ) +VG_REGPARM(2) void MC_(helperc_STOREV16le)(Addr a, UWord vbits16) { mc_STOREV16(a, vbits16, False); } @@ -5498,114 +5548,117 @@ VG_REGPARM(2) void MC_(helperc_STOREV16le) ( Addr a, UWord vbits16 ) /* Note: endianness is irrelevant for size == 1 */ // Non-generic assembly for arm32-linux -#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && defined(VGP_arm_linux) -__asm__( /* Derived from NCode template */ -".text \n" -".align 2 \n" -".global vgMemCheck_helperc_LOADV8 \n" -".type vgMemCheck_helperc_LOADV8, %function \n" -"vgMemCheck_helperc_LOADV8: \n" // -" lsr r2, r0, #16 \n" // r2 = pri-map-ix -" movw r3, #:lower16:primary_map \n" // -" uxth r1, r0 \n" // r1 = sec-map-offB -" movt r3, #:upper16:primary_map \n" // -" ldr r2, [r3, r2, lsl #2] \n" // r2 = sec-map -" ldrb r1, [r2, r1, lsr #2] \n" // r1 = sec-map-VABITS8 -" cmp r1, #0xAA \n" // r1 == VA_BITS8_DEFINED? -" bne .LLV8c0 \n" // no, goto .LLV8c0 -".LLV8h9: \n" // -" mov r0, #0xFFFFFF00 \n" // V_BITS8_DEFINED | top24safe -" bx lr \n" // -".LLV8c0: \n" // -" cmp r1, #0x55 \n" // VA_BITS8_UNDEFINED -" bne .LLV8c4 \n" // -".LLV8c2: \n" // -" mov r0, #0xFFFFFFFF \n" // V_BITS8_UNDEFINED | top24safe -" bx lr \n" // -".LLV8c4: \n" // - // r1 holds sec-map-VABITS8 - // r0 holds the address. Extract the relevant 2 bits and inspect. -" and r2, r0, #3 \n" // addr & 3 -" add r2, r2, r2 \n" // 2 * (addr & 3) -" lsr r1, r1, r2 \n" // sec-map-VABITS8 >> (2 * (addr & 3)) -" and r1, r1, #3 \n" // (sec-map-VABITS8 >> (2 * (addr & 3))) & 3 - -" cmp r1, #2 \n" // VA_BITS2_DEFINED -" beq .LLV8h9 \n" // - -" cmp r1, #1 \n" // VA_BITS2_UNDEFINED -" beq .LLV8c2 \n" // - -" push {r4, lr} \n" // -" mov r2, #0 \n" // -" mov r1, #8 \n" // -" bl mc_LOADVn_slow \n" // -" pop {r4, pc} \n" // -".size vgMemCheck_helperc_LOADV8, .-vgMemCheck_helperc_LOADV8 \n" -".previous\n" -); +#if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + defined(VGP_arm_linux) +__asm__(/* Derived from NCode template */ + ".text \n" + ".align 2 \n" + ".global vgMemCheck_helperc_LOADV8 \n" + ".type vgMemCheck_helperc_LOADV8, %function \n" + "vgMemCheck_helperc_LOADV8: \n" // + " lsr r2, r0, #16 \n" // r2 = pri-map-ix + " movw r3, #:lower16:primary_map \n" // + " uxth r1, r0 \n" // r1 = sec-map-offB + " movt r3, #:upper16:primary_map \n" // + " ldr r2, [r3, r2, lsl #2] \n" // r2 = sec-map + " ldrb r1, [r2, r1, lsr #2] \n" // r1 = sec-map-VABITS8 + " cmp r1, #0xAA \n" // r1 == VA_BITS8_DEFINED? + " bne .LLV8c0 \n" // no, goto .LLV8c0 + ".LLV8h9: \n" // + " mov r0, #0xFFFFFF00 \n" // V_BITS8_DEFINED | + // top24safe + " bx lr \n" // + ".LLV8c0: \n" // + " cmp r1, #0x55 \n" // VA_BITS8_UNDEFINED + " bne .LLV8c4 \n" // + ".LLV8c2: \n" // + " mov r0, #0xFFFFFFFF \n" // V_BITS8_UNDEFINED | + // top24safe + " bx lr \n" // + ".LLV8c4: \n" // + // r1 holds sec-map-VABITS8 + // r0 holds the address. + // Extract the relevant 2 + // bits and inspect. + " and r2, r0, #3 \n" // addr & 3 + " add r2, r2, r2 \n" // 2 * (addr & 3) + " lsr r1, r1, r2 \n" // sec-map-VABITS8 >> (2 * (addr & + // 3)) + " and r1, r1, #3 \n" // (sec-map-VABITS8 >> (2 * (addr & + // 3))) & 3 + + " cmp r1, #2 \n" // VA_BITS2_DEFINED + " beq .LLV8h9 \n" // + + " cmp r1, #1 \n" // VA_BITS2_UNDEFINED + " beq .LLV8c2 \n" // + + " push {r4, lr} \n" // + " mov r2, #0 \n" // + " mov r1, #8 \n" // + " bl mc_LOADVn_slow \n" // + " pop {r4, pc} \n" // + ".size vgMemCheck_helperc_LOADV8, .-vgMemCheck_helperc_LOADV8 \n" + ".previous\n"); /* Non-generic assembly for x86-linux */ -#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) -__asm__( -".text\n" -".align 16\n" -".global vgMemCheck_helperc_LOADV8\n" -".type vgMemCheck_helperc_LOADV8, @function\n" -"vgMemCheck_helperc_LOADV8:\n" -" mov %eax, %edx\n" -" shr $0x10, %edx\n" -" mov primary_map(,%edx,4), %ecx\n" -" movzwl %ax, %edx\n" -" shr $0x2, %edx\n" -" movzbl (%ecx,%edx,1), %edx\n"/* edx = VA bits for 32bit */ -" cmp $0xaa, %edx\n" /* compare to VA_BITS8_DEFINED? */ -" jne .LLV8LE2\n" /* jump if not defined */ -".LLV8LE1:\n" -" mov $0xffffff00, %eax\n" /* V_BITS8_DEFINED | top24safe */ -" ret\n" -".LLV8LE2:\n" -" cmp $0x55, %edx\n" /* compare to VA_BITS8_UNDEFINED */ -" jne .LLV8LE4\n" /* jump if not all 32bits are undefined */ -".LLV8LE3:\n" -" or $0xffffffff, %eax\n" /* V_BITS8_UNDEFINED | top24safe */ -" ret\n" -".LLV8LE4:\n" -" mov %eax, %ecx\n" -" and $0x3, %ecx\n" -" add %ecx, %ecx\n" -" sar %cl, %edx\n" -" and $0x3, %edx\n" -" cmp $0x2, %edx\n" -" je .LLV8LE1\n" /* jump if all 8bits are defined */ -" cmp $0x1, %edx\n" -" je .LLV8LE3\n" /* jump if all 8bits are undefined */ -" xor %ecx, %ecx\n" /* tail call to mc_LOADVn_slow(a, 8, 0) */ -" mov $0x8, %edx\n" -" jmp mc_LOADVn_slow\n" -".size vgMemCheck_helperc_LOADV8, .-vgMemCheck_helperc_LOADV8\n" -".previous\n" -); +#elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) && \ + (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) +__asm__(".text\n" + ".align 16\n" + ".global vgMemCheck_helperc_LOADV8\n" + ".type vgMemCheck_helperc_LOADV8, @function\n" + "vgMemCheck_helperc_LOADV8:\n" + " mov %eax, %edx\n" + " shr $0x10, %edx\n" + " mov primary_map(,%edx,4), %ecx\n" + " movzwl %ax, %edx\n" + " shr $0x2, %edx\n" + " movzbl (%ecx,%edx,1), %edx\n" /* edx = VA bits for 32bit */ + " cmp $0xaa, %edx\n" /* compare to VA_BITS8_DEFINED? */ + " jne .LLV8LE2\n" /* jump if not defined */ + ".LLV8LE1:\n" + " mov $0xffffff00, %eax\n" /* V_BITS8_DEFINED | top24safe */ + " ret\n" + ".LLV8LE2:\n" + " cmp $0x55, %edx\n" /* compare to VA_BITS8_UNDEFINED */ + " jne .LLV8LE4\n" /* jump if not all 32bits are undefined */ + ".LLV8LE3:\n" + " or $0xffffffff, %eax\n" /* V_BITS8_UNDEFINED | top24safe */ + " ret\n" + ".LLV8LE4:\n" + " mov %eax, %ecx\n" + " and $0x3, %ecx\n" + " add %ecx, %ecx\n" + " sar %cl, %edx\n" + " and $0x3, %edx\n" + " cmp $0x2, %edx\n" + " je .LLV8LE1\n" /* jump if all 8bits are defined */ + " cmp $0x1, %edx\n" + " je .LLV8LE3\n" /* jump if all 8bits are undefined */ + " xor %ecx, %ecx\n" /* tail call to mc_LOADVn_slow(a, 8, 0) */ + " mov $0x8, %edx\n" + " jmp mc_LOADVn_slow\n" + ".size vgMemCheck_helperc_LOADV8, .-vgMemCheck_helperc_LOADV8\n" + ".previous\n"); #else // Generic for all platforms except {arm32,x86}-linux and x86-solaris VG_REGPARM(1) -UWord MC_(helperc_LOADV8) ( Addr a ) +UWord MC_(helperc_LOADV8)(Addr a) { PROF_EVENT(MCPE_LOADV8); #ifndef PERF_FAST_LOADV - return (UWord)mc_LOADVn_slow( a, 8, False/*irrelevant*/ ); + return (UWord)mc_LOADVn_slow(a, 8, False /*irrelevant*/); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,8) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 8))) { PROF_EVENT(MCPE_LOADV8_SLOW1); - return (UWord)mc_LOADVn_slow( a, 8, False/*irrelevant*/ ); + return (UWord)mc_LOADVn_slow(a, 8, False /*irrelevant*/); } sm = get_secmap_for_reading_low(a); @@ -5614,18 +5667,22 @@ UWord MC_(helperc_LOADV8) ( Addr a ) // Convert V bits from compact memory form to expanded register form // Handle common case quickly: a is mapped, and the entire // word32 it lives in is addressible. - if (LIKELY(vabits8 == VA_BITS8_DEFINED )) { return V_BITS8_DEFINED; } - else if (LIKELY(vabits8 == VA_BITS8_UNDEFINED)) { return V_BITS8_UNDEFINED; } - else { + if (LIKELY(vabits8 == VA_BITS8_DEFINED)) { + return V_BITS8_DEFINED; + } else if (LIKELY(vabits8 == VA_BITS8_UNDEFINED)) { + return V_BITS8_UNDEFINED; + } else { // The 4 (yes, 4) bytes are not all-defined or all-undefined, check // the single byte. UChar vabits2 = extract_vabits2_from_vabits8(a, vabits8); - if (vabits2 == VA_BITS2_DEFINED ) { return V_BITS8_DEFINED; } - else if (vabits2 == VA_BITS2_UNDEFINED) { return V_BITS8_UNDEFINED; } - else { + if (vabits2 == VA_BITS2_DEFINED) { + return V_BITS8_DEFINED; + } else if (vabits2 == VA_BITS2_UNDEFINED) { + return V_BITS8_UNDEFINED; + } else { /* Slow case: the byte is not all-defined or all-undefined. */ PROF_EVENT(MCPE_LOADV8_SLOW2); - return (UWord)mc_LOADVn_slow( a, 8, False/*irrelevant*/ ); + return (UWord)mc_LOADVn_slow(a, 8, False /*irrelevant*/); } } } @@ -5638,20 +5695,20 @@ UWord MC_(helperc_LOADV8) ( Addr a ) /*------------------------------------------------------------*/ VG_REGPARM(2) -void MC_(helperc_STOREV8) ( Addr a, UWord vbits8 ) +void MC_(helperc_STOREV8)(Addr a, UWord vbits8) { PROF_EVENT(MCPE_STOREV8); #ifndef PERF_FAST_STOREV - mc_STOREVn_slow( a, 8, (ULong)vbits8, False/*irrelevant*/ ); + mc_STOREVn_slow(a, 8, (ULong)vbits8, False /*irrelevant*/); #else { UWord sm_off, vabits8; SecMap* sm; - if (UNLIKELY( UNALIGNED_OR_HIGH(a,8) )) { + if (UNLIKELY(UNALIGNED_OR_HIGH(a, 8))) { PROF_EVENT(MCPE_STOREV8_SLOW1); - mc_STOREVn_slow( a, 8, (ULong)vbits8, False/*irrelevant*/ ); + mc_STOREVn_slow(a, 8, (ULong)vbits8, False /*irrelevant*/); return; } @@ -5699,42 +5756,40 @@ void MC_(helperc_STOREV8) ( Addr a, UWord vbits8 ) if (LIKELY(vabits8 == VA_BITS8_DEFINED)) { return; // defined on defined } - if (!is_distinguished_sm(sm) - && VA_BITS2_NOACCESS != extract_vabits2_from_vabits8(a, vabits8)) { + if (!is_distinguished_sm(sm) && + VA_BITS2_NOACCESS != extract_vabits2_from_vabits8(a, vabits8)) { // direct mod - insert_vabits2_into_vabits8( a, VA_BITS2_DEFINED, - &(sm->vabits8[sm_off]) ); + insert_vabits2_into_vabits8(a, VA_BITS2_DEFINED, + &(sm->vabits8[sm_off])); return; } PROF_EVENT(MCPE_STOREV8_SLOW2); - mc_STOREVn_slow( a, 8, (ULong)vbits8, False/*irrelevant*/ ); + mc_STOREVn_slow(a, 8, (ULong)vbits8, False /*irrelevant*/); return; } if (V_BITS8_UNDEFINED == vbits8) { if (vabits8 == VA_BITS8_UNDEFINED) { return; // undefined on undefined } - if (!is_distinguished_sm(sm) - && (VA_BITS2_NOACCESS - != extract_vabits2_from_vabits8(a, vabits8))) { + if (!is_distinguished_sm(sm) && + (VA_BITS2_NOACCESS != extract_vabits2_from_vabits8(a, vabits8))) { // direct mod - insert_vabits2_into_vabits8( a, VA_BITS2_UNDEFINED, - &(sm->vabits8[sm_off]) ); + insert_vabits2_into_vabits8(a, VA_BITS2_UNDEFINED, + &(sm->vabits8[sm_off])); return; } PROF_EVENT(MCPE_STOREV8_SLOW3); - mc_STOREVn_slow( a, 8, (ULong)vbits8, False/*irrelevant*/ ); + mc_STOREVn_slow(a, 8, (ULong)vbits8, False /*irrelevant*/); return; } // Partially defined word PROF_EVENT(MCPE_STOREV8_SLOW4); - mc_STOREVn_slow( a, 8, (ULong)vbits8, False/*irrelevant*/ ); + mc_STOREVn_slow(a, 8, (ULong)vbits8, False /*irrelevant*/); } #endif } - /*------------------------------------------------------------*/ /*--- Functions called directly from generated code: ---*/ /*--- Value-check failure handlers. ---*/ @@ -5742,58 +5797,67 @@ void MC_(helperc_STOREV8) ( Addr a, UWord vbits8 ) /* Call these ones when an origin is available ... */ VG_REGPARM(1) -void MC_(helperc_value_check0_fail_w_o) ( UWord origin ) { - MC_(record_cond_error) ( VG_(get_running_tid)(), (UInt)origin ); +void MC_(helperc_value_check0_fail_w_o)(UWord origin) +{ + MC_(record_cond_error)(VG_(get_running_tid)(), (UInt)origin); } VG_REGPARM(1) -void MC_(helperc_value_check1_fail_w_o) ( UWord origin ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 1, (UInt)origin ); +void MC_(helperc_value_check1_fail_w_o)(UWord origin) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 1, (UInt)origin); } VG_REGPARM(1) -void MC_(helperc_value_check4_fail_w_o) ( UWord origin ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 4, (UInt)origin ); +void MC_(helperc_value_check4_fail_w_o)(UWord origin) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 4, (UInt)origin); } VG_REGPARM(1) -void MC_(helperc_value_check8_fail_w_o) ( UWord origin ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 8, (UInt)origin ); +void MC_(helperc_value_check8_fail_w_o)(UWord origin) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 8, (UInt)origin); } VG_REGPARM(2) -void MC_(helperc_value_checkN_fail_w_o) ( HWord sz, UWord origin ) { - MC_(record_value_error) ( VG_(get_running_tid)(), (Int)sz, (UInt)origin ); +void MC_(helperc_value_checkN_fail_w_o)(HWord sz, UWord origin) +{ + MC_(record_value_error)(VG_(get_running_tid)(), (Int)sz, (UInt)origin); } /* ... and these when an origin isn't available. */ VG_REGPARM(0) -void MC_(helperc_value_check0_fail_no_o) ( void ) { - MC_(record_cond_error) ( VG_(get_running_tid)(), 0/*origin*/ ); +void MC_(helperc_value_check0_fail_no_o)(void) +{ + MC_(record_cond_error)(VG_(get_running_tid)(), 0 /*origin*/); } VG_REGPARM(0) -void MC_(helperc_value_check1_fail_no_o) ( void ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 1, 0/*origin*/ ); +void MC_(helperc_value_check1_fail_no_o)(void) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 1, 0 /*origin*/); } VG_REGPARM(0) -void MC_(helperc_value_check4_fail_no_o) ( void ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 4, 0/*origin*/ ); +void MC_(helperc_value_check4_fail_no_o)(void) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 4, 0 /*origin*/); } VG_REGPARM(0) -void MC_(helperc_value_check8_fail_no_o) ( void ) { - MC_(record_value_error) ( VG_(get_running_tid)(), 8, 0/*origin*/ ); +void MC_(helperc_value_check8_fail_no_o)(void) +{ + MC_(record_value_error)(VG_(get_running_tid)(), 8, 0 /*origin*/); } VG_REGPARM(1) -void MC_(helperc_value_checkN_fail_no_o) ( HWord sz ) { - MC_(record_value_error) ( VG_(get_running_tid)(), (Int)sz, 0/*origin*/ ); +void MC_(helperc_value_checkN_fail_no_o)(HWord sz) +{ + MC_(record_value_error)(VG_(get_running_tid)(), (Int)sz, 0 /*origin*/); } - /*------------------------------------------------------------*/ /*--- Metadata get/set functions, for client requests. ---*/ /*------------------------------------------------------------*/ @@ -5807,13 +5871,13 @@ void MC_(helperc_value_checkN_fail_no_o) ( HWord sz ) { /* Nb: We used to issue various definedness/addressability errors from here, but we took them out because they ranged from not-very-helpful to downright annoying, and they complicated the error data structures. */ -static Int mc_get_or_set_vbits_for_client ( - Addr a, - Addr vbits, +static Int mc_get_or_set_vbits_for_client( + Addr a, + Addr vbits, SizeT szB, - Bool setting, /* True <=> set vbits, False <=> get vbits */ - Bool is_client_request /* True <=> real user request - False <=> internal call from gdbserver */ + Bool setting, /* True <=> set vbits, False <=> get vbits */ + Bool is_client_request /* True <=> real user request + False <=> internal call from gdbserver */ ) { SizeT i; @@ -5844,14 +5908,13 @@ static Int mc_get_or_set_vbits_for_client ( ((UChar*)vbits)[i] = vbits8; } if (is_client_request) - // The bytes in vbits[] have now been set, so mark them as such. - MC_(make_mem_defined)(vbits, szB); + // The bytes in vbits[] have now been set, so mark them as such. + MC_(make_mem_defined)(vbits, szB); } return 1; } - /*------------------------------------------------------------*/ /*--- Detecting leaked (unreachable) malloc'd blocks. ---*/ /*------------------------------------------------------------*/ @@ -5860,9 +5923,9 @@ static Int mc_get_or_set_vbits_for_client ( address space is possibly in use, or not. If in doubt return True. */ -Bool MC_(is_within_valid_secondary) ( Addr a ) +Bool MC_(is_within_valid_secondary)(Addr a) { - SecMap* sm = maybe_get_secmap_for ( a ); + SecMap* sm = maybe_get_secmap_for(a); if (sm == NULL || sm == &sm_distinguished[SM_DIST_NOACCESS]) { /* Definitely not in use. */ return False; @@ -5871,17 +5934,16 @@ Bool MC_(is_within_valid_secondary) ( Addr a ) } } - /* For the memory leak detector, say whether or not a given word address is to be regarded as valid. */ -Bool MC_(is_valid_aligned_word) ( Addr a ) +Bool MC_(is_valid_aligned_word)(Addr a) { tl_assert(sizeof(UWord) == 4 || sizeof(UWord) == 8); tl_assert(VG_IS_WORD_ALIGNED(a)); - if (get_vabits8_for_aligned_word32 (a) != VA_BITS8_DEFINED) + if (get_vabits8_for_aligned_word32(a) != VA_BITS8_DEFINED) return False; if (sizeof(UWord) == 8) { - if (get_vabits8_for_aligned_word32 (a + 4) != VA_BITS8_DEFINED) + if (get_vabits8_for_aligned_word32(a + 4) != VA_BITS8_DEFINED) return False; } if (UNLIKELY(MC_(in_ignored_range)(a))) @@ -5890,30 +5952,32 @@ Bool MC_(is_valid_aligned_word) ( Addr a ) return True; } - /*------------------------------------------------------------*/ /*--- Initialisation ---*/ /*------------------------------------------------------------*/ -static void init_shadow_memory ( void ) +static void init_shadow_memory(void) { Int i; SecMap* sm; - tl_assert(V_BIT_UNDEFINED == 1); - tl_assert(V_BIT_DEFINED == 0); + tl_assert(V_BIT_UNDEFINED == 1); + tl_assert(V_BIT_DEFINED == 0); tl_assert(V_BITS8_UNDEFINED == 0xFF); - tl_assert(V_BITS8_DEFINED == 0); + tl_assert(V_BITS8_DEFINED == 0); /* Build the 3 distinguished secondaries */ sm = &sm_distinguished[SM_DIST_NOACCESS]; - for (i = 0; i < SM_CHUNKS; i++) sm->vabits8[i] = VA_BITS8_NOACCESS; + for (i = 0; i < SM_CHUNKS; i++) + sm->vabits8[i] = VA_BITS8_NOACCESS; sm = &sm_distinguished[SM_DIST_UNDEFINED]; - for (i = 0; i < SM_CHUNKS; i++) sm->vabits8[i] = VA_BITS8_UNDEFINED; + for (i = 0; i < SM_CHUNKS; i++) + sm->vabits8[i] = VA_BITS8_UNDEFINED; sm = &sm_distinguished[SM_DIST_DEFINED]; - for (i = 0; i < SM_CHUNKS; i++) sm->vabits8[i] = VA_BITS8_DEFINED; + for (i = 0; i < SM_CHUNKS; i++) + sm->vabits8[i] = VA_BITS8_DEFINED; /* Set up the primary map. */ /* These entries gradually get overwritten as the used address @@ -5931,12 +5995,11 @@ static void init_shadow_memory ( void ) secVBitTable = createSecVBitTable(); } - /*------------------------------------------------------------*/ /*--- Sanity check machinery (permanently engaged) ---*/ /*------------------------------------------------------------*/ -static Bool mc_cheap_sanity_check ( void ) +static Bool mc_cheap_sanity_check(void) { n_sanity_cheap++; PROF_EVENT(MCPE_CHEAP_SANITY_CHECK); @@ -5947,16 +6010,18 @@ static Bool mc_cheap_sanity_check ( void ) return True; } -static Bool mc_expensive_sanity_check ( void ) +static Bool mc_expensive_sanity_check(void) { - Int i; - Word n_secmaps_found; - SecMap* sm; - const HChar* errmsg; - Bool bad = False; + Int i; + Word n_secmaps_found; + SecMap* sm; + const HChar* errmsg; + Bool bad = False; - if (0) VG_(printf)("expensive sanity check\n"); - if (0) return True; + if (0) + VG_(printf)("expensive sanity check\n"); + if (0) + return True; n_sanity_expensive++; PROF_EVENT(MCPE_EXPENSIVE_SANITY_CHECK); @@ -6000,7 +6065,7 @@ static Bool mc_expensive_sanity_check ( void ) /* check the auxiliary maps, very thoroughly */ n_secmaps_found = 0; - errmsg = check_auxmap_L1_L2_sanity( &n_secmaps_found ); + errmsg = check_auxmap_L1_L2_sanity(&n_secmaps_found); if (errmsg) { VG_(printf)("memcheck expensive sanity, auxmaps:\n\t%s", errmsg); return False; @@ -6047,35 +6112,33 @@ static Bool mc_expensive_sanity_check ( void ) /* 31 Aug 2015: Vectorised code is now so widespread that --partial-loads-ok needs to be enabled by default on all platforms. Not doing so causes lots of false errors. */ -Bool MC_(clo_partial_loads_ok) = True; -Long MC_(clo_freelist_vol) = 20*1000*1000LL; -Long MC_(clo_freelist_big_blocks) = 1*1000*1000LL; -LeakCheckMode MC_(clo_leak_check) = LC_Summary; -VgRes MC_(clo_leak_resolution) = Vg_HighRes; -UInt MC_(clo_show_leak_kinds) = R2S(Possible) | R2S(Unreached); -UInt MC_(clo_error_for_leak_kinds) = R2S(Possible) | R2S(Unreached); -UInt MC_(clo_leak_check_heuristics) = H2S(LchStdString) - | H2S( LchLength64) - | H2S( LchNewArray) - | H2S( LchMultipleInheritance); -Bool MC_(clo_xtree_leak) = False; -const HChar* MC_(clo_xtree_leak_file) = "xtleak.kcg.%p"; -Bool MC_(clo_workaround_gcc296_bugs) = False; -Int MC_(clo_malloc_fill) = -1; -Int MC_(clo_free_fill) = -1; -KeepStacktraces MC_(clo_keep_stacktraces) = KS_alloc_and_free; -Int MC_(clo_mc_level) = 2; -Bool MC_(clo_show_mismatched_frees) = True; -Bool MC_(clo_show_realloc_size_zero) = True; - -ExpensiveDefinednessChecks - MC_(clo_expensive_definedness_checks) = EdcAUTO; - -Bool MC_(clo_ignore_range_below_sp) = False; -UInt MC_(clo_ignore_range_below_sp__first_offset) = 0; -UInt MC_(clo_ignore_range_below_sp__last_offset) = 0; - -static const HChar * MC_(parse_leak_heuristics_tokens) = +Bool MC_(clo_partial_loads_ok) = True; +Long MC_(clo_freelist_vol) = 20 * 1000 * 1000LL; +Long MC_(clo_freelist_big_blocks) = 1 * 1000 * 1000LL; +LeakCheckMode MC_(clo_leak_check) = LC_Summary; +VgRes MC_(clo_leak_resolution) = Vg_HighRes; +UInt MC_(clo_show_leak_kinds) = R2S(Possible) | R2S(Unreached); +UInt MC_(clo_error_for_leak_kinds) = R2S(Possible) | R2S(Unreached); +UInt MC_(clo_leak_check_heuristics) = H2S(LchStdString) | H2S(LchLength64) | + H2S(LchNewArray) | + H2S(LchMultipleInheritance); +Bool MC_(clo_xtree_leak) = False; +const HChar* MC_(clo_xtree_leak_file) = "xtleak.kcg.%p"; +Bool MC_(clo_workaround_gcc296_bugs) = False; +Int MC_(clo_malloc_fill) = -1; +Int MC_(clo_free_fill) = -1; +KeepStacktraces MC_(clo_keep_stacktraces) = KS_alloc_and_free; +Int MC_(clo_mc_level) = 2; +Bool MC_(clo_show_mismatched_frees) = True; +Bool MC_(clo_show_realloc_size_zero) = True; + +ExpensiveDefinednessChecks MC_(clo_expensive_definedness_checks) = EdcAUTO; + +Bool MC_(clo_ignore_range_below_sp) = False; +UInt MC_(clo_ignore_range_below_sp__first_offset) = 0; +UInt MC_(clo_ignore_range_below_sp__last_offset) = 0; + +static const HChar* MC_(parse_leak_heuristics_tokens) = "-,stdstring,length64,newarray,multipleinheritance"; /* The first heuristic value (LchNone) has no keyword, as this is a fake heuristic used to collect the blocks found without any @@ -6084,9 +6147,9 @@ static const HChar * MC_(parse_leak_heuristics_tokens) = static Bool mc_process_cmd_line_options(const HChar* arg) { const HChar* tmp_str; - Bool tmp_show; + Bool tmp_show; - tl_assert( MC_(clo_mc_level) >= 1 && MC_(clo_mc_level) <= 3 ); + tl_assert(MC_(clo_mc_level) >= 1 && MC_(clo_mc_level) <= 3); /* Set MC_(clo_mc_level): 1 = A bit tracking only @@ -6097,7 +6160,7 @@ static Bool mc_process_cmd_line_options(const HChar* arg) --track-origins=. Reject the case --undef-value-errors=no --track-origins=yes as meaningless. */ - if VG_BOOL_CLO(arg, "--undef-value-errors", tmp_show) { + if VG_BOOL_CLO (arg, "--undef-value-errors", tmp_show) { if (tmp_show) { if (MC_(clo_mc_level) == 1) MC_(clo_mc_level) = 2; @@ -6108,75 +6171,77 @@ static Bool mc_process_cmd_line_options(const HChar* arg) MC_(clo_mc_level) = 1; } } - } - else if VG_BOOL_CLO(arg, "--track-origins", tmp_show) { - if (tmp_show) { + } else if VG_BOOL_CLO (arg, "--track-origins", tmp_show) { + if (tmp_show) { if (MC_(clo_mc_level) == 1) { goto bad_level; } else { MC_(clo_mc_level) = 3; } } else { - if (MC_(clo_mc_level) == 3) - MC_(clo_mc_level) = 2; + if (MC_(clo_mc_level) == 3) + MC_(clo_mc_level) = 2; } - } - else if VG_BOOL_CLO(arg, "--partial-loads-ok", MC_(clo_partial_loads_ok)) {} - else if VG_USET_CLOM(cloPD, arg, "--errors-for-leak-kinds", - MC_(parse_leak_kinds_tokens), - MC_(clo_error_for_leak_kinds)) {} - else if VG_USET_CLOM(cloPD, arg, "--show-leak-kinds", - MC_(parse_leak_kinds_tokens), - MC_(clo_show_leak_kinds)) {} - else if VG_USET_CLOM(cloPD, arg, "--leak-check-heuristics", - MC_(parse_leak_heuristics_tokens), - MC_(clo_leak_check_heuristics)) {} - else if (VG_BOOL_CLOM(cloPD, arg, "--show-reachable", tmp_show)) { + } else if VG_BOOL_CLO (arg, "--partial-loads-ok", + MC_(clo_partial_loads_ok)) { + } else if VG_USET_CLOM (cloPD, arg, "--errors-for-leak-kinds", + MC_(parse_leak_kinds_tokens), + MC_(clo_error_for_leak_kinds)) { + } else if VG_USET_CLOM (cloPD, arg, "--show-leak-kinds", + MC_(parse_leak_kinds_tokens), + MC_(clo_show_leak_kinds)) { + } else if VG_USET_CLOM (cloPD, arg, "--leak-check-heuristics", + MC_(parse_leak_heuristics_tokens), + MC_(clo_leak_check_heuristics)) { + } else if (VG_BOOL_CLOM(cloPD, arg, "--show-reachable", tmp_show)) { if (tmp_show) { MC_(clo_show_leak_kinds) = MC_(all_Reachedness)(); } else { MC_(clo_show_leak_kinds) &= ~R2S(Reachable); } - } - else if VG_BOOL_CLOM(cloPD, arg, "--show-possibly-lost", tmp_show) { + } else if VG_BOOL_CLOM (cloPD, arg, "--show-possibly-lost", tmp_show) { if (tmp_show) { MC_(clo_show_leak_kinds) |= R2S(Possible); } else { MC_(clo_show_leak_kinds) &= ~R2S(Possible); } + } else if VG_BOOL_CLO (arg, "--workaround-gcc296-bugs", + MC_(clo_workaround_gcc296_bugs)) { + } + + else if VG_BINT_CLOM (cloPD, arg, "--freelist-vol", MC_(clo_freelist_vol), 0, + 10 * 1000 * 1000 * 1000LL) { } - else if VG_BOOL_CLO(arg, "--workaround-gcc296-bugs", - MC_(clo_workaround_gcc296_bugs)) {} - - else if VG_BINT_CLOM(cloPD, arg, "--freelist-vol", MC_(clo_freelist_vol), - 0, 10*1000*1000*1000LL) {} - - else if VG_BINT_CLOM(cloPD, arg, "--freelist-big-blocks", - MC_(clo_freelist_big_blocks), - 0, 10*1000*1000*1000LL) {} - - else if VG_XACT_CLOM(cloPD, arg, "--leak-check=no", - MC_(clo_leak_check), LC_Off) {} - else if VG_XACT_CLOM(cloPD, arg, "--leak-check=summary", - MC_(clo_leak_check), LC_Summary) {} - else if VG_XACT_CLOM(cloPD, arg, "--leak-check=yes", - MC_(clo_leak_check), LC_Full) {} - else if VG_XACT_CLOM(cloPD, arg, "--leak-check=full", - MC_(clo_leak_check), LC_Full) {} - - else if VG_XACT_CLO(arg, "--leak-resolution=low", - MC_(clo_leak_resolution), Vg_LowRes) {} - else if VG_XACT_CLO(arg, "--leak-resolution=med", - MC_(clo_leak_resolution), Vg_MedRes) {} - else if VG_XACT_CLO(arg, "--leak-resolution=high", - MC_(clo_leak_resolution), Vg_HighRes) {} - - else if VG_STR_CLOM(cloPD, arg, "--ignore-ranges", tmp_str) { + + else if VG_BINT_CLOM (cloPD, arg, "--freelist-big-blocks", + MC_(clo_freelist_big_blocks), 0, + 10 * 1000 * 1000 * 1000LL) { + } + + else if VG_XACT_CLOM (cloPD, arg, "--leak-check=no", MC_(clo_leak_check), + LC_Off) { + } else if VG_XACT_CLOM (cloPD, arg, "--leak-check=summary", + MC_(clo_leak_check), LC_Summary) { + } else if VG_XACT_CLOM (cloPD, arg, "--leak-check=yes", MC_(clo_leak_check), + LC_Full) { + } else if VG_XACT_CLOM (cloPD, arg, "--leak-check=full", MC_(clo_leak_check), + LC_Full) { + } + + else if VG_XACT_CLO (arg, "--leak-resolution=low", MC_(clo_leak_resolution), + Vg_LowRes) { + } else if VG_XACT_CLO (arg, "--leak-resolution=med", + MC_(clo_leak_resolution), Vg_MedRes) { + } else if VG_XACT_CLO (arg, "--leak-resolution=high", + MC_(clo_leak_resolution), Vg_HighRes) { + } + + else if VG_STR_CLOM (cloPD, arg, "--ignore-ranges", tmp_str) { Bool ok = parse_ignore_ranges(tmp_str); if (!ok) { VG_(message)(Vg_DebugMsg, - "ERROR: --ignore-ranges: " - "invalid syntax, or end <= start in range\n"); + "ERROR: --ignore-ranges: " + "invalid syntax, or end <= start in range\n"); return False; } if (gIgnoredAddressRanges) { @@ -6185,23 +6250,23 @@ static Bool mc_process_cmd_line_options(const HChar* arg) UWord val = IAR_INVALID; UWord key_min = ~(UWord)0; UWord key_max = (UWord)0; - VG_(indexRangeMap)( &key_min, &key_max, &val, - gIgnoredAddressRanges, i ); + VG_(indexRangeMap)(&key_min, &key_max, &val, gIgnoredAddressRanges, + i); tl_assert(key_min <= key_max); UWord limit = 0x4000000; /* 64M - entirely arbitrary limit */ if (key_max - key_min > limit && val == IAR_CommandLine) { - VG_(message)(Vg_DebugMsg, + VG_(message)( + Vg_DebugMsg, "ERROR: --ignore-ranges: suspiciously large range:\n"); - VG_(message)(Vg_DebugMsg, - " 0x%lx-0x%lx (size %lu)\n", key_min, key_max, - key_max - key_min + 1); + VG_(message)(Vg_DebugMsg, " 0x%lx-0x%lx (size %lu)\n", + key_min, key_max, key_max - key_min + 1); return False; } } } } - else if VG_STR_CLOM(cloPD, arg, "--ignore-range-below-sp", tmp_str) { + else if VG_STR_CLOM (cloPD, arg, "--ignore-range-below-sp", tmp_str) { /* This seems at first a bit weird, but: in order to imply a non-wrapped-around address range, the first offset needs to be larger than the second one. For example @@ -6211,131 +6276,155 @@ static Bool mc_process_cmd_line_options(const HChar* arg) UInt offs1 = 0, offs2 = 0; Bool ok = parse_UInt_pair(&tmp_str, &offs1, &offs2); // Ensure we used all the text after the '=' sign. - if (ok && *tmp_str != 0) ok = False; + if (ok && *tmp_str != 0) + ok = False; if (!ok) { VG_(message)(Vg_DebugMsg, "ERROR: --ignore-range-below-sp: invalid syntax. " " Expected \"...=decimalnumber-decimalnumber\".\n"); return False; } - if (offs1 > 1000*1000 /*arbitrary*/ || offs2 > 1000*1000 /*ditto*/) { + if (offs1 > 1000 * 1000 /*arbitrary*/ || offs2 > 1000 * 1000 /*ditto*/) { VG_(message)(Vg_DebugMsg, "ERROR: --ignore-range-below-sp: suspiciously large " - "offset(s): %u and %u\n", offs1, offs2); + "offset(s): %u and %u\n", + offs1, offs2); return False; } if (offs1 <= offs2) { VG_(message)(Vg_DebugMsg, "ERROR: --ignore-range-below-sp: invalid offsets " - "(the first must be larger): %u and %u\n", offs1, offs2); + "(the first must be larger): %u and %u\n", + offs1, offs2); return False; } tl_assert(offs1 > offs2); if (offs1 - offs2 > 4096 /*arbitrary*/) { VG_(message)(Vg_DebugMsg, "ERROR: --ignore-range-below-sp: suspiciously large " - "range: %u-%u (size %u)\n", offs1, offs2, offs1 - offs2); + "range: %u-%u (size %u)\n", + offs1, offs2, offs1 - offs2); return False; } - MC_(clo_ignore_range_below_sp) = True; + MC_(clo_ignore_range_below_sp) = True; MC_(clo_ignore_range_below_sp__first_offset) = offs1; MC_(clo_ignore_range_below_sp__last_offset) = offs2; return True; } - else if VG_BHEX_CLO(arg, "--malloc-fill", MC_(clo_malloc_fill), 0x00,0xFF) {} - else if VG_BHEX_CLO(arg, "--free-fill", MC_(clo_free_fill), 0x00,0xFF) {} - - else if VG_XACT_CLO(arg, "--keep-stacktraces=alloc", - MC_(clo_keep_stacktraces), KS_alloc) {} - else if VG_XACT_CLO(arg, "--keep-stacktraces=free", - MC_(clo_keep_stacktraces), KS_free) {} - else if VG_XACT_CLO(arg, "--keep-stacktraces=alloc-and-free", - MC_(clo_keep_stacktraces), KS_alloc_and_free) {} - else if VG_XACT_CLO(arg, "--keep-stacktraces=alloc-then-free", - MC_(clo_keep_stacktraces), KS_alloc_then_free) {} - else if VG_XACT_CLO(arg, "--keep-stacktraces=none", - MC_(clo_keep_stacktraces), KS_none) {} - - else if VG_BOOL_CLOM(cloPD, arg, "--show-mismatched-frees", - MC_(clo_show_mismatched_frees)) {} - else if VG_BOOL_CLOM(cloPD, arg, "--show-realloc-size-zero", - MC_(clo_show_realloc_size_zero)) {} - - else if VG_XACT_CLO(arg, "--expensive-definedness-checks=no", - MC_(clo_expensive_definedness_checks), EdcNO) {} - else if VG_XACT_CLO(arg, "--expensive-definedness-checks=auto", - MC_(clo_expensive_definedness_checks), EdcAUTO) {} - else if VG_XACT_CLO(arg, "--expensive-definedness-checks=yes", - MC_(clo_expensive_definedness_checks), EdcYES) {} - - else if VG_BOOL_CLO(arg, "--xtree-leak", - MC_(clo_xtree_leak)) {} - else if VG_STR_CLO (arg, "--xtree-leak-file", - MC_(clo_xtree_leak_file)) {} + else if VG_BHEX_CLO (arg, "--malloc-fill", MC_(clo_malloc_fill), 0x00, + 0xFF) { + } else if VG_BHEX_CLO (arg, "--free-fill", MC_(clo_free_fill), 0x00, 0xFF) { + } + + else if VG_XACT_CLO (arg, "--keep-stacktraces=alloc", + MC_(clo_keep_stacktraces), KS_alloc) { + } else if VG_XACT_CLO (arg, "--keep-stacktraces=free", + MC_(clo_keep_stacktraces), KS_free) { + } else if VG_XACT_CLO (arg, "--keep-stacktraces=alloc-and-free", + MC_(clo_keep_stacktraces), KS_alloc_and_free) { + } else if VG_XACT_CLO (arg, "--keep-stacktraces=alloc-then-free", + MC_(clo_keep_stacktraces), KS_alloc_then_free) { + } else if VG_XACT_CLO (arg, "--keep-stacktraces=none", + MC_(clo_keep_stacktraces), KS_none) { + } + + else if VG_BOOL_CLOM (cloPD, arg, "--show-mismatched-frees", + MC_(clo_show_mismatched_frees)) { + } else if VG_BOOL_CLOM (cloPD, arg, "--show-realloc-size-zero", + MC_(clo_show_realloc_size_zero)) { + } + + else if VG_XACT_CLO (arg, "--expensive-definedness-checks=no", + MC_(clo_expensive_definedness_checks), EdcNO) { + } else if VG_XACT_CLO (arg, "--expensive-definedness-checks=auto", + MC_(clo_expensive_definedness_checks), EdcAUTO) { + } else if VG_XACT_CLO (arg, "--expensive-definedness-checks=yes", + MC_(clo_expensive_definedness_checks), EdcYES) { + } + + else if VG_BOOL_CLO (arg, "--xtree-leak", MC_(clo_xtree_leak)) { + } else if VG_STR_CLO (arg, "--xtree-leak-file", MC_(clo_xtree_leak_file)) { + } else return VG_(replacement_malloc_process_cmd_line_option)(arg); return True; - - bad_level: - VG_(fmsg_bad_option)(arg, - "--track-origins=yes has no effect when --undef-value-errors=no.\n"); +bad_level: + VG_(fmsg_bad_option)( + arg, "--track-origins=yes has no effect when --undef-value-errors=no.\n"); return False; } static void mc_print_usage(void) { VG_(printf)( -" --leak-check=no|summary|full search for memory leaks at exit? [summary]\n" -" --leak-resolution=low|med|high differentiation of leak stack traces [high]\n" -" --show-leak-kinds=kind1,kind2,.. which leak kinds to show?\n" -" [definite,possible]\n" -" --errors-for-leak-kinds=kind1,kind2,.. which leak kinds are errors?\n" -" [definite,possible]\n" -" where kind is one of:\n" -" definite indirect possible reachable all none\n" -" --leak-check-heuristics=heur1,heur2,... which heuristics to use for\n" -" improving leak search false positive [all]\n" -" where heur is one of:\n" -" stdstring length64 newarray multipleinheritance all none\n" -" --show-reachable=yes same as --show-leak-kinds=all\n" -" --show-reachable=no --show-possibly-lost=yes\n" -" same as --show-leak-kinds=definite,possible\n" -" --show-reachable=no --show-possibly-lost=no\n" -" same as --show-leak-kinds=definite\n" -" --xtree-leak=no|yes output leak result in xtree format? [no]\n" -" --xtree-leak-file= xtree leak report file [xtleak.kcg.%%p]\n" -" --undef-value-errors=no|yes check for undefined value errors [yes]\n" -" --track-origins=no|yes show origins of undefined values? [no]\n" -" --partial-loads-ok=no|yes too hard to explain here; see manual [yes]\n" -" --expensive-definedness-checks=no|auto|yes\n" -" Use extra-precise definedness tracking [auto]\n" -" --freelist-vol= volume of freed blocks queue [20000000]\n" -" --freelist-big-blocks= releases first blocks with size>= [1000000]\n" -" --workaround-gcc296-bugs=no|yes self explanatory [no]. Deprecated.\n" -" Use --ignore-range-below-sp instead.\n" -" --ignore-ranges=0xPP-0xQQ[,0xRR-0xSS] assume given addresses are OK\n" -" --ignore-range-below-sp=- do not report errors for\n" -" accesses at the given offsets below SP\n" -" --malloc-fill= fill malloc'd areas with given value\n" -" --free-fill= fill free'd areas with given value\n" -" --keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none\n" -" stack trace(s) to keep for malloc'd/free'd areas [alloc-and-free]\n" -" --show-mismatched-frees=no|yes show frees that don't match the allocator? [yes]\n" -" --show-realloc-size-zero=no|yes show realocs with a size of zero? [yes]\n" - ); -} - -static void mc_print_debug_usage(void) -{ - VG_(printf)( -" (none)\n" - ); -} - + " --leak-check=no|summary|full search for memory leaks at exit? " + "[summary]\n" + " --leak-resolution=low|med|high differentiation of leak stack " + "traces [high]\n" + " --show-leak-kinds=kind1,kind2,.. which leak kinds to show?\n" + " [definite,possible]\n" + " --errors-for-leak-kinds=kind1,kind2,.. which leak kinds are " + "errors?\n" + " [definite,possible]\n" + " where kind is one of:\n" + " definite indirect possible reachable all none\n" + " --leak-check-heuristics=heur1,heur2,... which heuristics to use " + "for\n" + " improving leak search false positive [all]\n" + " where heur is one of:\n" + " stdstring length64 newarray multipleinheritance all none\n" + " --show-reachable=yes same as --show-leak-kinds=all\n" + " --show-reachable=no --show-possibly-lost=yes\n" + " same as " + "--show-leak-kinds=definite,possible\n" + " --show-reachable=no --show-possibly-lost=no\n" + " same as " + "--show-leak-kinds=definite\n" + " --xtree-leak=no|yes output leak result in xtree " + "format? [no]\n" + " --xtree-leak-file= xtree leak report file " + "[xtleak.kcg.%%p]\n" + " --undef-value-errors=no|yes check for undefined value errors " + "[yes]\n" + " --track-origins=no|yes show origins of undefined values? " + "[no]\n" + " --partial-loads-ok=no|yes too hard to explain here; see " + "manual [yes]\n" + " --expensive-definedness-checks=no|auto|yes\n" + " Use extra-precise definedness " + "tracking [auto]\n" + " --freelist-vol= volume of freed blocks queue " + "[20000000]\n" + " --freelist-big-blocks= releases first blocks with size>= " + "[1000000]\n" + " --workaround-gcc296-bugs=no|yes self explanatory [no]. " + "Deprecated.\n" + " Use --ignore-range-below-sp " + "instead.\n" + " --ignore-ranges=0xPP-0xQQ[,0xRR-0xSS] assume given addresses are " + "OK\n" + " --ignore-range-below-sp=- do not report errors " + "for\n" + " accesses at the given offsets " + "below SP\n" + " --malloc-fill= fill malloc'd areas with given " + "value\n" + " --free-fill= fill free'd areas with given " + "value\n" + " --keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none\n" + " stack trace(s) to keep for malloc'd/free'd areas " + "[alloc-and-free]\n" + " --show-mismatched-frees=no|yes show frees that don't match the " + "allocator? [yes]\n" + " --show-realloc-size-zero=no|yes show realocs with a size of zero? " + "[yes]\n"); +} + +static void mc_print_debug_usage(void) { VG_(printf)(" (none)\n"); } /*------------------------------------------------------------*/ /*--- Client blocks ---*/ @@ -6361,23 +6450,20 @@ static UWord cgb_used = 0; static CGenBlock* cgbs = NULL; /* Stats for this subsystem. */ -static ULong cgb_used_MAX = 0; /* Max in use. */ -static ULong cgb_allocs = 0; /* Number of allocs. */ -static ULong cgb_discards = 0; /* Number of discards. */ -static ULong cgb_search = 0; /* Number of searches. */ - +static ULong cgb_used_MAX = 0; /* Max in use. */ +static ULong cgb_allocs = 0; /* Number of allocs. */ +static ULong cgb_discards = 0; /* Number of discards. */ +static ULong cgb_search = 0; /* Number of searches. */ /* Get access to the client block array. */ -void MC_(get_ClientBlock_array)( /*OUT*/CGenBlock** blocks, - /*OUT*/UWord* nBlocks ) +void MC_(get_ClientBlock_array)(/*OUT*/ CGenBlock** blocks, + /*OUT*/ UWord* nBlocks) { *blocks = cgbs; *nBlocks = cgb_used; } - -static -Int alloc_client_block ( void ) +static Int alloc_client_block(void) { UWord i, sz_new; CGenBlock* cgbs_new; @@ -6393,91 +6479,95 @@ Int alloc_client_block ( void ) /* Not found. Try to allocate one at the end. */ if (cgb_used < cgb_size) { cgb_used++; - return cgb_used-1; + return cgb_used - 1; } /* Ok, we have to allocate a new one. */ tl_assert(cgb_used == cgb_size); sz_new = (cgbs == NULL) ? 10 : (2 * cgb_size); - cgbs_new = VG_(malloc)( "mc.acb.1", sz_new * sizeof(CGenBlock) ); + cgbs_new = VG_(malloc)("mc.acb.1", sz_new * sizeof(CGenBlock)); for (i = 0; i < cgb_used; i++) cgbs_new[i] = cgbs[i]; if (cgbs != NULL) - VG_(free)( cgbs ); + VG_(free)(cgbs); cgbs = cgbs_new; cgb_size = sz_new; cgb_used++; if (cgb_used > cgb_used_MAX) cgb_used_MAX = cgb_used; - return cgb_used-1; + return cgb_used - 1; } - -static void show_client_block_stats ( void ) +static void show_client_block_stats(void) { - VG_(message)(Vg_DebugMsg, + VG_(message)( + Vg_DebugMsg, "general CBs: %llu allocs, %llu discards, %llu maxinuse, %llu search\n", - cgb_allocs, cgb_discards, cgb_used_MAX, cgb_search - ); + cgb_allocs, cgb_discards, cgb_used_MAX, cgb_search); } -static void print_monitor_help ( void ) +static void print_monitor_help(void) { VG_(gdb_printf) - ( -"\n" -"memcheck monitor commands:\n" -" xb []\n" -" prints validity bits for (or 1) bytes at \n" -" bit values 0 = valid, 1 = invalid, __ = unaddressable byte\n" -" Then prints the bytes values below the corresponding validity bits\n" -" in a layout similar to the gdb command 'x /xb '\n" -" Example: xb 0x8049c78 10\n" -" get_vbits []\n" -" Similar to xb, but only prints the validity bytes by group of 4.\n" -" make_memory [noaccess|undefined\n" -" |defined|Definedifaddressable] []\n" -" mark (or 1) bytes at with the given accessibility\n" -" check_memory [addressable|defined] []\n" -" check that (or 1) bytes at have the given accessibility\n" -" and outputs a description of \n" -" leak_check [full*|summary|xtleak]\n" -" [kinds kind1,kind2,...|reachable|possibleleak*|definiteleak]\n" -" [heuristics heur1,heur2,...]\n" -" [new|increased*|changed|any]\n" -" [unlimited*|limited ]\n" -" * = defaults\n" -" xtleak produces an xtree full leak result in xtleak.kcg.%%p.%%n\n" -" where kind is one of:\n" -" definite indirect possible reachable all none\n" -" where heur is one of:\n" -" stdstring length64 newarray multipleinheritance all none*\n" -" Examples: leak_check\n" -" leak_check summary any\n" -" leak_check full kinds indirect,possible\n" -" leak_check full reachable any limited 100\n" -" block_list |..\n" -" [unlimited*|limited ]\n" -" [heuristics heur1,heur2,...]\n" -" after a leak search, shows the list of blocks of \n" -" (or of the range ..).\n" -" With heuristics, only shows the blocks found via heur1,heur2,...\n" -" * = defaults\n" -" who_points_at []\n" -" shows places pointing inside (default 1) bytes at \n" -" (with len 1, only shows \"start pointers\" pointing exactly to ,\n" -" with len > 1, will also show \"interior pointers\")\n" -" xtmemory []\n" -" dump xtree memory profile in (default xtmemory.kcg.%%p.%%n)\n" -"\n"); + ("\n" + "memcheck monitor commands:\n" + " xb []\n" + " prints validity bits for (or 1) bytes at \n" + " bit values 0 = valid, 1 = invalid, __ = unaddressable byte\n" + " Then prints the bytes values below the corresponding validity " + "bits\n" + " in a layout similar to the gdb command 'x /xb '\n" + " Example: xb 0x8049c78 10\n" + " get_vbits []\n" + " Similar to xb, but only prints the validity bytes by group of 4.\n" + " make_memory [noaccess|undefined\n" + " |defined|Definedifaddressable] []\n" + " mark (or 1) bytes at with the given accessibility\n" + " check_memory [addressable|defined] []\n" + " check that (or 1) bytes at have the given " + "accessibility\n" + " and outputs a description of \n" + " leak_check [full*|summary|xtleak]\n" + " [kinds " + "kind1,kind2,...|reachable|possibleleak*|definiteleak]\n" + " [heuristics heur1,heur2,...]\n" + " [new|increased*|changed|any]\n" + " [unlimited*|limited ]\n" + " * = defaults\n" + " xtleak produces an xtree full leak result in xtleak.kcg.%%p.%%n\n" + " where kind is one of:\n" + " definite indirect possible reachable all none\n" + " where heur is one of:\n" + " stdstring length64 newarray multipleinheritance all none*\n" + " Examples: leak_check\n" + " leak_check summary any\n" + " leak_check full kinds indirect,possible\n" + " leak_check full reachable any limited 100\n" + " block_list |..\n" + " [unlimited*|limited ]\n" + " [heuristics heur1,heur2,...]\n" + " after a leak search, shows the list of blocks of " + "\n" + " (or of the range ..).\n" + " With heuristics, only shows the blocks found via heur1,heur2,...\n" + " * = defaults\n" + " who_points_at []\n" + " shows places pointing inside (default 1) bytes at \n" + " (with len 1, only shows \"start pointers\" pointing exactly to " + ",\n" + " with len > 1, will also show \"interior pointers\")\n" + " xtmemory []\n" + " dump xtree memory profile in (default " + "xtmemory.kcg.%%p.%%n)\n" + "\n"); } /* Print szB bytes at address, with a format similar to the gdb command x /xb address. res[i] == 1 indicates the corresponding byte is addressable. */ -static void gdb_xb (Addr address, SizeT szB, Int res[]) +static void gdb_xb(Addr address, SizeT szB, Int res[]) { UInt i; @@ -6485,21 +6575,20 @@ static void gdb_xb (Addr address, SizeT szB, Int res[]) UInt bnr = i % 8; if (bnr == 0) { if (i != 0) - VG_(printf) ("\n"); // Terminate previous line - VG_(printf) ("%p:", (void*)(address+i)); + VG_(printf)("\n"); // Terminate previous line + VG_(printf)("%p:", (void*)(address + i)); } if (res[i] == 1) - VG_(printf) ("\t0x%02x", *(UChar*)(address+i)); + VG_(printf)("\t0x%02x", *(UChar*)(address + i)); else - VG_(printf) ("\t0x??"); + VG_(printf)("\t0x??"); } - VG_(printf) ("\n"); // Terminate previous line + VG_(printf)("\n"); // Terminate previous line } - /* Returns the address of the next non space character, or address of the string terminator. */ -static HChar* next_non_space (HChar *s) +static HChar* next_non_space(HChar* s) { while (*s && *s == ' ') s++; @@ -6511,22 +6600,21 @@ static HChar* next_non_space (HChar *s) [.. ] (spaces are allowed before and/or after ..). Return True if range correctly parsed, False otherwise. */ -static Bool VG_(parse_slice) (HChar* s, HChar** saveptr, - UInt *from, UInt *to) +static Bool VG_(parse_slice)(HChar* s, HChar** saveptr, UInt* from, UInt* to) { HChar* wl; - HChar *endptr; - endptr = NULL;//// - wl = VG_(strtok_r) (s, " ", saveptr); + HChar* endptr; + endptr = NULL; //// + wl = VG_(strtok_r)(s, " ", saveptr); /* slice must start with an integer. */ if (wl == NULL) { - VG_(gdb_printf) ("expecting integer or slice ..\n"); + VG_(gdb_printf)("expecting integer or slice ..\n"); return False; } - *from = VG_(strtoull10) (wl, &endptr); + *from = VG_(strtoull10)(wl, &endptr); if (endptr == wl) { - VG_(gdb_printf) ("invalid integer or slice ..\n"); + VG_(gdb_printf)("invalid integer or slice ..\n"); return False; } @@ -6540,31 +6628,31 @@ static Bool VG_(parse_slice) (HChar* s, HChar** saveptr, if (*endptr == '\0') { // iii .. => get the next token - wl = VG_(strtok_r) (NULL, " .", saveptr); + wl = VG_(strtok_r)(NULL, " .", saveptr); } else { // It must be iii.. - if (*endptr != '.' && *(endptr+1) != '.') { - VG_(gdb_printf) ("expecting slice ..\n"); + if (*endptr != '.' && *(endptr + 1) != '.') { + VG_(gdb_printf)("expecting slice ..\n"); return False; } - if ( *(endptr+2) == ' ') { + if (*(endptr + 2) == ' ') { // It must be iii.. jjj => get the next token - wl = VG_(strtok_r) (NULL, " .", saveptr); + wl = VG_(strtok_r)(NULL, " .", saveptr); } else { // It must be iii..jjj - wl = endptr+2; + wl = endptr + 2; } } - *to = VG_(strtoull10) (wl, &endptr); + *to = VG_(strtoull10)(wl, &endptr); if (*endptr != '\0') { - VG_(gdb_printf) ("missing/wrong 'to' of slice ..\n"); + VG_(gdb_printf)("missing/wrong 'to' of slice ..\n"); return False; } if (*from > *to) { - VG_(gdb_printf) (" cannot be bigger than " - "in slice ..\n"); + VG_(gdb_printf)(" cannot be bigger than " + "in slice ..\n"); return False; } @@ -6572,170 +6660,175 @@ static Bool VG_(parse_slice) (HChar* s, HChar** saveptr, } /* return True if request recognised, False otherwise */ -static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req) +static Bool handle_gdb_monitor_command(ThreadId tid, HChar* req) { HChar* wcmd; - HChar s[VG_(strlen)(req) + 1]; /* copy for strtok_r */ - HChar *ssaveptr; + HChar s[VG_(strlen)(req) + 1]; /* copy for strtok_r */ + HChar* ssaveptr; - VG_(strcpy) (s, req); + VG_(strcpy)(s, req); - wcmd = VG_(strtok_r) (s, " ", &ssaveptr); + wcmd = VG_(strtok_r)(s, " ", &ssaveptr); /* NB: if possible, avoid introducing a new command below which starts with the same first letter(s) as an already existing command. This ensures a shorter abbreviation for the user. */ - switch (VG_(keyword_id) - ("help get_vbits leak_check make_memory check_memory " - "block_list who_points_at xb xtmemory", - wcmd, kwd_report_duplicated_matches)) { + switch (VG_(keyword_id)("help get_vbits leak_check make_memory check_memory " + "block_list who_points_at xb xtmemory", + wcmd, kwd_report_duplicated_matches)) { case -2: /* multiple matches */ return True; case -1: /* not found */ return False; - case 0: /* help */ + case 0: /* help */ print_monitor_help(); return True; - case 1: { /* get_vbits */ - Addr address; + case 1: { /* get_vbits */ + Addr address; SizeT szB = 1; - if (VG_(strtok_get_address_and_size) (&address, &szB, &ssaveptr)) { + if (VG_(strtok_get_address_and_size)(&address, &szB, &ssaveptr)) { UChar vbits; - Int i; - Int unaddressable = 0; + Int i; + Int unaddressable = 0; for (i = 0; i < szB; i++) { - Int res = mc_get_or_set_vbits_for_client - (address+i, (Addr) &vbits, 1, - False, /* get them */ - False /* is client request */ ); + Int res = mc_get_or_set_vbits_for_client( + address + i, (Addr)&vbits, 1, False, /* get them */ + False /* is client request */); /* we are before the first character on next line, print a \n. */ if ((i % 32) == 0 && i != 0) - VG_(printf) ("\n"); + VG_(printf)("\n"); /* we are before the next block of 4 starts, print a space. */ else if ((i % 4) == 0 && i != 0) - VG_(printf) (" "); + VG_(printf)(" "); if (res == 1) { - VG_(printf) ("%02x", vbits); + VG_(printf)("%02x", vbits); } else { tl_assert(3 == res); unaddressable++; - VG_(printf) ("__"); + VG_(printf)("__"); } } - VG_(printf) ("\n"); + VG_(printf)("\n"); if (unaddressable) { VG_(printf) - ("Address %p len %lu has %d bytes unaddressable\n", - (void *)address, szB, unaddressable); + ("Address %p len %lu has %d bytes unaddressable\n", (void*)address, + szB, unaddressable); } } return True; } - case 2: { /* leak_check */ - Int err = 0; + case 2: { /* leak_check */ + Int err = 0; LeakCheckParams lcp; - HChar* xt_filename = NULL; - HChar* kw; - - lcp.mode = LC_Full; - lcp.show_leak_kinds = R2S(Possible) | R2S(Unreached); - lcp.errors_for_leak_kinds = 0; // no errors for interactive leak search. - lcp.heuristics = 0; - lcp.deltamode = LCD_Increased; + HChar* xt_filename = NULL; + HChar* kw; + + lcp.mode = LC_Full; + lcp.show_leak_kinds = R2S(Possible) | R2S(Unreached); + lcp.errors_for_leak_kinds = 0; // no errors for interactive leak search. + lcp.heuristics = 0; + lcp.deltamode = LCD_Increased; lcp.max_loss_records_output = 999999999; lcp.requested_by_monitor_command = True; - lcp.xt_filename = NULL; - - for (kw = VG_(strtok_r) (NULL, " ", &ssaveptr); - kw != NULL; - kw = VG_(strtok_r) (NULL, " ", &ssaveptr)) { - switch (VG_(keyword_id) - ("full summary xtleak " - "kinds reachable possibleleak definiteleak " - "heuristics " - "new increased changed any " - "unlimited limited ", - kw, kwd_report_all)) { - case -2: err++; break; - case -1: err++; break; - case 0: /* full */ - lcp.mode = LC_Full; break; - case 1: /* summary */ - lcp.mode = LC_Summary; break; - case 2: /* xtleak */ + lcp.xt_filename = NULL; + + for (kw = VG_(strtok_r)(NULL, " ", &ssaveptr); kw != NULL; + kw = VG_(strtok_r)(NULL, " ", &ssaveptr)) { + switch (VG_(keyword_id)("full summary xtleak " + "kinds reachable possibleleak definiteleak " + "heuristics " + "new increased changed any " + "unlimited limited ", + kw, kwd_report_all)) { + case -2: + err++; + break; + case -1: + err++; + break; + case 0: /* full */ lcp.mode = LC_Full; - xt_filename - = VG_(expand_file_name)("--xtleak-mc_main.c", - "xtleak.kcg.%p.%n"); + break; + case 1: /* summary */ + lcp.mode = LC_Summary; + break; + case 2: /* xtleak */ + lcp.mode = LC_Full; + xt_filename = + VG_(expand_file_name)("--xtleak-mc_main.c", "xtleak.kcg.%p.%n"); lcp.xt_filename = xt_filename; break; - case 3: { /* kinds */ - wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr); - if (wcmd == NULL - || !VG_(parse_enum_set)(MC_(parse_leak_kinds_tokens), - True/*allow_all*/, - wcmd, - &lcp.show_leak_kinds)) { - VG_(gdb_printf) ("missing or malformed leak kinds set\n"); + case 3: { /* kinds */ + wcmd = VG_(strtok_r)(NULL, " ", &ssaveptr); + if (wcmd == NULL || + !VG_(parse_enum_set)(MC_(parse_leak_kinds_tokens), + True /*allow_all*/, wcmd, + &lcp.show_leak_kinds)) { + VG_(gdb_printf)("missing or malformed leak kinds set\n"); err++; } break; } - case 4: /* reachable */ + case 4: /* reachable */ lcp.show_leak_kinds = MC_(all_Reachedness)(); break; - case 5: /* possibleleak */ - lcp.show_leak_kinds - = R2S(Possible) | R2S(IndirectLeak) | R2S(Unreached); + case 5: /* possibleleak */ + lcp.show_leak_kinds = + R2S(Possible) | R2S(IndirectLeak) | R2S(Unreached); break; - case 6: /* definiteleak */ + case 6: /* definiteleak */ lcp.show_leak_kinds = R2S(Unreached); break; - case 7: { /* heuristics */ - wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr); - if (wcmd == NULL - || !VG_(parse_enum_set)(MC_(parse_leak_heuristics_tokens), - True,/*allow_all*/ - wcmd, - &lcp.heuristics)) { - VG_(gdb_printf) ("missing or malformed heuristics set\n"); + case 7: { /* heuristics */ + wcmd = VG_(strtok_r)(NULL, " ", &ssaveptr); + if (wcmd == NULL || + !VG_(parse_enum_set)(MC_(parse_leak_heuristics_tokens), + True, /*allow_all*/ + wcmd, &lcp.heuristics)) { + VG_(gdb_printf)("missing or malformed heuristics set\n"); err++; } break; } - case 8: /* new */ - lcp.deltamode = LCD_New; break; - case 9: /* increased */ - lcp.deltamode = LCD_Increased; break; + case 8: /* new */ + lcp.deltamode = LCD_New; + break; + case 9: /* increased */ + lcp.deltamode = LCD_Increased; + break; case 10: /* changed */ - lcp.deltamode = LCD_Changed; break; + lcp.deltamode = LCD_Changed; + break; case 11: /* any */ - lcp.deltamode = LCD_Any; break; + lcp.deltamode = LCD_Any; + break; case 12: /* unlimited */ - lcp.max_loss_records_output = 999999999; break; + lcp.max_loss_records_output = 999999999; + break; case 13: { /* limited */ - Int int_value; + Int int_value; const HChar* endptr; - wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr); + wcmd = VG_(strtok_r)(NULL, " ", &ssaveptr); if (wcmd == NULL) { int_value = 0; - endptr = "empty"; /* to report an error below */ + endptr = "empty"; /* to report an error below */ } else { - HChar *the_end; - int_value = VG_(strtoll10) (wcmd, &the_end); - endptr = the_end; + HChar* the_end; + int_value = VG_(strtoll10)(wcmd, &the_end); + endptr = the_end; } if (*endptr != '\0') - VG_(gdb_printf) ("missing or malformed integer value\n"); + VG_(gdb_printf)("missing or malformed integer value\n"); else if (int_value > 0) - lcp.max_loss_records_output = (UInt) int_value; + lcp.max_loss_records_output = (UInt)int_value; else - VG_(gdb_printf) ("max_loss_records_output must be >= 1," - " got %d\n", int_value); + VG_(gdb_printf)("max_loss_records_output must be >= 1," + " got %d\n", + int_value); break; } default: - tl_assert (0); + tl_assert(0); } } if (!err) @@ -6745,183 +6838,202 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req) return True; } - case 3: { /* make_memory */ - Addr address; + case 3: { /* make_memory */ + Addr address; SizeT szB = 1; - Int kwdid = VG_(keyword_id) - ("noaccess undefined defined Definedifaddressable", - VG_(strtok_r) (NULL, " ", &ssaveptr), kwd_report_all); - if (!VG_(strtok_get_address_and_size) (&address, &szB, &ssaveptr)) + Int kwdid = + VG_(keyword_id)("noaccess undefined defined Definedifaddressable", + VG_(strtok_r)(NULL, " ", &ssaveptr), kwd_report_all); + if (!VG_(strtok_get_address_and_size)(&address, &szB, &ssaveptr)) return True; switch (kwdid) { - case -2: break; - case -1: break; - case 0: MC_(make_mem_noaccess) (address, szB); break; - case 1: make_mem_undefined_w_tid_and_okind ( address, szB, tid, - MC_OKIND_USER ); break; - case 2: MC_(make_mem_defined) ( address, szB ); break; - case 3: make_mem_defined_if_addressable ( address, szB ); break;; - default: tl_assert(0); + case -2: + break; + case -1: + break; + case 0: + MC_(make_mem_noaccess)(address, szB); + break; + case 1: + make_mem_undefined_w_tid_and_okind(address, szB, tid, MC_OKIND_USER); + break; + case 2: + MC_(make_mem_defined)(address, szB); + break; + case 3: + make_mem_defined_if_addressable(address, szB); + break; + ; + default: + tl_assert(0); } return True; } - case 4: { /* check_memory */ - Addr address; - SizeT szB = 1; - Addr bad_addr; - UInt okind; - const HChar* src; - UInt otag; - UInt ecu; - ExeContext* origin_ec; + case 4: { /* check_memory */ + Addr address; + SizeT szB = 1; + Addr bad_addr; + UInt okind; + const HChar* src; + UInt otag; + UInt ecu; + ExeContext* origin_ec; MC_ReadResult res; - Int kwdid = VG_(keyword_id) - ("addressable defined", - VG_(strtok_r) (NULL, " ", &ssaveptr), kwd_report_all); - if (!VG_(strtok_get_address_and_size) (&address, &szB, &ssaveptr)) + Int kwdid = + VG_(keyword_id)("addressable defined", + VG_(strtok_r)(NULL, " ", &ssaveptr), kwd_report_all); + if (!VG_(strtok_get_address_and_size)(&address, &szB, &ssaveptr)) return True; switch (kwdid) { - case -2: break; - case -1: break; - case 0: /* addressable */ - if (is_mem_addressable ( address, szB, &bad_addr )) - VG_(printf) ("Address %p len %lu addressable\n", - (void *)address, szB); + case -2: + break; + case -1: + break; + case 0: /* addressable */ + if (is_mem_addressable(address, szB, &bad_addr)) + VG_(printf)("Address %p len %lu addressable\n", (void*)address, + szB); else VG_(printf) - ("Address %p len %lu not addressable:\nbad address %p\n", - (void *)address, szB, (void *) bad_addr); + ("Address %p len %lu not addressable:\nbad address %p\n", + (void*)address, szB, (void*)bad_addr); // Describe this (probably live) address with current epoch - MC_(pp_describe_addr) (VG_(current_DiEpoch)(), address); + MC_(pp_describe_addr)(VG_(current_DiEpoch)(), address); break; - case 1: /* defined */ - res = is_mem_defined ( address, szB, &bad_addr, &otag ); + case 1: /* defined */ + res = is_mem_defined(address, szB, &bad_addr, &otag); if (MC_AddrErr == res) VG_(printf) - ("Address %p len %lu not addressable:\nbad address %p\n", - (void *)address, szB, (void *) bad_addr); - else if (MC_ValueErr == res) { + ("Address %p len %lu not addressable:\nbad address %p\n", + (void*)address, szB, (void*)bad_addr); + else if (MC_ValueErr == res) + { okind = otag & 3; switch (okind) { case MC_OKIND_STACK: - src = " was created by a stack allocation"; break; + src = " was created by a stack allocation"; + break; case MC_OKIND_HEAP: - src = " was created by a heap allocation"; break; + src = " was created by a heap allocation"; + break; case MC_OKIND_USER: - src = " was created by a client request"; break; + src = " was created by a client request"; + break; case MC_OKIND_UNKNOWN: - src = ""; break; - default: tl_assert(0); + src = ""; + break; + default: + tl_assert(0); } VG_(printf) - ("Address %p len %lu not defined:\n" - "Uninitialised value at %p%s\n", - (void *)address, szB, (void *) bad_addr, src); + ("Address %p len %lu not defined:\n" + "Uninitialised value at %p%s\n", + (void*)address, szB, (void*)bad_addr, src); ecu = otag & ~3; if (VG_(is_plausible_ECU)(ecu)) { - origin_ec = VG_(get_ExeContext_from_ECU)( ecu ); - VG_(pp_ExeContext)( origin_ec ); + origin_ec = VG_(get_ExeContext_from_ECU)(ecu); + VG_(pp_ExeContext)(origin_ec); } } - else - VG_(printf) ("Address %p len %lu defined\n", - (void *)address, szB); + else VG_(printf)("Address %p len %lu defined\n", (void*)address, szB); // Describe this (probably live) address with current epoch - MC_(pp_describe_addr) (VG_(current_DiEpoch)(), address); + MC_(pp_describe_addr)(VG_(current_DiEpoch)(), address); break; - default: tl_assert(0); + default: + tl_assert(0); } return True; } - case 5: { /* block_list */ + case 5: { /* block_list */ HChar* wl; - HChar *the_end; - UInt lr_nr_from = 0; - UInt lr_nr_to = 0; + HChar* the_end; + UInt lr_nr_from = 0; + UInt lr_nr_to = 0; - if (VG_(parse_slice) (NULL, &ssaveptr, &lr_nr_from, &lr_nr_to)) { + if (VG_(parse_slice)(NULL, &ssaveptr, &lr_nr_from, &lr_nr_to)) { UInt limit_blocks = 999999999; - Int int_value; + Int int_value; UInt heuristics = 0; - for (wl = VG_(strtok_r) (NULL, " ", &ssaveptr); - wl != NULL; - wl = VG_(strtok_r) (NULL, " ", &ssaveptr)) { - switch (VG_(keyword_id) ("unlimited limited heuristics ", - wl, kwd_report_all)) { - case -2: return True; - case -1: return True; - case 0: /* unlimited */ - limit_blocks = 999999999; break; - case 1: /* limited */ - wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr); + for (wl = VG_(strtok_r)(NULL, " ", &ssaveptr); wl != NULL; + wl = VG_(strtok_r)(NULL, " ", &ssaveptr)) { + switch (VG_(keyword_id)("unlimited limited heuristics ", wl, + kwd_report_all)) { + case -2: + return True; + case -1: + return True; + case 0: /* unlimited */ + limit_blocks = 999999999; + break; + case 1: /* limited */ + wcmd = VG_(strtok_r)(NULL, " ", &ssaveptr); if (wcmd == NULL) { - VG_(gdb_printf) ("missing integer value\n"); + VG_(gdb_printf)("missing integer value\n"); return True; } - int_value = VG_(strtoll10) (wcmd, &the_end); + int_value = VG_(strtoll10)(wcmd, &the_end); if (*the_end != '\0') { - VG_(gdb_printf) ("malformed integer value\n"); + VG_(gdb_printf)("malformed integer value\n"); return True; } if (int_value <= 0) { - VG_(gdb_printf) ("max_blocks must be >= 1," - " got %d\n", int_value); + VG_(gdb_printf)("max_blocks must be >= 1," + " got %d\n", + int_value); return True; } - limit_blocks = (UInt) int_value; + limit_blocks = (UInt)int_value; break; - case 2: /* heuristics */ - wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr); - if (wcmd == NULL - || !VG_(parse_enum_set)(MC_(parse_leak_heuristics_tokens), - True,/*allow_all*/ - wcmd, - &heuristics)) { - VG_(gdb_printf) ("missing or malformed heuristics set\n"); + case 2: /* heuristics */ + wcmd = VG_(strtok_r)(NULL, " ", &ssaveptr); + if (wcmd == NULL || + !VG_(parse_enum_set)(MC_(parse_leak_heuristics_tokens), + True, /*allow_all*/ + wcmd, &heuristics)) { + VG_(gdb_printf)("missing or malformed heuristics set\n"); return True; } break; default: - tl_assert (0); + tl_assert(0); } } /* substract 1 from lr_nr_from/lr_nr_to as what is shown to the user is 1 more than the index in lr_array. */ - if (lr_nr_from == 0 || ! MC_(print_block_list) (lr_nr_from-1, - lr_nr_to-1, - limit_blocks, - heuristics)) - VG_(gdb_printf) ("invalid loss record nr\n"); + if (lr_nr_from == 0 || + !MC_(print_block_list)(lr_nr_from - 1, lr_nr_to - 1, limit_blocks, + heuristics)) + VG_(gdb_printf)("invalid loss record nr\n"); } return True; } - case 6: { /* who_points_at */ - Addr address; + case 6: { /* who_points_at */ + Addr address; SizeT szB = 1; - if (!VG_(strtok_get_address_and_size) (&address, &szB, &ssaveptr)) + if (!VG_(strtok_get_address_and_size)(&address, &szB, &ssaveptr)) return True; - if (address == (Addr) 0) { - VG_(gdb_printf) ("Cannot search who points at 0x0\n"); + if (address == (Addr)0) { + VG_(gdb_printf)("Cannot search who points at 0x0\n"); return True; } - MC_(who_points_at) (address, szB); + MC_(who_points_at)(address, szB); return True; } - case 7: { /* xb */ - Addr address; + case 7: { /* xb */ + Addr address; SizeT szB = 1; - if (VG_(strtok_get_address_and_size) (&address, &szB, &ssaveptr)) { + if (VG_(strtok_get_address_and_size)(&address, &szB, &ssaveptr)) { UChar vbits[8]; - Int res[8]; - Int i; - Int unaddressable = 0; + Int res[8]; + Int i; + Int unaddressable = 0; for (i = 0; i < szB; i++) { Int bnr = i % 8; /* We going to print the first vabits of a new line. @@ -6929,40 +7041,39 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req) address and the data. */ if (bnr == 0) { if (i != 0) { - VG_(printf) ("\n"); - gdb_xb (address + i - 8, 8, res); + VG_(printf)("\n"); + gdb_xb(address + i - 8, 8, res); } - VG_(printf) ("\t"); // To align VABITS with gdb_xb layout + VG_(printf)("\t"); // To align VABITS with gdb_xb layout } - res[bnr] = mc_get_or_set_vbits_for_client - (address+i, (Addr) &vbits[bnr], 1, - False, /* get them */ - False /* is client request */ ); + res[bnr] = mc_get_or_set_vbits_for_client( + address + i, (Addr)&vbits[bnr], 1, False, /* get them */ + False /* is client request */); if (res[bnr] == 1) { - VG_(printf) ("\t %02x", vbits[bnr]); + VG_(printf)("\t %02x", vbits[bnr]); } else { tl_assert(3 == res[bnr]); unaddressable++; - VG_(printf) ("\t __"); + VG_(printf)("\t __"); } } - VG_(printf) ("\n"); + VG_(printf)("\n"); if (szB % 8 == 0 && szB > 0) - gdb_xb (address + szB - 8, 8, res); + gdb_xb(address + szB - 8, 8, res); else - gdb_xb (address + szB - szB % 8, szB % 8, res); + gdb_xb(address + szB - szB % 8, szB % 8, res); if (unaddressable) { VG_(printf) - ("Address %p len %lu has %d bytes unaddressable\n", - (void *)address, szB, unaddressable); + ("Address %p len %lu has %d bytes unaddressable\n", (void*)address, + szB, unaddressable); } } return True; } - case 8: { /* xtmemory */ + case 8: { /* xtmemory */ HChar* filename; - filename = VG_(strtok_r) (NULL, " ", &ssaveptr); + filename = VG_(strtok_r)(NULL, " ", &ssaveptr); MC_(xtmemory_report)(filename, False); return True; } @@ -6977,344 +7088,333 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req) /*--- Client requests ---*/ /*------------------------------------------------------------*/ -static Bool mc_handle_client_request ( ThreadId tid, UWord* arg, UWord* ret ) -{ - Int i; - Addr bad_addr; - - if (!VG_IS_TOOL_USERREQ('M','C',arg[0]) - && VG_USERREQ__MALLOCLIKE_BLOCK != arg[0] - && VG_USERREQ__RESIZEINPLACE_BLOCK != arg[0] - && VG_USERREQ__FREELIKE_BLOCK != arg[0] - && VG_USERREQ__CREATE_MEMPOOL != arg[0] - && VG_USERREQ__DESTROY_MEMPOOL != arg[0] - && VG_USERREQ__MEMPOOL_ALLOC != arg[0] - && VG_USERREQ__MEMPOOL_FREE != arg[0] - && VG_USERREQ__MEMPOOL_TRIM != arg[0] - && VG_USERREQ__MOVE_MEMPOOL != arg[0] - && VG_USERREQ__MEMPOOL_CHANGE != arg[0] - && VG_USERREQ__MEMPOOL_EXISTS != arg[0] - && VG_USERREQ__GDB_MONITOR_COMMAND != arg[0] - && VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE != arg[0] - && VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE != arg[0]) +static Bool mc_handle_client_request(ThreadId tid, UWord* arg, UWord* ret) +{ + Int i; + Addr bad_addr; + + if (!VG_IS_TOOL_USERREQ('M', 'C', arg[0]) && + VG_USERREQ__MALLOCLIKE_BLOCK != arg[0] && + VG_USERREQ__RESIZEINPLACE_BLOCK != arg[0] && + VG_USERREQ__FREELIKE_BLOCK != arg[0] && + VG_USERREQ__CREATE_MEMPOOL != arg[0] && + VG_USERREQ__DESTROY_MEMPOOL != arg[0] && + VG_USERREQ__MEMPOOL_ALLOC != arg[0] && + VG_USERREQ__MEMPOOL_FREE != arg[0] && + VG_USERREQ__MEMPOOL_TRIM != arg[0] && + VG_USERREQ__MOVE_MEMPOOL != arg[0] && + VG_USERREQ__MEMPOOL_CHANGE != arg[0] && + VG_USERREQ__MEMPOOL_EXISTS != arg[0] && + VG_USERREQ__GDB_MONITOR_COMMAND != arg[0] && + VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE != arg[0] && + VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE != arg[0]) return False; switch (arg[0]) { - case VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE: { - Bool ok = is_mem_addressable ( arg[1], arg[2], &bad_addr ); - if (!ok) - MC_(record_user_error) ( tid, bad_addr, /*isAddrErr*/True, 0 ); - *ret = ok ? (UWord)NULL : bad_addr; - break; - } + case VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE: { + Bool ok = is_mem_addressable(arg[1], arg[2], &bad_addr); + if (!ok) + MC_(record_user_error)(tid, bad_addr, /*isAddrErr*/ True, 0); + *ret = ok ? (UWord)NULL : bad_addr; + break; + } - case VG_USERREQ__CHECK_MEM_IS_DEFINED: { - Bool errorV = False; - Addr bad_addrV = 0; - UInt otagV = 0; - Bool errorA = False; - Addr bad_addrA = 0; - is_mem_defined_comprehensive( - arg[1], arg[2], - &errorV, &bad_addrV, &otagV, &errorA, &bad_addrA - ); - if (errorV) { - MC_(record_user_error) ( tid, bad_addrV, - /*isAddrErr*/False, otagV ); - } - if (errorA) { - MC_(record_user_error) ( tid, bad_addrA, - /*isAddrErr*/True, 0 ); - } - /* Return the lower of the two erring addresses, if any. */ - *ret = 0; - if (errorV && !errorA) { - *ret = bad_addrV; - } - if (!errorV && errorA) { - *ret = bad_addrA; - } - if (errorV && errorA) { - *ret = bad_addrV < bad_addrA ? bad_addrV : bad_addrA; - } - break; + case VG_USERREQ__CHECK_MEM_IS_DEFINED: { + Bool errorV = False; + Addr bad_addrV = 0; + UInt otagV = 0; + Bool errorA = False; + Addr bad_addrA = 0; + is_mem_defined_comprehensive(arg[1], arg[2], &errorV, &bad_addrV, &otagV, + &errorA, &bad_addrA); + if (errorV) { + MC_(record_user_error)(tid, bad_addrV, + /*isAddrErr*/ False, otagV); + } + if (errorA) { + MC_(record_user_error)(tid, bad_addrA, + /*isAddrErr*/ True, 0); + } + /* Return the lower of the two erring addresses, if any. */ + *ret = 0; + if (errorV && !errorA) { + *ret = bad_addrV; } + if (!errorV && errorA) { + *ret = bad_addrA; + } + if (errorV && errorA) { + *ret = bad_addrV < bad_addrA ? bad_addrV : bad_addrA; + } + break; + } - case VG_USERREQ__DO_LEAK_CHECK: { - LeakCheckParams lcp; + case VG_USERREQ__DO_LEAK_CHECK: { + LeakCheckParams lcp; - if (arg[1] == 0) - lcp.mode = LC_Full; - else if (arg[1] == 1) - lcp.mode = LC_Summary; - else { - VG_(message)(Vg_UserMsg, - "Warning: unknown memcheck leak search mode\n"); - lcp.mode = LC_Full; - } + if (arg[1] == 0) + lcp.mode = LC_Full; + else if (arg[1] == 1) + lcp.mode = LC_Summary; + else { + VG_(message)(Vg_UserMsg, + "Warning: unknown memcheck leak search mode\n"); + lcp.mode = LC_Full; + } - lcp.show_leak_kinds = MC_(clo_show_leak_kinds); - lcp.errors_for_leak_kinds = MC_(clo_error_for_leak_kinds); - lcp.heuristics = MC_(clo_leak_check_heuristics); + lcp.show_leak_kinds = MC_(clo_show_leak_kinds); + lcp.errors_for_leak_kinds = MC_(clo_error_for_leak_kinds); + lcp.heuristics = MC_(clo_leak_check_heuristics); + + if (arg[2] == 0) + lcp.deltamode = LCD_Any; + else if (arg[2] == 1) + lcp.deltamode = LCD_Increased; + else if (arg[2] == 2) + lcp.deltamode = LCD_Changed; + else if (arg[2] == 3) + lcp.deltamode = LCD_New; + else { + VG_(message) + (Vg_UserMsg, "Warning: unknown memcheck leak search deltamode\n"); + lcp.deltamode = LCD_Any; + } + lcp.max_loss_records_output = 999999999; + lcp.requested_by_monitor_command = False; + lcp.xt_filename = NULL; - if (arg[2] == 0) - lcp.deltamode = LCD_Any; - else if (arg[2] == 1) - lcp.deltamode = LCD_Increased; - else if (arg[2] == 2) - lcp.deltamode = LCD_Changed; - else if (arg[2] == 3) - lcp.deltamode = LCD_New; - else { - VG_(message) - (Vg_UserMsg, - "Warning: unknown memcheck leak search deltamode\n"); - lcp.deltamode = LCD_Any; - } - lcp.max_loss_records_output = 999999999; - lcp.requested_by_monitor_command = False; - lcp.xt_filename = NULL; + MC_(detect_memory_leaks)(tid, &lcp); + *ret = 0; /* return value is meaningless */ + break; + } - MC_(detect_memory_leaks)(tid, &lcp); - *ret = 0; /* return value is meaningless */ - break; - } + case VG_USERREQ__MAKE_MEM_NOACCESS: + MC_(make_mem_noaccess)(arg[1], arg[2]); + *ret = -1; + break; - case VG_USERREQ__MAKE_MEM_NOACCESS: - MC_(make_mem_noaccess) ( arg[1], arg[2] ); - *ret = -1; - break; + case VG_USERREQ__MAKE_MEM_UNDEFINED: + make_mem_undefined_w_tid_and_okind(arg[1], arg[2], tid, MC_OKIND_USER); + *ret = -1; + break; - case VG_USERREQ__MAKE_MEM_UNDEFINED: - make_mem_undefined_w_tid_and_okind ( arg[1], arg[2], tid, - MC_OKIND_USER ); - *ret = -1; - break; + case VG_USERREQ__MAKE_MEM_DEFINED: + MC_(make_mem_defined)(arg[1], arg[2]); + *ret = -1; + break; - case VG_USERREQ__MAKE_MEM_DEFINED: - MC_(make_mem_defined) ( arg[1], arg[2] ); - *ret = -1; - break; + case VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE: + make_mem_defined_if_addressable(arg[1], arg[2]); + *ret = -1; + break; - case VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE: - make_mem_defined_if_addressable ( arg[1], arg[2] ); + case VG_USERREQ__CREATE_BLOCK: /* describe a block */ + if (arg[1] != 0 && arg[2] != 0) { + i = alloc_client_block(); + /* VG_(printf)("allocated %d %p\n", i, cgbs); */ + cgbs[i].start = arg[1]; + cgbs[i].size = arg[2]; + cgbs[i].desc = VG_(strdup)("mc.mhcr.1", (HChar*)arg[3]); + cgbs[i].where = VG_(record_ExeContext)(tid, 0 /*first_ip_delta*/); + *ret = i; + } else *ret = -1; - break; - - case VG_USERREQ__CREATE_BLOCK: /* describe a block */ - if (arg[1] != 0 && arg[2] != 0) { - i = alloc_client_block(); - /* VG_(printf)("allocated %d %p\n", i, cgbs); */ - cgbs[i].start = arg[1]; - cgbs[i].size = arg[2]; - cgbs[i].desc = VG_(strdup)("mc.mhcr.1", (HChar *)arg[3]); - cgbs[i].where = VG_(record_ExeContext) ( tid, 0/*first_ip_delta*/ ); - *ret = i; - } else - *ret = -1; - break; + break; - case VG_USERREQ__DISCARD: /* discard */ - if (cgbs == NULL - || arg[2] >= cgb_used || - (cgbs[arg[2]].start == 0 && cgbs[arg[2]].size == 0)) { - *ret = 1; - } else { - tl_assert(arg[2] >= 0 && arg[2] < cgb_used); - cgbs[arg[2]].start = cgbs[arg[2]].size = 0; - VG_(free)(cgbs[arg[2]].desc); - cgb_discards++; - *ret = 0; - } - break; + case VG_USERREQ__DISCARD: /* discard */ + if (cgbs == NULL || arg[2] >= cgb_used || + (cgbs[arg[2]].start == 0 && cgbs[arg[2]].size == 0)) { + *ret = 1; + } else { + tl_assert(arg[2] >= 0 && arg[2] < cgb_used); + cgbs[arg[2]].start = cgbs[arg[2]].size = 0; + VG_(free)(cgbs[arg[2]].desc); + cgb_discards++; + *ret = 0; + } + break; - case VG_USERREQ__GET_VBITS: - *ret = mc_get_or_set_vbits_for_client - ( arg[1], arg[2], arg[3], - False /* get them */, - True /* is client request */ ); - break; + case VG_USERREQ__GET_VBITS: + *ret = mc_get_or_set_vbits_for_client(arg[1], arg[2], arg[3], + False /* get them */, + True /* is client request */); + break; - case VG_USERREQ__SET_VBITS: - *ret = mc_get_or_set_vbits_for_client - ( arg[1], arg[2], arg[3], - True /* set them */, - True /* is client request */ ); - break; + case VG_USERREQ__SET_VBITS: + *ret = mc_get_or_set_vbits_for_client(arg[1], arg[2], arg[3], + True /* set them */, + True /* is client request */); + break; - case VG_USERREQ__COUNT_LEAKS: { /* count leaked bytes */ - UWord** argp = (UWord**)arg; - // MC_(bytes_leaked) et al were set by the last leak check (or zero - // if no prior leak checks performed). - *argp[1] = MC_(bytes_leaked) + MC_(bytes_indirect); - *argp[2] = MC_(bytes_dubious); - *argp[3] = MC_(bytes_reachable); - *argp[4] = MC_(bytes_suppressed); - // there is no argp[5] - //*argp[5] = MC_(bytes_indirect); - // XXX need to make *argp[1-4] defined; currently done in the - // VALGRIND_COUNT_LEAKS_MACRO by initialising them to zero. - *ret = 0; - return True; - } - case VG_USERREQ__COUNT_LEAK_BLOCKS: { /* count leaked blocks */ - UWord** argp = (UWord**)arg; - // MC_(blocks_leaked) et al were set by the last leak check (or zero - // if no prior leak checks performed). - *argp[1] = MC_(blocks_leaked) + MC_(blocks_indirect); - *argp[2] = MC_(blocks_dubious); - *argp[3] = MC_(blocks_reachable); - *argp[4] = MC_(blocks_suppressed); - // there is no argp[5] - //*argp[5] = MC_(blocks_indirect); - // XXX need to make *argp[1-4] defined; currently done in the - // VALGRIND_COUNT_LEAK_BLOCKS_MACRO by initialising them to zero. - *ret = 0; - return True; - } - case VG_USERREQ__MALLOCLIKE_BLOCK: { - Addr p = (Addr)arg[1]; - SizeT sizeB = arg[2]; - UInt rzB = arg[3]; - Bool is_zeroed = (Bool)arg[4]; - - MC_(new_block) ( tid, p, sizeB, /*ignored*/0, is_zeroed, - MC_AllocCustom, MC_(malloc_list) ); - if (rzB > 0) { - MC_(make_mem_noaccess) ( p - rzB, rzB); - MC_(make_mem_noaccess) ( p + sizeB, rzB); - } - return True; + case VG_USERREQ__COUNT_LEAKS: { /* count leaked bytes */ + UWord** argp = (UWord**)arg; + // MC_(bytes_leaked) et al were set by the last leak check (or zero + // if no prior leak checks performed). + *argp[1] = MC_(bytes_leaked) + MC_(bytes_indirect); + *argp[2] = MC_(bytes_dubious); + *argp[3] = MC_(bytes_reachable); + *argp[4] = MC_(bytes_suppressed); + // there is no argp[5] + //*argp[5] = MC_(bytes_indirect); + // XXX need to make *argp[1-4] defined; currently done in the + // VALGRIND_COUNT_LEAKS_MACRO by initialising them to zero. + *ret = 0; + return True; + } + case VG_USERREQ__COUNT_LEAK_BLOCKS: { /* count leaked blocks */ + UWord** argp = (UWord**)arg; + // MC_(blocks_leaked) et al were set by the last leak check (or zero + // if no prior leak checks performed). + *argp[1] = MC_(blocks_leaked) + MC_(blocks_indirect); + *argp[2] = MC_(blocks_dubious); + *argp[3] = MC_(blocks_reachable); + *argp[4] = MC_(blocks_suppressed); + // there is no argp[5] + //*argp[5] = MC_(blocks_indirect); + // XXX need to make *argp[1-4] defined; currently done in the + // VALGRIND_COUNT_LEAK_BLOCKS_MACRO by initialising them to zero. + *ret = 0; + return True; + } + case VG_USERREQ__MALLOCLIKE_BLOCK: { + Addr p = (Addr)arg[1]; + SizeT sizeB = arg[2]; + UInt rzB = arg[3]; + Bool is_zeroed = (Bool)arg[4]; + + MC_(new_block)(tid, p, sizeB, /*ignored*/ 0, is_zeroed, MC_AllocCustom, + MC_(malloc_list)); + if (rzB > 0) { + MC_(make_mem_noaccess)(p - rzB, rzB); + MC_(make_mem_noaccess)(p + sizeB, rzB); } - case VG_USERREQ__RESIZEINPLACE_BLOCK: { - Addr p = (Addr)arg[1]; - SizeT oldSizeB = arg[2]; - SizeT newSizeB = arg[3]; - UInt rzB = arg[4]; + return True; + } + case VG_USERREQ__RESIZEINPLACE_BLOCK: { + Addr p = (Addr)arg[1]; + SizeT oldSizeB = arg[2]; + SizeT newSizeB = arg[3]; + UInt rzB = arg[4]; - MC_(handle_resizeInPlace) ( tid, p, oldSizeB, newSizeB, rzB ); - return True; - } - case VG_USERREQ__FREELIKE_BLOCK: { - Addr p = (Addr)arg[1]; - UInt rzB = arg[2]; + MC_(handle_resizeInPlace)(tid, p, oldSizeB, newSizeB, rzB); + return True; + } + case VG_USERREQ__FREELIKE_BLOCK: { + Addr p = (Addr)arg[1]; + UInt rzB = arg[2]; - MC_(handle_free) ( tid, p, rzB, MC_AllocCustom ); - return True; - } + MC_(handle_free)(tid, p, rzB, MC_AllocCustom); + return True; + } - case _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR: { - HChar* s = (HChar*)arg[1]; - Addr dst = (Addr) arg[2]; - Addr src = (Addr) arg[3]; - SizeT len = (SizeT)arg[4]; - MC_(record_overlap_error)(tid, s, src, dst, len); - return True; - } + case _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR: { + HChar* s = (HChar*)arg[1]; + Addr dst = (Addr)arg[2]; + Addr src = (Addr)arg[3]; + SizeT len = (SizeT)arg[4]; + MC_(record_overlap_error)(tid, s, src, dst, len); + return True; + } - case VG_USERREQ__CREATE_MEMPOOL: { - Addr pool = (Addr)arg[1]; - UInt rzB = arg[2]; - Bool is_zeroed = (Bool)arg[3]; - UInt flags = arg[4]; - - // The create_mempool function does not know these mempool flags, - // pass as booleans. - MC_(create_mempool) ( pool, rzB, is_zeroed, - (flags & VALGRIND_MEMPOOL_AUTO_FREE), - (flags & VALGRIND_MEMPOOL_METAPOOL) ); - return True; - } + case VG_USERREQ__CREATE_MEMPOOL: { + Addr pool = (Addr)arg[1]; + UInt rzB = arg[2]; + Bool is_zeroed = (Bool)arg[3]; + UInt flags = arg[4]; - case VG_USERREQ__DESTROY_MEMPOOL: { - Addr pool = (Addr)arg[1]; + // The create_mempool function does not know these mempool flags, + // pass as booleans. + MC_(create_mempool)(pool, rzB, is_zeroed, + (flags & VALGRIND_MEMPOOL_AUTO_FREE), + (flags & VALGRIND_MEMPOOL_METAPOOL)); + return True; + } - MC_(destroy_mempool) ( pool ); - return True; - } + case VG_USERREQ__DESTROY_MEMPOOL: { + Addr pool = (Addr)arg[1]; - case VG_USERREQ__MEMPOOL_ALLOC: { - Addr pool = (Addr)arg[1]; - Addr addr = (Addr)arg[2]; - UInt size = arg[3]; + MC_(destroy_mempool)(pool); + return True; + } - MC_(mempool_alloc) ( tid, pool, addr, size ); - return True; - } + case VG_USERREQ__MEMPOOL_ALLOC: { + Addr pool = (Addr)arg[1]; + Addr addr = (Addr)arg[2]; + UInt size = arg[3]; - case VG_USERREQ__MEMPOOL_FREE: { - Addr pool = (Addr)arg[1]; - Addr addr = (Addr)arg[2]; + MC_(mempool_alloc)(tid, pool, addr, size); + return True; + } - MC_(mempool_free) ( pool, addr ); - return True; - } + case VG_USERREQ__MEMPOOL_FREE: { + Addr pool = (Addr)arg[1]; + Addr addr = (Addr)arg[2]; - case VG_USERREQ__MEMPOOL_TRIM: { - Addr pool = (Addr)arg[1]; - Addr addr = (Addr)arg[2]; - UInt size = arg[3]; + MC_(mempool_free)(pool, addr); + return True; + } - MC_(mempool_trim) ( pool, addr, size ); - return True; - } + case VG_USERREQ__MEMPOOL_TRIM: { + Addr pool = (Addr)arg[1]; + Addr addr = (Addr)arg[2]; + UInt size = arg[3]; - case VG_USERREQ__MOVE_MEMPOOL: { - Addr poolA = (Addr)arg[1]; - Addr poolB = (Addr)arg[2]; + MC_(mempool_trim)(pool, addr, size); + return True; + } - MC_(move_mempool) ( poolA, poolB ); - return True; - } + case VG_USERREQ__MOVE_MEMPOOL: { + Addr poolA = (Addr)arg[1]; + Addr poolB = (Addr)arg[2]; - case VG_USERREQ__MEMPOOL_CHANGE: { - Addr pool = (Addr)arg[1]; - Addr addrA = (Addr)arg[2]; - Addr addrB = (Addr)arg[3]; - UInt size = arg[4]; + MC_(move_mempool)(poolA, poolB); + return True; + } - MC_(mempool_change) ( pool, addrA, addrB, size ); - return True; - } + case VG_USERREQ__MEMPOOL_CHANGE: { + Addr pool = (Addr)arg[1]; + Addr addrA = (Addr)arg[2]; + Addr addrB = (Addr)arg[3]; + UInt size = arg[4]; - case VG_USERREQ__MEMPOOL_EXISTS: { - Addr pool = (Addr)arg[1]; + MC_(mempool_change)(pool, addrA, addrB, size); + return True; + } - *ret = (UWord) MC_(mempool_exists) ( pool ); - return True; - } + case VG_USERREQ__MEMPOOL_EXISTS: { + Addr pool = (Addr)arg[1]; - case VG_USERREQ__GDB_MONITOR_COMMAND: { - Bool handled = handle_gdb_monitor_command (tid, (HChar*)arg[1]); - if (handled) - *ret = 1; - else - *ret = 0; - return handled; - } + *ret = (UWord)MC_(mempool_exists)(pool); + return True; + } - case VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE: - case VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE: { - Bool addRange - = arg[0] == VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE; - Bool ok - = modify_ignore_ranges(addRange, arg[1], arg[2]); - *ret = ok ? 1 : 0; - return True; - } + case VG_USERREQ__GDB_MONITOR_COMMAND: { + Bool handled = handle_gdb_monitor_command(tid, (HChar*)arg[1]); + if (handled) + *ret = 1; + else + *ret = 0; + return handled; + } - default: - VG_(message)( - Vg_UserMsg, - "Warning: unknown memcheck client request code %llx\n", - (ULong)arg[0] - ); - return False; + case VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE: + case VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE: { + Bool addRange = + arg[0] == VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE; + Bool ok = modify_ignore_ranges(addRange, arg[1], arg[2]); + *ret = ok ? 1 : 0; + return True; + } + + default: + VG_(message)(Vg_UserMsg, + "Warning: unknown memcheck client request code %llx\n", + (ULong)arg[0]); + return False; } return True; } - /*------------------------------------------------------------*/ /*--- Crude profiling machinery. ---*/ /*------------------------------------------------------------*/ @@ -7324,140 +7424,140 @@ static Bool mc_handle_client_request ( ThreadId tid, UWord* arg, UWord* ret ) #ifdef MC_PROFILE_MEMORY -ULong MC_(event_ctr)[MCPE_LAST]; +ULong MC_(event_ctr)[MCPE_LAST]; /* Event counter names. Use the name of the function that increases the event counter. Drop any MC_() and mc_ prefices. */ static const HChar* MC_(event_ctr_name)[MCPE_LAST] = { - [MCPE_LOADVN_SLOW] = "LOADVn_slow", - [MCPE_LOADVN_SLOW_LOOP] = "LOADVn_slow_loop", - [MCPE_STOREVN_SLOW] = "STOREVn_slow", - [MCPE_STOREVN_SLOW_LOOP] = "STOREVn_slow(loop)", + [MCPE_LOADVN_SLOW] = "LOADVn_slow", + [MCPE_LOADVN_SLOW_LOOP] = "LOADVn_slow_loop", + [MCPE_STOREVN_SLOW] = "STOREVn_slow", + [MCPE_STOREVN_SLOW_LOOP] = "STOREVn_slow(loop)", [MCPE_MAKE_ALIGNED_WORD32_UNDEFINED] = "make_aligned_word32_undefined", [MCPE_MAKE_ALIGNED_WORD32_UNDEFINED_SLOW] = - "make_aligned_word32_undefined_slow", + "make_aligned_word32_undefined_slow", [MCPE_MAKE_ALIGNED_WORD64_UNDEFINED] = "make_aligned_word64_undefined", [MCPE_MAKE_ALIGNED_WORD64_UNDEFINED_SLOW] = - "make_aligned_word64_undefined_slow", + "make_aligned_word64_undefined_slow", [MCPE_MAKE_ALIGNED_WORD32_NOACCESS] = "make_aligned_word32_noaccess", [MCPE_MAKE_ALIGNED_WORD32_NOACCESS_SLOW] = - "make_aligned_word32_noaccess_slow", + "make_aligned_word32_noaccess_slow", [MCPE_MAKE_ALIGNED_WORD64_NOACCESS] = "make_aligned_word64_noaccess", [MCPE_MAKE_ALIGNED_WORD64_NOACCESS_SLOW] = - "make_aligned_word64_noaccess_slow", - [MCPE_MAKE_MEM_NOACCESS] = "make_mem_noaccess", - [MCPE_MAKE_MEM_UNDEFINED] = "make_mem_undefined", - [MCPE_MAKE_MEM_UNDEFINED_W_OTAG] = "make_mem_undefined_w_otag", - [MCPE_MAKE_MEM_DEFINED] = "make_mem_defined", - [MCPE_CHEAP_SANITY_CHECK] = "cheap_sanity_check", - [MCPE_EXPENSIVE_SANITY_CHECK] = "expensive_sanity_check", - [MCPE_COPY_ADDRESS_RANGE_STATE] = "copy_address_range_state", + "make_aligned_word64_noaccess_slow", + [MCPE_MAKE_MEM_NOACCESS] = "make_mem_noaccess", + [MCPE_MAKE_MEM_UNDEFINED] = "make_mem_undefined", + [MCPE_MAKE_MEM_UNDEFINED_W_OTAG] = "make_mem_undefined_w_otag", + [MCPE_MAKE_MEM_DEFINED] = "make_mem_defined", + [MCPE_CHEAP_SANITY_CHECK] = "cheap_sanity_check", + [MCPE_EXPENSIVE_SANITY_CHECK] = "expensive_sanity_check", + [MCPE_COPY_ADDRESS_RANGE_STATE] = "copy_address_range_state", [MCPE_COPY_ADDRESS_RANGE_STATE_LOOP1] = "copy_address_range_state(loop1)", [MCPE_COPY_ADDRESS_RANGE_STATE_LOOP2] = "copy_address_range_state(loop2)", - [MCPE_CHECK_MEM_IS_NOACCESS] = "check_mem_is_noaccess", - [MCPE_CHECK_MEM_IS_NOACCESS_LOOP] = "check_mem_is_noaccess(loop)", - [MCPE_IS_MEM_ADDRESSABLE] = "is_mem_addressable", - [MCPE_IS_MEM_ADDRESSABLE_LOOP] = "is_mem_addressable(loop)", - [MCPE_IS_MEM_DEFINED] = "is_mem_defined", - [MCPE_IS_MEM_DEFINED_LOOP] = "is_mem_defined(loop)", - [MCPE_IS_MEM_DEFINED_COMPREHENSIVE] = "is_mem_defined_comprehensive", + [MCPE_CHECK_MEM_IS_NOACCESS] = "check_mem_is_noaccess", + [MCPE_CHECK_MEM_IS_NOACCESS_LOOP] = "check_mem_is_noaccess(loop)", + [MCPE_IS_MEM_ADDRESSABLE] = "is_mem_addressable", + [MCPE_IS_MEM_ADDRESSABLE_LOOP] = "is_mem_addressable(loop)", + [MCPE_IS_MEM_DEFINED] = "is_mem_defined", + [MCPE_IS_MEM_DEFINED_LOOP] = "is_mem_defined(loop)", + [MCPE_IS_MEM_DEFINED_COMPREHENSIVE] = "is_mem_defined_comprehensive", [MCPE_IS_MEM_DEFINED_COMPREHENSIVE_LOOP] = - "is_mem_defined_comprehensive(loop)", - [MCPE_IS_DEFINED_ASCIIZ] = "is_defined_asciiz", - [MCPE_IS_DEFINED_ASCIIZ_LOOP] = "is_defined_asciiz(loop)", - [MCPE_FIND_CHUNK_FOR_OLD] = "find_chunk_for_OLD", + "is_mem_defined_comprehensive(loop)", + [MCPE_IS_DEFINED_ASCIIZ] = "is_defined_asciiz", + [MCPE_IS_DEFINED_ASCIIZ_LOOP] = "is_defined_asciiz(loop)", + [MCPE_FIND_CHUNK_FOR_OLD] = "find_chunk_for_OLD", [MCPE_FIND_CHUNK_FOR_OLD_LOOP] = "find_chunk_for_OLD(loop)", [MCPE_SET_ADDRESS_RANGE_PERMS] = "set_address_range_perms", [MCPE_SET_ADDRESS_RANGE_PERMS_SINGLE_SECMAP] = - "set_address_range_perms(single-secmap)", + "set_address_range_perms(single-secmap)", [MCPE_SET_ADDRESS_RANGE_PERMS_STARTOF_SECMAP] = - "set_address_range_perms(startof-secmap)", + "set_address_range_perms(startof-secmap)", [MCPE_SET_ADDRESS_RANGE_PERMS_MULTIPLE_SECMAPS] = - "set_address_range_perms(multiple-secmaps)", + "set_address_range_perms(multiple-secmaps)", [MCPE_SET_ADDRESS_RANGE_PERMS_DIST_SM1] = - "set_address_range_perms(dist-sm1)", + "set_address_range_perms(dist-sm1)", [MCPE_SET_ADDRESS_RANGE_PERMS_DIST_SM2] = - "set_address_range_perms(dist-sm2)", + "set_address_range_perms(dist-sm2)", [MCPE_SET_ADDRESS_RANGE_PERMS_DIST_SM1_QUICK] = - "set_address_range_perms(dist-sm1-quick)", + "set_address_range_perms(dist-sm1-quick)", [MCPE_SET_ADDRESS_RANGE_PERMS_DIST_SM2_QUICK] = - "set_address_range_perms(dist-sm2-quick)", - [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1A] = "set_address_range_perms(loop1a)", - [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1B] = "set_address_range_perms(loop1b)", - [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1C] = "set_address_range_perms(loop1c)", - [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8A] = "set_address_range_perms(loop8a)", - [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8B] = "set_address_range_perms(loop8b)", + "set_address_range_perms(dist-sm2-quick)", + [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1A] = "set_address_range_perms(loop1a)", + [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1B] = "set_address_range_perms(loop1b)", + [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP1C] = "set_address_range_perms(loop1c)", + [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8A] = "set_address_range_perms(loop8a)", + [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP8B] = "set_address_range_perms(loop8b)", [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP64K] = "set_address_range_perms(loop64K)", [MCPE_SET_ADDRESS_RANGE_PERMS_LOOP64K_FREE_DIST_SM] = - "set_address_range_perms(loop64K-free-dist-sm)", + "set_address_range_perms(loop64K-free-dist-sm)", [MCPE_LOADV_128_OR_256_SLOW_LOOP] = "LOADV_128_or_256_slow(loop)", - [MCPE_LOADV_128_OR_256] = "LOADV_128_or_256", - [MCPE_LOADV_128_OR_256_SLOW1] = "LOADV_128_or_256-slow1", - [MCPE_LOADV_128_OR_256_SLOW2] = "LOADV_128_or_256-slow2", - [MCPE_LOADV64] = "LOADV64", - [MCPE_LOADV64_SLOW1] = "LOADV64-slow1", - [MCPE_LOADV64_SLOW2] = "LOADV64-slow2", - [MCPE_STOREV64] = "STOREV64", - [MCPE_STOREV64_SLOW1] = "STOREV64-slow1", - [MCPE_STOREV64_SLOW2] = "STOREV64-slow2", - [MCPE_STOREV64_SLOW3] = "STOREV64-slow3", - [MCPE_STOREV64_SLOW4] = "STOREV64-slow4", - [MCPE_LOADV32] = "LOADV32", - [MCPE_LOADV32_SLOW1] = "LOADV32-slow1", - [MCPE_LOADV32_SLOW2] = "LOADV32-slow2", - [MCPE_STOREV32] = "STOREV32", - [MCPE_STOREV32_SLOW1] = "STOREV32-slow1", - [MCPE_STOREV32_SLOW2] = "STOREV32-slow2", - [MCPE_STOREV32_SLOW3] = "STOREV32-slow3", - [MCPE_STOREV32_SLOW4] = "STOREV32-slow4", - [MCPE_LOADV16] = "LOADV16", - [MCPE_LOADV16_SLOW1] = "LOADV16-slow1", - [MCPE_LOADV16_SLOW2] = "LOADV16-slow2", - [MCPE_STOREV16] = "STOREV16", - [MCPE_STOREV16_SLOW1] = "STOREV16-slow1", - [MCPE_STOREV16_SLOW2] = "STOREV16-slow2", - [MCPE_STOREV16_SLOW3] = "STOREV16-slow3", - [MCPE_STOREV16_SLOW4] = "STOREV16-slow4", - [MCPE_LOADV8] = "LOADV8", - [MCPE_LOADV8_SLOW1] = "LOADV8-slow1", - [MCPE_LOADV8_SLOW2] = "LOADV8-slow2", - [MCPE_STOREV8] = "STOREV8", - [MCPE_STOREV8_SLOW1] = "STOREV8-slow1", - [MCPE_STOREV8_SLOW2] = "STOREV8-slow2", - [MCPE_STOREV8_SLOW3] = "STOREV8-slow3", - [MCPE_STOREV8_SLOW4] = "STOREV8-slow4", - [MCPE_NEW_MEM_STACK_4] = "new_mem_stack_4", - [MCPE_NEW_MEM_STACK_8] = "new_mem_stack_8", - [MCPE_NEW_MEM_STACK_12] = "new_mem_stack_12", - [MCPE_NEW_MEM_STACK_16] = "new_mem_stack_16", - [MCPE_NEW_MEM_STACK_32] = "new_mem_stack_32", - [MCPE_NEW_MEM_STACK_112] = "new_mem_stack_112", - [MCPE_NEW_MEM_STACK_128] = "new_mem_stack_128", - [MCPE_NEW_MEM_STACK_144] = "new_mem_stack_144", - [MCPE_NEW_MEM_STACK_160] = "new_mem_stack_160", - [MCPE_DIE_MEM_STACK_4] = "die_mem_stack_4", - [MCPE_DIE_MEM_STACK_8] = "die_mem_stack_8", - [MCPE_DIE_MEM_STACK_12] = "die_mem_stack_12", - [MCPE_DIE_MEM_STACK_16] = "die_mem_stack_16", - [MCPE_DIE_MEM_STACK_32] = "die_mem_stack_32", - [MCPE_DIE_MEM_STACK_112] = "die_mem_stack_112", - [MCPE_DIE_MEM_STACK_128] = "die_mem_stack_128", - [MCPE_DIE_MEM_STACK_144] = "die_mem_stack_144", - [MCPE_DIE_MEM_STACK_160] = "die_mem_stack_160", - [MCPE_NEW_MEM_STACK] = "new_mem_stack", - [MCPE_DIE_MEM_STACK] = "die_mem_stack", + [MCPE_LOADV_128_OR_256] = "LOADV_128_or_256", + [MCPE_LOADV_128_OR_256_SLOW1] = "LOADV_128_or_256-slow1", + [MCPE_LOADV_128_OR_256_SLOW2] = "LOADV_128_or_256-slow2", + [MCPE_LOADV64] = "LOADV64", + [MCPE_LOADV64_SLOW1] = "LOADV64-slow1", + [MCPE_LOADV64_SLOW2] = "LOADV64-slow2", + [MCPE_STOREV64] = "STOREV64", + [MCPE_STOREV64_SLOW1] = "STOREV64-slow1", + [MCPE_STOREV64_SLOW2] = "STOREV64-slow2", + [MCPE_STOREV64_SLOW3] = "STOREV64-slow3", + [MCPE_STOREV64_SLOW4] = "STOREV64-slow4", + [MCPE_LOADV32] = "LOADV32", + [MCPE_LOADV32_SLOW1] = "LOADV32-slow1", + [MCPE_LOADV32_SLOW2] = "LOADV32-slow2", + [MCPE_STOREV32] = "STOREV32", + [MCPE_STOREV32_SLOW1] = "STOREV32-slow1", + [MCPE_STOREV32_SLOW2] = "STOREV32-slow2", + [MCPE_STOREV32_SLOW3] = "STOREV32-slow3", + [MCPE_STOREV32_SLOW4] = "STOREV32-slow4", + [MCPE_LOADV16] = "LOADV16", + [MCPE_LOADV16_SLOW1] = "LOADV16-slow1", + [MCPE_LOADV16_SLOW2] = "LOADV16-slow2", + [MCPE_STOREV16] = "STOREV16", + [MCPE_STOREV16_SLOW1] = "STOREV16-slow1", + [MCPE_STOREV16_SLOW2] = "STOREV16-slow2", + [MCPE_STOREV16_SLOW3] = "STOREV16-slow3", + [MCPE_STOREV16_SLOW4] = "STOREV16-slow4", + [MCPE_LOADV8] = "LOADV8", + [MCPE_LOADV8_SLOW1] = "LOADV8-slow1", + [MCPE_LOADV8_SLOW2] = "LOADV8-slow2", + [MCPE_STOREV8] = "STOREV8", + [MCPE_STOREV8_SLOW1] = "STOREV8-slow1", + [MCPE_STOREV8_SLOW2] = "STOREV8-slow2", + [MCPE_STOREV8_SLOW3] = "STOREV8-slow3", + [MCPE_STOREV8_SLOW4] = "STOREV8-slow4", + [MCPE_NEW_MEM_STACK_4] = "new_mem_stack_4", + [MCPE_NEW_MEM_STACK_8] = "new_mem_stack_8", + [MCPE_NEW_MEM_STACK_12] = "new_mem_stack_12", + [MCPE_NEW_MEM_STACK_16] = "new_mem_stack_16", + [MCPE_NEW_MEM_STACK_32] = "new_mem_stack_32", + [MCPE_NEW_MEM_STACK_112] = "new_mem_stack_112", + [MCPE_NEW_MEM_STACK_128] = "new_mem_stack_128", + [MCPE_NEW_MEM_STACK_144] = "new_mem_stack_144", + [MCPE_NEW_MEM_STACK_160] = "new_mem_stack_160", + [MCPE_DIE_MEM_STACK_4] = "die_mem_stack_4", + [MCPE_DIE_MEM_STACK_8] = "die_mem_stack_8", + [MCPE_DIE_MEM_STACK_12] = "die_mem_stack_12", + [MCPE_DIE_MEM_STACK_16] = "die_mem_stack_16", + [MCPE_DIE_MEM_STACK_32] = "die_mem_stack_32", + [MCPE_DIE_MEM_STACK_112] = "die_mem_stack_112", + [MCPE_DIE_MEM_STACK_128] = "die_mem_stack_128", + [MCPE_DIE_MEM_STACK_144] = "die_mem_stack_144", + [MCPE_DIE_MEM_STACK_160] = "die_mem_stack_160", + [MCPE_NEW_MEM_STACK] = "new_mem_stack", + [MCPE_DIE_MEM_STACK] = "die_mem_stack", [MCPE_MAKE_STACK_UNINIT_W_O] = "MAKE_STACK_UNINIT_w_o", [MCPE_MAKE_STACK_UNINIT_NO_O] = "MAKE_STACK_UNINIT_no_o", [MCPE_MAKE_STACK_UNINIT_128_NO_O] = "MAKE_STACK_UNINIT_128_no_o", - [MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_16] - = "MAKE_STACK_UNINIT_128_no_o_aligned_16", - [MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_8] - = "MAKE_STACK_UNINIT_128_no_o_aligned_8", - [MCPE_MAKE_STACK_UNINIT_128_NO_O_SLOWCASE] - = "MAKE_STACK_UNINIT_128_no_o_slowcase", + [MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_16] = + "MAKE_STACK_UNINIT_128_no_o_aligned_16", + [MCPE_MAKE_STACK_UNINIT_128_NO_O_ALIGNED_8] = + "MAKE_STACK_UNINIT_128_no_o_aligned_8", + [MCPE_MAKE_STACK_UNINIT_128_NO_O_SLOWCASE] = + "MAKE_STACK_UNINIT_128_no_o_slowcase", }; -static void init_prof_mem ( void ) +static void init_prof_mem(void) { Int i, name_count = 0; @@ -7471,7 +7571,7 @@ static void init_prof_mem ( void ) tl_assert(name_count == MCPE_LAST); } -static void done_prof_mem ( void ) +static void done_prof_mem(void) { Int i, n; Bool spaced = False; @@ -7483,21 +7583,19 @@ static void done_prof_mem ( void ) if (MC_(event_ctr)[i] > 0) { spaced = False; ++n; - VG_(printf)( "prof mem event %3d: %11llu %s\n", - i, MC_(event_ctr)[i], - MC_(event_ctr_name)[i]); + VG_(printf)("prof mem event %3d: %11llu %s\n", i, MC_(event_ctr)[i], + MC_(event_ctr_name)[i]); } } } #else -static void init_prof_mem ( void ) { } -static void done_prof_mem ( void ) { } +static void init_prof_mem(void) {} +static void done_prof_mem(void) {} #endif - /*------------------------------------------------------------*/ /*--- Origin tracking stuff ---*/ /*------------------------------------------------------------*/ @@ -7506,43 +7604,46 @@ static void done_prof_mem ( void ) { } /*--- Origin tracking: load handlers ---*/ /*--------------------------------------------*/ -static INLINE UInt merge_origins ( UInt or1, UInt or2 ) { +static INLINE UInt merge_origins(UInt or1, UInt or2) +{ return or1 > or2 ? or1 : or2; } -UWord VG_REGPARM(1) MC_(helperc_b_load1)( Addr a ) { +UWord VG_REGPARM(1) MC_(helperc_b_load1)(Addr a) +{ OCacheLine* line; - UChar descr; - UWord lineoff = oc_line_offset(a); - UWord byteoff = a & 3; /* 0, 1, 2 or 3 */ + UChar descr; + UWord lineoff = oc_line_offset(a); + UWord byteoff = a & 3; /* 0, 1, 2 or 3 */ if (OC_ENABLE_ASSERTIONS) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); descr = line->u.main.descr[lineoff]; if (OC_ENABLE_ASSERTIONS) { tl_assert(descr < 0x10); } - if (LIKELY(0 == (descr & (1 << byteoff)))) { + if (LIKELY(0 == (descr & (1 << byteoff)))) { return 0; } else { return line->u.main.w32[lineoff]; } } -UWord VG_REGPARM(1) MC_(helperc_b_load2)( Addr a ) { +UWord VG_REGPARM(1) MC_(helperc_b_load2)(Addr a) +{ OCacheLine* line; - UChar descr; - UWord lineoff, byteoff; + UChar descr; + UWord lineoff, byteoff; if (UNLIKELY(a & 1)) { /* Handle misaligned case, slowly. */ - UInt oLo = (UInt)MC_(helperc_b_load1)( a + 0 ); - UInt oHi = (UInt)MC_(helperc_b_load1)( a + 1 ); + UInt oLo = (UInt)MC_(helperc_b_load1)(a + 0); + UInt oHi = (UInt)MC_(helperc_b_load1)(a + 1); return merge_origins(oLo, oHi); } @@ -7552,7 +7653,7 @@ UWord VG_REGPARM(1) MC_(helperc_b_load2)( Addr a ) { if (OC_ENABLE_ASSERTIONS) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); descr = line->u.main.descr[lineoff]; if (OC_ENABLE_ASSERTIONS) { @@ -7566,15 +7667,16 @@ UWord VG_REGPARM(1) MC_(helperc_b_load2)( Addr a ) { } } -UWord VG_REGPARM(1) MC_(helperc_b_load4)( Addr a ) { +UWord VG_REGPARM(1) MC_(helperc_b_load4)(Addr a) +{ OCacheLine* line; - UChar descr; - UWord lineoff; + UChar descr; + UWord lineoff; if (UNLIKELY(a & 3)) { /* Handle misaligned case, slowly. */ - UInt oLo = (UInt)MC_(helperc_b_load2)( a + 0 ); - UInt oHi = (UInt)MC_(helperc_b_load2)( a + 2 ); + UInt oLo = (UInt)MC_(helperc_b_load2)(a + 0); + UInt oHi = (UInt)MC_(helperc_b_load2)(a + 2); return merge_origins(oLo, oHi); } @@ -7583,7 +7685,7 @@ UWord VG_REGPARM(1) MC_(helperc_b_load4)( Addr a ) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); descr = line->u.main.descr[lineoff]; if (OC_ENABLE_ASSERTIONS) { @@ -7597,24 +7699,25 @@ UWord VG_REGPARM(1) MC_(helperc_b_load4)( Addr a ) { } } -UWord VG_REGPARM(1) MC_(helperc_b_load8)( Addr a ) { +UWord VG_REGPARM(1) MC_(helperc_b_load8)(Addr a) +{ OCacheLine* line; - UChar descrLo, descrHi, descr; - UWord lineoff; + UChar descrLo, descrHi, descr; + UWord lineoff; if (UNLIKELY(a & 7)) { /* Handle misaligned case, slowly. */ - UInt oLo = (UInt)MC_(helperc_b_load4)( a + 0 ); - UInt oHi = (UInt)MC_(helperc_b_load4)( a + 4 ); + UInt oLo = (UInt)MC_(helperc_b_load4)(a + 0); + UInt oHi = (UInt)MC_(helperc_b_load4)(a + 4); return merge_origins(oLo, oHi); } lineoff = oc_line_offset(a); if (OC_ENABLE_ASSERTIONS) { - tl_assert(lineoff == (lineoff & 6)); /*0,2,4,6*//*since 8-aligned*/ + tl_assert(lineoff == (lineoff & 6)); /*0,2,4,6*/ /*since 8-aligned*/ } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); descrLo = line->u.main.descr[lineoff + 0]; descrHi = line->u.main.descr[lineoff + 1]; @@ -7632,38 +7735,39 @@ UWord VG_REGPARM(1) MC_(helperc_b_load8)( Addr a ) { } } -UWord VG_REGPARM(1) MC_(helperc_b_load16)( Addr a ) { - UInt oLo = (UInt)MC_(helperc_b_load8)( a + 0 ); - UInt oHi = (UInt)MC_(helperc_b_load8)( a + 8 ); +UWord VG_REGPARM(1) MC_(helperc_b_load16)(Addr a) +{ + UInt oLo = (UInt)MC_(helperc_b_load8)(a + 0); + UInt oHi = (UInt)MC_(helperc_b_load8)(a + 8); UInt oBoth = merge_origins(oLo, oHi); return (UWord)oBoth; } -UWord VG_REGPARM(1) MC_(helperc_b_load32)( Addr a ) { - UInt oQ0 = (UInt)MC_(helperc_b_load8)( a + 0 ); - UInt oQ1 = (UInt)MC_(helperc_b_load8)( a + 8 ); - UInt oQ2 = (UInt)MC_(helperc_b_load8)( a + 16 ); - UInt oQ3 = (UInt)MC_(helperc_b_load8)( a + 24 ); - UInt oAll = merge_origins(merge_origins(oQ0, oQ1), - merge_origins(oQ2, oQ3)); +UWord VG_REGPARM(1) MC_(helperc_b_load32)(Addr a) +{ + UInt oQ0 = (UInt)MC_(helperc_b_load8)(a + 0); + UInt oQ1 = (UInt)MC_(helperc_b_load8)(a + 8); + UInt oQ2 = (UInt)MC_(helperc_b_load8)(a + 16); + UInt oQ3 = (UInt)MC_(helperc_b_load8)(a + 24); + UInt oAll = merge_origins(merge_origins(oQ0, oQ1), merge_origins(oQ2, oQ3)); return (UWord)oAll; } - /*--------------------------------------------*/ /*--- Origin tracking: store handlers ---*/ /*--------------------------------------------*/ -void VG_REGPARM(2) MC_(helperc_b_store1)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store1)(Addr a, UWord d32) +{ OCacheLine* line; - UWord lineoff = oc_line_offset(a); - UWord byteoff = a & 3; /* 0, 1, 2 or 3 */ + UWord lineoff = oc_line_offset(a); + UWord byteoff = a & 3; /* 0, 1, 2 or 3 */ if (OC_ENABLE_ASSERTIONS) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); #if OC_PRECISION_STORE if (LIKELY(d32 == 0)) { @@ -7680,7 +7784,7 @@ void VG_REGPARM(2) MC_(helperc_b_store1)( Addr a, UWord d32 ) { // but with some other origin. We can't represent both origins, so we // forget about the previous origin and install this one instead. line->u.main.descr[lineoff] = (1 << byteoff); - line->u.main.w32[lineoff] = d32; + line->u.main.w32[lineoff] = d32; } #else if (d32 == 0) { @@ -7692,14 +7796,15 @@ void VG_REGPARM(2) MC_(helperc_b_store1)( Addr a, UWord d32 ) { #endif } -void VG_REGPARM(2) MC_(helperc_b_store2)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store2)(Addr a, UWord d32) +{ OCacheLine* line; - UWord lineoff, byteoff; + UWord lineoff, byteoff; if (UNLIKELY(a & 1)) { /* Handle misaligned case, slowly. */ - MC_(helperc_b_store1)( a + 0, d32 ); - MC_(helperc_b_store1)( a + 1, d32 ); + MC_(helperc_b_store1)(a + 0, d32); + MC_(helperc_b_store1)(a + 1, d32); return; } @@ -7710,7 +7815,7 @@ void VG_REGPARM(2) MC_(helperc_b_store2)( Addr a, UWord d32 ) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); #if OC_PRECISION_STORE // Same logic as in the store1 case above. @@ -7721,7 +7826,7 @@ void VG_REGPARM(2) MC_(helperc_b_store2)( Addr a, UWord d32 ) { line->u.main.w32[lineoff] = d32; } else { line->u.main.descr[lineoff] = (3 << byteoff); - line->u.main.w32[lineoff] = d32; + line->u.main.w32[lineoff] = d32; } #else if (d32 == 0) { @@ -7733,14 +7838,15 @@ void VG_REGPARM(2) MC_(helperc_b_store2)( Addr a, UWord d32 ) { #endif } -void VG_REGPARM(2) MC_(helperc_b_store4)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store4)(Addr a, UWord d32) +{ OCacheLine* line; - UWord lineoff; + UWord lineoff; if (UNLIKELY(a & 3)) { /* Handle misaligned case, slowly. */ - MC_(helperc_b_store2)( a + 0, d32 ); - MC_(helperc_b_store2)( a + 2, d32 ); + MC_(helperc_b_store2)(a + 0, d32); + MC_(helperc_b_store2)(a + 2, d32); return; } @@ -7749,34 +7855,35 @@ void VG_REGPARM(2) MC_(helperc_b_store4)( Addr a, UWord d32 ) { tl_assert(lineoff >= 0 && lineoff < OC_W32S_PER_LINE); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); if (d32 == 0) { line->u.main.descr[lineoff] = 0; } else { line->u.main.descr[lineoff] = 0xF; - line->u.main.w32[lineoff] = d32; + line->u.main.w32[lineoff] = d32; } } -void VG_REGPARM(2) MC_(helperc_b_store8)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store8)(Addr a, UWord d32) +{ STATIC_ASSERT(OC_W32S_PER_LINE == 8); OCacheLine* line; - UWord lineoff; + UWord lineoff; if (UNLIKELY(a & 7)) { /* Handle misaligned case, slowly. */ - MC_(helperc_b_store4)( a + 0, d32 ); - MC_(helperc_b_store4)( a + 4, d32 ); + MC_(helperc_b_store4)(a + 0, d32); + MC_(helperc_b_store4)(a + 4, d32); return; } lineoff = oc_line_offset(a); if (OC_ENABLE_ASSERTIONS) { - tl_assert(lineoff == (lineoff & 6)); /*0,2,4,6*//*since 8-aligned*/ + tl_assert(lineoff == (lineoff & 6)); /*0,2,4,6*/ /*since 8-aligned*/ } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); if (d32 == 0) { line->u.main.descr[lineoff + 0] = 0; @@ -7784,29 +7891,30 @@ void VG_REGPARM(2) MC_(helperc_b_store8)( Addr a, UWord d32 ) { } else { line->u.main.descr[lineoff + 0] = 0xF; line->u.main.descr[lineoff + 1] = 0xF; - line->u.main.w32[lineoff + 0] = d32; - line->u.main.w32[lineoff + 1] = d32; + line->u.main.w32[lineoff + 0] = d32; + line->u.main.w32[lineoff + 1] = d32; } } -void VG_REGPARM(2) MC_(helperc_b_store16)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store16)(Addr a, UWord d32) +{ STATIC_ASSERT(OC_W32S_PER_LINE == 8); OCacheLine* line; - UWord lineoff; + UWord lineoff; if (UNLIKELY(a & 15)) { /* Handle misaligned case, slowly. */ - MC_(helperc_b_store8)( a + 0, d32 ); - MC_(helperc_b_store8)( a + 8, d32 ); + MC_(helperc_b_store8)(a + 0, d32); + MC_(helperc_b_store8)(a + 8, d32); return; } lineoff = oc_line_offset(a); if (OC_ENABLE_ASSERTIONS) { - tl_assert(lineoff == (lineoff & 4)); /*0,4*//*since 16-aligned*/ + tl_assert(lineoff == (lineoff & 4)); /*0,4*/ /*since 16-aligned*/ } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); if (d32 == 0) { line->u.main.descr[lineoff + 0] = 0; @@ -7818,22 +7926,23 @@ void VG_REGPARM(2) MC_(helperc_b_store16)( Addr a, UWord d32 ) { line->u.main.descr[lineoff + 1] = 0xF; line->u.main.descr[lineoff + 2] = 0xF; line->u.main.descr[lineoff + 3] = 0xF; - line->u.main.w32[lineoff + 0] = d32; - line->u.main.w32[lineoff + 1] = d32; - line->u.main.w32[lineoff + 2] = d32; - line->u.main.w32[lineoff + 3] = d32; + line->u.main.w32[lineoff + 0] = d32; + line->u.main.w32[lineoff + 1] = d32; + line->u.main.w32[lineoff + 2] = d32; + line->u.main.w32[lineoff + 3] = d32; } } -void VG_REGPARM(2) MC_(helperc_b_store32)( Addr a, UWord d32 ) { +void VG_REGPARM(2) MC_(helperc_b_store32)(Addr a, UWord d32) +{ STATIC_ASSERT(OC_W32S_PER_LINE == 8); OCacheLine* line; - UWord lineoff; + UWord lineoff; if (UNLIKELY(a & 31)) { /* Handle misaligned case, slowly. */ - MC_(helperc_b_store16)( a + 0, d32 ); - MC_(helperc_b_store16)( a + 16, d32 ); + MC_(helperc_b_store16)(a + 0, d32); + MC_(helperc_b_store16)(a + 16, d32); return; } @@ -7842,7 +7951,7 @@ void VG_REGPARM(2) MC_(helperc_b_store32)( Addr a, UWord d32 ) { tl_assert(lineoff == 0); } - line = find_OCacheLine( a ); + line = find_OCacheLine(a); if (d32 == 0) { line->u.main.descr[0] = 0; @@ -7862,18 +7971,17 @@ void VG_REGPARM(2) MC_(helperc_b_store32)( Addr a, UWord d32 ) { line->u.main.descr[5] = 0xF; line->u.main.descr[6] = 0xF; line->u.main.descr[7] = 0xF; - line->u.main.w32[0] = d32; - line->u.main.w32[1] = d32; - line->u.main.w32[2] = d32; - line->u.main.w32[3] = d32; - line->u.main.w32[4] = d32; - line->u.main.w32[5] = d32; - line->u.main.w32[6] = d32; - line->u.main.w32[7] = d32; + line->u.main.w32[0] = d32; + line->u.main.w32[1] = d32; + line->u.main.w32[2] = d32; + line->u.main.w32[3] = d32; + line->u.main.w32[4] = d32; + line->u.main.w32[5] = d32; + line->u.main.w32[6] = d32; + line->u.main.w32[7] = d32; } } - /*--------------------------------------------*/ /*--- Origin tracking: sarp handlers ---*/ /*--------------------------------------------*/ @@ -7881,138 +7989,139 @@ void VG_REGPARM(2) MC_(helperc_b_store32)( Addr a, UWord d32 ) { // We may get asked to do very large SARPs (bug 446103), hence it is important // to process 32-byte chunks at a time when possible. -__attribute__((noinline)) -static void ocache_sarp_Set_Origins ( Addr a, UWord len, UInt otag ) { +__attribute__((noinline)) static void +ocache_sarp_Set_Origins(Addr a, UWord len, UInt otag) +{ if ((a & 1) && len >= 1) { - MC_(helperc_b_store1)( a, otag ); + MC_(helperc_b_store1)(a, otag); a++; len--; } if ((a & 2) && len >= 2) { - MC_(helperc_b_store2)( a, otag ); + MC_(helperc_b_store2)(a, otag); a += 2; len -= 2; } if ((a & 4) && len >= 4) { - MC_(helperc_b_store4)( a, otag ); + MC_(helperc_b_store4)(a, otag); a += 4; len -= 4; } if ((a & 8) && len >= 8) { - MC_(helperc_b_store8)( a, otag ); + MC_(helperc_b_store8)(a, otag); a += 8; len -= 8; } if ((a & 16) && len >= 16) { - MC_(helperc_b_store16)( a, otag ); + MC_(helperc_b_store16)(a, otag); a += 16; len -= 16; } if (len >= 32) { tl_assert(0 == (a & 31)); while (len >= 32) { - MC_(helperc_b_store32)( a, otag ); + MC_(helperc_b_store32)(a, otag); a += 32; len -= 32; } } if (len >= 16) { - MC_(helperc_b_store16)( a, otag ); + MC_(helperc_b_store16)(a, otag); a += 16; len -= 16; } if (len >= 8) { - MC_(helperc_b_store8)( a, otag ); + MC_(helperc_b_store8)(a, otag); a += 8; len -= 8; } if (len >= 4) { - MC_(helperc_b_store4)( a, otag ); + MC_(helperc_b_store4)(a, otag); a += 4; len -= 4; } if (len >= 2) { - MC_(helperc_b_store2)( a, otag ); + MC_(helperc_b_store2)(a, otag); a += 2; len -= 2; } if (len >= 1) { - MC_(helperc_b_store1)( a, otag ); - //a++; + MC_(helperc_b_store1)(a, otag); + // a++; len--; } tl_assert(len == 0); } -__attribute__((noinline)) -static void ocache_sarp_Clear_Origins ( Addr a, UWord len ) { +__attribute__((noinline)) static void ocache_sarp_Clear_Origins(Addr a, + UWord len) +{ if ((a & 1) && len >= 1) { - MC_(helperc_b_store1)( a, 0 ); + MC_(helperc_b_store1)(a, 0); a++; len--; } if ((a & 2) && len >= 2) { - MC_(helperc_b_store2)( a, 0 ); + MC_(helperc_b_store2)(a, 0); a += 2; len -= 2; } if ((a & 4) && len >= 4) { - MC_(helperc_b_store4)( a, 0 ); + MC_(helperc_b_store4)(a, 0); a += 4; len -= 4; } if ((a & 8) && len >= 8) { - MC_(helperc_b_store8)( a, 0 ); + MC_(helperc_b_store8)(a, 0); a += 8; len -= 8; } if ((a & 16) && len >= 16) { - MC_(helperc_b_store16)( a, 0 ); + MC_(helperc_b_store16)(a, 0); a += 16; len -= 16; } if (len >= 32) { tl_assert(0 == (a & 31)); while (len >= 32) { - MC_(helperc_b_store32)( a, 0 ); + MC_(helperc_b_store32)(a, 0); a += 32; len -= 32; } } if (len >= 16) { - MC_(helperc_b_store16)( a, 0 ); + MC_(helperc_b_store16)(a, 0); a += 16; len -= 16; } if (len >= 8) { - MC_(helperc_b_store8)( a, 0 ); + MC_(helperc_b_store8)(a, 0); a += 8; len -= 8; } if (len >= 4) { - MC_(helperc_b_store4)( a, 0 ); + MC_(helperc_b_store4)(a, 0); a += 4; len -= 4; } if (len >= 2) { - MC_(helperc_b_store2)( a, 0 ); + MC_(helperc_b_store2)(a, 0); a += 2; len -= 2; } if (len >= 1) { - MC_(helperc_b_store1)( a, 0 ); - //a++; + MC_(helperc_b_store1)(a, 0); + // a++; len--; } tl_assert(len == 0); } - /*------------------------------------------------------------*/ /*--- Setup and finalisation ---*/ /*------------------------------------------------------------*/ -static void mc_post_clo_init ( void ) +static void mc_post_clo_init(void) { /* If we've been asked to emit XML, mash around various other options so as to constrain the output somewhat. */ @@ -8021,56 +8130,55 @@ static void mc_post_clo_init ( void ) MC_(clo_leak_check) = LC_Full; } - if (MC_(clo_freelist_big_blocks) >= MC_(clo_freelist_vol) - && VG_(clo_verbosity) == 1 && !VG_(clo_xml)) { + if (MC_(clo_freelist_big_blocks) >= + MC_(clo_freelist_vol)&& VG_(clo_verbosity) == + 1 && + !VG_(clo_xml)) { VG_(message)(Vg_UserMsg, "Warning: --freelist-big-blocks value %lld has no effect\n" "as it is >= to --freelist-vol value %lld\n", - MC_(clo_freelist_big_blocks), - MC_(clo_freelist_vol)); + MC_(clo_freelist_big_blocks), MC_(clo_freelist_vol)); } - if (MC_(clo_workaround_gcc296_bugs) - && VG_(clo_verbosity) == 1 && !VG_(clo_xml)) { - VG_(umsg)( - "Warning: --workaround-gcc296-bugs=yes is deprecated.\n" - "Warning: Instead use: --ignore-range-below-sp=1024-1\n" - "\n" - ); + if (MC_(clo_workaround_gcc296_bugs)&& VG_(clo_verbosity) == 1 && + !VG_(clo_xml)) { + VG_(umsg)("Warning: --workaround-gcc296-bugs=yes is deprecated.\n" + "Warning: Instead use: --ignore-range-below-sp=1024-1\n" + "\n"); } - tl_assert( MC_(clo_mc_level) >= 1 && MC_(clo_mc_level) <= 3 ); + tl_assert(MC_(clo_mc_level) >= 1 && MC_(clo_mc_level) <= 3); if (MC_(clo_mc_level) == 3) { /* We're doing origin tracking. */ -# ifdef PERF_FAST_STACK - VG_(track_new_mem_stack_4_w_ECU) ( mc_new_mem_stack_4_w_ECU ); - VG_(track_new_mem_stack_8_w_ECU) ( mc_new_mem_stack_8_w_ECU ); - VG_(track_new_mem_stack_12_w_ECU) ( mc_new_mem_stack_12_w_ECU ); - VG_(track_new_mem_stack_16_w_ECU) ( mc_new_mem_stack_16_w_ECU ); - VG_(track_new_mem_stack_32_w_ECU) ( mc_new_mem_stack_32_w_ECU ); - VG_(track_new_mem_stack_112_w_ECU) ( mc_new_mem_stack_112_w_ECU ); - VG_(track_new_mem_stack_128_w_ECU) ( mc_new_mem_stack_128_w_ECU ); - VG_(track_new_mem_stack_144_w_ECU) ( mc_new_mem_stack_144_w_ECU ); - VG_(track_new_mem_stack_160_w_ECU) ( mc_new_mem_stack_160_w_ECU ); -# endif - VG_(track_new_mem_stack_w_ECU) ( mc_new_mem_stack_w_ECU ); - VG_(track_new_mem_stack_signal) ( mc_new_mem_w_tid_make_ECU ); +#ifdef PERF_FAST_STACK + VG_(track_new_mem_stack_4_w_ECU)(mc_new_mem_stack_4_w_ECU); + VG_(track_new_mem_stack_8_w_ECU)(mc_new_mem_stack_8_w_ECU); + VG_(track_new_mem_stack_12_w_ECU)(mc_new_mem_stack_12_w_ECU); + VG_(track_new_mem_stack_16_w_ECU)(mc_new_mem_stack_16_w_ECU); + VG_(track_new_mem_stack_32_w_ECU)(mc_new_mem_stack_32_w_ECU); + VG_(track_new_mem_stack_112_w_ECU)(mc_new_mem_stack_112_w_ECU); + VG_(track_new_mem_stack_128_w_ECU)(mc_new_mem_stack_128_w_ECU); + VG_(track_new_mem_stack_144_w_ECU)(mc_new_mem_stack_144_w_ECU); + VG_(track_new_mem_stack_160_w_ECU)(mc_new_mem_stack_160_w_ECU); +#endif + VG_(track_new_mem_stack_w_ECU)(mc_new_mem_stack_w_ECU); + VG_(track_new_mem_stack_signal)(mc_new_mem_w_tid_make_ECU); } else { /* Not doing origin tracking */ -# ifdef PERF_FAST_STACK - VG_(track_new_mem_stack_4) ( mc_new_mem_stack_4 ); - VG_(track_new_mem_stack_8) ( mc_new_mem_stack_8 ); - VG_(track_new_mem_stack_12) ( mc_new_mem_stack_12 ); - VG_(track_new_mem_stack_16) ( mc_new_mem_stack_16 ); - VG_(track_new_mem_stack_32) ( mc_new_mem_stack_32 ); - VG_(track_new_mem_stack_112) ( mc_new_mem_stack_112 ); - VG_(track_new_mem_stack_128) ( mc_new_mem_stack_128 ); - VG_(track_new_mem_stack_144) ( mc_new_mem_stack_144 ); - VG_(track_new_mem_stack_160) ( mc_new_mem_stack_160 ); -# endif - VG_(track_new_mem_stack) ( mc_new_mem_stack ); - VG_(track_new_mem_stack_signal) ( mc_new_mem_w_tid_no_ECU ); +#ifdef PERF_FAST_STACK + VG_(track_new_mem_stack_4)(mc_new_mem_stack_4); + VG_(track_new_mem_stack_8)(mc_new_mem_stack_8); + VG_(track_new_mem_stack_12)(mc_new_mem_stack_12); + VG_(track_new_mem_stack_16)(mc_new_mem_stack_16); + VG_(track_new_mem_stack_32)(mc_new_mem_stack_32); + VG_(track_new_mem_stack_112)(mc_new_mem_stack_112); + VG_(track_new_mem_stack_128)(mc_new_mem_stack_128); + VG_(track_new_mem_stack_144)(mc_new_mem_stack_144); + VG_(track_new_mem_stack_160)(mc_new_mem_stack_160); +#endif + VG_(track_new_mem_stack)(mc_new_mem_stack); + VG_(track_new_mem_stack_signal)(mc_new_mem_w_tid_no_ECU); } // We assume that brk()/sbrk() does not initialise new memory. Is this @@ -8123,89 +8231,80 @@ static void mc_post_clo_init ( void ) // directly with brk(), not with sbrk(), perhaps it would be reasonable to // just mark all memory it allocates as defined.] // -# if !defined(VGO_solaris) +#if !defined(VGO_solaris) if (MC_(clo_mc_level) == 3) - VG_(track_new_mem_brk) ( mc_new_mem_w_tid_make_ECU ); + VG_(track_new_mem_brk)(mc_new_mem_w_tid_make_ECU); else - VG_(track_new_mem_brk) ( mc_new_mem_w_tid_no_ECU ); -# else + VG_(track_new_mem_brk)(mc_new_mem_w_tid_no_ECU); +#else // On Solaris, brk memory has to be marked as defined, otherwise we get // many false positives. - VG_(track_new_mem_brk) ( make_mem_defined_w_tid ); -# endif + VG_(track_new_mem_brk)(make_mem_defined_w_tid); +#endif /* This origin tracking cache is huge (~100M), so only initialise if we need it. */ if (MC_(clo_mc_level) >= 3) { init_OCache(); tl_assert(ocacheL1 != NULL); - for (UInt i = 0; i < 4096; i++ ) { + for (UInt i = 0; i < 4096; i++) { tl_assert(ocachesL2[i] != NULL); } } else { tl_assert(ocacheL1 == NULL); - for (UInt i = 0; i < 4096; i++ ) { + for (UInt i = 0; i < 4096; i++) { tl_assert(ocachesL2[i] == NULL); } } - MC_(chunk_poolalloc) = VG_(newPA) - (sizeof(MC_Chunk) + MC_(n_where_pointers)() * sizeof(ExeContext*), - 1000, - VG_(malloc), - "mc.cMC.1 (MC_Chunk pools)", - VG_(free)); + MC_(chunk_poolalloc) = VG_(newPA)( + sizeof(MC_Chunk) + MC_(n_where_pointers)() * sizeof(ExeContext*), 1000, + VG_(malloc), "mc.cMC.1 (MC_Chunk pools)", VG_(free)); /* Do not check definedness of guest state if --undef-value-errors=no */ if (MC_(clo_mc_level) >= 2) - VG_(track_pre_reg_read) ( mc_pre_reg_read ); + VG_(track_pre_reg_read)(mc_pre_reg_read); if (VG_(clo_xtree_memory) == Vg_XTMemory_Full) { - if (MC_(clo_keep_stacktraces) == KS_none - || MC_(clo_keep_stacktraces) == KS_free) + if (MC_(clo_keep_stacktraces) == KS_none || + MC_(clo_keep_stacktraces) == KS_free) VG_(fmsg_bad_option)("--keep-stacktraces", "To use --xtree-memory=full, you must" " keep at least the alloc stacktrace\n"); // Activate full xtree memory profiling. VG_(XTMemory_Full_init)(VG_(XT_filter_1top_and_maybe_below_main)); } - } static void print_SM_info(const HChar* type, Int n_SMs) { - VG_(message)(Vg_DebugMsg, - " memcheck: SMs: %s = %d (%luk, %luM)\n", - type, - n_SMs, - n_SMs * sizeof(SecMap) / 1024UL, - n_SMs * sizeof(SecMap) / (1024 * 1024UL) ); + VG_(message)(Vg_DebugMsg, " memcheck: SMs: %s = %d (%luk, %luM)\n", type, + n_SMs, n_SMs * sizeof(SecMap) / 1024UL, + n_SMs * sizeof(SecMap) / (1024 * 1024UL)); } -static void mc_print_stats (void) +static void mc_print_stats(void) { SizeT max_secVBit_szB, max_SMs_szB, max_shmem_szB; VG_(message)(Vg_DebugMsg, " memcheck: freelist: vol %lld length %lld\n", VG_(free_queue_volume), VG_(free_queue_length)); VG_(message)(Vg_DebugMsg, - " memcheck: sanity checks: %d cheap, %d expensive\n", - n_sanity_cheap, n_sanity_expensive ); - VG_(message)(Vg_DebugMsg, + " memcheck: sanity checks: %d cheap, %d expensive\n", + n_sanity_cheap, n_sanity_expensive); + VG_(message)( + Vg_DebugMsg, " memcheck: auxmaps: %llu auxmap entries (%lluk, %lluM) in use\n", - n_auxmap_L2_nodes, - n_auxmap_L2_nodes * 64, - n_auxmap_L2_nodes / 16 ); - VG_(message)(Vg_DebugMsg, + n_auxmap_L2_nodes, n_auxmap_L2_nodes * 64, n_auxmap_L2_nodes / 16); + VG_(message)( + Vg_DebugMsg, " memcheck: auxmaps_L1: %llu searches, %llu cmps, ratio %llu:10\n", n_auxmap_L1_searches, n_auxmap_L1_cmps, - (10ULL * n_auxmap_L1_cmps) - / (n_auxmap_L1_searches ? n_auxmap_L1_searches : 1) - ); + (10ULL * n_auxmap_L1_cmps) / + (n_auxmap_L1_searches ? n_auxmap_L1_searches : 1)); VG_(message)(Vg_DebugMsg, - " memcheck: auxmaps_L2: %llu searches, %llu nodes\n", - n_auxmap_L2_searches, n_auxmap_L2_nodes - ); + " memcheck: auxmaps_L2: %llu searches, %llu nodes\n", + n_auxmap_L2_searches, n_auxmap_L2_nodes); print_SM_info("n_issued ", n_issued_SMs); print_SM_info("n_deissued ", n_deissued_SMs); @@ -8222,107 +8321,91 @@ static void mc_print_stats (void) // Note that the pool allocator has some additional small overhead // which is not counted in the below. // Hardwiring this logic sucks, but I don't see how else to do it. - max_secVBit_szB = max_secVBit_nodes * - (3*sizeof(Word) + VG_ROUNDUP(sizeof(SecVBitNode), sizeof(void*))); - max_shmem_szB = sizeof(primary_map) + max_SMs_szB + max_secVBit_szB; + max_secVBit_szB = + max_secVBit_nodes * + (3 * sizeof(Word) + VG_ROUNDUP(sizeof(SecVBitNode), sizeof(void*))); + max_shmem_szB = sizeof(primary_map) + max_SMs_szB + max_secVBit_szB; VG_(message)(Vg_DebugMsg, - " memcheck: max sec V bit nodes: %d (%luk, %luM)\n", - max_secVBit_nodes, max_secVBit_szB / 1024, - max_secVBit_szB / (1024 * 1024)); - VG_(message)(Vg_DebugMsg, + " memcheck: max sec V bit nodes: %d (%luk, %luM)\n", + max_secVBit_nodes, max_secVBit_szB / 1024, + max_secVBit_szB / (1024 * 1024)); + VG_(message)( + Vg_DebugMsg, " memcheck: set_sec_vbits8 calls: %llu (new: %llu, updates: %llu)\n", - sec_vbits_new_nodes + sec_vbits_updates, - sec_vbits_new_nodes, sec_vbits_updates ); - VG_(message)(Vg_DebugMsg, - " memcheck: max shadow mem size: %luk, %luM\n", - max_shmem_szB / 1024, max_shmem_szB / (1024 * 1024)); + sec_vbits_new_nodes + sec_vbits_updates, sec_vbits_new_nodes, + sec_vbits_updates); + VG_(message)(Vg_DebugMsg, " memcheck: max shadow mem size: %luk, %luM\n", + max_shmem_szB / 1024, max_shmem_szB / (1024 * 1024)); if (MC_(clo_mc_level) >= 3) { - VG_(message)(Vg_DebugMsg, - " ocacheL1: %'14lu refs %'14lu misses (%'lu lossage)\n", - stats_ocacheL1_find, - stats_ocacheL1_misses, - stats_ocacheL1_lossage ); - VG_(message)(Vg_DebugMsg, - " ocacheL1: %'14lu at 0 %'14lu at 1\n", - stats_ocacheL1_find - stats_ocacheL1_misses - - stats_ocacheL1_found_at_1 - - stats_ocacheL1_found_at_N, - stats_ocacheL1_found_at_1 ); - VG_(message)(Vg_DebugMsg, - " ocacheL1: %'14lu at 2+ %'14lu move-fwds\n", - stats_ocacheL1_found_at_N, - stats_ocacheL1_movefwds ); - VG_(message)(Vg_DebugMsg, - " ocacheL1: %'14lu sizeB %'14d useful\n", + VG_(message)( + Vg_DebugMsg, " ocacheL1: %'14lu refs %'14lu misses (%'lu lossage)\n", + stats_ocacheL1_find, stats_ocacheL1_misses, stats_ocacheL1_lossage); + VG_(message)(Vg_DebugMsg, " ocacheL1: %'14lu at 0 %'14lu at 1\n", + stats_ocacheL1_find - stats_ocacheL1_misses - + stats_ocacheL1_found_at_1 - stats_ocacheL1_found_at_N, + stats_ocacheL1_found_at_1); + VG_(message)(Vg_DebugMsg, " ocacheL1: %'14lu at 2+ %'14lu move-fwds\n", + stats_ocacheL1_found_at_N, stats_ocacheL1_movefwds); + VG_(message)(Vg_DebugMsg, " ocacheL1: %'14lu sizeB %'14d useful\n", (SizeT)sizeof(OCache), - 4 * OC_W32S_PER_LINE * OC_LINES_PER_SET * OC_N_SETS ); - VG_(message)(Vg_DebugMsg, - " ocacheL2: %'14lu finds %'14lu misses\n", - stats__ocacheL2_finds, - stats__ocacheL2_misses ); - VG_(message)(Vg_DebugMsg, - " ocacheL2: %'14lu adds %'14lu dels\n", - stats__ocacheL2_adds, - stats__ocacheL2_dels ); + 4 * OC_W32S_PER_LINE * OC_LINES_PER_SET * OC_N_SETS); + VG_(message)(Vg_DebugMsg, " ocacheL2: %'14lu finds %'14lu misses\n", + stats__ocacheL2_finds, stats__ocacheL2_misses); + VG_(message)(Vg_DebugMsg, " ocacheL2: %'14lu adds %'14lu dels\n", + stats__ocacheL2_adds, stats__ocacheL2_dels); VG_(message)(Vg_DebugMsg, " ocacheL2: %'9lu max nodes %'9lu curr nodes\n", - stats__ocacheL2_n_nodes_max, - stats__ocacheL2_n_nodes ); - VG_(message)(Vg_DebugMsg, - " niacache: %'12lu refs %'12lu misses\n", + stats__ocacheL2_n_nodes_max, stats__ocacheL2_n_nodes); + VG_(message)(Vg_DebugMsg, " niacache: %'12lu refs %'12lu misses\n", stats__nia_cache_queries, stats__nia_cache_misses); } else { tl_assert(ocacheL1 == NULL); - for (UInt i = 0; i < 4096; i++ ) { + for (UInt i = 0; i < 4096; i++) { tl_assert(ocachesL2[1] == NULL); } } } - -static void mc_fini ( Int exitcode ) +static void mc_fini(Int exitcode) { - MC_(xtmemory_report) (VG_(clo_xtree_memory_file), True); + MC_(xtmemory_report)(VG_(clo_xtree_memory_file), True); MC_(print_malloc_stats)(); if (MC_(clo_leak_check) != LC_Off) { LeakCheckParams lcp; - HChar* xt_filename = NULL; - lcp.mode = MC_(clo_leak_check); - lcp.show_leak_kinds = MC_(clo_show_leak_kinds); - lcp.heuristics = MC_(clo_leak_check_heuristics); - lcp.errors_for_leak_kinds = MC_(clo_error_for_leak_kinds); - lcp.deltamode = LCD_Any; - lcp.max_loss_records_output = 999999999; + HChar* xt_filename = NULL; + lcp.mode = MC_(clo_leak_check); + lcp.show_leak_kinds = MC_(clo_show_leak_kinds); + lcp.heuristics = MC_(clo_leak_check_heuristics); + lcp.errors_for_leak_kinds = MC_(clo_error_for_leak_kinds); + lcp.deltamode = LCD_Any; + lcp.max_loss_records_output = 999999999; lcp.requested_by_monitor_command = False; if (MC_(clo_xtree_leak)) { - xt_filename = VG_(expand_file_name)("--xtree-leak-file", + xt_filename = VG_(expand_file_name)("--xtree-leak-file", MC_(clo_xtree_leak_file)); - lcp.xt_filename = xt_filename; - lcp.mode = LC_Full; + lcp.xt_filename = xt_filename; + lcp.mode = LC_Full; lcp.show_leak_kinds = MC_(all_Reachedness)(); - } - else + } else lcp.xt_filename = NULL; - MC_(detect_memory_leaks)(1/*bogus ThreadId*/, &lcp); + MC_(detect_memory_leaks)(1 /*bogus ThreadId*/, &lcp); if (MC_(clo_xtree_leak)) VG_(free)(xt_filename); } else { if (VG_(clo_verbosity) == 1 && !VG_(clo_xml)) { VG_(umsg)( "For a detailed leak analysis, rerun with: --leak-check=full\n" - "\n" - ); + "\n"); } } - if (MC_(any_value_errors) && !VG_(clo_xml) && VG_(clo_verbosity) >= 1 - && MC_(clo_mc_level) == 2) { - VG_(message)(Vg_UserMsg, - "Use --track-origins=yes to see where " - "uninitialised values come from\n"); + if (MC_(any_value_errors)&& !VG_(clo_xml)&& VG_(clo_verbosity) >= 1 && + MC_(clo_mc_level) == 2) { + VG_(message)(Vg_UserMsg, "Use --track-origins=yes to see where " + "uninitialised values come from\n"); } /* Print a warning if any client-request generated ignore-ranges @@ -8338,25 +8421,23 @@ static void mc_fini ( Int exitcode ) UWord val = IAR_INVALID; UWord key_min = ~(UWord)0; UWord key_max = (UWord)0; - VG_(indexRangeMap)( &key_min, &key_max, &val, - gIgnoredAddressRanges, i ); + VG_(indexRangeMap)(&key_min, &key_max, &val, gIgnoredAddressRanges, i); if (val != IAR_ClientReq) - continue; + continue; /* Print the offending range. Also, if it is the first, print a banner before it. */ nBad++; if (nBad == 1) { VG_(umsg)( - "WARNING: exiting program has the following client-requested\n" - "WARNING: address error disablement range(s) still in force,\n" - "WARNING: " - "possibly as a result of some mistake in the use of the\n" - "WARNING: " - "VALGRIND_{DISABLE,ENABLE}_ERROR_REPORTING_IN_RANGE macros.\n" - ); + "WARNING: exiting program has the following client-requested\n" + "WARNING: address error disablement range(s) still in force,\n" + "WARNING: " + "possibly as a result of some mistake in the use of the\n" + "WARNING: " + "VALGRIND_{DISABLE,ENABLE}_ERROR_REPORTING_IN_RANGE macros.\n"); } - VG_(umsg)(" [%u] 0x%016lx-0x%016lx %s\n", - i, key_min, key_max, showIARKind(val)); + VG_(umsg)(" [%u] 0x%016lx-0x%016lx %s\n", i, key_min, key_max, + showIARKind(val)); } } @@ -8366,143 +8447,128 @@ static void mc_fini ( Int exitcode ) mc_print_stats(); if (0) { - VG_(message)(Vg_DebugMsg, - "------ Valgrind's client block stats follow ---------------\n" ); + VG_(message)( + Vg_DebugMsg, + "------ Valgrind's client block stats follow ---------------\n"); show_client_block_stats(); } } /* mark the given addr/len unaddressable for watchpoint implementation The PointKind will be handled at access time */ -static Bool mc_mark_unaddressable_for_watchpoint (PointKind kind, Bool insert, - Addr addr, SizeT len) +static Bool mc_mark_unaddressable_for_watchpoint(PointKind kind, + Bool insert, + Addr addr, + SizeT len) { /* GDBTD this is somewhat fishy. We might rather have to save the previous accessibility and definedness in gdbserver so as to allow restoring it properly. Currently, we assume that the user only watches things which are properly addressable and defined */ if (insert) - MC_(make_mem_noaccess) (addr, len); + MC_(make_mem_noaccess)(addr, len); else - MC_(make_mem_defined) (addr, len); + MC_(make_mem_defined)(addr, len); return True; } static void mc_pre_clo_init(void) { - VG_(details_name) ("Memcheck"); - VG_(details_version) (NULL); - VG_(details_description) ("a memory error detector"); + VG_(details_name)("Memcheck"); + VG_(details_version)(NULL); + VG_(details_description)("a memory error detector"); VG_(details_copyright_author)( "Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al."); - VG_(details_bug_reports_to) (VG_BUGS_TO); - VG_(details_avg_translation_sizeB) ( 640 ); - - VG_(basic_tool_funcs) (mc_post_clo_init, - MC_(instrument), - mc_fini); - - VG_(needs_final_IR_tidy_pass) ( MC_(final_tidy) ); - - - VG_(needs_core_errors) (); - VG_(needs_tool_errors) (MC_(eq_Error), - MC_(before_pp_Error), - MC_(pp_Error), - True,/*show TIDs for errors*/ - MC_(update_Error_extra), - MC_(is_recognised_suppression), - MC_(read_extra_suppression_info), - MC_(error_matches_suppression), - MC_(get_error_name), - MC_(get_extra_suppression_info), - MC_(print_extra_suppression_use), - MC_(update_extra_suppression_use)); - VG_(needs_libc_freeres) (); - VG_(needs_cxx_freeres) (); - VG_(needs_command_line_options)(mc_process_cmd_line_options, - mc_print_usage, + VG_(details_bug_reports_to)(VG_BUGS_TO); + VG_(details_avg_translation_sizeB)(640); + + VG_(basic_tool_funcs)(mc_post_clo_init, MC_(instrument), mc_fini); + + VG_(needs_final_IR_tidy_pass)(MC_(final_tidy)); + + VG_(needs_core_errors)(); + VG_(needs_tool_errors)( + MC_(eq_Error), MC_(before_pp_Error), MC_(pp_Error), + True, /*show TIDs for errors*/ + MC_(update_Error_extra), MC_(is_recognised_suppression), + MC_(read_extra_suppression_info), MC_(error_matches_suppression), + MC_(get_error_name), MC_(get_extra_suppression_info), + MC_(print_extra_suppression_use), MC_(update_extra_suppression_use)); + VG_(needs_libc_freeres)(); + VG_(needs_cxx_freeres)(); + VG_(needs_command_line_options)(mc_process_cmd_line_options, mc_print_usage, mc_print_debug_usage); - VG_(needs_client_requests) (mc_handle_client_request); - VG_(needs_sanity_checks) (mc_cheap_sanity_check, - mc_expensive_sanity_check); - VG_(needs_print_stats) (mc_print_stats); - VG_(needs_info_location) (MC_(pp_describe_addr)); - VG_(needs_malloc_replacement) (MC_(malloc), - MC_(__builtin_new), - MC_(__builtin_new_aligned), - MC_(__builtin_vec_new), - MC_(__builtin_vec_new_aligned), - MC_(memalign), - MC_(calloc), - MC_(free), - MC_(__builtin_delete), - MC_(__builtin_delete_aligned), - MC_(__builtin_vec_delete), - MC_(__builtin_vec_delete_aligned), - MC_(realloc), - MC_(malloc_usable_size), - MC_MALLOC_DEFAULT_REDZONE_SZB ); + VG_(needs_client_requests)(mc_handle_client_request); + VG_(needs_sanity_checks)(mc_cheap_sanity_check, mc_expensive_sanity_check); + VG_(needs_print_stats)(mc_print_stats); + VG_(needs_info_location)(MC_(pp_describe_addr)); + VG_(needs_malloc_replacement)( + MC_(malloc), MC_(__builtin_new), MC_(__builtin_new_aligned), + MC_(__builtin_vec_new), MC_(__builtin_vec_new_aligned), MC_(memalign), + MC_(calloc), MC_(free), MC_(__builtin_delete), + MC_(__builtin_delete_aligned), MC_(__builtin_vec_delete), + MC_(__builtin_vec_delete_aligned), MC_(realloc), MC_(malloc_usable_size), + MC_MALLOC_DEFAULT_REDZONE_SZB); MC_(Malloc_Redzone_SzB) = VG_(malloc_effective_client_redzone_size)(); - VG_(needs_xml_output) (); + VG_(needs_xml_output)(); - VG_(track_new_mem_startup) ( mc_new_mem_startup ); + VG_(track_new_mem_startup)(mc_new_mem_startup); // Handling of mmap and mprotect isn't simple (well, it is simple, // but the justification isn't.) See comments above, just prior to // mc_new_mem_mmap. - VG_(track_new_mem_mmap) ( mc_new_mem_mmap ); - VG_(track_change_mem_mprotect) ( mc_new_mem_mprotect ); + VG_(track_new_mem_mmap)(mc_new_mem_mmap); + VG_(track_change_mem_mprotect)(mc_new_mem_mprotect); - VG_(track_copy_mem_remap) ( MC_(copy_address_range_state) ); + VG_(track_copy_mem_remap)(MC_(copy_address_range_state)); - VG_(track_die_mem_stack_signal)( MC_(make_mem_noaccess) ); - VG_(track_die_mem_brk) ( MC_(make_mem_noaccess) ); - VG_(track_die_mem_munmap) ( MC_(make_mem_noaccess) ); + VG_(track_die_mem_stack_signal)(MC_(make_mem_noaccess)); + VG_(track_die_mem_brk)(MC_(make_mem_noaccess)); + VG_(track_die_mem_munmap)(MC_(make_mem_noaccess)); /* Defer the specification of the new_mem_stack functions to the post_clo_init function, since we need to first parse the command line before deciding which set to use. */ -# ifdef PERF_FAST_STACK - VG_(track_die_mem_stack_4) ( mc_die_mem_stack_4 ); - VG_(track_die_mem_stack_8) ( mc_die_mem_stack_8 ); - VG_(track_die_mem_stack_12) ( mc_die_mem_stack_12 ); - VG_(track_die_mem_stack_16) ( mc_die_mem_stack_16 ); - VG_(track_die_mem_stack_32) ( mc_die_mem_stack_32 ); - VG_(track_die_mem_stack_112) ( mc_die_mem_stack_112 ); - VG_(track_die_mem_stack_128) ( mc_die_mem_stack_128 ); - VG_(track_die_mem_stack_144) ( mc_die_mem_stack_144 ); - VG_(track_die_mem_stack_160) ( mc_die_mem_stack_160 ); -# endif - VG_(track_die_mem_stack) ( mc_die_mem_stack ); - - VG_(track_ban_mem_stack) ( MC_(make_mem_noaccess) ); - - VG_(track_pre_mem_read) ( check_mem_is_defined ); - VG_(track_pre_mem_read_asciiz) ( check_mem_is_defined_asciiz ); - VG_(track_pre_mem_write) ( check_mem_is_addressable ); - VG_(track_post_mem_write) ( mc_post_mem_write ); - - VG_(track_post_reg_write) ( mc_post_reg_write ); - VG_(track_post_reg_write_clientcall_return)( mc_post_reg_write_clientcall ); +#ifdef PERF_FAST_STACK + VG_(track_die_mem_stack_4)(mc_die_mem_stack_4); + VG_(track_die_mem_stack_8)(mc_die_mem_stack_8); + VG_(track_die_mem_stack_12)(mc_die_mem_stack_12); + VG_(track_die_mem_stack_16)(mc_die_mem_stack_16); + VG_(track_die_mem_stack_32)(mc_die_mem_stack_32); + VG_(track_die_mem_stack_112)(mc_die_mem_stack_112); + VG_(track_die_mem_stack_128)(mc_die_mem_stack_128); + VG_(track_die_mem_stack_144)(mc_die_mem_stack_144); + VG_(track_die_mem_stack_160)(mc_die_mem_stack_160); +#endif + VG_(track_die_mem_stack)(mc_die_mem_stack); + + VG_(track_ban_mem_stack)(MC_(make_mem_noaccess)); + + VG_(track_pre_mem_read)(check_mem_is_defined); + VG_(track_pre_mem_read_asciiz)(check_mem_is_defined_asciiz); + VG_(track_pre_mem_write)(check_mem_is_addressable); + VG_(track_post_mem_write)(mc_post_mem_write); + + VG_(track_post_reg_write)(mc_post_reg_write); + VG_(track_post_reg_write_clientcall_return)(mc_post_reg_write_clientcall); if (MC_(clo_mc_level) >= 2) { - VG_(track_copy_mem_to_reg) ( mc_copy_mem_to_reg ); - VG_(track_copy_reg_to_mem) ( mc_copy_reg_to_mem ); + VG_(track_copy_mem_to_reg)(mc_copy_mem_to_reg); + VG_(track_copy_reg_to_mem)(mc_copy_reg_to_mem); } - VG_(needs_watchpoint) ( mc_mark_unaddressable_for_watchpoint ); + VG_(needs_watchpoint)(mc_mark_unaddressable_for_watchpoint); init_shadow_memory(); // MC_(chunk_poolalloc) must be allocated in post_clo_init tl_assert(MC_(chunk_poolalloc) == NULL); - MC_(malloc_list) = VG_(HT_construct)( "MC_(malloc_list)" ); - MC_(mempool_list) = VG_(HT_construct)( "MC_(mempool_list)" ); + MC_(malloc_list) = VG_(HT_construct)("MC_(malloc_list)"); + MC_(mempool_list) = VG_(HT_construct)("MC_(mempool_list)"); init_prof_mem(); - tl_assert( mc_expensive_sanity_check() ); + tl_assert(mc_expensive_sanity_check()); // {LOADV,STOREV}[8421] will all fail horribly if this isn't true. tl_assert(sizeof(UWord) == sizeof(Addr)); @@ -8519,34 +8585,34 @@ static void mc_pre_clo_init(void) if we need to, since the command line args haven't been processed yet. Hence defer it to mc_post_clo_init. */ tl_assert(ocacheL1 == NULL); - for (UInt i = 0; i < 4096; i++ ) { + for (UInt i = 0; i < 4096; i++) { tl_assert(ocachesL2[i] == NULL); } /* Check some important stuff. See extensive comments above re UNALIGNED_OR_HIGH for background. */ -# if VG_WORDSIZE == 4 +#if VG_WORDSIZE == 4 tl_assert(sizeof(void*) == 4); - tl_assert(sizeof(Addr) == 4); + tl_assert(sizeof(Addr) == 4); tl_assert(sizeof(UWord) == 4); - tl_assert(sizeof(Word) == 4); + tl_assert(sizeof(Word) == 4); tl_assert(MAX_PRIMARY_ADDRESS == 0xFFFFFFFFUL); tl_assert(MASK(1) == 0UL); tl_assert(MASK(2) == 1UL); tl_assert(MASK(4) == 3UL); tl_assert(MASK(8) == 7UL); -# else +#else tl_assert(VG_WORDSIZE == 8); tl_assert(sizeof(void*) == 8); - tl_assert(sizeof(Addr) == 8); + tl_assert(sizeof(Addr) == 8); tl_assert(sizeof(UWord) == 8); - tl_assert(sizeof(Word) == 8); + tl_assert(sizeof(Word) == 8); tl_assert(MAX_PRIMARY_ADDRESS == 0x1FFFFFFFFFULL); tl_assert(MASK(1) == 0xFFFFFFE000000000ULL); tl_assert(MASK(2) == 0xFFFFFFE000000001ULL); tl_assert(MASK(4) == 0xFFFFFFE000000003ULL); tl_assert(MASK(8) == 0xFFFFFFE000000007ULL); -# endif +#endif /* Check some assertions to do with the instrumentation machinery. */ MC_(do_instrumentation_startup_checks)(); diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index b32f13f76d..2111b6b09f 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -28,11 +28,11 @@ */ #include "pub_tool_basics.h" -#include "pub_tool_poolalloc.h" +#include "pub_tool_clreq.h" #include "pub_tool_hashtable.h" +#include "pub_tool_poolalloc.h" #include "pub_tool_redir.h" #include "pub_tool_tooliface.h" -#include "pub_tool_clreq.h" /* --------------------------------------------------------------------- We have our own versions of these functions for multiple reasons: @@ -116,7 +116,6 @@ */ #endif - /* Figure out if [dst .. dst+dstlen-1] overlaps with [src .. src+srclen-1]. We assume that the address ranges do not wrap around @@ -124,8 +123,8 @@ are not accessible and the program will segfault in this circumstance, presumably). */ -static inline -Bool is_overlap ( void* dst, const void* src, SizeT dstlen, SizeT srclen ) +static inline Bool +is_overlap(void* dst, const void* src, SizeT dstlen, SizeT srclen) { Addr loS, hiS, loD, hiD; @@ -140,46 +139,47 @@ Bool is_overlap ( void* dst, const void* src, SizeT dstlen, SizeT srclen ) /* So figure out if [loS .. hiS] overlaps with [loD .. hiD]. */ if (loS < loD) { return !(hiS < loD); - } - else if (loD < loS) { + } else if (loD < loS) { return !(hiD < loS); - } - else { + } else { /* They start at same place. Since we know neither of them has zero length, they must overlap. */ return True; } } - /* Call here to exit if we can't continue. On Android we can't call _exit for some reason, so we have to blunt-instrument it. */ -__attribute__ ((__noreturn__)) -static inline void my_exit ( int x ) +__attribute__((__noreturn__)) static inline void my_exit(int x) { -# if defined(VGPV_arm_linux_android) || defined(VGPV_mips32_linux_android) \ - || defined(VGPV_arm64_linux_android) +#if defined(VGPV_arm_linux_android) || defined(VGPV_mips32_linux_android) || \ + defined(VGPV_arm64_linux_android) __asm__ __volatile__(".word 0xFFFFFFFF"); - while (1) {} -# elif defined(VGPV_x86_linux_android) + while (1) { + } +#elif defined(VGPV_x86_linux_android) __asm__ __volatile__("ud2"); - while (1) {} -# else - extern __attribute__ ((__noreturn__)) void _exit(int status); + while (1) { + } +#else + extern __attribute__((__noreturn__)) void _exit(int status); _exit(x); -# endif +#endif } - // This is a macro rather than a function because we don't want to have an // extra function in the stack trace. #ifndef RECORD_OVERLAP_ERROR -#define RECORD_OVERLAP_ERROR(s, src, dst, len) do { } while (0) +#define RECORD_OVERLAP_ERROR(s, src, dst, len) \ + do { \ + } while (0) #endif // Used for tools that record bulk copies: memcpy, strcpy, etc. #ifndef RECORD_COPY -#define RECORD_COPY(len) do { } while (0) +#define RECORD_COPY(len) \ + do { \ + } while (0) #define FOR_COPY(x) #else #define FOR_COPY(x) x @@ -189,208 +189,209 @@ static inline void my_exit ( int x ) #define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) 1 #endif - /*---------------------- strrchr ----------------------*/ -#define STRRCHR(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20010,soname,fnname)( const char* s, int c ); \ - char* VG_REPLACE_FUNCTION_EZU(20010,soname,fnname)( const char* s, int c ) \ - { \ - HChar ch = (HChar)c; \ - const HChar* p = s; \ - const HChar* last = NULL; \ - while (True) { \ - if (*p == ch) last = p; \ - if (*p == 0) return CONST_CAST(HChar *,last); \ - p++; \ - } \ +#define STRRCHR(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20010, soname, fnname)(const char* s, int c); \ + char* VG_REPLACE_FUNCTION_EZU(20010, soname, fnname)(const char* s, int c) \ + { \ + HChar ch = (HChar)c; \ + const HChar* p = s; \ + const HChar* last = NULL; \ + while (True) { \ + if (*p == ch) \ + last = p; \ + if (*p == 0) \ + return CONST_CAST(HChar*, last); \ + p++; \ + } \ } // Apparently rindex() is the same thing as strrchr() #if defined(VGO_linux) - STRRCHR(VG_Z_LIBC_SONAME, strrchr) - STRRCHR(VG_Z_LIBC_SONAME, rindex) - STRRCHR(VG_Z_LIBC_SONAME, __GI_strrchr) - STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse2) - STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse2_no_bsf) - STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse42) - STRRCHR(VG_Z_LD_LINUX_SO_2, rindex) -#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \ - || defined(VGPV_mips32_linux_android) - STRRCHR(NONE, __dl_strrchr); /* in /system/bin/linker */ +STRRCHR(VG_Z_LIBC_SONAME, strrchr) +STRRCHR(VG_Z_LIBC_SONAME, rindex) +STRRCHR(VG_Z_LIBC_SONAME, __GI_strrchr) +STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse2) +STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse2_no_bsf) +STRRCHR(VG_Z_LIBC_SONAME, __strrchr_sse42) +STRRCHR(VG_Z_LD_LINUX_SO_2, rindex) +#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) || \ + defined(VGPV_mips32_linux_android) +STRRCHR(NONE, __dl_strrchr); /* in /system/bin/linker */ #endif #elif defined(VGO_freebsd) - STRRCHR(VG_Z_LIBC_SONAME, strrchr) - STRRCHR(VG_Z_LIBC_SONAME, rindex) - STRRCHR(VG_Z_LD_ELF_SO_1, strrchr) - STRRCHR(VG_Z_LD_ELF32_SO_1, strrchr) +STRRCHR(VG_Z_LIBC_SONAME, strrchr) +STRRCHR(VG_Z_LIBC_SONAME, rindex) +STRRCHR(VG_Z_LD_ELF_SO_1, strrchr) +STRRCHR(VG_Z_LD_ELF32_SO_1, strrchr) #elif defined(VGO_darwin) - //STRRCHR(VG_Z_LIBC_SONAME, strrchr) - //STRRCHR(VG_Z_LIBC_SONAME, rindex) - //STRRCHR(VG_Z_DYLD, strrchr) - //STRRCHR(VG_Z_DYLD, rindex) - STRRCHR(VG_Z_LIBC_SONAME, strrchr) -# if DARWIN_VERS >= DARWIN_10_9 - STRRCHR(libsystemZucZddylib, strrchr) -# endif +// STRRCHR(VG_Z_LIBC_SONAME, strrchr) +// STRRCHR(VG_Z_LIBC_SONAME, rindex) +// STRRCHR(VG_Z_DYLD, strrchr) +// STRRCHR(VG_Z_DYLD, rindex) +STRRCHR(VG_Z_LIBC_SONAME, strrchr) +#if DARWIN_VERS >= DARWIN_10_9 +STRRCHR(libsystemZucZddylib, strrchr) +#endif #elif defined(VGO_solaris) - STRRCHR(VG_Z_LIBC_SONAME, strrchr) - STRRCHR(VG_Z_LIBC_SONAME, rindex) - STRRCHR(VG_Z_LD_SO_1, strrchr) +STRRCHR(VG_Z_LIBC_SONAME, strrchr) +STRRCHR(VG_Z_LIBC_SONAME, rindex) +STRRCHR(VG_Z_LD_SO_1, strrchr) #endif - /*---------------------- strchr ----------------------*/ -#define STRCHR(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20020,soname,fnname) ( const char* s, int c ); \ - char* VG_REPLACE_FUNCTION_EZU(20020,soname,fnname) ( const char* s, int c ) \ - { \ - HChar ch = (HChar)c ; \ - const HChar* p = s; \ - while (True) { \ - if (*p == ch) return CONST_CAST(HChar *,p); \ - if (*p == 0) return NULL; \ - p++; \ - } \ +#define STRCHR(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20020, soname, fnname)(const char* s, int c); \ + char* VG_REPLACE_FUNCTION_EZU(20020, soname, fnname)(const char* s, int c) \ + { \ + HChar ch = (HChar)c; \ + const HChar* p = s; \ + while (True) { \ + if (*p == ch) \ + return CONST_CAST(HChar*, p); \ + if (*p == 0) \ + return NULL; \ + p++; \ + } \ } // Apparently index() is the same thing as strchr() #if defined(VGO_linux) - STRCHR(VG_Z_LIBC_SONAME, strchr) - STRCHR(VG_Z_LIBC_SONAME, __GI_strchr) - STRCHR(VG_Z_LIBC_SONAME, __strchr_sse2) - STRCHR(VG_Z_LIBC_SONAME, __strchr_sse2_no_bsf) - STRCHR(VG_Z_LIBC_SONAME, index) -# if !defined(VGP_x86_linux) && !defined(VGP_amd64_linux) - STRCHR(VG_Z_LD_LINUX_SO_2, strchr) - STRCHR(VG_Z_LD_LINUX_SO_2, index) - STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr) - STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, index) -# endif +STRCHR(VG_Z_LIBC_SONAME, strchr) +STRCHR(VG_Z_LIBC_SONAME, __GI_strchr) +STRCHR(VG_Z_LIBC_SONAME, __strchr_sse2) +STRCHR(VG_Z_LIBC_SONAME, __strchr_sse2_no_bsf) +STRCHR(VG_Z_LIBC_SONAME, index) +#if !defined(VGP_x86_linux) && !defined(VGP_amd64_linux) +STRCHR(VG_Z_LD_LINUX_SO_2, strchr) +STRCHR(VG_Z_LD_LINUX_SO_2, index) +STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr) +STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, index) +#endif #if defined(VGPV_mips32_linux_android) - STRCHR(NONE, __dl_strchr) +STRCHR(NONE, __dl_strchr) #endif #elif defined(VGO_freebsd) - STRCHR(VG_Z_LIBC_SONAME, strchr) - STRCHR(VG_Z_LIBC_SONAME, index) - STRCHR(VG_Z_LD_ELF_SO_1, strchr) - STRCHR(VG_Z_LD_ELF32_SO_1, strchr) +STRCHR(VG_Z_LIBC_SONAME, strchr) +STRCHR(VG_Z_LIBC_SONAME, index) +STRCHR(VG_Z_LD_ELF_SO_1, strchr) +STRCHR(VG_Z_LD_ELF32_SO_1, strchr) #elif defined(VGO_darwin) - STRCHR(VG_Z_LIBC_SONAME, strchr) -# if DARWIN_VERS == DARWIN_10_9 - STRCHR(libsystemZuplatformZddylib, _platform_strchr) -# endif -# if DARWIN_VERS >= DARWIN_10_10 - /* _platform_strchr$VARIANT$Generic */ - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Generic) - /* _platform_strchr$VARIANT$Haswell */ - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Haswell) -# endif - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Base) +STRCHR(VG_Z_LIBC_SONAME, strchr) +#if DARWIN_VERS == DARWIN_10_9 +STRCHR(libsystemZuplatformZddylib, _platform_strchr) +#endif +#if DARWIN_VERS >= DARWIN_10_10 +/* _platform_strchr$VARIANT$Generic */ +STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Generic) +/* _platform_strchr$VARIANT$Haswell */ +STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Haswell) +#endif +STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Base) #elif defined(VGO_solaris) - STRCHR(VG_Z_LIBC_SONAME, strchr) - STRCHR(VG_Z_LIBC_SONAME, index) - STRCHR(VG_Z_LD_SO_1, strchr) +STRCHR(VG_Z_LIBC_SONAME, strchr) +STRCHR(VG_Z_LIBC_SONAME, index) +STRCHR(VG_Z_LD_SO_1, strchr) #endif - /*---------------------- strcat ----------------------*/ -#define STRCAT(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20030,soname,fnname) \ - ( char* dst, const char* src ); \ - char* VG_REPLACE_FUNCTION_EZU(20030,soname,fnname) \ - ( char* dst, const char* src ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - while (*dst) dst++; \ - while (*src) *dst++ = *src++; \ - *dst = 0; \ - \ +#define STRCAT(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20030, soname, fnname)(char* dst, \ + const char* src); \ + char* VG_REPLACE_FUNCTION_EZU(20030, soname, fnname)(char* dst, \ + const char* src) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + while (*dst) \ + dst++; \ + while (*src) \ + *dst++ = *src++; \ + *dst = 0; \ + \ /* This is a bit redundant, I think; any overlap and the strcat will */ \ - /* go forever... or until a seg fault occurs. */ \ - if (is_overlap(dst_orig, \ - src_orig, \ - (Addr)dst-(Addr)dst_orig+1, \ - (Addr)src-(Addr)src_orig+1)) \ - RECORD_OVERLAP_ERROR("strcat", dst_orig, src_orig, 0); \ - \ - return dst_orig; \ + /* go forever... or until a seg fault occurs. */ \ + if (is_overlap(dst_orig, src_orig, (Addr)dst - (Addr)dst_orig + 1, \ + (Addr)src - (Addr)src_orig + 1)) \ + RECORD_OVERLAP_ERROR("strcat", dst_orig, src_orig, 0); \ + \ + return dst_orig; \ } #if defined(VGO_linux) - STRCAT(VG_Z_LIBC_SONAME, strcat) - STRCAT(VG_Z_LIBC_SONAME, __GI_strcat) +STRCAT(VG_Z_LIBC_SONAME, strcat) +STRCAT(VG_Z_LIBC_SONAME, __GI_strcat) #elif defined(VGO_freebsd) - STRCAT(VG_Z_LIBC_SONAME, strcat) - STRCAT(VG_Z_LD_ELF_SO_1, strcat) - STRCAT(VG_Z_LD_ELF32_SO_1, strcat) +STRCAT(VG_Z_LIBC_SONAME, strcat) +STRCAT(VG_Z_LD_ELF_SO_1, strcat) +STRCAT(VG_Z_LD_ELF32_SO_1, strcat) #elif defined(VGO_darwin) - //STRCAT(VG_Z_LIBC_SONAME, strcat) +// STRCAT(VG_Z_LIBC_SONAME, strcat) #elif defined(VGO_solaris) - STRCAT(VG_Z_LIBC_SONAME, strcat) - STRCAT(VG_Z_LD_SO_1, strcat) +STRCAT(VG_Z_LIBC_SONAME, strcat) +STRCAT(VG_Z_LD_SO_1, strcat) #endif - /*---------------------- strncat ----------------------*/ -#define STRNCAT(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20040,soname,fnname) \ - ( char* dst, const char* src, SizeT n ); \ - char* VG_REPLACE_FUNCTION_EZU(20040,soname,fnname) \ - ( char* dst, const char* src, SizeT n ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - SizeT m = 0; \ - \ - while (*dst) dst++; \ - while (m < n && *src) { m++; *dst++ = *src++; } /* concat <= n chars */ \ - *dst = 0; /* always add null */ \ - \ - /* This checks for overlap after copying, unavoidable without */ \ - /* pre-counting lengths... should be ok */ \ - if (is_overlap(dst_orig, \ - src_orig, \ - (Addr)dst-(Addr)dst_orig+1, \ - (Addr)src-(Addr)src_orig+1)) \ - RECORD_OVERLAP_ERROR("strncat", dst_orig, src_orig, n); \ - \ - return dst_orig; \ +#define STRNCAT(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20040, soname, \ + fnname)(char* dst, const char* src, SizeT n); \ + char* VG_REPLACE_FUNCTION_EZU(20040, soname, \ + fnname)(char* dst, const char* src, SizeT n) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + SizeT m = 0; \ + \ + while (*dst) \ + dst++; \ + while (m < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } /* concat <= n chars */ \ + *dst = 0; /* always add null */ \ + \ + /* This checks for overlap after copying, unavoidable without */ \ + /* pre-counting lengths... should be ok */ \ + if (is_overlap(dst_orig, src_orig, (Addr)dst - (Addr)dst_orig + 1, \ + (Addr)src - (Addr)src_orig + 1)) \ + RECORD_OVERLAP_ERROR("strncat", dst_orig, src_orig, n); \ + \ + return dst_orig; \ } #if defined(VGO_linux) - STRNCAT(VG_Z_LIBC_SONAME, strncat) +STRNCAT(VG_Z_LIBC_SONAME, strncat) #elif defined(VGO_freebsd) - STRNCAT(VG_Z_LIBC_SONAME, strncat) +STRNCAT(VG_Z_LIBC_SONAME, strncat) #elif defined(VGO_darwin) - //STRNCAT(VG_Z_LIBC_SONAME, strncat) - //STRNCAT(VG_Z_DYLD, strncat) +// STRNCAT(VG_Z_LIBC_SONAME, strncat) +// STRNCAT(VG_Z_DYLD, strncat) #elif defined(VGO_solaris) - STRNCAT(VG_Z_LIBC_SONAME, strncat) +STRNCAT(VG_Z_LIBC_SONAME, strncat) #endif - /*---------------------- strlcat ----------------------*/ /* Append src to dst. n is the size of dst's buffer. dst is guaranteed @@ -398,87 +399,93 @@ static inline void my_exit ( int x ) Returns min(n, strlen(dst_orig)) + strlen(src_orig). Truncation occurred if retval >= n. */ -#define STRLCAT(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20050,soname,fnname) \ - ( char* dst, const char* src, SizeT n ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20050,soname,fnname) \ - ( char* dst, const char* src, SizeT n ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - SizeT m = 0; \ - \ - while (m < n && *dst) { m++; dst++; } \ - if (m < n) { \ - /* Fill as far as dst_orig[n-2], then nul-terminate. */ \ - while (m+1 < n && *src) { m++; *dst++ = *src++; } \ - *dst = 0; \ - } else { \ - /* No space to copy anything to dst. m == n */ \ - } \ - /* Finish counting min(n, strlen(dst_orig)) + strlen(src_orig) */ \ - while (*src) { m++; src++; } \ - /* This checks for overlap after copying, unavoidable without */ \ - /* pre-counting lengths... should be ok */ \ - if (is_overlap(dst_orig, \ - src_orig, \ - (Addr)dst-(Addr)dst_orig+1, \ - (Addr)src-(Addr)src_orig+1)) \ - RECORD_OVERLAP_ERROR("strlcat", dst_orig, src_orig, n); \ - \ - return m; \ +#define STRLCAT(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20050, soname, \ + fnname)(char* dst, const char* src, SizeT n); \ + SizeT VG_REPLACE_FUNCTION_EZU(20050, soname, \ + fnname)(char* dst, const char* src, SizeT n) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + SizeT m = 0; \ + \ + while (m < n && *dst) { \ + m++; \ + dst++; \ + } \ + if (m < n) { \ + /* Fill as far as dst_orig[n-2], then nul-terminate. */ \ + while (m + 1 < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } \ + *dst = 0; \ + } else { \ + /* No space to copy anything to dst. m == n */ \ + } \ + /* Finish counting min(n, strlen(dst_orig)) + strlen(src_orig) */ \ + while (*src) { \ + m++; \ + src++; \ + } \ + /* This checks for overlap after copying, unavoidable without */ \ + /* pre-counting lengths... should be ok */ \ + if (is_overlap(dst_orig, src_orig, (Addr)dst - (Addr)dst_orig + 1, \ + (Addr)src - (Addr)src_orig + 1)) \ + RECORD_OVERLAP_ERROR("strlcat", dst_orig, src_orig, n); \ + \ + return m; \ } #if defined(VGO_linux) #elif defined(VGO_freebsd) - STRLCAT(VG_Z_LD_ELF_SO_1, strlcat) - STRLCAT(VG_Z_LIBC_SONAME, strlcat) - STRLCAT(VG_Z_LD_ELF32_SO_1, strlcat) +STRLCAT(VG_Z_LD_ELF_SO_1, strlcat) +STRLCAT(VG_Z_LIBC_SONAME, strlcat) +STRLCAT(VG_Z_LD_ELF32_SO_1, strlcat) #elif defined(VGO_darwin) - //STRLCAT(VG_Z_LIBC_SONAME, strlcat) - //STRLCAT(VG_Z_DYLD, strlcat) - STRLCAT(VG_Z_LIBC_SONAME, strlcat) +// STRLCAT(VG_Z_LIBC_SONAME, strlcat) +// STRLCAT(VG_Z_DYLD, strlcat) +STRLCAT(VG_Z_LIBC_SONAME, strlcat) #elif defined(VGO_solaris) - STRLCAT(VG_Z_LIBC_SONAME, strlcat) +STRLCAT(VG_Z_LIBC_SONAME, strlcat) #endif - /*---------------------- strnlen ----------------------*/ -#define STRNLEN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20060,soname,fnname) \ - ( const char* str, SizeT n ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20060,soname,fnname) \ - ( const char* str, SizeT n ) \ - { \ - SizeT i = 0; \ - while (i < n && str[i] != 0) i++; \ - return i; \ +#define STRNLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20060, soname, fnname)(const char* str, \ + SizeT n); \ + SizeT VG_REPLACE_FUNCTION_EZU(20060, soname, fnname)(const char* str, \ + SizeT n) \ + { \ + SizeT i = 0; \ + while (i < n && str[i] != 0) \ + i++; \ + return i; \ } #if defined(VGO_linux) - STRNLEN(VG_Z_LIBC_SONAME, strnlen) - STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen) +STRNLEN(VG_Z_LIBC_SONAME, strnlen) +STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen) #elif defined(VGO_freebsd) - STRNLEN(VG_Z_LIBC_SONAME, srtnlen) +STRNLEN(VG_Z_LIBC_SONAME, srtnlen) #elif defined(VGO_darwin) -# if DARWIN_VERS == DARWIN_10_9 - STRNLEN(libsystemZucZddylib, strnlen) -# endif +#if DARWIN_VERS == DARWIN_10_9 +STRNLEN(libsystemZucZddylib, strnlen) +#endif #elif defined(VGO_solaris) - STRNLEN(VG_Z_LIBC_SONAME, strnlen) +STRNLEN(VG_Z_LIBC_SONAME, strnlen) #endif - /*---------------------- strlen ----------------------*/ // Note that this replacement often doesn't get used because gcc inlines @@ -486,1026 +493,1140 @@ static inline void my_exit ( int x ) // confusing if you aren't expecting it. Other small functions in // this file may also be inline by gcc. -#define STRLEN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20070,soname,fnname) \ - ( const char* str ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20070,soname,fnname) \ - ( const char* str ) \ - { \ - SizeT i = 0; \ - while (str[i] != 0) i++; \ - return i; \ +#define STRLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20070, soname, fnname)(const char* str); \ + SizeT VG_REPLACE_FUNCTION_EZU(20070, soname, fnname)(const char* str) \ + { \ + SizeT i = 0; \ + while (str[i] != 0) \ + i++; \ + return i; \ } #if defined(VGO_linux) - STRLEN(VG_Z_LIBC_SONAME, strlen) - STRLEN(VG_Z_LIBC_SONAME, __GI_strlen) - STRLEN(VG_Z_LIBC_SONAME, __strlen_sse2) - STRLEN(VG_Z_LIBC_SONAME, __strlen_sse2_no_bsf) - STRLEN(VG_Z_LIBC_SONAME, __strlen_sse42) - STRLEN(VG_Z_LD_LINUX_SO_2, strlen) - STRLEN(VG_Z_LD_LINUX_X86_64_SO_2, strlen) -# if defined(VGPV_arm_linux_android) \ - || defined(VGPV_x86_linux_android) \ - || defined(VGPV_mips32_linux_android) - STRLEN(NONE, __dl_strlen); /* in /system/bin/linker */ -# endif +STRLEN(VG_Z_LIBC_SONAME, strlen) +STRLEN(VG_Z_LIBC_SONAME, __GI_strlen) +STRLEN(VG_Z_LIBC_SONAME, __strlen_sse2) +STRLEN(VG_Z_LIBC_SONAME, __strlen_sse2_no_bsf) +STRLEN(VG_Z_LIBC_SONAME, __strlen_sse42) +STRLEN(VG_Z_LD_LINUX_SO_2, strlen) +STRLEN(VG_Z_LD_LINUX_X86_64_SO_2, strlen) +#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) || \ + defined(VGPV_mips32_linux_android) +STRLEN(NONE, __dl_strlen); /* in /system/bin/linker */ +#endif #elif defined(VGO_freebsd) - STRLEN(VG_Z_LIBC_SONAME, strlen) - STRLEN(VG_Z_LD_ELF_SO_1, strlen) - STRLEN(VG_Z_LD_ELF32_SO_1, strlen) +STRLEN(VG_Z_LIBC_SONAME, strlen) +STRLEN(VG_Z_LD_ELF_SO_1, strlen) +STRLEN(VG_Z_LD_ELF32_SO_1, strlen) #elif defined(VGO_darwin) - STRLEN(VG_Z_LIBC_SONAME, strlen) -# if DARWIN_VERS >= DARWIN_10_9 - STRLEN(libsystemZucZddylib, strlen) -# endif +STRLEN(VG_Z_LIBC_SONAME, strlen) +#if DARWIN_VERS >= DARWIN_10_9 +STRLEN(libsystemZucZddylib, strlen) +#endif #elif defined(VGO_solaris) - STRLEN(VG_Z_LIBC_SONAME, strlen) - STRLEN(VG_Z_LD_SO_1, strlen) +STRLEN(VG_Z_LIBC_SONAME, strlen) +STRLEN(VG_Z_LD_SO_1, strlen) #endif - /*---------------------- strcpy ----------------------*/ -#define STRCPY(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20080,soname,fnname) \ - ( char* dst, const char* src ); \ - char* VG_REPLACE_FUNCTION_EZU(20080,soname,fnname) \ - ( char* dst, const char* src ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - \ - while (*src) *dst++ = *src++; \ - *dst = 0; \ - \ - /* This happens after copying, unavoidable without */ \ - /* pre-counting length... should be ok */ \ - SizeT srclen = (Addr)src-(Addr)src_orig+1; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_orig, \ - src_orig, \ - (Addr)dst-(Addr)dst_orig+1, \ - srclen)) \ - RECORD_OVERLAP_ERROR("strcpy", dst_orig, src_orig, 0); \ - \ - return dst_orig; \ +#define STRCPY(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20080, soname, fnname)(char* dst, \ + const char* src); \ + char* VG_REPLACE_FUNCTION_EZU(20080, soname, fnname)(char* dst, \ + const char* src) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + \ + while (*src) \ + *dst++ = *src++; \ + *dst = 0; \ + \ + /* This happens after copying, unavoidable without */ \ + /* pre-counting length... should be ok */ \ + SizeT srclen = (Addr)src - (Addr)src_orig + 1; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, src_orig, (Addr)dst - (Addr)dst_orig + 1, \ + srclen)) \ + RECORD_OVERLAP_ERROR("strcpy", dst_orig, src_orig, 0); \ + \ + return dst_orig; \ } #if defined(VGO_linux) - STRCPY(VG_Z_LIBC_SONAME, strcpy) - STRCPY(VG_Z_LIBC_SONAME, __GI_strcpy) +STRCPY(VG_Z_LIBC_SONAME, strcpy) +STRCPY(VG_Z_LIBC_SONAME, __GI_strcpy) #elif defined(VGO_freebsd) - STRCPY(VG_Z_LIBC_SONAME, strcpy) - STRCPY(VG_Z_LD_ELF_SO_1, strcpy) - STRCPY(VG_Z_LD_ELF32_SO_1, strcpy) +STRCPY(VG_Z_LIBC_SONAME, strcpy) +STRCPY(VG_Z_LD_ELF_SO_1, strcpy) +STRCPY(VG_Z_LD_ELF32_SO_1, strcpy) #elif defined(VGO_darwin) - STRCPY(VG_Z_LIBC_SONAME, strcpy) -# if DARWIN_VERS == DARWIN_10_9 - STRCPY(libsystemZucZddylib, strcpy) -# endif +STRCPY(VG_Z_LIBC_SONAME, strcpy) +#if DARWIN_VERS == DARWIN_10_9 +STRCPY(libsystemZucZddylib, strcpy) +#endif #elif defined(VGO_solaris) - STRCPY(VG_Z_LIBC_SONAME, strcpy) - STRCPY(VG_Z_LD_SO_1, strcpy) +STRCPY(VG_Z_LIBC_SONAME, strcpy) +STRCPY(VG_Z_LD_SO_1, strcpy) #endif - /*---------------------- strncpy ----------------------*/ -#define STRNCPY(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20090,soname,fnname) \ - ( char* dst, const char* src, SizeT n ); \ - char* VG_REPLACE_FUNCTION_EZU(20090,soname,fnname) \ - ( char* dst, const char* src, SizeT n ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - SizeT m = 0; \ - \ - while (m < n && *src) { m++; *dst++ = *src++; } \ - /* Check for overlap after copying; all n bytes of dst are relevant, */ \ - /* but only m+1 bytes of src if terminator was found */ \ - SizeT srclen = (m < n) ? m+1 : n; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_orig, src_orig, n, srclen)) \ - RECORD_OVERLAP_ERROR("strncpy", dst, src, n); \ - while (m++ < n) *dst++ = 0; /* must pad remainder with nulls */ \ - \ - return dst_orig; \ +#define STRNCPY(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20090, soname, \ + fnname)(char* dst, const char* src, SizeT n); \ + char* VG_REPLACE_FUNCTION_EZU(20090, soname, \ + fnname)(char* dst, const char* src, SizeT n) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + SizeT m = 0; \ + \ + while (m < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } \ + /* Check for overlap after copying; all n bytes of dst are relevant, */ \ + /* but only m+1 bytes of src if terminator was found */ \ + SizeT srclen = (m < n) ? m + 1 : n; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, src_orig, n, srclen)) \ + RECORD_OVERLAP_ERROR("strncpy", dst, src, n); \ + while (m++ < n) \ + *dst++ = 0; /* must pad remainder with nulls */ \ + \ + return dst_orig; \ } #if defined(VGO_linux) - STRNCPY(VG_Z_LIBC_SONAME, strncpy) - STRNCPY(VG_Z_LIBC_SONAME, __GI_strncpy) - STRNCPY(VG_Z_LIBC_SONAME, __strncpy_sse2) - STRNCPY(VG_Z_LIBC_SONAME, __strncpy_sse2_unaligned) +STRNCPY(VG_Z_LIBC_SONAME, strncpy) +STRNCPY(VG_Z_LIBC_SONAME, __GI_strncpy) +STRNCPY(VG_Z_LIBC_SONAME, __strncpy_sse2) +STRNCPY(VG_Z_LIBC_SONAME, __strncpy_sse2_unaligned) #elif defined(VGO_freebsd) - STRNCPY(VG_Z_LIBC_SONAME, strncpy) - STRNCPY(VG_Z_LD_ELF_SO_1, strncpy) - STRNCPY(VG_Z_LD_ELF32_SO_1, strncpy) +STRNCPY(VG_Z_LIBC_SONAME, strncpy) +STRNCPY(VG_Z_LD_ELF_SO_1, strncpy) +STRNCPY(VG_Z_LD_ELF32_SO_1, strncpy) #elif defined(VGO_darwin) - STRNCPY(VG_Z_LIBC_SONAME, strncpy) -# if DARWIN_VERS >= DARWIN_10_9 - STRNCPY(libsystemZucZddylib, strncpy) -# endif +STRNCPY(VG_Z_LIBC_SONAME, strncpy) +#if DARWIN_VERS >= DARWIN_10_9 +STRNCPY(libsystemZucZddylib, strncpy) +#endif #elif defined(VGO_solaris) - STRNCPY(VG_Z_LIBC_SONAME, strncpy) - STRNCPY(VG_Z_LD_SO_1, strncpy) +STRNCPY(VG_Z_LIBC_SONAME, strncpy) +STRNCPY(VG_Z_LD_SO_1, strncpy) #endif - /*---------------------- strlcpy ----------------------*/ /* Copy up to n-1 bytes from src to dst. Then nul-terminate dst if n > 0. Returns strlen(src). Does not zero-fill the remainder of dst. */ -#define STRLCPY(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20100,soname,fnname) \ - ( char* dst, const char* src, SizeT n ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20100,soname,fnname) \ - ( char* dst, const char* src, SizeT n ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - SizeT m = 0; \ - \ - STRLCPY_CHECK_FOR_DSTSIZE_ZERO \ - \ - while (m+1 < n && *src) { m++; *dst++ = *src++; } \ - /* m non-nul bytes have now been copied, and m <= n-1. */ \ - /* Check for overlap after copying; all n bytes of dst are relevant, */ \ - /* but only m+1 bytes of src if terminator was found */ \ - SizeT srclen = (m < n) ? m+1 : n; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_orig, src_orig, n, srclen)) \ - RECORD_OVERLAP_ERROR("strlcpy", dst, src, n); \ - /* Nul-terminate dst. */ \ - if (n > 0) *dst = 0; \ - /* Finish counting strlen(src). */ \ - while (*src) src++; \ - return src - src_orig; \ +#define STRLCPY(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20100, soname, \ + fnname)(char* dst, const char* src, SizeT n); \ + SizeT VG_REPLACE_FUNCTION_EZU(20100, soname, \ + fnname)(char* dst, const char* src, SizeT n) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + SizeT m = 0; \ + \ + STRLCPY_CHECK_FOR_DSTSIZE_ZERO \ + \ + while (m + 1 < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } \ + /* m non-nul bytes have now been copied, and m <= n-1. */ \ + /* Check for overlap after copying; all n bytes of dst are relevant, */ \ + /* but only m+1 bytes of src if terminator was found */ \ + SizeT srclen = (m < n) ? m + 1 : n; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, src_orig, n, srclen)) \ + RECORD_OVERLAP_ERROR("strlcpy", dst, src, n); \ + /* Nul-terminate dst. */ \ + if (n > 0) \ + *dst = 0; \ + /* Finish counting strlen(src). */ \ + while (*src) \ + src++; \ + return src - src_orig; \ } #if defined(VGO_linux) -#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \ - || defined(VGPV_mips32_linux_android) - #define STRLCPY_CHECK_FOR_DSTSIZE_ZERO - STRLCPY(VG_Z_LIBC_SONAME, strlcpy); +#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) || \ + defined(VGPV_mips32_linux_android) +#define STRLCPY_CHECK_FOR_DSTSIZE_ZERO +STRLCPY(VG_Z_LIBC_SONAME, strlcpy); #endif #elif defined(VGO_freebsd) - #define STRLCPY_CHECK_FOR_DSTSIZE_ZERO - STRLCPY(VG_Z_LD_ELF_SO_1, strlcpy) - STRLCPY(VG_Z_LD_ELF32_SO_1, strlcpy) - STRLCPY(VG_Z_LIBC_SONAME, strlcpy) +#define STRLCPY_CHECK_FOR_DSTSIZE_ZERO +STRLCPY(VG_Z_LD_ELF_SO_1, strlcpy) +STRLCPY(VG_Z_LD_ELF32_SO_1, strlcpy) +STRLCPY(VG_Z_LIBC_SONAME, strlcpy) #elif defined(VGO_darwin) - #define STRLCPY_CHECK_FOR_DSTSIZE_ZERO - //STRLCPY(VG_Z_LIBC_SONAME, strlcpy) - //STRLCPY(VG_Z_DYLD, strlcpy) - STRLCPY(VG_Z_LIBC_SONAME, strlcpy) +#define STRLCPY_CHECK_FOR_DSTSIZE_ZERO +// STRLCPY(VG_Z_LIBC_SONAME, strlcpy) +// STRLCPY(VG_Z_DYLD, strlcpy) +STRLCPY(VG_Z_LIBC_SONAME, strlcpy) #elif defined(VGO_solaris) - /* special case for n == 0 which is undocumented but heavily used */ - #define STRLCPY_CHECK_FOR_DSTSIZE_ZERO \ - if (n == 0) { \ - while (*src) src++; \ - return src - src_orig; \ - } +/* special case for n == 0 which is undocumented but heavily used */ +#define STRLCPY_CHECK_FOR_DSTSIZE_ZERO \ + if (n == 0) { \ + while (*src) \ + src++; \ + return src - src_orig; \ + } - STRLCPY(VG_Z_LIBC_SONAME, strlcpy) +STRLCPY(VG_Z_LIBC_SONAME, strlcpy) #endif - /*---------------------- strncmp ----------------------*/ -#define STRNCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20110,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax ); \ - int VG_REPLACE_FUNCTION_EZU(20110,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax ) \ - { \ - SizeT n = 0; \ - while (True) { \ - if (n >= nmax) return 0; \ - if (*s1 == 0 && *s2 == 0) return 0; \ - if (*s1 == 0) return -1; \ - if (*s2 == 0) return 1; \ - \ - if (*(const UChar*)s1 < *(const UChar*)s2) return -1; \ - if (*(const UChar*)s1 > *(const UChar*)s2) return 1; \ - \ - s1++; s2++; n++; \ - } \ +#define STRNCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20110, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax); \ + int VG_REPLACE_FUNCTION_EZU(20110, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax) \ + { \ + SizeT n = 0; \ + while (True) { \ + if (n >= nmax) \ + return 0; \ + if (*s1 == 0 && *s2 == 0) \ + return 0; \ + if (*s1 == 0) \ + return -1; \ + if (*s2 == 0) \ + return 1; \ + \ + if (*(const UChar*)s1 < *(const UChar*)s2) \ + return -1; \ + if (*(const UChar*)s1 > *(const UChar*)s2) \ + return 1; \ + \ + s1++; \ + s2++; \ + n++; \ + } \ } #if defined(VGO_linux) - STRNCMP(VG_Z_LIBC_SONAME, strncmp) - STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp) - STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse2) - STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse42) - STRNCMP(VG_Z_LD_LINUX_SO_2, strncmp) - STRNCMP(VG_Z_LD_LINUX_X86_64_SO_2, strncmp) +STRNCMP(VG_Z_LIBC_SONAME, strncmp) +STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp) +STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse2) +STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse42) +STRNCMP(VG_Z_LD_LINUX_SO_2, strncmp) +STRNCMP(VG_Z_LD_LINUX_X86_64_SO_2, strncmp) #elif defined(VGO_freebsd) - STRNCMP(VG_Z_LIBC_SONAME, strncmp) - STRNCMP(VG_Z_LD_ELF_SO_1, strncmp) - STRNCMP(VG_Z_LD_ELF32_SO_1, strncmp) +STRNCMP(VG_Z_LIBC_SONAME, strncmp) +STRNCMP(VG_Z_LD_ELF_SO_1, strncmp) +STRNCMP(VG_Z_LD_ELF32_SO_1, strncmp) #elif defined(VGO_darwin) - STRNCMP(VG_Z_LIBC_SONAME, strncmp) -# if DARWIN_VERS >= DARWIN_10_9 - STRNCMP(libsystemZuplatformZddylib, _platform_strncmp) -# endif +STRNCMP(VG_Z_LIBC_SONAME, strncmp) +#if DARWIN_VERS >= DARWIN_10_9 +STRNCMP(libsystemZuplatformZddylib, _platform_strncmp) +#endif #elif defined(VGO_solaris) - STRNCMP(VG_Z_LIBC_SONAME, strncmp) +STRNCMP(VG_Z_LIBC_SONAME, strncmp) #endif - /*---------------------- strcasecmp ----------------------*/ -#define STRCASECMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20120,soname,fnname) \ - ( const char* s1, const char* s2 ); \ - int VG_REPLACE_FUNCTION_EZU(20120,soname,fnname) \ - ( const char* s1, const char* s2 ) \ - { \ - extern int tolower(int); \ - register UChar c1; \ - register UChar c2; \ - while (True) { \ - c1 = tolower(*(const UChar *)s1); \ - c2 = tolower(*(const UChar *)s2); \ - if (c1 != c2) break; \ - if (c1 == 0) break; \ - s1++; s2++; \ - } \ - if ((UChar)c1 < (UChar)c2) return -1; \ - if ((UChar)c1 > (UChar)c2) return 1; \ - return 0; \ +#define STRCASECMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20120, soname, fnname)(const char* s1, \ + const char* s2); \ + int VG_REPLACE_FUNCTION_EZU(20120, soname, fnname)(const char* s1, \ + const char* s2) \ + { \ + extern int tolower(int); \ + register UChar c1; \ + register UChar c2; \ + while (True) { \ + c1 = tolower(*(const UChar*)s1); \ + c2 = tolower(*(const UChar*)s2); \ + if (c1 != c2) \ + break; \ + if (c1 == 0) \ + break; \ + s1++; \ + s2++; \ + } \ + if ((UChar)c1 < (UChar)c2) \ + return -1; \ + if ((UChar)c1 > (UChar)c2) \ + return 1; \ + return 0; \ } #if defined(VGO_linux) -# if !defined(VGPV_arm_linux_android) \ - && !defined(VGPV_x86_linux_android) \ - && !defined(VGPV_mips32_linux_android) \ - && !defined(VGPV_arm64_linux_android) - STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) - STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp) -# endif +#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) && \ + !defined(VGPV_mips32_linux_android) && !defined(VGPV_arm64_linux_android) +STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) +STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp) +#endif #elif defined(VGO_freebsd) - STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) - STRNCMP(VG_Z_LD_ELF_SO_1, strcasecmp) - STRNCMP(VG_Z_LD_ELF32_SO_1, strcasecmp) +STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) +STRNCMP(VG_Z_LD_ELF_SO_1, strcasecmp) +STRNCMP(VG_Z_LD_ELF32_SO_1, strcasecmp) #elif defined(VGO_darwin) - //STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) +// STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) #elif defined(VGO_solaris) - STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) +STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp) #endif - /*---------------------- strncasecmp ----------------------*/ -#define STRNCASECMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20130,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax ); \ - int VG_REPLACE_FUNCTION_EZU(20130,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax ) \ - { \ - extern int tolower(int); \ - SizeT n = 0; \ - while (True) { \ - if (n >= nmax) return 0; \ - if (*s1 == 0 && *s2 == 0) return 0; \ - if (*s1 == 0) return -1; \ - if (*s2 == 0) return 1; \ - \ - if (tolower(*(const UChar *)s1) \ - < tolower(*(const UChar*)s2)) return -1; \ - if (tolower(*(const UChar *)s1) \ - > tolower(*(const UChar *)s2)) return 1; \ - \ - s1++; s2++; n++; \ - } \ +#define STRNCASECMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20130, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax); \ + int VG_REPLACE_FUNCTION_EZU(20130, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax) \ + { \ + extern int tolower(int); \ + SizeT n = 0; \ + while (True) { \ + if (n >= nmax) \ + return 0; \ + if (*s1 == 0 && *s2 == 0) \ + return 0; \ + if (*s1 == 0) \ + return -1; \ + if (*s2 == 0) \ + return 1; \ + \ + if (tolower(*(const UChar*)s1) < tolower(*(const UChar*)s2)) \ + return -1; \ + if (tolower(*(const UChar*)s1) > tolower(*(const UChar*)s2)) \ + return 1; \ + \ + s1++; \ + s2++; \ + n++; \ + } \ } #if defined(VGO_linux) -# if !defined(VGPV_arm_linux_android) \ - && !defined(VGPV_x86_linux_android) \ - && !defined(VGPV_mips32_linux_android) \ - && !defined(VGPV_arm64_linux_android) - STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) - STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp) -# endif +#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) && \ + !defined(VGPV_mips32_linux_android) && !defined(VGPV_arm64_linux_android) +STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) +STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp) +#endif #elif defined(VGO_freebsd) - STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) - STRNCASECMP(VG_Z_LD_ELF_SO_1, strncasecmp) - STRNCASECMP(VG_Z_LD_ELF32_SO_1, strncasecmp) +STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) +STRNCASECMP(VG_Z_LD_ELF_SO_1, strncasecmp) +STRNCASECMP(VG_Z_LD_ELF32_SO_1, strncasecmp) #elif defined(VGO_darwin) - //STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) - //STRNCASECMP(VG_Z_DYLD, strncasecmp) +// STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) +// STRNCASECMP(VG_Z_DYLD, strncasecmp) #elif defined(VGO_solaris) - STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) +STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp) #endif - /*---------------------- strcasecmp_l ----------------------*/ -#define STRCASECMP_L(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20140,soname,fnname) \ - ( const char* s1, const char* s2, void* locale ); \ - int VG_REPLACE_FUNCTION_EZU(20140,soname,fnname) \ - ( const char* s1, const char* s2, void* locale ) \ - { \ - extern int tolower_l(int, void*) __attribute__((weak)); \ - register UChar c1; \ - register UChar c2; \ - while (True) { \ - c1 = tolower_l(*(const UChar *)s1, locale); \ - c2 = tolower_l(*(const UChar *)s2, locale); \ - if (c1 != c2) break; \ - if (c1 == 0) break; \ - s1++; s2++; \ - } \ - if ((UChar)c1 < (UChar)c2) return -1; \ - if ((UChar)c1 > (UChar)c2) return 1; \ - return 0; \ +#define STRCASECMP_L(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20140, soname, fnname)( \ + const char* s1, const char* s2, void* locale); \ + int VG_REPLACE_FUNCTION_EZU(20140, soname, fnname)( \ + const char* s1, const char* s2, void* locale) \ + { \ + extern int tolower_l(int, void*) __attribute__((weak)); \ + register UChar c1; \ + register UChar c2; \ + while (True) { \ + c1 = tolower_l(*(const UChar*)s1, locale); \ + c2 = tolower_l(*(const UChar*)s2, locale); \ + if (c1 != c2) \ + break; \ + if (c1 == 0) \ + break; \ + s1++; \ + s2++; \ + } \ + if ((UChar)c1 < (UChar)c2) \ + return -1; \ + if ((UChar)c1 > (UChar)c2) \ + return 1; \ + return 0; \ } #if defined(VGO_linux) - STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) - STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l) - STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l) +STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) +STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l) +STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l) #elif defined(VGO_freebsd) - STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) +STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) #elif defined(VGO_darwin) - //STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) +// STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) #elif defined(VGO_solaris) #endif - /*---------------------- strncasecmp_l ----------------------*/ -#define STRNCASECMP_L(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20150,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax, void* locale ); \ - int VG_REPLACE_FUNCTION_EZU(20150,soname,fnname) \ - ( const char* s1, const char* s2, SizeT nmax, void* locale ) \ - { \ - extern int tolower_l(int, void*) __attribute__((weak)); \ - SizeT n = 0; \ - while (True) { \ - if (n >= nmax) return 0; \ - if (*s1 == 0 && *s2 == 0) return 0; \ - if (*s1 == 0) return -1; \ - if (*s2 == 0) return 1; \ - \ - if (tolower_l(*(const UChar *)s1, locale) \ - < tolower_l(*(const UChar *)s2, locale)) return -1; \ - if (tolower_l(*(const UChar *)s1, locale) \ - > tolower_l(*(const UChar *)s2, locale)) return 1; \ - \ - s1++; s2++; n++; \ - } \ +#define STRNCASECMP_L(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20150, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax, void* locale); \ + int VG_REPLACE_FUNCTION_EZU(20150, soname, fnname)( \ + const char* s1, const char* s2, SizeT nmax, void* locale) \ + { \ + extern int tolower_l(int, void*) __attribute__((weak)); \ + SizeT n = 0; \ + while (True) { \ + if (n >= nmax) \ + return 0; \ + if (*s1 == 0 && *s2 == 0) \ + return 0; \ + if (*s1 == 0) \ + return -1; \ + if (*s2 == 0) \ + return 1; \ + \ + if (tolower_l(*(const UChar*)s1, locale) < \ + tolower_l(*(const UChar*)s2, locale)) \ + return -1; \ + if (tolower_l(*(const UChar*)s1, locale) > \ + tolower_l(*(const UChar*)s2, locale)) \ + return 1; \ + \ + s1++; \ + s2++; \ + n++; \ + } \ } #if defined(VGO_linux) - STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) - STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l) - STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI___strncasecmp_l) +STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) +STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l) +STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI___strncasecmp_l) #elif defined(VGO_freebsd) - STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) +STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) #elif defined(VGO_darwin) - //STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) - //STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l) +// STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) +// STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l) #elif defined(VGO_solaris) #endif - /*---------------------- strcmp ----------------------*/ -#define STRCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20160,soname,fnname) \ - ( const char* s1, const char* s2 ); \ - int VG_REPLACE_FUNCTION_EZU(20160,soname,fnname) \ - ( const char* s1, const char* s2 ) \ - { \ - register UChar c1; \ - register UChar c2; \ - while (True) { \ - c1 = *(const UChar *)s1; \ - c2 = *(const UChar *)s2; \ - if (c1 != c2) break; \ - if (c1 == 0) break; \ - s1++; s2++; \ - } \ - if ((UChar)c1 < (UChar)c2) return -1; \ - if ((UChar)c1 > (UChar)c2) return 1; \ - return 0; \ +#define STRCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20160, soname, fnname)(const char* s1, \ + const char* s2); \ + int VG_REPLACE_FUNCTION_EZU(20160, soname, fnname)(const char* s1, \ + const char* s2) \ + { \ + register UChar c1; \ + register UChar c2; \ + while (True) { \ + c1 = *(const UChar*)s1; \ + c2 = *(const UChar*)s2; \ + if (c1 != c2) \ + break; \ + if (c1 == 0) \ + break; \ + s1++; \ + s2++; \ + } \ + if ((UChar)c1 < (UChar)c2) \ + return -1; \ + if ((UChar)c1 > (UChar)c2) \ + return 1; \ + return 0; \ } #if defined(VGO_linux) - STRCMP(VG_Z_LIBC_SONAME, strcmp) - STRCMP(VG_Z_LIBC_SONAME, __GI_strcmp) - STRCMP(VG_Z_LIBC_SONAME, __strcmp_sse2) - STRCMP(VG_Z_LIBC_SONAME, __strcmp_sse42) - STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp) - STRCMP(VG_Z_LD64_SO_1, strcmp) -# if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \ - || defined(VGPV_mips32_linux_android) - STRCMP(NONE, __dl_strcmp); /* in /system/bin/linker */ -# endif +STRCMP(VG_Z_LIBC_SONAME, strcmp) +STRCMP(VG_Z_LIBC_SONAME, __GI_strcmp) +STRCMP(VG_Z_LIBC_SONAME, __strcmp_sse2) +STRCMP(VG_Z_LIBC_SONAME, __strcmp_sse42) +STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp) +STRCMP(VG_Z_LD64_SO_1, strcmp) +#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) || \ + defined(VGPV_mips32_linux_android) +STRCMP(NONE, __dl_strcmp); /* in /system/bin/linker */ +#endif #elif defined(VGO_freebsd) - STRCMP(VG_Z_LIBC_SONAME, strcmp) - STRCMP(VG_Z_LD_ELF_SO_1, strcmp) - STRCMP(VG_Z_LD_ELF32_SO_1, strcmp) +STRCMP(VG_Z_LIBC_SONAME, strcmp) +STRCMP(VG_Z_LD_ELF_SO_1, strcmp) +STRCMP(VG_Z_LD_ELF32_SO_1, strcmp) #elif defined(VGO_darwin) - STRCMP(VG_Z_LIBC_SONAME, strcmp) -# if DARWIN_VERS >= DARWIN_10_9 - STRCMP(libsystemZuplatformZddylib, _platform_strcmp) -# endif +STRCMP(VG_Z_LIBC_SONAME, strcmp) +#if DARWIN_VERS >= DARWIN_10_9 +STRCMP(libsystemZuplatformZddylib, _platform_strcmp) +#endif #elif defined(VGO_solaris) - STRCMP(VG_Z_LIBC_SONAME, strcmp) - STRCMP(VG_Z_LD_SO_1, strcmp) +STRCMP(VG_Z_LIBC_SONAME, strcmp) +STRCMP(VG_Z_LD_SO_1, strcmp) #endif - /*---------------------- memchr ----------------------*/ -#define MEMCHR(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20170,soname,fnname) \ - (const void *s, int c, SizeT n); \ - void* VG_REPLACE_FUNCTION_EZU(20170,soname,fnname) \ - (const void *s, int c, SizeT n) \ - { \ - SizeT i; \ - UChar c0 = (UChar)c; \ - const UChar* p = s; \ - for (i = 0; i < n; i++) \ - if (p[i] == c0) return CONST_CAST(void *,&p[i]); \ - return NULL; \ +#define MEMCHR(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20170, soname, fnname)(const void* s, int c, \ + SizeT n); \ + void* VG_REPLACE_FUNCTION_EZU(20170, soname, fnname)(const void* s, int c, \ + SizeT n) \ + { \ + SizeT i; \ + UChar c0 = (UChar)c; \ + const UChar* p = s; \ + for (i = 0; i < n; i++) \ + if (p[i] == c0) \ + return CONST_CAST(void*, &p[i]); \ + return NULL; \ } #if defined(VGO_linux) - MEMCHR(VG_Z_LIBC_SONAME, memchr) - MEMCHR(VG_Z_LIBC_SONAME, __GI_memchr) +MEMCHR(VG_Z_LIBC_SONAME, memchr) +MEMCHR(VG_Z_LIBC_SONAME, __GI_memchr) #elif defined(VGO_freebsd) - MEMCHR(VG_Z_LIBC_SONAME, memchr) +MEMCHR(VG_Z_LIBC_SONAME, memchr) #elif defined(VGO_darwin) -# if DARWIN_VERS == DARWIN_10_9 - MEMCHR(VG_Z_DYLD, memchr) - MEMCHR(libsystemZuplatformZddylib, _platform_memchr) -# endif -# if DARWIN_VERS >= DARWIN_10_10 - MEMCHR(VG_Z_DYLD, memchr) - /* _platform_memchr$VARIANT$Generic */ - MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Generic) - /* _platform_memchr$VARIANT$Haswell */ - MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Haswell) -# endif +#if DARWIN_VERS == DARWIN_10_9 +MEMCHR(VG_Z_DYLD, memchr) +MEMCHR(libsystemZuplatformZddylib, _platform_memchr) +#endif +#if DARWIN_VERS >= DARWIN_10_10 +MEMCHR(VG_Z_DYLD, memchr) +/* _platform_memchr$VARIANT$Generic */ +MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Generic) +/* _platform_memchr$VARIANT$Haswell */ +MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Haswell) +#endif #elif defined(VGO_solaris) - MEMCHR(VG_Z_LIBC_SONAME, memchr) +MEMCHR(VG_Z_LIBC_SONAME, memchr) #endif - /*---------------------- memrchr ----------------------*/ -#define MEMRCHR(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \ - (const void *s, int c, SizeT n); \ - void* VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \ - (const void *s, int c, SizeT n) \ - { \ - SizeT i; \ - UChar c0 = (UChar)c; \ - const UChar* p = s; \ - for (i = 0; i < n; i++) \ - if (p[n-1-i] == c0) return CONST_CAST(void *,&p[n-1-i]); \ - return NULL; \ +#define MEMRCHR(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20360, soname, fnname)(const void* s, int c, \ + SizeT n); \ + void* VG_REPLACE_FUNCTION_EZU(20360, soname, fnname)(const void* s, int c, \ + SizeT n) \ + { \ + SizeT i; \ + UChar c0 = (UChar)c; \ + const UChar* p = s; \ + for (i = 0; i < n; i++) \ + if (p[n - 1 - i] == c0) \ + return CONST_CAST(void*, &p[n - 1 - i]); \ + return NULL; \ } #if defined(VGO_linux) - MEMRCHR(VG_Z_LIBC_SONAME, memrchr) +MEMRCHR(VG_Z_LIBC_SONAME, memrchr) #elif defined(VGO_freebsd) - MEMRCHR(VG_Z_LIBC_SONAME, memrchr) +MEMRCHR(VG_Z_LIBC_SONAME, memrchr) #elif defined(VGO_darwin) - //MEMRCHR(VG_Z_LIBC_SONAME, memrchr) - //MEMRCHR(VG_Z_DYLD, memrchr) +// MEMRCHR(VG_Z_LIBC_SONAME, memrchr) +// MEMRCHR(VG_Z_DYLD, memrchr) #elif defined(VGO_solaris) #endif - /*---------------------- memcpy ----------------------*/ -#define MEMMOVE_OR_MEMCPY(becTag, soname, fnname, do_ol_check) \ - void* VG_REPLACE_FUNCTION_EZZ(becTag,soname,fnname) \ - ( void *dst, const void *src, SizeT len ); \ - void* VG_REPLACE_FUNCTION_EZZ(becTag,soname,fnname) \ - ( void *dst, const void *src, SizeT len ) \ - { \ - RECORD_COPY(len); \ - if (do_ol_check && is_overlap(dst, src, len, len)) \ - RECORD_OVERLAP_ERROR("memcpy", dst, src, len); \ - \ - const Addr WS = sizeof(UWord); /* 8 or 4 */ \ - const Addr WM = WS - 1; /* 7 or 3 */ \ - \ - if (len > 0) { \ - if (dst < src || !is_overlap(dst, src, len, len)) { \ - \ - /* Copying backwards. */ \ - SizeT n = len; \ - Addr d = (Addr)dst; \ - Addr s = (Addr)src; \ - \ - if (((s^d) & WM) == 0) { \ - /* s and d have same UWord alignment. */ \ - /* Pull up to a UWord boundary. */ \ - while ((s & WM) != 0 && n >= 1) \ - { *(UChar*)d = *(UChar*)s; s += 1; d += 1; n -= 1; } \ - /* Copy UWords. */ \ - while (n >= WS * 4) \ - { *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; \ - *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; \ - *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; \ - *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; } \ - while (n >= WS) \ - { *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; } \ - if (n == 0) \ - return dst; \ - } \ - if (((s|d) & 1) == 0) { \ - /* Both are 16-aligned; copy what we can thusly. */ \ - while (n >= 2) \ - { *(UShort*)d = *(UShort*)s; s += 2; d += 2; n -= 2; } \ - } \ - /* Copy leftovers, or everything if misaligned. */ \ - while (n >= 1) \ - { *(UChar*)d = *(UChar*)s; s += 1; d += 1; n -= 1; } \ - \ - } else if (dst > src) { \ - \ - SizeT n = len; \ - Addr d = ((Addr)dst) + n; \ - Addr s = ((Addr)src) + n; \ - \ - /* Copying forwards. */ \ - if (((s^d) & WM) == 0) { \ - /* s and d have same UWord alignment. */ \ - /* Back down to a UWord boundary. */ \ - while ((s & WM) != 0 && n >= 1) \ - { s -= 1; d -= 1; *(UChar*)d = *(UChar*)s; n -= 1; } \ - /* Copy UWords. */ \ - while (n >= WS * 4) \ - { s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; \ - s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; \ - s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; \ - s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; } \ - while (n >= WS) \ - { s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; } \ - if (n == 0) \ - return dst; \ - } \ - if (((s|d) & 1) == 0) { \ - /* Both are 16-aligned; copy what we can thusly. */ \ - while (n >= 2) \ - { s -= 2; d -= 2; *(UShort*)d = *(UShort*)s; n -= 2; } \ - } \ - /* Copy leftovers, or everything if misaligned. */ \ - while (n >= 1) \ - { s -= 1; d -= 1; *(UChar*)d = *(UChar*)s; n -= 1; } \ - \ - } \ - } \ - \ - return dst; \ +#define MEMMOVE_OR_MEMCPY(becTag, soname, fnname, do_ol_check) \ + void* VG_REPLACE_FUNCTION_EZZ(becTag, soname, fnname)( \ + void* dst, const void* src, SizeT len); \ + void* VG_REPLACE_FUNCTION_EZZ(becTag, soname, fnname)( \ + void* dst, const void* src, SizeT len) \ + { \ + RECORD_COPY(len); \ + if (do_ol_check && is_overlap(dst, src, len, len)) \ + RECORD_OVERLAP_ERROR("memcpy", dst, src, len); \ + \ + const Addr WS = sizeof(UWord); /* 8 or 4 */ \ + const Addr WM = WS - 1; /* 7 or 3 */ \ + \ + if (len > 0) { \ + if (dst < src || !is_overlap(dst, src, len, len)) { \ + \ + /* Copying backwards. */ \ + SizeT n = len; \ + Addr d = (Addr)dst; \ + Addr s = (Addr)src; \ + \ + if (((s ^ d) & WM) == 0) { \ + /* s and d have same UWord alignment. */ \ + /* Pull up to a UWord boundary. */ \ + while ((s & WM) != 0 && n >= 1) { \ + *(UChar*)d = *(UChar*)s; \ + s += 1; \ + d += 1; \ + n -= 1; \ + } \ + /* Copy UWords. */ \ + while (n >= WS * 4) { \ + *(UWord*)d = *(UWord*)s; \ + s += WS; \ + d += WS; \ + n -= WS; \ + *(UWord*)d = *(UWord*)s; \ + s += WS; \ + d += WS; \ + n -= WS; \ + *(UWord*)d = *(UWord*)s; \ + s += WS; \ + d += WS; \ + n -= WS; \ + *(UWord*)d = *(UWord*)s; \ + s += WS; \ + d += WS; \ + n -= WS; \ + } \ + while (n >= WS) { \ + *(UWord*)d = *(UWord*)s; \ + s += WS; \ + d += WS; \ + n -= WS; \ + } \ + if (n == 0) \ + return dst; \ + } \ + if (((s | d) & 1) == 0) { \ + /* Both are 16-aligned; copy what we can thusly. */ \ + while (n >= 2) { \ + *(UShort*)d = *(UShort*)s; \ + s += 2; \ + d += 2; \ + n -= 2; \ + } \ + } \ + /* Copy leftovers, or everything if misaligned. */ \ + while (n >= 1) { \ + *(UChar*)d = *(UChar*)s; \ + s += 1; \ + d += 1; \ + n -= 1; \ + } \ + \ + } else if (dst > src) { \ + \ + SizeT n = len; \ + Addr d = ((Addr)dst) + n; \ + Addr s = ((Addr)src) + n; \ + \ + /* Copying forwards. */ \ + if (((s ^ d) & WM) == 0) { \ + /* s and d have same UWord alignment. */ \ + /* Back down to a UWord boundary. */ \ + while ((s & WM) != 0 && n >= 1) { \ + s -= 1; \ + d -= 1; \ + *(UChar*)d = *(UChar*)s; \ + n -= 1; \ + } \ + /* Copy UWords. */ \ + while (n >= WS * 4) { \ + s -= WS; \ + d -= WS; \ + *(UWord*)d = *(UWord*)s; \ + n -= WS; \ + s -= WS; \ + d -= WS; \ + *(UWord*)d = *(UWord*)s; \ + n -= WS; \ + s -= WS; \ + d -= WS; \ + *(UWord*)d = *(UWord*)s; \ + n -= WS; \ + s -= WS; \ + d -= WS; \ + *(UWord*)d = *(UWord*)s; \ + n -= WS; \ + } \ + while (n >= WS) { \ + s -= WS; \ + d -= WS; \ + *(UWord*)d = *(UWord*)s; \ + n -= WS; \ + } \ + if (n == 0) \ + return dst; \ + } \ + if (((s | d) & 1) == 0) { \ + /* Both are 16-aligned; copy what we can thusly. */ \ + while (n >= 2) { \ + s -= 2; \ + d -= 2; \ + *(UShort*)d = *(UShort*)s; \ + n -= 2; \ + } \ + } \ + /* Copy leftovers, or everything if misaligned. */ \ + while (n >= 1) { \ + s -= 1; \ + d -= 1; \ + *(UChar*)d = *(UChar*)s; \ + n -= 1; \ + } \ + } \ + } \ + \ + return dst; \ } -#define MEMMOVE(soname, fnname) \ - MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0) +#define MEMMOVE(soname, fnname) MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0) -#define MEMCPY(soname, fnname) \ - MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) +#define MEMCPY(soname, fnname) MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) #if defined(VGO_linux) - /* For older memcpy we have to use memmove-like semantics and skip - the overlap check; sigh; see #275284. */ - MEMMOVE(VG_Z_LIBC_SONAME, memcpyZAGLIBCZu2Zd2Zd5) /* memcpy@GLIBC_2.2.5 */ - MEMCPY(VG_Z_LIBC_SONAME, memcpyZAZAGLIBCZu2Zd14) /* memcpy@@GLIBC_2.14 */ - MEMCPY(VG_Z_LIBC_SONAME, memcpy) /* fallback case */ - MEMCPY(VG_Z_LIBC_SONAME, __GI_memcpy) - MEMCPY(VG_Z_LIBC_SONAME, __memcpy_sse2) - MEMCPY(VG_Z_LIBC_SONAME, __memcpy_avx_unaligned_erms) - MEMCPY(VG_Z_LD_SO_1, memcpy) /* ld.so.1 */ - MEMCPY(VG_Z_LD64_SO_1, memcpy) /* ld64.so.1 */ - /* icc9 blats these around all over the place. Not only in the main - executable but various .so's. They are highly tuned and read - memory beyond the source boundary (although work correctly and - never go across page boundaries), so give errors when run - natively, at least for misaligned source arg. Just intercepting - in the exe only until we understand more about the problem. See - http://bugs.kde.org/show_bug.cgi?id=139776 - */ - MEMCPY(NONE, ZuintelZufastZumemcpy) +/* For older memcpy we have to use memmove-like semantics and skip + the overlap check; sigh; see #275284. */ +MEMMOVE(VG_Z_LIBC_SONAME, memcpyZAGLIBCZu2Zd2Zd5) /* memcpy@GLIBC_2.2.5 */ +MEMCPY(VG_Z_LIBC_SONAME, memcpyZAZAGLIBCZu2Zd14) /* memcpy@@GLIBC_2.14 */ +MEMCPY(VG_Z_LIBC_SONAME, memcpy) /* fallback case */ +MEMCPY(VG_Z_LIBC_SONAME, __GI_memcpy) +MEMCPY(VG_Z_LIBC_SONAME, __memcpy_sse2) +MEMCPY(VG_Z_LIBC_SONAME, __memcpy_avx_unaligned_erms) +MEMCPY(VG_Z_LD_SO_1, memcpy) /* ld.so.1 */ +MEMCPY(VG_Z_LD64_SO_1, memcpy) /* ld64.so.1 */ +/* icc9 blats these around all over the place. Not only in the main + executable but various .so's. They are highly tuned and read + memory beyond the source boundary (although work correctly and + never go across page boundaries), so give errors when run + natively, at least for misaligned source arg. Just intercepting + in the exe only until we understand more about the problem. See + http://bugs.kde.org/show_bug.cgi?id=139776 +*/ +MEMCPY(NONE, ZuintelZufastZumemcpy) #elif defined(VGO_freebsd) - MEMCPY(VG_Z_LIBC_SONAME, memcpy) - MEMCPY(VG_Z_LD_ELF_SO_1, memcpy) - MEMCPY(VG_Z_LD_ELF32_SO_1, memcpy) +MEMCPY(VG_Z_LIBC_SONAME, memcpy) +MEMCPY(VG_Z_LD_ELF_SO_1, memcpy) +MEMCPY(VG_Z_LD_ELF32_SO_1, memcpy) #elif defined(VGO_darwin) -# if DARWIN_VERS <= DARWIN_10_6 - MEMCPY(VG_Z_LIBC_SONAME, memcpy) -# endif - MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse3x) /* memcpy$VARIANT$sse3x */ - MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse42) /* memcpy$VARIANT$sse42 */ +#if DARWIN_VERS <= DARWIN_10_6 +MEMCPY(VG_Z_LIBC_SONAME, memcpy) +#endif +MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse3x) /* memcpy$VARIANT$sse3x */ +MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse42) /* memcpy$VARIANT$sse42 */ #elif defined(VGO_solaris) - MEMCPY(VG_Z_LIBC_SONAME, memcpy) - MEMCPY(VG_Z_LIBC_SONAME, memcpyZPZa) - MEMCPY(VG_Z_LD_SO_1, memcpy) +MEMCPY(VG_Z_LIBC_SONAME, memcpy) +MEMCPY(VG_Z_LIBC_SONAME, memcpyZPZa) +MEMCPY(VG_Z_LD_SO_1, memcpy) #endif - /*---------------------- memcmp ----------------------*/ -#define MEMCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20190,soname,fnname) \ - ( const void *s1V, const void *s2V, SizeT n ); \ - int VG_REPLACE_FUNCTION_EZU(20190,soname,fnname) \ - ( const void *s1V, const void *s2V, SizeT n ) \ - { \ - const SizeT WS = sizeof(UWord); /* 8 or 4 */ \ - const SizeT WM = WS - 1; /* 7 or 3 */ \ - Addr s1A = (Addr)s1V; \ - Addr s2A = (Addr)s2V; \ - \ - if (((s1A | s2A) & WM) == 0) { \ - /* Both areas are word aligned. Skip over the */ \ - /* equal prefix as fast as possible. */ \ - while (n >= WS) { \ - UWord w1 = *(UWord*)s1A; \ - UWord w2 = *(UWord*)s2A; \ - if (w1 != w2) break; \ - s1A += WS; \ - s2A += WS; \ - n -= WS; \ - } \ - } \ - \ - const UChar* s1 = (const UChar*) s1A; \ - const UChar* s2 = (const UChar*) s2A; \ - \ - while (n != 0) { \ - UChar a0 = s1[0]; \ - UChar b0 = s2[0]; \ - s1 += 1; \ - s2 += 1; \ - int res = ((int)a0) - ((int)b0); \ - if (res != 0) \ - return res; \ - n -= 1; \ - } \ - return 0; \ +#define MEMCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20190, soname, fnname)( \ + const void* s1V, const void* s2V, SizeT n); \ + int VG_REPLACE_FUNCTION_EZU(20190, soname, fnname)( \ + const void* s1V, const void* s2V, SizeT n) \ + { \ + const SizeT WS = sizeof(UWord); /* 8 or 4 */ \ + const SizeT WM = WS - 1; /* 7 or 3 */ \ + Addr s1A = (Addr)s1V; \ + Addr s2A = (Addr)s2V; \ + \ + if (((s1A | s2A) & WM) == 0) { \ + /* Both areas are word aligned. Skip over the */ \ + /* equal prefix as fast as possible. */ \ + while (n >= WS) { \ + UWord w1 = *(UWord*)s1A; \ + UWord w2 = *(UWord*)s2A; \ + if (w1 != w2) \ + break; \ + s1A += WS; \ + s2A += WS; \ + n -= WS; \ + } \ + } \ + \ + const UChar* s1 = (const UChar*)s1A; \ + const UChar* s2 = (const UChar*)s2A; \ + \ + while (n != 0) { \ + UChar a0 = s1[0]; \ + UChar b0 = s2[0]; \ + s1 += 1; \ + s2 += 1; \ + int res = ((int)a0) - ((int)b0); \ + if (res != 0) \ + return res; \ + n -= 1; \ + } \ + return 0; \ } #if defined(VGO_linux) - MEMCMP(VG_Z_LIBC_SONAME, memcmp) - MEMCMP(VG_Z_LIBC_SONAME, __GI_memcmp) - MEMCMP(VG_Z_LIBC_SONAME, __memcmp_sse2) - MEMCMP(VG_Z_LIBC_SONAME, __memcmp_sse4_1) - MEMCMP(VG_Z_LIBC_SONAME, bcmp) - MEMCMP(VG_Z_LD_SO_1, bcmp) +MEMCMP(VG_Z_LIBC_SONAME, memcmp) +MEMCMP(VG_Z_LIBC_SONAME, __GI_memcmp) +MEMCMP(VG_Z_LIBC_SONAME, __memcmp_sse2) +MEMCMP(VG_Z_LIBC_SONAME, __memcmp_sse4_1) +MEMCMP(VG_Z_LIBC_SONAME, bcmp) +MEMCMP(VG_Z_LD_SO_1, bcmp) #elif defined(VGO_freebsd) - MEMCMP(VG_Z_LIBC_SONAME, memcmp) - MEMCMP(VG_Z_LIBC_SONAME, bcmp) +MEMCMP(VG_Z_LIBC_SONAME, memcmp) +MEMCMP(VG_Z_LIBC_SONAME, bcmp) #elif defined(VGO_darwin) -# if DARWIN_VERS >= DARWIN_10_9 - MEMCMP(libsystemZuplatformZddylib, _platform_memcmp) -# endif +#if DARWIN_VERS >= DARWIN_10_9 +MEMCMP(libsystemZuplatformZddylib, _platform_memcmp) +#endif #elif defined(VGO_solaris) - MEMCMP(VG_Z_LIBC_SONAME, memcmp) - MEMCMP(VG_Z_LIBC_SONAME, bcmp) - MEMCMP(VG_Z_LD_SO_1, memcmp) +MEMCMP(VG_Z_LIBC_SONAME, memcmp) +MEMCMP(VG_Z_LIBC_SONAME, bcmp) +MEMCMP(VG_Z_LD_SO_1, memcmp) #endif - /*---------------------- stpcpy ----------------------*/ /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. (minor variant of strcpy) */ -#define STPCPY(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20200,soname,fnname) \ - ( char* dst, const char* src ); \ - char* VG_REPLACE_FUNCTION_EZU(20200,soname,fnname) \ - ( char* dst, const char* src ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_orig = dst; \ - \ - while (*src) *dst++ = *src++; \ - *dst = 0; \ - \ - /* This checks for overlap after copying, unavoidable without */ \ - /* pre-counting length... should be ok */ \ - SizeT srclen = (Addr)src-(Addr)src_orig+1; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_orig, \ - src_orig, \ - (Addr)dst-(Addr)dst_orig+1, \ - srclen)) \ - RECORD_OVERLAP_ERROR("stpcpy", dst_orig, src_orig, 0); \ - \ - return dst; \ +#define STPCPY(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20200, soname, fnname)(char* dst, \ + const char* src); \ + char* VG_REPLACE_FUNCTION_EZU(20200, soname, fnname)(char* dst, \ + const char* src) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_orig = dst; \ + \ + while (*src) \ + *dst++ = *src++; \ + *dst = 0; \ + \ + /* This checks for overlap after copying, unavoidable without */ \ + /* pre-counting length... should be ok */ \ + SizeT srclen = (Addr)src - (Addr)src_orig + 1; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, src_orig, (Addr)dst - (Addr)dst_orig + 1, \ + srclen)) \ + RECORD_OVERLAP_ERROR("stpcpy", dst_orig, src_orig, 0); \ + \ + return dst; \ } #if defined(VGO_linux) - STPCPY(VG_Z_LIBC_SONAME, stpcpy) - STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy) - STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2) - STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2_unaligned) - STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy) - STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy) - STPCPY(VG_Z_LD_LINUX_AARCH64_SO_1,stpcpy) +STPCPY(VG_Z_LIBC_SONAME, stpcpy) +STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy) +STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2) +STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2_unaligned) +STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy) +STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy) +STPCPY(VG_Z_LD_LINUX_AARCH64_SO_1, stpcpy) #elif defined(VGO_freebsd) - STPCPY(VG_Z_LD_ELF_SO_1, stpcpy) - STPCPY(VG_Z_LD_ELF32_SO_1, stpcpy) - STPCPY(VG_Z_LIBC_SONAME, stpcpy) +STPCPY(VG_Z_LD_ELF_SO_1, stpcpy) +STPCPY(VG_Z_LD_ELF32_SO_1, stpcpy) +STPCPY(VG_Z_LIBC_SONAME, stpcpy) #elif defined(VGO_freebsd) - STPCPY(VG_Z_LD_ELF_SO_1, stpcpy) - STPCPY(VG_Z_LD_ELF32_SO_1, stpcpy) - STPCPY(VG_Z_LIBC_SONAME, stpcpy) +STPCPY(VG_Z_LD_ELF_SO_1, stpcpy) +STPCPY(VG_Z_LD_ELF32_SO_1, stpcpy) +STPCPY(VG_Z_LIBC_SONAME, stpcpy) #elif defined(VGO_darwin) - //STPCPY(VG_Z_LIBC_SONAME, stpcpy) - //STPCPY(VG_Z_DYLD, stpcpy) +// STPCPY(VG_Z_LIBC_SONAME, stpcpy) +// STPCPY(VG_Z_DYLD, stpcpy) #elif defined(VGO_solaris) - STPCPY(VG_Z_LIBC_SONAME, stpcpy) +STPCPY(VG_Z_LIBC_SONAME, stpcpy) #endif - /*---------------------- stpncpy ----------------------*/ -#define STPNCPY(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20420,soname,fnname) \ - ( char* dst, const char* src, SizeT n ); \ - char* VG_REPLACE_FUNCTION_EZU(20420,soname,fnname) \ - ( char* dst, const char* src, SizeT n ) \ - { \ - const HChar* src_orig = src; \ - HChar* dst_str = dst; \ - SizeT m = 0; \ - \ - while (m < n && *src) { m++; *dst++ = *src++; } \ - /* Check for overlap after copying; all n bytes of dst are relevant, */ \ - /* but only m+1 bytes of src if terminator was found */ \ - SizeT srclen = (m < n) ? m+1 : n; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_str, src_orig, n, srclen)) \ - RECORD_OVERLAP_ERROR("stpncpy", dst, src, n); \ - dst_str = dst; \ - while (m++ < n) *dst++ = 0; /* must pad remainder with nulls */ \ - \ - return dst_str; \ +#define STPNCPY(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20420, soname, \ + fnname)(char* dst, const char* src, SizeT n); \ + char* VG_REPLACE_FUNCTION_EZU(20420, soname, \ + fnname)(char* dst, const char* src, SizeT n) \ + { \ + const HChar* src_orig = src; \ + HChar* dst_str = dst; \ + SizeT m = 0; \ + \ + while (m < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } \ + /* Check for overlap after copying; all n bytes of dst are relevant, */ \ + /* but only m+1 bytes of src if terminator was found */ \ + SizeT srclen = (m < n) ? m + 1 : n; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_str, src_orig, n, srclen)) \ + RECORD_OVERLAP_ERROR("stpncpy", dst, src, n); \ + dst_str = dst; \ + while (m++ < n) \ + *dst++ = 0; /* must pad remainder with nulls */ \ + \ + return dst_str; \ } #if defined(VGO_linux) || defined(VGO_freebsd) - STPNCPY(VG_Z_LIBC_SONAME, stpncpy) +STPNCPY(VG_Z_LIBC_SONAME, stpncpy) #endif - /*---------------------- memset ----------------------*/ -#define MEMSET(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZZ(20210,soname,fnname) \ - (void *s, Int c, SizeT n); \ - void* VG_REPLACE_FUNCTION_EZZ(20210,soname,fnname) \ - (void *s, Int c, SizeT n) \ - { \ - if (sizeof(void*) == 8) { \ - Addr a = (Addr)s; \ - ULong c8 = (c & 0xFF); \ - c8 = (c8 << 8) | c8; \ - c8 = (c8 << 16) | c8; \ - c8 = (c8 << 32) | c8; \ - while ((a & 7) != 0 && n >= 1) \ - { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \ - while (n >= 32) \ - { *(ULong*)a = c8; a += 8; n -= 8; \ - *(ULong*)a = c8; a += 8; n -= 8; \ - *(ULong*)a = c8; a += 8; n -= 8; \ - *(ULong*)a = c8; a += 8; n -= 8; } \ - while (n >= 8) \ - { *(ULong*)a = c8; a += 8; n -= 8; } \ - while (n >= 1) \ - { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \ - return s; \ - } else { \ - Addr a = (Addr)s; \ - UInt c4 = (c & 0xFF); \ - c4 = (c4 << 8) | c4; \ - c4 = (c4 << 16) | c4; \ - while ((a & 3) != 0 && n >= 1) \ - { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \ - while (n >= 16) \ - { *(UInt*)a = c4; a += 4; n -= 4; \ - *(UInt*)a = c4; a += 4; n -= 4; \ - *(UInt*)a = c4; a += 4; n -= 4; \ - *(UInt*)a = c4; a += 4; n -= 4; } \ - while (n >= 4) \ - { *(UInt*)a = c4; a += 4; n -= 4; } \ - while (n >= 1) \ - { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \ - return s; \ - } \ +#define MEMSET(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZZ(20210, soname, fnname)(void* s, Int c, \ + SizeT n); \ + void* VG_REPLACE_FUNCTION_EZZ(20210, soname, fnname)(void* s, Int c, \ + SizeT n) \ + { \ + if (sizeof(void*) == 8) { \ + Addr a = (Addr)s; \ + ULong c8 = (c & 0xFF); \ + c8 = (c8 << 8) | c8; \ + c8 = (c8 << 16) | c8; \ + c8 = (c8 << 32) | c8; \ + while ((a & 7) != 0 && n >= 1) { \ + *(UChar*)a = (UChar)c; \ + a += 1; \ + n -= 1; \ + } \ + while (n >= 32) { \ + *(ULong*)a = c8; \ + a += 8; \ + n -= 8; \ + *(ULong*)a = c8; \ + a += 8; \ + n -= 8; \ + *(ULong*)a = c8; \ + a += 8; \ + n -= 8; \ + *(ULong*)a = c8; \ + a += 8; \ + n -= 8; \ + } \ + while (n >= 8) { \ + *(ULong*)a = c8; \ + a += 8; \ + n -= 8; \ + } \ + while (n >= 1) { \ + *(UChar*)a = (UChar)c; \ + a += 1; \ + n -= 1; \ + } \ + return s; \ + } else { \ + Addr a = (Addr)s; \ + UInt c4 = (c & 0xFF); \ + c4 = (c4 << 8) | c4; \ + c4 = (c4 << 16) | c4; \ + while ((a & 3) != 0 && n >= 1) { \ + *(UChar*)a = (UChar)c; \ + a += 1; \ + n -= 1; \ + } \ + while (n >= 16) { \ + *(UInt*)a = c4; \ + a += 4; \ + n -= 4; \ + *(UInt*)a = c4; \ + a += 4; \ + n -= 4; \ + *(UInt*)a = c4; \ + a += 4; \ + n -= 4; \ + *(UInt*)a = c4; \ + a += 4; \ + n -= 4; \ + } \ + while (n >= 4) { \ + *(UInt*)a = c4; \ + a += 4; \ + n -= 4; \ + } \ + while (n >= 1) { \ + *(UChar*)a = (UChar)c; \ + a += 1; \ + n -= 1; \ + } \ + return s; \ + } \ } #if defined(VGO_linux) - MEMSET(VG_Z_LIBC_SONAME, memset) +MEMSET(VG_Z_LIBC_SONAME, memset) #elif defined(VGO_freebsd) - MEMSET(VG_Z_LIBC_SONAME, memset) - MEMSET(VG_Z_LD_ELF_SO_1, memset) - MEMSET(VG_Z_LD_ELF32_SO_1, memset) +MEMSET(VG_Z_LIBC_SONAME, memset) +MEMSET(VG_Z_LD_ELF_SO_1, memset) +MEMSET(VG_Z_LD_ELF32_SO_1, memset) #elif defined(VGO_darwin) - //MEMSET(VG_Z_LIBC_SONAME, memset) - //MEMSET(VG_Z_DYLD, memset) - MEMSET(VG_Z_LIBC_SONAME, memset) +// MEMSET(VG_Z_LIBC_SONAME, memset) +// MEMSET(VG_Z_DYLD, memset) +MEMSET(VG_Z_LIBC_SONAME, memset) #elif defined(VGO_solaris) - MEMSET(VG_Z_LIBC_SONAME, memset) - MEMSET(VG_Z_LIBC_SONAME, memsetZPZa) +MEMSET(VG_Z_LIBC_SONAME, memset) +MEMSET(VG_Z_LIBC_SONAME, memsetZPZa) #endif - /*---------------------- memmove ----------------------*/ /* memmove -- use the MEMMOVE defn above. */ #if defined(VGO_linux) - MEMMOVE(VG_Z_LIBC_SONAME, memmove) - MEMMOVE(VG_Z_LIBC_SONAME, __GI_memmove) - /* See bug #349828 Override for ld64.so.1 like memcpy, because for some - arches MEMCPY_OK_FOR_FORWARD_MEMMOVE is set, which might cause memmove - to call memcpy. */ - MEMMOVE(VG_Z_LD64_SO_1, memmove) +MEMMOVE(VG_Z_LIBC_SONAME, memmove) +MEMMOVE(VG_Z_LIBC_SONAME, __GI_memmove) +/* See bug #349828 Override for ld64.so.1 like memcpy, because for some + arches MEMCPY_OK_FOR_FORWARD_MEMMOVE is set, which might cause memmove + to call memcpy. */ +MEMMOVE(VG_Z_LD64_SO_1, memmove) #elif defined(VGO_freebsd) - MEMMOVE(VG_Z_LD_ELF_SO_1, memmove) - MEMMOVE(VG_Z_LD_ELF32_SO_1, memmove) - MEMMOVE(VG_Z_LIBC_SONAME, memmove) +MEMMOVE(VG_Z_LD_ELF_SO_1, memmove) +MEMMOVE(VG_Z_LD_ELF32_SO_1, memmove) +MEMMOVE(VG_Z_LIBC_SONAME, memmove) #elif defined(VGO_darwin) -# if DARWIN_VERS <= DARWIN_10_6 - MEMMOVE(VG_Z_LIBC_SONAME, memmove) -# endif - MEMMOVE(VG_Z_LIBC_SONAME, memmoveZDVARIANTZDsse3x) /* memmove$VARIANT$sse3x */ - MEMMOVE(VG_Z_LIBC_SONAME, memmoveZDVARIANTZDsse42) /* memmove$VARIANT$sse42 */ -# if DARWIN_VERS >= DARWIN_10_9 - /* _platform_memmove$VARIANT$Ivybridge */ - MEMMOVE(libsystemZuplatformZddylib, ZuplatformZumemmoveZDVARIANTZDIvybridge) -# endif +#if DARWIN_VERS <= DARWIN_10_6 +MEMMOVE(VG_Z_LIBC_SONAME, memmove) +#endif +MEMMOVE(VG_Z_LIBC_SONAME, memmoveZDVARIANTZDsse3x) /* memmove$VARIANT$sse3x */ +MEMMOVE(VG_Z_LIBC_SONAME, memmoveZDVARIANTZDsse42) /* memmove$VARIANT$sse42 */ +#if DARWIN_VERS >= DARWIN_10_9 +/* _platform_memmove$VARIANT$Ivybridge */ +MEMMOVE(libsystemZuplatformZddylib, ZuplatformZumemmoveZDVARIANTZDIvybridge) +#endif #elif defined(VGO_solaris) - MEMMOVE(VG_Z_LIBC_SONAME, memmove) - MEMMOVE(VG_Z_LIBC_SONAME, memmoveZPZa) - MEMMOVE(VG_Z_LD_SO_1, memmove) +MEMMOVE(VG_Z_LIBC_SONAME, memmove) +MEMMOVE(VG_Z_LIBC_SONAME, memmoveZPZa) +MEMMOVE(VG_Z_LD_SO_1, memmove) #endif - /*---------------------- bcopy ----------------------*/ -#define BCOPY(soname, fnname) \ - void VG_REPLACE_FUNCTION_EZU(20230,soname,fnname) \ - (const void *srcV, void *dstV, SizeT n); \ - void VG_REPLACE_FUNCTION_EZU(20230,soname,fnname) \ - (const void *srcV, void *dstV, SizeT n) \ - { \ - RECORD_COPY(n); \ - SizeT i; \ - HChar* dst = dstV; \ - const HChar* src = srcV; \ - if (dst < src) { \ - for (i = 0; i < n; i++) \ - dst[i] = src[i]; \ - } \ - else \ - if (dst > src) { \ - for (i = 0; i < n; i++) \ - dst[n-i-1] = src[n-i-1]; \ - } \ +#define BCOPY(soname, fnname) \ + void VG_REPLACE_FUNCTION_EZU(20230, soname, fnname)(const void* srcV, \ + void* dstV, SizeT n); \ + void VG_REPLACE_FUNCTION_EZU(20230, soname, fnname)(const void* srcV, \ + void* dstV, SizeT n) \ + { \ + RECORD_COPY(n); \ + SizeT i; \ + HChar* dst = dstV; \ + const HChar* src = srcV; \ + if (dst < src) { \ + for (i = 0; i < n; i++) \ + dst[i] = src[i]; \ + } else if (dst > src) { \ + for (i = 0; i < n; i++) \ + dst[n - i - 1] = src[n - i - 1]; \ + } \ } #if defined(VGO_linux) - BCOPY(VG_Z_LIBC_SONAME, bcopy) +BCOPY(VG_Z_LIBC_SONAME, bcopy) #elif defined(VGO_freebsd) - BCOPY(VG_Z_LIBC_SONAME, bcopy) - BCOPY(VG_Z_LD_ELF_SO_1, bcopy) - BCOPY(VG_Z_LD_ELF32_SO_1, bcopy) +BCOPY(VG_Z_LIBC_SONAME, bcopy) +BCOPY(VG_Z_LD_ELF_SO_1, bcopy) +BCOPY(VG_Z_LD_ELF32_SO_1, bcopy) #elif defined(VGO_darwin) - //BCOPY(VG_Z_LIBC_SONAME, bcopy) - //BCOPY(VG_Z_DYLD, bcopy) +// BCOPY(VG_Z_LIBC_SONAME, bcopy) +// BCOPY(VG_Z_DYLD, bcopy) #elif defined(VGO_darwin) - BCOPY(VG_Z_LIBC_SONAME, bcopy) +BCOPY(VG_Z_LIBC_SONAME, bcopy) #endif - /*-------------------- memmove_chk --------------------*/ /* glibc 2.5 variant of memmove which checks the dest is big enough. There is no specific part of glibc that this is copied from. */ -#define GLIBC25___MEMMOVE_CHK(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20240,soname,fnname) \ - (void *dstV, const void *srcV, SizeT n, SizeT destlen); \ - void* VG_REPLACE_FUNCTION_EZU(20240,soname,fnname) \ - (void *dstV, const void *srcV, SizeT n, SizeT destlen) \ - { \ - RECORD_COPY(n); \ - SizeT i; \ - HChar* dst = dstV; \ - const HChar* src = srcV; \ - if (destlen < n) \ - goto badness; \ - if (dst < src) { \ - for (i = 0; i < n; i++) \ - dst[i] = src[i]; \ - } \ - else \ - if (dst > src) { \ - for (i = 0; i < n; i++) \ - dst[n-i-1] = src[n-i-1]; \ - } \ - return dst; \ - badness: \ - VALGRIND_PRINTF_BACKTRACE( \ - "*** memmove_chk: buffer overflow detected ***: " \ - "program terminated\n"); \ - my_exit(1); \ - /*NOTREACHED*/ \ - return NULL; \ +#define GLIBC25___MEMMOVE_CHK(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20240, soname, fnname)( \ + void* dstV, const void* srcV, SizeT n, SizeT destlen); \ + void* VG_REPLACE_FUNCTION_EZU(20240, soname, fnname)( \ + void* dstV, const void* srcV, SizeT n, SizeT destlen) \ + { \ + RECORD_COPY(n); \ + SizeT i; \ + HChar* dst = dstV; \ + const HChar* src = srcV; \ + if (destlen < n) \ + goto badness; \ + if (dst < src) { \ + for (i = 0; i < n; i++) \ + dst[i] = src[i]; \ + } else if (dst > src) { \ + for (i = 0; i < n; i++) \ + dst[n - i - 1] = src[n - i - 1]; \ + } \ + return dst; \ + badness: \ + VALGRIND_PRINTF_BACKTRACE( \ + "*** memmove_chk: buffer overflow detected ***: " \ + "program terminated\n"); \ + my_exit(1); \ + /*NOTREACHED*/ \ + return NULL; \ } #if defined(VGO_linux) - GLIBC25___MEMMOVE_CHK(VG_Z_LIBC_SONAME, __memmove_chk) +GLIBC25___MEMMOVE_CHK(VG_Z_LIBC_SONAME, __memmove_chk) #elif defined(VGO_darwin) @@ -1513,30 +1634,31 @@ static inline void my_exit ( int x ) #endif - /*-------------------- strchrnul --------------------*/ /* Find the first occurrence of C in S or the final NUL byte. */ -#define GLIBC232_STRCHRNUL(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20250,soname,fnname) \ - (const char* s, int c_in); \ - char* VG_REPLACE_FUNCTION_EZU(20250,soname,fnname) \ - (const char* s, int c_in) \ - { \ - HChar c = (HChar) c_in; \ - const HChar* char_ptr = s; \ - while (1) { \ - if (*char_ptr == 0) return CONST_CAST(HChar *,char_ptr); \ - if (*char_ptr == c) return CONST_CAST(HChar *,char_ptr); \ - char_ptr++; \ - } \ +#define GLIBC232_STRCHRNUL(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20250, soname, fnname)(const char* s, \ + int c_in); \ + char* VG_REPLACE_FUNCTION_EZU(20250, soname, fnname)(const char* s, \ + int c_in) \ + { \ + HChar c = (HChar)c_in; \ + const HChar* char_ptr = s; \ + while (1) { \ + if (*char_ptr == 0) \ + return CONST_CAST(HChar*, char_ptr); \ + if (*char_ptr == c) \ + return CONST_CAST(HChar*, char_ptr); \ + char_ptr++; \ + } \ } #if defined(VGO_linux) - GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul) +GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul) #elif defined(VGO_freebsd) - GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul) +GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul) #elif defined(VGO_darwin) @@ -1544,27 +1666,27 @@ static inline void my_exit ( int x ) #endif - /*---------------------- rawmemchr ----------------------*/ /* Find the first occurrence of C in S. */ -#define GLIBC232_RAWMEMCHR(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20260,soname,fnname) \ - (const void* s, int c_in); \ - void* VG_REPLACE_FUNCTION_EZU(20260,soname,fnname) \ - (const void* s, int c_in) \ - { \ - UChar c = (UChar) c_in; \ - const UChar* char_ptr = s; \ - while (1) { \ - if (*char_ptr == c) return CONST_CAST(void *,char_ptr); \ - char_ptr++; \ - } \ +#define GLIBC232_RAWMEMCHR(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20260, soname, fnname)(const void* s, \ + int c_in); \ + void* VG_REPLACE_FUNCTION_EZU(20260, soname, fnname)(const void* s, \ + int c_in) \ + { \ + UChar c = (UChar)c_in; \ + const UChar* char_ptr = s; \ + while (1) { \ + if (*char_ptr == c) \ + return CONST_CAST(void*, char_ptr); \ + char_ptr++; \ + } \ } -#if defined (VGO_linux) - GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, rawmemchr) - GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, __GI___rawmemchr) +#if defined(VGO_linux) +GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, rawmemchr) +GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, __GI___rawmemchr) #elif defined(VGO_darwin) @@ -1572,37 +1694,36 @@ static inline void my_exit ( int x ) #endif - /*---------------------- strcpy_chk ----------------------*/ /* glibc variant of strcpy that checks the dest is big enough. Copied from glibc-2.5/debug/test-strcpy_chk.c. */ -#define GLIBC25___STRCPY_CHK(soname,fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20270,soname,fnname) \ - (char* dst, const char* src, SizeT len); \ - char* VG_REPLACE_FUNCTION_EZU(20270,soname,fnname) \ - (char* dst, const char* src, SizeT len) \ - { \ - FOR_COPY(const HChar* src_orig = src); \ - HChar* ret = dst; \ - if (! len) \ - goto badness; \ - while ((*dst++ = *src++) != '\0') \ - if (--len == 0) \ - goto badness; \ - RECORD_COPY((Addr)src-(Addr)src_orig); \ - return ret; \ - badness: \ - VALGRIND_PRINTF_BACKTRACE( \ - "*** strcpy_chk: buffer overflow detected ***: " \ - "program terminated\n"); \ - my_exit(1); \ - /*NOTREACHED*/ \ - return NULL; \ +#define GLIBC25___STRCPY_CHK(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20270, soname, fnname)( \ + char* dst, const char* src, SizeT len); \ + char* VG_REPLACE_FUNCTION_EZU(20270, soname, fnname)( \ + char* dst, const char* src, SizeT len) \ + { \ + FOR_COPY(const HChar* src_orig = src); \ + HChar* ret = dst; \ + if (!len) \ + goto badness; \ + while ((*dst++ = *src++) != '\0') \ + if (--len == 0) \ + goto badness; \ + RECORD_COPY((Addr)src - (Addr)src_orig); \ + return ret; \ + badness: \ + VALGRIND_PRINTF_BACKTRACE( \ + "*** strcpy_chk: buffer overflow detected ***: " \ + "program terminated\n"); \ + my_exit(1); \ + /*NOTREACHED*/ \ + return NULL; \ } #if defined(VGO_linux) - GLIBC25___STRCPY_CHK(VG_Z_LIBC_SONAME, __strcpy_chk) +GLIBC25___STRCPY_CHK(VG_Z_LIBC_SONAME, __strcpy_chk) #elif defined(VGO_darwin) @@ -1610,36 +1731,35 @@ static inline void my_exit ( int x ) #endif - /*---------------------- stpcpy_chk ----------------------*/ /* glibc variant of stpcpy that checks the dest is big enough. Copied from glibc-2.5/debug/test-stpcpy_chk.c. */ -#define GLIBC25___STPCPY_CHK(soname,fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20280,soname,fnname) \ - (char* dst, const char* src, SizeT len); \ - char* VG_REPLACE_FUNCTION_EZU(20280,soname,fnname) \ - (char* dst, const char* src, SizeT len) \ - { \ - FOR_COPY(const HChar* src_orig = src); \ - if (! len) \ - goto badness; \ - while ((*dst++ = *src++) != '\0') \ - if (--len == 0) \ - goto badness; \ - RECORD_COPY((Addr)src-(Addr)src_orig); \ - return dst - 1; \ - badness: \ - VALGRIND_PRINTF_BACKTRACE( \ - "*** stpcpy_chk: buffer overflow detected ***: " \ - "program terminated\n"); \ - my_exit(1); \ - /*NOTREACHED*/ \ - return NULL; \ +#define GLIBC25___STPCPY_CHK(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20280, soname, fnname)( \ + char* dst, const char* src, SizeT len); \ + char* VG_REPLACE_FUNCTION_EZU(20280, soname, fnname)( \ + char* dst, const char* src, SizeT len) \ + { \ + FOR_COPY(const HChar* src_orig = src); \ + if (!len) \ + goto badness; \ + while ((*dst++ = *src++) != '\0') \ + if (--len == 0) \ + goto badness; \ + RECORD_COPY((Addr)src - (Addr)src_orig); \ + return dst - 1; \ + badness: \ + VALGRIND_PRINTF_BACKTRACE( \ + "*** stpcpy_chk: buffer overflow detected ***: " \ + "program terminated\n"); \ + my_exit(1); \ + /*NOTREACHED*/ \ + return NULL; \ } #if defined(VGO_linux) - GLIBC25___STPCPY_CHK(VG_Z_LIBC_SONAME, __stpcpy_chk) +GLIBC25___STPCPY_CHK(VG_Z_LIBC_SONAME, __stpcpy_chk) #elif defined(VGO_darwin) @@ -1647,100 +1767,98 @@ static inline void my_exit ( int x ) #endif - /*---------------------- mempcpy ----------------------*/ /* mempcpy */ -#define GLIBC25_MEMPCPY(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20290,soname,fnname) \ - ( void *dst, const void *src, SizeT len ); \ - void* VG_REPLACE_FUNCTION_EZU(20290,soname,fnname) \ - ( void *dst, const void *src, SizeT len ) \ - { \ - RECORD_COPY(len); \ - SizeT len_saved = len; \ - \ - if (len == 0) \ - return dst; \ - \ - if (is_overlap(dst, src, len, len)) \ - RECORD_OVERLAP_ERROR("mempcpy", dst, src, len); \ - \ - if ( dst > src ) { \ - register HChar *d = (char *)dst + len - 1; \ - register const HChar *s = (const char *)src + len - 1; \ - while ( len-- ) { \ - *d-- = *s--; \ - } \ - } else if ( dst < src ) { \ - register HChar *d = dst; \ - register const HChar *s = src; \ - while ( len-- ) { \ - *d++ = *s++; \ - } \ - } \ - return (void*)( ((char*)dst) + len_saved ); \ +#define GLIBC25_MEMPCPY(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20290, soname, fnname)( \ + void* dst, const void* src, SizeT len); \ + void* VG_REPLACE_FUNCTION_EZU(20290, soname, fnname)( \ + void* dst, const void* src, SizeT len) \ + { \ + RECORD_COPY(len); \ + SizeT len_saved = len; \ + \ + if (len == 0) \ + return dst; \ + \ + if (is_overlap(dst, src, len, len)) \ + RECORD_OVERLAP_ERROR("mempcpy", dst, src, len); \ + \ + if (dst > src) { \ + register HChar* d = (char*)dst + len - 1; \ + register const HChar* s = (const char*)src + len - 1; \ + while (len--) { \ + *d-- = *s--; \ + } \ + } else if (dst < src) { \ + register HChar* d = dst; \ + register const HChar* s = src; \ + while (len--) { \ + *d++ = *s++; \ + } \ + } \ + return (void*)(((char*)dst) + len_saved); \ } #if defined(VGO_linux) - GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) - GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, __GI_mempcpy) - GLIBC25_MEMPCPY(VG_Z_LD_SO_1, mempcpy) /* ld.so.1 */ - GLIBC25_MEMPCPY(VG_Z_LD_LINUX_SO_3, mempcpy) /* ld-linux.so.3 */ - GLIBC25_MEMPCPY(VG_Z_LD_LINUX_X86_64_SO_2, mempcpy) /* ld-linux-x86-64.so.2 */ +GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) +GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, __GI_mempcpy) +GLIBC25_MEMPCPY(VG_Z_LD_SO_1, mempcpy) /* ld.so.1 */ +GLIBC25_MEMPCPY(VG_Z_LD_LINUX_SO_3, mempcpy) /* ld-linux.so.3 */ +GLIBC25_MEMPCPY(VG_Z_LD_LINUX_X86_64_SO_2, mempcpy) /* ld-linux-x86-64.so.2 */ #elif defined(VGO_freebsd) - GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) +GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) #elif defined(VGO_darwin) - //GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) +// GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) #elif defined(VGO_solaris) #endif - /*-------------------- memcpy_chk --------------------*/ -#define GLIBC26___MEMCPY_CHK(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \ - (void* dst, const void* src, SizeT len, SizeT dstlen ); \ - void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \ - (void* dst, const void* src, SizeT len, SizeT dstlen ) \ - { \ - register HChar *d; \ - register const HChar *s; \ - if (dstlen < len) \ - goto badness; \ - RECORD_COPY(len); \ - if (len == 0) \ - return dst; \ - if (is_overlap(dst, src, len, len)) \ - RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ - if ( dst > src ) { \ - d = (HChar *)dst + len - 1; \ - s = (const HChar *)src + len - 1; \ - while ( len-- ) { \ - *d-- = *s--; \ - } \ - } else if ( dst < src ) { \ - d = (HChar *)dst; \ - s = (const HChar *)src; \ - while ( len-- ) { \ - *d++ = *s++; \ - } \ - } \ - return dst; \ - badness: \ - VALGRIND_PRINTF_BACKTRACE( \ - "*** memcpy_chk: buffer overflow detected ***: " \ - "program terminated\n"); \ - my_exit(1); \ - /*NOTREACHED*/ \ - return NULL; \ +#define GLIBC26___MEMCPY_CHK(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20300, soname, fnname)( \ + void* dst, const void* src, SizeT len, SizeT dstlen); \ + void* VG_REPLACE_FUNCTION_EZU(20300, soname, fnname)( \ + void* dst, const void* src, SizeT len, SizeT dstlen) \ + { \ + register HChar* d; \ + register const HChar* s; \ + if (dstlen < len) \ + goto badness; \ + RECORD_COPY(len); \ + if (len == 0) \ + return dst; \ + if (is_overlap(dst, src, len, len)) \ + RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ + if (dst > src) { \ + d = (HChar*)dst + len - 1; \ + s = (const HChar*)src + len - 1; \ + while (len--) { \ + *d-- = *s--; \ + } \ + } else if (dst < src) { \ + d = (HChar*)dst; \ + s = (const HChar*)src; \ + while (len--) { \ + *d++ = *s++; \ + } \ + } \ + return dst; \ + badness: \ + VALGRIND_PRINTF_BACKTRACE( \ + "*** memcpy_chk: buffer overflow detected ***: " \ + "program terminated\n"); \ + my_exit(1); \ + /*NOTREACHED*/ \ + return NULL; \ } #if defined(VGO_linux) - GLIBC26___MEMCPY_CHK(VG_Z_LIBC_SONAME, __memcpy_chk) +GLIBC26___MEMCPY_CHK(VG_Z_LIBC_SONAME, __memcpy_chk) #elif defined(VGO_darwin) @@ -1748,304 +1866,314 @@ static inline void my_exit ( int x ) #endif - /*---------------------- strstr ----------------------*/ -#define STRSTR(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20310,soname,fnname) \ - (const char* haystack, const char* needle); \ - char* VG_REPLACE_FUNCTION_EZU(20310,soname,fnname) \ - (const char* haystack, const char* needle) \ - { \ - const HChar* h = haystack; \ - const HChar* n = needle; \ - \ - /* find the length of n, not including terminating zero */ \ - UWord nlen = 0; \ - while (n[nlen]) nlen++; \ - \ - /* if n is the empty string, match immediately. */ \ - if (nlen == 0) return CONST_CAST(HChar *,h); \ - \ - /* assert(nlen >= 1); */ \ - HChar n0 = n[0]; \ - \ - while (1) { \ - const HChar hh = *h; \ - if (hh == 0) return NULL; \ - if (hh != n0) { h++; continue; } \ - \ - UWord i; \ - for (i = 0; i < nlen; i++) { \ - if (n[i] != h[i]) \ - break; \ - } \ - /* assert(i >= 0 && i <= nlen); */ \ - if (i == nlen) \ - return CONST_CAST(HChar *,h); \ - \ - h++; \ - } \ +#define STRSTR(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20310, soname, fnname)(const char* haystack, \ + const char* needle); \ + char* VG_REPLACE_FUNCTION_EZU(20310, soname, fnname)(const char* haystack, \ + const char* needle) \ + { \ + const HChar* h = haystack; \ + const HChar* n = needle; \ + \ + /* find the length of n, not including terminating zero */ \ + UWord nlen = 0; \ + while (n[nlen]) \ + nlen++; \ + \ + /* if n is the empty string, match immediately. */ \ + if (nlen == 0) \ + return CONST_CAST(HChar*, h); \ + \ + /* assert(nlen >= 1); */ \ + HChar n0 = n[0]; \ + \ + while (1) { \ + const HChar hh = *h; \ + if (hh == 0) \ + return NULL; \ + if (hh != n0) { \ + h++; \ + continue; \ + } \ + \ + UWord i; \ + for (i = 0; i < nlen; i++) { \ + if (n[i] != h[i]) \ + break; \ + } \ + /* assert(i >= 0 && i <= nlen); */ \ + if (i == nlen) \ + return CONST_CAST(HChar*, h); \ + \ + h++; \ + } \ } #if defined(VGO_linux) - STRSTR(VG_Z_LIBC_SONAME, strstr) - STRSTR(VG_Z_LIBC_SONAME, __strstr_sse2) - STRSTR(VG_Z_LIBC_SONAME, __strstr_sse42) +STRSTR(VG_Z_LIBC_SONAME, strstr) +STRSTR(VG_Z_LIBC_SONAME, __strstr_sse2) +STRSTR(VG_Z_LIBC_SONAME, __strstr_sse42) #elif defined(VGO_freebsd) - STRSTR(VG_Z_LIBC_SONAME, strstr) +STRSTR(VG_Z_LIBC_SONAME, strstr) #elif defined(VGO_darwin) #elif defined(VGO_solaris) - STRSTR(VG_Z_LIBC_SONAME, strstr) +STRSTR(VG_Z_LIBC_SONAME, strstr) #endif /*---------------------- memmem ----------------------*/ -#define MEMMEM(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \ - (const void* haystack, SizeT hlen, const void* needle, SizeT nlen); \ - void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \ - (const void* haystack, SizeT hlen, const void* needle, SizeT nlen) \ - { \ - const HChar* h = haystack; \ - const HChar* n = needle; \ - \ - /* If the needle is the empty string, match immediately. */ \ - if (nlen == 0) return CONST_CAST(void *,h); \ - \ - HChar n0 = n[0]; \ - \ - for (; hlen >= nlen; hlen--, h++) { \ - if (h[0] != n0) continue; \ - \ - UWord i; \ - for (i = 1; i < nlen; i++) { \ - if (n[i] != h[i]) \ - break; \ - } \ - if (i == nlen) \ - return CONST_CAST(HChar *,h); \ - \ - } \ - return NULL; \ +#define MEMMEM(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20460, soname, fnname)( \ + const void* haystack, SizeT hlen, const void* needle, SizeT nlen); \ + void* VG_REPLACE_FUNCTION_EZU(20460, soname, fnname)( \ + const void* haystack, SizeT hlen, const void* needle, SizeT nlen) \ + { \ + const HChar* h = haystack; \ + const HChar* n = needle; \ + \ + /* If the needle is the empty string, match immediately. */ \ + if (nlen == 0) \ + return CONST_CAST(void*, h); \ + \ + HChar n0 = n[0]; \ + \ + for (; hlen >= nlen; hlen--, h++) { \ + if (h[0] != n0) \ + continue; \ + \ + UWord i; \ + for (i = 1; i < nlen; i++) { \ + if (n[i] != h[i]) \ + break; \ + } \ + if (i == nlen) \ + return CONST_CAST(HChar*, h); \ + } \ + return NULL; \ } #if defined(VGP_s390x_linux) - MEMMEM(VG_Z_LIBC_SONAME, memmem) +MEMMEM(VG_Z_LIBC_SONAME, memmem) #endif - /*---------------------- strpbrk ----------------------*/ -#define STRPBRK(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20320,soname,fnname) \ - (const char* sV, const char* acceptV); \ - char* VG_REPLACE_FUNCTION_EZU(20320,soname,fnname) \ - (const char* sV, const char* acceptV) \ - { \ - const HChar* s = sV; \ - const HChar* accept = acceptV; \ - \ - /* find the length of 'accept', not including terminating zero */ \ - UWord nacc = 0; \ - while (accept[nacc]) nacc++; \ - \ - /* if n is the empty string, fail immediately. */ \ - if (nacc == 0) return NULL; \ - \ - /* assert(nacc >= 1); */ \ - while (1) { \ - UWord i; \ - HChar sc = *s; \ - if (sc == 0) \ - break; \ - for (i = 0; i < nacc; i++) { \ - if (sc == accept[i]) \ - return CONST_CAST(HChar *,s); \ - } \ - s++; \ - } \ - \ - return NULL; \ +#define STRPBRK(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20320, soname, fnname)(const char* sV, \ + const char* acceptV); \ + char* VG_REPLACE_FUNCTION_EZU(20320, soname, fnname)(const char* sV, \ + const char* acceptV) \ + { \ + const HChar* s = sV; \ + const HChar* accept = acceptV; \ + \ + /* find the length of 'accept', not including terminating zero */ \ + UWord nacc = 0; \ + while (accept[nacc]) \ + nacc++; \ + \ + /* if n is the empty string, fail immediately. */ \ + if (nacc == 0) \ + return NULL; \ + \ + /* assert(nacc >= 1); */ \ + while (1) { \ + UWord i; \ + HChar sc = *s; \ + if (sc == 0) \ + break; \ + for (i = 0; i < nacc; i++) { \ + if (sc == accept[i]) \ + return CONST_CAST(HChar*, s); \ + } \ + s++; \ + } \ + \ + return NULL; \ } #if defined(VGO_linux) - STRPBRK(VG_Z_LIBC_SONAME, strpbrk) +STRPBRK(VG_Z_LIBC_SONAME, strpbrk) #elif defined(VGO_freebsd) - STRPBRK(VG_Z_LIBC_SONAME, strpbrk) +STRPBRK(VG_Z_LIBC_SONAME, strpbrk) #elif defined(VGO_darwin) #elif defined(VGO_solaris) - STRPBRK(VG_Z_LIBC_SONAME, strpbrk) +STRPBRK(VG_Z_LIBC_SONAME, strpbrk) #endif - /*---------------------- strcspn ----------------------*/ -#define STRCSPN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20330,soname,fnname) \ - (const char* sV, const char* rejectV); \ - SizeT VG_REPLACE_FUNCTION_EZU(20330,soname,fnname) \ - (const char* sV, const char* rejectV) \ - { \ - const HChar* s = sV; \ - const HChar* reject = rejectV; \ - \ - /* find the length of 'reject', not including terminating zero */ \ - UWord nrej = 0; \ - while (reject[nrej]) nrej++; \ - \ - UWord len = 0; \ - while (1) { \ - UWord i; \ - HChar sc = *s; \ - if (sc == 0) \ - break; \ - for (i = 0; i < nrej; i++) { \ - if (sc == reject[i]) \ - break; \ - } \ - /* assert(i >= 0 && i <= nrej); */ \ - if (i < nrej) \ - break; \ - s++; \ - len++; \ - } \ - \ - return len; \ +#define STRCSPN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20330, soname, fnname)(const char* sV, \ + const char* rejectV); \ + SizeT VG_REPLACE_FUNCTION_EZU(20330, soname, fnname)(const char* sV, \ + const char* rejectV) \ + { \ + const HChar* s = sV; \ + const HChar* reject = rejectV; \ + \ + /* find the length of 'reject', not including terminating zero */ \ + UWord nrej = 0; \ + while (reject[nrej]) \ + nrej++; \ + \ + UWord len = 0; \ + while (1) { \ + UWord i; \ + HChar sc = *s; \ + if (sc == 0) \ + break; \ + for (i = 0; i < nrej; i++) { \ + if (sc == reject[i]) \ + break; \ + } \ + /* assert(i >= 0 && i <= nrej); */ \ + if (i < nrej) \ + break; \ + s++; \ + len++; \ + } \ + \ + return len; \ } #if defined(VGO_linux) - STRCSPN(VG_Z_LIBC_SONAME, strcspn) - STRCSPN(VG_Z_LIBC_SONAME, __GI_strcspn) +STRCSPN(VG_Z_LIBC_SONAME, strcspn) +STRCSPN(VG_Z_LIBC_SONAME, __GI_strcspn) #elif defined(VGO_freebsd) - STRCSPN(VG_Z_LIBC_SONAME, strcspn) +STRCSPN(VG_Z_LIBC_SONAME, strcspn) #elif defined(VGO_darwin) #elif defined(VGO_solaris) - STRCSPN(VG_Z_LIBC_SONAME, strcspn) +STRCSPN(VG_Z_LIBC_SONAME, strcspn) #endif - /*---------------------- strspn ----------------------*/ -#define STRSPN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20340,soname,fnname) \ - (const char* sV, const char* acceptV); \ - SizeT VG_REPLACE_FUNCTION_EZU(20340,soname,fnname) \ - (const char* sV, const char* acceptV) \ - { \ - const UChar* s = (const UChar *)sV; \ - const UChar* accept = (const UChar *)acceptV; \ - \ - /* find the length of 'accept', not including terminating zero */ \ - UWord nacc = 0; \ - while (accept[nacc]) nacc++; \ - if (nacc == 0) return 0; \ - \ - UWord len = 0; \ - while (1) { \ - UWord i; \ - UChar sc = *s; \ - if (sc == 0) \ - break; \ - for (i = 0; i < nacc; i++) { \ - if (sc == accept[i]) \ - break; \ - } \ - /* assert(i >= 0 && i <= nacc); */ \ - if (i == nacc) \ - break; \ - s++; \ - len++; \ - } \ - \ - return len; \ +#define STRSPN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20340, soname, fnname)(const char* sV, \ + const char* acceptV); \ + SizeT VG_REPLACE_FUNCTION_EZU(20340, soname, fnname)(const char* sV, \ + const char* acceptV) \ + { \ + const UChar* s = (const UChar*)sV; \ + const UChar* accept = (const UChar*)acceptV; \ + \ + /* find the length of 'accept', not including terminating zero */ \ + UWord nacc = 0; \ + while (accept[nacc]) \ + nacc++; \ + if (nacc == 0) \ + return 0; \ + \ + UWord len = 0; \ + while (1) { \ + UWord i; \ + UChar sc = *s; \ + if (sc == 0) \ + break; \ + for (i = 0; i < nacc; i++) { \ + if (sc == accept[i]) \ + break; \ + } \ + /* assert(i >= 0 && i <= nacc); */ \ + if (i == nacc) \ + break; \ + s++; \ + len++; \ + } \ + \ + return len; \ } #if defined(VGO_linux) - STRSPN(VG_Z_LIBC_SONAME, strspn) +STRSPN(VG_Z_LIBC_SONAME, strspn) #elif defined(VGO_freebsd) - STRSPN(VG_Z_LIBC_SONAME, strspn) +STRSPN(VG_Z_LIBC_SONAME, strspn) #elif defined(VGO_darwin) #elif defined(VGO_solaris) - STRSPN(VG_Z_LIBC_SONAME, strspn) +STRSPN(VG_Z_LIBC_SONAME, strspn) #endif - /*---------------------- strcasestr ----------------------*/ -#define STRCASESTR(soname, fnname) \ - char* VG_REPLACE_FUNCTION_EZU(20350,soname,fnname) \ - (const char* haystack, const char* needle); \ - char* VG_REPLACE_FUNCTION_EZU(20350,soname,fnname) \ - (const char* haystack, const char* needle) \ - { \ - extern int tolower(int); \ - const HChar* h = haystack; \ - const HChar* n = needle; \ - \ - /* find the length of n, not including terminating zero */ \ - UWord nlen = 0; \ - while (n[nlen]) nlen++; \ - \ - /* if n is the empty string, match immediately. */ \ - if (nlen == 0) return CONST_CAST(HChar *,h); \ - \ - /* assert(nlen >= 1); */ \ - UChar n0 = tolower(n[0]); \ - \ - while (1) { \ - UChar hh = tolower(*h); \ - if (hh == 0) return NULL; \ - if (hh != n0) { h++; continue; } \ - \ - UWord i; \ - for (i = 0; i < nlen; i++) { \ - if (tolower(n[i]) != tolower(h[i])) \ - break; \ - } \ - /* assert(i >= 0 && i <= nlen); */ \ - if (i == nlen) \ - return CONST_CAST(HChar *,h); \ - \ - h++; \ - } \ +#define STRCASESTR(soname, fnname) \ + char* VG_REPLACE_FUNCTION_EZU(20350, soname, fnname)(const char* haystack, \ + const char* needle); \ + char* VG_REPLACE_FUNCTION_EZU(20350, soname, fnname)(const char* haystack, \ + const char* needle) \ + { \ + extern int tolower(int); \ + const HChar* h = haystack; \ + const HChar* n = needle; \ + \ + /* find the length of n, not including terminating zero */ \ + UWord nlen = 0; \ + while (n[nlen]) \ + nlen++; \ + \ + /* if n is the empty string, match immediately. */ \ + if (nlen == 0) \ + return CONST_CAST(HChar*, h); \ + \ + /* assert(nlen >= 1); */ \ + UChar n0 = tolower(n[0]); \ + \ + while (1) { \ + UChar hh = tolower(*h); \ + if (hh == 0) \ + return NULL; \ + if (hh != n0) { \ + h++; \ + continue; \ + } \ + \ + UWord i; \ + for (i = 0; i < nlen; i++) { \ + if (tolower(n[i]) != tolower(h[i])) \ + break; \ + } \ + /* assert(i >= 0 && i <= nlen); */ \ + if (i == nlen) \ + return CONST_CAST(HChar*, h); \ + \ + h++; \ + } \ } #if defined(VGO_linux) -# if !defined(VGPV_arm_linux_android) \ - && !defined(VGPV_x86_linux_android) \ - && !defined(VGPV_mips32_linux_android) \ - && !defined(VGPV_arm64_linux_android) - STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) -# endif +#if !defined(VGPV_arm_linux_android) && !defined(VGPV_x86_linux_android) && \ + !defined(VGPV_mips32_linux_android) && !defined(VGPV_arm64_linux_android) +STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) +#endif #elif defined(VGO_freebsd) - STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) +STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) #elif defined(VGO_darwin) #elif defined(VGO_solaris) - STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) +STRCASESTR(VG_Z_LIBC_SONAME, strcasestr) #endif - /*---------------------- wcslen ----------------------*/ // This is a wchar_t equivalent to strlen. Unfortunately @@ -2053,42 +2181,40 @@ static inline void my_exit ( int x ) // a 32 bit int on Linux. I don't know if that is also // valid on MacOSX. -#define WCSLEN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \ - ( const Int* str ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \ - ( const Int* str ) \ - { \ - SizeT i = 0; \ - while (str[i] != 0) i++; \ - return i; \ +#define WCSLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20370, soname, fnname)(const Int* str); \ + SizeT VG_REPLACE_FUNCTION_EZU(20370, soname, fnname)(const Int* str) \ + { \ + SizeT i = 0; \ + while (str[i] != 0) \ + i++; \ + return i; \ } #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) - WCSLEN(VG_Z_LIBC_SONAME, wcslen) +WCSLEN(VG_Z_LIBC_SONAME, wcslen) #endif /*---------------------- wcsnlen ----------------------*/ -#define WCSNLEN(soname, fnname) \ - SizeT VG_REPLACE_FUNCTION_EZU(20440,soname,fnname) \ - ( const Int *s, SizeT n ); \ - SizeT VG_REPLACE_FUNCTION_EZU(20440,soname,fnname) \ - ( const Int *s, SizeT n ) \ - { \ - SizeT i = 0; \ - const Int* p = s; \ - while (i < n && *p != 0) { \ - i++; \ - p++; \ - } \ - return i; \ +#define WCSNLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20440, soname, fnname)(const Int* s, \ + SizeT n); \ + SizeT VG_REPLACE_FUNCTION_EZU(20440, soname, fnname)(const Int* s, SizeT n) \ + { \ + SizeT i = 0; \ + const Int* p = s; \ + while (i < n && *p != 0) { \ + i++; \ + p++; \ + } \ + return i; \ } #if defined(VGO_linux) || defined(VGO_freebsd) - WCSNLEN(VG_Z_LIBC_SONAME, wcsnlen) - WCSNLEN(VG_Z_LIBC_SONAME, __GI_wcsnlen) +WCSNLEN(VG_Z_LIBC_SONAME, wcsnlen) +WCSNLEN(VG_Z_LIBC_SONAME, __GI_wcsnlen) #endif /*---------------------- wcscmp ----------------------*/ @@ -2098,28 +2224,33 @@ static inline void my_exit ( int x ) // wchar_t is always 32 bits wide and wcscmp uses signed // comparison, not unsigned as in strcmp function. -#define WCSCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20380,soname,fnname) \ - ( const Int* s1, const Int* s2 ); \ - int VG_REPLACE_FUNCTION_EZU(20380,soname,fnname) \ - ( const Int* s1, const Int* s2 ) \ - { \ - register Int c1; \ - register Int c2; \ - while (True) { \ - c1 = *s1; \ - c2 = *s2; \ - if (c1 != c2) break; \ - if (c1 == 0) break; \ - s1++; s2++; \ - } \ - if (c1 < c2) return -1; \ - if (c1 > c2) return 1; \ - return 0; \ +#define WCSCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20380, soname, fnname)(const Int* s1, \ + const Int* s2); \ + int VG_REPLACE_FUNCTION_EZU(20380, soname, fnname)(const Int* s1, \ + const Int* s2) \ + { \ + register Int c1; \ + register Int c2; \ + while (True) { \ + c1 = *s1; \ + c2 = *s2; \ + if (c1 != c2) \ + break; \ + if (c1 == 0) \ + break; \ + s1++; \ + s2++; \ + } \ + if (c1 < c2) \ + return -1; \ + if (c1 > c2) \ + return 1; \ + return 0; \ } #if defined(VGO_linux) || defined(VGO_freebsd) - WCSCMP(VG_Z_LIBC_SONAME, wcscmp) +WCSCMP(VG_Z_LIBC_SONAME, wcscmp) #endif /*---------------------- wcsncmp ----------------------*/ @@ -2129,27 +2260,35 @@ static inline void my_exit ( int x ) // wchar_t is always 32 bits wide and wcsncmp uses signed // comparison, not unsigned as in strncmp function. -#define WCSNCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20450,soname,fnname) \ - ( const Int* s1, const Int* s2, SizeT nmax ); \ - int VG_REPLACE_FUNCTION_EZU(20450,soname,fnname) \ - ( const Int* s1, const Int* s2, SizeT nmax ) \ - { \ - SizeT n = 0; \ - while (True) { \ - if (n >= nmax) return 0; \ - if (*s1 == 0 && *s2 == 0) return 0; \ - if (*s1 == 0) return -1; \ - if (*s2 == 0) return 1; \ - \ - if (*s1 < *s2) return -1; \ - if (*s1 > *s2) return 1; \ - \ - s1++; s2++; n++; \ - } \ +#define WCSNCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20450, soname, fnname)( \ + const Int* s1, const Int* s2, SizeT nmax); \ + int VG_REPLACE_FUNCTION_EZU(20450, soname, fnname)( \ + const Int* s1, const Int* s2, SizeT nmax) \ + { \ + SizeT n = 0; \ + while (True) { \ + if (n >= nmax) \ + return 0; \ + if (*s1 == 0 && *s2 == 0) \ + return 0; \ + if (*s1 == 0) \ + return -1; \ + if (*s2 == 0) \ + return 1; \ + \ + if (*s1 < *s2) \ + return -1; \ + if (*s1 > *s2) \ + return 1; \ + \ + s1++; \ + s2++; \ + n++; \ + } \ } #if defined(VGO_linux) || defined(VGO_freebsd) - WCSNCMP(VG_Z_LIBC_SONAME, wcsncmp) +WCSNCMP(VG_Z_LIBC_SONAME, wcsncmp) #endif /*---------------------- wcscpy ----------------------*/ @@ -2158,58 +2297,57 @@ static inline void my_exit ( int x ) // have wchar_t available here, but in the GNU C Library // wchar_t is always 32 bits wide. -#define WCSCPY(soname, fnname) \ - Int* VG_REPLACE_FUNCTION_EZU(20390,soname,fnname) \ - ( Int* dst, const Int* src ); \ - Int* VG_REPLACE_FUNCTION_EZU(20390,soname,fnname) \ - ( Int* dst, const Int* src ) \ - { \ - const Int* src_orig = src; \ - Int* dst_orig = dst; \ - \ - while (*src) *dst++ = *src++; \ - *dst = 0; \ - \ - /* This checks for overlap after copying, unavoidable without */ \ - /* pre-counting length... should be ok */ \ - /* +4 because sizeof(wchar_t) == 4 */ \ - SizeT srclen = (Addr)src-(Addr)src_orig+4; \ - RECORD_COPY(srclen); \ - if (is_overlap(dst_orig, \ - src_orig, \ - /* +4 because sizeof(wchar_t) == 4 */ \ - (Addr)dst-(Addr)dst_orig+4, \ - srclen)) \ - RECORD_OVERLAP_ERROR("wcscpy", dst_orig, src_orig, 0); \ - \ - return dst_orig; \ +#define WCSCPY(soname, fnname) \ + Int* VG_REPLACE_FUNCTION_EZU(20390, soname, fnname)(Int * dst, \ + const Int* src); \ + Int* VG_REPLACE_FUNCTION_EZU(20390, soname, fnname)(Int * dst, \ + const Int* src) \ + { \ + const Int* src_orig = src; \ + Int* dst_orig = dst; \ + \ + while (*src) \ + *dst++ = *src++; \ + *dst = 0; \ + \ + /* This checks for overlap after copying, unavoidable without */ \ + /* pre-counting length... should be ok */ \ + /* +4 because sizeof(wchar_t) == 4 */ \ + SizeT srclen = (Addr)src - (Addr)src_orig + 4; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, src_orig, /* +4 because sizeof(wchar_t) == 4 */ \ + (Addr)dst - (Addr)dst_orig + 4, srclen)) \ + RECORD_OVERLAP_ERROR("wcscpy", dst_orig, src_orig, 0); \ + \ + return dst_orig; \ } #if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) - WCSCPY(VG_Z_LIBC_SONAME, wcscpy) +WCSCPY(VG_Z_LIBC_SONAME, wcscpy) #endif - /*---------------------- wcschr ----------------------*/ // This is a wchar_t equivalent to strchr. We don't // have wchar_t available here, but in the GNU C Library // wchar_t is always 32 bits wide. -#define WCSCHR(soname, fnname) \ - Int* VG_REPLACE_FUNCTION_EZU(20400,soname,fnname) ( const Int* s, Int c ); \ - Int* VG_REPLACE_FUNCTION_EZU(20400,soname,fnname) ( const Int* s, Int c ) \ - { \ - const Int* p = s; \ - while (True) { \ - if (*p == c) return CONST_CAST(Int *,p); \ - if (*p == 0) return NULL; \ - p++; \ - } \ +#define WCSCHR(soname, fnname) \ + Int* VG_REPLACE_FUNCTION_EZU(20400, soname, fnname)(const Int* s, Int c); \ + Int* VG_REPLACE_FUNCTION_EZU(20400, soname, fnname)(const Int* s, Int c) \ + { \ + const Int* p = s; \ + while (True) { \ + if (*p == c) \ + return CONST_CAST(Int*, p); \ + if (*p == 0) \ + return NULL; \ + p++; \ + } \ } -#if defined(VGO_linux) || defined(VGO_freebsd) - WCSCHR(VG_Z_LIBC_SONAME, wcschr) +#if defined(VGO_linux) || defined(VGO_freebsd) +WCSCHR(VG_Z_LIBC_SONAME, wcschr) #endif /*---------------------- wcsrchr ----------------------*/ @@ -2217,72 +2355,73 @@ static inline void my_exit ( int x ) // have wchar_t available here, but in the GNU C Library // wchar_t is always 32 bits wide. -#define WCSRCHR(soname, fnname) \ - Int* VG_REPLACE_FUNCTION_EZU(20410,soname,fnname)( const Int* s, Int c ); \ - Int* VG_REPLACE_FUNCTION_EZU(20410,soname,fnname)( const Int* s, Int c ) \ - { \ - const Int* p = s; \ - const Int* last = NULL; \ - while (True) { \ - if (*p == c) last = p; \ - if (*p == 0) return CONST_CAST(Int *,last); \ - p++; \ - } \ +#define WCSRCHR(soname, fnname) \ + Int* VG_REPLACE_FUNCTION_EZU(20410, soname, fnname)(const Int* s, Int c); \ + Int* VG_REPLACE_FUNCTION_EZU(20410, soname, fnname)(const Int* s, Int c) \ + { \ + const Int* p = s; \ + const Int* last = NULL; \ + while (True) { \ + if (*p == c) \ + last = p; \ + if (*p == 0) \ + return CONST_CAST(Int*, last); \ + p++; \ + } \ } #if defined(VGO_linux) || defined(VGO_freebsd) - WCSRCHR(VG_Z_LIBC_SONAME, wcsrchr) +WCSRCHR(VG_Z_LIBC_SONAME, wcsrchr) #endif - /*---------------------- wmemchr ----------------------*/ +/*---------------------- wmemchr ----------------------*/ // This is a wchar_t equivalent to memchr. We don't // have wchar_t available here, but in the GNU C Library // wchar_t is always 32 bits wide. -#define WMEMCHR(soname, fnname) \ - Int* VG_REPLACE_FUNCTION_EZU(20430,soname,fnname) \ - (const Int *s, Int c, SizeT n); \ - Int* VG_REPLACE_FUNCTION_EZU(20430,soname,fnname) \ - (const Int *s, Int c, SizeT n) \ - { \ - SizeT i; \ - const Int* p = s; \ - for (i = 0; i < n; i++) { \ - if (*p == c) return CONST_CAST(Int *,p); \ - p++; \ - } \ - return NULL; \ +#define WMEMCHR(soname, fnname) \ + Int* VG_REPLACE_FUNCTION_EZU(20430, soname, fnname)(const Int* s, Int c, \ + SizeT n); \ + Int* VG_REPLACE_FUNCTION_EZU(20430, soname, fnname)(const Int* s, Int c, \ + SizeT n) \ + { \ + SizeT i; \ + const Int* p = s; \ + for (i = 0; i < n; i++) { \ + if (*p == c) \ + return CONST_CAST(Int*, p); \ + p++; \ + } \ + return NULL; \ } #if defined(VGO_linux) - WMEMCHR(VG_Z_LIBC_SONAME, wmemchr) - WMEMCHR(VG_Z_LIBC_SONAME, __GI_wmemchr) +WMEMCHR(VG_Z_LIBC_SONAME, wmemchr) +WMEMCHR(VG_Z_LIBC_SONAME, __GI_wmemchr) #endif #if defined(VGO_freebsd) - WMEMCHR(VG_Z_LIBC_SONAME, wmemchr) +WMEMCHR(VG_Z_LIBC_SONAME, wmemchr) #endif - -#define WMEMCMP(soname, fnname) \ - int VG_REPLACE_FUNCTION_EZU(20470,soname,fnname) \ - ( const Int *b1, const Int *b2, SizeT n ); \ - int VG_REPLACE_FUNCTION_EZU(20470,soname,fnname) \ - ( const Int *b1, const Int *b2, SizeT n ) \ - { \ - for (SizeT i = 0U; i < n; ++i) { \ - if (b1[i] != b2[i]) \ - return b1[i] > b2[i] ? 1 : -1; \ - } \ - return 0; \ +#define WMEMCMP(soname, fnname) \ + int VG_REPLACE_FUNCTION_EZU(20470, soname, fnname)(const Int* b1, \ + const Int* b2, SizeT n); \ + int VG_REPLACE_FUNCTION_EZU(20470, soname, fnname)(const Int* b1, \ + const Int* b2, SizeT n) \ + { \ + for (SizeT i = 0U; i < n; ++i) { \ + if (b1[i] != b2[i]) \ + return b1[i] > b2[i] ? 1 : -1; \ + } \ + return 0; \ } #if defined(VGO_linux) - WMEMCMP(VG_Z_LIBC_SONAME, wmemcmp) +WMEMCMP(VG_Z_LIBC_SONAME, wmemcmp) #endif - /*------------------------------------------------------------*/ /*--- Improve definedness checking of process environment ---*/ /*------------------------------------------------------------*/ @@ -2295,65 +2434,65 @@ static inline void my_exit ( int x ) /*---------------------- putenv ----------------------*/ -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string); -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string) +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv)(char* string); +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv)(char* string) { - OrigFn fn; - Word result; - const HChar* p = string; - VALGRIND_GET_ORIG_FN(fn); - /* Now by walking over the string we magically produce - traces when hitting undefined memory. */ - if (p) - while (*p++) - __asm__ __volatile__("" ::: "memory"); - CALL_FN_W_W(result, fn, string); - return result; + OrigFn fn; + Word result; + const HChar* p = string; + VALGRIND_GET_ORIG_FN(fn); + /* Now by walking over the string we magically produce + traces when hitting undefined memory. */ + if (p) + while (*p++) + __asm__ __volatile__("" ::: "memory"); + CALL_FN_W_W(result, fn, string); + return result; } - /*---------------------- unsetenv ----------------------*/ -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name); -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name) +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv)(const char* name); +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv)(const char* name) { - OrigFn fn; - Word result; - const HChar* p = name; - VALGRIND_GET_ORIG_FN(fn); - /* Now by walking over the string we magically produce - traces when hitting undefined memory. */ - if (p) - while (*p++) - __asm__ __volatile__("" ::: "memory"); - CALL_FN_W_W(result, fn, name); - return result; + OrigFn fn; + Word result; + const HChar* p = name; + VALGRIND_GET_ORIG_FN(fn); + /* Now by walking over the string we magically produce + traces when hitting undefined memory. */ + if (p) + while (*p++) + __asm__ __volatile__("" ::: "memory"); + CALL_FN_W_W(result, fn, name); + return result; } - /*---------------------- setenv ----------------------*/ /* setenv */ -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv) - (const char* name, const char* value, int overwrite); -int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv) - (const char* name, const char* value, int overwrite) +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)(const char* name, + const char* value, + int overwrite); +int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)(const char* name, + const char* value, + int overwrite) { - OrigFn fn; - Word result; - const HChar* p; - VALGRIND_GET_ORIG_FN(fn); - /* Now by walking over the string we magically produce - traces when hitting undefined memory. */ - if (name) - for (p = name; *p; p++) - __asm__ __volatile__("" ::: "memory"); - if (value) - for (p = value; *p; p++) - __asm__ __volatile__("" ::: "memory"); - (void) VALGRIND_CHECK_VALUE_IS_DEFINED (overwrite); - CALL_FN_W_WWW(result, fn, name, value, overwrite); - return result; + OrigFn fn; + Word result; + const HChar* p; + VALGRIND_GET_ORIG_FN(fn); + /* Now by walking over the string we magically produce + traces when hitting undefined memory. */ + if (name) + for (p = name; *p; p++) + __asm__ __volatile__("" ::: "memory"); + if (value) + for (p = value; *p; p++) + __asm__ __volatile__("" ::: "memory"); + (void)VALGRIND_CHECK_VALUE_IS_DEFINED(overwrite); + CALL_FN_W_WWW(result, fn, name, value, overwrite); + return result; } #endif /* defined(VGO_linux) */