Fix 64-bit Massif breakage, caused by problems with integer arithmetic on
values of different signs and sizes that only a C language lawyer would
spot.
Merged the MASSIF2 branch to the trunk. Main changes:
- ms_main.c: completely overhauled.
- massif/tests/*: lots of them now.
- massif/perf/: added.
- massif/hp2ps: removed. No longer used.
- vg_regtest: renamed the previously unused "posttest" notion to "post".
Using it for checking ms_print's output.
Although the code has changed dramatically, as has the form of the tool's
output, the information presented in the output is basically the same,
although it's now (hopefully) much more useful. So the tool name is
unchanged.
callgrind_control: Fix behavior with callgrind runs of another user
callgrind_control uses files /tmp/callgrind.info.* to be able to
locate running callgrind processes. These files can be read only by
the user which started callgrind. The callgrind_control script
did not check for "permission denied" on opening these files, which
resulted in some unexpected errors. Now, it is checked whether
the "open" was successful, and if not, we skip the according callgrind
process.
callgrind: Use directory in debug info when available
Prepend the file name of a source file with the directory
if that is available. This not only gets rid of problems with the
same file name used in different paths of a project, but lets
the annotation work out of the box without having to specify any
source directory.
Works both with callgrind_annotate and KCachegrind without any
changes there.
Inspired by Nick's change to cachegrind doing the same thing
in r6839 (and gets rid of a FIXME in the source)
Split the OSet interface into two parts: "OSetGen_", which is the existing
interface and provides full power; and "OSetWord_", which is an
easier-to-use interface for if you just want to store words.
ppc32-linux signal handling: don't place the sigframe return stub on
the stack; instead use a stub in m_trampoline.S. This makes it
possible to deliver signals on non-executable stacks, and makes the
behaviour consistent with x86-linux and amd64-linux.
Julian Seward [Wed, 29 Aug 2007 09:11:35 +0000 (09:11 +0000)]
Valgrind-side changes to track vx1786 (which was: Support x86 $int
0x40 .. 0x43 instructions on Linux. Apparently these generate a
segfault and then restart the instruction.)
Julian Seward [Tue, 28 Aug 2007 06:05:20 +0000 (06:05 +0000)]
Merge, from CGTUNE branch, a cleaned up version of r6742:
Another optimisation: allow tools to provide a final_tidy function
which they can use to mess with the final post-tree-built IR before it
is handed off to instruction selection.
In memcheck, use this to remove redundant calls to
MC_(helperc_value_check0_fail) et al. Gives a 6% reduction in code
size for Memcheck on x86 and a smaller (3% ?) speedup.
Julian Seward [Mon, 27 Aug 2007 10:46:39 +0000 (10:46 +0000)]
This module supplies various replacement functions, amongst them a
replacement for index/strchr in ld.so. Unfortunately the replacement
functionality was actually rindex/strrchr and amazingly it has taken
about 2.5 years for anyone to notice.
This fixes the x86-linux case; ppc32-linux and ppc64-linux fixes to
follow.
Julian Seward [Sat, 25 Aug 2007 07:19:08 +0000 (07:19 +0000)]
Changes to m_hashtable:
Allow hashtables to dynamically resize (patch from Christoph
Bartoschek). Results in the following interface changes:
* HT_construct: no need to supply an initial table size.
Instead, supply a text string used to "name" the table, so
that debugging messages ("resizing the table") can say which
one they are resizing.
* Remove VG_(HT_get_node). This exposes the chain structure to
callers (via the next_ptr parameter), which is a problem since
callers could get some info about the chain structure which then
changes when the table is resized. Fortunately is not used.
* Remove VG_(HT_first_match) and VG_(HT_apply_to_all_nodes) as
they are unused.
* Make the iteration mechanism more paranoid, so any adding or
deleting of nodes part way through an iteration causes VG_(HT_next)
to assert.
* Fix the comment on VG_(HT_to_array) so it no longer speaks
specifically about MC's leak detector.
Julian Seward [Thu, 23 Aug 2007 10:22:44 +0000 (10:22 +0000)]
The drastic increase in the number of per-arena freelists in r6771
exposes a performance problem with doing m_mallocfree.c sanity checks
(at --sanity-level=3, at least), caused by slowness in
listNo_to_pszB_min. This commit fixes the problem by caching the
results of queries to listNo_to_pszB_min.
Julian Seward [Tue, 21 Aug 2007 10:55:26 +0000 (10:55 +0000)]
Previously, each Arena has a linked list of Superblocks, which can
make VG_(arena_free) expensive if many superblocks have to be checked
before the right one is found. This change gives the arena a
dynamically expanding sorted array of superblocks, so that finding the
superblock containing an about-to-be-freed block (findSb) is now
O(log2 n) rather than linear in the number of superblocks in the
arena. Patch from Christoph Bartoschek.
Julian Seward [Mon, 20 Aug 2007 22:57:56 +0000 (22:57 +0000)]
Some improvements for malloc/free intensive programs, inspired by
performance studies by Christoph Bartoschek:
* Increase the number of freelists per arena from 18 to 112, so as
to (drastically) cut down on the amount of freelist searching that
happens.
* Increase the size of the client and tool arenas, so as to reduce
the cost of finding arenas during freeing. This is a kludge; a
better solution would be to use binary search on superblocks, as
Christoph's patches do.
Get rid of VG_(getcwd) and replace it with a pair of functions,
VG_(record_startup_wd) which records the working directory at startup,
and VG_(get_startup_wd) which later tells you what value was recorded.
This works because all uses of VG_(getcwd) serve only to record the
directory at process start anyway. The motivation is that AIX does
not support sys_getcwd directly, so it's easier for the launcher to
ship in the required value using an environment variable. On Linux
sys_getcwd is used as before.
Callgrind manual: rewriting start of section about avoding cycles
This hopefully makes the whole issue with cycles easier to understand.
And no, this does not get rid of the description of cycles, carefully
crafted by Julian ;-)
* Looks a little bit more like the Cachegrind manual
(at least in front)
* Removed the out-of-place general section about profiling
and gprof. Perhaps something like this can be put at
another place
* Notes about Callgrinds problems with call tracing on PPC
* Include usage of callgrind_annotate, and note its lack of
cycle detection
Julian Seward [Tue, 8 May 2007 09:20:25 +0000 (09:20 +0000)]
Add branch-misprediction profiling to Cachegrind. When the (new) flag
--branch-sim=yes is specified, Cachegrind simulates a simple indirect
branch predictor and a conditional branch predictor. The latter
considers both the branch instruction's address and the behaviour of
the last few conditional branches. Return stack prediction is not
modelled.
The new counted events are: conditional branches (Bc), mispredicted
conditional branches (Bcm), indirect branches (Bi) and mispredicted
indirect branches (Bim). Postprocessing tools (cg_annotate, cg_merge)
handle the new events as you would expect. Note that branch
simulation is not enabled by default as it gives a 20%-25% slowdown,
so you need to ask for it explicitly using --branch-sim=yes.
Julian Seward [Sat, 5 May 2007 11:40:35 +0000 (11:40 +0000)]
Fix stack overflow which lead to totally mysterious .bss corruption
and hence to segfaulting in vex on ppc32/64-linux in obscure
circumstances. VKI_MAX_PAGE_SIZE is 64k in recent Valgrinds.
Julian Seward [Tue, 1 May 2007 13:44:08 +0000 (13:44 +0000)]
If gcc supports -fno-stack-protector, use it. This should fix
compilation failures on distros where -fstack-protector is enabled by
default. See #144112.