77 Commits

Author SHA1 Message Date
Julian Seward
080c67f88d Avoid excessive fragmentation in m_mallocfree facility by munmapping
unused superblocks in some circumstances.  Bug 250101 (==269884,
==275852)
(Philippe Waroquiers, philippe.waroquiers@skynet.be)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11911
2011-07-24 17:39:10 +00:00
Julian Seward
ad7de5b336 Delete the AIX5 port. The last release this worked for is 3.4.1,
and then only on AIX 5.2 and 5.3.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11842
2011-06-28 07:25:29 +00:00
Julian Seward
b3827d6c33 Create new module m_libcsetjmp, which wraps up uses of
__builtin_setjmp and __builtin_longjmp so that they can be selectively
replaced, on a platform by platform basis.  Does not change any
functionality.  Related to #259977.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11687
2011-04-11 16:17:51 +00:00
Julian Seward
0e228dac5d Fix a scalability problem observed whilst running Helgrind on a large
workload: when scanning a freelist of a given size for a big-enough
block (to allocate), don't scan all the way around the list.  Instead
give up after 100 blocks and try the freelist above.  The pathological
case (as observed) is that the freelist contains tens of thousands of
blocks, but all are too small for the current request, hence they are
all visited pointlessly.  If the new heuristic is used, the freelist
start point is moved along by one block, so that future searches
eventually inspect the entire freelist, just very slowly.

Also, some improvements to stats gathering, and rename of some
existing stats fields in struct Arena.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11567
2011-02-23 13:18:56 +00:00
Julian Seward
9b0574dff8 Update copyright dates to 2010.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11121
2010-05-03 21:37:12 +00:00
Julian Seward
e7dde85a24 Merge coregrind/ changes from branches/MESSAGING_TIDYUP r10464.
This commit tidies up and rationalises what could be called the
"messaging" system -- that part of V to do with presenting output to
the user.  In particular it brings significant improvements to XML
output.

Changes are:

* XML and normal text output now have separate file descriptors,
  which solves longstanding problems for XML consumers caused by
  the XML output getting polluted by unexpected non-XML output.

* This also means that we no longer have to hardwire all manner
  of output settings (verbosity, etc) when XML is requested.

* The XML output format has been revised, cleaned up, and made
  more suitable for use by error detecting tools in general
  (various Memcheck-specific features have been removed).  XML
  output is enabled for Ptrcheck and Helgrind, and Memcheck is
  updated to the new format.

* One side effect is that the behaviour of VG_(message) has been
  made to be consistent with printf: it no longer automatically
  adds a newline at the end of the output.  This means multiple
  calls to it can be used to build up a single line message; or a
  single call can write a multi-line message.  The ==pid==
  preamble is automatically inserted at each newline.

* VG_(message)(Vg_UserMsg, ..args..) now has the abbreviated form
  VG_(UMSG)(..args..); ditto VG_(DMSG) for Vg_DebugMsg and
  VG_(EMSG) for Vg_DebugExtraMsg.  A couple of other useful
  printf derivatives have been added to pub_tool_libcprint.h,
  most particularly VG_(vcbprintf).

* There's a small change in the core-tool interface to do with
  error handling: VG_(needs_tool_errors) has a new method
  void (*before_pp_Error)(Error* err)  which, if non-NULL, is
  called just before  void (*pp_Error)(Error* err).  This is to
  give tools the chance to look at errors before any part of them
  is printed, so they can print any XML preamble they like.

* coregrind/m_errormgr.c has been overhauled and cleaned up, and
  is a bit simpler and more commented.  In particular pp_Error
  and VG_(maybe_record_error) are significantly changed.

The diff is huge, but mostly very boring.  Most of the changes
are of the form

-   VG_(message)(Vg_UserMsg, "this is a message %d", n);
+   VG_(message)(Vg_UserMsg, "this is a message %d\n", n);

