|
From: Doug R. <df...@nl...> - 2004-01-03 18:49:03
|
On Sat, 2004-01-03 at 18:06, Nicholas Nethercote wrote: > On Sat, 3 Jan 2004, Doug Rabson wrote: > > > > Well done! A few people have tried this, but it sounds like you've got a > > > lot further than anyone else. Would you be able to write some kind of > > > summary describing the changes you had to make? That would be very useful > > > for people to get a grip on what you've done. > > > > I summarised most of the changes in a later message and you can get a > > patch against today's cvs at > > http://people.freebsd.org/~dfr/valgrind-20040103-dfr.diff. > > Er, which message? I only see a couple of brief descriptions... I was > thinking more along the lines of a page or two of summary -- more work for > you, I realise, but much easier for everyone else to understand than a > 130KB diff... Its earlier in this very thread. I'll just quote the relavent part: The only really dodgy bits in this patch are in stage1.c where I had to stub out the stack alignment bits. The code couldn't code when the alignment offset wasn't exactly zero because it assumed that the new aux entries would fit exactly into the gap. I also had problems moving the brk() up past the end of stage2 so I punted on that and just overrode brk() and sbrk() instead. I had problems with vg_signals.c for the async signal handlers. Currently FreeBSD has a bug (which will be fixed RSN) with sigaltstack that means that all threads share the same stack setting. This meant that async signals (intended for the proxylwp) were being delivered on the signal stack instead of the proxylwp stack. I just changed the code to not set SA_ONSTACK for those signals. Attaching GDB doesn't work very well with this port since we have no equivalent of /proc/self/fd. I guess the code could be changed to remember the exec filename and pass that instead of /proc/self/fd/$d. This also affected the implementation of VG_(resolve_filename) which I worked around by using the file descriptor tracking code to lookup the filename. > > > The most fiddly part was getting syscalls to work. FreeBSD (and probably > > all 4.4BSD derived systems) has a quite different syscall ABI with > > arguments on the stack and error-returns signalled with the carry flag. > > Add to that the fact that some (not all) syscalls return an extra 32bits > > in %edx and things get a bit tricky in vg_syscalls.c. > > That's exactly the sort of thing I'd like to see in a summary (I don't > think you mentioned this previously)... what are the details of "things > get a bit tricky"? Well the part which executes the system call has to be changed to account for the extra return values (eax, edx and eflags instead of just eax). It also needs to be able to preserve the value of edx for those syscalls which don't change its value. All the bits of code through the system which assume the linux-style error return value of -errno need to be tweaked to account for the BSD-style error return which has errno in eax and eflags.C set. Most of that can be hidden by a macro so: res = -VKI_EINVAL; changes to #define seterror(e) do {tst->m_eax = e; tst->m_eflags |= EFlagC;} while(0) ... seterror(VKI_EINVAL); |