626 Commits

Author SHA1 Message Date
Nicholas Nethercote
07045477ca Merge the DARWIN branch onto the trunk.
I tried using 'svn merge' to do the merge but it did a terrible job and
there were bazillions of conflicts.  So instead I just took the diff between
the branch and trunk  at r10155, applied the diff to the trunk, 'svn add'ed
the added files (no files needed to be 'svn remove'd) and committed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156
2009-05-28 01:53:07 +00:00
Nicholas Nethercote
99b76e50c7 DARWIN sync: add some 'const' attributes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10022
2009-05-20 04:22:42 +00:00
Nicholas Nethercote
df51cff058 DARWIN sync: comment change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10018
2009-05-20 04:09:38 +00:00
Nicholas Nethercote
7f19e9cb79 Merge r9993, r9995 (comment changes about vg_stat) from the DARWIN branch,
and rename all the vg_stat fields to avoid problems that the old names cause
on Darwin.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9996
2009-05-20 02:02:30 +00:00
Nicholas Nethercote
1016fb0228 Param names sync wibble.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9957
2009-05-19 05:50:34 +00:00
Nicholas Nethercote
c2c6d7407e Minor sync with the DARWIN branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9920
2009-05-19 01:32:52 +00:00
Nicholas Nethercote
338d03ec6c Add some extra CALL_FN_V_* macros. Copied from the DARWIN branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9919
2009-05-19 01:24: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
a3dfa6672b Factor out the name of the libpthread library. Also fix a minor stack trace
bogon.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9832
2009-05-11 08:01:09 +00:00
Nicholas Nethercote
6378dfe575 Created a new module, m_aspacehl. Factored out three(!) copies of
get_seg_starts() into it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9796
2009-05-08 00:39:31 +00:00
Nicholas Nethercote
fbe37d96a8 Fix bug #191182, where printing the leak checker results was really slow if
there were a lot of loss records.

The fix was:
- Avoid the O(m * n) looping over the chunks when creating the loss
  records, by putting loss records into an OSet instead of a list, which
  makes duplicate detection for each chunk an O(log n) operation instead of
  an O(n) operation.
- Avoid the looping over loss records which was used to do a poor
  man's sort, but was O(n^2).  Instead copy pointers to the loss records
  from the OSet into an array and sort it normally with VG_(ssort) (n log n,
  usually) before printing.

This approach was similar to that used in the patch Philippe attached to the
bug report.

Other changes:
- Added Philippe's test programs in the new memcheck/perf directory.  It
  used to take 57s on my machine, now it takes 1.6s.
- Cleaned up massif/perf/Makefile.am to be consistent with other Makefiles.
- Improved some comments relating to VgHashTable and OSet.
- Avoided a redundant traversal of the hash table in VG_(HT_to_array), also
  identified by Philippe..
- Made memcheck/tests/mempool's results independent of the pointer size, and
  thus was able to remove its .stderr.exp64 file.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9781
2009-05-06 06:15:55 +00:00
Nicholas Nethercote
57a42692d9 Don't compile Linux-only redirects on non-Linux platforms.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9745
2009-05-04 04:20:02 +00:00
Nicholas Nethercote
199e02a8c1 Remove VKI_SI_TKILL for platforms that don't have it.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9700
2009-04-30 05:23:22 +00:00
Nicholas Nethercote
3bd466a089 Converted VG_(message) calls in m_signals.c to VG_*MSG macros, for brevity.
Converted lots of tabs on modified lines to spaces as well.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9693
2009-04-30 04:17:45 +00:00
Bart Van Assche
29ab523a49 Fixed compiler warnings triggered by the test programs that include both <stdlib.h> and "pub_tool_oset.h".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9634
2009-04-26 07:15:58 +00:00
Nicholas Nethercote
d834611463 Merge r9600 (separate VG_ and ML_ definitions for C and asm files) from the
DARWIN branch.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9601
2009-04-24 04:57:07 +00:00
Julian Seward
779bbb61c6 Add support for reading Windows PDB debug info (symbols and line
numbers) when Valgrind is running Wine.  Modified version of a
patch by John Reiser (vgsvn+wine-load-pdb-debuginfo.patch) with
extensions to read a second format of line number tables.

