Julian Seward [Sun, 3 Nov 2002 13:41:41 +0000 (13:41 +0000)]
Add a new client request, VG_USERREQ__LOGMESSAGE, and use this to route
all commentary from our libpthread.so through to the valgrind core and
hence to the selected logging sink.
Julian Seward [Sun, 3 Nov 2002 11:44:36 +0000 (11:44 +0000)]
Robustification of logging to a socket. If the listener process dies
or for whatever reason hangs up the connection, don't let valgrind
get SIGPIPE; instead just switch back to spewing messages on stderr.
Julian Seward [Sun, 3 Nov 2002 03:20:15 +0000 (03:20 +0000)]
Implement logging to a network socket. So it's now possible to do
valgrind ... --logsocket=192.168.0.1:1500 or whatever, to send all
output to that address/port combination.
Julian Seward [Wed, 23 Oct 2002 21:58:55 +0000 (21:58 +0000)]
Merge patch from Jeremy Fitzhardinge:
19-hg-lockgraph
HELGRIND: large patch which does a big bugfix and adds some new
instrumentation:
1. The bugfix is BIG. Previously the code which maintained the
thread's current lockset would often (maybe always) fail to add new
locks to the set, so it always looked like threads were holding one
lock. The problem was in weird_LockSet_equals(); I rewrote it in a way
which should be obviously correct. Fixing this exposed a bug in
removing locks from a thread's lockset, which was also caused by
another bug in weird_LockSet_equals(). This fix makes many spurious
data race warnings go away (notably, stdio becomes silent).
2. The new feature is tracking of the order of lock usage. If
threads are taking locks in an inconsistent order, that's a symptom of
possible deadlock. Helgrind will now warn when it sees this happening
(though the warnings themselves need to be improved).
Julian Seward [Wed, 23 Oct 2002 21:53:49 +0000 (21:53 +0000)]
Merge patch from Jeremy Fitzhardinge:
16-function-intercept
Implement a more reliable for vg_libpthread to intercept libc
calls. Since the only reliable way of making sure that our code
defines the symbol is by making sure that valgrind.so itself does it,
this patch adds a new file, vg_intercept.so, which defines those
symbols. They are then passed off to a weak local function if
libpthread isn't present, or to the libpthread version if it is.
Julian Seward [Wed, 23 Oct 2002 21:46:13 +0000 (21:46 +0000)]
Merge patch from Jeremy Fitzhardinge:
14-hg-mmap-magic-virgin
This does two things:
1. change the signatures of the new_mem_mmap and change_mem_mprotect
functions to remove the pointless 'nn' argument. This makes them match
the signature of new_mem_startup...
2. change helgrind to mark memory created by mmap as if it were the
same as other magically pre-inited memory. Implement this by pointing
helgrind's new_mem_mmap function at new_mem_startup.
Julian Seward [Wed, 23 Oct 2002 21:38:22 +0000 (21:38 +0000)]
Merge patch from Jeremy Fitzhardinge:
13-kill-1ifroot
Kill VG_(get_current_tid_1_if_root)() and replace it with the slightly
more appetising (though still hackish)
VG_(get_current_or_recent_tid)(). This is intended for use when
there's no thread actually loaded into the baseblock, but we're doing
work on behalf of the the thread that was last running (such as during
a syscall).
This probably fixes a bug with helgrind misattributing memory created
with mmap to thread 1 rather than the thread which called mmap (though
the behaviour is still probably wrong: mmapped memory should be
magically_inited).
Julian Seward [Tue, 22 Oct 2002 05:09:36 +0000 (05:09 +0000)]
Merge patch from Jeremy Fitzhardinge:
21-hg-dupwrite
HELGRIND: quite often memory is written with a value which is already
there, which would not cause a race (I think; there are certainly
valid idioms which rely on this behaviour). Anyway, suppressing checks
for such overwrites cuts down the number of apparently spurious
errors. Also fixes the bug in which FP loads were considered to be
stores.
Julian Seward [Tue, 22 Oct 2002 05:05:49 +0000 (05:05 +0000)]
Merge patch from Jeremy Fitzhardinge:
20-hg-secmap
HELGRIND: fix bugs causing a torrent of "access to distingished map"
messages. There were two: one is some absurdly broken rounding/padding
code in set_address_range_state() (how did anything work!?). The other
was some odd looking code in the tracking of attaching shared memory
segments. Since they're semantically very similar to mmap, track them
as such.
Julian Seward [Tue, 22 Oct 2002 04:59:26 +0000 (04:59 +0000)]
Merge patch from Jeremy Fitzhardinge:
19-hg-context
HELGRIND: Yet more work on making sure the right context is used when
reporting errors. The previous code used the snapshot of the thread
context in the VG_(threads) array rather than the current machine
state in the baseBlock. This patch makes sure that errors arising from
program reads and writes are reported properly.
Julian Seward [Tue, 22 Oct 2002 04:55:54 +0000 (04:55 +0000)]
Merge patch from Jeremy Fitzhardinge:
18-hg-err-reporting
HELGRIND: show more information about the address we're reporting a
possible data race for; in particular, try to describe where the
address came from (static variable, or heap allocated and if so
where?) (Mostly stolen from memcheck). Also puts memory locations
involved with an error into an error state, so that duplicate errors
are suppressed. Also displays the last good set of locks for a memory
location.
Julian Seward [Tue, 22 Oct 2002 04:54:55 +0000 (04:54 +0000)]
Merge patch from Jeremy Fitzhardinge:
17-hg-generic-mutex
HELGRIND: remove references to pthread_mutex_t and replace it with a
more generic notion of a mutex. Adds a persistent store of per-mutex
information. Not presently useful, but will be.
Julian Seward [Tue, 22 Oct 2002 04:45:48 +0000 (04:45 +0000)]
Merge patch from Jeremy Fitzhardinge:
14-sprintf
Update to core VG_(printf)/sprintf/vprintf. They've been modified to
return the number of characters they generated (either printed, put
into the buffer, or sent). Also adds a new %y format, which takes an
Addr argument and looks up a symbol. It takes a '(' flag (ie: "%(y")
which surrounds the symbol in parens if it could be found.
Julian Seward [Tue, 22 Oct 2002 04:14:35 +0000 (04:14 +0000)]
Merge patch from Jeremy Fitzhardinge:
08-skin-clientreq
Introduce a systematic way for skins to distinguish each other's
client requests. Uses the de-facto standard two-letter identifiers in
the top two bytes of the client request code. Also changes the
interface to SK_(handle_client_request) so that a skin can say whether
or not it handled the request, which allows correct setting of the
default return value if the request was not handled.
Julian Seward [Sun, 20 Oct 2002 19:40:32 +0000 (19:40 +0000)]
merge patches from Jeremy Fitzhardinge:
14-hg-tid
HELGRIND: This fixes a bug in Helgrind in which all memory access by
syscalls was being treated as if it were happening in thread 1. This
is because the eraser_mem_read/write functions were using
get_current_tid_1_if_root() to get the current tid. Unfortunately,
during syscalls there is no current thread, so it was getting
1_if_root. This patch fixes this by using what thread ID information
we're given, and only using get_current_tid() if we're recording a
memory access performed by code (rather than by a syscall).
Julian Seward [Sun, 20 Oct 2002 19:29:21 +0000 (19:29 +0000)]
Merge 13-data-syms from Jeremy Fitzhardinge:
Fix to the ELF file reader to make sure that each SegInfo includes not
only the text mapped from an ELF file, but also the data and bss. This
allows the data symbols to be extracted. Also adds a new needs boolean
to allow a skin to specify if it needs data symbols. As a nice
side-effect, it removes the "offset" hack: the offset is the mapped
address in the ELF Phdr: it is (mapped_address - phdr_vaddr).
Moved baseBlock initialisation to after command-line processing, for skins that
don't register helpers until command-line options are seen. As requested by
Jeremy Fitzhardinge. Also neatened the code up marginally.
Julian Seward [Sat, 12 Oct 2002 17:27:16 +0000 (17:27 +0000)]
Fixes for the DWARF2 reader, from Josef Weidendorfer:
Attached patch is for the Dwarf2 source line info reader;
For reading, a state machine is used reconstructing source line
info while running and reading (see DWARF2 specification, ch. 6.2).
The state machine was correct, but the calls to addLineInfo()
were wrong: It reported most of the times too small ranges
for source code statements, because it used only the diff of the last
state machine command instead of the diff to the last statement
boundary. Effect: Around 1/3 of all addresses with source line info got
unknown location.
The patch adds a "last_address" to the state machine to remember the last
statement boundary. On reset, it#s initialised to the "invalid" address 0. I
hope this is OK (or should we use "(Addr)-1" instead?).
The patch now uses the "is_stmt" boolean correctly to only call addLineInfo()
if there's a statement boundary (on x86, is_stmt most probably is
always true...).
Julian Seward [Sat, 12 Oct 2002 16:42:35 +0000 (16:42 +0000)]
Finish off support for Red Hat 8 thread-specific-data. Unfortunately
the appearance of libc_internal_tsd_address requires a redesign, since
the existing scheme doesn't make it sensible to take the address of a
specific-data value.
New scheme is that the ThreadState structure carries not the table of
specifics, but merely a pointer to such. This is allocated from the
client-side library, thus residing in client-visible memory and so
addresses can validlyh be taken.
Julian Seward [Mon, 7 Oct 2002 23:56:55 +0000 (23:56 +0000)]
Initial stuff to make it work on Red Hat 8:
- autoconf stuff for detecting glibc-2.3
- vg_libpthread_unimp.c: hack for __pthread_clock_[gs]ettime
- vg_libpthread.c: initialise thread's default locale by calling
__uselocale(LC_GLOBAL_LOCALE) at the right time. Gruesome.
Also need to do this for new other threads - not yet done.
- cleanups -- don't use write() to write messages when bombing out,
instead go direct to the syscalls. Avoids nasty circularities
with glibc initialisations.
Julian Seward [Sun, 6 Oct 2002 21:43:50 +0000 (21:43 +0000)]
saneUInstr: define CCf correctly for FPU insns: they read no flags and
write no flags (usually) or write ZCP (rarely, >= P6 only fast FPU compare
insns.)
up_UInstr: Put some 0x in %x fields so we can see what's hex.
Julian Seward [Sun, 6 Oct 2002 00:28:21 +0000 (00:28 +0000)]
startup_segment_callback: don't panic when faced with non-executable,
non-readable, non-writable sections. Just ignore them. Comment in
the 1.0.X sources to the effect that this never happens is evidently a
lie.
Julian Seward [Sat, 5 Oct 2002 15:18:27 +0000 (15:18 +0000)]
merge revs
vg_syscall_mem.c 1.58.2.8 and 1.58.2.10
vg_unsafe.h 1.8.4.2
Support for __NR_ptrace, thanks to Jason Molenda. Now valgrind can be
used to debug GDB. Bwaha!
Kludge to work around the problem that the /usr/include/sys/user.h on
R H 6.2 doesn't define struct user_fpxregs_struct (problem appeared
with Jason Molenda's ptrace patch).
Julian Seward [Sat, 5 Oct 2002 02:44:47 +0000 (02:44 +0000)]
Back out rev 1.9 (optimised %eflags save/restore). It isn't quite
right.
Here's a code sequence illustrating the problem. The conditional jump
at the end evidently goes the wrong way sometimes, and the program
goes off into outer space soon after.
Look carefully at the annotation on # 17. Then look in the Intel docs
and see what flag(s) the Jnb (not-below) condition consults. Bwaha!
It consults the carry flag.
The generated code for 17 (renamed to 12 after some NOP removal, I
guess) is
viz, we do the decl, and then copy the real machine's %eflags into
%EFLAGS. Unfortunately this copies the real carry flag into the
simulated one, rather than leaving the simulated one alone.
So the principle is that it's only safe to omit the initial
%EFLAGS->%eflags move prior to the insn if the insn writes _all_ the
flags, and in this case it doesn't.
(after further consideration ...)
At first it seems tempting to play games with subset checks, ie if an
insn writes a _subset_ of the flags, we'd better copy sim'd to real
flags before the insn.
Problem with that is that the D (direction) flag, which specifies the
direction that rep-prefix string ops travel, is part of the "normal"
flag set. So it is conceivable, although highly unlikely, that an app
could
- set the D flag
- do something like ADD (-wOSZACP)
- use the D flag
then we'd still have to do an %EFLAGS->%eflags copy prior to the ADD,
in order to ensure the simulated D flag is preserved.
So it seems to me that it's pretty much impossible to preserve
absolute correctness and do any better than the vg_from_ucode.c rev
1.8 scheme.
Backing out rev 1.9. We can just as easily restore it from cvs if a
better solution is arrived at.
Moved discard, clientperm and clientstackperm from tests/ into the test
suite-proper, giving them .vgtest files and all that. They don't make sense
for 1.0.X because the client request constants are different in HEAD, indeed
one of them (clientperm) fails with --stable.
Also moved blocked_syscall.c from tests/ to tests/unused/.
Added one regression test for each of addrcheck, lackey, and helgrind, each of
which had none previously. They all run tests/true (added as well), just to
automatically catch any total b0rkage errors.
Also fixed up filter_stderr_basic to account for changes to startup message;
my changes from yesterday broke all the --stable tests.
Prettified output somewhat, so that full directory names (relative to .) are
printed, and so that directories containing no test files get a different, more
concise, message.
Julian Seward [Thu, 3 Oct 2002 16:14:57 +0000 (16:14 +0000)]
vg_to_ucode: deploy handleSegOverride() in a couple of places where an
address is calculated without use of disAMode. This gets the NVidia GL
driver further along, till the point where it dies as a result of an
MMX/SSE insn :-(
Changed startup message to give information about skin and core separately.
Added "version" and "copyright_author" fields for skins to supply.
Now startup message looks something like this:
==12698== cachegrind, an I1/D1/L2 cache profiler for x86-linux.
==12698== Copyright (C) 2002, and GNU GPL'd, by Nicholas Nethercote.
==12698== Built with valgrind-HEAD, a program execution monitor.
==12698== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==12698== Estimated CPU clock rate is 1422 MHz
==12698== For more details, rerun with: -v
The skin can specify a version number, but the skins that will be distributed
with Valgrind don't.
Also changed "x86 GNU/Linux" to the wicked "x86-linux" at Julian's request.
Updated default regression test filter to handle this new startup message.
----
Also moved the skin's name, description, etc., fields out of VG_(needs) into a
new struct VG_(details), since they are logically quite different to the needs.
Did a little code formatting, etc., for this. Updated skin docs
correspondingly, too.
Also renamed the need `run_libc_freeres' --> `libc_freeres' so it's a noun
phrase rather than a verb phrase.
Changes made so that skin error "report this bug to" messages are distinguished
from core error ones:
- Split up VG_(panic) into VG_(core_panic) and VG_(skin_panic)
- Likewise, split vg_assert into vg_assert and sk_assert
- Added a new need string: `bug_reports_to'
- Removed VG_(skin_error) which was a previous wussy attempt at this change.
This removed the need for the hacky redeclaration of VG_(skin_error) in
vg_profile.c, which is good.
At the moment, Julian and Nick's email addresses are hard-coded into each skin
individually, rather than using a #define in vg_skin.h, because that didn't
feel quite right to me... jseward@acm.org is still done with a #define for
core errors, though.
Qualifying suppression types with the skin name, like this:
memcheck:Addr4
Changed the `name' need of the memcheck skin from "valgrind" to "memcheck" for
this. But the name Valgrind will return when I print core and skin names in
the startup message.
One issue is that some skins share suppression types, eg. memcheck and
addrcheck. Might be useful to allow multi-skin suppressions, viz:
Julian Seward [Wed, 2 Oct 2002 10:20:30 +0000 (10:20 +0000)]
From "Francis Lebourse" <flebourse@jetmultimedia.fr>:
[re the ELF symbol reader]
This patch tries to exploit the dynamic symbols of a library if the
standard and debug symbols are missing.
This way, I avoid the "object doesn't have a symbol table message"
message and valgrind is able to print meaningful backtraces (else you
have only "in libsomelib.so"), even in the case of stripped libs.
Since the check of the .dynsym/.dynstr sections is done before the
.symtab/.strtab sections, the previous behavior is preseved for
unstripped libraries.
MERGE TO STABLE (if it doesn't cause probs with suppression files)