16800 Commits

Author SHA1 Message Date
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
Julian Seward
3415e1e1ac Bug 401416 - Compile failure with openmpi 4.0.
In short, use the missing symbol names only when compiling against OpenMPI
version 3 or below, or when compiling against a non-OpenMPI implementation.
Modified version of a patch originally from Mark Wielaard.
2021-03-17 08:10:49 +01:00
Mark Wielaard
3751e963fa Add memcheck/tests/linux/debuginfod-check.pl to EXTRA_DIST
debuginfod-check.pl is necessary as pre-check for make regtest.
2021-03-15 15:47:54 +01:00
Julian Seward
d695fb68e5 -> 3.17.0.RC1 2021-03-13 20:52:01 +01:00
Julian Seward
a049da18b3 amd64 front end: try to avoid a Memcheck false positive related to CPUID. n-i-bz.
In the amd64 front end, CPUID is implemented by calling dirty helper.  The way
the side-effects for this call are declared can lead to false positives from
Memcheck.  This is a somewhat inelegant "fix", but it's the least-worst that
can be done without changing parameter-passing for the helper functions
involved.  A big in-line comment explains the problem and fix.
2021-03-13 19:20:50 +01:00
Julian Seward
2157125296 mc_translate.c: enable further uses of DLexpensive for scalar EQ/NE comparisons
mc_translate.c: enable further cases where scalar integer EQ/NE comparisons
use expensive instrumentation by default:

  x86, amd64  for 16-bit comparisons
  arm, arm64  for 32-bit comparisons

This fixes 'Bug 434193 - GCC 9+ inlined strcmp causes "Conditional jump or move depends on
uninitialised value" report'.

Patch from Mike Crowe <mac@mcrowe.com>.
2021-03-12 17:59:01 +01:00
Andreas Arnez
ce4b0e0677 s390x: Update "reading material" in README.s390
Update the links to the z/Architecture and the s390x ABI.
2021-03-10 19:16:18 +01:00
Andreas Arnez
6ed09a6603 s390x: Improve isel for Iop_V128to64 and friends
The existing instruction selector for Iop_V128to64, Iop_V128HIto64, and
Iop_V128to32 stores the vector register on the stack and then reads the
requested integer value back from the stack into the target GPR.  This is
fairly inefficient.

Load the requested value directly from the vector register into the target
GPR instead, using S390_VEC_GET_ELEM.
2021-03-10 17:40:58 +01:00
Andreas Arnez
19dc8c467e s390x: Fix printing wrong/no vector registers in disassembler
A typo in s390_disasm.c causes some vector registers to be printed wrong,
or not at all.  This is fixed.
2021-03-09 19:13:37 +01:00
Mark Wielaard
0f0205f683 vgdb might crash if valgrind is killed
This is an odd corner case, but happens specifically with the gdb
testcase make check TESTS=gdb.base/valgrind-infcall-2.exp. At the
end valgrind gets killed with SIGKILL (-9) which cannot be blocked.
But vgdb at the time is inside waitstopped. It sees the process wasn't
exited (WIFEXITED(status) is false) and so assumes the process was
stopped by a signal. Which it asserts:

      assert (WIFSTOPPED(status));
      signal_received = WSTOPSIG(status);
      if (signal_received == signal_expected)
         break;

But the assert fails and vgdb dumps core. The gdb testcase doesn't care,
because it already finished its test and just makes sure all processes
are gone. But it slowly fills your disk with core files (if you have
enabled them) when running the testsuite.

The fix is to simply check first whether the program has termined
normally or by getting a fatal signal.

https://bugs.kde.org/show_bug.cgi?id=434035
2021-03-09 18:51:57 +01:00
Andreas Arnez
484b7dd1e8 Bug 430429 - s390x: Fix clang compile error in valgrind.h
It has been observed that clang emits an error in valgrind.h for the macro
VALGRIND_DO_CLIENT_REQUEST_EXPR:

 "[...] unsupported inline asm: input with type 'int' matching output with
 type 'volatile unsigned long'"

Fix this with an explicit cast of the input to 'unsigned long int.'

The patch has been suggested by Jonathan Albrecht.
2021-03-09 17:36:12 +01:00
Balint Reczey
8b1961511c Don't look for debug alt file in debug image if it is already found
With dwz the .gnu_debuglink section may appear duplicated in the
debug file referenced originally in the .gnu_debuglink section.

