Commit Graph

37 Commits

Author SHA1 Message Date
Nicholas Nethercote
f8910f2b3f Avoid compile warnings.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3144
2004-11-29 16:57:02 +00:00
Nicholas Nethercote
61fcb2828d Gave VG_(do_syscall)() a more specific prototype:
Int VG_(do_syscall) ( UInt, UWord, UWord, UWord, UWord, UWord, UWord );

to replace the previous:
  
  Int VG_(do_syscall) ( UInt, ... )

Reason being that sometimes you could get incorrect args passed, when
passing 32-bit ints on 64-bit platforms.  I also added macros
VG_(do_syscall[123456]) to make life easier, and converted all the
relevant calls.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3143
2004-11-29 16:49:18 +00:00
Nicholas Nethercote
57ab6c1b41 Fix post-amd64-commit x86 breakage:
- remove warnings from vg_scheduler.c by using (UWord) casts rather than
  64-bit-assuming (ULong) casts.
- move deref_Addr() to x86-linux/syscalls.c, where it's now used.

Also got rid of the ancient SIGNAL_SIMULATION flag, which is a remnant of very
early days -- things now only work with signal simulation, so no point in
keeping it around.

Also make addrcheck/tests/fprw work again now that --single-step is
dead.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3137
2004-11-29 14:24:57 +00:00
Nicholas Nethercote
10b4595add Added beginnings of an AMD64 port, so lots of new files and directories.
It compiles, but aborts immediately if you try to run it.

I didn't include ldt.c;  I'm not sure how the LDT is used on AMD64.  It can be
added later if necessary.

While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
  ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
  ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
  parameter.
- Couple of other minor things.

I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places.  In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places.  This difference will have to be abstracted out somehow.

Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.

Also moved the ipc wrapper into x86, since it's not applicable for
AMD64.  However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs.  Hmm.  Also now using the real IPC constants rather than magic
numbers in the wrapper.

Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
  numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
  thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
2004-11-29 13:54:10 +00:00
Nicholas Nethercote
4e12afbac2 Moved some duplicated macros out of arch/OS/platform-specific parts,
into the core.  Renamed them with capital letters at the same time (eg.
arg1-->ARG1, res-->RES) to reduce likelihood of name conflicts, and also
it doesn't hurt to make it clearer that they're macros.  The result is a
very big diff, but conceptually it's very simple.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3126
2004-11-27 16:10:23 +00:00
Nicholas Nethercote
f23dea17b2 Factored out some stuff duplicated across all archs, to do with syscall
wrappers.  The management apologises for the excessive use of macros, but it's
hard to avoid and really does make the repetitive parts of the code (ie. the
parts that are repeated for each arch) much more concise.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3124
2004-11-27 15:22:24 +00:00
Nicholas Nethercote
4399d9700f Added beginnings of an ARM port, to the point where it compiles. It does not
run, though.  There are lots of stubs to be filled in.  (The asm ones currently
just have "swi" in them, which seems to cause seg faults.) 

Also, some of the macros are decided dubious, especially:

  ARCH_* are bogus
  SYSCALL_RET is bogus
  PLATFORM_SET_SYSCALL_RESULT is bogus
  not sure about SET_SYSCALL_RETVAL
  FIRST_STACK_FRAME et al -- bogus?
  VG_MAX_JUMPS ?

And in stage2.lds, the 0x8048000 is almost certainly wrong


This required some tweakings of the core:
- some of the vki_*.h kernel types were fixed up

- had to disable the AM_PROG_CC_C_O macro in configure.in, because automake
  (autoconf?) didn't like it...

- some "#ifdef __x86__" guards were introduced, for nasty x86 things I don't
  yet know how to factor out (trampoline page muck, sysinfo page muck).

- fixed a minor stupidity in vg_proxylwp.c.

- moved the ptrace wrapper into the x86-linux part

- had to change the intercept mangling scheme, to use 'J' instead of '$' as the
  escape char because GCC didn't like '$'.  This is all very dubious, and only
  works because none of our intercepted symbols contains a 'J'.  To be fixed up
  ASAP.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3120
2004-11-26 19:34:36 +00:00
Nicholas Nethercote
9680327dd9 Cleanups:
- move things around so that each arch doesn't duplicate stuff to do with
  VG_(do_thread_syscall)().
- enum PXState doesn't need to be visible outside vg_proxylwp.c



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3097
2004-11-24 18:14:41 +00:00
Nicholas Nethercote
feb4fbaef5 Removed all uses of register numbers (eg. arch-specific ones like R_EAX, and
arch-neutral ones like R_STACK_PTR).  Where they were used, we now always talk
about an offset into the Vex guest state, and an offset.  As a result,
the shadow register get/set functions had to change.  They now also use
an offset and size, and in an arch-neutral way.

