16179 Commits

Author SHA1 Message Date
Mark Wielaard
2e2ae5bda8 Implement minimal ptrace support for ppc64[le]-linux. 2018-12-14 14:41:57 +01:00
Mark Wielaard
43fe4bc236 arm64: Fix PTRACE_TRACEME memcheck/tests/linux/getregset.vgtest testcase.
The sys_ptrace post didn't mark the thread as being in traceme mode.
This occassionally would make the memcheck/tests/linux/getregset.vgtest
testcase fail. With this patch it reliably passes.
2018-12-14 14:32:27 +01:00
Petar Jovanovic
c4ab123605 mips64: fix build break introduced by be7a730
Follow up to
commit be7a73004583aab5d4c97cf55276ca58d5b3090b

that broke the build for mips64.
2018-12-13 16:20:28 +01:00
Petar Jovanovic
71be91d2dd make outputs of drd/tests/fork* deterministic
Wait for children to finish before terminating the main process.

This fixes occasional failures of the following tests:

drd/tests/fork-parallel                  (stderr)
drd/tests/fork-serial                    (stderr)
2018-12-12 17:53:43 +00:00
Mark Wielaard
be7a730045 Mark helper regs defined in final_tidyup before freeres_wrapper call.
In final_tidyup we setup the guest to call the freeres_wrapper, which
will (possibly) call __gnu_cxx::__freeres() and/or __libc_freeres().

In a couple of cases (ppc64be, ppc64le and mips32) this involves setting
up one or more helper registers. Since we setup these guest registers
we should make sure to mark them as fully defined. Otherwise we might
see spurious warnings about undefined value usage if the guest register
happened to not be fully defined before.

This fixes PR402006.
2018-12-12 14:15:28 +01:00
Nicholas Nethercote
46fb3eb81c Fix path handling in the new Cachegrind and Callgrind tests. 2018-12-12 20:52:33 +11:00
Nicholas Nethercote
e6e8377521 Add a --show-percs option to cg_annotate and callgrind_annotate.
Because it's very useful. As part of this, the "percentage of events
annotated" numbers at the bottom of the output is changed to "events
annotated" so that --show-percs doesn't compute a percentage of a
percentage.

Example output lines:
```
4,967,137,442 (100.0%)  PROGRAM TOTALS

4,543 (25.23%)    17,566 ( 0.43%)    47,993 ( 0.92%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c

1 ( 0.01%) 2,000,001 (49.29%) 3,000,004 (57.36%)     for (int i = 0; i < 1000000; i++) {
```

The commit also adds some much-needed tests for cg_annotate and
callgrind_annotate.
2018-12-10 14:14:20 +11:00
Mark Wielaard
0c701ba2a4 Fix sigkill.stderr.exp for glibc-2.28.
glibc 2.28 filters out some bad signal numbers and returns
Invalid argument instead of passing such bad signal numbers
the kernel sigaction syscall. So we won't see such bad signal
numbers and won't print "bad signal number" ourselves.

Add a new memcheck/tests/sigkill.stderr.exp-glibc-2.28 to catch
this case.
2018-12-07 14:05:15 +01:00
Mark Wielaard
a0d97e88ec Bug 401822 Fix asm constraints for ppc64 jm-vmx jm-insns.c test.
The mfvscr and vor instructions in jm-insns.c had a "=vr" constraint.
This should have been an "=v" constraint. This resolved assembler
warnings and the testcase failing on ppc64le with gcc 8.2 and
binutils 2.30.
2018-12-06 20:52:36 +01:00
Mark Wielaard
cf00e0e59d Bug 401627 - Add wcsncmp override and testcase.
glibc 2.28 added an avx2 optimized variant of wstrncmp which memcheck
cannot proof correct. Add a simple override in vg_replace_strmem.c.
2018-12-06 16:40:34 +01:00
Andreas Arnez
43699f30f6 Add Emacs configuration files
This adds a configuration file ".dir-locals.el" for Emacs to the topmost
directory of the Valgrind source tree, and another such file to the
directory drd/tests.  These files contain per-directory local Emacs
variables.

The following settings are performed:

* The base C style is set to "Linux", indentation is set to 3 columns
  per level, the use of tabs for indentation is disabled, and the fill
  column is set to 80.

* The source files in drd/tests use 2 instead of 3 columns per indentation
  level.
2018-12-05 18:15:57 -08:00
Mark Wielaard
206e81e8ad Fix tsan_unittest.cpp compile error with older compilers.
Older compilers (g++ 4.8.5) don't like '>>':
  error: ‘>>’ should be ‘> >’ within a nested template argument list.
