Commit Graph

162 Commits

Author SHA1 Message Date
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
Nicholas Nethercote
a2b3609df7 Small step in factoring out arch-specific code: replace
__attribute((regparm(n))) with REGPARM(n) everywhere.  REGPARM() is defined in
vg_skin.h, but will eventually be defined separately for each arch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2601
2004-08-23 15:06:23 +00:00
Tom Hughes
57d86ee4de More fixes for the cancellation wrappers in libpthread - if looking
for the original function with RTLD_NEXT doesn't work then try looking
for the __libc_ version of the function the RTLD_DEFAULT instead.

The reason for this is that, contrary to the dlsym documentation, it
seems that RTLD_NEXT doesn't always seem to find the definition that
would have been used if it weren't for the override. This is particularly
common wihen libpthread is pulled in implicitly by a dependency from
another library.

This should hopefully fix bug #85658.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2595
2004-08-22 22:56:25 +00:00
Tom Hughes
42c7adce45 Maek init_global_thread_specific_state as a constructor to try and ensure
that it is called as soon as libpthread.so is loaded even if pthread_create
is never called.

This ensures that pthread_exit will work correctly, and I think will also
cure the famous memory leak in the pthread specifics for the main thread.

CCMAIL: 86730-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2584
2004-08-14 15:37:59 +00:00
Tom Hughes
5392f371af Make sure init_global_thread_specific_state() set the global_init_done
flag before the call to __uselocale() in order to avoid deadlock.

CCMAIL: 77952-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2493
2004-07-17 11:08:03 +00:00
Tom Hughes
0142b68d33 Removed duplicate call to rw_remap.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2445
2004-06-27 13:26:44 +00:00
Tom Hughes
03df333128 Commit the patch from bug 69508 that seeks to make more of the pthread
stack attribute related functions work properly as it seems to be a
sensible thing to improve even if it isn't enough to get the JVM running
under valgrind now.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2444
2004-06-27 12:48:53 +00:00
Tom Hughes
f267e2c7d0 Fixed the NPTL cleanup handler support to try and make sure it will
compile on systems with NPTL header files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2406
2004-06-12 17:25:25 +00:00
Tom Hughes
83780627b5 It appears that NPTL uses a new system for dealing with cleanup
handlers when a thread is cancelled which has the side effect that
programs linked with librt fail on Fedora Core 2 due to librt having
been built against the NPTL header instead of the old pthread headers.

This change extends valgrind's libpthread.so to handle both the old
and new style cleanup handlers in a similar way to NPTL and seems to
be sufficient to get programs linked with librt working again.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2405
2004-06-12 12:58:22 +00:00
Tom Hughes
0bbe5bb70d There is no __accept in any libc or libpthread that I can find so
it isn't clear why we were intercepting that and only aliasing accept
to it. Switched to intercepting accept directly instead.

CCMAIL: 76869-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2404
2004-06-04 21:42:18 +00:00
Tom Hughes
95776fd744 Changed cancellation wrappers to use dlsym(RTLD_NEXT) to look up the
libc version of the wrapped function when forwarding the call rather
than trying to call the internal __libc_xxx version of the routine
as many of those are marked as GLIBC_PRIVATE in recent releases.

CCMAIL: 82026-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2402
2004-06-03 18:00:58 +00:00
Nicholas Nethercote
f7c264da4c Remove "pre-history" handling for mutexes -- now that Valgrind has full control
from the very beginning (thanks to FV) it's no longer necessary.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2356
2004-04-10 00:54:42 +00:00
Tom Hughes
b769d6df88 Implement tcdrain in the pthread library. The fact that this function
is missing was reported in bug #70344 but the reporter then closed the
bug saying that they were using the wrong version of valgrind.