Wine uses a new client request, VG_USERREQ__LOAD_PDB_DEBUGINFO,
to tell Valgrind when to read PDB info.  Wine's implementation
of module loading is vastly different from that used by
ld-linux.so, and it is too difficult to recognize what is going
on just by observing the calls to mmap and mprotect.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9580
2009-04-22 22:42:10 +00:00
Tom Hughes
2d43007ce1 Add SIOCGSTAMPNS support. Fixes #188530.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9502
2009-03-31 10:36:58 +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
5b758688bd Added some shortcuts for VG_(message)(), and used them in a few places (but
certainly not all).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9367
2009-03-12 00:06:45 +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
74b7903711 Remove dead code relating to interface versions.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9289
2009-02-27 03:38:28 +00:00
Nicholas Nethercote
3a36379dcf Add more testing to memcheck/tests/unit_libcbase.c.
Remove VG_(strcmp_ws) and VG_(strncmp_ws);  they're no longer needed by CLO
handling, and they're not much use elsewhere.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9270
2009-02-26 03:52:35 +00:00
Nicholas Nethercote
da695aa41a atoll() is a terrible function -- you can't do any error checking with it.
Some of our option processing code uses it.  This means that eg.
'--log-fd=9xxx' logs to fd 9, and '--log-fd=blahblahblah' logs to 0 (because
atoll() returns 0 if the string doesn't contain a number!)

It turns out that most of our option processing uses VG_(strtoll*) instead
of VG_(atoll).  The reason that not all of it does is that the
option-processing macros are underpowered -- they currently work well if you
just want to assign the value to a variable, eg:

        VG_BOOL_CLO(arg, "--heap",   clo_heap)
   else VG_BOOL_CLO(arg, "--stacks", clo_stacks)

   else VG_NUM_CLO(arg, "--heap-admin", clo_heap_admin)
   else VG_NUM_CLO(arg, "--depth",      clo_depth)

(This works because they are actually an if-statement, but it looks odd.)

VG_NUM_CLO uses VG_(stroll10).  But if you want to do any checking or
processing, you can't use those macros, leading to code like this:

      else if (VG_CLO_STREQN(9,  arg, "--log-fd=")) {
         log_to            = VgLogTo_Fd;
         VG_(clo_log_name) = NULL;
         tmp_log_fd        = (Int)VG_(atoll)(&arg[9]);
      }

So this commit:
- Improves the *_CLO_* macros so that they can be used in all circumstances.
  They're now just expressions (albeit ones with side-effects, setting the
  named variable appropriately).  Thus they can be used as if-conditions,
  and any post-checking or processing can occur in the then-statement.  And
  malformed numeric arguments (eg. --log-fd=foo) aren't accepted.  This also
  means you don't have to specify the lengths of any option strings anywhere
  (eg.  the 9 in the --log-fd example above).  The use of a wrong number
  caused at least one bug, in Massif.