https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1848211

https://bugs.kde.org/show_bug.cgi?id=396656
https://bugs.kde.org/show_bug.cgi?id=427969

Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
2021-03-09 16:38:15 +01:00
Philippe Waroquiers
c79180a3af Fix nlcontrolc.vgtest hanging on newer glibc and/or arm64
This test verifies that GDB can interrupt a process with all threads
blocked in a long select syscall.
The test used to terminate by having GDB modifying the select argument.
However, modifying the select argument works only for specific arch
and/or specific versions of glibc.
The test then blocks on other architectures/glibc versions.

The previous version of the test was:
  * first launching sleepers so as to have all threads blocked in long select
  * interrupting these threads
  * changing the select time arg so that the threads burn cpu
  * and then change variables to have the program exit.

The new version does:
  * first launches sleepers so that all threads are burning cpu.
  * interrupting these threads
  * change the local variables of sleepers so that the threads will
    block in a long select syscall
  * interrupt these threads
  * kill the program.

With this new version, we still check the behaviour of gdb+vgdbserver
for both burning and sleep threads, but without having the termination
depending on modifying select syscall argument.

Tested on debian amd64 and on ubuntu arm64 (to check the test does not hang
on an arm64 platform).
2021-03-07 22:35:58 +01:00
Julian Seward
2ab8ab38a3 Bug 432552 - [AArch64] invalid error emitted for pre-decremented byte and half-word addresses. 2021-03-05 09:38:30 +01:00
Carl Love
3c31707cd3 VSX Mask Manipulation operation tests. 2021-03-04 12:57:16 -06:00
Carl Love
82777ee408 ISA 3.1 VSX Mask Manipulation Operations
Add support for:

mtvsrbmMove to VSR Byte Mask
mtvsrbmiMove To VSR Byte Mask Immediate
mtvsrdmMove to VSR Doubleword Mask
mtvsrhmMove to VSR Halfword Mask
mtvsrqmMove to VSR Quadword Mask
mtvsrwmMove to VSR Word Mask
vcntmbbVector Count Mask Bits Byte
vcntmbdVector Count Mask Bits Doubleword
vcntmbhVector Count Mask Bits Halfword
vcntmbwVector Count Mask Bits Word
vexpandbmVector Expand Byte Mask
vexpanddmVector Expand Doubleword Mask
vexpandhmVector Expand Halfword Mask
vexpandqmVector Expand Quadword Mask
vexpandwmVector Expand Word Mask
vextractbmVector Extract Byte Mask
vextractdmVector Extract Doubleword Mask
vextracthmVector Extract Halfword Mask
vextractqmVector Extract Quadword Mask
vextractwmVector Extract Word Mask

Re-implemented the copy_MSB_bit_fields() function.  It can be done similarly to
the implementation of the vgnb instruction leveraging the clean helpers
used for the vgnb instruction.

Reimplemented the vexpandXm instructions eliminating
the call to copy_MSB_bit_fileds() and the need for the
for(i = 0; i< max; i++) loop.

Reimplemented the mtvsrXm instructions to remove the
need for the for(i = 0; i< max; i++) loop.