Add an extra space.
2018-12-02 12:39:27 +01:00
Bart Van Assche
65dcbc70db drd/tests: Fix remaining gcc 8 compiler warnings 2018-12-01 21:53:59 -08:00
Bart Van Assche
4b90a2e668 Add drd/tests/fork-serial and drd/tests/fork-parallel 2018-12-01 11:05:26 -08:00
Bart Van Assche
66a7a592c0 drd: Add fork test program 2018-12-01 10:45:51 -08:00
Bart Van Assche
df10905d33 drd: Fix fork() handling
The thread ID passed to DRD_(drd_thread_atfork_child)() is a Valgrind
thread ID instead of a DRD thread ID. This patch fixes bug 401578.
2018-12-01 10:45:51 -08:00
Bart Van Assche
bb7086d063 drd/test: Fix most gcc 8 compiler warnings 2018-12-01 10:45:51 -08:00
Vadim Barkov
86bd889458 Bug 385411 s390x: Tests and internals for z13 vector FP support
Add test cases for the z13 vector FP support.  Bring s390-opcodes.csv
up-to-date, reflecting that the z13 vector instructions are now supported.
Also remove the non-support disclaimer for the vector facility from
README.s390.

The patch was contributed by Vadim Barkov, with some clean-up and minor
adjustments by Andreas Arnez.
2018-11-30 14:29:39 +01:00
Vadim Barkov
600a0099a1 Bug 385411 s390x: Add z13 vector floating point support
This adds support for the z/Architecture vector FP instructions that were
introduced with z13.

The patch was contributed by Vadim Barkov, with some clean-up and minor
adjustments by Andreas Arnez.
2018-11-30 14:29:39 +01:00
Julian Seward
f2c03ce3ba Bug 401112 - LLVM 5.0 generates comparison against partially initialized data.
This generalises the existing spec rules for W of 32 bits:

             W  <u   0---(N-1)---0 1 0---0  or

(that is, B/NB after SUBL, where dep2 has the above form), to also cover

             W  <=u  0---(N-1)---0 0 1---1

(that is, BE/NBE after SUBL, where dept2 has the specified form).

Patch from Nicolas B. Pierron (nicolas.b.pierron@nbp.name).
2018-11-28 14:15:06 +01:00
Philippe Waroquiers
7c26e71c09 Always output all leak kinds in a xtree leak result file.
- The option --xtree-leak=yes (to output leak result in xtree format)
  automatically activates the option --show-leak-kinds=all,
  as xtree visualisation tools such as kcachegrind can in any case
  select what kind of leak to visualise.
2018-11-25 19:51:53 +01:00
Andreas Arnez
ddfc274b24 s390x: More fixes for z13 support
This patch addresses the following:

* Fix the implementation of LOCGHI.  Previously Valgrind performed 32-bit
  sign extension instead of 64-bit sign extension on the immediate value.

* Advertise VXRS in HWCAP.  If no VXRS are advertised, but the program
  uses vector registers, this could cause problems with a glibc built with
  "-march=z13".
2018-11-22 13:45:56 +01:00
Julian Seward
27fe22378d Add support for Iop_{Sar,Shr}8 on ppc. --expensive-definedness-checks=yes needs them. 2018-11-20 12:09:03 +01:00
Julian Seward
cb5d7e0475 VEX/priv/ir_opt.c
fold_Expr: transform PopCount64(And64(Add64(x,-1),Not64(x))) into CtzNat64(x).

This is part of the fix for bug 386945.
2018-11-20 11:46:55 +01:00
Julian Seward
81d9832226 ppc front end: use new IROps added in 42719898.
This pertains to bug 386945.

VEX/priv/guest_ppc_toIR.c:

gen_POPCOUNT: use Iop_PopCount{32,64} where possible.

gen_vpopcntd_mode32: use Iop_PopCount32.

for cntlz{w,d}, use Iop_CtzNat{32,64}.

gen_byterev32: use Iop_Reverse8sIn32_x1 instead of lengthy sequence.

verbose_Clz32: remove (was unused anyway).
2018-11-20 11:36:53 +01:00
Julian Seward
e221eca26b Add Memcheck support for IROps added in 42719898.
memcheck/mc_translate.c:

Add mkRight{32,64} as right-travelling analogues to mkLeft{32,64}.

