43 Commits

Author SHA1 Message Date
Mark Wielaard
3392155359 Upgrade to GNU General Public License version 3
- Update COPYING and VEX/LICENSE.GPL to version 3.
- Update README, NEWS, docs/manual license and contributing text.
- Update file headers to say either version 3 of the License,
  or (at your option) any later version.
- Leave tests and perf file headers as is, unless the code is derived
  from Valgrind/VEX.
- Leave valgrind.h, cachegrind.h, callgrind.h, drd.h, helgrind.h,
  memcheck.h and dhat.h Hybrid-BSD licensed.
2025-10-18 00:55:07 +02:00
Paul Floyd
dc1276745f Correct typos and spelling mistakes 2024-11-03 10:55:57 +01:00
Paul Floyd
036bf06734 Refactor: reorder a few structs to make them more compact
Used pahole to find candidates. Don't have any performance
measurements, but it won't do any harm.
2023-03-11 16:31:43 +01:00
Julian Seward
9dcd3ab1f6 Fix some spelling errors found by Lintian. Patch from Alessandro Ghedini <ghedo@debian.org>. 2020-01-23 10:53:36 +01:00
Mark Wielaard
461cc5c003 Cleanup GPL header address notices by using http://www.gnu.org/licenses/
Sync VEX/LICENSE.GPL with top-level COPYING file. We used 3 different
addresses for writing to the FSF to receive a copy of the GPL. Replace
all different variants with an URL <http://www.gnu.org/licenses/>.

The following files might still have some slightly different (L)GPL
copyright notice because they were derived from other programs:

- files under coregrind/m_demangle which come from libiberty:
  cplus-dem.c, d-demangle.c, demangle.h, rust-demangle.c,
  safe-ctype.c and safe-ctype.h
- coregrind/m_demangle/dyn-string.[hc] derived from GCC.
- coregrind/m_demangle/ansidecl.h derived from glibc.
- VEX files for FMA detived from glibc:
  host_generic_maddf.h and host_generic_maddf.c
- files under coregrin/m_debuginfo derived from LZO:
  lzoconf.h, lzodefs.h, minilzo-inl.c and minilzo.h
- files under coregrind/m_gdbserver detived from GDB:
  gdb/signals.h, inferiors.c, regcache.c, regcache.h,
  regdef.h, remote-utils.c, server.c, server.h, signals.c,
  target.c, target.h and utils.c

Plus the following test files:

- none/tests/ppc32/testVMX.c derived from testVMX.
- ppc tests derived from QEMU: jm-insns.c, ppc64_helpers.h
  and test_isa_3_0.c
- tests derived from bzip2 (with embedded GPL text in code):
  hackedbz2.c, origin5-bz2.c, varinfo6.c
- tests detived from glibc: str_tester.c, pth_atfork1.c
- test detived from GCC libgomp: tc17_sembar.c
- performance tests derived from bzip2 or tinycc (with embedded GPL
  text in code): bz2.c, test_input_for_tinycc.c and tinycc.c
2019-05-26 20:07:51 +02:00
Ivo Raisr
38edd50c0e Update copyright end year to 2017 in preparation for 3.13 release.
n-i-bz



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16333
2017-05-04 15:09:39 +00:00
Philippe Waroquiers
7ac00163a3 fix 369468 Remove quadratic metapool alg. using VG_(HT_remove_at_Iter)(VgHashTable *table)
Based on a patch from Ruurd Beerstra
but reworked VG_(HT_remove_at_Iter) so that
the function is implemented without touching the rest of m_hashtable.c
to ensure no performance impact on other hash table usages.

Testing with
for f in 1 2 3 4 5 6 7 8 9; do echo $f;  time ./vg-in-place -q ./memcheck/tests/leak-autofreepool 2 $(expr $f \* 100000); done|&grep user

With the patch :
user	0m0.524s
user	0m0.660s
user	0m0.784s
user	0m0.916s
user	0m1.064s
user	0m1.192s
user	0m1.316s
user	0m1.496s
user	0m1.632s

Without the patch, the same gives:
user	0m4.464s
user	0m16.776s
user	0m24.472s
user	1m5.544s
user	1m21.168s
user	1m40.500s
user	1m54.884s
user	4m58.308s
user	5m34.060s



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16041
2016-10-15 09:30:39 +00:00
Julian Seward
adc2dafee9 Update copyright dates, to include 2015. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15577
2015-08-21 11:32:26 +00:00
Florian Krohm
e56a4a50df Fix printf format inconsistencies as pointed out by gcc -Wformat-signedness.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15499
2015-08-05 21:16:09 +00:00
Florian Krohm
7bd7811604 The number of elements in a hash table cannot be negative.
Let the return type of VG_(HT_count_nodes) reflect that.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15490
2015-08-05 11:26:10 +00:00
Philippe Waroquiers
d117a8d8b0 Also compare keys before calling cmp in the hash table stats printing
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15268
2015-05-21 22:01:19 +00:00
Philippe Waroquiers
b09ffd9fb9 Have the hash table 'gen' functions comparing the key instead of the
cmp function.
Document this in the cmp function comment in pub_tool_hashtable.h



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15263
2015-05-20 15:08:09 +00:00
Philippe Waroquiers
0543df0e12 Give statistics about RCEC helgrind hash table chains.
Improve statistic in coregrind hash table


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15141
2015-04-25 14:00:24 +00:00
Florian Krohm
f5e2bdbddc Change the definition of VgHashTable to not have pointer type.
This is (a) consistent with how the other containers are defined
and, more importantly, (b) allows the constification of the hash table API.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14639
2014-10-18 10:58:05 +00:00
Philippe Waroquiers
bcd0b77c3b Improve/fix hash table collision statistics + remove useless space in gdbsrv hostvisibility keywork
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14053
2014-06-19 20:33:27 +00:00
Philippe Waroquiers
53df23f0a6 This patch adds a 'de-duplicating memory pool allocator':
include/pub_tool_deduppoolalloc.h
  coregrind/pub_core_deduppoolalloc.h
  coregrind/m_deduppoolalloc.c