Also, I combined the five the post_reg_write* functions into a single one that
takes a 'CorePart' parameter (plus also a ThreadId).  Also, I added more
arguments (the CorePart, and the ThreadId) to the post_mem_write event, for
consistency with the pre_mem_* events.

Also, I reduced the number of register names that must be specified by each
arch, by factoring out duplication; and shortened their names for the core (eg.
ARCH_STACK_PTR is now STACK_PTR).

Plus some related minor cleanups in syscall wrappers.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3094
2004-11-24 16:30:22 +00:00
Nicholas Nethercote
ef30c84f5f Update comments for the renaming of arch_thread_t.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3092
2004-11-24 10:55:37 +00:00
Julian Seward
3558db91b1 Get rid of baseBlock. Now, when generated code is running, the guest
state pointer points directly at the ThreadState.arch.vex field, thus
updating it in place and avoiding a lot of code (and time-wasting)
which copies stuff back and forth to baseBlock.

Fix zillions of other places in the system where the current thread id
is needed.  It is now passed to all needed places.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3090
2004-11-24 10:44:19 +00:00
Nicholas Nethercote
230e9ae419 Clean slightly.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3089
2004-11-23 19:10:18 +00:00
Nicholas Nethercote
45ef5a7794 Remove out-of-date comment.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3088
2004-11-23 18:42:54 +00:00
Julian Seward
b3498dd85c Merge in enough changes from the old Vex tree to make stage2 link, at
least.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3061
2004-11-22 19:01:47 +00:00
Robert Walsh
423bfef15b Allow readlink to handle /proc/self/exe and /proc/<pid>/exe properly.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3048
2004-11-18 22:56:09 +00:00
Nicholas Nethercote
2f787498e8 Arch-abstraction:
- Moved some more syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c.  There are still heaps of wrappers that probably aren't
  generic, but I'm not sure, so they're staying in vg_syscalls.c for now.
  Let's worry about that when we do an OS port.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3036
