1577 Commits

Author SHA1 Message Date
Alexandra Hájková
56ccb1e36c vgdb --multi: fix various typos, indentation and such
Remove --launched-with-multi from --help-debug output since it is not
a real user option. Do add a comment in m_main.c explaining the
internal usage.

Add a top-level comment describing the three usages of vgdb.

Fix comment description of decode_hexstring, create_packet,
split_hexdecode.

Consistently use 3 space indention in send_packet and receive_packet
and next_delim_string and split_hexdecode, count_delims,
do_multi_mode.

Fix return type of count_delims to size_t.

Add a note in coregrind/m_gdbserver/server.c to sync qSupported
replies with coregrind/vgdb.c.

Use vgdb (all lowercase) and GDB (all caps) consistently in the
manual.
2023-04-20 14:29:45 +02:00
Carl Love
19c9e2418c PowerPC:, Update test test_isa_3_1_R1_RT.c, test_isa_3_1_R1_XT.c
The commit:

  commit 20cc0680c3491e062c76605b24e76dc02e16ef47
  Author: Carl Love <cel@us.ibm.com>
  Date:   Mon Apr 17 17:12:25 2023 -0400

      PowerPC:, Fix test test_isa_3_1_R1_RT.c, test_isa_3_1_R1_XT.c

Fixes an issue with the PAD_ORI used in the the tests by explicitly adding
SAVE_REGS and RESTORE_REGS macros.  The macros ensure that the block of
immediate OR instructions don't inadvertently change the contents of the
registers.

John Reiser suggested that the PAD_ORI asm statements in the PAD_ORI
macro be updated to inform the compiler which register the ori instruction
is clobbering.  The compiler will then generate the code to save and
restore the register automatically.  This is a cleaner solution then
explicitly adding the macros to store and restore the registers.  It is
functionally cleaner in that the value fetched by the instruction under
test is not modified by the PAD_ORI instructions.

This patch removes the SAVE_REG and RESTORE_REG macros and updates the
PAD_ORI macro.
2023-04-19 14:43:48 -04:00
Carl Love
20cc0680c3 PowerPC:, Fix test test_isa_3_1_R1_RT.c, test_isa_3_1_R1_XT.c
Test adds a block of xori instructions for use with the PC relative tests.
The registers used by the xori instructions need to be saved and restored,
otherwise the register changes can impact the execution of the for loops
in the test as registers are randomly changed.  The issue occcurs when
GCC is optimizing and inlining the test functions.
2023-04-18 15:44:19 -04:00
Mark Wielaard
16be0ca4ba tests fdleak.h close all open file descriptors > 2
Use sysconf (_SC_OPEN_MAX) to find the upper limit. Or use 1024
if that fails.

https://bugs.kde.org/show_bug.cgi?id=467714
2023-04-15 00:14:01 +02:00
Paul Floyd
1e42338863 regtest: add new multi option to cmdline2 help output expecteds 2023-04-14 08:15:40 +02:00
Paul Floyd
0ae17c117e FreeBSD: auxv changes for FreeBSD 13.2 2023-04-13 22:45:46 +02:00
Paul Floyd
50bded71b2 Bug 436413 - Warn about realloc of size zero
Adds a new warning to memcheck when realloc is used with a size of 0.
For a long time this has been "implementation defined" and so
non-portable. With C23 it will become UB.

Also adds a switch to turn off the error generation and a
second switch to select between the most common
"implementation" behaviours. The defaults for this second
switch are baked in at build time.
2023-03-10 21:55:14 +01:00
Paul Floyd
b861458d3d FreeBSD: make rfork() fail more gracefully
rfork() is barely used in base FreeBSD. The main use
is in posix_spawn(). If rfork() fails with EINVAL
then it falls back to using vfork(). This is preferable
to Valgrind bombing.

ksh93 uses posix_spawn. I tested bash and csh and they had
no problems.