and uses it (currently only) for the strings in m_debuginfo/storage.c
The idea is that such ddup pool allocator will also be used for other
highly duplicated information (e.g. the DiCFSI information), where
significant gains can also be achieved.
The dedup pool for strings also decreases significantly the memory
needed by the read inline information (patch still to be committed,
see bug 278972).

When testing with a big executable (tacot_process),
this reduces the size of the dinfo arena from
  trunk:  158941184/109760512  max/curr mmap'd, 156775944/107882728 max/curr,
to
  ddup:   157892608/106614784  max/curr mmap'd, 156362160/101414712 max/curr

(so 3Mb less mmap-ed once debug info is read, 1Mb less mmap-ed in peak,
6Mb less allocated once debug info is read).

This is all gained due to the string which changes from:
  trunk:   17,434,704 in       266: di.storage.addStr.1
to
  ddup:    10,966,608 in       750: di.storage.addStr.1
(6.5Mb less memory used by strings)
The gain in mmap-ed memory is smaller due to fragmentation.
Probably one could decrease the fragmentation by using bigger
size for the dedup pool, but then we would lose memory on the last
allocated pool (and for small libraries, we often do not use much
of a big pool block).
Solution might be to increase the pool size but have a "shrink_block"
operation. To be looked at in the future.

In terms of performance, startup of a big executable (on an old pentium)
is not influenced significantly (something like 0.1 seconds on 15 seconds
startup for a big executable, on a slow pentium).

The dedup pool uses a hash table. The hash function used currently
is the VG_(adler32) check sum. It is reported (and visible also here)
that this checksum is not a very good hash function (many collisions).

To have statistics about collisions, use  --stats -v -v -v

As an example of the collisions, on the strings in debug info of memcheck tool on x86,
one obtain:
   --4789-- dedupPA:di.storage.addStr.1 9983 allocs (8174 uniq) 11 pools (4820 bytes free in last pool)
   --4789-- nr occurences of chains of len N, N-plicated keys, N-plicated elts
   --4789-- N: 0 : nr chain   6975, nr keys      0, nr elts      0
   --4789-- N: 1 : nr chain   3670, nr keys   6410, nr elts   8174
   --4789-- N: 2 : nr chain   1070, nr keys    226, nr elts      0
   --4789-- N: 3 : nr chain    304, nr keys    100, nr elts      0
   --4789-- N: 4 : nr chain    104, nr keys     84, nr elts      0
   --4789-- N: 5 : nr chain     72, nr keys     42, nr elts      0
   --4789-- N: 6 : nr chain     44, nr keys     34, nr elts      0
   --4789-- N: 7 : nr chain     18, nr keys     13, nr elts      0
   --4789-- N: 8 : nr chain     17, nr keys      8, nr elts      0
   --4789-- N: 9 : nr chain      4, nr keys      6, nr elts      0
   --4789-- N:10 : nr chain      9, nr keys      4, nr elts      0
   --4789-- N:11 : nr chain      1, nr keys      0, nr elts      0
   --4789-- N:13 : nr chain      1, nr keys      1, nr elts      0
   --4789-- total nr of unique   chains:  12289, keys   6928, elts   8174
which shows that on 8174 different strings, we have only 6410 strings which have
a unique hash value. As other examples, N:13 line shows we have 13 strings
mapping to the same key. N:14 line shows we have 4 groups of 10 strings mapping to the
same key, etc.
So, adler32 is definitely a bad hash function.
Trials have been done with another hash function, giving a much lower
collision rate. So, a better (but still fast) hash function would probably
be beneficial. To be looked at ...




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14029
2014-06-14 16:30:09 +00:00
Julian Seward
dbf9b63605 Update copyright dates (20XY-2012 ==> 20XY-2013)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13658
2013-10-18 14:27:36 +00:00
Florian Krohm
5337376bf2 More Char/HChar fixes and constification.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13088
2012-10-27 18:39:11 +00:00
Julian Seward
4a3633e266 Update copyright dates to include 2012.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12843
2012-08-05 15:46:46 +00:00
Philippe Waroquiers
be97cddd7a Fixes 282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit
* new files include/pub_tool_groupalloc.h and coregrind/m_groupalloc.c
  implementing a group allocator (based on helgrind group alloc).