doCmpORD: for the cases of a signed comparison against zero, compute
definedness of the 3 result bits (lt,gt,eq) separately, and, for the lt and eq
bits, do it exactly accurately.

expensiveCountTrailingZeroes: no functional change.  Re-analyse/verify and add
comments.

expensiveCountLeadingZeroes: add.  Very similar to
expensiveCountTrailingZeroes.

Add some comments to mark unary ops which are self-shadowing.

Route Iop_Ctz{,Nat}{32,64} through expensiveCountTrailingZeroes.
Route Iop_Clz{,Nat}{32,64} through expensiveCountLeadingZeroes.

Add instrumentation for Iop_PopCount{32,64} and Iop_Reverse8sIn32_x1.

memcheck/tests/vbit-test/irops.c

Add dummy new entries for all new IROps, just enough to make it compile and
run.
2018-11-20 11:28:42 +01:00
Julian Seward
97d336b79e Add ppc host-side isel and instruction support for IROps added in previous commit.
VEX/priv/host_ppc_defs.c, VEX/priv/host_ppc_defs.h:

Dont emit cnttz{w,d}.  We may need them on a target which doesn't support
them.  Instead we can generate a fairly reasonable alternative sequence with
cntlz{w,d} instead.

Add support for emitting popcnt{w,d}.

VEX/priv/host_ppc_isel.c

Add support for: Iop_ClzNat32 Iop_ClzNat64

Redo support for: Iop_Ctz{32,64} and their Nat equivalents, so as to not use
cnttz{w,d}, as mentioned above.

Add support for: Iop_PopCount64 Iop_PopCount32 Iop_Reverse8sIn32_x1
2018-11-20 11:09:30 +01:00
Julian Seward
4271989815 Add some new IROps to support improved Memcheck analysis of strlen etc.
This is part of the fix for bug 386945.  It adds the following IROps, plus
their supporting type- and printing- fragments:

Iop_Reverse8sIn32_x1: 32-bit byteswap.  A fancy name, but it is consistent
with naming for the other swapping IROps that already exist.

Iop_PopCount64, Iop_PopCount32: population count

Iop_ClzNat64, Iop_ClzNat32, Iop_CtzNat64, Iop_CtzNat32: counting leading and
trailing zeroes, with "natural" (Nat) semantics for a zero input, meaning, in
the case of zero input, return the number of bits in the word.  These
functionally overlap with the existing Iop_Clz64, Iop_Clz32, Iop_Ctz64,
Iop_Ctz32.  The existing operations are undefined in case of a zero input.
Adding these new variants avoids the complexity of having to change the
declared semantics of the existing operations.  Instead they are deprecated
but still available for use.
2018-11-20 10:52:33 +01:00
Julian Seward
7f1dd9d5ae get_otrack_shadow_offset_wrk for ppc32 and ppc64: add missing cases for XER_OV32, XER_CA32 and C_FPCC.
The missing cases were discovered whilst testing fixes for bug 386945, but are
otherwise unrelated to that bug.
2018-11-20 10:28:13 +01:00
Nicholas Nethercote
18d4bf8f0c Fix Cachegrind's --help message. 2018-11-16 16:48:13 +11:00
Andreas Arnez
50bd2282bc Bug 397187 s390x: Add vector register support for vgdb
On s390x machines with a vector facility, Valgrind's gdbserver didn't
represent the vector registers.  This is fixed.
2018-11-14 16:24:06 +01:00
Andreas Arnez
9545e9f96b Bug 400491 s390x: Sign-extend immediate operand of LOCHI and friends
The VEX implementation of each of the z/Architecture instructions LOCHI,
LOCHHI, and LOCGHI treats the immediate 16-bit operand as an unsigned
integer instead of a signed integer.  This is fixed.
2018-11-14 16:22:24 +01:00
Andreas Arnez
71002d8a51 Bug 400490 s390x: Fix register allocation for VRs vs FPRs
On s390x, if vector registers are available, they are fed to the register
allocator as if they were separate from the floating-point registers.  But
in fact the FPRs are embedded in the VRs.  So for instance, if both f3 and
v3 are allocated and used at the same time, corruption will result.