Also add 'hello world" smoke tests for bash csh and ksh
2023-02-25 15:16:35 +01:00
Paul Floyd
7136cd9876 musl regtest : fix warnings and badly initialized struct msghdr 2023-02-21 23:05:22 +01:00
Paul Floyd
fe008c8739 regtest: remove compiler warnings with clang 2023-02-19 10:10:59 +01:00
Paul Floyd
b1aba91160 FreeBSD: cleanup and refactor syscalls readlink and readlinkat
There was some code to handle /proc/curproc/file (a symlink to
the exe that wee need to bodge as it refers to the tool exe).
But it was neither tested nor working.

Can't use the same technique as Linux and Solaris which have more
complete /proc filesystems where each pid has symlinks for
each open file, which we use for the guest. Instead need to
copy the path ourselves. So move sys_readlink out of generic.

Simplify the handling of the resolved guest exe name - store it in
a global like VG_(args_the_exename).
2023-01-31 21:52:36 +01:00
Paul Floyd
f7e4bb4af2 Bug 382034 - Testcases build fixes for musl 2023-01-27 08:42:06 +01:00
Paul Floyd
e2eeebafa6 FreeBSD: fix compile of auxv on FreeBSD 12 2023-01-24 22:00:44 +01:00
Paul Floyd
f7983be3f2 FreeBSD: improve auxv filter
Didn't work id the clone directory isn't 'valgrind'
2023-01-22 09:41:49 +01:00
Paul Floyd
a526bbd051 FreeBSD: Fix auxv AT_EXECPATH
This was being copied from the host. Now it's synthesized for
the guest. Also improve the none/freebsd/auxv test to
print a few of the strings in auxv (but not the envp ones).
2023-01-21 20:49:30 +01:00
Paul Floyd
ed73978bdb Update wrong expecteds for Bug 241072 2023-01-12 08:00:27 +01:00
Paul Floyd
8fcc813468 Bug 241072 List tools in --help output 2023-01-11 21:42:41 +01:00
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
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
8224cf37a9 Update none/tests/cmdline1 and 2 for non-linux 2022-12-31 10:13:19 +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
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
Mark Wielaard
0811a612dd Implicit int in none/tests/faultstatus.c
There is a definition in faultstatus.c that is not accepted by
C99 compilers (implicit ints were removed in that language revision).

https://bugs.kde.org/show_bug.cgi?id=462007
2022-11-18 20:12:06 +01:00
Paul Floyd
ac6d9faf4b Bug 351857 - confusing error message about valid command line option
Added code to handle missing "=something".
2022-11-12 21:02:07 +01:00
Paul Floyd
f2550057e1 Bug 170510 - Don't warn about ioctl of size 0 without direction hint
Apply this to generic and update the message on all platforms.
2022-11-10 22:31:07 +01:00
Mark Wielaard
6a5a689fd9 Add none/tests/freebsd/auxv.stderr.exp-freebsd14 to EXTRA_DIST 2022-10-20 00:34:15 +02:00
Paul Floyd
12d2a3c85d Auxv user stack for FreeBSD, last part
Clean up, didn't need an extra func for user stack limit.
2022-10-19 00:51:05 +02:00
Paul Floyd
802f2d21d9 Auxv user stack for FreeBSD, part 2
Try to set the stack limit.
2022-10-18 22:11:32 +02:00
Paul Floyd
e5b069f2e8 Add abexit to non-Linux expecteds for gdb atexit events 2022-09-18 16:57:04 +02:00
Philippe Waroquiers
e489f31974 Add abexit in --vgdb-stopat. fix 459031 --error-exitcode doc. Add lwpid in thread_wrapper tracing.
Note that this modifies files on darwin/solaris/bsd but I only did a linux
build so possibly this commit might cause a compilation error, that should
then be trivial to fix.

