46 Commits

Author SHA1 Message Date
Florian Krohm
778fe51a69 testsuite: Tidy. Remove empty .stdout.exp files
As per tests/vg_regtest:

 Expected stdout (filtered) is kept in <test>.stdout.exp* (can be more
 than one expected output).  It can be missing if it would be empty.
2025-12-13 18:37:27 +00:00
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
Mark Wielaard
757dc5703d Update where to get a copy of the GNU General Public License
Several files still said to write to the Free Software Foundation at a
particular address. Add a reference to <http://www.gnu.org/licenses/>
instead.

Some files that were imported into valgrind from other places still
mention the old address. They should be updated when new versions
get imported.
2025-10-18 00:55:07 +02:00
Mark Wielaard
d216fff966 Update emitted Copyright years to include 2024
Also adjust test exp and filters.
2024-04-20 04:13:04 +02:00
Paul Floyd
cc1aed1ce2 DHAT: only handle own user reqs, ignore others
Make other tools consistent with this as well
(using memcheck as the model). Also refactored
the DRD user req names to make it clearer which
are Valgrind user reqs, which are DRD public
user reqs and which are DRD internal user reqs.
2023-10-09 23:23:03 +02:00
Paul Floyd
a265a20620 Add memcheck errors for aligned and sized allocations and deallocations
Bug 433857 Add validation to C++17 aligned new/delete alignment size
Bug 433859 Add mismatched detection to C++ 17 aligned new/delete
Bug 466105 aligned_alloc problems, part 2
Bug 467441 Add mismatched detection to C++ 14 sized delete

Memcheck now tests and warns about the values used for
alignment and size. These apply to various functions: memalign,
posix_memalign and aligned_alloc in C and various overloads
of operators new and delete in C++. The kinds of error that can
be detected are
- invalid alignment, for instance the alignment is usually required
  to be a power of 2
- mismatched alignment between aligned allocation and aligned
  deallocation
- mismatched size when sized delete is used
- bad size for functions that have implementation defined behaviour
  when the requested size is zero

An example of the new errors is:

int *pi = memalign(31, 100);

which will generate the following error

==96206== Invalid alignment value: 31 (should be power of 2)
==96206==    at 0x485195E: memalign (vg_replace_malloc.c:1886)
==96206==    by 0x20200E: main (memalign.c:59)
2023-09-02 16:12:35 +02:00
Paul Floyd
be26a1773e dhat: remove initial count value from access count histogram user requests
Based on feedback from Nick Nethercote.
2023-04-27 09:29:44 +02:00
Paul Floyd
3b93737876 regtest: add C++11 flag to build of user_histo1.cpp
For old compilers that don't default to C++11 or later
2023-04-22 09:38:35 +02:00
Paul Floyd
f5416b5edd regtest: dhat/tests/user_histo1 filter out summary
Too system dependent.
2023-04-21 23:35:37 +02:00
Paul Floyd
577912e62c regtest: add another expected for dhat/tests/user_histo1 2023-04-21 23:17:32 +02:00
Paul Floyd
869e6e28b1 regtest: filter error address from dhat/tests/user_histo1 2023-04-21 23:10:51 +02:00
Paul Floyd
dc5209d42b Add missing user_histo1.stdout.exp to EXTRA_DIST 2023-04-21 22:57:09 +02:00
Paul Floyd
424340403c Bug 464103 - Enhancement: add a client request to DHAT to mark memory to be histogrammed 2023-04-21 21:21:23 +02:00
Paul Floyd
50bded71b2 Bug 436413 - Warn about realloc of size zero
Adds a new warning to memcheck when realloc is used with a size of 0.
For a long time this has been "implementation defined" and so
non-portable. With C23 it will become UB.

Also adds a switch to turn off the error generation and a
second switch to select between the most common
"implementation" behaviours. The defaults for this second
switch are baked in at build time.
2023-03-10 21:55:14 +01:00
Julian Seward
394ca9b400 Remove a debugging line if (0) .. that mistakenly got landed in fa3a9cc43c. 2023-01-04 17:43:21 +01:00
Julian Seward
fa3a9cc43c DHAT: increase the size of the cache for find_Block_containing from 2 to 3.
In the hope of making DHAT a bit faster.
2023-01-04 15:38:12 +01:00
Paul Floyd
4fb52a67b5 Cleanup of str* and mem* functions
Add function checks to configure.ac
Use the configure HAVE_ macro rather than OS-dependent tests.
I suspect that a lot of the tests hve been obsolete for many
years. Add wrappers to FreeBSD.
:w
2022-06-01 22:09:50 +02:00
Paul Floyd
33aba8eef6 Bug 444495 - dhat/tests/copy fails on s390x
Add -fno-builtin to ensure that the copy functions get called and so dhat
can intercept and count them.
2021-10-27 21:37:00 +02:00
Mark Wielaard
bfd28bb9f8 Remove more warnings from tests
GCC12 catches various issues in tests at compile time that we want to
catch at runtime. Also glibc 2.34 deprecated various mallinfo related
functions. Add the relevant -Wno-foobar flags to those tests.  In one
case, unit_oset.c, the warning was correct and the uninitialized
variable was explicitly set.
2021-10-10 17:19:34 +02:00
Mark Wielaard
4015813336 Remove some warnings from tests
Various tests do things which we want to detect at runtime, like
ignoring the result of malloc or doing a deliberate impossibly large
allocation or operations that would result in overflowing or
truncated strings, that generate a warning from gcc.