Unfortunately as a result of this, it touches a large number
of source files.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10465
2009-07-15 14:48:32 +00:00
Nicholas Nethercote
8fde04297b Changing VG_MALLOC_MIN_SZB to 16 on some platforms broke heap profiling.
This fixes it by changing the size of a cost centre from ULong to
VG_MALLOC_MIN_SZB.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10136
2009-05-24 23:36:50 +00:00
Nicholas Nethercote
131ab00744 Merged non-Darwin-specific parts of r9397,r9423,r9490, 9461, 9462 from the
DARWIN branch.  A big ugly DARWIN/trunk sync commit, mostly to do with
changing the representation of SysRes and vki_sigset_t.  Functionality of
the trunk shouldn't be changed by it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9876
2009-05-18 02:12:08 +00:00
Nicholas Nethercote
74b33a87de Made the Valgrind abort/crash message clearer about the fact that it can be
caused by heap corruption by the client.  Also clarified the FAQ about this.

Also updated the FAQ about decoding failures a little.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9556
2009-04-16 00:33:20 +00:00
Nicholas Nethercote
698c99b62c Merge r9529 (better memalign abort message) from the DARWIN branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9530
2009-04-14 23:43:15 +00:00
Nicholas Nethercote
f224503623 whitespace-only change
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9454
2009-03-17 04:51:19 +00:00
Nicholas Nethercote
b15e3d9a45 Fix all the non-VEX problems identified with the Clang Static Analyzer.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9416
2009-03-15 23:25:38 +00:00
Nicholas Nethercote
2001629c3f Updated copyright years.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9344
2009-03-10 22:02:09 +00:00
Nicholas Nethercote
5aac956e64 Remove a number of unused parameters, found with -Wunused-parameter.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9248
2009-02-24 03:07:37 +00:00
Nicholas Nethercote
3ed4532cde In the core, include malloc_usable_size() as one of the functions that must
be replaced if malloc() et al are replaced by a tool.  This is because
different tools implement the function in different ways.

Add an appropriate malloc_usable_size() replacement to each of Memcheck,
Helgrind, DRD, Ptrcheck, Massif.

Update memcheck/tests/malloc_usable and add massif/tests/malloc_usable.

Merged from the DARWIN branch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9193
2009-02-17 04:31:18 +00:00
Nicholas Nethercote
d33b3e0d24 Patch from Robert O'Callahan:
make realloc(NULL, size) behave like malloc(size), and make
  realloc(ptr, 0) behave like free(ptr), as the real libc realloc does.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8666
2008-10-12 19:51:41 +00:00
Julian Seward
6e8238ffc4 m_mallocfree.c: omit the 8 byte per block cost-center field used
for heap profiling, if heap profiling is not selected.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8625
2008-09-19 20:13:39 +00:00
Julian Seward
335992d8fc Merge all remaining changes from branches/PTRCHECK. These are some
relatively minor extensions to m_debuginfo, a major overhaul of
m_debuginfo/readdwarf3.c to get its space usage under control, and
changes throughout the system to enable heap-use profiling.