2004-11-17 18:22:38 +00:00
Nicholas Nethercote
05522127c4 Add coregrind/linux/ and coregrind/linux/* that was supposed to go in the last
commit.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3035
2004-11-17 17:21:12 +00:00
Nicholas Nethercote
d0ef8153b4 Arch-abstraction:
- Moved the system call table into x86-linux, since it's platform specific.

- Started moving the non-generic syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c as appropriate.

- Added new coregrind/linux/ directory and some files in it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3034
2004-11-17 17:11:45 +00:00
Nicholas Nethercote
1524d5ac06 Converted the last syscalls. Phew. Still some cleaning up to do, esp. with
socketcall() and ipc() which are done too simplistically.

Also, VG_([gs]et_thread_area)() both now return -VKI_EFAULT if they are given a
NULL pointer.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3024
2004-11-16 17:13:24 +00:00
Nicholas Nethercote
df2c9db230 converted mmap and mmap2
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3003
2004-11-15 12:57:39 +00:00
Nicholas Nethercote
b55751404f Improved Memcheck's error checking messages in two significant ways:
- All memory-related errors are now clear whether they are caused by
  unaddressable or uninitialised memory.  (Previously, writes were
  clearly addressability errors, but reads could be either.)  Mostly
  done by replacing the 'isWrite' field in MAC_Error with 'isUnaddr'.
  Also, mc_check_readable() now indicates not just if an error occurred,
  but what kind of error (ie. addressability or definedness).

- Put machinery into place in the core to inform tools when registers
  are being read by the core -- ie. a 'pre_reg_read' event.  Most
  notably, this facilitates syscall scalar arg definedness checking for
  Memcheck.  Currently this is only working for read(), write(), exit()
  and exit_group(), but it will be extended as the syscalls are
  overhauled as part of the arch-abstraction work.

  A consequence of this is that the ParamErr messages have changed.  This:

    Syscall param write(buf) contains uninitialised byte(s)

  now means that the pointer 'buf' is partially undefined.  If the memory
  pointed to by 'buf' is partially undefined or unaddressable, it says one of:

    Syscall param write(buf) points to uninitialised byte(s)
    Syscall param write(buf) points to unaddressable byte(s)

  The docs have been updated accordingly.

  I also added a couple of regression tests.

These two change sare notable for being the first improvements to
Memcheck's checking/errors in a long time.

I also folded mc_clientreqs.c into mc_main.c, which saves exporting a
whole bunch of things that are not used anywhere else.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2949
2004-11-08 19:20:09 +00:00
Nicholas Nethercote
7fbab350e1 Some syscall improvements:
- made pre_mem_read etc. calls more concise by improving the macros used
- made printing calls more concise by renaming the macro used
- updated README_MISSING_SYSCALL_OR_IOCTL
- improved --trace-syscalls=yes;  a bit neater, and now prints return values
  for all syscalls.
- introduced LOHI64 macro for 64-bit args that are created from 2 32-bit args
- 64-bit cleanness tweaks for *xattr* syscall printing


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2941
2004-11-06 15:38:43 +00:00
Nicholas Nethercote
c4cf15dc21 Arch-abstraction:
- Added include/x86-linux/ and include/linux/ subdirectories, with Makefile.am
  files.

- Overhauled the definitions of kernel types.  include/vg_kerneliface.h is now
  three files, include/linux/vki.h, include/x86-linux/vki_arch.h, and
  include/x86-linux/vki_arch_posixtypes.h.  These files separate the
  common/Linux and x86/Linux parts cleanly.  All code is copied verbatim from
  the relevant kernel headers, except that VKI_/vki_ prefixes are added as
  necessary to distinguish them from glibc types.  (This is done consistently,
  unlike previously when some types did not have the prefixes.)

  All code is clearly marked to show which particular header file it came from,
  and the Linux version used.  (I used 2.6.8.1, the most recent stable release,
  for all of them.)

  A few of the types changed;  this is because they changed between the older
  versions of Linux and the current 2.6.8.1.  I checked that all these changes
  were ok with respect to backwards compatibility for our purposes.

- vg_unsafe.h has been removed;  we are no longer including any kernel headers,
  as we have our own copies for everything.  This is because installed kernel
  headers are not reliable, and often cause compilation problems. (bug
  #92420 is a recent example)

- Removed some no-longer-needed header-presence tests from configure.in.

- Some code in the rest of Valgrind was changed to account for some slight
  changes in the names of our VKI_/vki_ kernel constants and types.

- Updated README_MISSING_SYSCALL_OR_IOCTL accordingly.

- Fixed off-by-one error with VKI_GDT_ENTRY_TLS_MAX (merged from stable branch)

The end result is that the kernel types situation should be much clearer, and
similar files can be created relatively easily for other architectures as
necessary.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2884
2004-10-31 18:48:21 +00:00
Nicholas Nethercote
171c23bcc2 64-bit cleanness tweaks.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2845
2004-10-26 10:57:24 +00:00
Nicholas Nethercote
6bd10a4f02 comment wibbles
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2841
2004-10-25 20:43:14 +00:00
Nicholas Nethercote
3e21a5a1fd Whoops, syscall.S is platform-specific, and so must go in x86-linux/ rather
than x86/.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2800
2004-10-19 14:23:46 +00:00
Nicholas Nethercote
f19fdbd136 Tweak type of VGA_(thread_syscall), and related variable name changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2793
2004-10-18 17:41:36 +00:00
Nicholas Nethercote
7d17111d99 Arch-abstraction:
- factor out the horrid thread_syscall() function, which is written in assembly
  code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2792
2004-10-18 17:36:40 +00:00
Nicholas Nethercote
296804a70e Arch-abstraction:
- factor out the setting of syscall results, which can be more complicated
  than just putting a value in the result register (eg. PPC has to fiddle with
  multiple registers).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2789
2004-10-18 17:00:30 +00:00
Nicholas Nethercote
3cff5cf8d9 Arch-abstraction:
- factor out code for restarting syscalls


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2786
2004-10-18 15:34:14 +00:00
Nicholas Nethercote
f3ef39ea53 Arch-abstraction:
- account for x86's strange argument passing (via memory) for mmap()


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2785
2004-10-18 14:47:48 +00:00
Nicholas Nethercote
d1ad5601fb Arch-abstraction:
- factor out differences in ucontext types across different archs.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2751
2004-10-13 14:42:57 +00:00
Nicholas Nethercote
fcae323a88 Arch-abstraction:
- move LDT stuff out of core, into x86-linux specific stuff.  Some of it
  (VG_(do_useseg)()?) may be really x86-specific, rather than
  x86/linux-specific, but that can be fixed later if it's really shared with
  another OS.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2748
2004-10-13 13:05:20 +00:00
Nicholas Nethercote
d0d1c64875 Arch-abstraction:
- abstract out all the SET_THREAD_REG macros


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2716
2004-09-13 16:11:09 +00:00
Nicholas Nethercote
db64449073 Arch-abstraction:
- added x86-linux/core_platform.h
- factored out getting/setting of system call arguments, put it in
  platform-specific part.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2685
2004-09-10 17:42:11 +00:00
Nicholas Nethercote
6c9df6f79e Whoops, file should be called ".cvsignore", not ".cvgsigore".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2684
2004-09-10 16:34:24 +00:00
Nicholas Nethercote
a8d85f7180 Arch-abstraction:
- create coregrind/x86-linux/ directory.
- move vg_unistd.h into x86-linux/, because it's platform-dependent.  Also
  rename it as vki_unistd.h to make clear it's a kernel interface thing.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2681
2004-09-10 14:23:59 +00:00