In once case, mq_setattr called with new and old attrs overlapping,
this was explicitly fixed, in others -Wno-foobar was added to silence
the warning. This is safe even for older gcc, since a compiler will
ignore any -Wno-foobar they don't know about - since they do know they
won't warn for foobar.
2021-10-10 15:56:50 +02:00
Paul Floyd
53dd9bd255 FreeBSD support, patch 9
cachegrind callgrind dhat exp-bbv gdbserver_tests massif none mpi shared

Mostly these are just updates (and new testcases) under new/tests
The other directories have just #ifdef changes
2021-10-07 22:41:22 +02:00
Paul Floyd
e531f994c6 Two fixes for Darwin 'make check'
mempcpy is not available on Darwin, so make it conditional like Solaris.

also sys/auxv.h does not exist so make including it conditional.
2021-03-17 09:12:21 +01:00
Paul Floyd
e42badd060 Bug 388787 - Support for C++17 new/delete
These over-aligned new and delete operators were added in C++ 17.
2021-03-02 13:32:22 +01:00
Paul Floyd
a86016fc22 Fix dhat/tests/copy on Solaris 2020-12-08 21:29:43 +01:00
Mark Wielaard
419d7cddca dhat/tests/Makefile.am: Add filter_copy to dist_noinst_SCRIPTS
Make sure that make dist includes all needed test filters.
2020-12-08 12:00:49 +01:00
Nicholas Nethercote
8c08253b89 Add support for copy and ad hoc profiling to DHAT. 2020-12-07 19:57:56 +11:00
Nicholas Nethercote
48ba17f87d Fix an obscure problem with peak finding.
Currently, if there are multiple equal global peaks, `intro_Block` and
`resize_Block` record the first one while `check_for_peak` records the
last one. This could lead to inconsistent output, though it's unlikely
in practice.

This commit fixes things so that all functions record the last peak.
2020-12-01 13:46:25 +11:00
Mark Wielaard
a489f40f78 docs: Make sure all elements that need it have an id tag.
When generating HTML it is useful if every element that can be referenced
has a stable id. If it doesn't a random one is generated which makes it
harder to link to parts of the manual on the website. It also generates
spurious diffs. Explicitly add an id tag for the sect2 and sect3 elements
in dh-manual, a unique id for each legalnotice element and for each
FAQ question and answer.
2020-06-09 11:23:46 +02:00
Mark Wielaard
555ddc4753 Use DTD DocBook XML V4.5 everywhere.
This makes the rule for xmllint easier since it doesn't need to
override the DTD to validate against. It also helps with other tools
tryinf to process the docbookx xml files.
2020-05-14 15:12:02 +02:00
Mark Wielaard
c0916494f6 docbook xml doesn't allow xref inside option, use link instead 2020-05-14 12:43:39 +02:00
Mark Wielaard
9a79b194f2 dh-manual.xml: Don't use computeroutput in title.
It seems legal docbook, but it crashes our xsltproc/pdfxmltex toolchain.
2020-05-13 16:43:51 +02:00
Mark Wielaard
53dd0183d8 dh-manual.xml: Put stray text before graphic in a para. 2020-05-13 15:52:32 +02:00
Mark Wielaard
7425c1bc96 dh-manual.xml: Remove duplicate dh-manual.options id.
Rename one to dh-manual.realloc.
2020-05-13 15:15:45 +02:00
Nicholas Nethercote
968bddcd4b Fix reads and writes counts in DHAT.
If you do `malloc(100)` followed by `realloc(200)`, DHAT now adds 100
bytes to the read and write counts for the implicit `memcpy`. This gives
more reasonable results.

I have long been surprised by low writes-per-byte values of around 0.35
for vectors that are grown by doubling. Counting the implicit `memcpy`
increases those numbers to well above 0.5, which is what you'd expect.

The commit also adds a section to the DHAT docs about `realloc`, because
there is some non-obvious behaviour, some of which confused me just a
couple of days ago.
2020-05-08 08:40:19 +10: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
Philippe Waroquiers
b4403d38c7 Fix minor leaks in dhat.
Only leaks in dh_fini, and only once.
But fixing these leaks is easier than maintain suppression entries.
2019-04-18 20:41:44 +02:00
Mark Wielaard
4960f47c7d dhat is broken on x86 (32bit)
dhat will crash on x86 (32bit) because it doesn't handle Vg_CoreClientReq
in its track_post_mem_write.

