17243 Commits

Author SHA1 Message Date
Andreas Arnez
4f4cd4b8d5 s390: Add z16 support to ecag testcase
The testcase 'none/tests/s390x/ecag' requires expected output from any
machine it runs on.  This is missing for z16, so add it.
2023-01-11 16:44:38 +01:00
Andreas Arnez
d6073d34d4 s390: Add test for short/extended vector float insns
Several issues with vector floating point instructions have gone unnoticed
due to a lack of test coverage in this area.  Add a test case that
improves the coverage, particuarly when dealing with short and extended
floating point formats.
2023-01-11 16:44:38 +01:00
Andreas Arnez
1b8dcec1b4 s390: Stop CC clobbering by VFMIN and VFMAX
Valgrind's implementation of the VFMIN and VFMAX instructions clobbers the
condition code, which is wrong.  Stop doing that.
2023-01-11 16:44:38 +01:00
Andreas Arnez
73ab2978f8 s390: Un-swap implementations of VFCH and VFCHE
When running under Valgrind, the VFCH instruction behaves like VFCHE, and
vice versa.  Fix this.
2023-01-11 16:44:38 +01:00
Andreas Arnez
e05f55c77c s390: Fix VFMA, VFMS, VFNMA, and VFNMS for 128-bit FP
When trying to execute any of the vector float multiply-and-add family
instructions, Valgrind panics with the message "Iex_Qop with F128 data".

So far all F128 operations were implemented with instructions that operate
on FP register pairs.  However, such instructions don't exist for
Iop_MAddF128 and Iop_MSubF128, so they must be implemented with vector
instructions instead.  This was missed when emitting them in
"guest_s390_toIR.c".

Add the missing support.  This also involves adding a few new features to
host_s390_defs:

* a new vector operation S390_VEC_INIT_FROM_FPRS

* the capability to move the left half of a VR to an FPR

* S390_VEC_FLOAT_MADD/_MSUB for 128-bit sizes
2023-01-11 16:44:38 +01:00
Andreas Arnez
6da4025b59 Bug 460356 -- s390: Fix code generation for Iop_Sqrt32Fx4
There is no instruction selector for Iop_Sqrt32Fx4, leading to Valgrind
panicking with the message:

   s390_isel_vec_expr: cannot reduce tree

Fix this.
2023-01-11 16:44:38 +01:00
Mark Wielaard
c5d52a4056 gdbserver tests filter out uninstalled python scripts warnings
Filter out loading error messages when python scripts haven't
been installed yet (running against vg-in-place)
2023-01-11 15:45:32 +01:00
Paul Floyd
36b9fea113 Linux regtest: openat2 not available on older systems
The x86-linux/scalar testcase fas failing to compile.
So split out openat2 into a separate test with a condfigure test.
2023-01-10 21:00:22 +01:00
Philippe Waroquiers
e41dff2999 Fix gdbserver tests failing when python code cannot be autoloaded.
If the valgrind python code loading is not authorised by GDB config,
ensure the related error messages and info messages are filtered.
2023-01-10 00:28:38 +01:00
Paul Floyd
99dfad28a5 Cleanup warnings
Now no warnings on Fedora 36
For a short while
2023-01-09 23:57:01 +01:00
Paul Floyd
d320fc123b FreeBSD: clang-tidy corrections 2023-01-08 17:52:48 +01:00
Paul Floyd
1cea0e151b Cleanup of warnings, mostly -Wno-unused-but-set-variable 2023-01-08 17:51:37 +01:00
Philippe Waroquiers
39a063513c Implement front end GDB commands for Valgrind gdbserver monitor commands.
This commit implements in python a set of GDB commands corresponding to the
Valgrind gdbserver monitor commands.

Basically, the idea is that one GDB command is defined for each valgrind
gdbserver subcommand and will generate and send a monitor command to valgrind.

The python code is auto-loaded by GDB as soon as GDB observes that the valgrind
preload core shared lib is loaded (e.g. vgpreload_core-amd64-linux.so).
This automatic loading is done thanks to the .debug_gdb_scripts section
added in vg_preloaded.c file.

Sadly, the auto-load only happens once valgrind has started to execute the code
of ld that loads this vg_preload file.

I have tried 2 approaches to have the python code auto-loaded when attaching at
startup to valgrind:
  * have valgrind gdbserver reporting first to GDB that the executable file is
    the tool executable (with a .debug_gdb_scripts section) and then reporting
    the real (guest) executable file.
    The drawback of this approach is that it triggers a warning/question in GDB
    according to the GDB setting 'set exec-file-mismatch'.
  * have valgrind gdbserver pretending to be multiprocess enabled, and report
    a fake process using the tool executable with a .debug_gdb_scripts section.
    The drawback of this is that this always creates a second inferior in GDB,
    which will be confusing.

