[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Porting valgrind to Debian/kFreeBSD



On Thu, Mar 07, 2013 at 09:40:38AM -0600, Jeff Epler wrote:
> Valgrind does appear to be aware of sysarch, implementing
> sysarch(AMD64_SET_FSBASE) in
> coregrind/m_syswrap/syswrap-amd64-freebsd.c.

Aha.  eglibc is testing that the syscall succeeds, which is indicated by
setting RAX to 0.


       /* "do" the syscall ourselves; the kernel never sees it */
       SET_STATUS_Success2((ULong)*p, tst->arch.vex.guest_RDX );
+      SET_STATUS_Success2(0, tst->arch.vex.guest_RAX );

I was just able to get a useful valgrind run on my Debian/kFreeBSD amd64
system:

jepler@zaphod:/store/src/valgrind-freebsd$ ./vg-in-place ./a.out
==84159== Memcheck, a memory error detector
==84159== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==84159== Using Valgrind-3.8.0 and LibVEX; rerun with -h for copyright info
==84159== Command: ./a.out
==84159== 
==84159== Invalid write of size 2
==84159==    at 0x40055C: main (in /store/src/valgrind-freebsd/a.out)
==84159==  Address 0x1556044 is 0 bytes after a block of size 4 alloc'd
==84159==    at 0x10056CE: malloc (vg_replace_malloc.c:274)
==84159==    by 0x40054D: main (in /store/src/valgrind-freebsd/a.out)
==84159== 
==84159== 
==84159== HEAP SUMMARY:
==84159==     in use at exit: 4 bytes in 1 blocks
==84159==   total heap usage: 1 allocs, 0 frees, 4 bytes allocated
==84159== 
==84159== LEAK SUMMARY:
==84159==    definitely lost: 4 bytes in 1 blocks
==84159==    indirectly lost: 0 bytes in 0 blocks
==84159==      possibly lost: 0 bytes in 0 blocks
==84159==    still reachable: 0 bytes in 0 blocks
==84159==         suppressed: 0 bytes in 0 blocks
==84159== Rerun with --leak-check=full to see details of leaked memory
==84159== 
==84159== For counts of detected and suppressed errors, rerun with: -v
==84159== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 7 from 7)

This is very exciting!

Jeff
PS test program was
    int main() {
        char *buf = malloc(4);
        strcpy(buf, "hello");
        return 0;
    }


Reply to: