1. Make the output deterministic; different thread interleaving from expected
was causing failures for me.
2. Make it actually use the condition variable -- the condvar stupidly wasn't
actually being used in the expected case, because the other threads finished
all their work before pthread_cond_wait() even got called, and this prevented
the condition guarding pthread_cond_wait() from succeeding.
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:
Arch-abstraction:
- Started overhauling the syscalls to account for different architectures;
in particular, accounts for the fact that the __NR_foo syscall number
often doesn't directly match with the sys_foo() function that implements the
function in the Linux kernel. So started introducing this indirection as
needed. Currently, only read() and write() have been done; the transition
will be staged, since doing all syscalls in one hit is a total pain.
This will also pave the way for scalar syscall arg checking with Memcheck,
now that it is clear what the prototypes of the relevant syscalls are.
- Removed support for 2.2 kernels in the configure test, after discussion with
Julian. If it causes major problems, we can consider reverting.
Julian Seward [Mon, 8 Nov 2004 13:14:06 +0000 (13:14 +0000)]
x86 guest: majorly rehash eflags thunk scheme for a second time. See
detailed comment in priv/guest-x86/gdefs.h. In short we move to a
4-word thunk so as to be able to present Memcheck with the data
dependencies we want, and at the same time allow iropt to easily
optimise away most of the helper calls that evaluate the thunk.
Hopefully this is the last change.
Comment in priv/guest-x86/gdefs.h also explains properly the
relationship between the thunk arrangements and how we expect Memcheck
to behave with respect to definedness of flags.
Julian Seward [Sun, 7 Nov 2004 18:46:22 +0000 (18:46 +0000)]
Memcheck: add helper functions to support 64-bit loads/stores. This
stuff all needs serious rethinking to make it work on 64-bit platforms
and on big-endian platforms.
Julian Seward [Sun, 7 Nov 2004 00:57:46 +0000 (00:57 +0000)]
Install a bogus-literals hack a la old UCode scheme, but do not use
it. Instead, observe that all of the residual errors are from
stpcpy/strnlen in glibc. Then observe that the redirect mechanism
seems to fail to redirect these to our "safe" equivalents. Then,
finally realise that the redirect mechanism is defeated by vex's
cross-BB-chasing and specifically by chasing across function call
boundaries.
So, the good news is that giving --vex-guest-chase-thresh=0 makes all
these errors go away. This should be straightforward to fix properly.
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
Julian Seward [Sat, 6 Nov 2004 12:27:15 +0000 (12:27 +0000)]
More fiddling in an attempt to make it work properly (so far
unsuccessful):
* in clean helper calls, take notice of exclusion-mask (mcx_mask)
specifying which args to ignore. Seems to have no effect.
* Add Paul-Mackerras-style expensive-add. Seems to have no effect.
* When doing a shadow PUT, do not complain if uninitialised data
is written to guest state areas which are marked in the layout info
as 'always defined'. This seems to help reduce the false positive
rate, because (in guest x86) the CC_AUX field of the flags thunk
is sometimes given an undefined value (old C flag) when setting
the thunk after inc/dec. Since we assume that no compiler would
examine the C flag after inc/dec unless it knew the C flag before it
was defined (inc/dec do not change C), this is assumed to be safe.
Julian Seward [Sat, 6 Nov 2004 12:17:57 +0000 (12:17 +0000)]
IRCallee: add a mcx_mask field, through which front ends can pass
hints to Memcheck about which arguments in a helper call should be
ignored when it comes to computing lazy approximations of definedness
through that function. Not sure if this mechanism needs to remain,
but for the time being ...
Julian Seward [Sat, 6 Nov 2004 12:14:43 +0000 (12:14 +0000)]
Further integration of baseblock stuff for shadow state. Get rid of
tons of now-irrelevant baseblock fields and offsets. The layout
defined in coregrind/x86/state.c is now more or less (completely?)
target-independent: vex-defined guest state, vex-defined shadow guest
state, and vex-specified spill area.
Julian Seward [Fri, 5 Nov 2004 19:49:09 +0000 (19:49 +0000)]
Major overhaul of x86 guest eflags handling, so as to make one
specific word of the thunk (CC_RES) have all data dependencies on
result of the flag setting operation. The delayed-flag mechanism is
thusly modified so as to prevent Memcheck from giving false positives.
Julian Seward [Wed, 3 Nov 2004 15:24:42 +0000 (15:24 +0000)]
Make the x86 back end capable of generating conditional calls.
NOTE, the argument marshalling for regparm'd calls is observed to
be wrong. Arguments are computed directly into the real registers,
thus trashing themselves if a regparm-call should be contained in
an argument to another regparm-call.
Julian Seward [Wed, 3 Nov 2004 09:08:33 +0000 (09:08 +0000)]
Changes to support Memcheck:
* Pass host word type to instrumentation functions
* irdefs.c: add beginnings of proper sanity checking for flatness
* refine guest-state-layout stuff
* new primop Iop_1Sto32
64-bit cleanness: Converted malloc() et al to use SizeT rather than Int.
This required some tricks with casting to maintain Memcheck's silly (ie.
negative) arg checking. The allocator was also changed accordingly. It
should now be able to allocate more than 4GB blocks on 64-bit platforms.