New qExecAndArgs packet has been added recently to GDB's remote
protocol.
The new qExecAndArgs packet is sent from GDB, and gdbserver replies
with a packet that includes the executable filename and the arguments
string that were used for starting the initial inferior.
On the GDB side this information can be used to update GDB's state,
the 'show remote exec-file' will reflect how gdbserver was started,
and 'show args' will reflect the arguments used for starting the
inferior.
When running valgrind together with GDB like this:
All issues are similar to this:
--- mcblocklistsearch.stderrB.exp
+++ mcblocklistsearch.stderrB.out
@@ -1,7 +1,8 @@
vgdb-error value changed from 0 to 999999
-Breakpoint 1 at 0x........: file leak-tree.c, line 42.
-Breakpoint 2 at 0x........: file leak-tree.c, line 68.
+Haltepunkt 1 at 0x........: file leak-tree.c, line 42.
+Haltepunkt 2 at 0x........: file leak-tree.c, line 68.
Continuing.
+Warnung: Missing auto-load script at offset 0 in section .debug_gdb_scripts
Breakpoint 1, f () at leak-tree.c:42
42 t->l = mk(); // B
Continuing.
@@ -63,4 +64,4 @@
0x........[16] indirect loss record 4
0x........[16] indirect loss record 5
monitor command request to kill this process
-Remote connection closed
+Remote Verbindung wurde beendet
Mark Wielaard [Thu, 23 Oct 2025 23:12:19 +0000 (01:12 +0200)]
configure.ac: Use primary arch flags for openssl and libaio checks
Make sure that the configure check for openssl/crypto and libaio use
the primary arch flags. These are used in testcases for the primary
arch and should compile and link with the primary arch flags (which
are empty on most arches, but are set explicitly on e.g. mips).
Move the libaio check after the compiler check flags.
Make function check_valgrind_output actually check something..
Remove --check-prereq logic. It is not needed. I think I was doing some
experiment of using objdump to make sure the insns written out by
valgrind match those produced by objdump. And then there was different
behaviour of objdump in different versions.
Mark Wielaard [Mon, 20 Oct 2025 17:11:41 +0000 (19:11 +0200)]
Update NEWS with more items
- Make BUILD_DOCS controls building documentation.
- LTP integration has been updated to v20250930.
- New Linux syscall wrappers (cachestat, futex_waitv, listmount,
mount_setattr, mseal, quotactl_fd, remap_file_pages, setdomainname,
statmount, swapoff, swapon, sysfs and ustat).
- New --modify-fds=yes is like --modify-fds=high except for fds 0,1,2.
- New --track-fds=bad only produces errors for bad file descriptor usage.
- With --xml=yes log now always uses output protocol 6.
- vgdb now handles the qExecAndArgs packet.
- DWARF inlined subroutine handling has been rewritten to work cross CUs.
Mark Wielaard [Mon, 20 Oct 2025 17:04:25 +0000 (19:04 +0200)]
Document FdBadUse in xml-output-protocol5.txt
The core error FdBadUse was added in commit 22971a15d62d
"Report track-fd errors for fd used which was not opened or already closed"
But not documented. Add it to the protocol documentation now.
GCC notices that this_seg is set, but never really used in this
function
m_debuginfo/readpdb.c: In function 'DEBUG_SnarfLinetab':
m_debuginfo/readpdb.c:1542:23: warning: variable 'this_seg' set but not used [-Wunused-but-set-variable=]
1542 | Int this_seg;
| ^~~~~~~~
Mark Wielaard [Sun, 12 Oct 2025 21:57:43 +0000 (23:57 +0200)]
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.
Mark Wielaard [Fri, 17 Oct 2025 16:23:58 +0000 (18:23 +0200)]
Keep at least one frame while peeling syscall frames
VG_(get_StackTrace_with_deltas) might peel extra glibc syscall
(cancel) frames. But if the backtrace failed, or only contains such
syscall frames then we should keep at least one (the initial frame will
always be there). Various routines expect n_ips of a Stacktrace to be
at least 1.
New qExecAndArgs packet has been added recently to GDB's remote
protocol.
The new qExecAndArgs packet is sent from GDB, and gdbserver replies
with a packet that includes the executable filename and the arguments
string that were used for starting the initial inferior.
On the GDB side this information can be used to update GDB's state,
the 'show remote exec-file' will reflect how gdbserver was started,
and 'show args' will reflect the arguments used for starting the
inferior.
When running Valgrind from inside GDB, we can see that GDB actually
sends the packet to vgdb and vgdb is able to respond to it.
[remote] Sending packet: $qExecAndArgs#96
[remote] Packet received: U
[remote] packet_ok: Packet qExecAndArgs (fetch-exec-and-args) is supported
To be able to run Valgrind from inside GDB we currently have to set
remote exec-file and our goal is to avoid that to make running Valgrind
from GDB easier for the users. There's work on GDB side which should allow
us to avoid this soon.
When vgdb replies with 'U', it indicates that no executable has been set.
GDB sees that the executable that it has loaded is inside the sysroot
(which we set with 'set sysroot /'), then GDB knows that the remote and
GDB can see the same file. GDB will then automatically use the current
executable path as the remote exec-file value.
Paul Floyd [Tue, 14 Oct 2025 06:27:16 +0000 (08:27 +0200)]
Fix exe name warnings
Most of the exe name functions can take a const char* for the name.
Indeed, on Linux this is a requirement since we also lookup
debuginfod-find using a const char string literal.
The exception to this rule is for scripts. In this case the script
shebang can refer to another script with another shebang. And so on
until eventually an ELF or macho file is encountered. In that case
VG_(args_the_exename) will get freed if necessary and reassigned
to a new string. So VG_(load_script) needs to be able to take a
non-const char* name, unlike VG_(load_ELF) and VG_(load_macho).
VG_(args_the_exename) is now non-const (which fixes a warning
when freeing it), VG_(load_script) takes a non-const name
and there is an ugly cast for the function pointer.
Paul Floyd [Mon, 13 Oct 2025 07:18:18 +0000 (09:18 +0200)]
FreeBSD syscall wrapper: fix warning
Was giving
m_syswrap/syswrap-main.c:370:28: warning: variable 'saved' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]
370 | syscall_mask, &saved, sizeof(vki_sigset_t)
| ^~~~~
Initialising it is probably the safest thing to do, but I suspect that the
argument ought not to be const. Will check on that.
While I'm at it, looking at how Solaris handles the carry flag it's much
better than the global variable used by FreeBSD and Darwin. Will check on
that as well.
Paul Floyd [Mon, 13 Oct 2025 06:38:09 +0000 (08:38 +0200)]
configure and make: add configure checks for C++ exception warnings
Add checks for -Wno-implicit-exception-spec-mismatch
(FLAG_W_NO_IMPLICIT_EXCEPTION_SPEC_MISMATCH)
and -Wno-missing-exception-spec
(FLAG_W_NO_MISSING_EXCEPTION_SPEC)
Also we should clean up C++ flag checking a bit. If all checks get
grouped together than just one AC_LANG(C++)/AC_LANG(C) would be
needed.
Paul Floyd [Sun, 12 Oct 2025 11:29:45 +0000 (13:29 +0200)]
FreeBSD regtest: add a prereq for bug452274
This test tends to hang when running in a VM. The problem is that
the test spams both syscalls (write) and signals (SIGVTALRM from
setitimer). The test halts after 100 signals have been handled.
Under VirtualBox the timer signals get starved by the syscalls
and the limit of 100 doesn't get reached (at least not in any
reasonable amount of time).
Martin Cermak [Thu, 2 Oct 2025 15:11:50 +0000 (17:11 +0200)]
Update the LTP version in valgrind testsuite to v20250930
Update the LTP version in valgrind testsuite to v20250930.
All patches from auxprogs/ltp-patches were accepted by LTP
upstream and included in the release, so these can now be
dropped locally.
Andreas Arnez [Thu, 9 Oct 2025 11:42:39 +0000 (13:42 +0200)]
s390x: Make IBM z17 known to Valgrind
Make the IBM z17 machine model 9175 known to Valgrind. Also add the
expected output of the s390x-specific "ecag" test case on an IBM z17, so
the test case succeeds on that system.
Florian Krohm [Fri, 3 Oct 2025 16:26:55 +0000 (16:26 +0000)]
Control building documentation (BZ 495483)
Introduce Makefile variable BUILD_DOCS with these possible values:
none - does not build any documentation
all - builds all documentation
html - builds HTML docs but skips building PDFs
BUILD_ALL_DOCS is still recognised for backward compatibility and
is mapped to BUILD_DOCS like so:
If not specified --> BUILD_DOCS=all
BUILD_ALL_DOCS=yes --> BUILD_DOCS=all
BUILD_ALL_DOCS=no --> BUILD_DOCS=html
On some file systems the testfiles 1000 and 1001 come out in different
order. Add filter_sort to sort the output lines to always appear at the
same order.
Florian Krohm [Wed, 1 Oct 2025 12:19:13 +0000 (12:19 +0000)]
VEX: Remove algebraic simplification for shift IROps.
Shl/Shr/Sar(0,x) ==> 0
Don't. Because doing so removes the undefined behaviour in case the shift
amount is out of range. This is also consistent with what constant folding
does in this case, namely, passing the undefined behaviour down the VEX
pipeline.
s390: Add testcases for unhandled IEEE exceptions. Fixes BZ 306098
New emulation warnings: EmWarn_S390X_XxC_not_zero and EmWarn_S390X_XiC_not_zero
New testcases bfp-XxC, dfp-XxC, and dfp-XiC.
New testcase driver emwarn-gen.pl to get around valgrind's restriction
on the number of emulation warnings.
Andreas Arnez [Mon, 29 Sep 2025 14:11:04 +0000 (16:11 +0200)]
s390x: Fix inline assembly for STFLE
The inline assembly for emitting the STFLE instruction changes GPR 0, but
fails to mention it in the clobber list. Depending on the compiler's
mood, this may result in wrong code.
A simple fix would be to just add "0" to the clobber list, but for
readability it also helps to move the inline assembly to a separate
function. So do that. In that function, use an "asm" variable for GPR 0
instead of moving the value back and forth between registers.
Rename rounding-1 to bfp-306054 because that was the corresponding BZ.
Rename bfp-3 to bfp-muldiv as it is more expressive.
Only compile testcases for 128-bit BFP if the compiler supports -mlong-double-128.
Add -mlong-double-128 to the compile flags for the files that need it.
This concludes fixing https://bugs.kde.org/show_bug.cgi?id=509572
Mark Wielaard [Wed, 24 Sep 2025 21:16:29 +0000 (23:16 +0200)]
Deal with linux arches that don't have getdents, only getdents64
Not all linux arches have getdents, some newer arches (arm64 and
riscv64) only implement getdents64. So only use the function
filter_valgrind_fds_from_getdents_with_refill on linux with
__NR_getdents.
Also move the getdents_filter testcase under none/tests/linux and only
use getdents64.
Fixes: e8e4066c3a01 ("Filter Valgrind FDs from getdents syscalls")
https://bugs.kde.org/show_bug.cgi?id=331311
s390: Reorg and extend BFP "convert to/from fixed/logical" testcases
Testing these insns was spread over 3 testcases: rounding-3, fpconv,
and fpext.
rounding-3 was testing "convert to fixed" with rounding per FPC.
fpext was testing "convert to/from logical" with rounding per M3 field.
fpconv was testing "convert to/from fixed" with rounding per M3 field.
The new testcase bfp-convert replaces these 3. It removes the
"convert from fixed/logical" testing because that is done in bfp-emit.pl.
It consolidates end extends "convert to fixed/logical" testing from
those files.
Testing "convert to logical" has been commented out until the condition
code weirdness for negative input values has been sorted.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509572
This change prevents client programs from seeing Valgrind's internal file
descriptors when scanning /proc/self/fd or /proc/<pid>/fd.
This patch modifies the getdents and getdents64 syscall wrappers to
selectively filter out Valgrind's internal file descriptors only when
listing /proc/*/fd directories for the current process.
Add none/tests/getdents_filter.vgtest test that tests that the
Valgrind's file descriptors are hidden from the client program
and verifies both /proc/self/fd filtering and that regular
directory listings remain unfiltered.
Remove square root tests as they are covered by bfp-emit.pl
Likewise for multiplication.
Add tests for division.
New file bfp-arith.c: Check condition code of arithmetic ops.
Remove bfp-1.c
Part of https://bugs.kde.org/show_bug.cgi?id=509572
Paul Floyd [Mon, 22 Sep 2025 12:59:17 +0000 (14:59 +0200)]
gdbserver regtest: add return value to sleepers select error message
This is failing on FreeBSD 15 (looks like an OS or libc regression).
Improve the error message to make the problem clearer. errno is 0
but select is returning 93 (from a set of 0 fds!).
Paul Floyd [Sun, 21 Sep 2025 15:08:35 +0000 (17:08 +0200)]
Refactor: make try_get_interp extern and multi-plaftorm
Previously it was static and defined for Darwin, FreeBSD and Linux.
Now it is global VG_(args_the_exename) and has a length check.
Also fixed a nasty bug related to VG_(args_the_exename).
Initially this is set to point to the name of the client command
in Valgrinds own arguments. Later when checking for scripts or binaries
VG_(load_script) may get called recursively. If it gets called more than
once it sets VG_(args_the_exename) to point to the new name.
But that is on the stack. Later, if the stack grows too much the
name will get overwritten. I was seeing that with my first versions
of this code in the recursive tests in none/tests/scripts.
Now I'm allocating VG_(args_the_exename) on the heap.
Paul Floyd [Sat, 20 Sep 2025 17:20:50 +0000 (19:20 +0200)]
FreeBSD amd64: amd64 syscalls only ever need max 7 args
The only possible exception would be a syscall0 of SYS_sendfile
done by the host. Since we're never going to do that reduce the number
of arguments to 7.
For a BFP insn X in the guest code the same insn will be emitted in
the jitted code. This does not hold universally but for most BFP
insns it does.
bfp-emit.pl contains a complete list of all BFP insns as of Principles
of Operations SA22-7832-14. It tests all insns for which the above
observation is true and ensures the emitted insn matches the insn in
the guest code.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509572
Martin Cermak [Fri, 19 Sep 2025 15:25:30 +0000 (17:25 +0200)]
Wrap the mount_setattr syscall 442
int syscall(SYS_mount_setattr, int dirfd, const char *pathname,
unsigned int flags, struct mount_attr *attr, size_t size);
The mount_setattr() system call changes the mount properties of a
mount or an entire mount tree. If pathname is a relative pathname,
then it is interpreted relative to the directory referred to by the
file descriptor dirfd. If dirfd is the special value AT_FDCWD, then
pathname is interpreted relative to the current working directory of
the calling process. If pathname is the empty string and
AT_EMPTY_PATH is specified in flags, then the mount properties of the
mount identified by dirfd are changed
Declare a mount_setattr wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINX_ with PRE handler in syswrap-linux.c
Part of this update also is a fix of the sys_move_mount wrapper.
Specifically there was a typo mount_moce vs. move_mount, and also
there was a problem in handling VKI_AT_FDCWD special fd value in the
check for to_fd and to_pathname.
Martin Cermak [Fri, 19 Sep 2025 07:31:39 +0000 (09:31 +0200)]
Wrap the setdomainname syscall
The setdomainname() call sets the domain name to the value given in the
character array name. The len argument specifies the number of bytes in
name. (Thus, name does not require a terminating null byte.)
Declare a setdomainname wrapper in priv_syswrap-linux.h and hook it for
{amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux using
LINX_ with PRE handler in syswrap-linux.c
Remove stdout.exp file as it is not needed.
The mandatory .stderr.exp file was not empty even though disasm-test
does not write anything to stderr. Annoying!
../filter_stderr was doing it. Adjust filter_stderr accordingly and
let .stderr.exp reflect the actual output.
Martin Cermak [Fri, 19 Sep 2025 09:47:14 +0000 (11:47 +0200)]
Add missing ppc64-linux and s390x-linux syswraps existing on other arches
This update adds following ppc64le and s390x syswraps:
- sys_msgctl
- sys_semctl
- sys_semtimedop
- sys_sethostname
- sys_shmctl
- sys_sigpending
- sys_stime
This update adds following ppc64le syswraps:
- sys_setns
This update adds following s390x syswraps:
- sys_bpf
Blacklist the shmctl05, as it is a long running one. It does
pass on all architectures afaics, but needs a relatively high
LTP_TIMEOUT_MUL setting. So, let's skip that one.