dh_handle_noninsn_write will be called with Vg_CoreClientReq during
shutdown when trying to setup an argument for the freeres_wrapper().
On other architectures this will be done through a register, but on
x86 we setup the argument on the stack. See final_tidyup () in
coregrind/m_main.c.

Just handle it like a syscall memory argument write.

https://bugs.kde.org/show_bug.cgi?id=406354
2019-04-10 17:06:55 +02:00
Julian Seward
b7c807f584 Finalise wording w.r.t. the MPL. 2019-04-08 07:18:55 +02:00
Nicholas Nethercote
b71265fbc9 Mention --num-callers more in DHAT docs. 2019-04-08 10:18:38 +10:00
Mark Wielaard
8a97bdbb1b Install dhat viewer files in libexec.
libexec seems a better location than libdir. libexec is for internal
binaries or scripts that are not intended to be executed directly.

If we want to change the location again it is now simple.
Just change the dhat/Makefile.am dhatdir variable.
2019-04-08 00:02:21 +02:00
Julian Seward
6b054f132c DHAT: when the run ends, print a how-to-view-the-profile hint message. n-i-bz.
The aim is to make it zero-effort for users to view the profile after
a run.  The printed message is as follows:

  To view the resulting profile, open
    file:///path/to/valgrind/installation/lib/valgrind/dh_view.html
  in a web browser, click on "Load..." and then select the file
    /path/to/dhat.out.12345
  Scroll to the end the displayed page to see a short
  explanation of some of the abbreviations used in the page.

This patch adds printing of the message, then filters it out in
dhat/tests/filter_stderr, and updates the .stderr.exp files to
remove blank lines.
2019-04-04 12:08:26 +02:00
Julian Seward
e125eb3931 Make the DHAT viewer components be copied into the distribution tarball. Followup to 441bfc5f51 (dhat overhaul). 2019-02-03 10:31:15 +01:00
Julian Seward
15ac949bef Make the DHAT viewer components be copied into the install tree. Followup to 441bfc5f51 (dhat overhaul). 2019-02-03 10:06:36 +01:00
Nicholas Nethercote
7e5fc882e9 Remove reference to non-existent *.post.exp files in dhat/tests/. 2019-02-02 07:41:02 +11:00
Nicholas Nethercote
f71002f1b5 Add missing stuff for a DHAT test. 2019-02-01 15:08:31 +11:00
Nicholas Nethercote
441bfc5f51 Overhaul DHAT.
This commit thoroughly overhauls DHAT, moving it out of the
"experimental" ghetto. It makes moderate changes to DHAT itself,
including dumping profiling data to a JSON format output file. It also
implements a new data viewer (as a web app, in dhat/dh_view.html).

The main benefits over the old DHAT are as follows.

- The separation of data collection and presentation means you can run a
  program once under DHAT and then sort the data in various ways. Also,
  full data is in the output file, and the viewer chooses what to omit.

- The data can be sorted in more ways than previously. Some of these
  sorts involve useful filters such as "short-lived" and "zero reads or
  zero writes".

- The tree structure view avoids the need to choose stack trace depth.
  This avoids both the problem of not enough depth (when records that
  should be distinct are combined, and may not contain enough
  information to be actionable) and the problem of too much depth (when
  records that should be combined are separated, making them seem less
  important than they really are).

- Byte and block measures are shown with a percentage relative to the
  global count, which helps gauge relative significance of different
  parts of the profile.

- Byte and blocks measures are also shown with an allocation rate
  (bytes and blocks per million instructions), which enables comparisons
  across multiple profiles, even if those profiles represent different
  workloads.

- Both global and per-node measurements are taken at the global heap
  peak ("At t-gmax"), which gives Massif-like insight into the point of
  peak memory use.

- The final/liftimes stats are a bit more useful than the old deaths
  stats. (E.g. the old deaths stats didn't take into account lifetimes
  of unfreed blocks.)

- The handling of realloc() has changed. The sequence `p = malloc(100);
  realloc(p, 200);` now increases the total block count by 2 and the
  total byte count by 300. Previously it increased them by 1 and 200.
  The new handling is a more operational view that better reflects the
  effect of allocations on performance. It makes a significant
  difference in the results, giving paths involving reallocation (e.g.
  repeated pushing to a growing vector) more prominence.

Other things of note:

- There is now testing, both regression tests that run within the
  standard test suite, and viewer-specific tests that cannot run within
  the standard test suite. The latter are run by loading
  dh_view.html?test=1 in a web browser.

- The commit puts all tool lists in Makefiles (and similar files) in the
  following consistent order: memcheck, cachegrind, callgrind, helgrind,
  drd, massif, dhat, lackey, none; exp-sgcheck, exp-bbv.

- A lot of fields in dh_main.c have been given more descriptive names.
  Those names now match those used in dh_view.js.
2019-02-01 14:54:34 +11:00