The majority of the merged changes were committed into
branches/PTRCHECK as the following revs: 8591 8595 8598 8599 8601 and
8161.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8621
2008-09-18 18:12:50 +00:00
Bart Van Assche
8e96150945 Merged FORMATCHECK branch (r8368) to trunk.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8369
2008-07-07 06:49:24 +00:00
Julian Seward
72a3a2f4f2 Make the size calculations inside VG_(mallinfo) 64-bit clean.
I don't really understand how 'struct mallinfo' makes any sense on a
64-bit platform given that all the field sizes are 32-bit ints, and
surely at least .arena and .uordblocks and probably others could
easily exceed 32-bit range.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8149
2008-05-29 13:45:49 +00:00
Bart Van Assche
2497cadb85 Refined mallinfo() implementation (contributed by Eugene Toder).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7901
2008-04-21 17:28:50 +00:00
Bart Van Assche
2a7b4f5bd5 Added mallinfo() implementation based on patch by Eugene Toder (see also bug 160956).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7888
2008-04-19 14:43:30 +00:00
Julian Seward
14af4957fc Merge in the DATASYMS branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7540
2008-03-03 01:35:41 +00:00
Julian Seward
5679a22410 Update copyright dates ("200X-2007" --> "200X-2008").
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7398
2008-02-11 11:34:59 +00:00
Julian Seward
b1cd71d2ca Attempt to shake out uses of uninitialised malloc'd memory by Valgrind
itself, if such exist.  Attempt failed (or no such uses exist :-)
Commit does not change any code.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7207
2007-11-24 23:37:07 +00:00
Nicholas Nethercote
d95559802b Changed Massif to record the 'slop' heap bytes caused by rounding asked-for
sizes up to a multiple of 8 (or whatever --alignment is).  This is combined
with the "admin" bytes, resulting in the "extra" bytes.  Added
VG_(malloc_usable_size) to the tool interface to support this.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7133
2007-11-10 04:08:08 +00:00
Nicholas Nethercote
cd95227e38 Add a comment.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7009
2007-10-16 23:18:06 +00:00
Nicholas Nethercote
7cb817e078 Fix various format string errors, courtesy of Florian Krohm.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6902
2007-09-23 00:51:24 +00:00
Julian Seward
3773a4d6c2 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.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6775
2007-08-23 10:22:44 +00:00
Julian Seward
f65fd40ae0 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.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6771
2007-08-21 10:55:26 +00:00
Julian Seward
0f312746f1 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.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6770
2007-08-20 22:57:56 +00:00
Nicholas Nethercote
38fd939a14 Clarify the "out of memory" message.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6656
2007-03-22 03:36:55 +00:00
Julian Seward
172505c978 Update copyright dates.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6488
2007-01-08 06:01:59 +00:00
Julian Seward
78cd9b9a70 Merge r6136:
Track SysRes change; support bigpage allocation on AIX; make the
client-arena superblocks much bigger on AIX.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6273
2006-10-17 01:42:40 +00:00
Julian Seward
ae8215b3ac Create a new module, m_vki, and move all knowledge about the kernel
interface, except for the syscall numbers, into that.  Mostly this
means moving include/vki-*.h to include/vki/vki-*.h.

include/pub_tool_basics.h previously dragged in the entire kernel
interface.  I've done away with that, so that modules which need to
see the kernel interface now have to include pub_{core,tool}_vki.h
explicitly.  This is why there are many modified .c files -- they have
all acquired an extra #include line.

This certainly breaks all platforms except x86.  Will fix shortly.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6225
2006-10-14 19:26:10 +00:00
Julian Seward
ad67fd79fe Update copyright dates.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5954
2006-06-05 23:21:15 +00:00
Nicholas Nethercote
3d12e0e9db Terminology change: previously in Memcheck we had the four states:
noaccess, writable, readable, other

Now they are:

   noaccess, undefined, defined, partdefined

As a result, the following names:

   make_writable, make_readable,
   check_writable, check_readable, check_defined

have become:

   make_mem_undefined, make_mem_defined,
   check_mem_is_addressable, check_mem_is_defined, check_value_is_defined

(and likewise for the upper-case versions for client request macros).
The old MAKE_* and CHECK_* macros still work for backwards compatibility.

This is much better, because the old names were subtly misleading.  For
example:

  - "readable" really meant "readable and writable".
  - "writable" really meant "writable and maybe readable, depending on how
    the read value is used".
  - "check_writable" really meant "check writable or readable"

The new names avoid these problems.

The recently-added macro which was called MAKE_DEFINED is now
MAKE_MEM_DEFINED_IF_ADDRESSABLE.