Also added memmem test in the list of ignored files.
2022-09-17 22:54:05 +02:00
Paul Floyd
5d058e6332 Backout synthesizing AT_BSDFLAGS auxv entry
This was causing a crash on several FreeBSD 13.1 testcases
(but not 13.0). Probably related to "sig fastblock".
2022-07-03 21:28:57 +02:00
Paul Floyd
b29a1e1cf5 Improve FreeBSD sysctl kern.usrstack
This was handled by sysctl but not sysctlbyname.
The value returned was wrong.
Added a regtest.
2022-07-03 15:12:20 +02:00
Paul Floyd
9f27d8fbc7 Bug-456171 [PATCH] FreeBSD: Don't record address errors when accessing the 'kern.ps_strings' sysctl struct
There is quite a lot of stuff here.

The problem is that setproctitle and kern.ps_strings were using the Valgrind host auxv
rather than the guest. The proposed patch would have just ignored those memory ranges.

I've gone a fair bit further than that
1. refactored the initimg code for building the client auxv. Previously we were
   simply ignoring any non-scalar entries. Now we copy most of thse as well.
   That means that 'strtab' built on the client stack no longet only contains
   strings, at can also now contain binary structures. Note I was a bit
   concerned that there may be some alignment issues, but I haven't seen any
   problems so far.
2. Added intercepts to sysctl and sysctlbyname for kern.ps_strings, then find
   AT_PS_STRINGS from the client auxv that is now usable from step 1.
3. Some refactoring of sysctl and sysctlbyname syscall wrappers. More to do
   there!
4. Added a setproctitle testcase (that also tests the sysctls).
5. Updated the auxv testcase now that more AT_* entries are handled.
2022-07-03 13:05:54 +02:00
Paul Floyd
3ce7673720 Add syscall wrappers for FreeBSD funlinkat and copy_file_range
Aslo add a smoketest for /bin/cp, which uses copy_file_range
2022-06-06 22:37:47 +02:00
Paul Floyd
a4151207a2 Add small sleep to none/tests/pth_2sig to help prevent hanging
On FreeBSD 13.0 x86 this testcase was hanging on some systems.
It seems like the SIGTERM signals were not being recieved
before the child exited, which left the parent hanging in the
pause() waiting to be killed.

Reported, patch provided and tested by Nick Briggs.
2022-05-23 21:27:58 +02:00
Paul Floyd
14df01dc4e Add expecteds to EXTRA_DIST 2022-05-20 22:13:16 +02:00
Mark Wielaard
2dad922aba Add cmdline{1,2}.stdout.exp-non-linux files
The new --enable-debuginfod=<yes|no> command line flag is only
available on GNU/Linux systems. Add new exp file for other systems.
2022-05-20 14:58:45 +02:00
Aaron Merey
8d4eb6be20 Add --enabled-debuginfod command line option
Currently debuginfod is enabled in Valgrind when the $DEBUGINFOD_URLS
environment variable is set and disabled when it isn't set.

This patch adds an --enable-debuginfod=<yes|no> command line option
to provide another level of control over whether Valgrind attempts
to download debuginfo. "yes" is the default value.

$DEBUGINFOD_URLS must still contain debuginfod server URLs in order
for this feature to work when --enable-debuginfod=yes.

https://bugs.kde.org/show_bug.cgi?id=453602
2022-05-20 02:48:53 +02:00
Paul Floyd
ed78405cd6 Make testcase myrandom() noinline.
With clang 13 none/tests/amd64/amd64locked fails because of what
looks like a clang optimization error. do_bt_G_E_tests is the
point of failure, and one factor is that clang 13 is inlining
myrandom().
2022-05-18 23:41:43 +02:00
Paul Floyd
7e5073f853 Changes to auxv for FreeBSD 13.1 2022-05-14 16:24:22 +02:00
Paul Floyd
8187a60ac3 Add a configure test for -ansi and use it for none/tests/ansi 2022-04-19 22:21:37 +02:00
Paul Floyd
d6bcd3ba29 Some more auxv extensions for FreeBSD 14
New entries added to testcase and documented in initimg.
May need more work
2022-04-14 00:01:49 +02:00
Paul Floyd
d5b782056d Fix typo in EXTRA_DIST 2022-04-12 23:55:46 +02:00
Paul Floyd
3e7774ea5a Bug 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed
FreeBSD (and Darwin) use the carry flag for syscall syscall status.
That means that in the assembler for do_syscall_for_client_WRK
they have a call to LibVEX_GuestAMD64_put_rflag_c (amd64) or
LibVEX_GuestX86_put_eflag_c (x86). These also call WRK functions.

