From owner-p4-projects@FreeBSD.ORG Thu Oct 23 07:27:41 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 16028106567A; Thu, 23 Oct 2008 07:27:41 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B539C1065679 for ; Thu, 23 Oct 2008 07:27:40 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A2A708FC0A for ; Thu, 23 Oct 2008 07:27:40 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m9N7RegL064265 for ; Thu, 23 Oct 2008 07:27:40 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9N7ReBY064263 for perforce@freebsd.org; Thu, 23 Oct 2008 07:27:40 GMT (envelope-from peter-gmail@wemm.org) Date: Thu, 23 Oct 2008 07:27:40 GMT Message-Id: <200810230727.m9N7ReBY064263@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter-gmail@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 151787 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2008 07:27:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=151787 Change 151787 by peter@peter_cheese on 2008/10/23 07:27:36 Checkpoint. libcoregrind builds. Affected files ... .. //depot/projects/valgrind/coregrind/m_coredump/coredump-x86-freebsd.c#2 edit .. //depot/projects/valgrind/coregrind/m_debuginfo/readelf.c#3 edit .. //depot/projects/valgrind/coregrind/m_initimg/initimg-freebsd.c#2 edit .. //depot/projects/valgrind/coregrind/m_sigframe/sigframe-x86-freebsd.c#2 edit .. //depot/projects/valgrind/coregrind/m_syscall.c#4 edit .. //depot/projects/valgrind/coregrind/m_syswrap/priv_types_n_macros.h#6 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syscall-x86-freebsd.S#4 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd-variants.c#3 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#9 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-generic.c#5 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-x86-freebsd.c#6 edit .. //depot/projects/valgrind/coregrind/pub_core_syscall.h#4 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_coredump/coredump-x86-freebsd.c#2 (text+ko) ==== @@ -29,6 +29,7 @@ */ #include "pub_core_basics.h" +#include "pub_core_vki.h" #include "pub_core_libcbase.h" #include "pub_core_coredump.h" #include "pub_core_threadstate.h" ==== //depot/projects/valgrind/coregrind/m_debuginfo/readelf.c#3 (text+ko) ==== @@ -1490,7 +1490,8 @@ } /* PLT is different on different platforms, it seems. */ -# if defined(VGP_x86_linux) || defined(VGP_amd64_linux) +# if defined(VGP_x86_linux) || defined(VGP_amd64_linux) || \ + defined(VGP_x86_freebsd) || defined(VGP_amd64_freebsd) /* Accept .plt where mapped as rx (code) */ if (0 == VG_(strcmp)(name, ".plt")) { if (inrx && size > 0 && !di->plt_present) { ==== //depot/projects/valgrind/coregrind/m_initimg/initimg-freebsd.c#2 (text+ko) ==== @@ -483,15 +483,9 @@ /* now, how big is the auxv? */ auxsize = sizeof(*auxv); /* there's always at least one entry: AT_NULL */ for (cauxv = orig_auxv; cauxv->a_type != AT_NULL; cauxv++) { - if (cauxv->a_type == AT_PLATFORM) - stringsize += VG_(strlen)(cauxv->u.a_ptr) + 1; auxsize += sizeof(*cauxv); } -# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux) - auxsize += 2 * sizeof(*cauxv); -# endif - /* OK, now we know how big the client stack is */ stacksize = sizeof(Word) + /* argc */ @@ -639,14 +633,6 @@ auxv = (struct ume_auxv *)ptr; *client_auxv = (UInt *)auxv; -# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux) - auxv[0].a_type = AT_IGNOREPPC; - auxv[0].u.a_val = AT_IGNOREPPC; - auxv[1].a_type = AT_IGNOREPPC; - auxv[1].u.a_val = AT_IGNOREPPC; - auxv += 2; -# endif - for (; orig_auxv->a_type != AT_NULL; auxv++, orig_auxv++) { /* copy the entry... */ @@ -664,8 +650,6 @@ case AT_EUID: case AT_GID: case AT_EGID: - case AT_CLKTCK: - case AT_FPUCW: /* All these are pointerless, so we don't need to do anything about them. */ break; @@ -688,45 +672,15 @@ auxv->u.a_val = info->interp_base; break; - case AT_PLATFORM: - /* points to a platform description string */ - auxv->u.a_ptr = copy_str(&strtab, orig_auxv->u.a_ptr); - break; - case AT_ENTRY: auxv->u.a_val = info->entry; break; - case AT_HWCAP: - break; - case AT_DCACHEBSIZE: case AT_ICACHEBSIZE: case AT_UCACHEBSIZE: -# if defined(VGP_ppc32_linux) - /* acquire cache info */ - if (auxv->u.a_val > 0) { - VG_(machine_ppc32_set_clszB)( auxv->u.a_val ); - VG_(debugLog)(2, "initimg", - "PPC32 cache line size %u (type %u)\n", - (UInt)auxv->u.a_val, (UInt)auxv->a_type ); - } -# elif defined(VGP_ppc64_linux) - /* acquire cache info */ - if (auxv->u.a_val > 0) { - VG_(machine_ppc64_set_clszB)( auxv->u.a_val ); - VG_(debugLog)(2, "initimg", - "PPC64 cache line size %u (type %u)\n", - (UInt)auxv->u.a_val, (UInt)auxv->a_type ); - } -# endif break; -# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux) - case AT_IGNOREPPC: - break; -# endif - case AT_SECURE: /* If this is 1, then it means that this program is running suid, and therefore the dynamic linker should @@ -738,9 +692,7 @@ break; case AT_SYSINFO: -# if !defined(VGP_ppc32_linux) && !defined(VGP_ppc64_linux) case AT_SYSINFO_EHDR: -# endif /* Trash this, because we don't reproduce it */ auxv->a_type = AT_IGNORE; break; @@ -954,7 +906,7 @@ /* On Linux we get client_{ip/sp/toc}, and start the client with all other registers zeroed. */ -# if defined(VGP_x86_linux) +# if defined(VGP_x86_freebsd) vg_assert(0 == sizeof(VexGuestX86State) % 8); /* Zero out the initial state, and set up the simulated FPU in a @@ -975,7 +927,7 @@ asm volatile("movw %%ds, %0" : : "m" (arch->vex.guest_DS)); asm volatile("movw %%ss, %0" : : "m" (arch->vex.guest_SS)); -# elif defined(VGP_amd64_linux) +# elif defined(VGP_amd64_freebsd) vg_assert(0 == sizeof(VexGuestAMD64State) % 8); /* Zero out the initial state, and set up the simulated FPU in a @@ -990,37 +942,6 @@ arch->vex.guest_RSP = iifii.initial_client_SP; arch->vex.guest_RIP = iifii.initial_client_IP; -# elif defined(VGP_ppc32_linux) - vg_assert(0 == sizeof(VexGuestPPC32State) % 8); - - /* Zero out the initial state, and set up the simulated FPU in a - sane way. */ - LibVEX_GuestPPC32_initialise(&arch->vex); - - /* Zero out the shadow areas. */ - VG_(memset)(&arch->vex_shadow1, 0, sizeof(VexGuestPPC32State)); - VG_(memset)(&arch->vex_shadow2, 0, sizeof(VexGuestPPC32State)); - - /* Put essential stuff into the new state. */ - arch->vex.guest_GPR1 = iifii.initial_client_SP; - arch->vex.guest_CIA = iifii.initial_client_IP; - -# elif defined(VGP_ppc64_linux) - vg_assert(0 == sizeof(VexGuestPPC64State) % 16); - - /* Zero out the initial state, and set up the simulated FPU in a - sane way. */ - LibVEX_GuestPPC64_initialise(&arch->vex); - - /* Zero out the shadow areas. */ - VG_(memset)(&arch->vex_shadow1, 0, sizeof(VexGuestPPC64State)); - VG_(memset)(&arch->vex_shadow2, 0, sizeof(VexGuestPPC64State)); - - /* Put essential stuff into the new state. */ - arch->vex.guest_GPR1 = iifii.initial_client_SP; - arch->vex.guest_GPR2 = iifii.initial_client_TOC; - arch->vex.guest_CIA = iifii.initial_client_IP; - # else # error Unknown platform # endif ==== //depot/projects/valgrind/coregrind/m_sigframe/sigframe-x86-freebsd.c#2 (text+ko) ==== @@ -30,6 +30,7 @@ */ #include "pub_core_basics.h" +#include "pub_core_vki.h" #include "pub_core_threadstate.h" #include "pub_core_aspacemgr.h" /* find_segment */ #include "pub_core_libcbase.h" @@ -98,7 +99,8 @@ /* XXX This is wrong. Surely we should store the shadow values into the shadow memory behind the actual values? */ - VexGuestX86State vex_shadow; + VexGuestX86State vex_shadow1; + VexGuestX86State vex_shadow2; /* HACK ALERT */ VexGuestX86State vex; @@ -438,7 +440,7 @@ /* For tracking memory events, indicate the entire frame has been allocated. */ VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB, - size + VG_STACK_REDZONE_SZB ); + size + VG_STACK_REDZONE_SZB, tid ); return True; } @@ -454,7 +456,8 @@ { frame->sigNo_private = sigNo; frame->magicPI = 0x31415927; - frame->vex_shadow = tst->arch.vex_shadow; + frame->vex_shadow1 = tst->arch.vex_shadow1; + frame->vex_shadow2 = tst->arch.vex_shadow2; /* HACK ALERT */ frame->vex = tst->arch.vex; /* end HACK ALERT */ @@ -573,6 +576,7 @@ void VG_(sigframe_create)( ThreadId tid, Addr esp_top_of_frame, const vki_siginfo_t *siginfo, + const struct vki_ucontext *uc, void *handler, UInt flags, const vki_sigset_t *mask, @@ -643,7 +647,8 @@ } tst->sig_mask = frame->mask; tst->tmp_sig_mask = frame->mask; - tst->arch.vex_shadow = frame->vex_shadow; + tst->arch.vex_shadow1 = frame->vex_shadow1; + tst->arch.vex_shadow2 = frame->vex_shadow2; /* HACK ALERT */ tst->arch.vex = frame->vex; /* end HACK ALERT */ ==== //depot/projects/valgrind/coregrind/m_syscall.c#4 (text+ko) ==== @@ -183,6 +183,17 @@ return r; } +#ifdef VGO_freebsd +SysRes VG_(mk_SysRes_Success2) ( UWord res, UWord res2 ) { + SysRes r; + r.res = res; + r.res2 = res2; + r.err = 0; + r.isError = False; + return r; +} +#endif + /* --------------------------------------------------------------------- A function for doing syscalls. ==== //depot/projects/valgrind/coregrind/m_syswrap/priv_types_n_macros.h#6 (text+ko) ==== @@ -318,6 +318,13 @@ status->sres = VG_(mk_SysRes_Success)(zzz); \ } while (0) +#ifdef VGO_freebsd +#define SET_STATUS_Success2(zzz, zzz2) \ + do { status->what = SsComplete; \ + status->sres = VG_(mk_SysRes_Success2)(zzz, zzz2); \ + } while (0) +#endif + #define SET_STATUS_Failure(zzz) \ do { Word wzz = (Word)(zzz); \ /* Catch out wildly bogus error values. */ \ ==== //depot/projects/valgrind/coregrind/m_syswrap/syscall-x86-freebsd.S#4 (text+ko) ==== @@ -29,7 +29,7 @@ */ #include "pub_core_basics_asm.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" #include "libvex_guest_offsets.h" ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd-variants.c#3 (text+ko) ==== @@ -46,6 +46,7 @@ #include "pub_core_basics.h" +#include "pub_core_vki.h" #include "pub_core_threadstate.h" #include "pub_core_aspacemgr.h" #include "pub_core_debuginfo.h" // VG_(di_notify_*) ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#9 (text+ko) ==== @@ -29,10 +29,13 @@ */ #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_clientstate.h" #include "pub_core_debuglog.h" #include "pub_core_libcbase.h" @@ -41,7 +44,6 @@ #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" @@ -54,8 +56,6 @@ #include "priv_syswrap-generic.h" #include "priv_syswrap-freebsd.h" -#include "vki_unistd.h" /* for the __NR_* constants */ - // Run a thread from beginning to end and return the thread's // scheduler-return-code. static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) @@ -70,14 +70,15 @@ vg_assert(tst->status == VgTs_Init); + /* make sure we get the CPU lock before doing anything significant */ - VG_(set_running)(tid); + VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)"); if (0) VG_(printf)("thread tid %d started: stack = %p\n", tid, &tid); - VG_TRACK ( post_thread_create, tst->os_state.parent, tid ); + VG_TRACK (pre_thread_first_insn, tid); tst->os_state.lwpid = VG_(gettid)(); tst->os_state.threadgroup = VG_(getpid)(); @@ -301,7 +302,7 @@ res = VG_(do_syscall0)( __NR_fork ); - if (!res.isError && res.val == 0) { + if (!res.isError && res.res == 0) { /* child */ VG_(do_atfork_child)(tid); @@ -309,11 +310,11 @@ VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL); } else - if (!res.isError && res.val > 0) { + if (!res.isError && res.res > 0) { /* parent */ if (VG_(clo_trace_syscalls)) VG_(printf)(" clone(fork): process %d created child %d\n", - VG_(getpid)(), res.val); + VG_(getpid)(), res.res); /* restore signal mask */ VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL); ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-generic.c#5 (text+ko) ==== @@ -2358,6 +2358,7 @@ PRE_REG_READ2(long, "getpriority", int, which, int, who); } +#ifdef VGO_linux PRE(sys_pwrite64_on64bitplat) { vg_assert(sizeof(UWord) == 8); @@ -2370,7 +2371,6 @@ PRE_MEM_READ( "pwrite64(buf)", ARG2, ARG3 ); } -#ifdef VGO_linux // The actual kernel definition of this routine takes a // single 64 bit offset argument. This version is for 32 bit // platforms only and treats the offset as two values - the @@ -2429,6 +2429,7 @@ PRE_REG_READ1(long, "getsid", vki_pid_t, pid); } +#ifdef VGO_linux PRE(sys_pread64_on64bitplat) { vg_assert(sizeof(UWord) == 8); @@ -2449,7 +2450,6 @@ } } -#ifdef VGO_linux // The actual kernel definition of this routine takes a // single 64 bit offset argument. This version is for 32 bit // platforms only and treats the offset as two values - the @@ -2709,9 +2709,7 @@ */ { vki_sigset_t allsigs; -#if 0 vki_siginfo_t info; -#endif for (i = 1; i < VG_(max_signal); i++) { struct vki_sigaction sa; @@ -2727,7 +2725,6 @@ VG_(sigfillset)(&allsigs); while(VG_(sigtimedwait_zero)(&allsigs, &info) > 0) ; -#endif VG_(sigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL); } @@ -4349,7 +4346,6 @@ } } break; -#endif /* I2C (/dev/i2c-*) ioctls */ case VKI_I2C_SLAVE: @@ -4360,6 +4356,7 @@ case VKI_I2C_FUNCS: PRE_MEM_WRITE( "ioctl(I2C_FUNCS)", ARG3, sizeof(unsigned long) ); break; +#endif /* We don't have any specific information on it, so try to do something reasonable based on direction and @@ -5070,7 +5067,6 @@ } } break; -#endif /* I2C (/dev/i2c-*) ioctls */ case VKI_I2C_SLAVE: @@ -5081,6 +5077,7 @@ case VKI_I2C_FUNCS: POST_MEM_WRITE( ARG3, sizeof(unsigned long) ); break; +#endif /* We don't have any specific information on it, so try to do something reasonable based on direction and ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-x86-freebsd.c#6 (text+ko) ==== @@ -34,6 +34,8 @@ */ #include "pub_core_basics.h" +#include "pub_core_vki.h" +#include "pub_core_vkiscnums.h" #include "pub_core_threadstate.h" #include "pub_core_debuginfo.h" // VG_(di_notify_mmap) #include "pub_core_aspacemgr.h" @@ -52,14 +54,13 @@ #include "pub_core_syscall.h" #include "pub_core_syswrap.h" #include "pub_core_tooliface.h" +#include "pub_core_stacks.h" // VG_(register_stack) #include "priv_types_n_macros.h" #include "priv_syswrap-generic.h" /* for decls of generic wrappers */ #include "priv_syswrap-freebsd.h" /* for decls of linux-ish wrappers */ #include "priv_syswrap-main.h" -#include "vki_unistd.h" /* for the __NR_* constants */ - /* Simulate C-style return values for pipe(2). This does not belong here at all, it should be in m_libcfile.c. */ @@ -152,7 +153,7 @@ static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void ) { Int nbytes = VEX_GUEST_X86_GDT_NENT * sizeof(VexGuestX86SegDescr); - return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1); + return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1); } #if 0 @@ -160,7 +161,7 @@ static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) { Int nbytes = VEX_GUEST_X86_LDT_NENT * sizeof(VexGuestX86SegDescr); - return VG_(arena_calloc)(VG_AR_CORE, nbytes, 1); + return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxL.1", nbytes, 1); } /* Free up an LDT or GDT allocated by the above fns. */ ==== //depot/projects/valgrind/coregrind/pub_core_syscall.h#4 (text+ko) ==== @@ -99,6 +99,9 @@ extern SysRes VG_(mk_SysRes_amd64_freebsd) ( ULong val, ULong val2, ULong flags ); extern SysRes VG_(mk_SysRes_Error) ( UWord val ); extern SysRes VG_(mk_SysRes_Success) ( UWord val ); +#ifdef VGO_freebsd +extern SysRes VG_(mk_SysRes_Success2) ( UWord val, UWord val2 ); +#endif /* Return a string which gives the name of an error value. Note,