Having moved VG_(arena_strdup)() out of core.h, core.h no longer
needs to #include pub_core_mallocfree.h. As a result, we need
to #include it explicitly everywhere else.
Put arch-specific Cachegrind code in files in the main cachegrind/
directory, instead of subdirectories. This is simpler and consistent
with how the rest of system is now structured.
Julian Seward [Thu, 9 Jun 2005 19:27:25 +0000 (19:27 +0000)]
More CFI-reader hacking. Thus far the reader has assumed that each
FDE refers to the immediately preceding CIE, and gives up if that
isn't so. Well, that isn't so, and this commit fixes it. Now FDEs
may refer to CIEs seen arbitrarily far back. This fixes some missing
stack traces on AMD64.
Also add some comments giving a top-level sketch of how the CFI reader
works.
Julian Seward [Thu, 9 Jun 2005 13:56:07 +0000 (13:56 +0000)]
Increase the number of auxmaps from 500 to 20000. This should be
enough to cover 1.25GB of auxiliary address space. This is all still
a hack until such time as the address space manager is rewritten, but
should make things work more reliably on amd64-linux for now.
Julian Seward [Thu, 9 Jun 2005 13:23:56 +0000 (13:23 +0000)]
Alternate expected outputs with better stack traces. CFI based stack
unwinding may have been a giant pain to implement, but it does appear
to be better at not missing stack frames and generally being
consistent then the old x86-linux follow-the-%ebp scheme.
Julian Seward [Tue, 7 Jun 2005 20:04:56 +0000 (20:04 +0000)]
A major overhaul of all machinery to do with syscalls, but mostly of
the m_syscalls module. Fundamentally the aim of the overhaul is to
clean up the logic and abstractions surrounding syscalls in order that
we can cleanly support ppc32 and other new targets. Aims in detail:
* To further decouple the syscall PRE/POST wrappers from specifics of
how those values are stored on a given platform. The wrappers look
the same as they did before, mostly (eg, references to ARGn and
RES are unchanged), but now those macros refer to values in structs
SyscallArgs and SyscallStatus (see priv_types_n_macros.h).
* Complete overhaul of the driver logic for syscalls. The resulting
logic is algorithmically identical to what we had before, but is
more documented, and deals with moving arg/result data between
platform specific representations and the canonical forms in
structs SyscallArgs and SyscallStatus.
* Also as a result of this change, remove problems in the old logic
due to assignments of RES in PRE wrappers trashing the ARGs whilst
we still need to see them.
* Lots of other cleanups and documentation. There is extensive
commentary in syscalls-main.c.
The driver logic has been placed in its own file, syscalls-main.c.
New/deleted files in m_syscalls:
* syscalls.c is divided up into syscalls-main.c, containing driver
logic, and syscalls-generic.c, containing generic Unix wrappers.
* priv_syscalls.h is chopped up into priv_types_n_macros.h
and priv_syscalls-{generic,main}.h.
------------
All the above changes are in m_syscalls. However there is one
system-wide change as a result of all this.
The x86-linux assumption that syscall return values in the range -4095
.. -1 are errors and all others are values, has been done away with
everywhere. Instead there is a new basic type SysRes which holds a
system call result in a platform-neutral way.
Everywhere that previously an Int would have held a system call
result, there is now a SysRes in its place.
------------
Almost everything works on SuSE 9.1 (LinuxThreads) again. NPTL will
still be majorly broken; I will commit fixes shortly. AMD64 is also
totalled. I will get to that too.
Robert Walsh [Sat, 4 Jun 2005 20:42:33 +0000 (20:42 +0000)]
Implement stack registration client requests. See the documentation
in the user manual for usage information. The stack_changes.c file in
corecheck/tests contains a short example.
Modularised assertions and panics in m_libcassert.
As part of this, killed the VG_STRINGIFY macro, which was used to expand
out names like "VG_(foo)" and "vgPlain_foo" in assertion failure
messages. This is good since we actually want the "VG_(foo)" form used
in these messages.
Rename *ROUND* as VG_*ROUND* to be consistent with everything else. Also
make them tool-visible, so that Memcheck and Helgrind don't have to defined
their own versions!
Started modularising vg_mylibc. Put all the standalone stuff -- ie. not
relying on any other modules -- in m_libcbase.
Also converted the 'size' parameters to functions like VG_(memcpy) and
VG_(strncpy) from Int to SizeT, as they should be.
Also removed VG_(atoll16) and VG_(toupper), which weren't being used.
Also made VG_(atoll36) less flexible -- it now only does base-36 numbers
instead of any base in the range 2..36, since base-36 is the only one we
need. As part of that, I fixed a horrible bug in it which caused it to
return incorrect answers for any number containing the digits 'A'..'I'!
(Eg. for "A; it would return 17 instead of 10!)
Had to disable the assertions in VG_(string_match), since this module can't
see vg_assert, which wasn't ideal but also isn't a disaster.
Whitespace/comment-only changes, to serve as placeholder for the last commit
which I put the wrong log message in for. The log message should have been:
Clean up VG_(core_panic_at)() -- pass it ip/sp/fp rather than a
StackTrace. This allows m_signals.c to not have to know about
m_stacktrace.c, nor does core.h need to import pub_core_stacktrace.h any
more. (Also fixed a bug that was preventing vg_assert2's extra string
from being printed.)
Also moved VG_DEEPEST_BACKTRACE out of core.h into pub_core_execontext.h.
Julian Seward [Tue, 31 May 2005 17:24:49 +0000 (17:24 +0000)]
Completely zero out all the thread records at initialisation. As far
as I can see, deallocate_LGDTs_for_thread were being called on
uninitialised thread records.
Julian Seward [Tue, 31 May 2005 10:12:06 +0000 (10:12 +0000)]
When handling the clone variant done by the Quadrics Elan3 user-space
driver, start the child off with a copy of the parent's GDT. All
other uses of clone() are unaffected.
Modularised vg_main.c as m_main.c. Moved some stuff out of it to reduce the
number of files that depend on it, but there are still some which should be
removed in the future.
Julian Seward [Mon, 30 May 2005 21:44:08 +0000 (21:44 +0000)]
Change the way thread termination is handled. Until now, there has
been a concept of a 'master thread'. This is the first thread in the
process. There was special logic which kept the master thread alive
artificially should it attempt to exit before its children. So the
master would wait for all children to exit and then exit itself, in
the process emitting the final summary of errors, leaks, etc.
This has the advantage that any process waiting on this one will see
the final summaries appearing before its sys_wait call returns. In
other words, the final summary output is synchronous with the
master-thread exiting.
Unfortunately the master-thread idea has a serious drawback, namely
that it can and sometimes does cause threaded programs to deadlock at
exit. It introduces an artificial dependency which is that the master
thread cannot really exit until all its children have exited. If --
by any means at all -- the children are waiting for the master to exit
before exiting themselves, deadlock results. There are now two known
examples of such deadlocks.
This commit removes the master thread concept and lets threads exit in
the order which they would have exited without Valgrind's involvement.
The last thread to exit prints the final summaries. This has the
disadvantage that final output may appear arbitrarily later relative
to the exit of the initial thread. Whether this is a problem in
practice remains to be seen.
As a minor side effect of this change, some functions have had
_NORETURN added to their names. Such functions do not return. The
thread in which they execute is guaranteed to exit before they return.
This makes the logic somewhat easier to follow.
amd64 compilation is now broken. I will fix it shortly.
Avoid confusing use of a pointer before checking it it's NULL. (The
code from the glibc demangler is buggy, but because we use a malloc()
that never returns NULL, this code is actually ok within Valgrind, albeit
strange. I changed it to avoid possible confusion.)