The problem is that do_syscall_for_client_WRK has carefully crafted
labels correspinding to IP addresses. If a signal interrupts
processdings, IP can be compared to these addresses so that
VG_(fixup_guest_state_after_syscall_interrupted) can work
out how to resume the syscall. But if IP is in the save
carry flag functions, the address is not recognized and
VG_(fixup_guest_state_after_syscall_interrupted) fails.

The crash in the title happens because the interrupted
syscall does not reset its status, and on the next syscall
it is expected that the status be idle.

To fix this I added global variables that get set to 1
just before calling the save carry flag functions, and cleared
just after. VG_(fixup_guest_state_after_syscall_interrupted)
can then check this and work out which section we are in
and resume the syscall correctly.

Also:

Start a new NEWS section for 3.20

Add a regtest for this and also a similar one for Bug 445032
(x86-freebsd only, new subdir).

I saw that this problem also probably exists with macOS, so I made
the same changes there (not yet tested)
2022-04-12 23:50:48 +02:00
Mark Wielaard
8eb547054a Warn for execve syscall with argv or argv[0] being NULL.
For execve valgrind would silently fail when argv was NULL or
unadressable. Make sure that this produces a warning under memcheck.

The linux kernel accepts argv[0] being NULL, but most other kernels
don't since posix says it should be non-NULL and it causes argc to
be zero which is unexpected and might cause security issues.

This adjusts some testcases so they don't rely on execve succeeding
when argv is NULL and expect warnings about argv or argv[0] being
NULL or unaddressable.

https://bugs.kde.org/show_bug.cgi?id=450437
2022-04-06 22:48:45 +02:00
Paul Floyd
bbc3bcab0a Bug 451843 - valgrind fails to start on a FreeBSD system which enforces W^X
Also add FreeBSD 13.1 to configure.ac
2022-04-03 15:50:38 +02:00
Mark Wielaard
df214356db none/tests/amd64/avx_estimate_insn.vgtest fails on AMD processors
commit ef9ac3aa0fd3ed41d74707ffe49abe9ad2797ddd
"fix avx-1 amd64 test" split off the estimate instructions
into their own testcase avx_estimate_insn.

The commit message suggested that two .exp files would be
added, one for the intel and one for the amd cases.

It seems the .exp-amd variant was forgotten. This commit
adds it.

https://bugs.kde.org/show_bug.cgi?id=413330
2022-02-16 23:26:16 +01:00
Carl Love
ab740a1741 Powerpc test_isa_3_1_VRT fix
The vcmpequq, vcmpgtsq, vcmpgtuq test cases for the dotted versions of the
instructions were issuing the non-dotted instruction.

This patch fixes the issues and updates the expected output.

Note, the issue exposed a bug in the VEX/priv/guest_ppc_toIR.c handling of
the instructions.  That fix is in a separate patch.
2022-02-02 00:52:31 +00:00
Paul Floyd
49fe0dc74a Anticipate testcase problems with GCC 12
There will be a lot more to come.

On amd64 Linux
In faultstatus was seeing the division by zero and emitting a ud2 opcode.
In wrap3 a pair of mutually recursive functions were being inlined.
When forced not to be inlined GCC merged them into a single function.
It cannot see that the client requests have diffeent behaviour.
2021-11-23 23:37:02 +01:00