Commit Graph

146 Commits

Author SHA1 Message Date
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
Tom Hughes
7d73311ef7 Improve the checks in PRE(execve) to check that the file being executed
is a regular file and fail with EINVAL if it is not.

This problem was highlight by bug 89481 although this doesn't solve the
actual problem reported in that bug.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2723
2004-09-25 16:13:55 +00:00
Tom Hughes
1555ffc9ce Fixed the statfs64 wrapper to look at the right argument for the
stat buffer and added an fstatfs64 wrapper.

CCMAIL: 90111-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2722
2004-09-24 22:57:17 +00:00
Tom Hughes
8adabd3253 Add support for the SIOCGPGRP ioctl and mark SIOCSPGRP as non-blocking
to avoid older kernels returning EPERM due to it being run in a separate
thread. This fixes bug #89198.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2697
2004-09-11 15:33:17 +00:00
Tom Hughes
bb199f64d1 Removed result checks from ioctl POST handlers as the POST handler is
not called unless PostOnFail is set so the checks are redundant.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2695
2004-09-11 15:14:59 +00:00
Tom Hughes
7d1259db4d Add system call wrappers for some CD related ioctls. Based on a
patch from Peter Jones <pjones@redhat.com>.

CCMAIL: 89263-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2693
2004-09-11 15:07:14 +00:00
Tom Hughes
0867191adf Add system call wrappers for the TIOCMBIS/TIOCMBIC/TIOMSET ioctls. Based
on a patch from Tobias Blomberg <blomman@ludd.ltu.se>.

CCMAIL: 88886-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2692
2004-09-11 14:37:04 +00:00
Tom Hughes
838ac82f4c Add system call wrappers for sched_{get,set}affinity. Based on patch
from Daryll Strauss <daryll@daryll.net>.

CCMAIL: 89139-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2691
2004-09-11 14:29:19 +00:00
Tom Hughes
99fcaf843d Make the virtualise setrlimit(RLIMIT_DATA) return EPERM when an attempt
is made to raise either the soft or hard limit above the current hard
limit rather than just allowing it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2690
2004-09-11 14:19:25 +00:00
Tom Hughes
2aad0526df Virtualise the stack rlimit for the main thread and make valgrind enforce
that limit when growing the stack. Also add a message when the stack in any
thread overflows.

CCMAIL: 73818-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2689
2004-09-11 14:16:57 +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
18355ff96b Arch-abstraction:
- Added include/x86/:  contains tool_arch.h, Makefile.am, .cvsignore.

- Added coregrind/x86/state.c.  Contains some arch-specific code for dealing
  with x86 registers -- eg. setting up the baseBlock, loading/saving the whole
  register state.  It is compiled into coregrind/x86/libarch.a and linked via
  ${VG_ARCH} with the core.

  Relatedly, also added coregrind/x86/{core_arch.h,core_arch_asm.h}.

- Correspondingly abstracted the register state out of ThreadState.  This
  affected every place that touches registers, and there are a lot of them.
  (Eventually all the register touching should be abstracted out in an
  arch-neutral way, but not yet;  one step at a time.)

- Added some declarations about register loading/saving functions to core.h;
  all architectures will have to provide these functions.

- Rejigged the build system so that the arch-specific stuff is all done via
  ${VG_ARCH}, rather than naming e.g. x86/ directly.  Appropriate -I arguments
  are used so that all the headers are found, etc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2656