Possibly, we might complete the below message :
  ==2984378== (action at startup) vgdb me ...
  ==2984378==
  ==2984378== TO DEBUG THIS PROCESS USING GDB: start GDB like this
  ==2984378==   /path/to/gdb /home/philippe/valgrind/littleprogs/some_mem
  ==2984378== and then give GDB the following command
  ==2984378==   target remote | /home/philippe/valgrind/git/improve/Inst/libexec/valgrind/../../bin/vgdb --pid=2984378
  ==2984378== --pid is optional if only one valgrind process is running

with:
  ==2984378== GDB valgrind python specific commands will be auto-loaded when execution begins.
  ==2984378== Alternatively, you might load it before with the GDB command:
  ==2984378==   source /abs/path/to/valgrind/install/libexec/valgrind/valgrind-monitor.py

The following GDB setting traces the monitor commands sent by a GDB valgrind
command to the valgrind gdbserver:
  set debug valgrind-execute-monitor on

How to use the new GDB valgrind commands?
-----------------------------------------

The usage of the GDB front end commands is compatible with the
monitor command as accepted today by Valgrind.

For example, the memcheck monitor command "xb' has the following usage:
 xb <addr> [<len>]

With some piece of code:
   'char some_mem [5];'
xb can be used the following way:
  (gdb) print &some_mem
  (gdb) $2 = (char (*)[5]) 0x1ffefffe8b
  (gdb) monitor xb 0x1ffefffe8b 5
  		    ff	  ff	  ff	  ff	  ff
  0x4A43040:	  0x00	0x00	0x00	0x00	0x00
  (gdb)

The same action can be done with the new GDB 'memcheck xb' command:
  (gdb) memcheck xb 0x1ffefffe8b 5
  		    ff	  ff	  ff	  ff	  ff
  0x1FFEFFFE8B:	  0x00	0x00	0x00	0x00	0x00
  (gdb)

At this point, you might ask yourself: "what is the interest ?".

Using GDB valgrind commands provides several advantages compared to
the valgrind gdbserver monitor commands.

Evaluation of arguments by GDB:
-------------------------------
For relevant arguments, the GDB command will evaluate its arguments using
the usual GDB evaluation logic, for example, instead of printing/copying
the address and size of 'some_mem', the following will work:
  (gdb) memcheck xb &some_mem sizeof(some_mem)
  		    ff	  ff	  ff	  ff	  ff
  0x1FFEFFFE8B:	  0x00	0x00	0x00	0x00	0x00
  (gdb)

or:
  (gdb) p some_mem
  $4 = "\000\000\000\000"
  (gdb) memcheck xb &$4
  		    ff	  ff	  ff	  ff	  ff
  0x1FFEFFFE8B:	  0x00	0x00	0x00	0x00	0x00
  (gdb)

This is both easier to use interactively and easier to use in GDB scripts,
as you can directly use variable names in the GDB valgrind commands.

Command completion by GDB:
--------------------------
The usual command completion in GDB will work for the GDB valgrind commands.
For example, typing TAB after the letter 'l' in:
  (gdb) valgrind v.info l
will show the 2 "valgrind v.info" subcommands:
  last_error  location
  (gdb) valgrind v.info l

Note that as usual, GDB will recognise a command as soon as it is unambiguous.

Usual help and apropos support by GDB:
--------------------------------------
The Valgrind gdbserver provides an online help using:
  (gdb) monitor help
However, this gives the help for all monitor commands, and is not searchable.
GDB provides a better help and documentation search.
For example, the following commands can be used to get various help
or search the GDB Valgrind command online documentation:
   help valgrind
   help memcheck
   help helgrind
   help callgrind
   help massif
to get help about the general valgrind commands or the tool specific commands.

Examples of searching the online documentation:
  apropos valgrind.*location
  apropos -v validity
  apropos -v leak

User can define aliases for the valgrind commands:
--------------------------------------------------
The following aliases are predefined:
  v and vg for valgrind
  mc for memcheck
  hg for helgrind
  cg for callgrind
  ms for massif

So, the following will be equivalent:
   (gdb) valgrind v.info location &some_mem
   (gdb) v v.i lo &some_mem
   (gdb) alias Vl = valgrind v.info location
   (gdb) Vl &some_mem

