Mark Wielaard [Tue, 24 Dec 2024 18:11:17 +0000 (19:11 +0100)]
memcheck/tests/sh-mem-random.c: Set huge_addr to 240GB
https://www.kernel.org/doc/html/next/riscv/vm-layout.html
Says RISC-V Linux Kernel SV39 user-space virtual memory ends at 256GB.
So try at 240GB. This seems a reasonable value for other arches too.
Mark Wielaard [Sun, 15 Dec 2024 20:26:21 +0000 (21:26 +0100)]
VEX/priv/ir_opt.c: Also fold Iop_And1 expressions when possible
Treat Iop_And1 just like And16/And32/And64. Fold fully constant And1
expressions and handle And1(x,True), And1(True,x), And1(x,False),
And1(False,x) and And1(x,x).
Make sure isOnesU handles Ico_U1 (isZerosU and sameIRExprs already
did).
Mark Wielaard [Sat, 14 Dec 2024 22:34:12 +0000 (22:34 +0000)]
Use Ints for fds in PRE and POST sys_close_range
The double_close_range test failed on riscv64-linux because the
close_range wrapper is using unsigned int and the ARG regwords
directly. Which causes the ARG2 == ~0U check to fail. Explicitly
using Int for the fd arguments fixes this. I am not clear on why
this was only an issue for the riscv port. It seems this patch is
OK for other arches (tested on amd64 and i386).
The other script also are likely to need some attention.
This one is probably the most useful for users that want to test OpenMP
aplications with DRD or Helgrind.
Mark Wielaard [Fri, 6 Dec 2024 14:39:25 +0000 (15:39 +0100)]
Recognize new DWARF5 DW_LANG constants
When using --read-var-info=yes readdwarf3 will try to read and
interpret the CU DW_AT_langauge attribute. Since DWARF5 was released a
number if new language constants have been introduced. See
https://dwarfstd.org/languages.html
GCC15 might start emitting some of these when switching to C23 by
default.
When valgrind --read-var-info=yes encounters an unknown DW_LANG
constant it will produce an error and stop processing any further
DWARF.
Recognize all currently known language constants. In particular
recognize DW_LANG_C17, DW_LANG_C23, DW_LANG_C_plus_plus_17,
DW_LANG_C_plus_plus_20, DW_LANG_C_plus_plus_23, DW_LANG_Fortran18,
DW_LANG_Fortran23, DW_LANG_Ada2005, DW_LANG_Ada2012 and DW_LANG_Rust.
Andreas Arnez [Wed, 4 Dec 2024 15:53:17 +0000 (16:53 +0100)]
s390x: Update instruction list with arch15 insns
Recent commits in Binutils added arch15 instructions to s390-opc.txt.
Since then, the script s390-check-opcodes.pl complains about many insns
that are not known to Valgrind.
Update Valgrind's instruction list to be in synch with Binutils again.
Add the new instructions to s390-opcodes.csv and declare them as "not
implemented".
Florian Krohm [Wed, 4 Dec 2024 15:53:17 +0000 (16:53 +0100)]
Bug 495817 - s390x: Fix disassembly for compare-and-branch/trap insns
The insns C[L][G]R[BJ], C[L][G]I[BJ], CL[G]T, and CL[FG]IT are
disassembled incorrectly. Fix this.
Replace s390_format_RIEv1 with s390_format_R0UU and s390_format_R0IU.
Handling both a signed and unsigned immediate constant field with the same
s390_format_... function does not work.
Add function s390_format_RSY_R0RD for CLT and CLGT. Those opcodes have
extended mnemonics. So adjusting the formerly used s390_format_RSY_RURD
wasn't an option as that function is also used for CLM[HY], STCM[HY], and
ICM[HY] which don't have extended mnemonics.
Thus, m3 is interpreted as a string which then causes the segfault.
Fix this by
(1) replacing all of S390_XMNM_LOC* and S390_XMNM_STOC* by S390_XMNM_CLS,
(2) passing down the mnemonic to s390_disasm, and
(3) changing function cls_operand() to be symmetric with cab_operand() by
also taking in the base mnemonic.
Apart from s390_format_RRF_U0RR(), further "load/store on condition"
instructions are handled via s390_format_RIE_RUPIX() and
s390_format_RSY_RDRM(). Adjust these functions accordingly as well.
Florian Krohm [Wed, 4 Dec 2024 15:53:17 +0000 (16:53 +0100)]
s390x: Add `--check-formats' flag to s390-check-opcodes.pl
Enhance the script s390-check-opcodes.pl: Add the command line option
`--check-formats' to print mismatches in the opcode formats between
guest_s390_toIR.c and s390-opc.txt.
Peter Seiderer [Mon, 8 Jul 2024 09:05:47 +0000 (11:05 +0200)]
Add support for landlock_create_ruleset (444), landlock_add_rule (445) and landlock_restrict_self (446) syscalls
- add support for landlock_create_ruleset (444) syscall
- add support for landlock_add_rule (445) syscall
- add support for landlock_restrict_self (446) syscall
Mark Wielaard [Sat, 23 Nov 2024 21:48:03 +0000 (22:48 +0100)]
drd/tests/swapcontext.c: Rename typedef struct thread_local to threadlocal
Since C23 thread_local is a keyword (thread storage duration).
swapcontext.c:23:16: error: expected '{' before 'thread_local'
23 | typedef struct thread_local {
| ^~~~~~~~~~~~
swapcontext.c:23:16: warning: 'thread_local' is not at beginning of declaration [-Wold-style-declaration]
swapcontext.c:23:16: error: 'thread_local' used with 'typedef'
swapcontext.c:26:3: warning: data definition has no type or storage class
26 | } thread_local_t;
| ^~~~~~~~~~~~~~
Mark Wielaard [Sat, 23 Nov 2024 21:37:14 +0000 (22:37 +0100)]
helgrind/tests/tc17_sembar.c: Remove bool typedef
Since C23 bool is a keyword. Also bool wasn't actually used.
tc17_sembar.c:45:14: error: both 'long' and '_Bool' in declaration specifiers
45 | typedef long bool;
| ^~~~
tc17_sembar.c:45:1: warning: useless type name in empty declaration
45 | typedef long bool;
| ^~~~~~~
Mark Wielaard [Sat, 23 Nov 2024 20:28:13 +0000 (21:28 +0100)]
Add exp and supp patterns for missing main frame for ppc64le
In some cases on ppc64le we are missing the main frame.
Add alternative .exp-ppc64le variants for socket_close_xml,
fdleak_cmsg_xml and fdleak_ipv4_xml. And extra suppressions
without a main frame for fdleak_cmsg_supp.
See also commit 04d30049b "Filter away "main" differences in filter_fdleak"
Paul Floyd [Thu, 21 Nov 2024 07:24:35 +0000 (08:24 +0100)]
Helgrind: fix unused result of write warnings
Thanks to GCC deciding that we can't ignore wur annotated
functions by casting to void we need to do otherwise. It was
either pragmas or adding an annotated unused local. Pragmas
seem to be the least awful.
Bart Van Assche [Mon, 18 Nov 2024 21:15:36 +0000 (13:15 -0800)]
drd: Split handle_client_request()
Make handle_client_request() easier to read by splitting it into two
functions: one for Valgrind core client requests and one for thread-
related client requests.
Mark Wielaard [Thu, 14 Nov 2024 11:25:27 +0000 (12:25 +0100)]
coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy
GCC8 (but apparently not later versions) complain about the use of
strncpy when not actually copying a string:
remote-utils.c:1140:14: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation]
strncpy (buf, "watch:", 6);
~~~~~~~~^~~~~~~~~~~~~~~~~~
This is "harmless" because buf is large enough and we will add more
chars (including a zero terminator) later. But using strncpy here is a
bit odd because we don't really want to copy a string, but an array of
6 chars. So use memcpy here to do so, simplyfing the code.
Mark Wielaard [Tue, 12 Nov 2024 12:34:09 +0000 (13:34 +0100)]
vgdb.c (fork_and_exec_valgrind): Fix another off-by-one error write
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced another off-by-one issue trying to write
back the error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is when the child needs to do a chdir and that chdir fails. If
that happens the parent would have gotten the wrong error code.
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced an off-by-one issue trying to write back the
error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is in an "should never happen" path, so hopefully didn't really
cause issues. But if it did happen the parent would have gotten the
wrong error code.
Andreas Arnez [Fri, 8 Nov 2024 13:52:11 +0000 (14:52 +0100)]
s390x regtest: Add missing register clobber in misc3.c
Depending on compiler options, the translation of test_mvcrl() in
`misc3.c' can misbehave because the inline assembly writes to r0 and
doesn't declare that.
Add a register clobber to fix this. Also, tell the compiler the actual
length of `from' and `to' instead of the decremented value.
Paul Floyd [Sun, 3 Nov 2024 19:42:43 +0000 (20:42 +0100)]
Bug 494327 - Crash when running Helgrind built with #define TRACE_PTH_FNS 1
Use write() rather than 'fprintf()' for the TRACE_PTH_FNS blocks for
pthread_mutex_lock and pthread_mutex_lock. Mixing FILE and fd isn't
great, but this is to stderr which gets flushed on every line, and
it is only for developer builds that modify that TRACE_PTH_FNS macro.
Report track-fd errors for fd used which was not opened or already closed
Add (optional) pathname, description, where_closed and where_opened
fields to struct FdBadUse. Print those fields when set in fd_pp_Error.
Add a new function ML_(find_OpenFd) that provides a recorded OpenFd
given an fd (or NULL when the fd was never recorded).
In ML_(fd_allowed) when using a file descriptor use ML_(find_OpenFd)
to see if the fd was ever created, if not create an "was never
created" FdBadUse error. If it was created, but already closed create
an "was closed already", filling in as much details as we can.
Add none/tests/use_after_close.vgtest to test, already closed, never
created, invalid, double (double) close and invalid close issues.
Adjust error message in none/tests/fdbaduse.stderr.exp.
Florian Krohm [Tue, 29 Oct 2024 15:24:31 +0000 (16:24 +0100)]
Bug 493959 - s390x: Fix regtest failure for op00 with /bin/dash
On different machines /bin/sh may be impersonated by different shells, and
those behave differently as to whether they write "Illegal instruction ..."
to stderr. While newer versions of bash do not, dash does.
For the op00 test case this means that an additional line may be written
to `op00.stderr.out', depending on which shell is being used. Hence
adding "Illegal instruction ..." as an expected line to `op00.stderr.exp'
wouldn't work on all systems.
Instead, fix this issue by adding the case of "illegal instruction" to the
general filtering logic in filter_stderr_basic.in, where various other
messages of this kind are already filtered out.