The computations for vexpandXm and mtvsrXm instructions
can be done much more efficiently.
2021-03-04 12:33:48 -06:00
Mark Wielaard
b92d30bb6d arm64: Handle sp, lr, fp as DwReg in CfiExpr
When copy_convert_CfiExpr_tree sees a DwReg on arm64 we simply call
I_die_here; This causes an issue in the case we really do have to handle
that case (see https://bugzilla.redhat.com/show_bug.cgi?id=1923493).

Handle the stack pointer (sp), link register (x30) and frame pointer (x29),
which we already keep in D3UnwindRegs, like we do for other architectures
in evalCfiExpr and copy_convert_CfiExpr_tree.

https://bugs.kde.org/show_bug.cgi?id=433898
2021-03-04 19:24:06 +01:00
Mark Wielaard
23223e28a5 Add an entry on the new --track-fds=all option to NEWS. 2021-03-03 16:02:33 +01:00
Paul Floyd
c136213d46 Keep on churning.
Without #define _XOPEN_SOURCE macports clang 9.0.1 on OSX 10.7.5 was
giving me

In file included from swapcontext.c:12:
/usr/include/ucontext.h:43:2: error: The deprecated ucontext routines require
      _XOPEN_SOURCE to be defined
 ^
swapcontext.

So I added #define _XOPEN_SOURCE

But that gives, on Solaris 11.3

In file included from /usr/include/limits.h:12:0,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/limits.h:168,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/syslimits.h:7,
                 from /usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/include-fixed/limits.h:34,
                 from swapcontext.c:7:
/usr/include/sys/feature_tests.h:354:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications  and pre-2001 POSIX applications"
 #error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
  ^

So make the #define _XOPEN_SOURCE conditional on darwin.
2021-03-03 08:53:51 +01:00
Paul Floyd
f9ee4517a0 Modify cxx17_aligned_new testcase to accommdate clang.
Explicitly use ordinary scalar delete and update the expecteds.
Otherwise g++ uses sized scalar delete whilse clang uses
ordinary scalar delete which causes a diff.
2021-03-02 17:48:14 +01:00
Paul Floyd
b030c481dc Added one redir too many on Solaris, which causes a runtime error. 2021-03-02 17:45:22 +01:00
Paul Floyd
8fd6de1cfe Fix compilation on OS X 2021-03-02 17:41:47 +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
Mark Wielaard
262ca91cff Remove deep-D.post.exp-ppc64 from EXTRA_DIST.
massif/tests/deep-D.post.exp-ppc64 was remove in commit 24a94df73
"VG_(get_fnname_kind): Recognize gcc "optimized" below main functions."
but was still listed in massif/tests/Makefile.am (EXTRA_DIST). Causing
make dist to fail.
2021-03-01 00:39:54 +01:00
Mark Wielaard
24a94df738 VG_(get_fnname_kind): Recognize gcc "optimized" below main functions.
The VG_(get_fnname_kind) function detects some special "below main"
function names. Specifically __libc_start_main and generic_start_main
both of which are used to call the actual main () function from the
application. We already recognized one variant, generic_start_main.isra.0,
but only for powerpc. Recognize all possibly specialed optimized variants
gcc can produce by simply checking for the function name with dot as
prefix. This fixes the memcheck/tests/supp_unknown.vgtest and
massif/tests/deep-D.vgtest with gcc 11.

We can now also get rid of the special cases in
massif/tests/deep-D.post.exp-ppc64 and memcheck/tests/supp_unknown.supp.

https://bugs.kde.org/show_bug.cgi?id=430158
2021-03-01 00:26:00 +01:00
Mike Hommey
5d45e212a6 sys_newfstatat: don't complain if |file_name| is NULL.
This is a followup to 2a7d3ae76, in the case rust code runs against a
glibc that supports statx but a kernel that doesn't, in which case glibc
falls back to fstatat.

https://bugs.kde.org/show_bug.cgi?id=433641
2021-02-28 22:31:25 +01:00
Mark Wielaard
9e9d1a1713 Fix README spelling mistake adb -> and
Reported by: satbek@unist.ac.kr

https://bugs.kde.org/show_bug.cgi?id=433629
2021-02-28 21:07:54 +01:00
Mark Wielaard
c9d1cd0db3 Use pkglibexec as vglibdir.
vglibdir is the directory from where valgrind loads its internal tool
executables and vgpreloads. Currently vglibdir is pkglibdir, so those
internal tools are intermingeled with normal executables and libraries
that the user might use directly.

Make vglibdir equal to pkglibexecdir so the internal tools get installed
and loaded from libexec and don't get get stored under lib.

This leaves just the static archives and the mpiwrapper libraries that
the user would link/load themselves under pkglibdir.

This seems more in line with the FHS lib/libexec standard and makes it
slightly easier to combine the tools from a multilib target (say the
memcheck-amd64-linux and memcheck-x86-linux tools) because they would
be installed under the same directory, while the pkglibdir can differ
depending on arch/target (lib/lib64).

https://bugs.kde.org/show_bug.cgi?id=433323
2021-02-28 17:49:40 +01:00
Bart Van Assche
ae15c01f72 none/tests/ifunc.c: Fix a compiler warning
Fix the following compiler warning:

ifunc.c:9:15: warning: 'ifunc' resolver for 'test' should return 'void (*)(int)' [-Wattribute-alias=]
    9 | static void (*resolve_test(void))(void)
      |               ^~~~~~~~~~~~
2021-02-27 20:40:50 -08:00
Mark Wielaard
9774de004a gdbserver_tests: filter out Download failed: messages.
gdb can also use debuginfod and is excessively chatty when downloads
fail (even when DEBUGINFOD_URLS isn't set). Filter those messages out
of the gdb output.
2021-02-27 17:44:36 +01:00
Mark Wielaard
b8a76e8f43 syswrap-ppc64-linux.c: Use FMT_REGWORD and [S]ARG[1234] in PRINT macros.
This prevents some print formatting related warnings.
2021-02-27 17:32:59 +01:00
Mark Wielaard
9c9b909cbf Make the dwarf3 reader more robust and less chatty when things go wrong
Skip some stuff when seeing an unknown language, be less chatty about
parser issues.

All the issues seem to come from the multi-file, that is the shared
(supplementary or alt) file containing debuginfo shared by all the
gcc/runtime libraries.

There are a couple of issues that this patch works around:

- The multifile contains entries for the 'D' language, which has some
  constructs we don't expect.
- We don't read partial units correctly, which means we often don't know
  the language we are looking at.
- The parser is very chatty about issues it didn't expect (even if they
  are ignored, it will still output something)

It only shows up with --read-var-info=yes which some tests enable, but
which is disabled by default.

Also increate the timeout of drd/tests/pth_cleanup_handler.c because
DWARF reading is so slow.

https://bugs.kde.org/show_bug.cgi?id=433500
2021-02-26 02:34:32 +01:00
Aaron Merey
fd4e3fb0ff PR432215 Add debuginfod functionality
debuginfod is an HTTP server for distributing ELF/DWARF debugging
information.  When a debuginfo file cannot be found locally, Valgrind
is able to query debuginfod servers for the file using its build-id.

readelf.c: Add debuginfod_find_debug_file(). Spawns a child process to
exec `debuginfod-find` in order to query servers for the debuginfo
file. Also add helper debuginfod_find_path().

pub_core_pathscan.h: Moved from priv_initimg_pathscan.h in order to use
VG_(find_executable)() in readelf.c.

docs: Add information regarding debuginfod to valgrind.1

memcheck/tests/linux: Add new test debuginfod-check.

tests/vg_regtest.in: Clear $DEBUGINFOD_URLS before running any tests.

https://bugs.kde.org/show_bug.cgi?id=432215
2021-02-26 01:38:42 +01:00
Carl Love
6daaeb0ff4 PPC64: 128-bit Binary Integer Operations, part tests. 2021-02-25 11:57:40 -06:00
Carl Love
affeb57ccd PPC64: ISA 3.1 (new Iops) 128-bit Binary Integer Operations
Add support for:

  dcffixqq DFP Convert From Fixed Quadword Quad
  dctfixqq DFP Convert To Fixed Quadword Quad

  vdivesq Vector Divide Extended Signed Quadword
  vdiveuq Vector Divide Extended Unsigned Quadword
  vdivsq Vector Divide Signed Quadword
  vdivuq Vector Divide Unsigned Quadword

  vmodsq Vector Modulo Signed Quadword
  vmoduq Vector Modulo Unsigned Quadword
  vmulesd Vector Multiply Even Signed Doubleword
  vmuleud Vector Multiply Even Unsigned Doubleword
  vmulosd Vector Multiply Odd Signed Doubleword
  vmuloud Vector Multiply Odd Unsigned Doubleword
  vmsumcud Vector Multiply-Sum & write Carry-out Unsigned Doubleword

  xscvqpsqz VSX Scalar Convert with round to zero Quad-Precision to Signed
    Quadword
  xscvqpuqz VSX Scalar Convert with round to zero Quad-Precision toUnsigned
    Quadword
  xscvsqqp VSX Scalar Convert Signed Quadword to Quad-Precision
  xscvuqqp VSX Scalar Convert Unsigned Quadword to Quad-Precision
2021-02-25 11:15:06 -06:00
Carl Love
5defeb017f PPC64: Fix naming trinary to ternary 2021-02-25 11:15:00 -06:00
Carl Love
953f54085d PPC64: Add ACC register file registers to get_otrack_shadow_offset_wrkget_otrack_shadow_offset_wrk() 2021-02-25 11:14:39 -06:00
Carl Love
4ebdf86538 PPC64: Fix V-bit casting for existing Iops.
Iop_TruncF128toI64S, Iop_TruncF128toI32S, Iop_TruncF128toI64U,
Iop_TruncF128toI32U, Iop_ReinterpI32asF32, Iop_ReinterpF32asI32,
Iop_ReinterpF64asI64, Iop_ReinterpI64asF64, Iop_ReinterpI64asD64,
Iop_ReinterpD64asI64
2021-02-25 11:14:21 -06:00
Paul Floyd
871f786535 Hopefully the last small changes for the drd swapcontext test 2021-02-24 11:01:13 +01:00
Bart Van Assche
caf05d5ca9 drd/tests/swapcontext: Improve the portability of this test further
- Remove the VALGRIND_STACK_REGISTER() invocation for the initial thread
  stack since it is superfluous. Remove the pthread_attr_getstack() call
  that became superfluous by this change.
- Change SIGINT into SIGALRM for FreeBSD since pthread_kill(..., SIGINT)
  causes the application to return a SIGINT status.
- Reduce the stack size of the threads created by this test.
2021-02-23 11:49:14 -08:00
Mark Wielaard
ea98cccb4d Filter out unsupported instructions from HWCAP2 on powerpc.
Valgrind currently doesn't support the DARN random number instruction
and the SCV syscall instruction. Filter them out of HWCAP2 so glibc
and applications don't try to use them when running under valgrind.

Also suppress printing a log message for scv instructions in the
instruction stream.

Reported by: Florian Weimer <fweimer@redhat.com>

DARN bug: https://bugs.kde.org/show_bug.cgi?id=411189
SCV bug: https://bugs.kde.org/show_bug.cgi?id=431157
2021-02-23 16:19:26 +01:00
Mark Wielaard
9337b44f93 gdbserver_tests/hgtls.vgtest: Make sure gdb is installed before running
The other gdbserver_tests that need to run gdb make sure it is actually
available before trying to run it, otherwise the test is skipped. Do the
same to hgtls.vgtest by adding test -e gdb to the prereq.
2021-02-23 11:56:56 +01:00
Mark Wielaard
ddf692c5cc Fix typo in DWARF 5 line table readers
This typo meant the directory entry was most often zero, which
happened to be sometimes correct anyway (since zero is the compdir).
So for simple testcases it looked correct. But it would be wrong for
compilation units not in the current compdir. Like files compiled with
a relative of absolute path (and then combined into the same compilation
unit with LTO).

The same typo was in both readdwarf.c (read_dwarf2_lineblock) and
readdwarf3.c (read_filename_table). read_dwarf2_lineblock also had
an extra "dwarf" string in the --debug-dump=line output.

https://bugzilla.redhat.com/show_bug.cgi?id=1927153
2021-02-21 23:20:09 +01:00
Paul Floyd
323690a770 Add enomem and swapcontext tests to .gitignore 2021-02-21 16:43:42 +01:00
Mark Wielaard
610973c79d swapcontext.vgtest fails with glibc-debuginfo installed
With debuginfo installed the backtace contains the swapcontext.S
source file. Filter that out, like the clone.S source file is in
drd/tests/filter_stderr.
2021-02-21 15:18:58 +01:00
Bart Van Assche
719d23b7a9 drd/tests/swapcontext: Improve portability 2021-02-20 14:51:15 -08:00
Allison Karlitskaya
dec3050653 Linux: Add wrapper for fcntl(F_{GET,ADD}_SEALS)
Add also a testcase to memcheck/tests/linux, enabled according to a new
check for memfd_create() in configure.ac.

https://bugs.kde.org/show_bug.cgi?id=361770
2021-02-20 21:04:12 +01:00
Mark Wielaard
7aac53c6d0 Fix valgrind.h include in drd/tests/swapcontext.c
In tree tests should include "valgrind.h" not <valgrind/valgrind.h>
the later might pick up the system installed valgrind.h and doesn't
work when srcdir != builddir.
2021-02-20 20:05:42 +01:00
Bart Van Assche
0062f2b519 drd/tests/swapcontext: Add a swapcontext() test 2021-02-20 08:44:50 -08:00
Bart Van Assche
fd5a12afcb drd: Process stack registration client requests
Reset stack information if the client registers a new stack
2021-02-20 08:44:50 -08:00