Thanks to Hassan El Karouni for the help in factorising the python
code common to all valgrind python commands using a decorator.
2023-01-08 16:00:57 +01:00
Philippe Waroquiers
3a046ec1c1 Avoid doing mempool specific leak search activities if there are no mempools
For most memcheck users, no mempools are used, but the leak search logic
was doing in any case special handling, leading to useless work such as
sorting again an already sorted array and making a copy of an array without
modifying it.

This slightly optimises the perf reg tests of memcheck.
perl perf/vg_perf --tools=memcheck --vg=. --vg=../trunk_untouched perf
-- Running  tests in perf ----------------------------------------------
-- bigcode1 --
bigcode1 .         :0.08s  me: 3.0s (38.1x, -----)
bigcode1 trunk_untouched:0.08s  me: 3.1s (38.6x, -1.3%)
-- bigcode2 --
bigcode2 .         :0.07s  me: 7.4s (105.9x, -----)
bigcode2 trunk_untouched:0.07s  me: 7.5s (107.4x, -1.5%)
-- bz2 --
bz2      .         :0.40s  me: 5.2s (12.9x, -----)
bz2      trunk_untouched:0.40s  me: 5.4s (13.6x, -5.0%)
-- fbench --
fbench   .         :0.15s  me: 2.8s (18.8x, -----)
fbench   trunk_untouched:0.15s  me: 2.9s (19.0x, -1.1%)
-- ffbench --
ffbench  .         :0.16s  me: 2.7s (16.8x, -----)
ffbench  trunk_untouched:0.16s  me: 2.7s (17.1x, -1.9%)
-- heap --
heap     .         :0.06s  me: 4.0s (66.5x, -----)
heap     trunk_untouched:0.06s  me: 4.1s (68.7x, -3.3%)
-- heap_pdb4 --
heap_pdb4 .         :0.07s  me: 6.2s (89.1x, -----)
heap_pdb4 trunk_untouched:0.07s  me: 6.6s (94.9x, -6.4%)
-- many-loss-records --
many-loss-records .         :0.01s  me: 1.2s (122.0x, -----)
many-loss-records trunk_untouched:0.01s  me: 1.2s (125.0x, -2.5%)
-- many-xpts --
many-xpts .         :0.03s  me: 1.2s (41.7x, -----)
many-xpts trunk_untouched:0.03s  me: 1.3s (43.7x, -4.8%)
-- memrw --
memrw    .         :0.06s  me: 1.2s (19.8x, -----)
memrw    trunk_untouched:0.06s  me: 1.2s (20.2x, -1.7%)
-- sarp --
sarp     .         :0.02s  me: 1.8s (91.5x, -----)
sarp     trunk_untouched:0.02s  me: 2.1s (103.5x,-13.1%)
-- tinycc --
tinycc   .         :0.11s  me: 7.1s (64.4x, -----)
tinycc   trunk_untouched:0.11s  me: 7.1s (64.3x,  0.1%)
-- Finished tests in perf ----------------------------------------------

== 12 programs, 24 timings =================
2023-01-08 11:50:07 +01:00
Paul Floyd
2c93baf53a Bug 433873 - openat2 syscall unimplemented on Linux
This syscall is not exposed via glibc, so there is only an
addition to the scalar test.
2023-01-06 21:27:01 +01:00
Julian Seward
394ca9b400 Remove a debugging line if (0) .. that mistakenly got landed in fa3a9cc43c22593c70796a99aff33bb9436ad448. 2023-01-04 17:43:21 +01:00
Julian Seward
1b8d0cbc81 Fix 64-bit uncleanness in VG_(get_bbs_translated)/VG_(get_bbs_discarded_or_dumped) ..
.. and some debug printing associated with them.  I don't think this affects
anything apart from debug printing.  Noticed when running a x86 (32-bit)
Firefox build.
2023-01-04 17:12:21 +01:00
Julian Seward
fe4e6578d4 amd64 and x86 front ends: add a few more spec rules.
amd64:
  S and NS  after LOGICQ (per comments from Eyal Soha on the dev list)
  S         after SHLQ
  NZ        after SHLL

x86:
  NZ        after SHRL
  Z         after SHLL

