Commit Graph

67 Commits

Author SHA1 Message Date
Jeremy Fitzhardinge
1f4c6deede Auto-generate stage2.lds so that the linker script matches the local
linker.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2122
2003-12-16 22:26:45 +00:00
Jeremy Fitzhardinge
918c3a7b7e This jumbo-checkin is the Full Virtualization checkin. This eliminates
Valgrind's dependency on the dynamic linker for getting started, and
instead takes things into its own hands.

This checkin doesn't add much in the way of new functionality, but it
is the basis for all future work on Valgrind.  It allows us much more
flexibility in implementation, and well as increasing the reliability
of Valgrind by protecting it more from its clients.

This patch requires some changes to tools to update them to the changes
in the tool API, but they are straightforward.  See the posting "Heads
up: Full Virtualization" on valgrind-developers for a more complete
description of this change and its effects on you.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2118
2003-12-16 02:05:15 +00:00
Jeremy Fitzhardinge
6d535b779d Change the --track-fds code to use VG_AR_CORE rather than
VG_(malloc)/(strdup), which puts things into VG_AR_SKIN.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2117
2003-12-16 01:48:38 +00:00
Jeremy Fitzhardinge
144c2fa42c Fix bug 69836: make record_fd_open ignore fds > VG_MAX_FD.
CCMAIL: 69836-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2103
2003-12-12 07:46:54 +00:00
Julian Seward
1bee40d28b Reword warning message emitted by fd_allowed() to make it a little clearer.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2102
2003-12-12 06:40:05 +00:00
Dirk Mueller
9f9343605d in C, casting of lvalues is illegal.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2099
2003-12-07 23:36:14 +00:00
Nicholas Nethercote
fed872284b Tools using shadow memory can't handle the first 64KB being mapped, because
they rely on this area being unmapped for their quick sanity check.  This
commit make Valgrind refuse to mmap() this area.  Added a regtest for it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2085
2003-12-02 14:56:04 +00:00
Nicholas Nethercote
3ddb89814c Backing out bogus support for gettid() I added yesterday.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2081
2003-12-02 09:35:33 +00:00
Nicholas Nethercote
c0e09ae11c Add gettid() syscall.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2078
2003-12-01 14:00:11 +00:00
Dirk Mueller
2c314c8a97 this should fix compilation on weird kernel 2.6.x installations.
CCMAIL: 68360@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2052
2003-11-19 22:07:14 +00:00
Dirk Mueller
69fa3515ae make use of statfs64 and make code blocks adjacent
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2042
2003-11-19 08:56:44 +00:00
Dirk Mueller
c3d9874e22 implement statfs64, utimes and clock_gettime
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2034
2003-11-19 00:43:57 +00:00
Robert Walsh
f9ea43d896 Add a facility for tracking open file descriptors. Information about
still open files is dumped out exit.  Enabled using the --track-fds
switch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2031
2003-11-17 17:45:00 +00:00
Jeremy Fitzhardinge
f15fa06f97 Fix some (bone-headed) loose ends left by my last checkin. "make regtest"
actually works this time.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2018
2003-11-10 21:21:00 +00:00
Jeremy Fitzhardinge
64b0808872 Only set the thread's status to WaitSys if we're actually waiting for
a proxyLWP to complete a syscall.

Update sigaltstack test to use mmap to allocate the stack.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2016
2003-11-09 09:51:33 +00:00
Jeremy Fitzhardinge
4eac75bf3e Fix some bugs in syscall/signal handling:
If the proxyLWP for a thread got a signal just as we were sending the
syscall request to it, then we would end up running the syscall twice.
The fix is to not check the results pipe while sending the syscall request
- wait until we're in a better state for handling signals (the deadlock
the results-read was supposed to avoid cannot actually happen).

Related to that, if we're delivering a signal to a thread, and that thread
is currently waiting for a syscall to complete, make sure we collect the
syscall results before entering the signal handler (otherwise we may end
up bogusly trying to restart the syscall by moving EIP back, even though
it now points to the signal handler rather than the syscall instruction)

This change also adds an assertion to VG_(restart_syscall) to make sure
we were actually restarting a syscall and not just randomly changing EIP
(this found the problem above).

Also, make set/getitimer run in the proxyLWP context, so that they
modify/read the proxyLWP's timers rather than the schedluer LWP's timers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2013
2003-11-07 23:09:48 +00:00
Nicholas Nethercote
ddc388cfd7 Add missing printf and pre_mem_read to rt_sigtimedwait(), thanks to Thomas
Lussnig <lussnig@smcc.net>.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1978
2003-11-01 14:03:37 +00:00
Jeremy Fitzhardinge
01c5d4fe3e Update some stuff related to the syscalls change:
- restart syscalls which return ERESETARTSYS
 - make code to restart a syscall common
 - keep a process-wide pending signal set to store as-yet
   undelivered signals (only used in 2.4 mode; TODO: siginfo, queues)
 - make execve work a bit better - it is impossible to recover from
   execve failing, so we try to check that it will before running the
   syscall itself (also fixes bug with SuSE 8.2 kernel)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1964
