From owner-p4-projects@FreeBSD.ORG Fri Oct 24 04:04:06 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 787A61065685; Fri, 24 Oct 2008 04:04:06 +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 3CE1B1065682 for ; Fri, 24 Oct 2008 04:04:06 +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 1BEB58FC12 for ; Fri, 24 Oct 2008 04:04:06 +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 m9O445CL056048 for ; Fri, 24 Oct 2008 04:04:05 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9O445AU056046 for perforce@freebsd.org; Fri, 24 Oct 2008 04:04:05 GMT (envelope-from peter-gmail@wemm.org) Date: Fri, 24 Oct 2008 04:04:05 GMT Message-Id: <200810240404.m9O445AU056046@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 151842 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: Fri, 24 Oct 2008 04:04:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=151842 Change 151842 by peter@peter_cheese on 2008/10/24 04:03:43 Try and get a better handle on err vs return value stuff in the New World Order. Hack to ignore a discrepancy in err value in client state - we have the right return anyway - this is a redundant sanity check that fails. With this, it runs /bin/ls successfully and reports a leak. Affected files ... .. //depot/projects/valgrind/coregrind/m_syscall.c#5 edit .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-main.c#7 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_syscall.c#5 (text+ko) ==== @@ -142,7 +142,13 @@ SysRes VG_(mk_SysRes_x86_freebsd) ( UInt val, UInt val2, UInt flags ) { SysRes res; res.isError = (flags & 1) != 0; /* PSL_C, carry bit */ - res.res = val; + if (res.isError) { + res.err = val; + res.res = 0; + } else { + res.err = 0; + res.res = val; + } res.res2 = val2; return res; } @@ -151,7 +157,13 @@ SysRes VG_(mk_SysRes_amd64_freebsd) ( ULong val, ULong val2, ULong flags ) { SysRes res; res.isError = (flags & 1) != 0; /* PSL_C, carry bit */ - res.res = val; + if (res.isError) { + res.err = val; + res.res = 0; + } else { + res.err = 0; + res.res = val; + } res.res2 = val2; return res; } ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-main.c#7 (text+ko) ==== @@ -286,12 +286,16 @@ static Bool eq_SyscallStatus ( SyscallStatus* s1, SyscallStatus* s2 ) { +//VG_(printf)( "eq_SyscallStatus: what %d %d res %ld %ld res2 %ld %ld err %ld %ld\n", s1->what, s2->what, s1->sres.res, s2->sres.res, s1->sres.res2, s2->sres.res2, s1->sres.err, s2->sres.err); return s1->what == s2->what && s1->sres.res == s2->sres.res #if defined(VGO_freebsd) && s1->sres.res2 == s2->sres.res2 #endif - && s1->sres.err == s2->sres.err; +#if !defined(VGO_freebsd) /* getSyscallStatusFromMumble is out of sync */ + && s1->sres.err == s2->sres.err +#endif + && s1->sres.isError == s2->sres.isError; } @@ -410,7 +414,7 @@ * Blindly copy 8 arguments from the stack. Valgrind checks * for initialized-ness elsewhere. */ - memcpy(&canonical->arg1, &argv[1], 8 * sizeof(UWord)); + VG_(memcpy)(&canonical->arg1, &argv[1], 8 * sizeof(UWord)); #else # error "getSyscallArgsFromGuestState: unknown arch" @@ -536,8 +540,7 @@ #elif defined(VGP_x86_freebsd) VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; canonical->what = SsComplete; - canonical->sres.res = (UWord)gst->guest_EAX; - canonical->sres.res2 = (UWord)gst->guest_EDX; + canonical->sres = VG_(mk_SysRes_x86_freebsd)( gst->guest_EAX, gst->guest_EDX, LibVEX_GuestX86_get_eflags(gst)); #elif defined(VGP_amd64_freebsd) VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;