I would have liked to have added the inverse conditions in all cases (eg, both
S and NS, or both Z and NZ), but finding use cases for some of these is almost
impossible, hence they are sometimes omitted.  All of the added cases have
been tested.
2023-01-04 17:06:01 +01:00
Julian Seward
d99a6f70e2 Memcheck: handle origin data for 8-/16-bit shadow stores a bit more accurately.
With origin tracking enabled, 8- and 16-bit stores could sometimes lose origin
info unnecessarily.  This patch removes this avoidable lossage.  (Since MC
only stores 1 origin value for each 32-bit word of address space, there is
still unavoidable lossage of origins in some cases; this patch does not help
in those cases since it's a fundamental design limitation.)
2023-01-04 16:32:03 +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
74e2000746 Bug 327548 - false positive while destroying mutex 2023-01-03 21:28:42 +01:00
Philippe Waroquiers
56971834a7 Small improvement to documentation. 2023-01-02 23:05:35 +01:00
Paul Floyd
8224cf37a9 Update none/tests/cmdline1 and 2 for non-linux 2022-12-31 10:13:19 +01:00
Philippe Waroquiers
f6fcc74a68 Allows to only output "new" loss records when doing a leak search.
In the memcheck monitor 'leak_search', add a "new" keyword corresponding
to the delta leak search mode LCD_New.

Add a new client request VALGRIND_DO_NEW_LEAK_CHECK.

When doing a delta leak search, new loss records are marked with "new"
(whatever the delta leak search mode).

Note that trailing white spaces were removed in mc_main.c.
A much small diff can be looked at by using the -w diff option.
2022-12-30 20:56:47 +01:00
Philippe Waroquiers
c8bb6a62ca Add clo option -scheduling-quantum=<number> to control scheduler time slice.
This option can be useful when tracking race conditions which are sensitive
to thread scheduling.
2022-12-30 16:28:23 +01:00
Paul Floyd
ccbb75cf1d FreeeBSD: Add Helgrind suppression for void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) 2022-12-30 13:46:09 +01:00
Paul Floyd
5cfb0173ed Add DRD shared_timed_mutex to Helgrind
This uses pthread_rwlock_timedrdlock / pthread_rwlock_timedwrlock
(see commit 6ffb70e650ee7cf4ada829557dd30ababb09e078)
2022-12-29 22:21:03 +01:00
Paul Floyd
d7c93d1f71 Add a variation of the Helgrind tls_threads test
This version uses GLIBC_TUNABLES in the environment so it checks
that glibc.pthread.stack_cache_size can be detected and modified.
2022-12-29 22:08:14 +01:00
Paul Floyd
6ffb70e650 Bug 400793 - pthread_rwlock_timedwrlock false positive
Add Helgrind intercepts for pthread_rwlock_timedwrlock
(and pthread_rwlock_timedrdlock)

Reuse the DRD trylock test
2022-12-29 22:02:47 +01:00
Paul Floyd
ab1eb2cb74 Update modified hg04 reference for DRD. 2022-12-29 20:59:25 +01:00
Philippe Waroquiers
a5b88a02d5 Add a test for helgrind --history-backtrace-size
Extend hg04_race to have more entries in the conflicting stacktrace,
and make another test hg04_race_h9 to test with one more entry than
the default of 8.
2022-12-29 16:19:24 +01:00
Philippe Waroquiers
3c916e4cbf Fix typo in NEWS. 2022-12-29 13:18:27 +01:00
Philippe Waroquiers
29252c77bb Add clo option the nr of entries in helgrind --history-level=full stack traces
The number of such entries was hardcoded to 8.
A new command line option -history-backtrace-size=number allows
to set the (max) number of entries to record.

Note that according
  perl perf/vg_perf --tools=helgrind --vg=. --vg=../trunk_untouched perf
this change (unexpectedly) improves some tests:
    - Running  tests in perf ----------------------------------------------
    -- bigcode1 --
    bigcode1 .         :0.08s  he: 2.0s (25.5x, -----)
    bigcode1 trunk_untouched:0.08s  he: 2.1s (25.9x, -1.5%)
    -- bigcode2 --
    bigcode2 .         :0.08s  he: 4.2s (52.2x, -----)
    bigcode2 trunk_untouched:0.08s  he: 4.2s (52.0x,  0.5%)
    -- bz2 --
    bz2      .         :0.40s  he: 6.5s (16.3x, -----)
    bz2      trunk_untouched:0.40s  he: 7.4s (18.5x,-14.0%)
    -- fbench --
    fbench   .         :0.15s  he: 2.0s (13.2x, -----)
    fbench   trunk_untouched:0.15s  he: 2.3s (15.5x,-17.7%)
    -- ffbench --
    ffbench  .         :0.16s  he: 3.7s (23.2x, -----)
    ffbench  trunk_untouched:0.16s  he: 3.7s (23.4x, -0.8%)
    -- heap --
    heap     .         :0.05s  he: 5.1s (102.8x, -----)
    heap     trunk_untouched:0.05s  he: 5.2s (104.6x, -1.8%)
    -- heap_pdb4 --
    heap_pdb4 .         :0.07s  he: 5.8s (82.9x, -----)
    heap_pdb4 trunk_untouched:0.07s  he: 5.8s (83.3x, -0.5%)
    -- many-loss-records --
    many-loss-records .         :0.01s  he: 1.0s (96.0x, -----)
    many-loss-records trunk_untouched:0.01s  he: 0.9s (95.0x,  1.0%)
    -- many-xpts --
    many-xpts .         :0.04s  he: 1.6s (38.8x, -----)
    many-xpts trunk_untouched:0.04s  he: 1.5s (38.5x,  0.6%)
    -- memrw --
    memrw    .         :0.06s  he: 2.5s (41.2x, -----)
    memrw    trunk_untouched:0.06s  he: 2.5s (41.2x,  0.0%)
    -- sarp --
    sarp     .         :0.02s  he: 4.0s (198.0x, -----)
    sarp     trunk_untouched:0.02s  he: 3.9s (196.5x,  0.8%)
    -- tinycc --
    tinycc   .         :0.10s  he: 7.1s (70.7x, -----)
    tinycc   trunk_untouched:0.10s  he: 7.6s (75.8x, -7.2%)
    -- Finished tests in perf ----------------------------------------------

    == 12 programs, 24 timings =================