This is fixed by offering only the non-overlapping VRs, v16 to v31, to the
register allocator instead.
2018-11-14 16:20:44 +01:00
Philippe Waroquiers
1d42a625ab Make white space style more consistent, no functional impact.
But this time, rather consistently use *no* space between function name and
function arg list.
2018-11-06 21:40:43 +01:00
Philippe Waroquiers
8a6fe39d2a Make white space style more consistent, no functional impact.
Consistently use a space between function name and function arg list.
2018-11-04 11:48:00 +01:00
Philippe Waroquiers
7820fc268f Fix dependencies between libcoregrind*.a and *m_main.o/*m_libcsetjmp.o
The primary and secondary coregrind libraries must be updated
when m_main.c or m_libcsetjmp.c are changed.

A dependency was missing between libcoregrind*.a and libnolto_coregrind*.a,
and so tools were not relinked when m_main.c or m_libcsetjmp.c were
changed.
2018-10-28 19:02:16 +01:00
Philippe Waroquiers
66b5a4e9c4 Fix 399301 - Use inlined frames in Massif XTree output.
Author: Nicholas Nethercote <nnethercote@mozilla.com>

Use inlined frames in Massif XTree output.

    This makes Massif's output much easier to follow.

    The commit also removes a -1 used on all Massif stack frame addresses.
    There was a big comment questioning the presence of that -1, and with it
    gone the addresses now match those produced by DHAT.
2018-10-27 20:28:59 +02:00
Philippe Waroquiers
d00dd9c2dd Update configure.ac to next version 3.15.GIT ...
As pointed out by Rhys, we need a .GIT postfix waiting
for the release ...
2018-10-20 16:54:19 +02:00
Philippe Waroquiers
e8eda462e9 Update configure.ac to next version 3.15 ... 2018-10-20 11:44:00 +02:00
Philippe Waroquiers
4c80082c36 Prepare for the next 3.15 release
* Create the 3.15 section in the NEWS file
  (the idea is that this section is maintained during the development,
   i.e. document user visible changes and/or the fixed bugs, as part of
   the commit).

* start the fixed bug list with 399322  Improve callgrind_annotate output

* update vg-entities.xml for 3.15 next release.
2018-10-20 11:37:26 +02:00
Nicholas Nethercote
8b689c66d9 Implement VG_(apply_ExeContext)().
It's been declared for a long time, but was lacking a definition.
2018-10-19 16:30:42 +11:00
Nicholas Nethercote
331949c1c5 Improve callgrind_annotate output.
This commit makes two changes:

- it adds commas to call counts (e.g. `65658x` becomes `65,658x`);

- it sorts callers/callees in the tree by the --sort order.

An example, old output:
```
72,142,945  < /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x (65658x)
68,977,760  *  /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x
       340  >   /build/glibc-OTsEL5/glibc-2.27/malloc/malloc.c:free (3x)
     4,564  >   /build/glibc-OTsEL5/glibc-2.27/nptl/pthread_mutex_unlock.c:pthread_mutex_unlock (163x)
 1,282,381  >   /build/glibc-OTsEL5/glibc-2.27/string/../sysdeps/x86_64/strcmp.S:strcmp (12893x)
    13,310  >   /build/glibc-OTsEL5/glibc-2.27/malloc/malloc.c:calloc (4x)
       223  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-misc.c:_dl_higher_prime_number (3x)
 1,741,689  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-misc.c:_dl_name_match_p (16842x)
     5,705  >   /build/glibc-OTsEL5/glibc-2.27/nptl/../nptl/pthread_mutex_lock.c:pthread_mutex_lock (163x)

    51,454  < /build/glibc-OTsEL5/glibc-2.27/elf/../elf/dl-runtime.c:_dl_fixup (33x)
     2,456  < /build/glibc-OTsEL5/glibc-2.27/elf/dl-sym.c:_dl_sym (2x)
100,313,502  < /build/glibc-OTsEL5/glibc-2.27/elf/../sysdeps/x86_64/dl-machine.h:_dl_relocate_object (39094x)
28,224,467  *  /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x
72,142,945  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x (65658x)

[...]

  567        setLastUser(LastPMUses, P->getResolver()->getPMDataManager().getAsPass());
   18  => /home/njn/moz/rust0/src/llvm/include/llvm/IR/LegacyPassManagers.h:non-virtual thunk to llvm::FPPassManager::getAsPass() (9x)
1,971  => /home/njn/moz/rust0/src/llvm/lib/IR/LegacyPassManager.cpp:llvm::PMTopLevelManager::setLastUser(llvm::ArrayRef<llvm::Pass*>, llvm::Pass*)'2 (63x)
  108  => ???:non-virtual thunk to (anonymous namespace)::MPPassManager::getAsPass() (54x)
```

New output:
```
72,142,945  < /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x (65,658x)
68,977,760  *  /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x
 1,741,689  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-misc.c:_dl_name_match_p (16,842x)
 1,282,381  >   /build/glibc-OTsEL5/glibc-2.27/string/../sysdeps/x86_64/strcmp.S:strcmp (12,893x)
    13,310  >   /build/glibc-OTsEL5/glibc-2.27/malloc/malloc.c:calloc (4x)
     5,705  >   /build/glibc-OTsEL5/glibc-2.27/nptl/../nptl/pthread_mutex_lock.c:pthread_mutex_lock (163x)
     4,564  >   /build/glibc-OTsEL5/glibc-2.27/nptl/pthread_mutex_unlock.c:pthread_mutex_unlock (163x)
       340  >   /build/glibc-OTsEL5/glibc-2.27/malloc/malloc.c:free (3x)
       223  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-misc.c:_dl_higher_prime_number (3x)

100,313,502  < /build/glibc-OTsEL5/glibc-2.27/elf/../sysdeps/x86_64/dl-machine.h:_dl_relocate_object (39,094x)
    51,454  < /build/glibc-OTsEL5/glibc-2.27/elf/../elf/dl-runtime.c:_dl_fixup (33x)
     2,456  < /build/glibc-OTsEL5/glibc-2.27/elf/dl-sym.c:_dl_sym (2x)
28,224,467  *  /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x
72,142,945  >   /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x (65,658x)

[...]

  567        setLastUser(LastPMUses, P->getResolver()->getPMDataManager().getAsPass());
1,971  => /home/njn/moz/rust0/src/llvm/lib/IR/LegacyPassManager.cpp:llvm::PMTopLevelManager::setLastUser(llvm::ArrayRef<llvm::Pass*>, llvm::Pass*)'2 (63x)
  108  => ???:non-virtual thunk to (anonymous namespace)::MPPassManager::getAsPass() (54x)
   18  => /home/njn/moz/rust0/src/llvm/include/llvm/IR/LegacyPassManagers.h:non-virtual thunk to llvm::FPPassManager::getAsPass() (9x)
```
2018-10-12 21:35:53 +11:00
Andreas Arnez
ca2f73592e Bug 399444 s390x: Drop unnecessary check in s390_irgen_VSLDB
In s390_irgen_VSLDB there was special handling for the case that the
immediate operand i4 has the value 16, which would mean that the result v1
were a full copy of the third operand v3.  However, this is impossible
because i4 can only assume values from 0 to 15; thus the special handling
can be removed.
2018-10-10 14:19:36 +02:00
Julian Seward
3a3000290b --> 3.14.0 final 2018-10-09 13:52:05 +02:00
Rhys Kidd
353a3587bb Fix macOS 10.13 building from tarball
Fixes: 1ce04c3 ("Preliminary support for Darwin 17.x (macOS 10.13)")
2018-10-07 21:26:35 -04:00
Julian Seward
d2af42d826 --> 3.14.0.RC2 2018-10-03 15:37:06 +02:00
Julian Seward
3e214c4858 sigframe construction for x86-linux: ensure that ESP is correctly aligned before entering the handler. n-i-bz.
Without this, a signal handler compiled by Clang 6, which uses movdqa to load/store
relative to ESP, segfaults because the resulting address isn't 16-aligned.
2018-10-03 15:29:42 +02:00
Julian Seward
617e673e9b x86 front end: handle UD2 as an officially recognised, unimplemented instruction, like the amd64 front end does. n-i-bz.
This doesn't change anything downstream -- a SIGILL is still raised -- but
there's a bit less debug printing now.
2018-10-03 15:26:48 +02:00
Julian Seward
7669f536ee --> 3.14.0.RC1 2018-09-30 10:21:27 +02:00
Julian Seward
c2aeea2d28 Memcheck on amd64; fix false positive associated with spec cases {Z,NZ} after {LOGICB,LOGICW}. n-i-bz.
For the spec cases {Z,NZ} after {LOGICB,LOGICW}, which are simply comparisons
of the result against zero, use Cmp{EQ,NE}32 rather than their 64-bit
counterparts.  This is because Memcheck on amd64 instruments the 32 bit
versions exactly, at the default --expensive-definedness-checks=auto setting.
The alternative would have been to make Memcheck also do exact instrumentation
of the 64 bit versions, but that would also burden all other 64 bit eq/ne
comparisons with that cost for no purpose.  So this is a cheaper solution.
2018-09-30 09:29:43 +02:00