- Updates all places where the macros were used.
- Updates Helgrind to use the *_CLO_* macros (it didn't use them).
- Updates Callgrind to use the *_CLO_* macros (it didn't use them), except
  for the more esoteric option names (those with numbers in the option
  name).  This allowed getUInt() and getUWord() to be removed.
- Improves the cache option parsing in Cachegrind and Callgrind -- now uses
  VG_(strtoll10)(), detects overflow, and is shorter.
- Uses INT instead of NUM in the macro names, to distinguish better vs. the
  DBL macro.
- Removes VG_(atoll*) and the few remaining uses -- they're wretched
  functions and VG_(strtoll*) should be used instead.
- Adds the VG_STREQN macro.
- Changes VG_BINT_CLO and VG_BHEX_CLO to abort if the given value is outside
  the range -- the current silent truncation is likely to cause confusion as
  much as anything.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9255
2009-02-25 01:01:05 +00:00
Bart Van Assche
c717c5071d Declared those function arguments that are not modified as const.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9245
2009-02-23 19:12:02 +00:00
Nicholas Nethercote
cfb40cbf6f Add missing __extension__ markings on a couple of clreqs.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9230
2009-02-23 02:08:24 +00:00
Nicholas Nethercote
13c8106f4f - Add 'unit_libcbase', the beginnings of a unit test module for m_libcbase.
- Rename 'oset_test' as 'unit_oset' to make its meaning more clear.
- Remove VG_(atoll36), VG_(strtoll8)() and VG_(strtoll36)();  they're not
  used and so untested, but easy to crib from similar functions if they need
  to be added again later.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9204
2009-02-20 06:10:44 +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
a8c9970a34 Cleaned up the mess that was the treatment of "below main" functions such as
'__libc_start_main', in Massif, m_debuginfo and m_stacktrace.  As part of
this, --show-below-main is now visible to tools, and Massif pays attention
to it.

Improved the description of --show-below-main=yes in the manual.

Replaced some instances of "__libc_start_main" in the test *.exp files with
"(below main)", which is what will actually be seen.  Also updated
scalar.stderr.exp*, which should make it get closer to actually passing.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9131
2009-02-10 06:48:00 +00:00
Nicholas Nethercote
947f9faaba Merge part of r9129 (factor out duplicated Z-encodings of names) from the
DARWIN branch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9130
2009-02-10 04:23:41 +00:00
Nicholas Nethercote
5ad1dd61f9 Introduce a new type, PtrdiffT. Replace lots of uses of OffT (all those
that are memory offsets) with PtrdiffT;  OffT should only be used for file
sizes and offsets.

Change Off64T from a ULong to a Long, as it should be.  Replace some uses
of ULong in the address space manager with Off64T to match.

Also add a comment explaining the meanings of the basic types like Addr,
OffT, SizeT, etc.

Also fix the prototype for VG_(pread) -- the last arg is an OffT, not an
Int.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8959
2009-01-15 21:29:24 +00:00
Julian Seward
0707edc9a5 Unbreak the build on aix5.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8867
2008-12-23 02:09:17 +00:00
Julian Seward
ba2ece03b8 This commit subtly changes the meaning of the values obtained via the
stack unwind mechanism (the function VG_(record_ExeContext) et al),
clears up some associated kludges, and makes suppression matching work
more reliably.

Prior to this commit, a stack snapshot contained, at [0], the IP of
the relevant thread, and at all positions [1] and above, the return
addresses for the open calls.

When showing a snapshot to the user (in VG_(apply_StackTrace)), and
searching the stack for stack blocks (in VG_(get_data_description)), 1
is subtracted from positions [1] and above, so as to move these return
addresses back to the last byte of the calling instruction.  This
subtraction is also done even in VG_(get_StackTrace_wrk) itself, in
order to make the stack unwinding work at all.

It turns out that suppression-vs-function-name matching requires the
same hack, and sometimes failed to match suppressions that should
match, because of this self-same problem.

So the commit changes the stack unwinder itself, so that entries [1]
and above point to the last byte of the call instruction, rather than
the return address.  The associated kludges in VG_(apply_StackTrace)
and VG_(get_StackTrace_wrk) are removed, and suppression matching is
observed to work in a case where it failed before.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8818
2008-12-12 13:23:03 +00:00
Julian Seward
09dac86eca Add a new module, m_seqmatch, which does very simple sequence (regexp)
matching, in the function VG_(generic_match).  Patterns to be matched
against may contain only '*'-style wildcards (matches any number of
elements, we don't care what they are), '?' wildcards (matches exactly
one element, we don't care what it is) and literal elements.

It is totally abstractified, in the sense that the pattern and input
arrays may be arrays of anything.  The caller provides enough
information so that VG_(generic_match) can step along both arrays, and
can ask the questions "is this pattern element a '*' ?", "is this
pattern element a '?' ?", and "does this pattern element match an
input element ?".

The existing function VG_(string_match) is reimplemented using
VG_(generic_match), although the ability to escape metacharacters in
the pattern string is removed -- I don't think it was ever used.

In m_errormgr, matching of suppression stacks (including wildcard
"..." lines) against error stacks is re-implemented using
VG_(generic_match).

Further detailed comments are in m_seqmatch.h and pub_tool_seqmatch.h.

A negative side effect is that VG_(string_match) will be much slower
than before, due to the abstractification.  It may be necessary to
reimplement a specialised version later.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8816
2008-12-12 08:07:49 +00:00
Julian Seward
5aa3e073b7 * Add a VG_(sizeSWA) function
* Fix spacing a bit



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8808
2008-12-06 23:34:52 +00:00
Julian Seward
dee63731b9 Add a new container data type, a Sparse Word Array: an array of UWord
which is also indexed by UWord.  This can be used as a replacement for
WordFM with unboxed keys, when the key ranges are dense.  It is
implemented as a 256-way radix tree (4-deep on 32-bit platforms,
8-deep on 64-bit platforms).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8806
2008-12-06 22:07:35 +00:00
Julian Seward
a6613bcb2b Change the memory allocation strategy used by the conflicting-access
machinery, so as to allocate fewer chunks of memory.  This increases
the speed of Helgrind by about 10% on some apps, which probably means
the conflicting-access machinery itself is about 20% faster.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8803
2008-12-03 11:39:37 +00:00
Julian Seward
3b60492dc1 Add a comment re VG_(expand_file_name).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8773
2008-11-17 12:45:01 +00:00
Julian Seward
24917a1daa Add performance comments to VG_(sizeFM), and add new method
VG_(isEmptyFM), currently commented out.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8765
2008-11-13 13:17:06 +00:00
Julian Seward
3a2fbbfafd Add ioctl wrappers for Linux wireless extensions version 22.
Patch from Gwenael Lambrouin.  Fixes #159452.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8734
2008-11-05 16:59:55 +00:00
Julian Seward
f4bffe6909 Support sys_pipe2 on {amd64,x86}-linux. Also, update syscall numbers
for all supported Linuxes to those in linux-2.6.28-rc3.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8730
2008-11-05 11:20:59 +00:00
Julian Seward
e9c7a88688 Update the C++ demangler to that from libiberty in the gcc svn trunk,
rev 141363.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8710
2008-10-26 11:53:30 +00:00
Julian Seward
35c28b721f Merge Helgrind from branches/YARD into the trunk. Also includes some
minor changes to make stack unwinding on amd64-linux approximately
twice as fast as it was before.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8707
2008-10-25 16:22:41 +00:00
Julian Seward
c50d12960e get_Seg_containing_addr() (in h_main.c): remove naive algorithm that
searches through all live Segs and replace it with one which is O(log
N) in the number of live Segs.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8676
2008-10-18 19:55:31 +00:00
Nicholas Nethercote
0cf8a14c70 - Reinstate the 'atfork' from 2.4.0, which was more powerful, and expose it to
tools.
- Factor out 'execv' from 'system' and expose it to tools.

Partly based on a patch from Robert O'Callahan.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8669
2008-10-13 04:19:15 +00:00
Nicholas Nethercote
cc2603ae7a Patch from Robert O'Callahan:
create and expose 'dup2'


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8667
2008-10-12 19:53:28 +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
Julian Seward
9d24c252e1 Make VG_(addToXA) and VG_(addBytesToXA) 64-bit clean.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8525
2008-08-19 08:57:49 +00:00
Julian Seward
27b2106884 Move the WordFM (AVL trees of UWord-pairs) implementation from
helgrind/ into the core.  It's just too darn useful to not be in the
core.  There is some overlap in functionality between OSet and WordFM,
but OSet is more space efficient in some circumstances, whereas WordFM
is easier to use and a bit more flexible in some cases.

Also in this new module (m_wordfm) is a type WordBag, build on top of
WordFM.  This provides Multiset of UWords functionality.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8524
2008-08-19 08:38:52 +00:00
Julian Seward
e5150447d7 Presently, Valgrind (non-client) code that wants to use the stat
family of syscalls is impossible to write in a way that's portable and
correct.  On some targets (eg x86-linux) you need to do sys_stat64 and
receive the results in a 'struct vki_stat64'.  But on other targets
(eg amd64-linux) neither sys_stat64 nor 'struct vki_stat64' exist.

This commit adds a new type, 'struct vg_stat', which contains 64 bit
fields in all the right places, and makes VG_(stat) and VG_(fstat) use
it.  This means callers to the two functions no longer need to worry
about the is-it-64-bit-clean-or-not question, since these routines
reformat the received data into a'struct vg_stat'.  Kind of like what
glibc must have been doing for decades.

This (indirectly) fixes a bug on x86-linux, in which m_debuginfo would
sometimes fail to read debug info, due to VG_(di_notify_mmap) using
VG_(stat) (hence sys_stat) on the file, which failed, and when in fact
it should have used sys_stat64.  Bug reported and tracked down by
Marc-Oliver Straub.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8522
2008-08-19 07:03:04 +00:00