2004-09-03 13:45:29 +00:00
Nicholas Nethercote
ba210a6364 Arch-abstraction step: renamed "vg_include.h" as "core.h".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2643
2004-09-01 23:58:16 +00:00
Tom Hughes
9a416ac766 Make some of the parallel port ioctls conditional as older systems
don't have them defined.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2638
2004-09-01 07:29:08 +00:00
Tom Hughes
0cd1d01031 Add support for POSIIX clocks and timers.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2630
2004-08-30 19:50:02 +00:00
Tom Hughes
22681c7c0a Include the filename in the system call trace for the access syscall.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2622
2004-08-26 12:26:27 +00:00
Nicholas Nethercote
2f53ead94d Fix problem with brk(). Thanks to Paull Mackerras for the patch.
Added a regression test for it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2619
2004-08-25 13:43:44 +00:00
Nicholas Nethercote
0ae90953a0 Here's a couple more I missed in the last commit.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2604
2004-08-23 16:39:42 +00:00
Nicholas Nethercote
7bb94df98b Use SYSNO and res, etc, instead of tst->m_eax in a few places to make things
less x86-specific.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2603
2004-08-23 16:36:09 +00:00
Nicholas Nethercote
40d9602352 Cleaned up the syscall wrappers a bit:
- corrected a few mistakes, eg. when printing them out, in prototypes
- made printing of "%p(%s)" args consistent
- removed 'sizeof_struct_user_fpxregs_struct' from PRE(ptrace)/POST(ptrace)
- allowing for the two different versions of open()


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2591
2004-08-18 14:37:17 +00:00
Nicholas Nethercote
b35a98059b getgroups can't block
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2589
2004-08-17 13:26:52 +00:00
Tom Hughes
1e3b61b6cf Add support for the parallel port ioctls.
CCMAIL: 86407-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2588
2004-08-16 19:46:55 +00:00
Tom Hughes
546afbe696 Add support for the POSIX message queue system calls.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2585
2004-08-14 18:52:27 +00:00
Tom Hughes
bbb1fad521 Rather surprisingly we weren't actually calling pre_mem_write for the buffer
argument to the read system call...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2583
2004-08-14 12:10:49 +00:00
Tom Hughes
6c5cd0dbd2 Improve handling of semctl, msgctl and shmctl so that all relevant
opcodes are properly validated. Using memcheck on ipcs now produces
no warnings on my machine.

This commit fixes bug #86987.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2580
2004-08-13 22:21:51 +00:00
Nicholas Nethercote
82c053aafc Remove some more global variables from vg_include.h, replacing them with
(fewer) functions.

Also fixed execve() so that it works better with .in_place.

Also added a regression test for --trace-children=yes (there were none!)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2577
2004-08-09 12:21:57 +00:00
Nicholas Nethercote
12a9939d3f Tweak stats printing -- use more consistent function names, improve output
formatting slightly, etc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2561
2004-08-03 18:08:50 +00:00
Nicholas Nethercote
38ff4e69d1 Comment changes only: s/skin/tool/
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2555
2004-08-03 13:29:09 +00:00
Nicholas Nethercote
7bdbf7377f Factor out differences between VG_(system) and PRE(execve). Required moving
mash_colon_env() from vg_syscalls.c to vg_mylibc.c.  Saved 20 lines of code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2554
2004-08-03 13:08:31 +00:00
Nicholas Nethercote
9a31e70a79 Cleaned up vg_include.h:
- removed various things that are no longer used
- made (module-)local some things that were global
- improved the formatting in places

Removed about 160 lines of code, and non-trivially reduced the number
of global entities.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2541
2004-08-01 22:36:40 +00:00
Tom Hughes
f10c38f7e5 Modify the ipc system call so that only those calls which may block
are treated as blocking.

This fixes bug #86000 because shmat is no longer treated as blocking
and it is therefore no longer possible for two threads to try and use
the same address for the shared memory segment.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2536
2004-07-29 22:40:07 +00:00
Tom Hughes
1afbb3fc45 Modified the fcntl system call so that only those reason codes which
can block (ie F_SETLKW) are treated as blocking.

This resolves the F_SETOWN problem described in bug #85969.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2535
2004-07-29 21:20:11 +00:00
Tom Hughes
b5f08d077f Add support for allowing the POST function for a system call to be called
even when the system call fails, and allow the PRE function to modify the
system call flags.

Also fix nanosleep so that it only marks the returned time as defined
if the system call exited with EINTR due to be interrupted.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2534
2004-07-29 17:44:23 +00:00
Tom Hughes
3a75fc74df Fix checking of execve() when argv is a null pointer.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2520
2004-07-21 16:23:38 +00:00
Nicholas Nethercote
4e6783677f apostrophe pedantry; comment change only
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2488
2004-07-16 17:32:15 +00:00
Tom Hughes
61fa07e868 Implement support for the async I/O system calls in 2.6 kernels. This
requires padding of the address space around calls to io_setup in order
to constrain the kernel's choice of address for the I/O context.