2022-12-29 11:14:05 +01:00
Paul Floyd
9acdd79b69 Disable some memcheck tests on FreeBSD
Fail due to differences in DWARF varinfo generated by clang
compared to GCC. No fix in perspective.
2022-12-26 11:06:32 +01:00
Paul Floyd
4dcfc05c20 Fixes related to Bug 392331
1. Added C++17 check to configure.ac
2. Needed Linux version of suppression
3. Added a filter for pthread_cond_signal
2022-12-26 09:04:17 +01:00
Paul Floyd
67bb7eeec9 Fix suppression file inconsistency from previous commit for Bug 392331 2022-12-25 22:31:55 +01:00
Paul Floyd
7d0389956e Bug 392331 - Spurious lock not held error from inside pthread_cond_timedwait
Added a "Dubious" error category to cover this kind of error.
2022-12-25 21:43:36 +01:00
Paul Floyd
227fa1d53b Cleanup for clangd, mostly FreeBSD
Consistently use braces. Make some bitwise expressions use unsigned.
Use some named variables for magic numbers.
2022-12-25 18:36:20 +01:00
Paul Floyd
d8cc70f6d5 FreeBSD only: fix 445743
Restart 3 of the umtx_op mutex operations if they are interrupted.
2022-12-25 10:18:51 +01:00
Paul Floyd
29cfa77b23 FreeBSD: enable PERF_FAST_LOADV for x86 and cleanup for clangd
clangd doesn't like asm, prefers __asm__
some hicpp-braces-around-statements fixes
2022-12-25 09:25:01 +01:00
Bart Van Assche
1845f51728 Revert "syscall"
Revert an incomplete commit that got published accidentally.
2022-12-24 16:49:56 -08:00
Bart Van Assche
72b556ab15 drd: Improve barrier support
Make test drd/tests/pth_barrier_thr_cr pass on Fedora 38.
2022-12-24 15:32:15 -08:00
Bart Van Assche
2bd7f70421 syscall 2022-12-24 08:18:01 -08:00
Paul Floyd
2de91d914c Bug 444488 - Use glibc.pthread.stack_cache_size tunable
Try to use GLIBC_TUNABLES to disable the pthread stack
cache.
2022-12-23 16:51:15 +01:00
Philippe Waroquiers
7e03a15d8d Pass a dummy process_option_state for dynamic options
The process_option_state is functionally needed during initial parsing
of CLO options.  When later changing them, only changing the CLO
itself is good enough.
But the processing of option needs to have a state.
2022-12-23 16:15:23 +01:00
Paul Floyd
316282cd3b Bug 463027 - broken check for MPX instruction support in assembler 2022-12-23 14:49:39 +01:00
Paul Floyd
8b0105ba63 Improve FreeBSD preadv/pwritev error messages
Also correct a copy paste error in generic readv.
2022-12-22 23:38:54 +01:00
Paul Floyd
5b52408406 Bug 462830 - WARNING: unhandled amd64-freebsd syscall: 474
Add syscall wrappers for sctp_generic_recvmsg and sctp_generic_sendmsg
on FreeBSD.
2022-12-22 23:08:45 +01:00
Paul Floyd
35bb01dd45 FreeBSD: make amd64 aspace max mem 128Gbytes 2022-12-22 09:30:45 +01:00
Paul Floyd
1c61a442b1 FreeBSD: add a check that the mqueuefs kernel module is loaded for the none/tests/mq regtest 2022-12-22 09:09:52 +01:00