Raise RLIMIT_AS to max allowable, so that we can create the large mappings
we need to. If the hard limit is set to low, then things will fail as
large mmaps fail.
Tom Hughes [Sun, 7 Mar 2004 19:36:14 +0000 (19:36 +0000)]
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.
Fix assertion failure when using VG_(system) near program termination.
The problem is that the use of VG_(system) causes a SIGCHLD to be sent
to the process, which ends up being delivered to one of the proxy LWPs
(which is a small problem in itself, but nothing too bad).
The proxy tells the scheduler LWP about this, and the scheduler LWP sends
a sigACK reply.
Then, while the proxy LWP is in the SigACK state, and the SigACK reply
is still queued in the message pipe, the scheduler LWP starts shutting
Valgrind down, and sends a SIGVGKILL to all proxy LWPs. This causes
the proxy to drop from sigACK state to WaitReq state, and it reads
further commands - one of which is the SigACK message - this causes the
assertion failure.
The fix is to simply make the proxy LWP exit immediately when it gets
a SIGVGKILL, and not process any more requests.
This change also fixes a bug in VG_(system), in which the child process
returns back into Valgrind rather than exiting when exec fails.
Tom Hughes [Sun, 29 Feb 2004 12:02:32 +0000 (12:02 +0000)]
Changed the fdleak tests to explicitly attach /dev/null as the standard
input so that the output is well known regardless of whether the test is
run from a terminal or from cron.
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...
Check new fds are not within Valgrind's reserved range. Still one case for
recvmsg() where I'm not sure if it should be checked, and if so, what error
should be returned if the check fails.
This fixes bug 75614. It seems that a symbol can be named
"foo<bar::blat>"; normally stabs names are terminated by ':', but we
also need to keep track of <> pairs so we can ignore nested colons.
Fix the use of brk. This change removes the requirement for the "real" brk
segment to be moved up to stage2's brk segment. Instead, Valgrind's
use of brk is simulated with mmap. In order to prevent any unwanted use
of the process brk segment, it also sets the RLIMIT_DATA to 0, which will
make brk always fail. glibc's malloc will use mmap to allocate if brk
fails. We try to intercept glibc's brk, but malloc seems to always use the
library-internal version. (The client's use of brk has always been simulated,
and is unaffected by this change.)
This patch fixes getrlimit(RLIMIT_FILENO) to return VG_(max_fd) as the soft
limit for file descriptors to try and prevent the target programming realising
that the reserved file descriptors exist. It also appears to fix
sysconf(_SC_OPEN_MAX) so that must be going through the same system call.
Fix for bug 73326. It seems that gcc 3.2.2 is generating negatively-sized
scopes and out of order line number information in the stabs debug info.
I wonder if this is the stabs writer rotting now that dwarf is the
default...
Doesn't fix "make distcheck", however, because this happens:
/usr/bin/ld: cannot open linker script file ../../coregrind/x86/stage2.lds:
No such file or directory
For some reason I can't work out, that file is built when you make in a CVS
tree, or manually from a "make dist" tarball, but not when you "make
distcheck".
Rearrange CPUID again. Moved most of the helper logic into C, since
the assember was getting fiddly. It now masks out only the undefined
or unimplemented parts of the feature set bits, so it now passes through
all the non-ISA-related feature bits to clients.
It also leaves the vendor ID string unmolested, so that clients can
extract vendor-specific information like extended brand strings and
cache/TLB configuration info.
It does, however, implement some Valgrind-specific requests at 0xd8000000,
though at present the only functionality is the ValgrindVCPU signature.
Patch to provide a proper environment to the debugger
Although this patch isn't strictly needed to allow alternative debuggers to
be used, it is needed if you want to use an X based debugger such as ups
(and presumably ddd) as VG_(system) has until now passed an empty
enviroment when starting the debugger but that causes DISPLAY to be lost.
This patch causes VG_(system) to pass a copy of the client environment
instead, with the necessary mashing done to clean up the LD_xxx variables.
Patch to allow debuggers other than GDB to be used
The patch replaces --gdb-attach and --gdb-path with --db-attach and
--db-command which are more general. The --db-command switch takes a
command string that can contain one or more instances of %p and %f markers.
The %p marker is replaced with the PID of the process to attach to and the
%f marker with the filename of the executable being attached to.
The default command is "gdb -nw %f %p" which gaves the same result as
currently.
Don't use TSC for internal timing purposes. This is for two reasons:
- old CPUs (and their modern embedded clones) don't implement the TSC
- new machines with power management, the TSC changes rate, and so is
useless as a timebase
Valgrind doesn't use read_millisecond_timer very much these days, so
the expense of doing a gettimeofday syscall shouldn't be a huge issue.
Naturally, rdtsc is still available for client purposes (if the host CPU
supports it).
Virtualize CPUID. Rather than just using the host CPU's CPUID,
we now completely virtualize it. The feature flags returned are the
intersection of the set the CPU supports, and the set of flags Valgrind
supports. This turns out to be a small number of features, like FPU,
TSC, MMX, SSE, SSE2, FXSR. All mention of things which are only useful
to kernel-mode code are also suppressed. This CPUID doesn't support
any extended feature flags, or extended CPUID operations. It returns a
vendor string of "ValgrindVCPU".
If the host CPU doesn't support CPUID, then we make sure we treat it as
an illegal instruction (I'm not sure if we handle the eflags bit toggle
test right). This is because the CPUID helper doesn't actually use the
cpuid instruction in all cases, so it may succeed where the host CPU
wouldn't (other instructions which depend on feature flags will end up
generating those instructions, so they'll endup generating a SIGILL if
client code uses them on a CPU which doesn't support them).
Moved stage2.c into vg_main.c. Merged main() and VG_(main)(); VG_(main)()
no longer exists. One advantage of this is that global
variables/structures needed for communicating between the two can be made
local. Also, the order in which things happen has been simplified.
This is mostly just a big refactoring. Startup is now a fair bit easier to
understand. Dependencies between the various startup stages are fairly well
documented in comments. Also, --help and --version now work properly --
eg. --help gives tool-specific help if --tool was specified. There is still
some parts where things could be reordered and/or simplified, and where the
dependencies aren't clear. These are marked with 'XXX'.
One new feature was added: ability to read options from ~/.valgrindrc and
./.valgrindrc. Part of this is support for specifying tool-specific options
in the form --toolname:tool-specific-option.
Fix bug 73219. This adds a general mechanism for querying the host CPU's
capabilities, and uses it to see if it has SSE/SSE2/fxsave support before
trying to use fxsave at startup.
Fix a bug in Cachegrind: when invalidating BBs, the lookup in the BBCC_table
sometimes failed, causing an assertion failure. This is because the debug
info for the code address, which is used in the lookup,
can change -- eg. "myprint.c:myprint()" is found at instrumentation, but by the
time the invalidation occurs, it's changed to "myprint.c:???". So it now falls
back to a slow exhaustive search of the table.
This was causing cachegrind/tests/dlclose to fail, and should hopefully fix
bug #72781.
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.
This patch should implement most of the missing SSE/SSE2 opcodes. About
the only ones it doesn't do are the MASKMOVxxx ones as they are quite
horrible and involved an implicit reference to EDI so I need to think
about them a bit more.
The patch also includes a set of tests for the MMX/SSE/SSE2 opcodes to
validate that they have the same effect under valgrind as they do when
run normally. In one or two cases this wasn't actually the case even
for some of the implemented opcodes, so I fixed those as well ;-)