2003-10-30 07:21:44 +00:00
Jeremy Fitzhardinge
4e77d30c2d Return an error rather than panicing when given a bad socketcall
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1957
2003-10-19 16:46:06 +00:00
Jeremy Fitzhardinge
1e6361234c A complete reworking of Valgrind's handling of system calls and signals,
with the aim of making it more robust, more correct and perhaps faster.

This patch removes the need to poll blocking syscalls, by adding a proxy
LWP for each application thread.  This LWP is a kernel thread whose job
is to run all (potentially) blocking syscalls, and also to handle signals.

This allows the kernel to do more of the work of dealing with signals,
so on kernels which do this properly (2.6), Valgrind's behavious is a
lot more posix compliant.  On base 2.4 kernels, we emulate some of the
missing 2.6 functionality.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1918
2003-10-13 22:26:55 +00:00
Nicholas Nethercote
6436799e7d Fix a couple of bugs in the sigalstack wrapper (Nb: found when I was
(apparently) self-hosting :)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1835
2003-09-26 09:06:41 +00:00
Nicholas Nethercote
ce82c07580 Cleaned up reading of debug info a bit.
Renamed:
  VG_(read_procselfmaps_contents)() --> VG_(read_procselfmaps)()
  VG_(read_procselfmaps)()          --> VG_(parse_procselfmaps)()
  VG_(read_symbols)()               --> VG_(read_all_symbols)()
  VG_(read_symtab_callback)()       --> VG_(read_seg_symbols)()

Removed the Bool 'read_from_file' arg from (what is now)
VG_(parse_procselfmaps)().  If /proc/self/maps needs to be read beforehand, the
code calls (what is now) VG_(read_procselfmaps)() before.  Still using the
static buffer which is not nice but good enough.

More importantly, I split up VG_(new_exe_segment)() into
VG_(new_exeseg_startup)() and VG_(new_exeseg_mmap)().  This is because at
startup, we were stupidly calling VG_(read_symbols)() for every exe seg, which
parses /proc/self/maps completely in order to load the debug info/symbols for
the exe seg (and any others we haven't already got the symbols for).  Despite
the fact that the startup code reads /proc/self/maps to know which segments are
there at startup.  In other words, we were reading /proc/self/maps several
times more often than necessary, and there were nested reads, which Stephan
Kulow's recent depth patch fixed (but in a pretty hacky way;  this commit fixes
it properly).  So VG_(new_exeseg_startup)() now doesn't cause /proc/self/maps
to be re-read.  Unfortunately we do have to re-read /proc/self/maps for mmap(),
because we don't know the filename from the mmap() call (only the file
descriptor, which isn't enough).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1830
2003-09-25 17:54:11 +00:00
Nicholas Nethercote
0c7c912c5b Fix problem with adjtimex.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1817
2003-09-09 11:27:59 +00:00
Dirk Mueller
be5cd9c8c1 patch for adjtimex syscall by Bob Van Manen <BVanManen@Scene7.com>
appares to compile for me


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1813
2003-09-05 17:46:54 +00:00
Nicholas Nethercote
138ada5bc2 Fixed readv() and writev() so they won't fall over if they are given a negative
count.  Added a regression test for it.