* include/Makefile.am coregrind/Makefile.am : added pub_tool_groupalloc.h
  and m_groupalloc.c
* helgrind/libhb_core.c : use pub_tool_groupalloc.h/m_groupalloc.c
  instead  of the local implementation.
* include/pub_tool_oset.h coregrind/m_oset.c : new function
  allowing to create an oset that will use a pool allocator.
  new function allowing to clone an oset (so as to share the pool alloc)
* memcheck/tests/unit_oset.c drd/tests/unit_bitmap.c : modified
  so that it compiles with the new m_oset.c
* memcheck/mc_main.c : use group alloc for MC_Chunk
  memcheck/mc_include.h : declare the MC_Chunk group alloc
* memcheck/mc_main.c : use group alloc for the nodes of the secVBitTable OSet
* include/pub_tool_hashtable.h coregrind/m_hashtable.c : pass the free node
  function in the VG_(HT_destruct).
  (needed as the hashtable user can allocate a node with its own alloc,
  the hash table destroy must be able to free the nodes with the user
  own free).
* coregrind/m_gdbserver/m_gdbserver.c : pass free function to VG_(HT_destruct)
* memcheck/mc_replace_strmem.c memcheck/mc_machine.c
  memcheck/mc_malloc_wrappers.c memcheck/mc_leakcheck.c
  memcheck/mc_errors.c memcheck/mc_translate.c : new include needed
  due to group alloc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12341
2012-01-17 21:16:30 +00:00
Julian Seward
c96096ab24 Update all copyright dates, from 20xy-2010 to 20xy-2011.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12206
2011-10-23 07:32:08 +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
Nicholas Nethercote
6fd1b000e4 Allow custom blocks to overlap with malloc blocks. Fixes bug 100628.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10765
2009-08-10 07:36:54 +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
2001629c3f Updated copyright years.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9344
2009-03-10 22:02:09 +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
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
0e70d01bdd 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.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6778
2007-08-25 07:19:08 +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
55f1835953 Change authorship.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6293
2006-10-17 02:11:55 +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
Julian Seward
008262dd17 Fix read-after-free in VG_(HT_destruct). This fixes
memcheck/tests/mempools.  Thanks to Jeroen Witmond for tracking it
down.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5429
2005-12-24 15:33:32 +00:00
Nicholas Nethercote
4f064ec81b Added an iterator to VgHashTable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4407
2005-08-14 17:42:35 +00:00
Nicholas Nethercote
5d07a9ad26 Changed many, but not all, of the VgHashNode* parameters and return
types in m_hashtable.c to void*.  This requires no changes to code
already using VgHashTables, but it allows some previously-required casts
to be removed.  I also changed Memcheck and Massif by removing some of
these now-unnecessary casts.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4404
2005-08-14 06:24:20 +00:00
Nicholas Nethercote
7f8c275c59 Give variable a better name.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4378
2005-08-11 00:06:36 +00:00
Nicholas Nethercote
e67b65d0eb Changed m_hashtable.c to allow the size of the hash table to be specified
when it is created.  Fortunately this didn't affect code outside this
module except for the calls to VG_(HT_construct)().

As a result, we save some memory because not all tables have to be as big
as the ones needed for malloc/free tracking.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4100
2005-07-03 17:53:11 +00:00
Nicholas Nethercote
dd80a229b4 whoops
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4099
2005-07-03 17:10:04 +00:00
Nicholas Nethercote
f174930b23 Final commit for the initial modularisation pass:
- Broke part of m_scheduler off into a new module m_threadstate.  It
  contains ThreadState, VG_(threads)[] and some basic operations on the
  thread table.  All simple stuff, the complex stuff stays in m_scheduler.
  This avoids lots of circular dependencies between m_scheduler and other
  modules.

- Managed to finally remove core.h and tool.h, double hurrah!

- Introduced pub_tool_basics.h and pub_core_basics.h, one of which is
  include by every single C file.

- Lots of little cleanups and changes related to the above.

- I even did a small amount of documentation updating.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3944
2005-06-19 01:24:32 +00:00
Nicholas Nethercote
38d2799b5b 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.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3881
2005-06-11 01:31:52 +00:00
Nicholas Nethercote
eb2d0a7d06 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.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3842
2005-06-04 19:16:06 +00:00
Julian Seward
a548e818d0 A 4999 entry hashtable is too small when there are a huge number (500k
ish) of blocks simultaneously live, and the client is doing intensive
malloc/frees.  Increase the table size 16-fold.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3752
2005-05-17 02:20:35 +00:00
Nicholas Nethercote
92c61a5fd1 Don't mix backticks and apostrophes when quoting words -- eg. use 'foo'
rather than `foo', as www.cl.cam.ac.uk/~mgk25/ucs/quotes.html explains
we should (in more detail than you'd imagine was possible).  I did this
both in output messages and in some comments, for consistency.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3723
2005-05-15 17:28:26 +00:00
Nicholas Nethercote
357303aebf Modularised vg_hashtable.c as m_hashtable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3710
2005-05-14 21:28:43 +00:00