From: Matthew E. <ma...@gs...> - 2003-04-22 12:12:59
|
> On Mon, 21 Apr 2003, Matthew Emmerton wrote: > > > There has been increasing interest in using Valgrind on the FreeBSD platform > > > > 1) Introduce a mapping layer for syscall #defines. > > > > For example, on Linux we'd have something like this: > > > > vg_syscall.h: > > #define VKI_SC_exit __NR_exit > > #define VKI_SC_getpid __NR_getpid > > > > And on FreeBSD, we'd have something like this: > > > > #define VKI_SC_exit SYS_exit > > #define VKI_SC_getpid SYS_getpid > > Do the *BSD and Linux system calls match as easily as this? Ie. none of > the "equivalent" ones have different arguments or similar? Most of the standard syscalls have matching names and matching data structures. So far, the only syscalls that have really caused me grief are the ones that simply don't exist on FreeBSD, and an #ifdef/#endif pair handles that nicely. Tom Hughes had mentioned including <sys/syscall.h> on Linux which will get SYS_xxx names rather than the __NR_xxx names. I'm curious as to whether this header implements is some sort of SUSv3 or POSIX standard for syscall naming? If so, it would be nice if we could take advantage of it since it would make this particular issue a moot point. > > 2) Introduce a mapping layer for pthread structures > > > > For example, on Linux: > > > > #define VKI_PTHREAD_OWNER __m_owner > > #define VKI_PTHREAD_COUNT __m_count > > #define VKI_PTHREAD_KIND __m_kind > > > > And on FreeBSD: > > > > #define VKI_PTHREAD_OWNER m_owner > > #define VKI_PTHREAD_COUNT m_data.m_count > > #define VKI_PTHREAD_KIND m_type > > Similarly, is there a nice one-to-one mapping between the relevant > structures, such that this simple approach will work? From what I've tried so far, this seems to work just fine -- especially since there are POSIX standards mandating the typing of internal pthread variables. (This is where FreeBSD isn't up to snuff, at least from what I've read.) > Have you tried implementing these layers? It's a nice, simple proposal > you've given, I'd like to know whether it suffices in practice :) Eg. I > imagine many of the syscalls, particularly the common ones, overlap in > *BSD and Linux, but what about the less common ones? Most of what I've done so far in the code is s/Linuxism/BSDism/ and that has been enough to get most of the code to compile and execute properly. There are pieces of code which are definitely OS-specified (most of the assembler stuff, for example) which I have adjusted by hand, and a couple of header (ie, vg_unsafe.h) which I have just rewritten. > Also, you say you have 1.9.5 working with only limited functionality... > what are the other stumbling blocks (you mentioned LDTs)? The biggest is the pthread stuff, which is intertwined with the LDT code, and because of some wierdness in our pthread code, I haven't got it working correctly yet. I will work away at getting more things working and get back to the list with my findings -- this was just a ping to see what the interest level was. Thanks, -- Matt |