Patch from Henrik Algestam <algestam@home.se>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2346
2004-03-31 15:23:13 +00:00
Tom Hughes
67bb2b010d Commit rewrite of semaphore handling to avoid having a fixed upper
limit. Patch courtesy of Aleksander Salwa <A.Salwa@osmosys.tv>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2336
2004-03-23 19:48:54 +00:00
Jeremy Fitzhardinge
d402c5408c When creating new threads, initially block all signals. It's up to the
client code (in vg_libpthread.c) to set the appropriate signal mask when
its ready.  This prevents a bug where a thread gets sent a signal before
even running any of its initialization code, which can cause problems
(particularly if the signal handler directly or indirectly uses TLS).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2332
2004-03-16 22:09:12 +00:00
Tom Hughes
ec672c606d Remove function which is no longer used following the changes to
the handling of libc thread specific data.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2297
2004-03-08 15:57:17 +00:00
Tom Hughes
2494bba71b Fix the handling of libc thread specific data so that it doesn't rely on
being able to use malloc as the libc malloc tries to use thread specific
data and we wind up in a recursive nightmare.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2293
2004-03-07 19:36:14 +00:00
Nicholas Nethercote
9f16738ca3 Some newer systems have a new version of pthreadtypes.h that comes from glibc
2.3.3, which is binary-compatible, but not source compatible with the old one,
which came from LinuxThreads.  We were using the types defined in the old one,
which caused compilation errors on systems using the new one.

This commit introduces our own versions of these types.  Our versions are laid
out identically to the LinuxThreads ones, but the field names are different.
We convert all pthread types to our versions before using them, so we don't
rely on the pthreadtypes.h types any more.  Hopefully this will fix the
problem;  I have three reports that it does.  Let's see...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2272
2004-02-28 15:40:36 +00:00
Jeremy Fitzhardinge
75d6dc8434 This change implements the TLS extension to the x86 ABI. This allows
threads to have thread-private data which is quickly accessible via a
segment in the GDT, stored in %gs.  The patch implements the relevent
syscalls (setthreadarea), and also manages switching the VCPU's segment
information at thread context-switch time.  Mostly Tom Hughes' work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2215
2004-01-21 01:27:27 +00:00
Nicholas Nethercote
07b8e3438b Updated copyright dates for 2004. Also added a couple of missing headers and
footers to some new files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2177
2004-01-04 16:43:23 +00:00
Julian Seward
6bbfc962d3 (David Lee, <david.lee@teracruz.com>)
This patch fixes a semaphore leak within valgrind. If your application
dynamically allocates/releases semaphores, you will very quickly run out.
Also, as a nice side effect, it implements sem_destroy properly.

(me)
Protect sem_getvalue with a lock/unlock of the semaphore's mutex,
like the other routines do.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2153
2004-01-02 11:39:06 +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
Nicholas Nethercote
d6d804d382 Updated all "report bugs to..." messages to point to valgrind.kde.org; also
updated the docs to refer to valgrind.kde.org instead of the old website.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2055
2003-11-20 16:20:55 +00:00
Nicholas Nethercote
b6e961b0bf Improved vg_libpthread's IGNORED/KLUDGED error messages; lots of people found
"kludged" confusing.  Even printing out brief explanations of why functions are
ignored/kludged, in some cases.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2054
2003-11-20 14:23:09 +00:00
Nicholas Nethercote
c4d186f121 Removed no-longer-needed declarations of __SOME_SKIN_H.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2025
2003-11-13 23:02:16 +00:00
Dirk Mueller
25a97a8692 fix build with kernel 2.6.x
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1941
2003-10-16 16:14:13 +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
f5ba3bad17 Added a couple of small #ifdefs so that Valgrind works with Erik Anderson's
uClibc (micro libc, a small alternative to glibc).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1908
2003-10-12 17:26:04 +00:00
Julian Seward
b820f69079 Delete some "inline" directives on functions that gcc-3.3.1 declined
to inline.  This is needed to get a warning-free compilation on 3.3.1.
It seems we had "inline" on some pretty huge functions in places.
Also it appears gcc-3.3.1 won't inline a function call in a tail call
position, reasonably enough.  I assume in that case it prefers to
create a tailcall to the callee, rather than inlining it.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1907
2003-10-12 10:27:06 +00:00
Julian Seward
b3e4bdb2a5 Implement pthread_spinlock_* (Tim Potter, tpot@samba.org)
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1902
2003-10-12 08:33:30 +00:00
Nicholas Nethercote
c8c6b4132e Fix minor cut+paste error.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1856
2003-09-29 12:58:37 +00:00
Dirk Mueller
612b8daeac fix compiler warnings
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1823
2003-09-18 01:39:50 +00:00
Julian Seward
9ee2fd8e43 A new implementation of pthread_once() which I believe should comply
properly with POSIX, and not get assertion failures when the same
thread makes nested calls to pthread_once with different once_control
pointers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1746
2003-07-11 00:12:58 +00:00
Julian Seward
090be413d9 Fix up weak binding for pthread_mutexattr_setpshared.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1726
2003-07-06 01:29:49 +00:00
Julian Seward
cceee45f87 Implement pthread_mutexattr_setpshared (Nick did this).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1724
2003-07-06 01:23:11 +00:00
Dirk Mueller
2416fb6967 don't bail out when pthread_once's init route calls itself recursively
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1684
2003-06-13 12:24:41 +00:00
Julian Seward
ecee893b06 Improve threaded handling of errno:
- Change various incorrect direct references to errno into
  *(__errno_location()).