Updated the basic test stderr filter to strip out line numbers from
vg_intercept.c

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1812
2003-09-04 21:57:45 +00:00
Nicholas Nethercote
7b2a49544e Fixed brk(); it was almost completely broken.
Added a regression test for it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1810
2003-09-04 20:57:51 +00:00
Dirk Mueller
4d7ce5006f implement waitpid syscall. Patch by Benjamin Lee <benjaminlee@users.sf.net>
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1806
2003-08-26 17:36:26 +00:00
Nicholas Nethercote
d4192ee3b2 comments change only
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1799
2003-08-14 15:23:55 +00:00
Nicholas Nethercote
0f871c249c A big commit size-wise, but small concept-wise: removed the ThreadState type
from skin's view, replacing all instances with ThreadId.  Much cleaner.  Had to
change the way VG_(get_ExeContext)() worked a little.  Changed the core/skin
major interface because this breaks the old version.  Also fixed a few minor
related things here and there.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1782
2003-07-24 08:45:32 +00:00
Dirk Mueller
faf02201e5 spelling fixes
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1715
2003-07-04 16:18:15 +00:00
Nicholas Nethercote
c10bae9afe comment only
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1708
2003-06-26 14:57:01 +00:00
Nicholas Nethercote
bf7cd19215 several wibbles: added some missing types in function protos, some missing
comments, etc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1685
2003-06-13 15:02:29 +00:00
Nicholas Nethercote
b973d9e383 Added SIOCOUTQ ioctl, thanks to Lennert Buytenhek <buytenh@gnu.org>.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1681
2003-06-12 14:27:58 +00:00
Nicholas Nethercote
03527720dc Added two syscalls: sendfile64 and rt_sigtimedwait. Had to #include
signal.h in vg_unsafe.h for the latter.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1667
2003-06-03 12:55:40 +00:00
Nicholas Nethercote
136a5e69d5 This commit fixes up the handling of shadow registers quite a bit.
Removed the SK_(written_shadow_regs_values)() function.  Instead, skins that
use shadow regs can track the `post_regs_write_init' event, and set the shadow
regs from within it.  This is much more flexible, since it allows each shadow
register to be set to a separate value if necessary.  It also matches the new
shadow-reg-change events described below.

In the core, there were some places where the shadow regs were changed, and
skins had no way of knowing about it, which was a problem for some skins.
So I added a bunch of new events to notify skins about these:

  post_reg_write_syscall_return
  post_reg_write_deliver_signal
  post_reg_write_pthread_return
  post_reg_write_clientreq_return
  post_reg_write_clientcall_return

Any skin that uses shadow regs should almost certainly track these events.  The
post_reg_write_clientcall_return allows a skin to tailor the shadow reg of the
return value of a CLIENTCALL'd function appropriately;  this is especially
useful when replacing malloc() et al.

Defined some macros that should be used *whenever the core changes the value of
a shadow register* :

  SET_SYSCALL_RETVAL
  SET_SIGNAL_EDX          (maybe should be SET_SIGNAL_RETVAL? ... not sure)
  SET_SIGNAL_ESP
  SET_CLREQ_RETVAL
  SET_CLCALL_RETVAL
  SET_PTHREQ_ESP
  SET_PTHREQ_RETVAL

These replace all the old SET_EAX and SET_EDX macros, and are added in a few
places where the shadow-reg update was missing.

Added shadow registers to the machine state saved/restored when signal handlers
are pushed/popped (they were missing).

Added skin-callable functions VG_(set_return_from_syscall_shadow)() and
VG_(get_exit_status_shadow)() which are useful and abstract away from which
registers the results are in.

Also, poll() changes %ebx (it's first argument) sometimes, I don't know why.
So we notify skins about that too (with the `post_reg_write_syscall_return'
event, which isn't ideal I guess...)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1642
2003-05-19 15:04:06 +00:00
Julian Seward
07258f73de gcc-3.3 as supplied with SuSE 8.2 ("gcc version 3.3 20030226
(prerelease) (SuSE Linux)") seems to complain about signed-vs-unsigned
comparisons, when -Wall is on.  This commit fixes (most of) those
complaints.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1638
2003-05-18 10:05:38 +00:00
Nicholas Nethercote
8c12eaeb63 Minor fix for lookup_dcookie
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1580
2003-05-02 16:18:06 +00:00
Nicholas Nethercote
694c3ee614 Fixed some syscalls a little bit:
- getcwd() now uses the result for the post_mem_write length rather than
   the argument, which would have over-estimated

 - accept(), recvfrom() and getsockopt() can now all take NULL buffers (which
   are quite legitimate) without Memcheck giving spurious errors

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1579
2003-05-02 16:00:34 +00:00
Julian Seward
284654f749 Add __NR_prctl.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1569
2003-04-26 22:55:12 +00:00
Julian Seward
a6194ccaea Add __NR_lookup_dcookie, whatever that might be.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1563
2003-04-26 21:46:16 +00:00
Nicholas Nethercote
4f1b2c3adc Added syscall creat(), courtesy of Tom Hughes <thh@cyberscience.com>.
Weird that it's never come up before, everyone must use open() in preference.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1555
2003-04-24 18:14:11 +00:00
Nicholas Nethercote
ac7027c441 Updated copyright notices for 2003. Only 4 months late.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1526
2003-04-15 14:58:06 +00:00
Julian Seward
f400903bd3 Support __NR_munlockall (syscall 151).
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1504
2003-04-03 22:35:01 +00:00
Julian Seward
575a8896ec o I fixed a small bug: the code in coregrind/vg_syscalls.c seems
to assume that all sockaddrs are non-NULL and non-zero in
     length.  This isn't always true, and when I ran a program that
     used a NULL sockaddr through Valgrind it segfaulted.  I believe
     that the change that I made fixes this bug in general, but I
     might be overlooking something.

From kclark@CetaceanNetworks.com (Kevin D. Clark)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1440
2003-02-24 21:55:34 +00:00
Julian Seward
9065d62ecc Hopefully deal with system 252 (__NR_exit_group) correctly.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1427
2003-02-23 03:26:08 +00:00
Nicholas Nethercote
3e0ad40f18 Changed comments only: added a couple of missing syscall numbers.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1421
2003-02-19 11:39:02 +00:00
Nicholas Nethercote
a3862bfb1b Ugh, fixed it properly this time.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1417
2003-02-05 22:08:58 +00:00
Nicholas Nethercote
6d6d33c360 Fixed comment typo.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1416
2003-02-05 22:06:48 +00:00
Julian Seward
1efa0352a6 Add syscall 185 (__NR_capset). From Gerald Carter <jerry@samba.org>.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1403
2003-01-05 12:35:19 +00:00
Julian Seward
3a71cb3483 Only complain three times about unhandled ioctls, then shut up. Stops
it complaining endlessly when running kscd.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1402
2003-01-05 12:19:35 +00:00