I also corrected the spelling of "addressable" in numerous places in
memcheck.h.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5802
2006-03-31 11:57:59 +00:00
Nicholas Nethercote
6b44965dc5 code layout wibbles only
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5440
2005-12-26 17:50:22 +00:00
Nicholas Nethercote
e830c38ce8 A minor performance improvement -- make swizzle() faster.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5431
2005-12-25 02:47:12 +00:00
Nicholas Nethercote
3866282110 Remove all remaining profiling gunk.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5388
2005-12-19 22:48:39 +00:00
Julian Seward
be18f74393 findSb: gradually rearrange the superblock list to bring frequently
accessed blocks closer to the front.  This speeds up malloc/free
intensive programs because evidently those searches cause a lot of
cache misses (so cachegrind tells us).  For perf/heap.c on P4
Northwood, this halves the run-time (!) from 85.8 to 42.9 seconds.
For "real" code (start/exit ktuberling) there is a small but
worthwhile performance gain, of about 2 seconds out of 95.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5365
2005-12-17 20:37:36 +00:00
Nicholas Nethercote
ad827637fd Add info about overhead in heap blocks and OSet nodes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5361
2005-12-16 17:06:37 +00:00
Julian Seward
07f008c0f2 Defensive hacks to detect cases where V corrupts its own heap and/or
uses memory after freeing.  Check the redzones for all non-client
frees, and fill all non-client freed areas with garbage.  Unroll
VG_(memset) as a precautionary measure against performance lossage.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5283
2005-12-04 23:27:14 +00:00
Julian Seward
36152f964e Pass args to match format string.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4963
2005-10-21 12:05:05 +00:00
Julian Seward
6048f9c854 Add a new arena (VG_AR_TTAUX) for holding auxiliary TT/TC structures
(see next commit).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4941
2005-10-18 02:20:18 +00:00
Tom Hughes
6961dcf591 Fix statement-before-declaration warnings for the core code.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4906
2005-10-12 10:45:27 +00:00
Tom Hughes
c0893e8f7d Stop memalign crashing if it fails to allocate the memory. Bug 112538.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4879
2005-10-06 12:04:26 +00:00
Julian Seward
cc8ccbbfb4 This commit merges in changes from branches/ASPACEM (specifically,
changes from r4341 through r4787 inclusive).  That branch is now dead.
Please do not commit anything else to it.

For the most part the merge was not troublesome.  The main areas of
uncertainty are:

- build system: I had to import by hand Makefile.core-AM_CPPFLAGS.am
  and include it in a couple of places.  Building etc seems to still
  work, but I haven't tried building the documentation.

- syscall wrappers: Following analysis by Greg & Nick, a whole lot of
  stuff was moved from -generic to -linux after the branch was created.
  I think that is satisfactorily glued back together now.

- Regtests: although this appears to work, no .out files appear, which
  is strange, and makes it hard to diagnose regtest failures.  In
  particular memcheck/tests/x86/scalar.stderr.exp remains in a 
  conflicted state.

- amd64 is broken (slightly), and ppc32 will be unbuildable.  I'll
  attend to the former shortly.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4789
2005-09-27 19:20:21 +00:00
Nicholas Nethercote
281297db9f Fix a problem I introduced in r4208 when reducing the space used by
heap blocks.  The minimum size for redzones is now sizeof(void*), but
I forgot to ensure this.  Massif was asking for 0 byte redzones, and this
was screwing things up on 64-bit platforms, and Massif was dying very
quickly.  This should fix bugs #111090 and #111285.

The fact that Massif was this badly broken but there were only 2 bug reports
indicates that not many people are using it, at least not on AMD64.

I also added a regtest that does some basic malloc/realloc/free testing
for Massif, which would have caught this problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4492
2005-08-24 22:38:00 +00:00
Nicholas Nethercote
f55a9512e0 Make the allocator's access functions slightly stricter in their
checking of the lo/hi size fields.  If we are corrupting the metadata,
this should make it more likely that we get an assertion failure rather
than an outright crash.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4480
2005-08-23 22:11:20 +00:00