- In __errno_location and __h_errno_location, treat the tid==1 case
  (root thread) specially, as with __res_state().

This seems to fix a bug in threaded handling of errno on R H 9 and SuSE8.2,
and almost makes OpenOffice work again on R H 9.

MERGE TO STABLE, if it doesn't break anything.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1625
2003-05-09 23:40:34 +00:00
Julian Seward
e455ba148d Fix interception of pthread_atfork with glibc-2.3.2.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1587
2003-05-04 12:35:54 +00:00
Nicholas Nethercote
90ef0ac1d6 Moved the CLIENT_tstCALL[0123] requests out of valgrind.h into vg_skin.h,
because there was no point exposing them to clients, as they don't know the
ThreadState type.

Also, removed the LOGMESSAGE request type, replaced it with calls to
VG_(message) via the generic VALGRIND_NON_SIMD_CALL2.

In fact, almost every single pthread client request could be removed in this
same way.  That would result in less code, which would be nice... yeah, real
nice.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1584
2003-05-02 17:53:54 +00:00
Julian Seward
76ffe12471 Add possibly-bogus implementations for __libc_current_sigrtmin,
__libc_current_sigrtmax and __libc_allocate_rtsig.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1561
2003-04-26 21:19:53 +00:00
Julian Seward
4efd705c4b Fix threading problems on glibc-2.3.2 or later. Note this is *not*
NPTL support.

The behaviour of weak vs strong symbols seems to have changed in
glibc-2.3.2.  This caused problems in coregrind/vg_intercept.c,
wherein strong symbols in vg_libpthread.c were intended to
override weak symbols in vg_intercept.c, in order to give alternative
thread-safe implementations of some functions, poll(), select(), etc.

The change involves moving the nonblocking implementations of poll, etc
into vg_intercept.c, renaming them to (eg)  VGR_(poll), and routing
all calls to poll to VGR_(poll) [dually for other such fns].  This
means even single-threaded programs now use these functions, but
that doesn't strike me as harmful.

MERGE TO STABLE, if it doesn't break anything


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1559
2003-04-26 20:11:15 +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
f340c1b180 Duh. Make the system buildable again following recent commit
of include/valgrind.h rev 1.10.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1459
2003-03-15 20:03:33 +00:00
Julian Seward
096df69efa Fix comment bug.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1429
2003-02-23 03:40:03 +00:00
Julian Seward
4a70193610 Make poll() return (errno==EINTR) if the poll is interrupted by a signal.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1428
2003-02-23 03:37:58 +00:00
Julian Seward
1ae9a3b631 Apply the following:
The veneers for msgrcv in vg_intercept.c and vg_libpthread.c are not
returning the number of bytes read correctly - they always return zero
for any non-error case, which causes programs using msgrcv to behave
somewhat non-optimally when running under valgrind ;-)

Attached is a patch against 1.9.3 which fixes this.

Tom

--
Tom Hughes (thh@cyberscience.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1424
2003-02-23 03:00:29 +00:00
Julian Seward
18722f68c7 Implement pthread_getconcurrency, in the same way as LinuxThreads does it.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1393
2002-12-26 12:16:11 +00:00
Julian Seward
1c1de878a1 Implement (nop, but that's OK according to POSIX) pthread_set_concurrency.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1355
2002-12-08 23:51:32 +00:00
Julian Seward
a3feec4235 Implement (as a nop) pthread_rwlockattr_destroy.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1354
2002-12-08 23:42:17 +00:00
Julian Seward
9545356102 Merge patch (bug fix) from Jeremy F:
59-fix-readv-writev

Fix error returns for readv and writev (and select).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1342
2002-12-01 10:25:53 +00:00