Based on patch from Scott Smith <scott-kde@gelatinous.com> with various
enhancements, this fixes bug #83060.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2485
2004-07-15 23:13:37 +00:00
Nicholas Nethercote
585a5d8244 Removed some unnecessary is_kerror() checks.
Fixed nanosleep's formatting.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2475
2004-07-10 18:08:13 +00:00
Nicholas Nethercote
977f595b53 Added assertion checking to a whole bunch of mmap() and munmap() calls. I used
assertions because if these calls fail, it's a bug in Valgrind.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2474
2004-07-10 17:49:17 +00:00
Nicholas Nethercote
159da68dd4 Format wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2472
2004-07-10 17:30:07 +00:00
Nicholas Nethercote
662b1e6029 Remove out-of-date comment.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2470
2004-07-10 17:22:27 +00:00
Nicholas Nethercote
8a556ef47c A few changes:
- removed an unnecessary VG_(unmap_range)() call in do_brk() -- the
  VG_(munmap)() just before it does it anyway.
- inlined mprotect_segment() and munmap_segment() because it's more concise and
  easier to understand that way.
- a couple of minor formatting changes
- added and cleaned up a couple of comments


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2469
2004-07-10 17:21:14 +00:00
Nicholas Nethercote
be21773f17 Removed the 'place-holder' behaviour of VG_(mmap). Previously, VG_(mmap) would
add a segment mapping to the segment skip-list, and then often the caller of
VG_(mmap) would do another one for the same segment, just to change the SF_*
flags.  Now VG_(mmap) gets passed the appropriate SF_* flags so it can do it
directly.   This results in shorter, simpler code, and less work at runtime.

Also, strengthened checking in VG_(mmap), POST(mmap), POST(mmap2) -- now if the
result is not in the right place, it aborts rather than unmapping and
continuing.  This is because if it's not in the right place, something has
gone badly wrong.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2466
2004-07-10 16:50:09 +00:00
Tom Hughes
f9a0e004f5 Implement an emulated soft limit for file descriptors in addition to
the current reserved area, which effectively acts as a hard limit. The
setrlimit system call now simply updates the emulated limits as best
as possible - the hard limit is not allowed to move at all and just
returns EPERM if you try and change it.

This should stop reductions in the soft limit causing assertions when
valgrind tries to allocate descriptors from the reserved area.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2440
2004-06-26 11:27:52 +00:00
Nicholas Nethercote
2fab200ad0 Renamed the following options:
--logfile-fd  -->  --log-fd
  --logfile     -->  --log-file
  --logsocket   -->  --log-socket

to be consistent with each other and other options (esp. --input-fd).  Also
renamed some related variables.  The old names still work, for backwards
compatibility, but they're not documented.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2429
2004-06-21 12:42:35 +00:00
Tom Hughes
827e3bebb6 Don't try and validate the contents of the environment passed to
the execve system call if the envp pointer is null as it causes
valgrind to die with a segmentation fault.

CCMAIL: 83573-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2427
2004-06-19 13:02:34 +00:00
Tom Hughes
96d29fe8ac Add support for the FIGETBSZ and FIBMAP ioctls based on a patch
from Joseph D Wagner <theman@josephdwagner.info>.

CCMAIL: 83025-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2426
2004-06-19 12:41:05 +00:00
Tom Hughes
0546e3739c Add support for the HDIO_GET_IDENTITY ioctl based on patch
from Jim McDonald <jim@mcdee.net>.

CCMAIL: 83340-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2425
2004-06-19 12:12:01 +00:00
Tom Hughes
c88651b1fc Add support for SIOCGMIIPHY, SIOCGMIIREG and SIOCSMIIREG ioctls and
improve the checking of other interface related ioctls.

Based in part on a patch from Jim McDonald <jim@mcdee.net> supplied
as a fix for bug #83344.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2424
2004-06-17 23:04:58 +00:00