You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(32) |
Oct
|
Nov
|
Dec
|
|
From: Paul F. <pa...@so...> - 2021-10-09 12:13:50
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e2e5d75f5cbc108d68142c4c56878df9abaed653 commit e2e5d75f5cbc108d68142c4c56878df9abaed653 Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 14:11:48 2021 +0200 FreeBSD support, patch 11 coregrind added files the key mechanics and the syscall wrappers Diff: --- configure.ac | 2 + coregrind/Makefile.am | 11 + coregrind/launcher-freebsd.c | 325 ++ coregrind/link_tool_exe_freebsd.in | 82 + coregrind/m_dispatch/dispatch-amd64-freebsd.S | 321 ++ coregrind/m_dispatch/dispatch-x86-freebsd.S | 251 + coregrind/m_initimg/initimg-freebsd.c | 979 ++++ coregrind/m_sigframe/sigframe-amd64-freebsd.c | 432 ++ coregrind/m_sigframe/sigframe-x86-freebsd.c | 457 ++ coregrind/m_syswrap/priv_syswrap-freebsd.h | 554 ++ coregrind/m_syswrap/syscall-amd64-freebsd.S | 207 + coregrind/m_syswrap/syscall-x86-freebsd.S | 201 + coregrind/m_syswrap/syswrap-amd64-freebsd.c | 1113 ++++ coregrind/m_syswrap/syswrap-freebsd.c | 6876 +++++++++++++++++++++++++ coregrind/m_syswrap/syswrap-x86-freebsd.c | 1517 ++++++ 15 files changed, 13328 insertions(+) diff --git a/configure.ac b/configure.ac index 39e619575e..275c0ca02c 100755 --- a/configure.ac +++ b/configure.ac @@ -5211,6 +5211,8 @@ AC_CONFIG_FILES([ ]) AC_CONFIG_FILES([coregrind/link_tool_exe_linux], [chmod +x coregrind/link_tool_exe_linux]) +AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd], + [chmod +x coregrind/link_tool_exe_freebsd]) AC_CONFIG_FILES([coregrind/link_tool_exe_darwin], [chmod +x coregrind/link_tool_exe_darwin]) AC_CONFIG_FILES([coregrind/link_tool_exe_solaris], diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 01b8783ee4..1de685bb45 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -286,6 +286,7 @@ noinst_HEADERS = \ m_syswrap/priv_syswrap-generic.h \ m_syswrap/priv_syswrap-linux.h \ m_syswrap/priv_syswrap-linux-variants.h \ + m_syswrap/priv_syswrap-freebsd.h \ m_syswrap/priv_syswrap-darwin.h \ m_syswrap/priv_syswrap-solaris.h \ m_syswrap/priv_syswrap-main.h \ @@ -388,6 +389,8 @@ COREGRIND_SOURCES_COMMON = \ m_dispatch/dispatch-mips32-linux.S \ m_dispatch/dispatch-mips64-linux.S \ m_dispatch/dispatch-nanomips-linux.S \ + m_dispatch/dispatch-x86-freebsd.S \ + m_dispatch/dispatch-amd64-freebsd.S \ m_dispatch/dispatch-x86-darwin.S \ m_dispatch/dispatch-amd64-darwin.S \ m_dispatch/dispatch-x86-solaris.S \ @@ -412,6 +415,7 @@ COREGRIND_SOURCES_COMMON = \ m_gdbserver/valgrind-low-nanomips.c \ m_gdbserver/version.c \ m_initimg/initimg-linux.c \ + m_initimg/initimg-freebsd.c \ m_initimg/initimg-darwin.c \ m_initimg/initimg-solaris.c \ m_mach/mach_basics.c \ @@ -426,6 +430,8 @@ COREGRIND_SOURCES_COMMON = \ m_sigframe/sigframe-common.c \ m_sigframe/sigframe-x86-linux.c \ m_sigframe/sigframe-amd64-linux.c \ + m_sigframe/sigframe-x86-freebsd.c \ + m_sigframe/sigframe-amd64-freebsd.c \ m_sigframe/sigframe-ppc32-linux.c \ m_sigframe/sigframe-ppc64-linux.c \ m_sigframe/sigframe-arm-linux.c \ @@ -448,6 +454,8 @@ COREGRIND_SOURCES_COMMON = \ m_syswrap/syscall-mips32-linux.S \ m_syswrap/syscall-mips64-linux.S \ m_syswrap/syscall-nanomips-linux.S \ + m_syswrap/syscall-x86-freebsd.S \ + m_syswrap/syscall-amd64-freebsd.S \ m_syswrap/syscall-x86-darwin.S \ m_syswrap/syscall-amd64-darwin.S \ m_syswrap/syscall-x86-solaris.S \ @@ -456,12 +464,15 @@ COREGRIND_SOURCES_COMMON = \ m_syswrap/syswrap-generic.c \ m_syswrap/syswrap-linux.c \ m_syswrap/syswrap-linux-variants.c \ + m_syswrap/syswrap-freebsd.c \ m_syswrap/syswrap-darwin.c \ m_syswrap/syswrap-solaris.c \ m_syswrap/syswrap-x86-linux.c \ m_syswrap/syswrap-amd64-linux.c \ m_syswrap/syswrap-ppc32-linux.c \ m_syswrap/syswrap-ppc64-linux.c \ + m_syswrap/syswrap-x86-freebsd.c \ + m_syswrap/syswrap-amd64-freebsd.c \ m_syswrap/syswrap-arm-linux.c \ m_syswrap/syswrap-arm64-linux.c \ m_syswrap/syswrap-s390x-linux.c \ diff --git a/coregrind/launcher-freebsd.c b/coregrind/launcher-freebsd.c new file mode 100644 index 0000000000..7d40ad6cce --- /dev/null +++ b/coregrind/launcher-freebsd.c @@ -0,0 +1,325 @@ + +/*--------------------------------------------------------------------*/ +/*--- Launching valgrind m_launcher.c ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 Julian Seward + js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Note: this is a "normal" program and not part of Valgrind proper, + and so it doesn't have to conform to Valgrind's arcane rules on + no-glibc-usage etc. */ + +#include <assert.h> +#include <ctype.h> +#include <elf.h> +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <sys/sysctl.h> +/* #include <sys/user.h> */ +#include <unistd.h> + +#include "pub_core_debuglog.h" +#include "pub_core_vki.h" // Avoids warnings from +// pub_core_libcfile.h +#include "pub_core_libcproc.h" // For VALGRIND_LIB, VALGRIND_LAUNCHER +#include "pub_core_ume.h" + + +#if !defined(PATH_MAX) +#define PATH_MAX 4096 /* POSIX refers to this a lot but I dunno + where it is defined */ +#endif + +#ifndef EM_X86_64 +#define EM_X86_64 62 // elf.h doesn't define this on some older systems +#endif + +/* Report fatal errors */ +__attribute__((noreturn)) +static void barf ( const char *format, ... ) +{ + va_list vargs; + + va_start(vargs, format); + fprintf(stderr, "valgrind: Cannot continue: "); + vfprintf(stderr, format, vargs); + fprintf(stderr, "\n"); + va_end(vargs); + + exit(1); + /*NOTREACHED*/ + assert(0); +} + +/* Search the path for the client program */ +static const char *find_client(const char *clientname) +{ + static char fullname[PATH_MAX]; + const char *path = getenv("PATH"); + const char *colon; + + while (path) { + if ((colon = strchr(path, ':')) == NULL) { + strcpy(fullname, path); + path = NULL; + } else { + memcpy(fullname, path, colon - path); + fullname[colon - path] = '\0'; + path = colon + 1; + } + + strcat(fullname, "/"); + strcat(fullname, clientname); + + if (access(fullname, R_OK|X_OK) == 0) + return fullname; + } + + return clientname; +} + +/* Examine the client and work out which platform it is for */ +static const char *select_platform(const char *clientname) +{ + int fd; + char header[4096]; + ssize_t n_bytes; + const char *platform = NULL; + + VG_(debugLog)(2, "launcher", "selecting platform for '%s'\n", clientname); + + if (strchr(clientname, '/') == NULL) + clientname = find_client(clientname); + + if ((fd = open(clientname, O_RDONLY)) < 0) + return NULL; + // barf("open(%s): %s", clientname, strerror(errno)); + + n_bytes = read(fd, header, sizeof(header)); + close(fd); + if (n_bytes < 2) { + return NULL; + } + + if (header[0] == '#' && header[1] == '!') { + int i = 2; + char *interp = (char *)header + 2; + + // Skip whitespace. + while (1) { + if (i == n_bytes) return NULL; + if (' ' != header[i] && '\t' == header[i]) break; + i++; + } + + // Get the interpreter name. + interp = &header[i]; + while (1) { + if (i == n_bytes) break; + if (isspace(header[i])) break; + i++; + } + if (i == n_bytes) return NULL; + header[i] = '\0'; + + platform = select_platform(interp); + + } else if (n_bytes >= SELFMAG && memcmp(header, ELFMAG, SELFMAG) == 0) { + + if ((size_t)n_bytes >= sizeof(Elf32_Ehdr) && header[EI_CLASS] == ELFCLASS32) { + const Elf32_Ehdr *ehdr = (Elf32_Ehdr *)header; + + if (header[EI_DATA] == ELFDATA2LSB) { + if (ehdr->e_machine == EM_386 && + ehdr->e_ident[EI_OSABI] == ELFOSABI_FREEBSD) { + platform = "x86-freebsd"; + } + } + } else if ((size_t)n_bytes >= sizeof(Elf64_Ehdr) && header[EI_CLASS] == ELFCLASS64) { + const Elf64_Ehdr *ehdr = (Elf64_Ehdr *)header; + + if (header[EI_DATA] == ELFDATA2LSB) { + if (ehdr->e_machine == EM_X86_64 && + ehdr->e_ident[EI_OSABI] == ELFOSABI_FREEBSD) { + platform = "amd64-freebsd"; + } + } + } + } + + VG_(debugLog)(2, "launcher", "selected platform '%s'\n", + platform ? platform : "unknown"); + + return platform; +} + +/* Where we expect to find all our aux files */ +static const char *valgrind_lib = VG_LIBDIR; + +int main(int argc, char** argv, char** envp) +{ + int i, j, loglevel, r; + const char *toolname = NULL; + const char *clientname = NULL; + const char *platform; + const char *default_platform; + const char *cp; + char *toolfile; + char launcher_name[PATH_MAX+1]; + char* new_line; + char** new_env; + int oid[4]; + vki_size_t len; + + /* Start the debugging-log system ASAP. First find out how many + "-d"s were specified. This is a pre-scan of the command line. + At the same time, look for the tool name. */ + loglevel = 0; + for (i = 1; i < argc; i++) { + if (argv[i][0] != '-') { + clientname = argv[i]; + break; + } + if (0 == strcmp(argv[i], "--")) { + if (i+1 < argc) + clientname = argv[i+1]; + break; + } + if (0 == strcmp(argv[i], "-d")) + loglevel++; + if (0 == strncmp(argv[i], "--tool=", 7)) + toolname = argv[i] + 7; + } + + /* ... and start the debug logger. Now we can safely emit logging + messages all through startup. */ + VG_(debugLog_startup)(loglevel, "Stage 1"); + + /* Make sure we know which tool we're using */ + if (toolname) { + VG_(debugLog)(1, "launcher", "tool '%s' requested\n", toolname); + } else { + VG_(debugLog)(1, "launcher", + "no tool requested, defaulting to 'memcheck'\n"); + toolname = "memcheck"; + } + + /* Select a platform to use if we can't decide that by looking at + the executable (eg because it's a shell script). Note that the + default_platform is not necessarily either the primary or + secondary build target. Instead it's chosen to maximise the + chances that /bin/sh will work on it. Hence for a primary + target of ppc64-linux we still choose ppc32-linux as the default + target, because on most ppc64-linux setups, the basic /bin, + /usr/bin, etc, stuff is built in 32-bit mode, not 64-bit + mode. */ + if (0==strcmp(VG_PLATFORM,"x86-freebsd")) + default_platform = "x86-freebsd"; + else if (0==strcmp(VG_PLATFORM,"amd64-freebsd")) + default_platform = "amd64-freebsd"; + else + barf("Unknown VG_PLATFORM '%s'", VG_PLATFORM); + + /* Work out what platform to use, or use the default platform if + not possible. */ + if (clientname == NULL) { + VG_(debugLog)(1, "launcher", + "no client specified, defaulting platform to '%s'\n", + default_platform); + platform = default_platform; + } else if ((platform = select_platform(clientname)) != NULL) { + VG_(debugLog)(1, "launcher", "selected platform '%s'\n", platform); + } else { + VG_(debugLog)(1, "launcher", + "no platform detected, defaulting platform to '%s'\n", + default_platform); + platform = default_platform; + } + + /* Figure out the name of this executable (viz, the launcher), so + we can tell stage2. stage2 will use the name for recursive + invocations of valgrind on child processes. */ + memset(launcher_name, 0, PATH_MAX+1); + + oid[0] = CTL_KERN; + oid[1] = KERN_PROC; + oid[2] = KERN_PROC_PATHNAME; + oid[3] = getpid(); + len = PATH_MAX; + r = sysctl(oid, 4, launcher_name, &len, 0, 0); + if (r != 0) { + fprintf(stderr, "valgrind: warning (non-fatal): " + "sysctl(\"kern.proc.pathname\") failed.\n"); + fprintf(stderr, "valgrind: continuing, however --trace-children=yes " + "will not work.\n"); + } + + /* tediously augment the env: VALGRIND_LAUNCHER=launcher_name */ + new_line = malloc(strlen(VALGRIND_LAUNCHER) + 1 + + strlen(launcher_name) + 1); + if (new_line == NULL) + barf("malloc of new_line failed."); + strcpy(new_line, VALGRIND_LAUNCHER); + strcat(new_line, "="); + strcat(new_line, launcher_name); + + for (j = 0; envp[j]; j++) + ; + new_env = malloc((j+2) * sizeof(char*)); + if (new_env == NULL) + barf("malloc of new_env failed."); + for (i = 0; i < j; i++) + new_env[i] = envp[i]; + new_env[i++] = new_line; + new_env[i++] = NULL; + assert(i == j+2); + + /* Establish the correct VALGRIND_LIB. */ + cp = getenv(VALGRIND_LIB); + + if (cp != NULL) + valgrind_lib = cp; + + /* Build the stage2 invocation, and execve it. Bye! */ + toolfile = malloc(strlen(valgrind_lib) + strlen(toolname) + strlen(platform) + 3); + if (toolfile == NULL) + barf("malloc of toolfile failed."); + sprintf(toolfile, "%s/%s-%s", valgrind_lib, toolname, platform); + + VG_(debugLog)(1, "launcher", "launching %s\n", toolfile); + + execve(toolfile, argv, new_env); + + fprintf(stderr, "valgrind: failed to start tool '%s' for platform '%s': %s\n", + toolname, platform, strerror(errno)); + + exit(1); +} diff --git a/coregrind/link_tool_exe_freebsd.in b/coregrind/link_tool_exe_freebsd.in new file mode 100755 index 0000000000..b4df4622c1 --- /dev/null +++ b/coregrind/link_tool_exe_freebsd.in @@ -0,0 +1,82 @@ +#! @PERL@ + +# This script handles linking the tool executables on FreeBSD, +# statically and at an alternative load address. +# +# Linking statically sidesteps all sorts of complications to do with +# having two copies of the dynamic linker (valgrind's and the +# client's) coexisting in the same process. The alternative load +# address is needed because Valgrind itself will load the client at +# whatever address it specifies, which is almost invariably the +# default load address. Hence we can't allow Valgrind itself (viz, +# the tool executable) to be loaded at that address. +# +# Unfortunately there's no standard way to do 'static link at +# alternative address', so these link_tool_exe_*.in scripts handle +# the per-platform hoop-jumping. +# +# What we get passed here is: +# first arg +# the alternative load address +# all the rest of the args +# the compiler invocation to do the final link, that +# the build system would have done, left to itself +# +# We just let the script 'die' if something is wrong, rather than do +# proper error reporting. We don't expect the users to run this +# directly. It is only run as part of the build process, with +# carefully constrained inputs. +# +# FreeBSD specific complications: +# +# - in the initial version of this file, the linker(s) it was targeted +# at supported only -Ttext to load the code at an alternative address, +# and did not require removing the build notes in order to function +# correctly, so the work done by configure to determine what should go +# into the FLAG_T_TEXT was ignored. +# +# - LLVM's ld.lld, for at least versions 8.0 (shipping with FreeBSD 12.1) +# and 9.0 support the -Ttext option and behave as desired. As of +# LLVM ld.lld version 10.0 a breaking change made -Ttext unusable, +# however the --image-base option has the desired semantics. +# It turns out that ld.lld has supported --image-base since at least +# as far back as version 8.0. +# +# So: what we actually do: +# +# pass the specified command to the linker as-is, except, add +# "-static" and the value of FLAG_T_TEXT as determined by configure. +# Previously we did this by adding these options after the first +# word of the rest of the arguments, which works in the common case +# when it's something like "gcc". But the linker invocation itself +# might be multiple words, say if it's "ccache gcc". So we now put +# the new options at the end instead. +# + +use warnings; +use strict; + +# expect at least: alt-load-address gcc -o foo bar.o +die "Not enough arguments" + if (($#ARGV + 1) < 5); + +my $ala = $ARGV[0]; +shift; # Remove $ala from @ARGV + +# check for plausible-ish alt load address +die "Bogus alt-load address" + if (length($ala) < 3 || index($ala, "0x") != 0); + +my $cmd = join(" ", @ARGV, "-static -Wl,@FLAG_T_TEXT@=$ala"); + +#print "link_tool_exe_freebsd: $cmd\n"; + + +# Execute the command: +my $r = system("$cmd"); + +if ($r == 0) { + exit 0; +} else { + exit 1; +} diff --git a/coregrind/m_dispatch/dispatch-amd64-freebsd.S b/coregrind/m_dispatch/dispatch-amd64-freebsd.S new file mode 100644 index 0000000000..db4dccac76 --- /dev/null +++ b/coregrind/m_dispatch/dispatch-amd64-freebsd.S @@ -0,0 +1,321 @@ + +/*--------------------------------------------------------------------*/ +/*--- The core dispatch loop, for jumping to a code address. ---*/ +/*--- dispatch-amd64-freebsd.S ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2017 Julian Seward + js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +#include "pub_core_basics_asm.h" + +#if defined(VGP_amd64_freebsd) + +#include "pub_core_dispatch_asm.h" +#include "pub_core_transtab_asm.h" +#include "libvex_guest_offsets.h" /* for OFFSET_amd64_RIP */ + + +/*------------------------------------------------------------*/ +/*--- ---*/ +/*--- The dispatch loop. VG_(disp_run_translations) is ---*/ +/*--- used to run all translations, ---*/ +/*--- including no-redir ones. ---*/ +/*--- ---*/ +/*------------------------------------------------------------*/ + +/*----------------------------------------------------*/ +/*--- Entry and preamble (set everything up) ---*/ +/*----------------------------------------------------*/ + +/* signature: +void VG_(disp_run_translations)( UWord* two_words, + void* guest_state, + Addr host_addr ); +*/ +.text +.globl VG_(disp_run_translations) +.type VG_(disp_run_translations), @function +VG_(disp_run_translations): + /* %rdi holds two_words */ + /* %rsi holds guest_state */ + /* %rdx holds host_addr */ + + /* The preamble */ + + /* Save integer registers, since this is a pseudo-function. */ + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdx + pushq %rsi + pushq %rbp + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + /* %rdi must be saved last */ + pushq %rdi + + /* Get the host CPU in the state expected by generated code. */ + + /* set host FPU control word to the default mode expected + by VEX-generated code. See comments in libvex.h for + more info. */ + finit + pushq $0x027F + fldcw (%rsp) + addq $8, %rsp + + /* set host SSE control word to the default mode expected + by VEX-generated code. */ + pushq $0x1F80 + ldmxcsr (%rsp) + addq $8, %rsp + + /* set dir flag to known value */ + cld + + /* Set up the guest state pointer */ + movq %rsi, %rbp + + /* and jump into the code cache. Chained translations in + the code cache run, until for whatever reason, they can't + continue. When that happens, the translation in question + will jump (or call) to one of the continuation points + VG_(cp_...) below. */ + jmpq *%rdx + /*NOTREACHED*/ + +/*----------------------------------------------------*/ +/*--- Postamble and exit. ---*/ +/*----------------------------------------------------*/ + +postamble: + /* At this point, %rax and %rdx contain two + words to be returned to the caller. %rax + holds a TRC value, and %rdx optionally may + hold another word (for CHAIN_ME exits, the + address of the place to patch.) */ + + /* We're leaving. Check that nobody messed with %mxcsr + or %fpucw. We can't mess with %rax or %rdx here as they + hold the tentative return values, but any others are OK. */ +#if !defined(ENABLE_INNER) + /* This check fails for self-hosting, so skip in that case */ + pushq $0 + fstcw (%rsp) + cmpl $0x027F, (%rsp) + popq %r15 /* get rid of the word without trashing %rflags */ + jnz invariant_violation +#endif + pushq $0 + stmxcsr (%rsp) + andl $0xFFFFFFC0, (%rsp) /* mask out status flags */ + cmpl $0x1F80, (%rsp) + popq %r15 + jnz invariant_violation + /* otherwise we're OK */ + jmp remove_frame +invariant_violation: + movq $VG_TRC_INVARIANT_FAILED, %rax + movq $0, %rdx + +remove_frame: + /* Pop %rdi, stash return values */ + popq %rdi + movq %rax, 0(%rdi) + movq %rdx, 8(%rdi) + /* Now pop everything else */ + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %r11 + popq %r10 + popq %r9 + popq %r8 + popq %rbp + popq %rsi + popq %rdx + popq %rcx + popq %rbx + popq %rax + ret + +/*----------------------------------------------------*/ +/*--- Continuation points ---*/ +/*----------------------------------------------------*/ + +/* ------ Chain me to slow entry point ------ */ +.global VG_(disp_cp_chain_me_to_slowEP) +VG_(disp_cp_chain_me_to_slowEP): + /* We got called. The return address indicates + where the patching needs to happen. Collect + the return address and, exit back to C land, + handing the caller the pair (Chain_me_S, RA) */ + movq $VG_TRC_CHAIN_ME_TO_SLOW_EP, %rax + popq %rdx + /* 10 = movabsq $VG_(disp_chain_me_to_slowEP), %r11; + 3 = call *%r11 */ + subq $10+3, %rdx + jmp postamble + +/* ------ Chain me to fast entry point ------ */ +.global VG_(disp_cp_chain_me_to_fastEP) +VG_(disp_cp_chain_me_to_fastEP): + /* We got called. The return address indicates + where the patching needs to happen. Collect + the return address and, exit back to C land, + handing the caller the pair (Chain_me_F, RA) */ + movq $VG_TRC_CHAIN_ME_TO_FAST_EP, %rax + popq %rdx + /* 10 = movabsq $VG_(disp_chain_me_to_fastEP), %r11; + 3 = call *%r11 */ + subq $10+3, %rdx + jmp postamble + +/* ------ Indirect but boring jump ------ */ +.global VG_(disp_cp_xindir) +VG_(disp_cp_xindir): + /* Where are we going? */ + movq OFFSET_amd64_RIP(%rbp), %rax // "guest" + + /* stats only */ + addl $1, VG_(stats__n_xIndirs_32) + + // LIVE: %rbp (guest state ptr), %rax (guest address to go to). + // We use 4 temporaries: + // %r9 (to point at the relevant FastCacheSet), + // %r10, %r11 and %r12 (scratch). + + /* Try a fast lookup in the translation cache. This is pretty much + a handcoded version of VG_(lookupInFastCache). */ + + // Compute %r9 = VG_TT_FAST_HASH(guest) + movq %rax, %r9 // guest + shrq $VG_TT_FAST_BITS, %r9 // (guest >> VG_TT_FAST_BITS) + xorq %rax, %r9 // (guest >> VG_TT_FAST_BITS) ^ guest + andq $VG_TT_FAST_MASK, %r9 // setNo + + // Compute %r9 = &VG_(tt_fast)[%r9] + shlq $VG_FAST_CACHE_SET_BITS, %r9 // setNo * sizeof(FastCacheSet) + movabsq $VG_(tt_fast), %r10 // &VG_(tt_fast)[0] + leaq (%r10, %r9), %r9 // &VG_(tt_fast)[setNo] + + // LIVE: %rbp (guest state ptr), %rax (guest addr), %r9 (cache set) + // try way 0 + cmpq %rax, FCS_g0(%r9) // cmp against .guest0 + jnz 1f + // hit at way 0 + jmp *FCS_h0(%r9) // goto .host0 + ud2 + +1: // try way 1 + cmpq %rax, FCS_g1(%r9) // cmp against .guest1 + jnz 2f + // hit at way 1; swap upwards + /* stats only */ + addl $1, VG_(stats__n_xIndir_hits1_32) + movq FCS_g0(%r9), %r10 // r10 = old .guest0 + movq FCS_h0(%r9), %r11 // r11 = old .host0 + movq FCS_h1(%r9), %r12 // r12 = old .host1 + movq %rax, FCS_g0(%r9) // new .guest0 = guest + movq %r12, FCS_h0(%r9) // new .host0 = old .host1 + movq %r10, FCS_g1(%r9) // new .guest1 = old .guest0 + movq %r11, FCS_h1(%r9) // new .host1 = old .host0 + jmp *%r12 // goto old .host1 a.k.a. new .host0 + ud2 + +2: // try way 2 + cmpq %rax, FCS_g2(%r9) // cmp against .guest2 + jnz 3f + // hit at way 2; swap upwards + /* stats only */ + addl $1, VG_(stats__n_xIndir_hits2_32) + movq FCS_g1(%r9), %r10 + movq FCS_h1(%r9), %r11 + movq FCS_h2(%r9), %r12 + movq %rax, FCS_g1(%r9) + movq %r12, FCS_h1(%r9) + movq %r10, FCS_g2(%r9) + movq %r11, FCS_h2(%r9) + jmp *%r12 + ud2 + +3: // try way 3 + cmpq %rax, FCS_g3(%r9) // cmp against .guest3 + jnz 4f + // hit at way 3; swap upwards + /* stats only */ + addl $1, VG_(stats__n_xIndir_hits3_32) + movq FCS_g2(%r9), %r10 + movq FCS_h2(%r9), %r11 + movq FCS_h3(%r9), %r12 + movq %rax, FCS_g2(%r9) + movq %r12, FCS_h2(%r9) + movq %r10, FCS_g3(%r9) + movq %r11, FCS_h3(%r9) + jmp *%r12 + ud2 + +4: // fast lookup failed + /* stats only */ + addl $1, VG_(stats__n_xIndir_misses_32) + + movq $VG_TRC_INNER_FASTMISS, %rax + movq $0, %rdx + jmp postamble + +/* ------ Assisted jump ------ */ +.global VG_(disp_cp_xassisted) +VG_(disp_cp_xassisted): + /* %rbp contains the TRC */ + movq %rbp, %rax + movq $0, %rdx + jmp postamble + +/* ------ Event check failed ------ */ +.global VG_(disp_cp_evcheck_fail) +VG_(disp_cp_evcheck_fail): + movq $VG_TRC_INNER_COUNTERZERO, %rax + movq $0, %rdx + jmp postamble + + +.size VG_(disp_run_translations), .-VG_(disp_run_translations) + +#endif // defined(VGP_amd64_freebsd) + +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-x86-freebsd.S b/coregrind/m_dispatch/dispatch-x86-freebsd.S new file mode 100644 index 0000000000..667bfcd96a --- /dev/null +++ b/coregrind/m_dispatch/dispatch-x86-freebsd.S @@ -0,0 +1,251 @@ + +/*--------------------------------------------------------------------*/ +/*--- The core dispatch loop, for jumping to a code address. ---*/ +/*--- dispatch-x86-freebsd.S ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2012 Julian Seward + js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +#include "pub_core_basics_asm.h" + +#if defined(VGP_x86_freebsd) + +#include "pub_core_dispatch_asm.h" +#include "pub_core_transtab_asm.h" +#include "libvex_guest_offsets.h" /* for OFFSET_x86_EIP */ + + +/*------------------------------------------------------------*/ +/*--- ---*/ +/*--- The dispatch loop. VG_(disp_run_translations) is ---*/ +/*--- used to run all translations, ---*/ +/*--- including no-redir ones. ---*/ +/*--- ---*/ +/*------------------------------------------------------------*/ + +/*----------------------------------------------------*/ +/*--- Entry and preamble (set everything up) ---*/ +/*----------------------------------------------------*/ + +/* signature: +void VG_(disp_run_translations)( UWord* two_words, + void* guest_state, + Addr host_addr ); +*/ +.text +.globl VG_(disp_run_translations) +.type VG_(disp_run_translations), @function +VG_(disp_run_translations): + /* 0(%esp) holds our return address. */ + /* 4(%esp) holds two_words */ + /* 8(%esp) holds guest_state */ + /* 12(%esp) holds host_addr */ + + /* The preamble */ + + /* Save integer registers, since this is a pseudo-function. */ + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + pushl %esi + pushl %edi + pushl %ebp + + /* 28+4(%esp) holds two_words */ + /* 28+8(%esp) holds guest_state */ + /* 28+12(%esp) holds host_addr */ + + /* Get the host CPU in the state expected by generated code. */ + + /* set host FPU control word to the default mode expected + by VEX-generated code. See comments in libvex.h for + more info. */ + finit + pushl $0x027F + fldcw (%esp) + addl $4, %esp + + /* set host SSE control word to the default mode expected + by VEX-generated code. */ + cmpl $0, VG_(machine_x86_have_mxcsr) + jz L1 + pushl $0x1F80 + ldmxcsr (%esp) + addl $4, %esp +L1: + /* set dir flag to known value */ + cld + + /* Set up the guest state pointer */ + movl 28+8(%esp), %ebp + + /* and jump into the code cache. Chained translations in + the code cache run, until for whatever reason, they can't + continue. When that happens, the translation in question + will jump (or call) to one of the continuation points + VG_(cp_...) below. */ + jmpl *28+12(%esp) + /*NOTREACHED*/ + +/*----------------------------------------------------*/ +/*--- Postamble and exit. ---*/ +/*----------------------------------------------------*/ + +postamble: + /* At this point, %eax and %edx contain two + words to be returned to the caller. %eax + holds a TRC value, and %edx optionally may + hold another word (for CHAIN_ME exits, the + address of the place to patch.) */ + + /* We're leaving. Check that nobody messed with %mxcsr + or %fpucw. We can't mess with %eax or %edx here as they + holds the tentative return value, but any others are OK. */ +#if !defined(ENABLE_INNER) + /* This check fails for self-hosting, so skip in that case */ + pushl $0 + fstcw (%esp) + cmpl $0x027F, (%esp) + popl %esi /* get rid of the word without trashing %eflags */ + jnz invariant_violation +#endif +# cmpl $0, VG_(machine_x86_have_mxcsr) + jz L2 + pushl $0 + stmxcsr (%esp) + andl $0xFFFFFFC0, (%esp) /* mask out status flags */ + cmpl $0x1F80, (%esp) + popl %esi + jnz invariant_violation +L2: /* otherwise we're OK */ + jmp remove_frame +invariant_violation: + movl $VG_TRC_INVARIANT_FAILED, %eax + movl $0, %edx + +remove_frame: + /* Stash return values */ + movl 28+4(%esp), %edi /* two_words */ + movl %eax, 0(%edi) + movl %edx, 4(%edi) + /* Restore int regs and return. */ + popl %ebp + popl %edi + popl %esi + popl %edx + popl %ecx + popl %ebx + popl %eax + ret + +/*----------------------------------------------------*/ +/*--- Continuation points ---*/ +/*----------------------------------------------------*/ + +/* ------ Chain me to slow entry point ------ */ +.global VG_(disp_cp_chain_me_to_slowEP) +VG_(disp_cp_chain_me_to_slowEP): + /* We got called. The return address indicates + where the patching needs to happen. Collect + the return address and, exit back to C land, + handing the caller the pair (Chain_me_S, RA) */ + movl $VG_TRC_CHAIN_ME_TO_SLOW_EP, %eax + popl %edx + /* 5 = movl $VG_(disp_chain_me_to_slowEP), %edx; + 2 = call *%edx */ + subl $5+2, %edx + jmp postamble + +/* ------ Chain me to fast entry point ------ */ +.global VG_(disp_cp_chain_me_to_fastEP) +VG_(disp_cp_chain_me_to_fastEP): + /* We got called. The return address indicates + where the patching needs to happen. Collect + the return address and, exit back to C land, + handing the caller the pair (Chain_me_F, RA) */ + movl $VG_TRC_CHAIN_ME_TO_FAST_EP, %eax + popl %edx + /* 5 = movl $VG_(disp_chain_me_to_fastEP), %edx; + 2 = call *%edx */ + subl $5+2, %edx + jmp postamble + +/* ------ Indirect but boring jump ------ */ +.global VG_(disp_cp_xindir) +VG_(disp_cp_xindir): + /* Where are we going? */ + movl OFFSET_x86_EIP(%ebp), %eax + + /* stats only */ + addl $1, VG_(stats__n_xIndirs_32) + + /* try a fast lookup in the translation cache */ + movl %eax, %ebx /* next guest addr */ + andl $VG_TT_FAST_MASK, %ebx /* entry# */ + movl 0+VG_(tt_fast)(,%ebx,8), %esi /* .guest */ + movl 4+VG_(tt_fast)(,%ebx,8), %edi /* .host */ + cmpl %eax, %esi + jnz fast_lookup_failed + + /* Found a match. Jump to .host. */ + jmp *%edi + ud2 /* persuade insn decoders not to speculate past here */ + +fast_lookup_failed: + /* stats only */ + addl $1, VG_(stats__n_xIndir_misses_32) + + movl $VG_TRC_INNER_FASTMISS, %eax + movl $0, %edx + jmp postamble + +/* ------ Assisted jump ------ */ +.global VG_(disp_cp_xassisted) +VG_(disp_cp_xassisted): + /* %ebp contains the TRC */ + movl %ebp, %eax + movl $0, %edx + jmp postamble + +/* ------ Event check failed ------ */ +.global VG_(disp_cp_evcheck_fail) +VG_(disp_cp_evcheck_fail): + movl $VG_TRC_INNER_COUNTERZERO, %eax + movl $0, %edx + jmp postamble + + +.size VG_(disp_run_translations), .-VG_(disp_run_translations) + +#endif // defined(VGP_x86_freebsd) + +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c new file mode 100644 index 0000000000..d19186a42c --- /dev/null +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -0,0 +1,979 @@ + +/*--------------------------------------------------------------------*/ +/*--- Startup: create initial process image on FreeBSD ---*/ +/*--- initimg-freebsd.c ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 Julian Seward + js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +#if defined(VGO_freebsd) + +#include "pub_core_basics.h" +#include "pub_core_vki.h" +#include "pub_core_debuglog.h" +#include "pub_core_libcbase.h" +#include "pub_core_libcassert.h" +#include "pub_core_libcfile.h" +#include "pub_core_libcproc.h" +#include "pub_core_libcprint.h" +#include "pub_core_xarray.h" +#include "pub_core_clientstate.h" +#include "pub_core_aspacemgr.h" +#include "pub_core_mallocfree.h" +#include "pub_core_machine.h" +#include "pub_core_ume.h" +#include "pub_core_options.h" +#include "pub_core_syscall.h" +#include "pub_core_tooliface.h" /* VG_TRACK */ +#include "pub_core_threadstate.h" /* ThreadArchState */ +#include "pub_core_pathscan.h" +#include "pub_core_initimg.h" /* self */ + +/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */ +/* This is for ELF types etc, and also the AT_ constants. */ +#include <elf.h> +/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */ + + +/*====================================================================*/ +/*=== Loading the client ===*/ +/*====================================================================*/ + +/* Load the client whose name is VG_(argv_the_exename). */ + +static void load_client ( /*OUT*/ExeInfo* info, + /*OUT*/Addr* client_ip, + /*OUT*/Addr* client_toc) +{ + const HChar* exe_name; + Int ret; + SysRes res; + + vg_assert( VG_(args_the_exename) != NULL); + exe_name = VG_(find_executable)( VG_(args_the_exename) ); + + if (!exe_name) { + VG_(printf)("valgrind: %s: command not found\n", VG_(args_the_exename)); + VG_(exit)(127); // 127 is Posix NOTFOUND + } + + VG_(memset)(info, 0, sizeof(*info)); + ret = VG_(do_exec)(exe_name, info); + if (ret < 0) { + VG_(printf)("valgrind: could not execute '%s'\n", exe_name); + VG_(exit)(1); + } + + // The client was successfully loaded! Continue. + + /* Get hold of a file descriptor which refers to the client + executable. This is needed for attaching to GDB. */ + res = VG_(open)(exe_name, VKI_O_RDONLY, VKI_S_IRUSR); + if (!sr_isError(res)) + VG_(cl_exec_fd) = sr_Res(res); + + /* Copy necessary bits of 'info' that were filled in */ + *client_ip = info->init_ip; + *client_toc = info->init_toc; + VG_(brk_base) = VG_(brk_limit) = VG_PGROUNDUP(info->brkbase); +} + + +/*====================================================================*/ +/*=== Setting up the client's environment ===*/ +/*====================================================================*/ + +/* Prepare the client's environment. This is basically a copy of our + environment, except: + + LD_PRELOAD=$VALGRIND_LIB/vgpreload_core-PLATFORM.so: + ($VALGRIND_LIB/vgpreload_TOOL-PLATFORM.so:)? + $LD_PRELOAD + + If this is missing, then it is added. + + Also, remove any binding for VALGRIND_LAUNCHER=. The client should + not be able to see this. + + If this needs to handle any more variables it should be hacked + into something table driven. The copy is VG_(malloc)'d space. +*/ +static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) +{ + vg_assert(origenv); + vg_assert(toolname); + + const HChar* preload_core = "vgpreload_core"; + const HChar* ld_preload = "LD_PRELOAD="; + const HChar* v_launcher = VALGRIND_LAUNCHER "="; + Int ld_preload_len = VG_(strlen)( ld_preload ); + Int v_launcher_len = VG_(strlen)( v_launcher ); + Bool ld_preload_done = False; +#if defined(VGP_x86_freebsd) + const HChar* ld_32_preload = "LD_32_PRELOAD="; + Int ld_32_preload_len = VG_(strlen)( ld_32_preload ); + Bool ld_32_preload_done = False; +#endif + Int vglib_len = VG_(strlen)(VG_(libdir)); + Bool debug = False; + + HChar** cpp; + HChar** ret; + HChar* preload_tool_path; + Int envc, i; + + /* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so + paths. We might not need the space for vgpreload_<tool>.so, but it + doesn't hurt to over-allocate briefly. The 16s are just cautious + slop. */ + Int preload_core_path_len = vglib_len + sizeof(preload_core) + + sizeof(VG_PLATFORM) + 16; + Int preload_tool_path_len = vglib_len + VG_(strlen)(toolname) + + sizeof(VG_PLATFORM) + 16; + Int preload_string_len = preload_core_path_len + preload_tool_path_len; + HChar* preload_string = VG_(malloc)("initimg-freebsd.sce.1", + preload_string_len); + /* Determine if there's a vgpreload_<tool>_<platform>.so file, and setup + preload_string. */ + preload_tool_path = VG_(malloc)("initimg-freebsd.sce.2", preload_tool_path_len); + VG_(snprintf)(preload_tool_path, preload_tool_path_len, + "%s/vgpreload_%s-%s.so", VG_(libdir), toolname, VG_PLATFORM); + if (VG_(access)(preload_tool_path, True/*r*/, False/*w*/, False/*x*/) == 0) { + VG_(snprintf)(preload_string, preload_string_len, "%s/%s-%s.so:%s", + VG_(libdir), preload_core, VG_PLATFORM, preload_tool_path); + } else { + VG_(snprintf)(preload_string, preload_string_len, "%s/%s-%s.so", + VG_(libdir), preload_core, VG_PLATFORM); + } + VG_(free)(preload_tool_path); + + VG_(debugLog)(2, "initimg", "preload_string:\n"); + VG_(debugLog)(2, "initimg", " \"%s\"\n", preload_string); + + /* Count the original size of the env */ + if (debug) VG_(printf)("\n\n"); + envc = 0; + for (cpp = origenv; cpp && *cpp; cpp++) { + envc++; + if (debug) VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp); + } + + /* Allocate a new space */ + ret = VG_(malloc) ("initimg-freebsd.sce.3", + sizeof(HChar *) * (envc+2+1)); /* 2 new entries + NULL */ + + /* copy it over */ + for (cpp = ret; *origenv; ) { + if (debug) VG_(printf)("XXXXXXXXX: COPY %s\n", *origenv); + *cpp++ = *origenv++; + } + *cpp = NULL; + *(cpp + 1) = NULL; + + vg_assert(envc == (cpp - ret)); + + /* Walk over the new environment, mashing as we go */ + for (cpp = ret; cpp && *cpp; cpp++) { + if (VG_(memcmp)(*cpp, ld_preload, ld_preload_len) == 0) { + Int len = VG_(strlen)(*cpp) + preload_string_len; + HChar *cp = VG_(malloc)("initimg-freebsd.sce.4", len); + + VG_(snprintf)(cp, len, "%s%s:%s", + ld_preload, preload_string, (*cpp)+ld_preload_len); + + *cpp = cp; + + ld_preload_done = True; + } + if (debug) VG_(printf)("XXXXXXXXX: MASH %s\n", *cpp); + } + + /* Add the missing bits */ + if (!ld_preload_done) { + Int len = ld_preload_len + preload_string_len; + HChar *cp = VG_(malloc) ("initimg-freebsd.sce.5", len); + + VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string); + + ret[envc++] = cp; + if (debug) VG_(printf)("XXXXXXXXX: ADD %s\n", cp); + } + +#if defined(VGP_x86_freebsd) + /* If we're running a 32 bit binary, ld-elf32.so.1 may be looking for + * a different variable name. Or it might be a 32 bit ld-elf.so.1 in a + * chroot. Cover both cases. */ + if (VG_(is32on64)()) { + for (cpp = ret; cpp && *cpp; cpp++) { + if (VG_(memcmp)(*cpp, ld_32_preload, ld_32_preload_len) == 0) { + Int len = VG_(strlen)(*cpp) + preload_string_len; + HChar *cp = VG_(malloc)("initimg-freebsd.sce.4a", len); + vg_assert(cp); + + VG_(snprintf)(cp, len, "%s%s:%s", + ld_32_preload, preload_string, (*cpp)+ld_32_preload_len); + + *cpp = cp; + + ld_32_preload_done = True; + } + } + if (!ld_32_preload_done) { + Int len = ld_32_preload_len + preload_string_len; + HChar *cp = VG_(malloc) ("initimg-freebsd.sce.5a", len); + vg_assert(cp); + + VG_(snprintf)(cp, len, "%s%s", ld_32_preload, preload_string); + + ret[envc++] = cp; + } + } +#endif + + /* ret[0 .. envc-1] is live now. */ + /* Find and remove a binding for VALGRIND_LAUNCHER. */ + for (i = 0; i < envc; i++) + if (0 == VG_(memcmp)(ret[i], v_launcher, v_launcher_len)) + break; + + if (i < envc) { + for (; i < envc-1; i++) + ret[i] = ret[i+1]; + envc--; + } + + VG_(free)(preload_string); + ret[envc] = NULL; + + for (i = 0; i < envc; i++) { + if (debug) VG_(printf)("XXXXXXXXX: FINAL %s\n", ret[i]); + } + + return ret; +} + + +/*====================================================================*/ +/*=== Setting up the client's stack ===*/ +/*====================================================================*/ + +/* Add a string onto the string table, and return its address */ +static HChar *copy_str(HChar **tab, const HChar *str) +{ + HChar *cp = *tab; + HChar *orig = cp; + + while(*str) + *cp++ = *str++; + *cp++ = '\0'; + + if (0) + VG_(printf)("copied %p \"%s\" len %lld\n", (void*)orig, orig, (Long)(cp-orig)); + + *tab = cp; + + return orig; +} + + +/* ---------------------------------------------------------------- + + This sets up the client's initial stack, containing the args, + environment and aux vector. + + The format of the stack is: + + higher address +-----------------+ <- clstack_end + | | + : string table : + | | + +-----------------+ + | AT_NULL | + - - + | auxv | + +-----------------+ + | NULL | + - - + | envp | + +-----------------+ + | NULL | + - - + | argv | + +-----------------+ + | argc | + lower address +-----------------+ <- sp + | undefined | + : : + + Allocate and create the initial client stack. It is allocated down + from clstack_end, which was previously determined by the address + space manager. The returned value is the SP value for the client. + + The client's auxv is created by copying and modifying our own one. + + ---------------------------------------------------------------- */ + +struct auxv { + Word a_type; + union { + void *a_ptr; + Word a_val; + } u; +}; + +static +struct auxv *find_auxv(UWord* sp) +{ + sp++; // skip argc (Nb: is word-sized, not int-sized!) + + while (*sp != 0) // skip argv + sp++; + sp++; + + while (*sp != 0) // skip env + sp++; + sp++; + + return (struct auxv *)sp; +} + +static +Addr setup_client_stack( void* init_sp, + HChar** orig_envp, + const ExeInfo* info, + UInt** client_auxv, + Addr clstack_end, + SizeT clstack_max_size ) +{ + SysRes res; + HChar **cpp; + HChar *strtab; /* string table */ + HChar *stringbase; + Addr *ptr; + struct auxv *auxv; + const struct auxv *orig_auxv; + const struct auxv *cauxv; + unsigned stringsize; /* total size of strings in bytes */ + unsigned auxsize; /* total size of auxv in bytes */ + Int argc; /* total argc */ + Int envc; /* total number of env vars */ + unsigned stacksize; /* total client stack size */ + Addr client_SP; /* client stack base (initial SP) */ + Addr clstack_start; + Int i; + Bool have_exename; + + vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1)); + vg_assert( VG_(args_for_client) ); + + /* use our own auxv as a prototype */ + orig_auxv = find_auxv(init_sp); + + /* ==================== compute sizes ==================== */ + + /* first of all, work out how big the client stack will be */ + stringsize = 0; + have_exename = VG_(args_the_exename) != NULL; + + /* paste on the extra args if the loader needs them (ie, the #! + interpreter and its argument) */ + argc = 0; + if (info->interp_name != NULL) { + argc++; + stringsize += VG_(strlen)(info->interp_name) + 1; + } + if (info->interp_args != NULL) { + argc++; + stringsize += VG_(strlen)(info->interp_args) + 1; + } + + /* now scan the args we're given... */ + if (have_exename) + stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1; + + for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { + argc++; + stringsize += VG_(strlen)( * (HChar**) + VG_(indexXA)( VG_(args_for_client), i )) + + 1; + } + + /* ...and the environment */ + envc = 0; + for (cpp = orig_envp; cpp && *cpp; cpp++) { + envc++; + stringsize += VG_(strlen)(*cpp) + 1; + } + + /* now, how big is the auxv? */ + auxsize = sizeof(*auxv); /* there's always at least one entry: AT_NULL */ + for (cauxv = orig_auxv; cauxv->a_type != AT_NULL; cauxv++) { + auxsize += sizeof(*cauxv); + } + + /* OK, now we know how big the client stack is */ + stacksize = + sizeof(Word) + /* argc */ + (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */ + sizeof(HChar **)*argc + /* argv */ + sizeof(HChar **) + /* terminal NULL */ + sizeof(HChar **)*envc + /* envp */ + sizeof(HChar **) + /* terminal NULL */ + auxsize + /* auxv */ + VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */ + + if (0) VG_(printf)("stacksize = %u\n", stacksize); + + /* client_SP is the client's stack pointer */ + client_SP = clstack_end - stacksize; + client_SP = VG_ROUNDDN(client_SP, 16); /* make stack 16 byte aligned */ + + /* base of the string table (aligned) */ + stringbase = strtab = (HChar *)clstack_end + - VG_ROUNDUP(stringsize, sizeof(int)); + + clstack_start = VG_PGROUNDDN(client_SP); + + /* The max stack size */ + clstack_max_size = VG_PGROUNDUP(clstack_max_size); + + if (0) + VG_(printf)("stringsize=%u auxsize=%u stacksize=%u maxsize=0x%lx\n" + "clstack_start %p\n" + "clstack_end %p\n", + stringsize, auxsize, stacksize, clstack_max_size, + (void*)clstack_start, (void*)clstack_end); + + /* ==================== allocate space ==================== */ + + { + SizeT anon_size = clstack_end - clstack_start + 1; + SizeT resvn_size = clstack_max_size - anon_size; + Addr anon_start = clstack_start; + Addr resvn_start = anon_start - resvn_size; + SizeT inner_HACK = 0; + Bool ok; + + /* So far we've only accounted for space requirements down to the + stack pointer. If this target's ABI requires a redzone below + the stack pointer, we need to allocate an extra page, to + handle the worst case in which the stack pointer is almost at + the bottom of a page, and so there is insufficient room left + over to put the redzone in. In this case the simple thing to + do is allocate an extra page, by shrinking the reservation by + one page and growing the anonymous area by a corresponding + page. */ + vg_assert(VG_STACK_REDZONE_SZB >= 0); + vg_assert(VG_STACK_REDZONE_SZB < VKI_PAGE_SIZE); + if (VG_STACK_REDZONE_SZB > 0) { + vg_assert(resvn_size > VKI_PAGE_SIZE); + resvn_size -= VKI_PAGE_SIZE; + anon_start -= VKI_PAGE_SIZE; + anon_size += VKI_PAGE_SIZE; + } + + vg_assert(VG_IS_PAGE_ALIGNED(anon_size)); + vg_assert(VG_IS_PAGE_ALIGNED(resvn_size)); + vg_assert(VG_IS_PAGE_ALIGNED(anon_start)); + vg_assert(VG_IS_PAGE_ALIGNED(resvn_start)); + vg_assert(resvn_start == clstack_end + 1 - clstack_max_size); + +# ifdef ENABLE_INNER + inner_HACK = 1024*1024; // create 1M non-fault-extending stack +# endif + + if (0) + VG_(printf)("%#lx 0x%lx %#lx 0x%lx\n", + resvn_start, resvn_size, anon_start, anon_size); + + /* Create a shrinkable reservation followed by an anonymous + segment. Together these constitute a growdown stack. */ + res = VG_(mk_SysRes_Error)(0); + ok = VG_(am_create_reservation)( + resvn_start, + resvn_size -inner_HACK, + SmUpper, + anon_size +inner_HACK + ); + if (ok) { + /* allocate a stack - mmap enough space for the stack */ + res = VG_(am_mmap_anon_fixed_client)( + anon_start -inner_HACK, + anon_size +inner_HACK, + VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC + ); + } + if ((!ok) || sr_isError(res)) { + /* Allocation of the stack failed. We have to stop. */ + VG_(printf)("valgrind: " + "I failed to allocate space for the application's stack.\n"); + VG_(printf)("valgrind: " + "This may be the result of a very large --main-stacksize=\n"); + VG_(printf)("valgrind: setting. Cannot continue. Sorry.\n\n"); + VG_(exit)(1); + } + + vg_assert(ok); + vg_assert(!sr_isError(res)); + + /* Record stack extent -- needed for stack-change code. */ + VG_(clstk_start_base) = anon_start -inner_HACK; + VG_(clstk_end) = VG_(clstk_start_base) + anon_size +inner_HACK -1; + + } + + /* ==================== create client stack ==================== */ + + ptr = (Addr*)client_SP; + + /* --- client argc --- */ + *ptr++ = argc + (have_exename ? 1 : 0); + + /* --- client argv --- */ + if (info->interp_name) + *ptr++ = (Addr)copy_str(&strtab, info->interp_name); + if (info->interp_args) + *ptr++ = (Addr)copy_str(&strtab, info->interp_args); + + if (have_exename) + *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename)); + + for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { + *ptr++ = (Addr)copy_str( + &strtab, + * (HChar**) VG_(indexXA)( VG_(args_for_client), i ) + ); + } + *ptr++ = 0; + + /* --- envp --- */ + VG_(client_envp) = (HChar **)ptr; + for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++) + *ptr = (Addr)copy_str(&strtab, *cpp); + *ptr++ = 0; + + /* --- auxv --- */ + auxv = (struct auxv *)ptr; + *client_auxv = (UInt *)auxv; +#if defined(VGP_x86_freebsd) + int* pagesizes = NULL; +#endif + + /* + * The PAGESIZES hack - PJF + * + * Normally a standalone application has a full auxv which, among + * many other things contains a vector of integers (PAGESIZES) + * of a platform dependent length (PAGESIZESLEN). On x86 the + * length is 2, on amd64 the length is 3 (there are other lengths + * for architectures not supported on Valgrind). + * + * When the dynamic loader executes it will run a routine + * static void init_pagesizes(Elf_Auxinfo **aux_info) + * (see /usr/src/libexec/rtld-elf/rltd.c). If the PAGESIZES info is in + * auxv, init_pagesizes will use that. However, normally this loop + * does not copy 'pointered' elements (because that would generate + * 'Invalid reads' in the guest). This means that the auxv that + * Valgrind provides to ldrt *doesn't* normally contain + * PAGESIZES. + * + * So init_pagesizes falls back to using sysctlnametomib/sysctl + * to read "hw.pagesizes". Unfortunately there seems to be a bug + * in this for an x86 executable compiled and running on an amd64 + * kernel. + * + * The application sees MAXPAGESLEN as 3 (from the amd64 headers) + * but the x86 kernel sees MAXPAGESLEN as 2. The routine that + * copies out the data for a sysctl sees this discrepancy and + * sets an ENOMEM error. So guest execution doesn't even get past + * executing the dynamic linker. + */ + + for (; orig_auxv->a_type != AT_NULL; auxv++, orig_auxv++) { + + /* copy the entry... */ + *auxv = *orig_auxv; + + /* + * ...and fix up / examine the copy + * in general there are thee possibilities for these items + * 1. copy it, a common case for scalars + * 2. synthesize, if the value that the host gets isn't what we want + * 3. ignore, usually the case for pointers to memory for the host + * the ignored items are just left commented out + */ + switch(auxv->a_type) { + + case AT_IGNORE: + case AT_PHENT: + case AT_PAGESZ: + case AT_FLAGS: + case AT_NOTELF: + case AT_UID: + case AT_EUID: + case AT_GID: + case AT_EGID: + case AT_STACKPROT: + case AT_NCPUS: + case AT_OSRELDATE: +#if (FREEBSD_VERS >= FREEBSD_11) + // FreeBSD 11+ also have HWCAP and HWCAP2 + case AT_EHDRFLAGS: +#endif + /* All these are pointerless, so we don't need to do + anything about them. */ + break; + // case AT_CANARYLEN: + // case AT_EXECPATH: + // case AT_CANARY: +#if defined(VGP_x86_freebsd) + case AT_PAGESIZESLEN: + if (!VG_(is32on64)()) { + VG_(debugLog)(2, "initimg", + "stomping auxv entry %llu\n", + (ULong)auxv->a_type); + auxv->a_type = AT_IGNORE; + } + break; + case AT_PAGESIZES: + if (VG_(is32on64)()) { + pagesizes = VG_(malloc)("initimg-freebsd.cpauxv.1", 2*sizeof(int)); + ... [truncated message content] |
|
From: Paul F. <pa...@so...> - 2021-10-09 10:52:49
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=1bbd829adb5a192593543d7b0fc2fab154317ece commit 1bbd829adb5a192593543d7b0fc2fab154317ece Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 12:51:41 2021 +0200 FreeBSD support, patch 10 Missing new expected file Diff: --- memcheck/tests/dw4.stderr.exp-freebsd | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/memcheck/tests/dw4.stderr.exp-freebsd b/memcheck/tests/dw4.stderr.exp-freebsd new file mode 100644 index 0000000000..e396a43b8a --- /dev/null +++ b/memcheck/tests/dw4.stderr.exp-freebsd @@ -0,0 +1,49 @@ +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:59) + Address 0x........ is 4 bytes inside a block of size ... alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (dw4.c:52) + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:61) + Location 0x........ is 0 bytes inside S2[0].i, + a global variable declared at dw4.c:47 + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:62) + Location 0x........ is 0 bytes inside local.i, + declared at dw4.c:51, in frame #1 of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:68) + Address 0x........ is in a rw- anonymous segment + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:82) + Address 0x........ is in a rw- mapped file valgrind-dw4-test.PID segment + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:87) + Address 0x........ is 0 bytes after the brk data segment limit 0x........ + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:89) + Address 0x........ is in the brk data segment 0x........-0x........ + +Uninitialised byte(s) found during client check request + at 0x........: croak (dw4.c:32) + by 0x........: main (dw4.c:91) + Address 0x........ is in the brk data segment 0x........-0x........ + +Unaddressable byte(s) found during client check request + at 0x........: croak (dw4.c:25) + by 0x........: main (dw4.c:93) + Address 0x........ is 1024 bytes after the brk data segment limit 0x........ + |
|
From: Paul F. <pa...@so...> - 2021-10-09 10:39:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7c5d720a2b67b19cd06210d83434295ae838ea89 commit 7c5d720a2b67b19cd06210d83434295ae838ea89 Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 12:37:17 2021 +0200 FreeBSD support, patch 10 memcheck No code changes. A few modified tests. Adds new FreeBSD specific tests. Diff: --- configure.ac | 11 + memcheck/tests/Makefile.am | 28 +- memcheck/tests/addressable.c | 3 + memcheck/tests/addressable.stderr.exp | 24 +- memcheck/tests/amd64-freebsd/Makefile.am | 20 + memcheck/tests/amd64-freebsd/posix_fadvise.c | 27 + .../tests/amd64-freebsd/posix_fadvise.stderr.exp | 16 + memcheck/tests/amd64-freebsd/posix_fadvise.vgtest | 3 + memcheck/tests/amd64-freebsd/posix_fallocate.c | 19 + .../tests/amd64-freebsd/posix_fallocate.stderr.exp | 8 + .../tests/amd64-freebsd/posix_fallocate.vgtest | 3 + memcheck/tests/amd64/Makefile.am | 3 +- .../tests/amd64/insn-pmovmskb.stderr.exp-clang | 48 + .../tests/amd64/xor-undef-amd64.stderr.exp-freebsd | 26 + memcheck/tests/badjump2.c | 4 +- memcheck/tests/demangle.stderr.exp-freebsd | 0 memcheck/tests/err_disable4.c | 2 + memcheck/tests/filter_dw4 | 11 - memcheck/tests/filter_dw4.in | 13 + memcheck/tests/filter_malloc_free | 2 +- memcheck/tests/filter_overlaperror | 4 - memcheck/tests/filter_overlaperror.in | 6 + memcheck/tests/{filter_stderr => filter_stderr.in} | 6 +- memcheck/tests/filter_varinfo3 | 5 +- memcheck/tests/fprw.stderr.exp-freebsd | 35 + memcheck/tests/fprw.stderr.exp-freebsd-x86 | 41 + memcheck/tests/freebsd/Makefile.am | 93 + memcheck/tests/freebsd/access.c | 43 + memcheck/tests/freebsd/access.stderr.exp | 53 + memcheck/tests/freebsd/access.vgtest | 3 + memcheck/tests/freebsd/capsicum.c | 97 + memcheck/tests/freebsd/capsicum.stderr.exp | 41 + memcheck/tests/freebsd/capsicum.vgtest | 3 + memcheck/tests/freebsd/chflags.c | 43 + memcheck/tests/freebsd/chflags.stderr.exp | 57 + memcheck/tests/freebsd/chflags.stderr.exp-x86 | 58 + memcheck/tests/freebsd/chflags.vgtest | 4 + memcheck/tests/freebsd/chmod_chown.c | 65 + memcheck/tests/freebsd/chmod_chown.stderr.exp | 65 + memcheck/tests/freebsd/chmod_chown.vgtest | 3 + memcheck/tests/freebsd/dump_stdout | 2 + memcheck/tests/freebsd/extattr.c | 99 + memcheck/tests/freebsd/extattr.stderr.exp | 209 + memcheck/tests/freebsd/extattr.vgtest | 2 + memcheck/tests/freebsd/file_locking_wait6.c | 130 + .../tests/freebsd/file_locking_wait6.stderr.exp | 5 + memcheck/tests/freebsd/file_locking_wait6.vgtest | 2 + memcheck/tests/freebsd/filter_scalar | 12 + memcheck/tests/freebsd/filter_sigwait | 5 + memcheck/tests/freebsd/filter_stderr | 3 + memcheck/tests/freebsd/get_set_context.c | 50 + memcheck/tests/freebsd/get_set_context.stderr.exp | 40 + .../tests/freebsd/get_set_context.stderr.exp-x86 | 40 + memcheck/tests/freebsd/get_set_context.vgtest | 2 + memcheck/tests/freebsd/get_set_login.c | 15 + memcheck/tests/freebsd/get_set_login.stderr.exp | 11 + memcheck/tests/freebsd/get_set_login.vgtest | 2 + memcheck/tests/freebsd/getfh.c | 50 + memcheck/tests/freebsd/getfh.stderr.exp | 71 + memcheck/tests/freebsd/getfh.vgtest | 2 + memcheck/tests/freebsd/getfsstat.c | 33 + memcheck/tests/freebsd/getfsstat.stderr.exp | 18 + memcheck/tests/freebsd/getfsstat.stderr.exp-x86 | 21 + memcheck/tests/freebsd/getfsstat.supp | 38 + memcheck/tests/freebsd/getfsstat.vgtest | 4 + memcheck/tests/freebsd/inlinfo.c | 11 + memcheck/tests/freebsd/inlinfo_nested.c | 78 + memcheck/tests/freebsd/linkat.c | 85 + memcheck/tests/freebsd/linkat.stderr.exp | 94 + memcheck/tests/freebsd/linkat.vgtest | 2 + memcheck/tests/freebsd/misc.c | 63 + memcheck/tests/freebsd/misc.stderr.exp | 32 + memcheck/tests/freebsd/misc.vgtest | 3 + memcheck/tests/freebsd/pdfork_pdkill.c | 101 + memcheck/tests/freebsd/pdfork_pdkill.stderr.exp | 41 + memcheck/tests/freebsd/pdfork_pdkill.vgtest | 4 + memcheck/tests/freebsd/revoke.c | 21 + memcheck/tests/freebsd/revoke.stderr.exp | 11 + memcheck/tests/freebsd/revoke.vgtest | 3 + memcheck/tests/freebsd/scalar.c | 2042 ++++++++ memcheck/tests/freebsd/scalar.h | 39 + memcheck/tests/freebsd/scalar.stderr.exp | 5310 +++++++++++++++++++ .../tests/freebsd/scalar.stderr.exp-freebsd130 | 5313 +++++++++++++++++++ memcheck/tests/freebsd/scalar.stderr.exp-x86 | 5371 ++++++++++++++++++++ memcheck/tests/freebsd/scalar.vgtest | 11 + memcheck/tests/freebsd/scalar_abort2.c | 14 + memcheck/tests/freebsd/scalar_abort2.stderr.exp | 25 + memcheck/tests/freebsd/scalar_abort2.vgtest | 2 + memcheck/tests/freebsd/scalar_fork.c | 11 + memcheck/tests/freebsd/scalar_fork.stderr.exp | 3 + memcheck/tests/freebsd/scalar_fork.vgtest | 2 + memcheck/tests/freebsd/scalar_pdfork.c | 14 + memcheck/tests/freebsd/scalar_pdfork.stderr.exp | 11 + memcheck/tests/freebsd/scalar_pdfork.vgtest | 2 + memcheck/tests/freebsd/scalar_thr_exit.c | 14 + memcheck/tests/freebsd/scalar_thr_exit.stderr.exp | 12 + memcheck/tests/freebsd/scalar_thr_exit.vgtest | 2 + memcheck/tests/freebsd/scalar_vfork.c | 11 + memcheck/tests/freebsd/scalar_vfork.stderr.exp | 3 + memcheck/tests/freebsd/scalar_vfork.vgtest | 2 + memcheck/tests/freebsd/sigwait.c | 68 + memcheck/tests/freebsd/sigwait.stderr.exp | 22 + memcheck/tests/freebsd/sigwait.stderr.exp-x86 | 24 + memcheck/tests/freebsd/sigwait.stdout.exp | 3 + memcheck/tests/freebsd/sigwait.vgtest | 3 + memcheck/tests/freebsd/stat.c | 71 + memcheck/tests/freebsd/stat.stderr.exp | 49 + memcheck/tests/freebsd/stat.stderr.exp-x86 | 49 + memcheck/tests/freebsd/stat.vgtest | 3 + memcheck/tests/freebsd/statfs.c | 46 + memcheck/tests/freebsd/statfs.stderr.exp | 47 + memcheck/tests/freebsd/statfs.vgtest | 3 + memcheck/tests/freebsd/static_allocs.c | 39 + memcheck/tests/freebsd/static_allocs.stderr.exp | 5 + memcheck/tests/freebsd/static_allocs.vgtest | 2 + memcheck/tests/freebsd/supponlyobj.stderr.exp | 8 + memcheck/tests/freebsd/supponlyobj.supp | 16 + memcheck/tests/freebsd/supponlyobj.vgtest | 4 + memcheck/tests/freebsd/utimens.c | 57 + memcheck/tests/freebsd/utimens.stderr.exp | 36 + memcheck/tests/freebsd/utimens.vgtest | 3 + memcheck/tests/freebsd/utimes.c | 99 + memcheck/tests/freebsd/utimes.stderr.exp | 96 + memcheck/tests/freebsd/utimes.stderr.exp-x86 | 96 + memcheck/tests/freebsd/utimes.vgtest | 2 + .../tests/leak-autofreepool-5.stderr.exp-freebsd | 34 + memcheck/tests/leak-segv-jmp.c | 96 + memcheck/tests/leak-segv-jmp.stderr.exp | 20 +- .../tests/leak_cpp_interior.stderr.exp-freebsd | 131 + memcheck/tests/libstdc++.supp | 10 + memcheck/tests/manuel1.stderr.exp-freebsd-clang | 28 + memcheck/tests/memalign2.c | 2 + .../tests/memalign_test.stderr.exp-freebsd-clang | 10 + memcheck/tests/origin1-yes.stderr.exp-freebsd | 29 + .../tests/origin2-not-quite.stderr.exp-freebsd | 11 + memcheck/tests/origin3-no.stderr.exp-freebsd | 22 + memcheck/tests/origin4-many.c | 16 +- memcheck/tests/origin5-bz2.stderr.exp-freebsd | 158 + memcheck/tests/origin5-bz2.stderr.exp-freebsd-x86 | 158 + memcheck/tests/sendmsg.stderr.exp-freebsd | 20 + memcheck/tests/sendmsg.stderr.exp-freebsd-x86 | 20 + memcheck/tests/sigkill.stderr.exp-freebsd | 197 + memcheck/tests/str_tester.c | 26 +- memcheck/tests/supp_unknown.supp | 8 + memcheck/tests/supponlyobj.vgtest | 3 +- memcheck/tests/test-plo-no.stderr.exp-le32-freebsd | 18 + .../test-plo-no.stderr.exp-le32-freebsd-clang | 20 + memcheck/tests/test-plo-no.stderr.exp-le64-freebsd | 20 + memcheck/tests/thread_alloca.c | 2 + memcheck/tests/varinfo1.c | 4 +- memcheck/tests/varinfo1.stderr.exp | 2 +- memcheck/tests/varinfo1.stderr.exp-freebsd | 37 + memcheck/tests/varinfo1.vgtest | 1 + memcheck/tests/varinfo2.c | 4 +- memcheck/tests/varinfo2.stderr.exp | 6 +- memcheck/tests/varinfo2.stderr.exp-ppc64 | 6 +- memcheck/tests/varinfo2.vgtest | 1 + memcheck/tests/varinfo3.c | 4 +- memcheck/tests/varinfo3.stderr.exp | 4 +- memcheck/tests/varinfo3.stderr.exp-freebsd | 58 + memcheck/tests/varinfo4.c | 4 +- memcheck/tests/varinfo4.stderr.exp-freebsd | 21 + memcheck/tests/varinfo5.stderr.exp | 20 +- memcheck/tests/varinfo5.stderr.exp-ppc64 | 16 +- memcheck/tests/varinfo5so.c | 4 +- memcheck/tests/varinfo6.c | 4 +- memcheck/tests/vbit-test/util.c | 6 +- memcheck/tests/vbit-test/vbits.c | 6 +- memcheck/tests/wrap6.c | 19 + memcheck/tests/x86-freebsd/Makefile.am | 21 + memcheck/tests/x86-freebsd/posix_fadvise.c | 27 + .../tests/x86-freebsd/posix_fadvise.stderr.exp | 24 + memcheck/tests/x86-freebsd/posix_fadvise.vgtest | 3 + memcheck/tests/x86-freebsd/posix_fallocate.c | 19 + .../tests/x86-freebsd/posix_fallocate.stderr.exp | 16 + memcheck/tests/x86-freebsd/posix_fallocate.vgtest | 3 + memcheck/tests/x86/filter_pushfpopf | 5 - memcheck/tests/x86/filter_pushfpopf.in | 7 + memcheck/tests/x86/pushfpopf_s.S | 6 +- 179 files changed, 22775 insertions(+), 118 deletions(-) diff --git a/configure.ac b/configure.ac index 3f2a73ee27..39e619575e 100755 --- a/configure.ac +++ b/configure.ac @@ -5141,11 +5141,14 @@ AC_CONFIG_FILES([ memcheck/tests/linux/debuginfod-check.vgtest memcheck/tests/darwin/Makefile memcheck/tests/solaris/Makefile + memcheck/tests/freebsd/Makefile memcheck/tests/amd64-linux/Makefile memcheck/tests/arm64-linux/Makefile memcheck/tests/x86-linux/Makefile memcheck/tests/amd64-solaris/Makefile memcheck/tests/x86-solaris/Makefile + memcheck/tests/amd64-freebsd/Makefile + memcheck/tests/x86-freebsd/Makefile memcheck/tests/ppc32/Makefile memcheck/tests/ppc64/Makefile memcheck/tests/s390x/Makefile @@ -5216,6 +5219,14 @@ AC_CONFIG_FILES([tests/filter_stderr_basic], [chmod +x tests/filter_stderr_basic]) AC_CONFIG_FILES([tests/filter_discards], [chmod +x tests/filter_discards]) +AC_CONFIG_FILES([memcheck/tests/filter_stderr], + [chmod +x memcheck/tests/filter_stderr]) +AC_CONFIG_FILES([memcheck/tests/filter_dw4], + [chmod +x memcheck/tests/filter_dw4]) +AC_CONFIG_FILES([memcheck/tests/filter_overlaperror], + [chmod +x memcheck/tests/filter_overlaperror]) +AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf], + [chmod +x memcheck/tests/x86/filter_pushfpopf]) AC_CONFIG_FILES([gdbserver_tests/filter_gdb], [chmod +x gdbserver_tests/filter_gdb]) AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor], diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 9fe8082b94..3ce33af181 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -66,6 +66,7 @@ endif DIST_SUBDIRS = x86 amd64 ppc32 ppc64 s390x linux \ darwin solaris x86-linux amd64-linux arm64-linux \ x86-solaris amd64-solaris mips32 mips64 \ + freebsd amd64-freebsd x86-freebsd \ common . dist_noinst_SCRIPTS = \ @@ -138,11 +139,13 @@ EXTRA_DIST = \ cxx17_aligned_new.stdout.exp \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ demangle.stderr.exp demangle.vgtest \ + demangle.stderr.exp-freebsd \ big_debuginfo_symbol.stderr.exp big_debuginfo_symbol.vgtest \ describe-block.stderr.exp describe-block.vgtest \ descr_belowsp.vgtest descr_belowsp.stderr.exp \ doublefree.stderr.exp doublefree.vgtest \ dw4.vgtest dw4.stderr.exp dw4.stderr.exp-solaris dw4.stdout.exp \ + dw4.stderr.exp-freebsd \ err_disable1.vgtest err_disable1.stderr.exp \ err_disable2.vgtest err_disable2.stderr.exp \ err_disable3.vgtest err_disable3.stderr.exp \ @@ -155,8 +158,9 @@ EXTRA_DIST = \ execve1.stderr.exp execve1.vgtest execve1.stderr.exp-kfail \ execve2.stderr.exp execve2.vgtest execve2.stderr.exp-kfail \ file_locking.stderr.exp file_locking.vgtest \ - fprw.stderr.exp fprw.stderr.exp-mips32-be fprw.stderr.exp-mips32-le \ - fprw.vgtest \ + fprw.stderr.exp fprw.stderr.exp-freebsd fprw.stderr.exp-mips32-be \ + fprw.stderr.exp-mips32-le fprw.vgtest \ + fprw.stderr.exp-freebsd-x86 \ fwrite.stderr.exp fwrite.vgtest fwrite.stderr.exp-kfail \ gone_abrt_xml.vgtest gone_abrt_xml.stderr.exp gone_abrt_xml.stderr.exp-solaris \ holey_buffer_too_small.vgtest holey_buffer_too_small.stdout.exp \ @@ -186,6 +190,7 @@ EXTRA_DIST = \ leak-autofreepool-4.vgtest leak-autofreepool-4.stderr.exp \ leak-autofreepool-5.vgtest leak-autofreepool-5.stderr.exp \ leak-autofreepool-6.vgtest leak-autofreepool-6.stderr.exp \ + leak-autofreepool-5.stderr.exp-freebsd \ leak-tree.vgtest leak-tree.stderr.exp \ leak-segv-jmp.vgtest leak-segv-jmp.stderr.exp \ lks.vgtest lks.stdout.exp lks.supp lks.stderr.exp \ @@ -204,11 +209,13 @@ EXTRA_DIST = \ malloc2.stderr.exp malloc2.vgtest \ malloc3.stderr.exp malloc3.stdout.exp malloc3.vgtest \ manuel1.stderr.exp manuel1.stdout.exp manuel1.vgtest \ + manuel1.stderr.exp-freebsd-clang \ manuel2.stderr.exp manuel2.stderr.exp64 manuel2.stdout.exp \ manuel2.vgtest \ manuel3.stderr.exp manuel3.vgtest \ match-overrun.stderr.exp match-overrun.vgtest match-overrun.supp \ memalign_test.stderr.exp memalign_test.vgtest \ + memalign_test.stderr.exp-freebsd-clang \ memalign2.stderr.exp memalign2.vgtest \ memcmptest.stderr.exp memcmptest.stderr.exp2 \ memcmptest.stdout.exp memcmptest.vgtest \ @@ -225,9 +232,12 @@ EXTRA_DIST = \ noisy_child.vgtest noisy_child.stderr.exp noisy_child.stdout.exp \ null_socket.stderr.exp null_socket.vgtest \ origin1-yes.vgtest origin1-yes.stdout.exp origin1-yes.stderr.exp \ + origin1-yes.stderr.exp-freebsd \ origin2-not-quite.vgtest origin2-not-quite.stdout.exp \ origin2-not-quite.stderr.exp \ + origin2-not-quite.stderr.exp-freebsd \ origin3-no.vgtest origin3-no.stdout.exp \ + origin3-no.stderr.exp-freebsd \ origin3-no.stderr.exp \ origin4-many.vgtest origin4-many.stdout.exp \ origin4-many.stderr.exp \ @@ -238,6 +248,8 @@ EXTRA_DIST = \ origin5-bz2.stderr.exp-glibc27-ppc64 \ origin5-bz2.stderr.exp-glibc212-s390x \ origin5-bz2.stderr.exp-glibc234-s390x \ + origin5-bz2.stderr.exp-freebsd \ + origin5-bz2.stderr.exp-freebsd-x86 \ origin5-bz2.stderr.exp-glibc218-mips32 \ origin6-fp.vgtest origin6-fp.stdout.exp \ origin6-fp.stderr.exp-glibc25-amd64 \ @@ -272,11 +284,13 @@ EXTRA_DIST = \ sbfragment.stdout.exp sbfragment.stderr.exp sbfragment.vgtest \ sem.stderr.exp sem.vgtest \ sendmsg.stderr.exp sendmsg.stderr.exp-solaris sendmsg.vgtest \ + sendmsg.stderr.exp-freebsd \ + sendmsg.stderr.exp-freebsd-x86 \ sh-mem.stderr.exp sh-mem.vgtest \ sh-mem-random.stderr.exp sh-mem-random.stdout.exp64 \ sh-mem-random.stdout.exp sh-mem-random.vgtest \ sigaltstack.stderr.exp sigaltstack.vgtest \ - sigkill.stderr.exp sigkill.stderr.exp-darwin sigkill.stderr.exp-mips32 \ + sigkill.stderr.exp sigkill.stderr.exp-darwin sigkill.stderr.exp-freebsd sigkill.stderr.exp-mips32 \ sigkill.stderr.exp-solaris \ sigkill.stderr.exp-glibc-2.28 sigkill.vgtest \ signal2.stderr.exp signal2.stdout.exp signal2.vgtest \ @@ -302,6 +316,8 @@ EXTRA_DIST = \ suppvarinfo5.stderr.exp suppvarinfo5.supp suppvarinfo5.vgtest \ test-plo-no.vgtest test-plo-no.stdout.exp \ test-plo-no.stderr.exp-le64 test-plo-no.stderr.exp-le32 \ + test-plo-no.stderr.exp-le32-freebsd test-plo-no.stderr.exp-le64-freebsd \ + test-plo-no.stderr.exp-le32-freebsd-clang \ test-plo-yes.vgtest test-plo-yes.stdout.exp \ test-plo-yes.stderr.exp-le64 test-plo-yes.stderr.exp-le32 \ test-plo-no.stderr.exp-s390x-mvc \ @@ -314,12 +330,15 @@ EXTRA_DIST = \ unit_oset.stderr.exp unit_oset.stdout.exp unit_oset.vgtest \ varinfo1.vgtest varinfo1.stdout.exp varinfo1.stderr.exp \ varinfo1.stderr.exp-ppc64 \ + varinfo1.stderr.exp-freebsd \ varinfo2.vgtest varinfo2.stdout.exp varinfo2.stderr.exp \ varinfo2.stderr.exp-ppc64 \ varinfo3.vgtest varinfo3.stdout.exp varinfo3.stderr.exp \ varinfo3.stderr.exp-ppc64 \ + varinfo3.stderr.exp-freebsd \ varinfo4.vgtest varinfo4.stdout.exp varinfo4.stderr.exp \ varinfo4.stderr.exp-ppc64 \ + varinfo4.stderr.exp-freebsd \ varinfo5.vgtest varinfo5.stdout.exp varinfo5.stderr.exp \ varinfo5.stderr.exp-ppc64 \ varinfo6.vgtest varinfo6.stdout.exp varinfo6.stderr.exp \ @@ -344,7 +363,8 @@ EXTRA_DIST = \ wrapmallocstatic.vgtest wrapmallocstatic.stdout.exp \ wrapmallocstatic.stderr.exp \ writev1.stderr.exp writev1.stderr.exp-solaris writev1.vgtest \ - xml1.stderr.exp xml1.stdout.exp xml1.vgtest xml1.stderr.exp-s390x-mvc + xml1.stderr.exp xml1.stdout.exp xml1.vgtest xml1.stderr.exp-s390x-mvc \ + leak_cpp_interior.stderr.exp-freebsd check_PROGRAMS = \ accounting \ diff --git a/memcheck/tests/addressable.c b/memcheck/tests/addressable.c index 5f3c2e182e..568fbb45ed 100644 --- a/memcheck/tests/addressable.c +++ b/memcheck/tests/addressable.c @@ -9,6 +9,9 @@ #include <errno.h> #include <string.h> #include <stdlib.h> +#if defined(VGO_freebsd) +#include <signal.h> +#endif static int pgsz; diff --git a/memcheck/tests/addressable.stderr.exp b/memcheck/tests/addressable.stderr.exp index 4c121987d6..533d6e9bb1 100644 --- a/memcheck/tests/addressable.stderr.exp +++ b/memcheck/tests/addressable.stderr.exp @@ -9,20 +9,20 @@ For a detailed leak analysis, rerun with: --leak-check=full For lists of detected and suppressed errors, rerun with: -s ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Unaddressable byte(s) found during client check request - at 0x........: test2 (addressable.c:48) - by 0x........: main (addressable.c:125) + at 0x........: test2 (addressable.c:51) + by 0x........: main (addressable.c:128) Address 0x........ is not stack'd, malloc'd or (recently) free'd Invalid write of size 1 - at 0x........: test2 (addressable.c:51) - by 0x........: main (addressable.c:125) + at 0x........: test2 (addressable.c:54) + by 0x........: main (addressable.c:128) Address 0x........ is not stack'd, malloc'd or (recently) free'd Process terminating with default action of signal N (SIGSEGV or SIGBUS) Bad memory (SIGSEGV or SIGBUS) at address 0x........ - at 0x........: test2 (addressable.c:51) - by 0x........: main (addressable.c:125) + at 0x........: test2 (addressable.c:54) + by 0x........: main (addressable.c:128) If you believe this happened as a result of a stack overflow in your program's main thread (unlikely but possible), you can try to increase the size of the @@ -49,8 +49,8 @@ ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Process terminating with default action of signal N (SIGSEGV or SIGBUS) Bad memory (SIGSEGV or SIGBUS) at address 0x........ - at 0x........: test4 (addressable.c:74) - by 0x........: main (addressable.c:125) + at 0x........: test4 (addressable.c:77) + by 0x........: main (addressable.c:128) HEAP SUMMARY: in use at exit: ... bytes in ... blocks @@ -61,13 +61,13 @@ For a detailed leak analysis, rerun with: --leak-check=full For lists of detected and suppressed errors, rerun with: -s ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Uninitialised byte(s) found during client check request - at 0x........: test5 (addressable.c:85) - by 0x........: main (addressable.c:125) + at 0x........: test5 (addressable.c:88) + by 0x........: main (addressable.c:128) Address 0x........ is in a rw- anonymous segment Uninitialised byte(s) found during client check request - at 0x........: test5 (addressable.c:91) - by 0x........: main (addressable.c:125) + at 0x........: test5 (addressable.c:94) + by 0x........: main (addressable.c:128) Address 0x........ is in a r-- anonymous segment diff --git a/memcheck/tests/amd64-freebsd/Makefile.am b/memcheck/tests/amd64-freebsd/Makefile.am new file mode 100644 index 0000000000..80854419dd --- /dev/null +++ b/memcheck/tests/amd64-freebsd/Makefile.am @@ -0,0 +1,20 @@ + +include $(top_srcdir)/Makefile.tool-tests.am + +dist_noinst_SCRIPTS = filter_stderr + +EXTRA_DIST = \ + posix_fadvise.vgtest \ + posix_fallocate.vgtest \ + posix_fadvise.stderr.exp \ + posix_fallocate.stderr.exp + +check_PROGRAMS = \ + posix_fadvise posix_fallocate + +AM_CFLAGS += @FLAG_M64@ +AM_CXXFLAGS += @FLAG_M64@ +AM_CCASFLAGS += @FLAG_M64@ + +posix_fallocate_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ +posix_fadvise_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ diff --git a/memcheck/tests/amd64-freebsd/posix_fadvise.c b/memcheck/tests/amd64-freebsd/posix_fadvise.c new file mode 100644 index 0000000000..2ba2005ae6 --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fadvise.c @@ -0,0 +1,27 @@ +#include <fcntl.h> +#include <stdio.h> +#include <errno.h> + +int main(void) +{ + int fd = open("foo", O_RDWR|O_CREAT, 0666); + if (fd < 0) return 1; + posix_fadvise( fd, 0, 4096, POSIX_FADV_WILLNEED ); + posix_fadvise( fd, 0, 0, POSIX_FADV_NOREUSE ); + + int badfd = 42; + posix_fadvise( badfd, 0, 4096, POSIX_FADV_WILLNEED ); + + int x; + posix_fadvise(x, 1, 2, POSIX_FADV_NORMAL); + posix_fadvise(badfd, x, 2, POSIX_FADV_NORMAL); + posix_fadvise(badfd, 1, x, POSIX_FADV_NORMAL); + posix_fadvise(badfd, 1, 2, x); + + x = posix_fadvise(badfd + , 1, 2, POSIX_FADV_NORMAL); + + if (x != EBADF) + fprintf(stderr, "Unexpected return value: %d\n", x); +} + diff --git a/memcheck/tests/amd64-freebsd/posix_fadvise.stderr.exp b/memcheck/tests/amd64-freebsd/posix_fadvise.stderr.exp new file mode 100644 index 0000000000..3fb69d8413 --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fadvise.stderr.exp @@ -0,0 +1,16 @@ +Syscall param posix_fadvise(fd) contains uninitialised byte(s) + at 0x........: posix_fadvise (in /...libc...) + by 0x........: main (posix_fadvise.c:16) + +Syscall param posix_fadvise(offset) contains uninitialised byte(s) + at 0x........: posix_fadvise (in /...libc...) + by 0x........: main (posix_fadvise.c:17) + +Syscall param posix_fadvise(len) contains uninitialised byte(s) + at 0x........: posix_fadvise (in /...libc...) + by 0x........: main (posix_fadvise.c:18) + +Syscall param posix_fadvise(advice) contains uninitialised byte(s) + at 0x........: posix_fadvise (in /...libc...) + by 0x........: main (posix_fadvise.c:19) + diff --git a/memcheck/tests/amd64-freebsd/posix_fadvise.vgtest b/memcheck/tests/amd64-freebsd/posix_fadvise.vgtest new file mode 100644 index 0000000000..6353a958cb --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fadvise.vgtest @@ -0,0 +1,3 @@ +prog: posix_fadvise +vgopts: -q +cleanup: rm -f foo diff --git a/memcheck/tests/amd64-freebsd/posix_fallocate.c b/memcheck/tests/amd64-freebsd/posix_fallocate.c new file mode 100644 index 0000000000..8c04594379 --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fallocate.c @@ -0,0 +1,19 @@ +#include <fcntl.h> +#include <stdio.h> +#include <errno.h> + +int main(void) +{ + int fd = open("foo", O_RDWR|O_CREAT, 0666); + if (fd < 0) return 1; + posix_fallocate(fd, 0, 400000); + + int badfd = 42; + int x; + posix_fallocate(badfd, x, 20); + posix_fallocate(badfd, 0, x); + x = posix_fallocate(badfd, 0, 20); + if (x != EBADF) + fprintf(stderr, "Unexpected return value: %d\n", x); +} + diff --git a/memcheck/tests/amd64-freebsd/posix_fallocate.stderr.exp b/memcheck/tests/amd64-freebsd/posix_fallocate.stderr.exp new file mode 100644 index 0000000000..063b6d98ba --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fallocate.stderr.exp @@ -0,0 +1,8 @@ +Syscall param posix_fallocate(offset) contains uninitialised byte(s) + at 0x........: posix_fallocate (in /...libc...) + by 0x........: main (posix_fallocate.c:13) + +Syscall param posix_fallocate(len) contains uninitialised byte(s) + at 0x........: posix_fallocate (in /...libc...) + by 0x........: main (posix_fallocate.c:14) + diff --git a/memcheck/tests/amd64-freebsd/posix_fallocate.vgtest b/memcheck/tests/amd64-freebsd/posix_fallocate.vgtest new file mode 100644 index 0000000000..28954e87fe --- /dev/null +++ b/memcheck/tests/amd64-freebsd/posix_fallocate.vgtest @@ -0,0 +1,3 @@ +prog: posix_fallocate +vgopts: -q +cleanup: rm -f foo diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index da15cf797a..d5c94f68a0 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -17,6 +17,7 @@ EXTRA_DIST = \ insn-bsfl.vgtest insn-bsfl.stdout.exp insn-bsfl.stderr.exp \ insn-pcmpistri.vgtest insn-pcmpistri.stdout.exp insn-pcmpistri.stderr.exp \ insn-pmovmskb.vgtest insn-pmovmskb.stdout.exp insn-pmovmskb.stderr.exp \ + insn-pmovmskb.stderr.exp-clang \ more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \ sh-mem-vec128-plo-no.vgtest \ sh-mem-vec128-plo-no.stderr.exp \ @@ -33,7 +34,7 @@ EXTRA_DIST = \ shr_edx.stderr.exp shr_edx.stdout.exp shr_edx.vgtest \ sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest \ xor-undef-amd64.stderr.exp xor-undef-amd64.stdout.exp \ - xor-undef-amd64.vgtest \ + xor-undef-amd64.stderr.exp-freebsd xor-undef-amd64.vgtest \ xsave-avx.vgtest xsave-avx.stdout.exp xsave-avx.stderr.exp check_PROGRAMS = \ diff --git a/memcheck/tests/amd64/insn-pmovmskb.stderr.exp-clang b/memcheck/tests/amd64/insn-pmovmskb.stderr.exp-clang new file mode 100644 index 0000000000..6d32a1f331 --- /dev/null +++ b/memcheck/tests/amd64/insn-pmovmskb.stderr.exp-clang @@ -0,0 +1,48 @@ +Conditional jump or move depends on uninitialised value(s) + ... + by 0x........: use (insn-pmovmskb.c:48) + by 0x........: doit (insn-pmovmskb.c:69) + by 0x........: main (insn-pmovmskb.c:140) + +Use of uninitialised value of size 8 + ... + by 0x........: use (insn-pmovmskb.c:48) + by 0x........: doit (insn-pmovmskb.c:69) + by 0x........: main (insn-pmovmskb.c:140) + +Use of uninitialised value of size 8 + ... + by 0x........: use (insn-pmovmskb.c:48) + by 0x........: doit (insn-pmovmskb.c:69) + by 0x........: main (insn-pmovmskb.c:140) + +Use of uninitialised value of size 8 + ... + by 0x........: use (insn-pmovmskb.c:48) + by 0x........: doit (insn-pmovmskb.c:69) + by 0x........: main (insn-pmovmskb.c:140) + +0: Invalid value is false +1: Invalid value is false +2: Invalid value is false +3: Invalid value is false +4: Invalid value is false +5: Invalid value is false +6: Invalid value is false +7: Invalid value is false +8: Invalid value is false +9: Invalid value is false +10: Invalid value is false +11: Invalid value is false +12: Invalid value is false +13: Invalid value is false +14: Invalid value is false +15: Invalid value is false +4: Invalid value is true +5: Invalid value is true +6: Invalid value is true +7: Invalid value is true +8: Invalid value is true +9: Invalid value is true +12: Invalid value is true +13: Invalid value is true diff --git a/memcheck/tests/amd64/xor-undef-amd64.stderr.exp-freebsd b/memcheck/tests/amd64/xor-undef-amd64.stderr.exp-freebsd new file mode 100755 index 0000000000..0bfff27098 --- /dev/null +++ b/memcheck/tests/amd64/xor-undef-amd64.stderr.exp-freebsd @@ -0,0 +1,26 @@ + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (xor-undef-amd64.c:17) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (xor-undef-amd64.c:38) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (xor-undef-amd64.c:65) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (xor-undef-amd64.c:92) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (xor-undef-amd64.c:117) + + +HEAP SUMMARY: + in use at exit: 4,096 bytes in 1 blocks + total heap usage: 2 allocs, 1 frees, 4,144 bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +For counts of detected and suppressed errors, rerun with: -v +Use --track-origins=yes to see where uninitialised values come from +ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/badjump2.c b/memcheck/tests/badjump2.c index 2085a30d9e..ae858e7733 100644 --- a/memcheck/tests/badjump2.c +++ b/memcheck/tests/badjump2.c @@ -3,6 +3,7 @@ #include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> // Regression test for bug 91162: if a client had a SEGV signal handler, // and jumped to a bogus address, Valgrind would abort. With the fix, @@ -22,9 +23,10 @@ int main(void) int res; /* Install own SIGSEGV handler */ + memset(&sigsegv_new, 0, sizeof(sigsegv_new)); sigsegv_new.sa_handler = SIGSEGV_handler; sigsegv_new.sa_flags = 0; -#if !defined(__APPLE__) && !defined(__sun) +#if !defined(__APPLE__) && !defined(__sun) && !defined(__FreeBSD__) sigsegv_new.sa_restorer = NULL; #endif res = sigemptyset( &sigsegv_new.sa_mask ); diff --git a/memcheck/tests/demangle.stderr.exp-freebsd b/memcheck/tests/demangle.stderr.exp-freebsd new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/err_disable4.c b/memcheck/tests/err_disable4.c index 44487afd2f..0692192ec8 100644 --- a/memcheck/tests/err_disable4.c +++ b/memcheck/tests/err_disable4.c @@ -94,7 +94,9 @@ int main ( void ) pthread_attr_t attr; r = pthread_attr_init(&attr); assert(!r); +#if !defined(VGO_freebsd) r = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif // create N threads to do child_fn_1 ... for (i = 0; i < NTHREADS; i++) { diff --git a/memcheck/tests/filter_dw4 b/memcheck/tests/filter_dw4 deleted file mode 100755 index b192bb91b7..0000000000 --- a/memcheck/tests/filter_dw4 +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh - -# Size of structure s1 differs between 32-bit and 64-bit programs. -sed "s/inside a block of size [0-9]* alloc'd/inside a block of size ... alloc'd/" | - -# remove directory name and pid from mapped filename -sed "s/file .*valgrind-dw4-test.[1-9][0-9]*/file valgrind-dw4-test.PID/" | - -./filter_stderr "$@" - -exit 0 diff --git a/memcheck/tests/filter_dw4.in b/memcheck/tests/filter_dw4.in new file mode 100755 index 0000000000..b217ad57ca --- /dev/null +++ b/memcheck/tests/filter_dw4.in @@ -0,0 +1,13 @@ +#! /bin/sh + +SED=@SED@ + +# Size of structure s1 differs between 32-bit and 64-bit programs. +$SED "s/inside a block of size [0-9]* alloc'd/inside a block of size ... alloc'd/" | + +# remove directory name and pid from mapped filename +$SED "s/file .*valgrind-dw4-test.[1-9][0-9]*/file valgrind-dw4-test.PID/" | + +./filter_stderr "$@" + +exit 0 diff --git a/memcheck/tests/filter_malloc_free b/memcheck/tests/filter_malloc_free index 0f43cf2e1d..9d4c52559c 100755 --- a/memcheck/tests/filter_malloc_free +++ b/memcheck/tests/filter_malloc_free @@ -2,5 +2,5 @@ ./filter_stderr "$@" | ./filter_allocs | -sed -e '/^malloc/d;/^free/d' +sed -e '/^malloc/d;/^free/d;/^calloc/d' diff --git a/memcheck/tests/filter_overlaperror b/memcheck/tests/filter_overlaperror deleted file mode 100755 index bd477b7351..0000000000 --- a/memcheck/tests/filter_overlaperror +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -./filter_allocs "$@" | -sed 's/\(Memcheck: mc_leakcheck.c:\)[0-9]*\(.*impossible.*happened.*\)/\1...\2/' diff --git a/memcheck/tests/filter_overlaperror.in b/memcheck/tests/filter_overlaperror.in new file mode 100755 index 0000000000..3c853c0480 --- /dev/null +++ b/memcheck/tests/filter_overlaperror.in @@ -0,0 +1,6 @@ +#! /bin/sh + +SED=@SED@ + +./filter_allocs "$@" | +$SED 's/\(Memcheck: mc_leakcheck.c:\)[0-9]*\(.*impossible.*happened.*\)/\1...\2/' diff --git a/memcheck/tests/filter_stderr b/memcheck/tests/filter_stderr.in similarity index 90% rename from memcheck/tests/filter_stderr rename to memcheck/tests/filter_stderr.in index c6f6cd439f..a410fa89e7 100755 --- a/memcheck/tests/filter_stderr +++ b/memcheck/tests/filter_stderr.in @@ -2,20 +2,22 @@ dir=`dirname $0` +SED=@SED@ + $dir/../../tests/filter_stderr_basic | # Anonymise addresses $dir/../../tests/filter_addresses | # Remove "Memcheck, ..." line and the following copyright line. -sed "/^Memcheck, a memory error detector/ , /./ d" | +$SED "/^Memcheck, a memory error detector/ , /./ d" | # Replace exit_group() with exit(), because you can get either on Linux # depending on the system. perl -p -e "s/param exit_group\(status\)/param exit(status)/" | # Leak check filtering. -sed "s/checked [0-9,]* bytes./checked ... bytes./" | +$SED "s/checked [0-9,]* bytes./checked ... bytes./" | # More leak check filtering. For systems that do extra libc allocations # (eg. Darwin) there may be extra (reachable, and thus not shown) loss diff --git a/memcheck/tests/filter_varinfo3 b/memcheck/tests/filter_varinfo3 index dbf25eee5b..9f0a31c091 100755 --- a/memcheck/tests/filter_varinfo3 +++ b/memcheck/tests/filter_varinfo3 @@ -4,4 +4,7 @@ ./filter_stderr "$@" | sed "s/static_local_def\.[0-9]*/static_local_def\.XXXX/g" | -sed "s/static_local_undef\.[0-9]*/static_local_undef\.XXXX/g" +sed "s/static_local_undef\.[0-9]*/static_local_undef\.XXXX/g" | +sed "s/foo.static_local_undef/static_local_undef.XXXX/g" | +sed "s/frame #./frame #X/g" + diff --git a/memcheck/tests/fprw.stderr.exp-freebsd b/memcheck/tests/fprw.stderr.exp-freebsd new file mode 100644 index 0000000000..1efbdcd91e --- /dev/null +++ b/memcheck/tests/fprw.stderr.exp-freebsd @@ -0,0 +1,35 @@ +Invalid read of size 8 + at 0x........: main (fprw.c:20) + Address 0x........ is 0 bytes inside a block of size 8 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:18) + +Invalid write of size 8 + at 0x........: main (fprw.c:20) + Address 0x........ is 0 bytes inside a block of size 8 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:18) + +Invalid read of size 4 + at 0x........: main (fprw.c:21) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:19) + +Invalid write of size 4 + at 0x........: main (fprw.c:21) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:19) + +Invalid free() / delete / delete[] / realloc() + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:22) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Invalid write of size 8 + at 0x........: main (fprw.c:24) + Address 0x........ is 0 bytes inside a block of size 4 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:23) + diff --git a/memcheck/tests/fprw.stderr.exp-freebsd-x86 b/memcheck/tests/fprw.stderr.exp-freebsd-x86 new file mode 100644 index 0000000000..3b920e5922 --- /dev/null +++ b/memcheck/tests/fprw.stderr.exp-freebsd-x86 @@ -0,0 +1,41 @@ +Use of uninitialised value of size 4 + at 0x........: main (fprw.c:16) + +Use of uninitialised value of size 4 + at 0x........: main (fprw.c:17) + +Invalid read of size 8 + at 0x........: main (fprw.c:20) + Address 0x........ is 0 bytes inside a block of size 8 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:18) + +Invalid write of size 8 + at 0x........: main (fprw.c:20) + Address 0x........ is 0 bytes inside a block of size 8 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:18) + +Invalid read of size 4 + at 0x........: main (fprw.c:21) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:19) + +Invalid write of size 4 + at 0x........: main (fprw.c:21) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:19) + +Invalid free() / delete / delete[] / realloc() + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:22) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Invalid write of size 8 + at 0x........: main (fprw.c:24) + Address 0x........ is 0 bytes inside a block of size 4 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (fprw.c:23) + diff --git a/memcheck/tests/freebsd/Makefile.am b/memcheck/tests/freebsd/Makefile.am new file mode 100644 index 0000000000..c1d675a7a3 --- /dev/null +++ b/memcheck/tests/freebsd/Makefile.am @@ -0,0 +1,93 @@ + +include $(top_srcdir)/Makefile.tool-tests.am + +dist_noinst_SCRIPTS = filter_stderr filter_pts dump_stdout filter_sigwait \ + filter_scalar + +EXTRA_DIST = \ + scalar.h \ + statfs.vgtest \ + statfs.stderr.exp \ + pdfork_pdkill.vgtest \ + pdfork_pdkill.stderr.exp \ + getfsstat.vgtest \ + getfsstat.stderr.exp \ + getfsstat.supp \ + getfsstat.stderr.exp-x86 \ + supponlyobj.vgtest \ + supponlyobj.stderr.exp \ + supponlyobj.supp \ + extattr.vgtest \ + extattr.stderr.exp \ + sigwait.vgtest \ + sigwait.stdout.exp \ + sigwait.stderr.exp \ + sigwait.stderr.exp-x86 \ + chflags.vgtest\ + chflags.stderr.exp \ + chflags.stderr.exp-x86 \ + get_set_login.vgtest \ + get_set_login.stderr.exp \ + revoke.vgtest \ + revoke.stderr.exp \ + scalar.vgtest \ + scalar.stderr.exp \ + scalar.stderr.exp-x86 \ + scalar.stderr.exp-freebsd130 \ + capsicum.vgtest \ + capsicum.stderr.exp \ + getfh.vgtest \ + getfh.stderr.exp \ + linkat.vgtest \ + linkat.stderr.exp \ + scalar_fork.vgtest \ + scalar_fork.stderr.exp \ + scalar_thr_exit.vgtest \ + scalar_thr_exit.stderr.exp \ + scalar_abort2.vgtest \ + scalar_abort2.stderr.exp \ + scalar_pdfork.vgtest \ + scalar_pdfork.stderr.exp \ + scalar_vfork.vgtest \ + scalar_vfork.stderr.exp \ + stat.vgtest \ + stat.stderr.exp \ + stat.stderr.exp-x86 \ + file_locking_wait6.vgtest \ + file_locking_wait6.stderr.exp \ + utimens.vgtest \ + utimens.stderr.exp \ + access.vgtest \ + access.stderr.exp \ + chmod_chown.vgtest \ + chmod_chown.stderr.exp \ + misc.vgtest \ + misc.stderr.exp \ + get_set_context.vgtest \ + get_set_context.stderr.exp \ + get_set_context.stderr.exp-x86 \ + utimes.vgtest \ + utimes.stderr.exp-x86 \ + utimes.stderr.exp \ + static_allocs.vgtest \ + static_allocs.stderr.exp + +check_PROGRAMS = \ + statfs pdfork_pdkill getfsstat inlinfo inlinfo_nested.so extattr \ + sigwait chflags get_set_login revoke scalar capsicum getfh \ + linkat scalar_fork scalar_thr_exit scalar_abort2 scalar_pdfork \ + scalar_vfork stat file_locking_wait6 utimens access chmod_chown \ + misc get_set_context utimes static_allocs + +AM_CFLAGS += $(AM_FLAG_M3264_PRI) +AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) + +inlinfo_SOURCES = inlinfo.c +inlinfo_DEPENDENCIES = inlinfo_nested.so +inlinfo_LDFLAGS = -Wl,-rpath,$(top_builddir)/memcheck/tests/freebsd +inlinfo_LDADD = inlinfo_nested.so +inlinfo_nested_so_SOURCES = inlinfo_nested.c +inlinfo_nested_so_CFLAGS = $(AM_CFLAGS) -fPIC @FLAG_W_NO_UNINITIALIZED@ +inlinfo_nested_so_LDFLAGS = -Wl,-rpath,$(top_builddir)/memcheck/tests/freebsd -shared -fPIC + +scalar_CFLAGS = ${AM_CFLAGS} -g diff --git a/memcheck/tests/freebsd/access.c b/memcheck/tests/freebsd/access.c new file mode 100644 index 0000000000..69e5a36da5 --- /dev/null +++ b/memcheck/tests/freebsd/access.c @@ -0,0 +1,43 @@ +/* + * Tests for various access functions + * + * access + * eaccess + * accessat + */ + + +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> + +int main() +{ + if (-1 == access("access.c", R_OK)) + { + perror("access failed:"); + } + + if (-1 == eaccess("access.c", F_OK)) + { + perror("eaccess failed:"); + } + + if (-1 == faccessat(AT_FDCWD, "access.c", R_OK, AT_EACCESS)) + { + perror("accessat failed:"); + } + + // error section + int badint; + char* badstring = strdup("foo"); + free(badstring); + access(badstring, badint); + eaccess(badstring, badint); + faccessat(badint, badstring, badint, badint); + + exit(badint); +} + diff --git a/memcheck/tests/freebsd/access.stderr.exp b/memcheck/tests/freebsd/access.stderr.exp new file mode 100644 index 0000000000..89166dcc31 --- /dev/null +++ b/memcheck/tests/freebsd/access.stderr.exp @@ -0,0 +1,53 @@ +Syscall param access(mode) contains uninitialised byte(s) + at 0x........: access (in /...libc...) + by 0x........: main (access.c:37) + +Syscall param access(pathname) points to unaddressable byte(s) + at 0x........: access (in /...libc...) + by 0x........: main (access.c:37) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (access.c:36) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (access.c:35) + +Syscall param eaccess(mode) contains uninitialised byte(s) + at 0x........: eaccess (in /...libc...) + by 0x........: main (access.c:38) + +Syscall param eaccess(path) points to unaddressable byte(s) + at 0x........: eaccess (in /...libc...) + by 0x........: main (access.c:38) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (access.c:36) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (access.c:35) + +Syscall param faccessat(fd) contains uninitialised byte(s) + at 0x........: faccessat (in /...libc...) + by 0x........: main (access.c:39) + +Syscall param faccessat(flag) contains uninitialised byte(s) + at 0x........: faccessat (in /...libc...) + by 0x........: main (access.c:39) + +Syscall param faccessat(path) points to unaddressable byte(s) + at 0x........: faccessat (in /...libc...) + by 0x........: main (access.c:39) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (access.c:36) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (access.c:35) + +Syscall param exit(status) contains uninitialised byte(s) + ... + by 0x........: main (access.c:41) + diff --git a/memcheck/tests/freebsd/access.vgtest b/memcheck/tests/freebsd/access.vgtest new file mode 100644 index 0000000000..28b90a030f --- /dev/null +++ b/memcheck/tests/freebsd/access.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./access +prog: access +vgopts: -q diff --git a/memcheck/tests/freebsd/capsicum.c b/memcheck/tests/freebsd/capsicum.c new file mode 100644 index 0000000000..c9cba9b588 --- /dev/null +++ b/memcheck/tests/freebsd/capsicum.c @@ -0,0 +1,97 @@ +#include <sys/capsicum.h> +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <err.h> +#include <sys/ioccom.h> +#include <net/bpf.h> + +int main(void) +{ + u_int mode; + if (-1 == cap_getmode(&mode)) { + perror("cap_getmode() failed:"); + exit(1); + } else { + assert(mode == 0U); + } + + // example from man cap_rights_get + cap_rights_t setrights, getrights; + int fd; + + memset(&setrights, 0, sizeof(setrights)); + memset(&getrights, 0, sizeof(getrights)); + + fd = open("capsicum.c", O_RDONLY); + if (fd < 0) + err(1, "open() failed"); + + cap_rights_init(&setrights, CAP_IOCTL, CAP_FSTAT, CAP_READ); + if (cap_rights_limit(fd, &setrights) < 0 && errno != ENOSYS) + err(1, "cap_rights_limit() failed"); + + unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF }; + if (cap_ioctls_limit(fd, cmds, sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) { + err(1, "cap_ioctls_limit() filed"); + } + + uint32_t fcntlrights = CAP_FCNTL_GETFL | CAP_FCNTL_SETFL; + if (cap_fcntls_limit(STDIN_FILENO, fcntlrights) < 0 && errno != ENOSYS) { + err(1, "cap_fcnls_limit() filed"); + } + + if (cap_rights_get(fd, &getrights) < 0 && errno != ENOSYS) + err(1, "cap_rights_get() failed"); + + assert(memcmp(&setrights, &getrights, sizeof(setrights)) == 0); + + unsigned long getcmds[2]; + if (cap_ioctls_get(fd, getcmds, 2) < 0 && errno != ENOSYS) + err(1, "cap_ioctls_get() failed"); + + assert(memcmp(cmds, getcmds, sizeof(cmds)) == 0); + + uint32_t getfcntlrights; + if (cap_fcntls_get(STDIN_FILENO, &getfcntlrights) < 0 && errno != ENOSYS) { + err(1, "cap_fcnls_limit() filed"); + } + + assert(fcntlrights == getfcntlrights); + + //close(fd); + + cap_enter(); + + if (-1 == cap_getmode(&mode)) { + perror("cap_getmode() failed:"); + exit(1); + } else { + assert(mode != 0U); + } + + // error section + + int *px = malloc(sizeof(int)); + int x = px[0]; + + cap_getmode(NULL); + + cap_rights_get(0, NULL); + cap_rights_get(x, &getrights); + cap_rights_t* badrights = malloc(sizeof(cap_rights_t)); + cap_rights_init(badrights, CAP_FSTAT, CAP_READ); + free(badrights); + cap_rights_get(0, badrights); + + cap_rights_limit(x, &setrights); + + cap_rights_limit(fd, badrights); + + int fd2 = open("foo", O_RDWR); + if (fd2 >= 0) + err(1, "open in write mode should have failed"); +} diff --git a/memcheck/tests/freebsd/capsicum.stderr.exp b/memcheck/tests/freebsd/capsicum.stderr.exp new file mode 100644 index 0000000000..3d70dbf821 --- /dev/null +++ b/memcheck/tests/freebsd/capsicum.stderr.exp @@ -0,0 +1,41 @@ +WARNING: Valgrind may not operate correctly in capability mode. + Please consider disabling capability by using the RUNNING_ON_VALGRIND mechanism. + See http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq +Syscall param cap_getmode(modep) points to unaddressable byte(s) + ... + by 0x........: main (capsicum.c:81) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param cap_rights_get(rights) points to unaddressable byte(s) + ... + by 0x........: main (capsicum.c:83) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param cap_rights_get(fd) contains uninitialised byte(s) + ... + by 0x........: main (capsicum.c:84) + +Syscall param cap_rights_get(rights) points to unaddressable byte(s) + ... + by 0x........: main (capsicum.c:88) + Address 0x........ is 0 bytes inside a block of size 16 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (capsicum.c:87) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (capsicum.c:85) + +Syscall param cap_rights_limit(fd) contains uninitialised byte(s) + ... + by 0x........: main (capsicum.c:90) + +Syscall param cap_rights_limit(rights) points to unaddressable byte(s) + ... + by 0x........: main (capsicum.c:92) + Address 0x........ is 0 bytes inside a block of size 16 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (capsicum.c:87) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (capsicum.c:85) + diff --git a/memcheck/tests/freebsd/capsicum.vgtest b/memcheck/tests/freebsd/capsicum.vgtest new file mode 100644 index 0000000000..f6ec3e12e7 --- /dev/null +++ b/memcheck/tests/freebsd/capsicum.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./capsicum +prog: capsicum +vgopts: -q diff --git a/memcheck/tests/freebsd/chflags.c b/memcheck/tests/freebsd/chflags.c new file mode 100644 index 0000000000..b32a44b4f4 --- /dev/null +++ b/memcheck/tests/freebsd/chflags.c @@ -0,0 +1,43 @@ +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include "../../memcheck.h" + + +int main() +{ + const char* filename = strdup("chflags.tst"); + int fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + + fchflags(fd, UF_APPEND); + + // a couple of errors while the file is open + int badfd = fd; + unsigned long badflags = UF_NODUMP; + VALGRIND_MAKE_MEM_UNDEFINED(&badfd, sizeof(int)); + VALGRIND_MAKE_MEM_UNDEFINED(&badflags, sizeof(unsigned long)); + + fchflags(badfd, UF_REPARSE); + fchflags(fd, badflags); + close(fd); + + chflags(filename, UF_SYSTEM); + lchflags(filename, UF_SYSTEM); + chflagsat(AT_FDCWD, filename, UF_SYSTEM, 0); + + chflags(filename, badflags); + lchflags(filename, badflags); + chflagsat(AT_FDCWD, filename, badflags, 0); + + int badatflag; + chflagsat(AT_FDCWD, filename, UF_SYSTEM, badatflag); + + free((void*)filename); + + chflags(filename, UF_SYSTEM); + lchflags(filename, UF_SYSTEM); + chflagsat(AT_FDCWD, filename, UF_SYSTEM, 0); +} + diff --git a/memcheck/tests/freebsd/chflags.stderr.exp b/memcheck/tests/freebsd/chflags.stderr.exp new file mode 100644 index 0000000000..82c11d13b2 --- /dev/null +++ b/memcheck/tests/freebsd/chflags.stderr.exp @@ -0,0 +1,57 @@ +Syscall param fchflags(fd) contains uninitialised byte(s) + at 0x........: fchflags (in /...libc...) + by 0x........: main (chflags.c:22) + +Syscall param fchflags(flags) contains uninitialised byte(s) + at 0x........: fchflags (in /...libc...) + by 0x........: main (chflags.c:23) + +Syscall param chflags(flags) contains uninitialised byte(s) + at 0x........: chflags (in /...libc...) + by 0x........: main (chflags.c:30) + +Syscall param lchflags(flags) contains uninitialised byte(s) + at 0x........: lchflags (in /...libc...) + by 0x........: main (chflags.c:31) + +Syscall param chflagsat(flags) contains uninitialised byte(s) + at 0x........: chflagsat (in /...libc...) + by 0x........: main (chflags.c:32) + +Syscall param chflagsat(atflag) contains uninitialised byte(s) + at 0x........: chflagsat (in /...libc...) + by 0x........: main (chflags.c:35) + +Syscall param chflags(path) points to unaddressable byte(s) + at 0x........: chflags (in /...libc...) + by 0x........: main (chflags.c:39) + Address 0x........ is 0 bytes inside a block of size 12 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:37) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chflags.c:11) + +Syscall param lchflags(path) points to unaddressable byte(s) + at 0x........: lchflags (in /...libc...) + by 0x........: main (chflags.c:40) + Address 0x........ is 0 bytes inside a block of size 12 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:37) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chflags.c:11) + +Syscall param chflagsat(path) points to unaddressable byte(s) + at 0x........: chflagsat (in /...libc...) + by 0x........: main (chflags.c:41) + Address 0x........ is 0 bytes inside a block of size 12 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:37) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chflags.c:11) + diff --git a/memcheck/tests/freebsd/chflags.stderr.exp-x86 b/memcheck/tests/freebsd/chflags.stderr.exp-x86 new file mode 100644 index 0000000000..61e0aae414 --- /dev/null +++ b/memcheck/tests/freebsd/chflags.stderr.exp-x86 @@ -0,0 +1,58 @@ +Invalid read of size 4 + at 0x........: main (chflags.c:23) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:21) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:15) + +Invalid read of size 4 + at 0x........: main (chflags.c:27) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:25) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:16) + +Invalid read of size 4 + at 0x........: main (chflags.c:34) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:25) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:16) + +Invalid read of size 4 + at 0x........: main (chflags.c:35) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:25) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:16) + +Syscall param chflags(path) points to unaddressable byte(s) + at 0x........: chflags (in /...libc...) + by 0x........: main (chflags.c:39) + Address 0x........ is 0 bytes inside a block of size 12 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:37) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chflags.c:9) + +Syscall param chflags(path) points to unaddressable byte(s) + at 0x........: lchflags (in /...libc...) + by 0x........: main (chflags.c:40) + Address 0x........ is 0 bytes inside a block of size 12 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chflags.c:37) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chflags.c:9) + diff --git a/memcheck/tests/freebsd/chflags.vgtest b/memcheck/tests/freebsd/chflags.vgtest new file mode 100644 index 0000000000..f9fa4b4d0e --- /dev/null +++ b/memcheck/tests/freebsd/chflags.vgtest @@ -0,0 +1,4 @@ +prog: chflags +vgopts: -q +cleanup: rm -f chflags.tst + diff --git a/memcheck/tests/freebsd/chmod_chown.c b/memcheck/tests/freebsd/chmod_chown.c new file mode 100644 index 0000000000..1fe40f4145 --- /dev/null +++ b/memcheck/tests/freebsd/chmod_chown.c @@ -0,0 +1,65 @@ +/* + * Test this family of functions + * lchmod chownat lchownat + */ + +#include <unistd.h> +#include <dirent.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> + +int main(void) +{ + char buff[64]; + char tmpfile[] = "/tmp/test_chmod_chown.XXXXXX"; + char tmplink[] = "/tmp/test_chx_link.XXXXXX"; + int tmpfd = mkstemp(tmpfile); + mktemp(tmplink); + + memset(buff, 0, sizeof(buff)); + sprintf(buff, "some data"); + write(tmpfd, buff, strlen(buff)+1); + close (tmpfd); + + DIR* tmpdir = opendir("/tmp"); + if (tmpdir) { + int tmpdirfd = dirfd(tmpdir); + + if (-1 == symlinkat(tmpfile+5, tmpdirfd, tmplink+5)) { + perror("linkat failed"); + } + + if (-1 == lchmod(tmplink, S_IRWXU|S_IRWXG|S_IRWXO)) + { + perror("lchmod failed:"); + } + + if (fchmodat(tmpdirfd, tmpfile+5, S_IRWXU|S_IRWXG|S_IRWXO, 0)) + { + perror("fchmodat failed:"); + } + + // no test for failure as not everyone runnning this will be a member of group 921 + fchownat(tmpdirfd, tmpfile+5, getuid(), 920, 0); + + closedir(tmpdir); + } + + unlink(tmpfile); + unlink(tmplink); + + // error section + char* badstring = strdup("foo"); + free(badstring); + int badint1; + int badint2; + int badint3; + int badint4; + + lchmod(badstring, badint1); + fchmodat(badint1, badstring, badint2, badint3); + fchownat(badint1, badstring, badint2, badint3, badint4); +} + diff --git a/memcheck/tests/freebsd/chmod_chown.stderr.exp b/memcheck/tests/freebsd/chmod_chown.stderr.exp new file mode 100644 index 0000000000..87a76a1252 --- /dev/null +++ b/memcheck/tests/freebsd/chmod_chown.stderr.exp @@ -0,0 +1,65 @@ +Syscall param lchmod(mode) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:61) + +Syscall param lchmod(path) points to unaddressable byte(s) + ... + by 0x........: main (chmod_chown.c:61) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chmod_chown.c:55) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chmod_chown.c:54) + +Syscall param fchmodat(fd) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:62) + +Syscall param fchmodat(mode) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:62) + +Syscall param fchmodat(flag) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:62) + +Syscall param fchmodat(path) points to unaddressable byte(s) + ... + by 0x........: main (chmod_chown.c:62) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chmod_chown.c:55) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chmod_chown.c:54) + +Syscall param fchownat(fd) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:63) + +Syscall param fchownat(owner) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:63) + +Syscall param fchownat(group) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:63) + +Syscall param fchownat(flag) contains uninitialised byte(s) + ... + by 0x........: main (chmod_chown.c:63) + +Syscall param fchownat(path) points to unaddressable byte(s) + ... + by 0x........: main (chmod_chown.c:63) + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (chmod_chown.c:55) + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) + ... + by 0x........: main (chmod_chown.c:54) + diff --git a/memcheck/tests/freebsd/chmod_chown.vgtest b/memcheck/tests/freebsd/chmod_chown.vgtest new file mode 100644 index 0000000000..db60bb886f --- /dev/null +++ b/memcheck/tests/freebsd/chmod_chown.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./chmod_chown +prog: chmod_chown +vgopts: -q diff --git a/memcheck/tests/freebsd/dump_stdout b/memcheck/tests/freebsd/dump_stdout new file mode 100755 index 0000000000..a8b7c3e935 --- /dev/null +++ b/memcheck/... [truncated message content] |
|
From: Paul F. <pa...@so...> - 2021-10-08 20:33:30
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3c53eea626f9151f4ece2b84f3aa161eda3b1bbb commit 3c53eea626f9151f4ece2b84f3aa161eda3b1bbb Author: Paul Floyd <pj...@wa...> Date: Fri Oct 8 22:08:12 2021 +0200 Add copyright statements to added FreeBSD headers Diff: --- include/vki/vki-amd64-freebsd.h | 2 ++ include/vki/vki-freebsd.h | 2 ++ include/vki/vki-machine-types-amd64-freebsd.h | 6 ++++-- include/vki/vki-machine-types-x86-freebsd.h | 6 ++++-- include/vki/vki-scnums-freebsd.h | 2 ++ include/vki/vki-x86-freebsd.h | 5 ++++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/vki/vki-amd64-freebsd.h b/include/vki/vki-amd64-freebsd.h index 55409dbebd..374e7eeb50 100644 --- a/include/vki/vki-amd64-freebsd.h +++ b/include/vki/vki-amd64-freebsd.h @@ -4,6 +4,8 @@ Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h index eaea7d74c2..a9ff6fb9d6 100644 --- a/include/vki/vki-freebsd.h +++ b/include/vki/vki-freebsd.h @@ -9,6 +9,8 @@ Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/vki/vki-machine-types-amd64-freebsd.h b/include/vki/vki-machine-types-amd64-freebsd.h index db408de703..2963f4d86e 100644 --- a/include/vki/vki-machine-types-amd64-freebsd.h +++ b/include/vki/vki-machine-types-amd64-freebsd.h @@ -1,7 +1,7 @@ /*--------------------------------------------------------------------*/ -/*--- x86/FreeBSD-specific kernel interface: posix types. ---*/ -/*--- vki_posixtypes-x86-freebsd.h ---*/ +/*--- x86/FreeBSD-specific kernel interface: posix types. ---*/ +/*--- vki_posixtypes-x86-freebsd.h ---*/ /*--------------------------------------------------------------------*/ /* @@ -10,6 +10,8 @@ Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/vki/vki-machine-types-x86-freebsd.h b/include/vki/vki-machine-types-x86-freebsd.h index 4906be7210..70f0a2b3fb 100644 --- a/include/vki/vki-machine-types-x86-freebsd.h +++ b/include/vki/vki-machine-types-x86-freebsd.h @@ -1,7 +1,7 @@ /*--------------------------------------------------------------------*/ -/*--- x86/FreeBSD-specific kernel interface: posix types. ---*/ -/*--- vki_posixtypes-x86-freebsd.h ---*/ +/*--- x86/FreeBSD-specific kernel interface: posix types. ---*/ +/*--- vki_posixtypes-x86-freebsd.h ---*/ /*--------------------------------------------------------------------*/ /* @@ -10,6 +10,8 @@ Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/vki/vki-scnums-freebsd.h b/include/vki/vki-scnums-freebsd.h index cac88ba8c1..3ea7d460e3 100644 --- a/include/vki/vki-scnums-freebsd.h +++ b/include/vki/vki-scnums-freebsd.h @@ -5,6 +5,8 @@ Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/include/vki/vki-x86-freebsd.h b/include/vki/vki-x86-freebsd.h index 13cc279cfc..638cea6bc5 100644 --- a/include/vki/vki-x86-freebsd.h +++ b/include/vki/vki-x86-freebsd.h @@ -7,9 +7,12 @@ This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2009 Stanislav Sedov <stas@FreeBSD.org> Copyright (C) 2000-2005 Julian Seward js...@ac... + Copyright (C) 2009 Stanislav Sedov + <stas@FreeBSD.org> + Copyright (C) 2018-2021 Paul Floyd + pj...@wa... This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as |
|
From: Paul F. <pa...@so...> - 2021-10-07 21:03:54
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a456fcef6d97ead3548e8c88cfd676d9847712eb commit a456fcef6d97ead3548e8c88cfd676d9847712eb Author: Paul Floyd <pj...@wa...> Date: Thu Oct 7 23:02:29 2021 +0200 FreeBSD support, patch 9 supplemental These files are now derived objects and should have been removed in the previous change. Diff: --- gdbserver_tests/filter_gdb | 252 -------------------------------- gdbserver_tests/filter_memcheck_monitor | 36 ----- gdbserver_tests/filter_stderr | 16 -- gdbserver_tests/filter_vgdb | 34 ----- 4 files changed, 338 deletions(-) diff --git a/gdbserver_tests/filter_gdb b/gdbserver_tests/filter_gdb deleted file mode 100755 index 13de9cc012..0000000000 --- a/gdbserver_tests/filter_gdb +++ /dev/null @@ -1,252 +0,0 @@ -#! /bin/sh - -# filter the output of gdb. - -SED=/usr/bin/sed - -PATTERNFILE=$(mktemp filter_gdb.tmp.XXXXXXXXXX) -cat > $PATTERNFILE <<EOF -# delete the initial lines between the launch of vgdb and the -# output of the echo command telling it is launched. -# This removes a whole lot of uninteresting lines varying -# with OS/glibc/gdb dep -/Remote debugging using/,/vgdb launched process attached/d - -# general way to delete uninteresting and varying lines. -/filter_gdb BEGIN drop/,/filter_gdb END drop/d - -# initial tty control character sent by gdb 7.0 -s/^\[?1034hReading symbols/Reading symbols/ - -# remove message about missing debuginfos -/^Missing separate debuginfo/d - -# remove messages about not being able to download debuginfos -/^Download failed: /d - -# suppress lines telling file _exit.c does not exist -/\/_exit.c: No such file or directory/d - -# On FreeBSD if the base and/or lib32 dbg components -# are installed but not system source then these -# errors get produced by GDB -/\(rtld_start.S\|kill.S\|_exit.S\|_select.S\): No such file or directory/d - -# Remove some Suse package manager messages -/^Try: zypper install -C/d - -# Remove vgdb message -/relaying data between gdb and process/d - -# Anonymise pid numbers -s/pid [0-9][0-9]*/pid ..../g - -# filter 'remote target killed' messages (produced by gdb >= 8.2) -/(Remote target) killed/d - -# Anonymise Thread numbers -s/Thread [0-9][0-9]*/Thread ..../g - -# delete thread switches -/\[Switching to Thread ....\]/d - -# ??? Probably we had a 'Switching ' message in front of -# a frame line ? -s/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/ - -# Anonymise info threads output (e.g. which thread is running and syscall) -s/^\([ \* ] [0-9] Thread .... (tid [0-9] VgTs_WaitSys) 0x........ in\).*$/\1 syscall .../ - -# Newer gdb say Thread .... hit Breakpoint, we expect just Breakpoint. -s/^Thread .... hit Breakpoint /Breakpoint / - -# We expect "Program received" instead of "Thread .... received" -s/^Thread .... received /Program received / - -s/#[0-9]\( 0x........ in sleeper_or_burner\)/#.\1/ - -# Some gdb versions don't show the source line:number after switching -# threads in #0 0x........ in do_burn (). -s/\(#0 0x........ in do_burn ()\) at sleepers.c:41/\1/ - - -# delete Reading symbols file lines -# Note: The 'done.' in "Reading symbols from <exe>...done." -# is optional (bugzilla 406357). -/^Reading symbols from .*\.\.\.\(done\.\)\?/d - -# delete Loaded symbols file lines -/^Loaded symbols for .*$/d - -# delete language switch messages. -/^Current language.*/d -/^The current source language is.*/d - -# 'exited with code' and 'exited normally' are printed slightly -# differently between gdb versions, normalize to "Program exited...". -s/^.*\( exited with code [0-9]\+\).$/Program\1\./g -s/^.*\( exited normally\).$/Program\1\./g - -# remove gdb prompts. -s/(gdb) //g - -# remove gdb continuation prompts. -s/^>[> ]*// - -# remove gdb done prompts. -/^done\.$/d - -# anonymise a 'general' system calls stack trace part -s/in _dl_sysinfo_int80 () from \/lib\/ld-linux.so.*/in syscall .../ - -# anonymise kill syscall. -s/in kill ().*$/in syscall .../ - -# anonymise syscall on ppc64 (bugzilla #284305) -s/in .*kill ().*$/in syscall .../ - - -s/in _dl_sysinfo_int80 ()/in syscall .../ -/^ from \/lib\/ld-linux.so.*$/d -s/\(0x........\) in ?? () from \/lib.*$/\1 in syscall .../ -s/\(0x........\) in ?? ()$/\1 in syscall .../ - -# 4 expressions to cover glibc 2.27 way to do a select, such as -# * 1 Thread 5548 (tid 1 VgTs_WaitSys) 0x0000000004f6203f in __GI___select ( -# nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x30a0e0 <t>) -# at ../sysdeps/unix/sysv/linux/select.c:41 -# If select.c sources are present, we can also get a line containing: -# return SYSCALL_CANCEL.... -s/in __select .*/in syscall .../ -s/in __select$/in syscall .../ -/nfds=/d -/exceptfds=/d -/timeout=/d -/sysv\/linux\/select\.c/d -/sysv\/linux\/generic\/select.c/d -/return SYSCALL_CANCEL /d - -# a more specialised system call select stack trace part -# (on 32 bits, we have an int_80, on 64 bits, directly select) -s/in \(.__\)\{0,1\}select () from \/.*$/in syscall .../ - -/^ from \/lib\/libc.so.*$/d -/^ from \/lib64\/libc.so.*$/d -/^ from \/lib64\/.*\/libc.so.*$/d - -# and yet another (gdb 7.0 way) to get a system call -s/in select ()$/in syscall .../ - -# and yet another (gdb 7.0 arm way) to get a system call -s/in \.__select ()$/in syscall .../ - -# + yet another way to get a select system call -s/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../ - -# FreeBSD system call -s/_select () at _select.S:.*$/0x........ in syscall .../ - -# FreeBSD system call again -/in _select.S/d - -# FreeBSD system call -s/kill () at kill.S:.*$/0x........ in syscall .../ - -# filter out names which starts with a "." -# such names are used for "function descriptors" on ppc64 -# bugzilla 406561 -s/in \.__select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../ - -# cleanup some lines for a system call (on ubuntu 10 64 bits) -# (pay attention : there are tab characters there in) -/^[ ]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d -/^[ ]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d - -/^[1-9][0-9]*[ ]*\.\.\/sysdeps\/unix\/syscall-template\.S/d -/^[1-9][0-9]*[ ]in *\.\.\/sysdeps\/unix\/syscall-template\.S/d -/^[1-9][0-9]*[ ]T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)/d - -# and yet another (Solaris way) to get a poll system call -# (on 32 bits, we have /lib/libc.so.*, on 64 bits, /lib/64/libc.so.*) -s/in __pollsys () from \/.*$/in syscall .../ -/^ from \/lib\/64\/libc.so.*$/d - -# which registers can't be modified -s/\(Could not write register \)".*"/\1 "xxx"/ -s/\(ERROR changing register \).*$/\1 xxx regno y/ - -# special transform for arm/ppc watchpoints which have an additional address -# at the beginning -s/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/ - -s/0x........ in \(main () at clean_after_fork.c:34\)/\1/ - -# SIGFPE backtrace is varying so much that we just remove all lines -# after the signal trapping using an expr in this sed, followed by another sed. -s/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/ - -# gdb might also try to show the "entry value" p=p@entry=0x... -s/p=p@entry=0x/p=0x/ - -# for hgtls the breakpoint p=... address might show var location. -s/\(^Breakpoint 1, tls_ptr (p=0x........\) <tests[0-9+]*>\() at tls.c:55\)/\1\2/ - -/Id Target Id *Frame/d -s/^\([ \*] [1234] \) *Thread /\1Thread / - -# Ordering of ' Thread .... (tid .' might differ between gdb version, -# so remove all such lines except the "current" one (starts with '*'). -s/^ [0-9] Thread .... (tid [0-9] .*$// - -# transform info thread of 7.3 into the layout of 7.2 and before. -s/VgTs_WaitSys) 0x/VgTs_WaitSys) 0x/ - -# delete lines telling that some memory can't be accessed: this is -# a.o. produced by gdb 7.2 on arm (same with standard gdbserver) -/Cannot access memory at address 0x......../d - -# Filter 'New thread' lines -# gdb 7.9 reports new threads at different moment than the previous versions. -# Filter these new threads lines so as to not be dependent on this -# gdb aspect. -/\[New Thread/d - -# 406355 -# adjust filtering for the new gdb output -# mcsigpass and mcsignopass tests fails due to the slightly different -# gdb output. Filter the tests output to make it the same for different -# gdb version. Change mcsigpass and mcsignopass .exp to fit filtered -# .out. -s/^0x........ in \(\w\+ (\)/\1/ - -# delete empty lines (the last line (only made of prompts) sometimes -# finishes with a new line, sometimes not ???). -/^$/d - - -EOF - -dir=`dirname $0` - -$dir/filter_stderr | - -# Anonymise addresses -$dir/../tests/filter_addresses | - -# memcheck stuff -$dir/filter_memcheck_monitor "$@" | - -# memcheck filter might leave some "..." lines, we are not interested -$SED -e '/^\ \ \ \ \.\.\.$/d' | - -# Anonymise or remove, using the big list of PATTERN prepared above -$SED -f $PATTERNFILE | - -# remove all the lines telling where the SIGFPE was trapped. -$SED -e '/after trap SIGFPE/,/after continue SIGFPE/d' | - -# join together two lines that gdb 7.1 splits in two (???) -# (in a separate sed, as the below influences the behaviour of the other expressions) -$SED -e :a -e '$!N;s/\n at sleepers.c:39/ at sleepers.c:39/;ta' -e 'P;D' - -rm $PATTERNFILE diff --git a/gdbserver_tests/filter_memcheck_monitor b/gdbserver_tests/filter_memcheck_monitor deleted file mode 100755 index ec7fc6a343..0000000000 --- a/gdbserver_tests/filter_memcheck_monitor +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/sh - -# used to filter memcheck output shown by gdb/vgdb. - -dir=`dirname $0` - -SED=/usr/bin/sed - -$dir/../memcheck/tests/filter_stderr "$@" | - -# filter vgdb messages -$dir/filter_vgdb | - - -# filter some normal error messages provided by some gdb -# -# gdb 7.2 sometimes tries to access address 0x0 (same as with standard gdbserver) -# -# filter a debian 6.0/ppc32 line -# -# filter some missing info msg from s390 -# -# Bypass a s390x kernel bug which makes faultstatus test3 fail. In our case, we are -# not interested in checking the si_code, but rather the signal passing -# in mcsig(no)pass -# -# When doing inferior function calls from gdb (in mcmain_pic) there might be -# extra heap usage from gdb that we aren't interested in tracking. -# -$SED -e '/Cannot access memory at address 0x......../d' \ - -e '/^[1-9][0-9]* \.\.\/sysdeps\/powerpc\/powerpc32\/dl-start\.S: No such file or directory\./d' \ - -e '/^Missing separate debuginfo/d' \ - -e '/^Try: zypper install -C/d' \ - -e 's/Test 3: FAIL: expected si_code==2, not 128/Test 3: PASS/' \ - -e 's/in use at exit: [0-9][0-9,]* bytes in [0-9][0-9]* blocks/in use at exit: ... bytes in ... blocks/' \ - -e '/^ total heap usage: /d' diff --git a/gdbserver_tests/filter_stderr b/gdbserver_tests/filter_stderr deleted file mode 100755 index 332e0502f1..0000000000 --- a/gdbserver_tests/filter_stderr +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - -dir=`dirname $0` - -SED=/usr/bin/sed - -$dir/../tests/filter_stderr_basic | -perl -0777 -p -e 's/error 4 Interrupted system call\nVG_\(poll\) failed \(old kernel \?\) retrying .*\n//g' | -$SED -e '/^Copyright (C) /d' \ - \ - -e '/TO DEBUG THIS PROCESS USING GDB/d' \ - -e '/\/path\/to\/gdb/d' \ - -e '/and then give GDB the following command/d' \ - -e '/target remote |/d' \ - -e '/pid is optional if only one valgrind process is running/d' \ - -e '/warning: remote target does not support file transfer, attempting to access files from local filesystem./d' diff --git a/gdbserver_tests/filter_vgdb b/gdbserver_tests/filter_vgdb deleted file mode 100755 index fe24f9eb05..0000000000 --- a/gdbserver_tests/filter_vgdb +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/sh - -dir=`dirname $0` - -SED=/usr/bin/sed - -$dir/filter_stderr | - -# Anonymise addresses -$dir/../tests/filter_addresses | - - -# On FreeBSD if the base and/or lib32 dbg components -# are installed but not system source then these -# errors get produced by GDB -$SED -e '/\(rtld_start.S\|kill.S\|_exit.S\|_select.S\): No such file or directory/d' | - -# filter vgdb process id, -# pid -# gdb 7.2 sometimes tries to access address 0x0 (same as with standard gdbserver) -# filter a debian 6.0/ppc32 line -$SED -e '/relaying data between gdb and process/d' \ - -e 's/\(sending command .* to pid \)[0-9][0-9]*/\1..../' \ - -e '/Cannot access memory at address 0x......../d' \ - -e '/^[1-9][0-9]* \.\.\/sysdeps\/powerpc\/powerpc32\/dl-start\.S: No such file or directory\./d' | - -# filter some debuginfo problems with ld.so and SLES11 -$SED -e '/^1 rtld.c: No such file or directory\./d' | -$SED -e '/rtld.c: Inappropriate ioctl for device\./d' | -# similar for Debian 11.0 arm64 -$SED -e '/_exit.c: Inappropriate ioctl for device\./d' | - -# and filter out any remaining empty lines -$SED -e '/^$/d' |
|
From: Paul F. <pa...@so...> - 2021-10-07 19:56:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3d25fd4a6c188f6183e69693920f81e3bc4e474f commit 3d25fd4a6c188f6183e69693920f81e3bc4e474f Author: Paul Floyd <pj...@wa...> Date: Tue Oct 5 09:12:45 2021 +0200 FreeBSD support, patch 8b nightly directory Diff: --- nightly/bin/nightly | 22 ++++++++++++++++++---- nightly/conf/freebsd12.1.conf | 4 ++++ nightly/conf/freebsd12.1.sendmail | 8 ++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/nightly/bin/nightly b/nightly/bin/nightly index 92fa076286..370a181114 100755 --- a/nightly/bin/nightly +++ b/nightly/bin/nightly @@ -42,6 +42,14 @@ runcmd () { # Startup #---------------------------------------------------------------------------- +if [ `uname -o` = "FreeBSD" ]; then + CP=gcp + MAKE=gmake +else + CP=cp + MAKE=make +fi + valgrind_git_repo="git://sourceware.org/git/valgrind.git/" # Must have exactly two arguments @@ -72,7 +80,7 @@ if [ "${ABT_EVAL}" = "" ]; then ABT_EVAL="eval" fi if [ "${ABT_RUN_REGTEST}" = "" ]; then - ABT_RUN_REGTEST="make regtest" + ABT_RUN_REGTEST="${MAKE} regtest" fi if [ "${ABT_PERF_TOOLS}" = "" ]; then @@ -118,7 +126,7 @@ for logfile in old new ; do # Check out, build, run tests runcmd $logfile \ "Checking out Valgrind source tree" \ - "cp -r --preserve=links valgrind-repo valgrind-$logfile && cd valgrind-$logfile && git checkout ${git_commit}" && \ + "${CP} -r --preserve=links valgrind-repo valgrind-$logfile && cd valgrind-$logfile && git checkout ${git_commit}" && \ \ runcmd $logfile \ "Configuring valgrind " \ @@ -126,7 +134,7 @@ for logfile in old new ; do \ runcmd $logfile \ "Building valgrind " \ - "cd valgrind-$logfile && make -j ${ABT_JOBS} && make -j ${ABT_JOBS} check && make install" && \ + "cd valgrind-$logfile && ${MAKE} -j ${ABT_JOBS} && ${MAKE} -j ${ABT_JOBS} check && ${MAKE} install" && \ \ runcmd $logfile \ "Running regression tests " \ @@ -177,11 +185,17 @@ END=`date "+%F %H:%M:%S %Z"` # Gather some information about this run and its environment valgrind_revision=$( ./valgrind-new/vg-in-place -v --version ) -gcc_version="`gcc --version 2> /dev/null | head -1`" +if [ `uname -o` = "FreeBSD" ]; then + gcc_version="`clang --version 2> /dev/null | head -1`" +else + gcc_version="`gcc --version 2> /dev/null | head -1`" +fi gdb_version="`gdb --version 2> /dev/null | head -1`" as_version="`as --version 2> /dev/null | head -1`" if [ `uname -o` = "Solaris" ]; then libc="Solaris libc" +elif [ `uname -o` = "FreeBSD" ]; then + libc="FreeBSD libc" else libc_so="`ls -1 /lib/libc.so.* /lib64/libc.so.* /lib32/libc.so.* /lib/*-linux-gnu/libc.so.* 2>/dev/null | tail -1`" libc="unknown" diff --git a/nightly/conf/freebsd12.1.conf b/nightly/conf/freebsd12.1.conf new file mode 100644 index 0000000000..c76383ed5c --- /dev/null +++ b/nightly/conf/freebsd12.1.conf @@ -0,0 +1,4 @@ +export ABT_DETAILS=`uname -mrs` +export ABT_JOBS=2 +#export ABT_PERF="--tools=none,memcheck,callgrind,helgrind,cachegrind,drd,massif --reps=3 --vg=../valgrind-old --vg=../valgrind-new" +export ABT_CONFIGURE_OPTIONS="CC=clang CXX=clang++" diff --git a/nightly/conf/freebsd12.1.sendmail b/nightly/conf/freebsd12.1.sendmail new file mode 100755 index 0000000000..6fc10f9deb --- /dev/null +++ b/nightly/conf/freebsd12.1.sendmail @@ -0,0 +1,8 @@ +#!/bin/sh + +subject=$1 +body=$2 +file=$3 +filename=$( basename $3 ) + +(cat "$body" "$file") | mail -s "$subject" val...@li... -f "Paul Floyd <pj...@wa...>" |
|
From: Paul F. <pa...@so...> - 2021-10-07 19:34:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=85bbe2853e813bbd83aa17bc17c2b73d82f6bc3e commit 85bbe2853e813bbd83aa17bc17c2b73d82f6bc3e Author: Paul Floyd <pj...@wa...> Date: Thu Oct 7 21:33:45 2021 +0200 FreeBSD support, patch 5 drd and helgrind tests Diff: --- .gitignore | 7 + configure.ac | 14 + drd/tests/Makefile.am | 23 +- drd/tests/annotate_smart_pointer.cpp | 3 + drd/tests/bar_bad.stderr.exp-freebsd | 45 ++++ drd/tests/bar_bad_xml.stderr.exp-freebsd | 286 +++++++++++++++++++++ drd/tests/circular_buffer.c | 22 +- drd/tests/concurrent_close.cpp | 3 + drd/tests/concurrent_close.vgtest | 2 +- .../{filter_error_count => filter_error_count.in} | 4 +- ...ilter_error_summary => filter_error_summary.in} | 4 +- drd/tests/{filter_stderr => filter_stderr.in} | 8 +- drd/tests/filter_stderr_and_thread_no_and_offset | 4 - .../filter_stderr_and_thread_no_and_offset.in | 6 + .../{filter_thread_no => filter_thread_no.in} | 4 +- ...l_and_thread_no => filter_xml_and_thread_no.in} | 4 +- drd/tests/pth_create_chain.c | 5 + drd/tests/pth_detached3.c | 8 + drd/tests/pth_detached3.stderr.exp-freebsd | 14 + drd/tests/pth_detached3.stderr.exp2 | 4 +- drd/tests/pth_uninitialized_cond.vgtest | 1 + drd/tests/recursive_mutex.stderr.exp-freebsd | 18 ++ drd/tests/std_list.cpp | 27 +- drd/tests/std_string.cpp | 3 + drd/tests/std_thread2.supp | 26 ++ drd/tests/tc09_bad_unlock.stderr.exp-freebsd | 49 ++++ drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang | 49 ++++ drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 | 46 ++-- drd/tests/tc22_exit_w_lock.vgtest | 1 + drd/tests/tc23_bogus_condwait.stderr.exp-freebsd | 40 +++ drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 | 44 ++-- drd/tests/thread_name.vgtest | 2 +- drd/tests/thread_name_freebsd.c | 63 +++++ drd/tests/thread_name_freebsd.stderr.exp | 93 +++++++ drd/tests/thread_name_freebsd.vgtest | 3 + drd/tests/thread_name_xml.vgtest | 2 +- helgrind/tests/Makefile.am | 13 +- helgrind/tests/bar_bad.c | 3 + helgrind/tests/bar_bad.stderr.exp-destroy-hang | 18 +- helgrind/tests/bar_bad.stderr.exp-freebsd | 58 +++++ helgrind/tests/filter_freebsd.awk | 148 +++++++++++ helgrind/tests/{filter_stderr => filter_stderr.in} | 20 +- helgrind/tests/filter_stderr_freebsd | 60 +++++ .../tests/locked_vs_unlocked2.stderr.exp-freebsd | 44 ++++ .../tests/locked_vs_unlocked3.stderr.exp-freebsd | 34 +++ .../tests/pth_cond_destroy_busy.stderr.exp-freebsd | 24 ++ .../tests/tc06_two_races_xml.stderr.exp-freebsd | 251 ++++++++++++++++++ helgrind/tests/tc07_hbl1.c | 9 +- helgrind/tests/tc08_hbl2.c | 9 +- helgrind/tests/tc09_bad_unlock.c | 3 + helgrind/tests/tc09_bad_unlock.stderr.exp | 72 +++--- helgrind/tests/tc09_bad_unlock.stderr.exp-freebsd | 150 +++++++++++ helgrind/tests/tc09_bad_unlock.stderr.exp-solaris | 72 +++--- helgrind/tests/tc11_XCHG.c | 9 +- helgrind/tests/tc12_rwl_trivial.c | 2 +- helgrind/tests/tc12_rwl_trivial.stderr.exp-freebsd | 31 +++ helgrind/tests/tc17_sembar.c | 5 +- helgrind/tests/tc18_semabuse.stderr.exp-freebsd | 40 +++ helgrind/tests/tc20_verifywrap.c | 2 +- helgrind/tests/tc20_verifywrap.vgtest | 2 +- helgrind/tests/tc22_exit_w_lock.vgtest | 1 + helgrind/tests/tc23_bogus_condwait.c | 9 +- helgrind/tests/tc23_bogus_condwait.stderr.exp | 14 +- .../tests/tc23_bogus_condwait.stderr.exp-freebsd | 100 +++++++ helgrind/tests/tc24_nonzero_sem.c | 5 +- tests/check_makefile_consistency | 2 +- tests/os_test.c | 4 + 67 files changed, 1975 insertions(+), 176 deletions(-) diff --git a/.gitignore b/.gitignore index 86962b4780..ac16d3638a 100644 --- a/.gitignore +++ b/.gitignore @@ -354,6 +354,12 @@ /drd/tests/*.stderr.out /drd/tests/*.stdout.diff* /drd/tests/*.stdout.out +/drd/tests/filter_error_count +/drd/tests/filter_error_summary +/drd/tests/filter_stderr +/drd/tests/filter_stderr_and_thread_no_and_offset +/drd/tests/filter_thread_no +/drd/tests/filter_xml_and_thread_no /drd/tests/.deps /drd/tests/annotate_barrier /drd/tests/annotate_hb_err @@ -629,6 +635,7 @@ /helgrind/tests/*.stderr.out /helgrind/tests/*.stdout.diff* /helgrind/tests/*.stdout.out +/helgrind/tests/filter_stderr /helgrind/tests/.deps /helgrind/tests/annotate_hbefore /helgrind/tests/annotate_rwlock diff --git a/configure.ac b/configure.ac index c05994516f..7e6773606d 100755 --- a/configure.ac +++ b/configure.ac @@ -5215,6 +5215,20 @@ AC_CONFIG_FILES([tests/filter_stderr_basic], [chmod +x tests/filter_stderr_basic]) AC_CONFIG_FILES([tests/filter_discards], [chmod +x tests/filter_discards]) +AC_CONFIG_FILES([drd/tests/filter_stderr], + [chmod +x drd/tests/filter_stderr]) +AC_CONFIG_FILES([drd/tests/filter_error_count], + [chmod +x drd/tests/filter_error_count]) +AC_CONFIG_FILES([drd/tests/filter_error_summary], + [chmod +x drd/tests/filter_error_summary]) +AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset], + [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset]) +AC_CONFIG_FILES([drd/tests/filter_thread_no], + [chmod +x drd/tests/filter_thread_no]) +AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no], + [chmod +x drd/tests/filter_xml_and_thread_no]) +AC_CONFIG_FILES([helgrind/tests/filter_stderr], + [chmod +x helgrind/tests/filter_stderr]) AC_OUTPUT cat<<EOF diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am old mode 100644 new mode 100755 index 07650ef88a..4cb2f7f84a --- a/drd/tests/Makefile.am +++ b/drd/tests/Makefile.am @@ -87,10 +87,12 @@ EXTRA_DIST = \ bar_bad.stderr.exp \ bar_bad.stderr.exp-nohang \ bar_bad.stderr.exp-solaris \ + bar_bad.stderr.exp-freebsd \ bar_bad.vgtest \ bar_bad_xml.stderr.exp \ bar_bad_xml.stderr.exp-nohang \ bar_bad_xml.stderr.exp-solaris \ + bar_bad_xml.stderr.exp-freebsd \ bar_bad_xml.vgtest \ bar_trivial.stderr.exp \ bar_trivial.stdout.exp \ @@ -213,6 +215,7 @@ EXTRA_DIST = \ pth_detached2.vgtest \ pth_detached3.stderr.exp1 \ pth_detached3.stderr.exp2 \ + pth_detached3.stderr.exp-freebsd \ pth_detached3.vgtest \ pth_detached_sem.stderr.exp \ pth_detached_sem.stdout.exp \ @@ -235,6 +238,7 @@ EXTRA_DIST = \ recursive_mutex.stderr.exp-linux \ recursive_mutex.stderr.exp-darwin \ recursive_mutex.stderr.exp-solaris \ + recursive_mutex.stderr.exp-freebsd \ recursive_mutex.vgtest \ rwlock_race.stderr.exp \ rwlock_race.stderr.exp2 \ @@ -313,6 +317,8 @@ EXTRA_DIST = \ tc09_bad_unlock.stderr.exp-glibc2.8 \ tc09_bad_unlock.stderr.exp-s390 \ tc09_bad_unlock.stderr.exp-solaris \ + tc09_bad_unlock.stderr.exp-freebsd \ + tc09_bad_unlock.stderr.exp-freebsd-clang \ tc09_bad_unlock.vgtest \ tc10_rec_lock.stderr.exp \ tc10_rec_lock.vgtest \ @@ -345,6 +351,7 @@ EXTRA_DIST = \ tc23_bogus_condwait.stderr.exp-linux-ppc \ tc23_bogus_condwait.stderr.exp-darwin-x86 \ tc23_bogus_condwait.stderr.exp-darwin-amd64 \ + tc23_bogus_condwait.stderr.exp-freebsd \ tc23_bogus_condwait.vgtest \ tc24_nonzero_sem.stderr.exp \ tc24_nonzero_sem.vgtest \ @@ -352,6 +359,8 @@ EXTRA_DIST = \ thread_name.vgtest \ thread_name_xml.stderr.exp \ thread_name_xml.vgtest \ + thread_name_freebsd.stderr.exp \ + thread_name_freebsd.vgtest \ threaded-fork.stderr.exp \ threaded-fork.vgtest \ threaded-fork-vcs.stderr.exp \ @@ -410,7 +419,11 @@ check_PROGRAMS = \ threaded-fork \ trylock \ unit_bitmap \ - unit_vc + unit_vc \ + std_atomic \ + std_list \ + std_mutex \ + std_string if HAVE_BOOST_1_35 check_PROGRAMS += boost_thread @@ -440,10 +453,6 @@ endif if CXX_CAN_INCLUDE_THREAD_HEADER if HAVE_SHARED_POINTER_ANNOTATION check_PROGRAMS += \ - std_atomic \ - std_list \ - std_mutex \ - std_string \ std_thread \ std_thread2 endif @@ -480,6 +489,10 @@ if !VGCONF_OS_IS_DARWIN check_PROGRAMS += sem_wait endif +if VGCONF_OS_IS_FREEBSD +check_PROGRAMS += thread_name_freebsd +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ @FLAG_FALIGNED_NEW@ \ diff --git a/drd/tests/annotate_smart_pointer.cpp b/drd/tests/annotate_smart_pointer.cpp index ccefc47350..a6c1a9d524 100644 --- a/drd/tests/annotate_smart_pointer.cpp +++ b/drd/tests/annotate_smart_pointer.cpp @@ -37,6 +37,7 @@ #include <pthread.h> // pthread_mutex_t #endif #include "unified_annotations.h" +#include "config.h" static bool s_enable_annotations; @@ -142,7 +143,9 @@ public: { pthread_attr_t attr; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 4096); +#endif pthread_create(&m_tid, &attr, pf, arg); pthread_attr_destroy(&attr); } diff --git a/drd/tests/bar_bad.stderr.exp-freebsd b/drd/tests/bar_bad.stderr.exp-freebsd new file mode 100644 index 0000000000..00276e462d --- /dev/null +++ b/drd/tests/bar_bad.stderr.exp-freebsd @@ -0,0 +1,45 @@ + + +initialise a barrier with zero count +pthread_barrier_init: 'count' argument is zero: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +initialise a barrier twice +Barrier reinitialization: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +initialise a barrier which has threads waiting on it +Barrier reinitialization: barrier 0x........ + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +destroy a barrier that has waiting threads +Destruction of a barrier with active waiters: barrier 0x........ + at 0x........: pthread_barrier_destroy (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +destroy a barrier that was never initialised +Destruction of barrier that is being waited upon: barrier 0x........ + at 0x........: free (vg_replace_malloc.c:...) + by 0x........: main (bar_bad.c:?) +barrier 0x........ was first observed at: + at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?) + by 0x........: main (bar_bad.c:?) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/bar_bad_xml.stderr.exp-freebsd b/drd/tests/bar_bad_xml.stderr.exp-freebsd new file mode 100644 index 0000000000..24ac7fe952 --- /dev/null +++ b/drd/tests/bar_bad_xml.stderr.exp-freebsd @@ -0,0 +1,286 @@ +<?xml version="1.0"?> + +<valgrindoutput> + +<protocolversion>4</protocolversion> +<protocoltool>drd</protocoltool> + +<preamble> + <line>...</line> + <line>...</line> + <line>...</line> + <line>...</line> +</preamble> + +<pid>...</pid> +<ppid>...</ppid> +<tool>drd</tool> + +<args> + <vargv>...</vargv> + <argv> + <exe>./../../helgrind/tests/bar_bad</exe> + </argv> +</args> + +<status> + <state>RUNNING</state> + <time>...</time> +</status> + + +initialise a barrier with zero count +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>pthread_barrier_init: 'count' argument is zero: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> +</error> + + +initialise a barrier twice +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Barrier reinitialization: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +initialise a barrier which has threads waiting on it +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Barrier reinitialization: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +destroy a barrier that has waiting threads +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Destruction of a barrier with active waiters: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_destroy</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +destroy a barrier that was never initialised +<error> + <unique>0x........</unique> + <tid>...</tid> + <kind>BarrierErr</kind> + <what>Destruction of barrier that is being waited upon: barrier 0x........</what> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>free</fn> + <dir>...</dir> + <file>vg_replace_malloc.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + <first_observed_at> + <what>barrier</what> + <address>0x........</address> + <stack> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>pthread_barrier_init</fn> + <dir>...</dir> + <file>drd_pthread_intercepts.c</file> + <line>...</line> + </frame> + <frame> + <ip>0x........</ip> + <obj>...</obj> + <fn>main</fn> + <dir>...</dir> + <file>bar_bad.c</file> + <line>...</line> + </frame> + </stack> + </first_observed_at> +</error> + + +<status> + <state>FINISHED</state> + <time>...</time> +</status> + +<errorcounts> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> + <pair> + <count>...</count> + <unique>0x........</unique> + </pair> +</errorcounts> + +<suppcounts>...</suppcounts> + +</valgrindoutput> + diff --git a/drd/tests/circular_buffer.c b/drd/tests/circular_buffer.c index 0b750467b7..d84ac01273 100644 --- a/drd/tests/circular_buffer.c +++ b/drd/tests/circular_buffer.c @@ -48,6 +48,12 @@ typedef struct { data_t buffer[BUFFER_MAX]; } buffer_t; +typedef struct id_and_wait_s +{ + int id; + int wait_time; +} id_and_wait_t; + static int quiet = 0; static int use_locking = 1; @@ -158,7 +164,8 @@ static buffer_t b; static void *producer(void* arg) { - int* id = arg; + id_and_wait_t* ctx = arg; + int* id = &ctx->id; buffer_send(&b, id); return NULL; @@ -168,14 +175,16 @@ static void *producer(void* arg) static void *consumer(void* arg) { - int* id = arg; + id_and_wait_t* ctx = arg; + int id = ctx->id; + int wait_time = ctx->wait_time; int d; - usleep(rand() % MAXSLEEP); + usleep(wait_time); buffer_recv(&b, &d); if (! quiet) { - printf("%i: %i\n", *id, d); + printf("%i: %i\n", id, d); fflush(stdout); } return NULL; @@ -187,7 +196,7 @@ int main(int argc, char** argv) { pthread_t producers[THREADS]; pthread_t consumers[THREADS]; - int thread_arg[THREADS]; + id_and_wait_t thread_arg[THREADS]; int i; int optchar; @@ -210,7 +219,8 @@ int main(int argc, char** argv) for (i = 0; i < THREADS; ++i) { - thread_arg[i] = i; + thread_arg[i].id = i; + thread_arg[i].wait_time = rand() % MAXSLEEP; pthread_create(producers + i, NULL, producer, &thread_arg[i]); } diff --git a/drd/tests/concurrent_close.cpp b/drd/tests/concurrent_close.cpp index 9f7e6d622f..e098dd37a5 100644 --- a/drd/tests/concurrent_close.cpp +++ b/drd/tests/concurrent_close.cpp @@ -8,6 +8,7 @@ #include <fcntl.h> /* O_RDONLY */ #include <pthread.h> #include <unistd.h> /* close() */ +#include "config.h" /* Happens with two threads also */ #define THREAD_COUNT 256 @@ -32,7 +33,9 @@ int main() pthread_t threads[THREAD_COUNT]; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif for (i = 0; i < THREAD_COUNT; ++i) { r = pthread_create(&threads[i], &attr, thread, 0); if (r != 0) { diff --git a/drd/tests/concurrent_close.vgtest b/drd/tests/concurrent_close.vgtest index 19c339b647..cc7834d877 100644 --- a/drd/tests/concurrent_close.vgtest +++ b/drd/tests/concurrent_close.vgtest @@ -1,4 +1,4 @@ prereq: ./supported_libpthread -vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no --num-callers=3 +vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no --num-callers=6 prog: concurrent_close stderr_filter: filter_stderr diff --git a/drd/tests/filter_error_count b/drd/tests/filter_error_count.in similarity index 92% rename from drd/tests/filter_error_count rename to drd/tests/filter_error_count.in index 89dc2b40c7..782284d1c7 100755 --- a/drd/tests/filter_error_count +++ b/drd/tests/filter_error_count.in @@ -1,9 +1,11 @@ #!/bin/sh +SED=@SED@ + # Filter the error output of Valgrind such that only the line with the error # summary is kept. Bart Van Assche, February 26, 2008. -sed -n \ +$SED -n \ -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' \ -e 's/^\(ERROR SUMMARY: [0-9]* errors\).*$/\1/' \ -e '/ERROR SUMMARY/p' diff --git a/drd/tests/filter_error_summary b/drd/tests/filter_error_summary.in similarity index 62% rename from drd/tests/filter_error_summary rename to drd/tests/filter_error_summary.in index cdf703f2fd..76d7a6dade 100755 --- a/drd/tests/filter_error_summary +++ b/drd/tests/filter_error_summary.in @@ -1,6 +1,8 @@ #!/bin/sh +SED=@SED@ + # Filter the error output of Valgrind such that only the line with the error # summary is kept. Bart Van Assche, February 26, 2008. -sed -n -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' -e '/ERROR SUMMARY/p' +$SED -n -e 's/^.*\(ERROR SUMMARY.*\) ([^()]*)$/\1/' -e '/ERROR SUMMARY/p' diff --git a/drd/tests/filter_stderr b/drd/tests/filter_stderr.in similarity index 94% rename from drd/tests/filter_stderr rename to drd/tests/filter_stderr.in index f5c56a3541..aec1d60f5d 100755 --- a/drd/tests/filter_stderr +++ b/drd/tests/filter_stderr.in @@ -2,7 +2,9 @@ dir=`dirname $0` -sed -e "s:_pthread_start (in /usr/lib/libSystem.B.dylib):(within libpthread-?.?.so):" | +SED=@SED@ + +$SED -e "s:_pthread_start (in /usr/lib/libSystem.B.dylib):(within libpthread-?.?.so):" | $dir/../../tests/filter_stderr_basic | @@ -17,7 +19,7 @@ fi | # Remove line numbers referring to drd's source code. # Remove libpthread's version number. # Remove line numbers from stack traces. -sed \ +$SED \ -e "/^drd, a thread error detector$/d" \ -e "s/^Allocation context: stack of thread \([0-9]*\), offset -[0-9]*$/Allocation context: stack of thread \1, offset .../" \ -e "/^warning: evaluate_Dwarf3_Expr: unhandled DW_OP_.*/d" \ @@ -30,8 +32,10 @@ sed \ -e "/^Copyright (C) 2006-20.., and GNU GPL'd, by Bart Van Assche.$/d" \ -e "s/\([A-Za-z_]*\) (clone.S:[0-9]*)/\1 (in \/...libc...)/" \ -e "s/\([A-Za-z_]*\) (swapcontext.S:[0-9]*)/\1 (in \/...libc...)/" \ +-e "s/_swapcontext/swapcontext/" \ -e "s/[A-Za-z_]* (pthread_create.c:[0-9]*)/(within libpthread-?.?.so)/" \ -e "s/[A-Za-z_]* (in [^ ]*libpthread-[0-9.]*\.so)/(within libpthread-?.?.so)/" \ +-e "s/... (in \/lib\/libthr.so.3)/(within libpthread-?.?.so)/" \ -e "s:(within /lib[0-9]*/ld-[0-9.]*\.so):(within ld-?.?.so):" \ -e "s/was held during [0-9][0-9]*/was held during .../" \ -e "s: BSS section of [^<]*/: BSS section of :g" \ diff --git a/drd/tests/filter_stderr_and_thread_no_and_offset b/drd/tests/filter_stderr_and_thread_no_and_offset deleted file mode 100755 index b0e75a4a7e..0000000000 --- a/drd/tests/filter_stderr_and_thread_no_and_offset +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -./filter_stderr_and_thread_no \ -| sed "s/ is at offset [0-9]* from / is at offset ... from /" diff --git a/drd/tests/filter_stderr_and_thread_no_and_offset.in b/drd/tests/filter_stderr_and_thread_no_and_offset.in new file mode 100755 index 0000000000..095d44d66c --- /dev/null +++ b/drd/tests/filter_stderr_and_thread_no_and_offset.in @@ -0,0 +1,6 @@ +#!/bin/sh + +SED=@SED@ + +./filter_stderr_and_thread_no \ +| $SED "s/ is at offset [0-9]* from / is at offset ... from /" diff --git a/drd/tests/filter_thread_no b/drd/tests/filter_thread_no.in similarity index 82% rename from drd/tests/filter_thread_no rename to drd/tests/filter_thread_no.in index f70c7b6682..6fac735705 100755 --- a/drd/tests/filter_thread_no +++ b/drd/tests/filter_thread_no.in @@ -1,7 +1,9 @@ #! /bin/sh +SED=@SED@ + # Get rid of the numbers as these make some tests more scheduling sensitive # -- those where there are multiple threads which play interchangeable roles. grep -v "^Thread [0-9][0-9]*:$" | -sed -e "s:hread [0-9][0-9]*:hread x:g" \ +$SED -e "s:hread [0-9][0-9]*:hread x:g" \ -e "s:of thread [0-9][0-9]*$:of thread x:g" diff --git a/drd/tests/filter_xml_and_thread_no b/drd/tests/filter_xml_and_thread_no.in similarity index 55% rename from drd/tests/filter_xml_and_thread_no rename to drd/tests/filter_xml_and_thread_no.in index a9f7ac1af5..db64dd7742 100755 --- a/drd/tests/filter_xml_and_thread_no +++ b/drd/tests/filter_xml_and_thread_no.in @@ -1,5 +1,7 @@ #! /bin/sh +SED=@SED@ + ../../memcheck/tests/filter_xml | ./filter_thread_no | -sed 's/ vc: \[[0-9:, ]*\]/ vc: [ ... ]/g' +$SED 's/ vc: \[[0-9:, ]*\]/ vc: [ ... ]/g' diff --git a/drd/tests/pth_create_chain.c b/drd/tests/pth_create_chain.c index e0771243d9..add1b33f0a 100644 --- a/drd/tests/pth_create_chain.c +++ b/drd/tests/pth_create_chain.c @@ -7,6 +7,7 @@ #include <stdlib.h> #include <stdio.h> #include <pthread.h> +#include "config.h" static pthread_t s_thread[1000]; @@ -23,7 +24,9 @@ static void* thread_func(void* p) // std::cout << "create " << thread_count << std::endl; s_arg[thread_count] = thread_count; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif pthread_create(&s_thread[thread_count], &attr, thread_func, &s_arg[thread_count]); pthread_attr_destroy(&attr); @@ -47,7 +50,9 @@ int main(int argc, char** argv) thread_count--; // std::cout << "create " << thread_count << std::endl; pthread_attr_init(&attr); +#if !defined(VGO_freebsd) pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); +#endif pthread_create(&s_thread[thread_count], &attr, thread_func, &thread_count); pthread_attr_destroy(&attr); diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c old mode 100644 new mode 100755 index efeb15b72d..eab8514ede --- a/drd/tests/pth_detached3.c +++ b/drd/tests/pth_detached3.c @@ -6,6 +6,10 @@ #include <stdio.h> #include <stdint.h> +#if defined(VGO_freebsd) +#include <sys/types.h> +#endif + static void* thread_func(void* arg) { return 0; @@ -22,7 +26,11 @@ int main(int argc, char** argv) pthread_detach(thread); /* Invoke pthread_detach() with an invalid thread ID. */ +#ifdef VGO_freebsd + pthread_detach((pthread_t)12345); +#else pthread_detach((pthread_t)((uintptr_t)thread + 8)); +#endif fprintf(stderr, "Finished.\n"); diff --git a/drd/tests/pth_detached3.stderr.exp-freebsd b/drd/tests/pth_detached3.stderr.exp-freebsd new file mode 100644 index 0000000000..870287d0fe --- /dev/null +++ b/drd/tests/pth_detached3.stderr.exp-freebsd @@ -0,0 +1,14 @@ + +pthread_detach(): invalid thread ID 0x........ + at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) + by 0x........: pthread_detach (drd_pthread_intercepts.c:?) + by 0x........: main (pth_detached3.c:26) + +pthread_detach(): invalid thread ID 0x........ + at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) + by 0x........: pthread_detach (drd_pthread_intercepts.c:?) + by 0x........: main (pth_detached3.c:30) + +Finished. + +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/drd/tests/pth_detached3.stderr.exp2 b/drd/tests/pth_detached3.stderr.exp2 index e82dee14db..d5910d8ebb 100644 --- a/drd/tests/pth_detached3.stderr.exp2 +++ b/drd/tests/pth_detached3.stderr.exp2 @@ -2,12 +2,12 @@ pthread_detach(): invalid thread ID 0x........ at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) by 0x........: pthread_detach (drd_pthread_intercepts.c:?) - by 0x........: main (pth_detached3.c:22) + by 0x........: main (pth_detached3.c:26) pthread_detach(): invalid thread ID 0x........ at 0x........: vgDrd_set_joinable (drd_pthread_intercepts.c:?) by 0x........: pthread_detach (drd_pthread_intercepts.c:?) - by 0x........: main (pth_detached3.c:25) + by 0x........: main (pth_detached3.c:32) Finished. diff --git a/drd/tests/pth_uninitialized_cond.vgtest b/drd/tests/pth_uninitialized_cond.vgtest index fe031397df..f0d9ac286b 100644 --- a/drd/tests/pth_uninitialized_cond.vgtest +++ b/drd/tests/pth_uninitialized_cond.vgtest @@ -1,3 +1,4 @@ prereq: test -e pth_uninitialized_cond && ./supported_libpthread vgopts: --read-var-info=yes --check-stack-var=yes prog: pth_uninitialized_cond +cleanup: rm -f vgcore.* diff --git a/drd/tests/recursive_mutex.stderr.exp-freebsd b/drd/tests/recursive_mutex.stderr.exp-freebsd new file mode 100644 index 0000000000..28c7a6d79f --- /dev/null +++ b/drd/tests/recursive_mutex.stderr.exp-freebsd @@ -0,0 +1,18 @@ + + +Non-recursive mutex. +second lock call failed ! +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: lock_twice (recursive_mutex.c:?) + by 0x........: main (recursive_mutex.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?) + by 0x........: lock_twice (recursive_mutex.c:?) + by 0x........: main (recursive_mutex.c:?) + +second unlock call failed ! + +Done. + +ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/drd/tests/std_list.cpp b/drd/tests/std_list.cpp index 1f09164538..d266bba9cb 100644 --- a/drd/tests/std_list.cpp +++ b/drd/tests/std_list.cpp @@ -15,9 +15,34 @@ #include <string> #include <sstream> #include <list> +#if defined(__FreeBSD__) +#include <mutex> +#endif using namespace std; +#if defined(__FreeBSD__) +std::mutex g_mutex; + +// according to this +// https://stackoverflow.com/questions/4057319/is-setlocale-thread-safe-function +// setlocale is not thread safe, and indeed on FreeBSD +// a load of errors are generated if this is not guarded +void setlocale_wrapper() +{ + const std::lock_guard<std::mutex> lock(g_mutex); + setlocale(LC_ALL, "English"); +} + +#else + +void setlocale_wrapper() +{ + setlocale(LC_ALL, "English"); +} + +#endif + class SubTest { public: SubTest() { @@ -41,7 +66,7 @@ class Test { public: void setUp() { subTest = new SubTest(); - setlocale(LC_ALL, "English"); + setlocale_wrapper(); } void tearDown() { delete subTest; } diff --git a/drd/tests/std_string.cpp b/drd/tests/std_string.cpp old mode 100644 new mode 100755 index 266c93fa5b..63f94729aa --- a/drd/tests/std_string.cpp +++ b/drd/tests/std_string.cpp @@ -8,6 +8,9 @@ #include <string> #include <cstring> #include <pthread.h> +#if defined(__FreeBSD__) +#include <stdio.h> +#endif #include <stdlib.h> #include <unistd.h> diff --git a/drd/tests/std_thread2.supp b/drd/tests/std_thread2.supp index ae69e0ddd9..2e41bac503 100644 --- a/drd/tests/std_thread2.supp +++ b/drd/tests/std_thread2.supp @@ -19,3 +19,29 @@ fun:allocate_stack fun:pthread_create@@GLIBC_2.2* } +{ + drd-gcc-runtims + drd:ConflictingAccess + obj:/lib/libgcc_s.so.1 +} +{ + drd-iterate-phdr + drd:ConflictingAccess + fun:dl_iterate_phdr +} +{ + drd-unwind-cfa + drd:ConflictingAccess + fun:_Unwind_GetCFA +} +{ + drd-thr + drd:ConflictingAccess + obj:/lib/libthr.so.3 +} +{ + drd-rtld + drd:ConflictingAccess + obj:/libexec/ld-elf*.so.1 +} + diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-freebsd b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd new file mode 100644 index 0000000000..e7828fd403 --- /dev/null +++ b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd @@ -0,0 +1,49 @@ + +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 1: +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +--------------------- +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) + +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang new file mode 100644 index 0000000000..384fd5cf75 --- /dev/null +++ b/drd/tests/tc09_bad_unlock.stderr.exp-freebsd-clang @@ -0,0 +1,49 @@ + +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: child_fn (tc09_bad_unlock.c:12) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +Thread 1: +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:39) + by 0x........: main (tc09_bad_unlock.c:52) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) + +--------------------- +Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) + +Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. + at 0x........: nearly_main (tc09_bad_unlock.c:39) + by 0x........: main (tc09_bad_unlock.c:53) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 index 277705a548..9a6c0474f5 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 +++ b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 @@ -1,59 +1,59 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: (below main) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: (below main) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) ERROR SUMMARY: 8 errors from 7 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc22_exit_w_lock.vgtest b/drd/tests/tc22_exit_w_lock.vgtest index f16c1dfe91..5edf4e5ffe 100644 --- a/drd/tests/tc22_exit_w_lock.vgtest +++ b/drd/tests/tc22_exit_w_lock.vgtest @@ -1,3 +1,4 @@ prereq: ./supported_libpthread && [ -e ../../helgrind/tests/tc22_exit_w_lock ] vgopts: --num-callers=3 -q prog: ../../helgrind/tests/tc22_exit_w_lock +cleanup: rm -f vgcore.* diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd b/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd new file mode 100644 index 0000000000..8fbfa87eb2 --- /dev/null +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-freebsd @@ -0,0 +1,40 @@ + +Mutex not locked: mutex 0x........, recursion count 0, owner 0. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:79) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:59) + +The object at address 0x........ is not a mutex. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:82) +rwlock 0x........ was first observed at: + at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:62) + +Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:85) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + +The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:85) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + +Thread 2: +Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: grab_the_lock (tc23_bogus_condwait.c:47) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:58) + + +ERROR SUMMARY: 6 errors from 5 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 index 753b589387..f2c8ad34cd 100644 --- a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 @@ -1,93 +1,93 @@ The object at address 0x........ is not a mutex. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:69) + by 0x........: main (tc23_bogus_condwait.c:75) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:20) + by 0x........: rescue_me (tc23_bogus_condwait.c:24) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) Thread 1: Mutex not locked: mutex 0x........, recursion count 0, owner 0. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:72) + by 0x........: main (tc23_bogus_condwait.c:79) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:54) + by 0x........: main (tc23_bogus_condwait.c:59) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:24) + by 0x........: rescue_me (tc23_bogus_condwait.c:29) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:54) + by 0x........: main (tc23_bogus_condwait.c:59) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:75) + by 0x........: main (tc23_bogus_condwait.c:82) rwlock 0x........ was first observed at: at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:57) + by 0x........: main (tc23_bogus_condwait.c:62) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:28) + by 0x........: rescue_me (tc23_bogus_condwait.c:33) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) rwlock 0x........ was first observed at: at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:57) + by 0x........: main (tc23_bogus_condwait.c:62) Thread 1: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 2. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 3: Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread. at 0x........: pthread_cond_signal (drd_pthread_intercepts.c:?) - by 0x........: rescue_me (tc23_bogus_condwait.c:32) + by 0x........: rescue_me (tc23_bogus_condwait.c:37) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) cond 0x........ was first observed at: at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:56) + by 0x........: main (tc23_bogus_condwait.c:61) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 1: The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:78) + by 0x........: main (tc23_bogus_condwait.c:85) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: grab_the_lock (tc23_bogus_condwait.c:42) + by 0x........: grab_the_lock (tc23_bogus_condwait.c:47) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: main (tc23_bogus_condwait.c:53) + by 0x........: main (tc23_bogus_condwait.c:58) ERROR SUMMARY: 12 errors from 10 contexts (suppressed: 0 from 0) diff --git a/drd/tests/thread_name.vgtest b/drd/tests/thread_name.vgtest index 868f5f3c3b..acd7bc682f 100644 --- a/drd/tests/thread_name.vgtest +++ b/drd/tests/thread_name.vgtest @@ -1,3 +1,3 @@ -prereq: test -e thread_name && ./supported_libpthread +prereq: test -e thread_name && ./supported_libpthread && ! ../../tests/os_test freebsd vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 prog: thread_name diff --git a/drd/tests/thread_name_freebsd.c b/drd/tests/thread_name_freebsd.c new file mode 100644 index 0000000000..0f4954ba7c --- /dev/null +++ b/drd/tests/thread_name_freebsd.c @@ -0,0 +1,63 @@ +/* Test whether assigning names to threads works properly. */ + +#define _GNU_SOURCE +#include <pthread.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> +#include "../../drd/drd.h" + + +#define NUM_THREADS 10 + + +static pthread_barrier_t s_barrier; +static pthread_mutex_t s_mutex; +static pthread_cond_t s_cond; +static int s_counter; + +static void* thread_func(void* argp) +{ + const int thread_num = (ptrdiff_t)(argp); + pthread_mutex_t invalid_mutex; + char thread_name[32]; + + snprintf(thread_name, sizeof(thread_name), + "thread_func instance %d", thread_num + 1); + ANNOTATE_THREAD_NAME(thread_name); + + pthread_barrier_wait(&s_barrier); + + pthread_mutex_lock(&s_mutex); + while (s_counter != thread_num) + pthread_cond_wait(&s_cond, &s_mutex); + fprintf(stderr, "\n%s\n\n", thread_name); + pthread_mutex_unlock(&invalid_mutex); + s_counter++; + pthread_cond_broadcast(&s_cond); + pthread_mutex_unlock(&s_mutex); + + return 0; +} + + +int main(int arg, char** argv) +{ + int i; + pthread_t tid[NUM_THREADS]; + + pthread_barrier_init(&s_barrier, NULL, NUM_THREADS); + pthread_mutex_init(&s_mutex, 0); + pthread_cond_init(&s_cond, 0); + + for (i = 0; i < NUM_THREADS; i++) + pthread_create(&tid[i], 0, thread_func, (void*)(ptrdiff_t)i); + + for (i = 0; i < NUM_THREADS; i++) + pthread_join(tid[i], 0); + + pthread_cond_destroy(&s_cond); + pthread_mutex_destroy(&s_mutex); + + return 0; +} diff --git a/drd/tests/thread_name_freebsd.stderr.exp b/drd/tests/thread_name_freebsd.stderr.exp new file mode 100644 index 0000000000..a96e14a4f5 --- /dev/null +++ b/drd/tests/thread_name_freebsd.stderr.exp @@ -0,0 +1,93 @@ + + +thread_func instance 1 + +Thread 2 (thread_func instance 1): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 2 + +Thread 3 (thread_func instance 2): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 3 + +Thread 4 (thread_func instance 3): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 4 + +Thread 5 (thread_func instance 4): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 5 + +Thread 6 (thread_func instance 5): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 6 + +Thread 7 (thread_func instance 6): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 7 + +Thread 8 (thread_func instance 7): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 8 + +Thread 9 (thread_func instance 8): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 9 + +Thread 10 (thread_func instance 9): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +thread_func instance 10 + +Thread 11 (thread_func instance 10): +The object at address 0x........ is not a mutex. + at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) + by 0x........: thread_func (thread_name_freebsd.c:?) + by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) + + +ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 0 from 0) diff --git a/drd/tests/thread_name_freebsd.vgtest b/drd/tests/thread_name_freebsd.vgtest new file mode 100644 index 0000000000..e6317acdab --- /dev/null +++ b/drd/tests/thread_name_freebsd.vgtest @@ -0,0 +1,3 @@ +prereq: ../../tests/os_test freebsd +vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 +prog: thread_name_freebsd diff --git a/drd/tests/thread_name_xml.vgtest b/drd/tests/thread_name_xml.vgtest index c6cd1cafb0..4c8545e38b 100644 --- a/drd/tests/thread_name_xml.vgtest +++ b/drd/tests/thread_name_xml.vgtest @@ -1,4 +1,4 @@ -prereq: test -e thread_name && ./supported_libpthread +prereq: test -e thread_name && ./supported_libpthread && ! ../../tests/os_test freebsd vgopts: --read-var-info=yes --check-stack-var=yes --num-callers=3 --xml=yes --xml-fd=2 prog: thread_name stderr_filter: filter_thread_name_xml diff --git a/helgrind/tests/Makefile.am b/helgrind/tests/Makefile.am old mode 100644 new mode 100755 index ad1af191a1..cf7f76d46a --- a/helgrind/tests/Makefile.am +++ b/helgrind/tests/Makefile.am @@ -4,7 +4,9 @@ include $(top_srcdir)/Makefile.tool-tests.am dist_noinst_SCRIPTS = filter_stderr \ filter_stderr_solaris \ filter_helgrind \ - filter_xml + filter_xml \ + filter_freebsd.awk \ + filter_stderr_freebsd EXTRA_DIST = \ annotate_hbefore.vgtest annotate_hbefore.stdout.exp \ @@ -21,6 +23,7 @@ EXTRA_DIST = \ cond_timedwait_test.stderr.exp \ bar_bad.vgtest bar_bad.stdout.exp bar_bad.stderr.exp \ bar_bad.stderr.exp-destroy-hang \ + bar_bad.stderr.exp-freebsd \ bar_trivial.vgtest bar_trivial.stdout.exp bar_trivial.stderr.exp \ free_is_write.vgtest free_is_write.stdout.exp \ free_is_write.stderr.exp \ @@ -40,9 +43,11 @@ EXTRA_DIST = \ locked_vs_unlocked2.vgtest \ locked_vs_unlocked2.stderr.exp \ locked_vs_unlocked2.stdout.exp \ + locked_vs_unlocked2.stderr.exp-freebsd \ locked_vs_unlocked3.vgtest \ locked_vs_unlocked3.stderr.exp \ locked_vs_unlocked3.stdout.exp \ + locked_vs_unlocked3.stderr.exp-freebsd \ pth_barrier1.vgtest pth_barrier1.stdout.exp pth_barrier1.stderr.exp \ pth_barrier2.vgtest pth_barrier2.stdout.exp pth_barrier2.stderr.exp \ pth_barrier3.vgtest pth_barrier3.stdout.exp pth_barrier3.stderr.exp \ @@ -52,6 +57,7 @@ EXTRA_DIST = \ pth_cond_destroy_busy.vgtest pth_cond_destroy_busy.stderr.exp \ pth_cond_destroy_busy.stderr.exp-ppc64 \ pth_cond_destroy_busy.stderr.exp-solaris \ + pth_cond_destroy_busy.stderr.exp-freebsd \ pth_spinlock.vgtest pth_spinlock.stdout.exp pth_spinlock.stderr.exp \ rwlock_race.vgtest rwlock_race.stdout.exp rwlock_race.stderr.exp \ rwlock_test.vgtest rwlock_test.stdout.exp rwlock_test.stderr.exp \ @@ -72,16 +78,19 @@ EXTRA_DIST = \ tc06_two_races.stderr.exp \ tc06_two_races_xml.vgtest tc06_two_races_xml.stdout.exp \ tc06_two_races_xml.stderr.exp \ + tc06_two_races_xml.stderr.exp-freebsd \ tc07_hbl1.vgtest tc07_hbl1.stdout.exp tc07_hbl1.stderr.exp \ tc08_hbl2.vgtest tc08_hbl2.stdout.exp tc08_hbl2.stderr.exp \ tc09_bad_unlock.vgtest tc09_bad_unlock.stdout.exp \ tc09_bad_unlock.stderr.exp tc09_bad_unlock.stderr.exp-solaris \ + tc09_bad_unlock.stderr.exp-freebsd \ tc10_rec_lock.vgtest tc10_rec_lock.stdout.exp tc10_rec_lock.stderr.exp \ tc11_XCHG.vgtest tc11_XCHG.stdout.exp tc11_XCHG.stderr.exp \ tc12_rwl_trivial.vgtest tc12_rwl_trivial.stdout.exp \ tc12_rwl_trivial.stderr.exp \ tc12_rwl_trivial.stderr.exp-darwin970 \ tc12_rwl_trivial.stderr.exp-solaris \ + tc12_rwl_trivial.stderr.exp-freebsd \ tc13_laog1.vgtest tc13_laog1.stdout.exp tc13_laog1.stderr.exp \ tc14_laog_dinphils.vgtest tc14_laog_dinphils.stdout.exp \ tc14_laog_dinphils.stderr.exp \ @@ -96,6 +105,7 @@ EXTRA_DIST = \ tc18_semabuse.stderr.exp-linux-mips32 \ tc18_semabuse.stderr.exp-linux-mips32-b \ tc18_semabuse.stderr.exp-solaris \ + tc18_semabuse.stderr.exp-freebsd \ tc19_shadowmem.vgtest tc19_shadowmem.stdout.exp \ tc19_shadowmem.stderr.exp tc19_shadowmem.stderr.exp-mips32 \ tc19_shadowmem.stderr.exp-mips32-BE \ @@ -115,6 +125,7 @@ EXTRA_DIST = \ tc23_bogus_condwait.vgtest tc23_bogus_condwait.stdout.exp \ tc23_bogus_condwait.stderr.exp \ tc23_bogus_condwait.stderr.exp-mips32 \ + tc23_bogus_condwait.stderr.exp-freebsd \ tc24_nonzero_sem.vgtest tc24_nonzero_sem.stdout.exp \ tc24_nonzero_sem.stderr.exp \ tls_threads.vgtest tls_threads.stdout.exp \ diff --git a/helgrind/tests/bar_bad.c... [truncated message content] |
|
From: Mark W. <ma...@so...> - 2021-10-07 11:47:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f22758d6dad9bae9b7531046e42ce105f12e1ead commit f22758d6dad9bae9b7531046e42ce105f12e1ead Author: Mark Wielaard <ma...@kl...> Date: Thu Oct 7 13:43:19 2021 +0200 Fix make distcheck by removing references to uncommitted files Some files for the freebsd port have not yet committed, but were already referenced in the Makefiles. Remove those references for now to make distcheck happy. * coregrind/Makefile.am (valgrind_SOURCES): Remove launcher-freebsd.c * drd/tests/Makefile.am (check_PROGRAMS): Remove thread_name_freebsd. * none/tests/Makefile.am (SUBDIRS): Remove freebsd. (DIST_SUBDIRS): Likewise. * none/tests/freebsd/filter_stderr: Removed. Diff: --- coregrind/Makefile.am | 1 - drd/tests/Makefile.am | 4 ---- none/tests/Makefile.am | 5 +---- none/tests/freebsd/filter_stderr | 3 --- 4 files changed, 1 insertion(+), 12 deletions(-) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index ee70cfde31..01b8783ee4 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -51,7 +51,6 @@ valgrind_SOURCES = \ endif if VGCONF_OS_IS_FREEBSD valgrind_SOURCES = \ - launcher-freebsd.c \ m_debuglog.c endif diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am index b53eeefebe..07650ef88a 100644 --- a/drd/tests/Makefile.am +++ b/drd/tests/Makefile.am @@ -480,10 +480,6 @@ if !VGCONF_OS_IS_DARWIN check_PROGRAMS += sem_wait endif -if VGCONF_OS_IS_FREEBSD -check_PROGRAMS += thread_name_freebsd -endif - AM_CFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ @FLAG_FALIGNED_NEW@ \ diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 617c92854d..b75fb01a5e 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -47,9 +47,6 @@ endif if VGCONF_OS_IS_SOLARIS SUBDIRS += solaris endif -if VGCONF_OS_IS_FREEBSD -SUBDIRS += freebsd -endif # Platform-specific tests if VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX @@ -72,7 +69,7 @@ SUBDIRS += x86-solaris endif DIST_SUBDIRS = x86 amd64 ppc32 ppc64 arm arm64 s390x mips32 mips64 nanomips \ - linux darwin solaris freebsd amd64-linux x86-linux amd64-darwin \ + linux darwin solaris amd64-linux x86-linux amd64-darwin \ x86-darwin amd64-solaris x86-solaris scripts . dist_noinst_SCRIPTS = \ diff --git a/none/tests/freebsd/filter_stderr b/none/tests/freebsd/filter_stderr deleted file mode 100755 index a778e971fc..0000000000 --- a/none/tests/freebsd/filter_stderr +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -../filter_stderr "$@" |
|
From: Paul F. <pa...@so...> - 2021-10-07 06:54:35
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a6096335c3f0d01c57b87538430de805aa632260 commit a6096335c3f0d01c57b87538430de805aa632260 Author: Paul Floyd <pj...@wa...> Date: Tue Oct 5 00:05:18 2021 +0200 FreeBSD support, patch 8a docs directory Diff: --- docs/xml/dist-docs.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/xml/dist-docs.xml b/docs/xml/dist-docs.xml index b1b5598fb0..439cdcc5f0 100644 --- a/docs/xml/dist-docs.xml +++ b/docs/xml/dist-docs.xml @@ -131,4 +131,14 @@ xmlns:xi="http://www.w3.org/2001/XInclude" /> </literallayout> </chapter> + + <chapter id="dist.readme-freebsd" + xreflabel="Readme FreeBSD"> + <title>README.freebsd</title> + <literallayout> + <xi:include href="../../README.freebsd" + parse="text" + xmlns:xi="http://www.w3.org/2001/XInclude" /> + </literallayout> + </chapter> </book> |
|
From: Paul F. <pa...@so...> - 2021-10-07 06:19:38
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e2583c02a5638fcbe7b3d693f7127ebde5d7c359 commit e2583c02a5638fcbe7b3d693f7127ebde5d7c359 Author: Paul Floyd <pj...@wa...> Date: Thu Oct 7 07:53:33 2021 +0200 FreeBSD support, patch 2 Files in the root directory Several Makefile.am files that have dependencies on FreeBSD autoconf variables. Included a few new filter files to act as placeholders to create new freebsd subdirectories. Updated NEWS with the FreeBSD bugzilla items plus a couple of other items fixed indirectly. Diff: --- .gitignore | 96 ++++++++++++++- Makefile.all.am | 25 ++++ Makefile.am | 2 + Makefile.tool.am | 24 ++++ NEWS | 2 + README | 2 + README.freebsd | 180 ++++++++++++++++++++++++++++ cachegrind/tests/Makefile.am | 2 + configure.ac | 181 ++++++++++++++++++++++++++--- coregrind/Makefile.am | 11 ++ docs/Makefile.am | 5 + drd/tests/Makefile.am | 15 ++- freebsd-drd.supp | 170 +++++++++++++++++++++++++++ freebsd-helgrind.supp | 162 ++++++++++++++++++++++++++ freebsd.supp | 51 ++++++++ gdbserver_tests/Makefile.am | 11 +- memcheck/tests/Makefile.am | 9 ++ memcheck/tests/amd64-freebsd/filter_stderr | 3 + memcheck/tests/freebsd/filter_pts | 5 + memcheck/tests/x86-freebsd/filter_stderr | 3 + mpi/Makefile.am | 4 + none/tests/Makefile.am | 23 +++- none/tests/freebsd/filter_stderr | 3 + 23 files changed, 960 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index bb8578d680..86962b4780 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ /auxprogs/getoff-nanomips-linux /auxprogs/getoff-amd64-solaris /auxprogs/getoff-x86-solaris +/auxprogs/getoff-*-freebsd /auxprogs/libmpiwrap-PPC32_LINUX.so /auxprogs/libmpiwrap-PPC64_LINUX.so /auxprogs/libmpiwrap-x86-darwin.so @@ -73,6 +74,7 @@ /cachegrind/cachegrind-*-darwin /cachegrind/cachegrind-*-linux /cachegrind/cachegrind-*-solaris +/cachegrind/cachegrind-*-freebsd /cachegrind/cg_annotate /cachegrind/cg_diff /cachegrind/cg_merge @@ -119,6 +121,7 @@ /callgrind/callgrind-*-darwin /callgrind/callgrind-*-linux /callgrind/callgrind-*-solaris +/callgrind/callgrind-*-freebsd /callgrind/callgrind_annotate /callgrind/callgrind_control /callgrind/Makefile @@ -152,6 +155,7 @@ /coregrind/link_tool_exe_darwin /coregrind/link_tool_exe_linux /coregrind/link_tool_exe_solaris +/coregrind/link_tool_exe_freebsd /coregrind/Makefile /coregrind/Makefile.in /coregrind/no_op_client_for_valgrind @@ -259,11 +263,13 @@ /dhat/dhat-*-darwin /dhat/dhat-*-linux /dhat/dhat-*-solaris +/dhat/dhat-*-freebsd /dhat/Makefile /dhat/Makefile.in /dhat/vgpreload_dhat-*-linux.so /dhat/vgpreload_dhat-*-darwin.so /dhat/vgpreload_dhat-*-solaris.so +/dhat/vgpreload_dhat-*-freebsd.so # /dhat/tests/ /dhat/tests/Makefile @@ -324,12 +330,14 @@ /drd/drd-*-darwin /drd/drd-*-linux /drd/drd-*-solaris +/drd/drd-*-freebsd /drd/Makefile /drd/Makefile.in /drd/splash2 /drd/vgpreload_drd-*-linux.so /drd/vgpreload_drd-*-darwin.so /drd/vgpreload_drd-*-solaris.so +/drd/vgpreload_drd-*-freebsd.so # /drd/docs/ /drd/docs/.deps @@ -455,6 +463,7 @@ /drd/tests/tc24_nonzero_sem /drd/tests/threaded-fork /drd/tests/thread_name +/drd/tests/thread_name_freebsd /drd/tests/trylock /drd/tests/tsan_unittest /drd/tests/unit_bitmap @@ -552,6 +561,11 @@ /gdbserver_tests/*.dSYM /gdbserver_tests/*.diff* /gdbserver_tests/*.out +/gdbserver_tests/filter_gdb +/gdbserver_tests/filter_memcheck_monitor +/gdbserver_tests/filter_stderr +/gdbserver_tests/filter_vgdb +/gdbserver_tests/filter_vgdb.in.orig /gdbserver_tests/.deps /gdbserver_tests/clean_after_fork /gdbserver_tests/detailed @@ -597,11 +611,13 @@ /helgrind/helgrind-*-darwin /helgrind/helgrind-*-linux /helgrind/helgrind-*-solaris +/helgrind/helgrind-*-freebsd /helgrind/Makefile /helgrind/Makefile.in /helgrind/vgpreload_helgrind-*-linux.so /helgrind/vgpreload_helgrind-*-darwin.so /helgrind/vgpreload_helgrind-*-solaris.so +/helgrind/vgpreload_helgrind-*-freebsd.so # /helgrind/docs/ /helgrind/docs/Makefile @@ -683,6 +699,7 @@ /lackey/lackey-*-darwin /lackey/lackey-*-linux /lackey/lackey-*-solaris +/lackey/lackey-*-freebsd /lackey/Makefile /lackey/Makefile.in @@ -707,6 +724,7 @@ /massif/massif-*-darwin /massif/massif-*-linux /massif/massif-*-solaris +/massif/massif-*-freebsd /massif/ms_print # /massif/docs/ @@ -765,6 +783,7 @@ /memcheck/memcheck-*-darwin /memcheck/memcheck-*-linux /memcheck/memcheck-*-solaris +/memcheck/memcheck-*-freebsd # /memcheck/docs/ /memcheck/docs/Makefile.in @@ -777,6 +796,8 @@ /memcheck/tests/*.stderr.out /memcheck/tests/*.stdout.diff* /memcheck/tests/*.stdout.out +/memcheck/tests/filter_dw4 +/memcheck/tests/filter_overlaperror /memcheck/tests/.deps /memcheck/tests/accounting /memcheck/tests/addressable @@ -968,7 +989,7 @@ /memcheck/tests/zeropage # /memcheck/tests/amd64/ -/memcheck/tests/amd64/*.diff +/memcheck/tests/amd64/*.diff* /memcheck/tests/amd64/*.dSYM /memcheck/tests/amd64/*.out /memcheck/tests/amd64/.deps @@ -1204,6 +1225,7 @@ /memcheck/tests/x86/*.stderr.out /memcheck/tests/x86/*.stdout.diff /memcheck/tests/x86/*.stdout.out +/memcheck/tests/x86/filter_pushfpopf /memcheck/tests/x86/.deps /memcheck/tests/x86/Makefile /memcheck/tests/x86/Makefile.in @@ -1260,6 +1282,65 @@ /memcheck/tests/x86-solaris/ldsoexec /memcheck/tests/x86-solaris/scalar +# /memcheck/tests/freebsd/ +/memcheck/tests/freebsd/*.stderr.diff* +/memcheck/tests/freebsd/*.stderr.out +/memcheck/tests/freebsd/*.stdout.diff +/memcheck/tests/freebsd/*.stdout.out +/memcheck/tests/freebsd/.deps +/memcheck/tests/freebsd/Makefile +/memcheck/tests/freebsd/Makefile.in +/memcheck/tests/freebsd/statfs +/memcheck/tests/freebsd/pdfork_pdkill +/memcheck/tests/freebsd/getfsstat +/memcheck/tests/freebsd/inlinfo +/memcheck/tests/freebsd/inlinfo_nested.so +/memcheck/tests/freebsd/extattr +/memcheck/tests/freebsd/sigwait +/memcheck/tests/freebsd/chflags +/memcheck/tests/freebsd/get_set_login +/memcheck/tests/freebsd/revoke +/memcheck/tests/freebsd/scalar +/memcheck/tests/freebsd/capsicum +/memcheck/tests/freebsd/getfh +/memcheck/tests/freebsd/linkat +/memcheck/tests/freebsd/scalar_fork +/memcheck/tests/freebsd/scalar_thr_exit +/memcheck/tests/freebsd/scalar_abort2 +/memcheck/tests/freebsd/scalar_pdfork +/memcheck/tests/freebsd/scalar_vfork +/memcheck/tests/freebsd/stat +/memcheck/tests/freebsd/file_locking_wait6 +/memcheck/tests/freebsd/utimens +/memcheck/tests/freebsd/access +/memcheck/tests/freebsd/chmod_chown +/memcheck/tests/freebsd/misc +/memcheck/tests/freebsd/get_set_context +/memcheck/tests/freebsd/utimes +/memcheck/tests/freebsd/static_allocs + +# /memcheck/tests/amd64-freebsd +/memcheck/tests/amd64-freebsd/*.stderr.diff +/memcheck/tests/amd64-freebsd/*.stderr.out +/memcheck/tests/amd64-freebsd/*.stdout.diff +/memcheck/tests/amd64-freebsd/*.stdout.out +/memcheck/tests/amd64-freebsd/.deps +/memcheck/tests/amd64-freebsd/Makefile +/memcheck/tests/amd64-freebsd/Makefile.in +/memcheck/tests/amd64-freebsd/posix_fadvise +/memcheck/tests/amd64-freebsd/posix_fallocate + +# /memcheck/tests/x86-freebsd +/memcheck/tests/x86-freebsd/*.stderr.diff +/memcheck/tests/x86-freebsd/*.stderr.out +/memcheck/tests/x86-freebsd/*.stdout.diff +/memcheck/tests/x86-freebsd/*.stdout.out +/memcheck/tests/x86-freebsd/.deps +/memcheck/tests/x86-freebsd/Makefile +/memcheck/tests/x86-freebsd/Makefile.in +/memcheck/tests/x86-freebsd/posix_fadvise +/memcheck/tests/x86-freebsd/posix_fallocate + # /mpi/ /mpi/*.dSYM /mpi/*.so @@ -1290,6 +1371,7 @@ /none/none-*-darwin /none/none-*-linux /none/none-*-solaris +/none/none-*-freebsd # /none/docs/ /none/docs/Makefile.in @@ -1946,6 +2028,18 @@ /none/tests/solaris/stack_prot /none/tests/solaris/threads_exitall +# /none/tests/freebsd/ +/none/tests/freebsd/*.stderr.diff +/none/tests/freebsd/*.stderr.out +/none/tests/freebsd/*.stdout.diff +/none/tests/freebsd/*.stdout.out +/none/tests/freebsd/.deps +/none/tests/freebsd/Makefile +/none/tests/freebsd/Makefile.in +/none/tests/freebsd/auxv +/none/tests/freebsd/osrel +/none/tests/freebsd/swapcontext + # /none/tests/x86/ /none/tests/x86/*.dSYM /none/tests/x86/*.stderr.diff diff --git a/Makefile.all.am b/Makefile.all.am old mode 100644 new mode 100755 index 06b23c99e0..1de1f13a7e --- a/Makefile.all.am +++ b/Makefile.all.am @@ -151,9 +151,17 @@ AM_CFLAGS_PSO_BASE = -dynamic \ -O -g -fno-omit-frame-pointer -fno-strict-aliasing \ -fpic -fPIC -fno-builtin @FLAG_FNO_IPA_ICF@ else +if VGCONF_OS_IS_FREEBSD +AM_CFLAGS_PSO_BASE = -O -g -fno-omit-frame-pointer -fno-strict-aliasing \ + -fpic -fPIC -fno-builtin +if COMPILER_IS_CLANG + AM_CFLAGS_BASE += @FLAG_W_NO_EXPANSION_TO_DEFINED@ +endif +else AM_CFLAGS_PSO_BASE = -O -g -fno-omit-frame-pointer -fno-strict-aliasing \ -fpic -fno-builtin @FLAG_FNO_IPA_ICF@ endif +endif # Flags for specific targets. @@ -218,6 +226,12 @@ AM_CFLAGS_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(ISA_3_0_BUILD_FLAG) AM_CFLAGS_PSO_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) AM_CCASFLAGS_PPC64LE_LINUX = @FLAG_M64@ -g +AM_FLAG_M3264_X86_FREEBSD = @FLAG_M32@ +AM_CFLAGS_X86_FREEBSD = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY_2@ \ + $(AM_CFLAGS_BASE) -fomit-frame-pointer +AM_CFLAGS_PSO_X86_FREEBSD = @FLAG_M32@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) +AM_CCASFLAGS_X86_FREEBSD = @FLAG_M32@ -g + AM_FLAG_M3264_ARM_LINUX = @FLAG_M32@ AM_CFLAGS_ARM_LINUX = @FLAG_M32@ \ $(AM_CFLAGS_BASE) -marm -mcpu=cortex-a8 @@ -231,6 +245,14 @@ AM_CFLAGS_ARM64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) AM_CFLAGS_PSO_ARM64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) AM_CCASFLAGS_ARM64_LINUX = @FLAG_M64@ -g + +AM_FLAG_M3264_AMD64_FREEBSD = @FLAG_M64@ +AM_CFLAGS_AMD64_FREEBSD = @FLAG_M64@ \ + $(AM_CFLAGS_BASE) -fomit-frame-pointer +AM_CFLAGS_PSO_AMD64_FREEBSD = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) +AM_CCASFLAGS_AMD64_FREEBSD = @FLAG_M64@ -g + + AM_FLAG_M3264_X86_DARWIN = -arch i386 AM_CFLAGS_X86_DARWIN = $(WERROR) -arch i386 $(AM_CFLAGS_BASE) \ -mmacosx-version-min=10.6 \ @@ -299,6 +321,7 @@ endif # Baseline link flags for making vgpreload shared objects. # PRELOAD_LDFLAGS_COMMON_LINUX = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst +PRELOAD_LDFLAGS_COMMON_FREEBSD = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst PRELOAD_LDFLAGS_COMMON_DARWIN = -dynamic -dynamiclib -all_load PRELOAD_LDFLAGS_COMMON_SOLARIS = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst if SOLARIS_XPG_SYMBOLS_PRESENT @@ -319,6 +342,8 @@ PRELOAD_LDFLAGS_PPC64BE_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@ PRELOAD_LDFLAGS_PPC64LE_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@ PRELOAD_LDFLAGS_ARM_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@ PRELOAD_LDFLAGS_ARM64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@ +PRELOAD_LDFLAGS_X86_FREEBSD = $(PRELOAD_LDFLAGS_COMMON_FREEBSD) @FLAG_M32@ +PRELOAD_LDFLAGS_AMD64_FREEBSD= $(PRELOAD_LDFLAGS_COMMON_FREEBSD) @FLAG_M64@ PRELOAD_LDFLAGS_X86_DARWIN = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch i386 PRELOAD_LDFLAGS_AMD64_DARWIN = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch x86_64 PRELOAD_LDFLAGS_S390X_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@ diff --git a/Makefile.am b/Makefile.am index f5935eb692..7749442e9f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,7 @@ SUPP_FILES = \ glibc-2.2-LinuxThreads-helgrind.supp \ glibc-2.X-drd.supp \ darwin9.supp darwin9-drd.supp \ + freebsd.supp freebsd-helgrind.supp freebsd-drd.supp \ darwin10.supp darwin10-drd.supp \ darwin11.supp darwin12.supp darwin13.supp darwin14.supp darwin15.supp \ darwin16.supp darwin17.supp \ @@ -116,6 +117,7 @@ EXTRA_DIST = \ README.mips \ README.aarch64 \ README.solaris \ + README.freebsd \ NEWS.old \ valgrind.pc.in \ valgrind.spec.in \ diff --git a/Makefile.tool.am b/Makefile.tool.am index 2bf90de5da..fe5f002cec 100644 --- a/Makefile.tool.am +++ b/Makefile.tool.am @@ -40,13 +40,21 @@ TOOL_LDFLAGS_COMMON_DARWIN = \ TOOL_LDFLAGS_COMMON_SOLARIS = \ -static -nodefaultlibs -nostartfiles -u _start \ -Wl,-M,/usr/lib/ld/map.noexstk +TOOL_LDFLAGS_COMMON_FREEBSD = -static \ + -nodefaultlibs -nostartfiles -Wl,-u,_start @FLAG_NO_BUILD_ID@ TOOL_LDFLAGS_X86_LINUX = \ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@ +TOOL_LDFLAGS_X86_FREEBSD = \ + $(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M32@ + TOOL_LDFLAGS_AMD64_LINUX = \ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ +TOOL_LDFLAGS_AMD64_FREEBSD = \ + $(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M64@ + TOOL_LDFLAGS_PPC32_LINUX = \ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@ @@ -125,12 +133,18 @@ LIBREPLACEMALLOC_PPC64BE_LINUX = \ LIBREPLACEMALLOC_PPC64LE_LINUX = \ $(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc64le-linux.a +LIBREPLACEMALLOC_X86_FREEBSD = \ + $(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-freebsd.a + LIBREPLACEMALLOC_ARM_LINUX = \ $(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm-linux.a LIBREPLACEMALLOC_ARM64_LINUX = \ $(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm64-linux.a +LIBREPLACEMALLOC_AMD64_FREEBSD = \ + $(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-freebsd.a + LIBREPLACEMALLOC_X86_DARWIN = \ $(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-darwin.a @@ -187,6 +201,16 @@ LIBREPLACEMALLOC_LDFLAGS_ARM64_LINUX = \ $(LIBREPLACEMALLOC_ARM64_LINUX) \ -Wl,--no-whole-archive +LIBREPLACEMALLOC_LDFLAGS_X86_FREEBSD = \ + -Wl,--whole-archive \ + $(LIBREPLACEMALLOC_X86_FREEBSD) \ + -Wl,--no-whole-archive + +LIBREPLACEMALLOC_LDFLAGS_AMD64_FREEBSD = \ + -Wl,--whole-archive \ + $(LIBREPLACEMALLOC_AMD64_FREEBSD) \ + -Wl,--no-whole-archive + LIBREPLACEMALLOC_LDFLAGS_X86_DARWIN = \ $(LIBREPLACEMALLOC_X86_DARWIN) diff --git a/NEWS b/NEWS index e4cec71c56..68315a77ad 100644 --- a/NEWS +++ b/NEWS @@ -37,7 +37,9 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +208531 [PATCH]: FreeBSD support for valgrind 368960 WARNING: unhandled amd64-linux syscall: 163 (acct) +407589 [Linux] Add support for C11 aligned_alloc() and GNU reallocarray() 423963 Error in child thread when CLONE_PIDFD is used 429375 PPC ISA 3.1 support is missing, part 9 431157 PPC_FEATURE2_SCV needs to be masked in AT_HWCAP2 diff --git a/README b/README index b8cc51de83..ae21cc74d6 100644 --- a/README +++ b/README @@ -46,6 +46,8 @@ platforms: - nanoMIPS/Linux - X86/Solaris - AMD64/Solaris +- X86/FreeBSD +- AMD64/FreeBSD Note that AMD64 is just another name for x86_64, and Valgrind runs fine on Intel processors. Also note that the core of macOS is called diff --git a/README.freebsd b/README.freebsd new file mode 100644 index 0000000000..c6e6818211 --- /dev/null +++ b/README.freebsd @@ -0,0 +1,180 @@ +Installing from ports or via pkg +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are using FreeBSD 11.3 or later, then you should be able to install +Valgrind using either + +pkg install devel/valgrind + +or alternatively from ports (if installed) + +cd /usr/ports/devel/valgrind && make install clean + + +Building Valgrind +~~~~~~~~~~~~~~~~~ + +Install ports for autoconf, automake, libtool and gmake. + +$ sh autogen.sh +$ ./configure --prefix=/where/ever +$ gmake +$ gmake install + +Known Limitations (December 2020) + +0. Be aware that if you use a wrapper script and run Valgrind on the wrapper + script Valgrind may hit restrictions if the wrapper script runs any + Capsicum enabled applications. Examples of Capsicum enabled applications + are echo, basename, tee, uniq and wc. It is recommended that you either + avoid these applications or that you run Valgrind directly on your test + application. +1. There are some limitations when running Valgrind on code that was compiled + with clang. These issues are not present with code compiled with GCC. + a) There may be missing source information concerning variables. + b) The client request mechanism may not work entirely correctly. + c) Code that uses OpenMP will generate spurious errors. +2. There are some limitations specific to i386 + a) In some cases signals are mishandled causing Valgrind to terminate and + report a SIGSEGV. + b) Applications that create and join many threads may crash. + +Notes for Developers +~~~~~~~~~~~~~~~~~~~~ + +See README_DEVELOPERS, README_MISSING_SYSCALL_OR_IOCTL and docs/* +for more general information for developers. + +0. Adding syscalls. + +When adding syscalls, you need to look at the manpage and also syscalls.master +(online at +https://github.com/freebsd/freebsd/blob/master/sys/kern/syscalls.master +and for 32bit +https://github.com/freebsd/freebsd/blob/master/sys/compat/freebsd32/syscalls.master + +and if you installed the src package there should also be + +/usr/src/sys/kern/syscalls.master +and +/usr/src/sys/compat/freebsd32/syscalls.master) + +syscalls.master is particularly useful for seeing quickly whether parameters +are inputs or outputs. + +The syscall wrappers can vary from trivial to difficult. Fortunately, many are +either trivial (no arguments) or easy (Valgrind just needs to know what memory +is being read or written). Some syscalls, such as those involving process +creation and termination, signals and memory mapping require deeper interaction +with Valgrind. + +When you add syscalls you will need to modify several files + a) include/vki/vki-scnums-freebsd.h + This file contains one #define for each syscall. The _NR_ prefix (Linux + style) is used rather than SYS_ for compatibility with the rest of the + Valgrind source. + b) coregrind/m_syswrap/priv_syswrap-freebsd.h + This uses the DECL_TEMPLATE macro to generate declarations for the syscall + before and after wrappers. + c) coregrind/m_syswrap/syswrap-freebsd.c + This is where the bulk of the code resides. Toward the end of the file + the BSDX_/BSDXY macros are used to generate entries in the table of + syscalls. BSDX_ is used for wrappers that only have a 'before', BSDXY + if both wrappers are required. In general, syscalls that have no arguments + or only input arguments just need a BSDX_ macro (before only). Syscalls + with output arguments need a BSDXY macro (before and after). + d) If the syscall uses 64bit arguments (long long) then instead of putting + the wrapper definitions in syswrap-freebsd.c there will be one definition + for each platform amd64 and x86 in syswrap-x86-freebsd.c and + syswrap-amd64-freebsd.c. + Each long long needs to be split into two ARGs in the x86 version. + +The PRE (before) wrapper +------------------------ + +Each PRE wrapper always contains the following two macro calls + +PRINT. This outputs the syscall name and argument values when Valgrind is +executed with +--trace-syscalls=yes + +PRE_READ_REGX. This macro lets Valgrind know about the number and types of the +syscall arguments which allows Valgrind to check that they are initialized. +X is the number of arguments. It is best that the argument names match +the man page, but the must match the types and number of arguments in +syscalls.master. +Occasionally there are differences between the two. + +If the syscall takes pointers to memory there will be one of the following for +each pointer argument. + +PRE_MEM_RASCIIZ for NULL terminated ascii strings. + +PRE_MEM_READ for pointers to structures or arrays that are read. + +PRE_MEM_WRITE for pointers to structures or arrays that are written. + +As a rule, the definitions of structures are copied into vki-freebsd.h +with the vki- prefix. [vki - Valgrind kernel interface; this was done +historically to protect against discrepancies between user include +structure definitions and kernel definitions on Linux]. + +The POST (after) wrapper +------------------------ + +These are much easier. + +They just contain a POST_MEM_WRITE macro for each output argument. + + +Feedback +~~~~~~~~ + +If you find any problems please create a bugzilla report at +https://bugs.kde.org using the Valgrind product. + +Alternatively you can use the FreeBSD bugilla +https://bugs.freebsd.org + +Credits +~~~~~~~ + +Valgrind was originally ported to FreeBSD by Doug Rabson +in 2004. + +Paul Floyd (that's me), started looking at this project in late 2018, +took a long pause and then continued in earnest in January 2020. + +A big thanks to Nick Briggs for helping with the x86 version. + +Kyle Evans and Ed Maste for contributing patches and helping with the +integration with FreeBSD ports. + +Prior to 2018 many others have also contributed. + +Dimitry Andric +Simon Barner +Roman Bogorodskiy +Rebecca Cran +Bryan Drewery +Brian Fundakowski Feldman +Denis Generalov +Mikolaj Golub +Eugene Kilachkoff +Xin LI +Phil Longstaff +Pav Lucistnik +Conrad Meyer +Julien Nadeau +Frerich Raabe +Doug Rabson +Craig Rodrigues +Tom Russo +Stephen Sanders +Stanislav Sedov +Andrei V. Shetuhin +Niklas Sorensson +Ryan Stone +Jerry Toung +Yuri + diff --git a/cachegrind/tests/Makefile.am b/cachegrind/tests/Makefile.am index 571ae222a8..7eb20e294b 100644 --- a/cachegrind/tests/Makefile.am +++ b/cachegrind/tests/Makefile.am @@ -30,7 +30,9 @@ AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) # C ones +if !VGCONF_OS_IS_FREEBSD dlclose_LDADD = -ldl +endif if VGCONF_OS_IS_DARWIN myprint_so_LDFLAGS = $(AM_CFLAGS) -dynamic -dynamiclib -all_load -fpic else diff --git a/configure.ac b/configure.ac index 0398aafa1c..c05994516f 100755 --- a/configure.ac +++ b/configure.ac @@ -224,7 +224,7 @@ case "${host_cpu}" in ARCH_MAX="x86" ;; - x86_64) + x86_64|amd64) AC_MSG_RESULT([ok (${host_cpu})]) ARCH_MAX="amd64" ;; @@ -360,6 +360,57 @@ case "${host_os}" in ;; + *freebsd*) + AC_MSG_RESULT([ok (${host_os})]) + VGCONF_OS="freebsd" + AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x]) + AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x]) + AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1]) + AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2]) + AC_DEFINE([FREEBSD_13], 1300, [FREEBSD_VERS value for FreeBSD 13.x]) + AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x]) + + AC_MSG_CHECKING([for the kernel version]) + kernel=`uname -r` + + case "${kernel}" in + 10.*) + AC_MSG_RESULT([FreeBSD 10.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version]) + ;; + 11.*) + AC_MSG_RESULT([FreeBSD 11.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version]) + ;; + 12.*) + case "${kernel}" in + 12.[[0-1]]-*) + AC_MSG_RESULT([FreeBSD 12.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version]) + ;; + *) + AC_MSG_RESULT([FreeBSD 12.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version]) + ;; + esac + ;; + 13.*) + AC_MSG_RESULT([FreeBSD 13.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_13, [FreeBSD version]) + ;; + 14.*) + AC_MSG_RESULT([FreeBSD 14.x (${kernel})]) + AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version]) + ;; + *) + AC_MSG_RESULT([unsupported (${kernel})]) + AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x]) + ;; + esac + + DEFAULT_SUPP="freebsd.supp freebsd-helgrind.supp freebsd-drd.supp ${DEFAULT_SUPP}" + ;; + *darwin*) AC_MSG_RESULT([ok (${host_os})]) VGCONF_OS="darwin" @@ -660,6 +711,48 @@ case "$ARCH_MAX-$VGCONF_OS" in valt_load_address_pri_inner="0x38000000" AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) ;; + x86-freebsd) + VGCONF_ARCH_PRI="x86" + VGCONF_ARCH_SEC="" + VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD" + VGCONF_PLATFORM_SEC_CAPS="" + valt_load_address_pri_norml="0x38000000" + valt_load_address_pri_inner="0x28000000" + valt_load_address_sec_norml="0xUNSET" + valt_load_address_sec_inner="0xUNSET" + AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) + ;; + amd64-freebsd) + if test x$vg_cv_only64bit = xyes; then + VGCONF_ARCH_PRI="amd64" + VGCONF_ARCH_SEC="" + VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD" + VGCONF_PLATFORM_SEC_CAPS="" + elif test x$vg_cv_only32bit = xyes; then + VGCONF_ARCH_PRI="x86" + VGCONF_ARCH_SEC="" + VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD" + VGCONF_PLATFORM_SEC_CAPS="" + else + VGCONF_ARCH_PRI="amd64" + VGCONF_ARCH_SEC="x86" + VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD" + VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD" + fi + # These work with either base clang or ports installed gcc + # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc) + if test x$is_clang = xclang ; then + FLAG_32ON64="-B/usr/lib32" + else + GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null` + FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/" + fi + valt_load_address_pri_norml="0x38000000" + valt_load_address_pri_inner="0x28000000" + valt_load_address_sec_norml="0x38000000" + valt_load_address_sec_inner="0x28000000" + AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) + ;; # Darwin gets identified as 32-bit even when it supports 64-bit. # (Not sure why, possibly because 'uname' returns "i386"?) Just about # all Macs support both 32-bit and 64-bit, so we just build both. If @@ -860,12 +953,15 @@ esac AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86, test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \ + -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \ -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \ -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \ -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS ) AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \ -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \ -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS ) AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, @@ -918,7 +1014,12 @@ AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX, test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX) AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX, test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX) -AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN, +AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD, + test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \ + -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD) +AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, + test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD) +AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN, test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN) AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, @@ -945,12 +1046,20 @@ AM_CONDITIONAL(VGCONF_OS_IS_LINUX, -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX) +AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD, + test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD) AM_CONDITIONAL(VGCONF_OS_IS_DARWIN, test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN) AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS, test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \ -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS) +AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD, + test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN) # Sometimes, in the Makefile.am files, it's useful to know whether or not @@ -1068,6 +1177,14 @@ AC_EGREP_CPP([DARWIN_LIBC], [ ], GLIBC_VERSION="darwin") +AC_EGREP_CPP([FREEBSD_LIBC], [ +#include <sys/cdefs.h> +#if defined(__FreeBSD__) + FREEBSD_LIBC +#endif +], +GLIBC_VERSION="freebsd") + # not really a version check AC_EGREP_CPP([BIONIC_LIBC], [ #if defined(__ANDROID__) @@ -1159,6 +1276,11 @@ case "${GLIBC_VERSION}" in AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin]) # DEFAULT_SUPP set by kernel version check above. ;; + freebsd) + AC_MSG_RESULT(FreeBSD) + AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD]) + # DEFAULT_SUPP set by kernel version check above. + ;; bionic) AC_MSG_RESULT(Bionic) AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic]) @@ -1929,12 +2051,12 @@ case "${host_cpu}" in AC_MSG_CHECKING([if gcc accepts -m32]) safe_CFLAGS=$CFLAGS - CFLAGS="-m32 -Werror" + CFLAGS="${FLAG_32ON64} -m32 -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])], [ - FLAG_M32="-m32" + FLAG_M32="${FLAG_32ON64} -m32" AC_MSG_RESULT([yes]) ], [ FLAG_M32="" @@ -2273,6 +2395,7 @@ AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION]) AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE]) AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE]) AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION]) +AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED]) AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS]) AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY]) @@ -2656,7 +2779,7 @@ CFLAGS=$safe_CFLAGS AC_MSG_CHECKING([if gcc accepts -no-pie]) safe_CFLAGS=$CFLAGS -CFLAGS="-no-pie" +CFLAGS="-no-pie -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ return 0; @@ -2679,30 +2802,52 @@ CFLAGS=$safe_CFLAGS # will reside. -Ttext aligns just the .text section start (but not any # other section). # -# So test for -Ttext-segment which is supported by all bfd ld versions +# LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes" +# in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html +# The --image-base option (since version 6.0?) provides the semantics needed. +# -Ttext-segment generates an error, but -Ttext now more closely +# follows the GNU (bfd) ld's -Ttext. +# +# So test first for --image-base support, and if that fails then +# for -Ttext-segment which is supported by all bfd ld versions # and use that if it exists. If it doesn't exist it must be an older # version of gold and we can fall back to using -Ttext which has the # right semantics. -AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment]) - safe_CFLAGS=$CFLAGS -CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror" +AC_MSG_CHECKING([if the linker accepts -Wl,--image-base]) + +CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror" AC_LINK_IFELSE( [AC_LANG_SOURCE([int _start () { return 0; }])], [ linker_using_t_text="no" - AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"]) + AC_SUBST([FLAG_T_TEXT], ["--image-base"]) AC_MSG_RESULT([yes]) ], [ - linker_using_t_text="yes" - AC_SUBST([FLAG_T_TEXT], ["-Ttext"]) AC_MSG_RESULT([no]) + + AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment]) + + CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror" + + AC_LINK_IFELSE( + [AC_LANG_SOURCE([int _start () { return 0; }])], + [ + linker_using_t_text="no" + AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"]) + AC_MSG_RESULT([yes]) + ], [ + linker_using_t_text="yes" + AC_SUBST([FLAG_T_TEXT], ["-Ttext"]) + AC_MSG_RESULT([no]) + ]) ]) + CFLAGS=$safe_CFLAGS -# If the linker only supports -Ttext (not -Ttext-segment) then we will +# If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will # have to strip any build-id ELF NOTEs from the statically linked tools. # Otherwise the build-id NOTE might end up at the default load address. # (Pedantically if the linker is gold then -Ttext is fine, but newer @@ -2728,7 +2873,7 @@ AC_LINK_IFELSE( AC_MSG_RESULT([no]) ]) else -AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.]) +AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.]) AC_SUBST([FLAG_NO_BUILD_ID], [""]) fi CFLAGS=$safe_CFLAGS @@ -4515,6 +4660,7 @@ AC_PATH_PROG([MPI_CC], [mpicc], [mpicc], mflag_primary= if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \ -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ @@ -4522,6 +4668,7 @@ if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then mflag_primary=$FLAG_M32 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \ + -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \ -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \ @@ -4537,7 +4684,8 @@ mflag_secondary= if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \ -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \ -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \ - -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then + -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \ + -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then mflag_secondary=$FLAG_M32 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then mflag_secondary="$FLAG_M32 -arch i386" @@ -4558,6 +4706,9 @@ AC_SUBST(MPI_CC) AM_COND_IF([VGCONF_OS_IS_LINUX], [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic" LDFLAGS_MPI="-fpic -shared"]) +AM_COND_IF([VGCONF_OS_IS_FREEBSD], + [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic" + LDFLAGS_MPI="-fpic -shared"]) AM_COND_IF([VGCONF_OS_IS_DARWIN], [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic" LDFLAGS_MPI="-dynamic -dynamiclib -all_load"]) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 65d2c705ad..ee70cfde31 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -49,6 +49,11 @@ valgrind_SOURCES = \ launcher-linux.c \ m_debuglog.c endif +if VGCONF_OS_IS_FREEBSD +valgrind_SOURCES = \ + launcher-freebsd.c \ + m_debuglog.c +endif # for valgrind coregrind building, use the LTO versions, in case they differ from non lto versions AR = ${LTO_AR} @@ -92,6 +97,12 @@ endif if VGCONF_OS_IS_SOLARIS vgdb_SOURCES += vgdb-invoker-solaris.c endif +if VGCONF_OS_IS_FREEBSD +# As with Darwin, we don't have ptrace PTRACE_PEEKTEXT +# so we can't use vgdb-invoker-ptrace.c +# Need to find an alternative, like Solaris +vgdb_SOURCES += vgdb-invoker-none.c +endif vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) diff --git a/docs/Makefile.am b/docs/Makefile.am index e9d659d2ec..5c777a263a 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -113,7 +113,11 @@ valkyriedir = $(top_builddir)/docs/vg-html downloadsdir = $(top_builddir)/docs/downloads vgdir = $(top_builddir)/docs/valgrind +if VGCONF_OS_IS_FREEBSD +XML_CATALOG_FILES = /usr/local/share/xml/catalog +else XML_CATALOG_FILES = /etc/xml/catalog +endif # file to log print output to LOGFILE = print.log @@ -132,6 +136,7 @@ XSL_FO_STYLE = $(mylibdir)/vg-fo.xsl XSL_TEXT_STYLE = $(mylibdir)/vg-faq2txt.xsl XSL_WEBSITE_STYLE = $(mylibdir)/vg-html-website.xsl XSL_MAN_STYLES = \ + /usr/local/share/xsl/docbook/manpages/docbook.xsl \ /usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl \ /usr/share/xml/docbook/stylesheet/nwalsh/current/manpages/docbook.xsl \ /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am index 3889fb15e3..b53eeefebe 100644 --- a/drd/tests/Makefile.am +++ b/drd/tests/Makefile.am @@ -400,7 +400,6 @@ check_PROGRAMS = \ pth_inconsistent_cond_wait \ pth_mutex_reinit \ pth_process_shared_mutex \ - pth_uninitialized_cond \ recursive_mutex \ rwlock_race \ rwlock_test \ @@ -428,8 +427,12 @@ endif if HAVE_BUILTIN_ATOMIC_CXX check_PROGRAMS += \ - annotate_smart_pointer \ - tsan_unittest + annotate_smart_pointer +endif + +if !VGCONF_OS_IS_FREEBSD +check_PROGRAMS += tsan_unittest \ + pth_uninitialized_cond endif # clang 3.3 will generate errors about libstdc++ headers from @@ -477,6 +480,10 @@ if !VGCONF_OS_IS_DARWIN check_PROGRAMS += sem_wait endif +if VGCONF_OS_IS_FREEBSD +check_PROGRAMS += thread_name_freebsd +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @FLAG_W_EXTRA@ @FLAG_FALIGNED_NEW@ \ @@ -487,7 +494,9 @@ LDADD = -lpthread bug322621_SOURCES = bug322621.cpp concurrent_close_SOURCES = concurrent_close.cpp +if !VGCONF_OS_IS_FREEBSD dlopen_main_LDADD = -ldl +endif dlopen_lib_so_SOURCES = dlopen_lib.c dlopen_lib_so_CFLAGS = -fPIC dlopen_lib_so_LDFLAGS = -shared -fPIC diff --git a/freebsd-drd.supp b/freebsd-drd.supp new file mode 100644 index 0000000000..a3414b544a --- /dev/null +++ b/freebsd-drd.supp @@ -0,0 +1,170 @@ +# Suppressions for FreeBSD / DRD + +{ + DRD-LDRT + drd:ConflictingAccess + obj:/libexec/ld-elf*.so.1 +} +{ + DRD-PTHREAD-EXIT1 + drd:ConflictingAccess + ... + fun:pthread_exit +} +{ + DRD-PTHREAD_CREATE1 + drd:ConflictingAccess + ... + fun:pthread_create +} +{ + DRD-PTHREAD-EXIT2 + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + fun:pthread_exit +} +{ + DRD-PRINTF1 + drd:ConflictingAccess + fun:f*lockfile +} +{ + DRD-MANY1 + drd:ConflictingAccess + obj:/lib/libthr.so.3 + obj:/libexec/ld-elf*.so.1 +} +{ + DRD-MANY2 + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + obj:/libexec/ld-elf*.so.1 +} +{ + DRD-MANY3 + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + obj:/libexec/ld-elf*.so.1 +} +{ + DRD-UNWIND1 + drd:ConflictingAccess + ... + fun:dl_iterate_phdr + obj:*/lib*/libgcc_s.so.1 +} +{ + DRD-PTHREAD-DETACH1 + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + fun:pthread_detach +} +{ + DRD-LIBGOMP + drd:ConflictingAccess + obj:/usr/local/lib*/gcc*/libgomp.so.1.0.0 +} +{ + DRD-LIBOMP + drd:ConflictingAccess + obj:/usr/lib*/libomp.so +} +{ + DRD-LIBGOMP3 + drd:ConflictingAccess + fun:.omp_outlined* +} +{ + DRD-LIBGOMP4 + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + fun:pthread_setspecific +} +{ + DRD-UNWIND1 + drd:ConflictingAccess + fun:_Unwind_GetCFA + obj:*/lib*/libthr.so.3 + obj:*/lib*/libgcc_s.so.1 +} +{ + DRD-UNWIND2 + drd:ConflictingAccess + ... + fun:_Unwind_ForcedUnwind +} +{ + DRD-PTHREAD-ATTR1 + drd:ConflictingAccess + fun:pthread_attr_get_np +} +{ + DRD-PTHREAD-SETSPECIFIC + drd:ConflictingAccess + fun:pthread_setspecific +} +{ + DRD-MEMSET + drd:ConflictingAccess + fun:memset + obj:*/lib*/libthr.so.3 +} +{ + DRD-SET-POINTER + drd:ConflictingAccess + fun:_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE11set_pointerEPS1_ +} +{ + DRD-DL-ITERATE-PHDR + drd:ConflictingAccess + ... + obj:*/lib*/libthr.so.3 + obj:/libexec/ld-elf*.so.1 + fun:dl_iterate_phdr +} +{ + DRD-LIBGCC-S + drd:ConflictingAccess + obj:*/lib*/libgcc_s.so.1 + obj:*/lib*/libgcc_s.so.1 + obj:*/lib*/libgcc_s.so.1 + obj:*/lib*/libgcc_s.so.1 + obj:*/lib*/libgcc_s.so.1 + obj:*/lib*/libgcc_s.so.1 +} +{ + DRD-DLOPEN + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:dlopen +} +{ + DRD-LD-ELF + drd:ConflictingAccess + obj:*/lib*/libthr.so.3 + ... + obj:/libexec/ld-elf*.so.1 +} +{ + DRD-SNPRINTF + drd:ConflictingAccess + ... + obj:*/lib*/libc.so.7 + fun:snprintf +} +{ + DRD-FREEBSD122-OMP + drd:MutexErr + fun:pthread_mutex_destroy_intercept + fun:pthread_mutex_destroy + fun:_ZNSt3__15mutexD1Ev + fun:__cxa_finalize +} diff --git a/freebsd-helgrind.supp b/freebsd-helgrind.supp new file mode 100644 index 0000000000..d24ff859bf --- /dev/null +++ b/freebsd-helgrind.supp @@ -0,0 +1,162 @@ +# Suppressions for FreeBSD / Helgrind + +{ + HELGRIND-LIBTHR1 + Helgrind:Race + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-LIB-LDRT1 + Helgrind:Race + obj:/libexec/ld-elf*.so.1 +} +{ + HELGRIND-PTHREAD-EXIT0 + Helgrind:Race + fun:thr_exit + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-PTHREAD-EXIT1 + Helgrind:Race + fun:_pthread_exit_mask + fun:pthread_exit + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-PTHREAD-EXIT2 + Helgrind:Race + fun:__sys_thr_exit + fun:_pthread_exit_mask + fun:pthread_exit + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-PTHREAD-EXIT4 + Helgrind:Race + fun:_thr_try_gc + obj:*/lib*/libthr.so.3 + fun:pthread_join_WRK + fun:pthread_join +} +{ + HELGRIND-PTHREAD-EXIT5 + Helgrind:Race + fun:__sys_thr_exit + obj:*/lib*/libthr.so.3 + fun:_pthread_exit_mask + fun:pthread_exit + obj:/lib/libthr.so.3 +} +{ + HELGRIND-PTHREAD-BARRIER2 + Helgrind:Race + fun:pthread_barrier_init +} +# added PJF +{ + HELGRIND-EXIT1 + Helgrind:Race + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:__cxa_finalize + fun:exit +} +{ + HELGRIND-EXIT2 + Helgrind:Race + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:_rtld_error + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:__cxa_finalize + fun:exit +} +{ + HELGRIND-EDIT3 + Helgrind:Race + fun:_rtld_error + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:__cxa_finalize + fun:exit +} +{ + HELGRIND-EXIT3 + Helgrind:Race + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + fun:__cxa_finalize + fun:exit +} +# PJF not sure exactly what the cause of this is, but it looks like it is the +# tls used for pthread_self() with a conflict between pthread_create and +# mythread_wrapper which coverst create/join/exit +{ + HELGRIND-PTHREAD-CREATE1 + Helgrind:Race + obj:/libexec/ld-elf*.so.1 + fun:_rtld_allocate_tls + obj:*/lib*/libthr.so.3 + obj:*/lib*/libthr.so.3 + fun:pthread_create +} +{ + HELGRIND-PTHREAD-CREATE2 + Helgrind:Race + fun:memset + obj:*/lib*/libthr.so.3 + fun:pthread_create +} +# PJF again a pthread_self() hazard +{ + HELGRIND-PTHREAD-SELF1 + Helgrind:Race + fun:mythread_wrapper + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-SEM-CLOCKWAIT1 + Helgrind:Race + fun:sem_clockwait_np +} +{ + HELGRIND-UMTX-OP1 + Helgrind:Race + fun:_umtx_op +} +{ + HELGRIND-SEM-POST1 + Helgrind:Race + fun:sem_post +} +{ + HELGRIND-GCC-UNWIND1 + Helgrind:Race + obj:/lib/libgcc_s.so.1 +} +{ + HELGRIND-LIBC-PRINTF1 + Helgrind:Race + fun:flockfile +} +{ + HELGRIND-LIBC-PRINTF2 + Helgrind:Race + fun:funlockfile +} +{ + HELGRIND-MUTEX-LOCK1 + Helgrind:Race + fun:memset + obj:*/lib*/libthr.so.3 +} +{ + HELGRIND-LIBOMP + Helgrind:Race + obj:/usr/lib*/libomp.so +} diff --git a/freebsd.supp b/freebsd.supp new file mode 100644 index 0000000000..7345d713de --- /dev/null +++ b/freebsd.supp @@ -0,0 +1,51 @@ +# Suppressions for FreeBSD / Memcheck +#This is a workaround for a bug in rtld +{ + MEMCHECK-RTLD-32ON64 + Memcheck:Addr4 + fun:memcpy + fun:elf_aux_info +} +{ + MEMCHECK-RTLD-COND + Memcheck:Cond + obj:/libexec/ld-elf*.so.1 +} +{ + MEMCHECK-RTLD-32ON64-ADDR4 + Memcheck:Addr4 + obj:/libexec/ld-elf32.so.1 + obj:/libexec/ld-elf32.so.1 +} + +{ + MEMCHECK-LIBSTDC++-REACHABLE + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + obj:/usr/local/lib*/gcc9/libstdc++.so.* + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 + obj:/libexec/ld-elf*.so.1 +} +{ + MEMCHECK-LIBC-REACHABLE + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + obj:*/lib*/libc.so.7 + obj:*/lib*/libc.so.7 + obj:*/lib*/libc.so.7 + fun:vfprintf_l +} +# clang only, should check that this is not a genuine error +{ + MEMCHECK-POSIX-FADVISE + Memcheck:Cond + fun:posix_fadvise +} +{ + MEMCHECK-POSIX-FALLOCATE + Memcheck:Cond + fun:posix_fallocate +} diff --git a/gdbserver_tests/Makefile.am b/gdbserver_tests/Makefile.am index 1a5c51356a..e93ead322f 100644 --- a/gdbserver_tests/Makefile.am +++ b/gdbserver_tests/Makefile.am @@ -155,17 +155,20 @@ check_PROGRAMS = \ clean_after_fork \ fork_chain \ gone \ - main_pic \ passsigalrm \ self_invalidate \ sleepers \ t \ watchpoints +if !VGCONF_OS_IS_FREEBSD + check_PROGRAMS += main_pic + + main_pic_LDFLAGS = @FLAG_PIE@ + main_pic_CFLAGS = $(AM_CFLAGS) -fPIC +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) LDADD = -lpthread - -main_pic_LDFLAGS = @FLAG_PIE@ -main_pic_CFLAGS = $(AM_CFLAGS) -fPIC diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 38a087cdfc..9fe8082b94 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -36,6 +36,9 @@ endif if VGCONF_OS_IS_SOLARIS SUBDIRS += solaris endif +if VGCONF_OS_IS_FREEBSD +SUBDIRS += freebsd +endif # Platform-specific tests if VGCONF_PLATFORMS_INCLUDE_X86_LINUX @@ -53,6 +56,12 @@ endif if VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS SUBDIRS += amd64-solaris endif +if VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD +SUBDIRS += x86-freebsd +endif +if VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD +SUBDIRS += amd64-freebsd +endif DIST_SUBDIRS = x86 amd64 ppc32 ppc64 s390x linux \ darwin solaris x86-linux amd64-linux arm64-linux \ diff --git a/memcheck/tests/amd64-freebsd/filter_stderr b/memcheck/tests/amd64-freebsd/filter_stderr new file mode 100755 index 0000000000..a778e971fc --- /dev/null +++ b/memcheck/tests/amd64-freebsd/filter_stderr @@ -0,0 +1,3 @@ +#! /bin/sh + +../filter_stderr "$@" diff --git a/memcheck/tests/freebsd/filter_pts b/memcheck/tests/freebsd/filter_pts new file mode 100755 index 0000000000..81dd4f2041 --- /dev/null +++ b/memcheck/tests/freebsd/filter_pts @@ -0,0 +1,5 @@ +#! /bin/sh + +../filter_stderr "$@" | + +gsed 's/Open file descriptor.*/Open file descriptor .../' diff --git a/memcheck/tests/x86-freebsd/filter_stderr b/memcheck/tests/x86-freebsd/filter_stderr new file mode 100755 index 0000000000..a778e971fc --- /dev/null +++ b/memcheck/tests/x86-freebsd/filter_stderr @@ -0,0 +1,3 @@ +#! /bin/sh + +../filter_stderr "$@" diff --git a/mpi/Makefile.am b/mpi/Makefile.am index 471fee02a9..69b69aa925 100644 --- a/mpi/Makefile.am +++ b/mpi/Makefile.am @@ -40,6 +40,10 @@ if VGCONF_OS_IS_LINUX MPI_FLAG_M3264_PRI = $(AM_FLAG_M3264_PRI) MPI_FLAG_M3264_SEC = $(AM_FLAG_M3264_SEC) endif +if VGCONF_OS_IS_FREEBSD + MPI_FLAG_M3264_PRI = $(AM_FLAG_M3264_PRI) + MPI_FLAG_M3264_SEC = $(AM_FLAG_M3264_SEC) +endif if VGCONF_OS_IS_DARWIN MPI_FLAG_M3264_PRI = $(AM_FLAG_M3264_PRI) MPI_FLAG_M3264_SEC = $(AM_FLAG_M3264_SEC) diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index e4a12cadc3..617c92854d 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -47,6 +47,9 @@ endif if VGCONF_OS_IS_SOLARIS SUBDIRS += solaris endif +if VGCONF_OS_IS_FREEBSD +SUBDIRS += freebsd +endif # Platform-specific tests if VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX @@ -69,7 +72,7 @@ SUBDIRS += x86-solaris endif DIST_SUBDIRS = x86 amd64 ppc32 ppc64 arm arm64 s390x mips32 mips64 nanomips \ - linux darwin solaris amd64-linux x86-linux amd64-darwin \ + linux darwin solaris freebsd amd64-linux x86-linux amd64-darwin \ x86-darwin amd64-solaris x86-solaris scripts . dist_noinst_SCRIPTS = \ @@ -265,9 +268,12 @@ if HAVE_NESTED_FUNCTIONS endif # This doesn't appear to be compilable on Darwin. +if ! VGCONF_OS_IS_DARWIN_OR_FREEBSD + check_PROGRAMS += rlimit64_nofile +endif + if ! VGCONF_OS_IS_DARWIN - check_PROGRAMS += rlimit64_nofile \ - ppoll_alarm + check_PROGRAMS += ppoll_alarm endif # clang does not know -ansi @@ -328,9 +334,14 @@ pth_self_kill_LDADD = -lpthread pth_stackalign_LDADD = -lpthread pth_2sig_LDADD = -lpthread pth_term_signal_LDADD = -lpthread -res_search_LDADD = -lresolv -lpthread +if VGCONF_OS_IS_FREEBSD + res_search_LDADD = -lpthread + resolv_LDADD = -lpthread +else + res_search_LDADD = -lresolv -lpthread + resolv_LDADD = -lresolv -lpthread +endif resolv_CFLAGS = $(AM_CFLAGS) -resolv_LDADD = -lresolv -lpthread if VGCONF_OS_IS_SOLARIS resolv_CFLAGS += -U_REENTRANT endif @@ -366,7 +377,7 @@ else endif vgprintf_nvalgrind_SOURCES = vgprintf.c -vgprintf_nvalgrind_CFLAGS = -DNVALGRIND +vgprintf_nvalgrind_CFLAGS = ${AM_CFLAGS} -DNVALGRIND valgrind_cpp_test_SOURCES = valgrind_cpp_test.cpp valgrind_cpp_test_LDADD = -lstdc++ diff --git a/none/tests/freebsd/filter_stderr b/none/tests/freebsd/filter_stderr new file mode 100755 index 0000000000..a778e971fc --- /dev/null +++ b/none/tests/freebsd/filter_stderr @@ -0,0 +1,3 @@ +#! /bin/sh + +../filter_stderr "$@" |
|
From: Paul F. <pa...@so...> - 2021-10-06 21:19:35
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b128b20e66adbf00e87cf43e00e07ffe04f2ba8b commit b128b20e66adbf00e87cf43e00e07ffe04f2ba8b Author: Paul Floyd <pj...@wa...> Date: Wed Oct 6 22:58:15 2021 +0200 FreeBSD support, patch 7 tests directory configure.ac to generate tests/filter_discards and tests/filter_stderr_basic .gitignore to ignore these generated filters Diff: --- .gitignore | 2 ++ configure.ac | 4 ++++ tests/arch_test.c | 4 ++-- tests/filter_discards | 8 -------- tests/filter_discards.in | 11 ++++++++++ tests/filter_libc | 6 +++++- ...{filter_stderr_basic => filter_stderr_basic.in} | 24 ++++++++++++---------- tests/malloc.h | 10 ++++++--- tests/platform_test | 1 + 9 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 05b0b040b2..bb8578d680 100644 --- a/.gitignore +++ b/.gitignore @@ -2084,6 +2084,8 @@ # /tests/ /tests/*.dSYM +/tests/filter_discards +/tests/filter_stderr_basic /tests/.deps /tests/Makefile /tests/Makefile.in diff --git a/configure.ac b/configure.ac index 27400ad1e5..0398aafa1c 100755 --- a/configure.ac +++ b/configure.ac @@ -5060,6 +5060,10 @@ AC_CONFIG_FILES([coregrind/link_tool_exe_darwin], [chmod +x coregrind/link_tool_exe_darwin]) AC_CONFIG_FILES([coregrind/link_tool_exe_solaris], [chmod +x coregrind/link_tool_exe_solaris]) +AC_CONFIG_FILES([tests/filter_stderr_basic], + [chmod +x tests/filter_stderr_basic]) +AC_CONFIG_FILES([tests/filter_discards], + [chmod +x tests/filter_discards]) AC_OUTPUT cat<<EOF diff --git a/tests/arch_test.c b/tests/arch_test.c index f132ea3c03..37cc1bc76d 100644 --- a/tests/arch_test.c +++ b/tests/arch_test.c @@ -40,11 +40,11 @@ char* all_archs[] = { static Bool go(char* arch) { #if defined(VGP_x86_linux) || defined(VGP_x86_darwin) \ - || defined(VGP_x86_solaris) + || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) if ( 0 == strcmp( arch, "x86" ) ) return True; #elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \ - || defined(VGP_amd64_solaris) + || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) #if defined(VGA_SEC_x86) if ( 0 == strcmp( arch, "x86" ) ) return True; #endif diff --git a/tests/filter_discards b/tests/filter_discards deleted file mode 100755 index df98d4519c..0000000000 --- a/tests/filter_discards +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh - -dir=`dirname $0` - -# Remove number and position of discards -sed "s/discard [0-9]\+ ([0-9]\+ -> [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | - -$dir/filter_addresses diff --git a/tests/filter_discards.in b/tests/filter_discards.in new file mode 100755 index 0000000000..05e823687c --- /dev/null +++ b/tests/filter_discards.in @@ -0,0 +1,11 @@ +#! /bin/sh + +dir=`dirname $0` + +SED=@SED@ + + +# Remove number and position of discards +$SED "s/discard [0-9]\+ ([0-9]\+ -> [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | + +$dir/filter_addresses diff --git a/tests/filter_libc b/tests/filter_libc index 8eb9911cb0..4f097903a3 100755 --- a/tests/filter_libc +++ b/tests/filter_libc @@ -1,6 +1,7 @@ -#! /usr/bin/perl -w +#!/usr/bin/env perl use strict; +use warnings; while (<>) { @@ -20,6 +21,9 @@ while (<>) # libc, on some (eg. Darwin) it will be in the main executable. s/\(below main\) \(.+\)$/(below main)/; + # libc on x86 FreeBSD + s#_start1 \(src/lib/csu/i386/crt1_c.c.*#(below main)#; + # filter out the exact libc-start.c:### line number. (ppc64*) s/\(libc-start.c:[0-9]*\)$/(in \/...libc...)/; diff --git a/tests/filter_stderr_basic b/tests/filter_stderr_basic.in similarity index 72% rename from tests/filter_stderr_basic rename to tests/filter_stderr_basic.in index 4b6e4806be..fc1d19b35b 100755 --- a/tests/filter_stderr_basic +++ b/tests/filter_stderr_basic.in @@ -1,5 +1,7 @@ #! /bin/sh +SED=@SED@ + # This filter should be applied to *every* stderr result. It removes # Valgrind startup stuff and pid numbers. # @@ -18,14 +20,14 @@ perl -p -e 's/(==|--|\*\*)[0-9]{1,7}\1 //' | # Remove "Command: line". (If wrapping occurs, it won't remove the # subsequent lines...) -sed "/^Command: .*$/d" | +$SED "/^Command: .*$/d" | # Remove "WARNING: assuming toc 0x.." strings -sed "/^WARNING: assuming toc 0x*/d" | +$SED "/^WARNING: assuming toc 0x*/d" | # Remove "Using Valgrind-$VERSION and LibVEX..." line. # Tools have to filter their own line themselves. -sed "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | +$SED "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | # Anonymise line numbers in vg_replace_malloc.c, remove dirname if present perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c:...\)/" | @@ -34,13 +36,13 @@ perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c: perl -p -e "s/valgrind\.h:\d+\)/valgrind\.h:...\)/" | # Hide suppressed error counts -sed "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" | +$SED "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" | # Reduce some libc incompatibility $dir/filter_libc | # Remove line info out of order warnings -sed "/warning: line info addresses out of order/d" | +$SED "/warning: line info addresses out of order/d" | # Older bash versions print abnormal termination messages on the stderr # of the bash process. Newer bash versions redirect such messages properly. @@ -53,20 +55,20 @@ perl -n -e 'print if !/^(Memory fault|Killed) $/' | # Translate intercepted glibc functions back to their canonical name perl -p -e "s/: memcpy\@\@?GLIBC_[.1-9]+ \(vg_replace_strmem.c:.*?\)/: memcpy \(vg_replace_strmem.c:...\)/" | -sed -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | +$SED -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | # Remove any ": dumping core" message as the user might have a # limit set that prevents the core dump -sed "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/" | +$SED "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/" | # Remove the size in "The main thread stack size..." message. -sed "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | +$SED "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | # Remove the size in "10482464 bytes below stack pointer" message. -sed "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | +$SED "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | # Suppress warnings from incompatible debug info -sed '/warning: the debug information found in "[^"]*" does not match/d' | +$SED '/warning: the debug information found in "[^"]*" does not match/d' | # Suppress warnings from Dwarf reader -sed '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' +$SED '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' diff --git a/tests/malloc.h b/tests/malloc.h index 146790e3c7..a64abbf2d7 100644 --- a/tests/malloc.h +++ b/tests/malloc.h @@ -1,8 +1,12 @@ // Replacement for malloc.h which factors out platform differences. #include <stdlib.h> +#include "config.h" #if defined(VGO_darwin) # include <malloc/malloc.h> +#elif defined(VGO_freebsd) +# include <stdlib.h> +# include <malloc_np.h> #else # include <malloc.h> #endif @@ -14,7 +18,7 @@ __attribute__((unused)) static void* memalign16(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign, but its malloc is always 16-aligned anyway. posix_memalign((void **)&x, 16, szB); #else @@ -30,7 +34,7 @@ __attribute__((unused)) static void* memalign32(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 32, szB); #else @@ -46,7 +50,7 @@ __attribute__((unused)) static void* memalign64(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 64, szB); #else diff --git a/tests/platform_test b/tests/platform_test index 376f62eb41..c23a4f6453 100644 --- a/tests/platform_test +++ b/tests/platform_test @@ -16,6 +16,7 @@ all_platforms="$all_platforms arm-linux arm64-linux" all_platforms="$all_platforms s390x-linux mips32-linux mips64-linux" all_platforms="$all_platforms x86-darwin amd64-darwin" all_platforms="$all_platforms x86-solaris amd64-solaris" +all_platforms="$all_platforms x86-freebsd amd64-freebsd" if [ $# -ne 2 ] ; then echo "usage: platform_test <arch-type> <OS-type>" |
|
From: Paul F. <pa...@so...> - 2021-10-06 20:42:17
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e2073121004fa969961c056594fcbf327cb57217 commit e2073121004fa969961c056594fcbf327cb57217 Author: Paul Floyd <pj...@wa...> Date: Mon Oct 4 23:02:40 2021 +0200 FreeBSD support, patch 5 helgrind code Mainly intercepts and changes to conditional compilation Diff: --- helgrind/hg_errors.c | 2 +- helgrind/hg_intercepts.c | 189 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 182 insertions(+), 9 deletions(-) diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c index 58801b66f2..e612449b54 100644 --- a/helgrind/hg_errors.c +++ b/helgrind/hg_errors.c @@ -474,7 +474,7 @@ void HG_(record_error_Race) ( Thread* thr, XError xe; tl_assert( HG_(is_sane_Thread)(thr) ); -# if defined(VGO_linux) +# if defined(VGO_linux) || defined(VGO_freebsd) /* Skip any races on locations apparently in GOTPLT sections. This is said to be caused by ld.so poking PLT table entries (or whatever) when it writes the resolved address of a dynamically diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 2bc89f8a09..866efdbaa8 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -109,6 +109,12 @@ # error "Unknown platform/thread wrapping" #endif +#if defined(VGO_freebsd) +#define LIBC_FUNC(ret_ty, f, args...) \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)(args); \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)(args) +#endif + // Do a client request. These are macros rather than a functions so // as to avoid having an extra frame in stack traces. @@ -250,7 +256,9 @@ static const HChar* lame_strerror ( long err ) case EDEADLK: return "EDEADLK: Resource deadlock would occur"; case EOPNOTSUPP: return "EOPNOTSUPP: Operation not supported on " "transport endpoint"; /* honest, guv */ +#if !defined(VGO_freebsd) case ETIME: return "ETIME: Timer expired"; +#endif default: return "hg_intercepts.c: lame_strerror(): " "unhandled case -- please fix me!"; } @@ -404,6 +412,7 @@ static void* mythread_wrapper ( void* xargsV ) // glibc: pthread_create@@GLIBC_2.2.5 // darwin: pthread_create // darwin: pthread_create_suspended_np (trapped) +// FreeBSD: pthread_create // /* ensure this has its own frame, so as to make it more distinguishable in suppressions */ @@ -468,6 +477,12 @@ static int pthread_create_WRK(pthread_t *thread, const pthread_attr_t *attr, void *(*start) (void *), void *arg) { return pthread_create_WRK(thread, attr, start, arg); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucreate, // pthread_create + pthread_t *thread, const pthread_attr_t *attr, + void *(*start) (void *), void *arg) { + return pthread_create_WRK(thread, attr, start, arg); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucreate, // pthread_create pthread_t *thread, const pthread_attr_t *attr, @@ -549,6 +564,7 @@ static int thr_create_WRK(void *stk, size_t stksize, void *(*start)(void *), // darwin: pthread_join // darwin: pthread_join$NOCANCEL$UNIX2003 // darwin pthread_join$UNIX2003 +// FreeBSD: pthread_join __attribute__((noinline)) static int pthread_join_WRK(pthread_t thread, void** value_pointer) { @@ -580,6 +596,11 @@ static int pthread_join_WRK(pthread_t thread, void** value_pointer) pthread_t thread, void** value_pointer) { return pthread_join_WRK(thread, value_pointer); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZujoin, // pthread_join + pthread_t thread, void** value_pointer) { + return pthread_join_WRK(thread, value_pointer); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZujoinZa, // pthread_join* pthread_t thread, void** value_pointer) { @@ -770,6 +791,7 @@ void I_WRAP_SONAME_FNNAME_ZU #if !defined(VGO_solaris) // glibc: pthread_mutex_init // darwin: pthread_mutex_init +// FreeBSD: pthread_mutex_init PTH_FUNC(int, pthreadZumutexZuinit, // pthread_mutex_init pthread_mutex_t *mutex, pthread_mutexattr_t* attr) @@ -842,6 +864,7 @@ PTH_FUNC(int, mutexZuinit, // mutex_init // glibc: pthread_mutex_destroy // darwin: pthread_mutex_destroy // Solaris: mutex_destroy (pthread_mutex_destroy is a weak alias) +// FreeBSD: pthread_mutex_destroy __attribute__((noinline)) static int mutex_destroy_WRK(pthread_mutex_t *mutex) { @@ -876,7 +899,7 @@ static int mutex_destroy_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZudestroy, // pthread_mutex_destroy pthread_mutex_t *mutex) { return mutex_destroy_WRK(mutex); @@ -895,6 +918,7 @@ static int mutex_destroy_WRK(pthread_mutex_t *mutex) // glibc: pthread_mutex_lock // darwin: pthread_mutex_lock // Solaris: mutex_lock (pthread_mutex_lock is a weak alias) +// FreeBSD: pthread_mutex_lock __attribute__((noinline)) static int mutex_lock_WRK(pthread_mutex_t *mutex) { @@ -928,7 +952,7 @@ static int mutex_lock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZulock, // pthread_mutex_lock pthread_mutex_t *mutex) { return mutex_lock_WRK(mutex); @@ -973,6 +997,7 @@ PTH_FUNC(void, lmutexZulock, // lmutex_lock // glibc: pthread_mutex_trylock // darwin: pthread_mutex_trylock // Solaris: mutex_trylock (pthread_mutex_trylock is a weak alias) +// FreeBSD: pthread_mutext_trylock // // pthread_mutex_trylock. The handling needed here is very similar // to that for pthread_mutex_lock, except that we need to tell @@ -1014,7 +1039,7 @@ static int mutex_trylock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZutrylock, // pthread_mutex_trylock pthread_mutex_t *mutex) { return mutex_trylock_WRK(mutex); @@ -1033,6 +1058,7 @@ static int mutex_trylock_WRK(pthread_mutex_t *mutex) // glibc: pthread_mutex_timedlock // darwin: (doesn't appear to exist) // Solaris: pthread_mutex_timedlock +// FreeBSD: pthread_mutex_timedlock // // pthread_mutex_timedlock. Identical logic to pthread_mutex_trylock. __attribute__((noinline)) @@ -1089,6 +1115,7 @@ PTH_FUNC(int, pthreadZumutexZureltimedlock, // pthread_mutex_reltimedlock // glibc: pthread_mutex_unlock // darwin: pthread_mutex_unlock // Solaris: mutex_unlock (pthread_mutex_unlock is a weak alias) +// FreeBSD: pthread_mutex_unlock __attribute__((noinline)) static int mutex_unlock_WRK(pthread_mutex_t *mutex) { @@ -1118,7 +1145,7 @@ static int mutex_unlock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZuunlock, // pthread_mutex_unlock pthread_mutex_t *mutex) { return mutex_unlock_WRK(mutex); @@ -1176,6 +1203,7 @@ PTH_FUNC(void, lmutexZuunlock, // lmutex_unlock // darwin: pthread_cond_wait$NOCANCEL$UNIX2003 // darwin: pthread_cond_wait$UNIX2003 // Solaris: cond_wait (pthread_cond_wait is built atop of cond_wait) +// FreeBSD: pthread_cond_wait // __attribute__((noinline)) static int pthread_cond_wait_WRK(pthread_cond_t* cond, @@ -1238,6 +1266,11 @@ static int pthread_cond_wait_WRK(pthread_cond_t* cond, pthread_cond_t* cond, pthread_mutex_t* mutex) { return pthread_cond_wait_WRK(cond, mutex); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZuwait, // pthread_cond_wait + pthread_cond_t* cond, pthread_mutex_t* mutex) { + return pthread_cond_wait_WRK(cond, mutex); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZuwaitZa, // pthread_cond_wait* pthread_cond_t* cond, pthread_mutex_t* mutex) { @@ -1263,6 +1296,7 @@ static int pthread_cond_wait_WRK(pthread_cond_t* cond, // darwin: pthread_cond_timedwait_relative_np (trapped) // Solaris: cond_timedwait (pthread_cond_timedwait is built on cond_timedwait) // Solaris: cond_reltimedwait (pthread_cond_reltimedwait_np is built on this) +// FreeBSD: pthread_cond_timedwait // __attribute__((noinline)) static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, @@ -1338,6 +1372,12 @@ static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, struct timespec* abstime) { return pthread_cond_timedwait_WRK(cond, mutex, abstime, ETIMEDOUT); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZutimedwait, // pthread_cond_timedwait + pthread_cond_t* cond, pthread_mutex_t* mutex, + struct timespec* abstime) { + return pthread_cond_timedwait_WRK(cond, mutex, abstime, ETIMEDOUT); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZutimedwait, // pthread_cond_timedwait pthread_cond_t* cond, pthread_mutex_t* mutex, @@ -1377,6 +1417,7 @@ static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, // darwin: pthread_cond_signal // darwin: pthread_cond_signal_thread_np (don't intercept this) // Solaris: cond_signal (pthread_cond_signal is a weak alias) +// FreeBSD: pthread_cond_signal // __attribute__((noinline)) static int pthread_cond_signal_WRK(pthread_cond_t* cond) @@ -1413,6 +1454,11 @@ static int pthread_cond_signal_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_signal_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZusignal, // pthread_cond_signal + pthread_cond_t* cond) { + return pthread_cond_signal_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZusignal, // pthread_cond_signal pthread_cond_t* cond) { @@ -1434,6 +1480,7 @@ static int pthread_cond_signal_WRK(pthread_cond_t* cond) // glibc: pthread_cond_broadcast@@GLIBC_2.3.2 // darwin: pthread_cond_broadcast // Solaris: cond_broadcast (pthread_cond_broadcast is a weak alias) +// FreeBSD: pthread_cond_broadcast // // Note, this is pretty much identical, from a dependency-graph // point of view, with cond_signal, so the code is duplicated. @@ -1474,6 +1521,11 @@ static int pthread_cond_broadcast_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_broadcast_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZubroadcast, // pthread_cond_broadcast + pthread_cond_t* cond) { + return pthread_cond_broadcast_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZubroadcast, // pthread_cond_broadcast pthread_cond_t* cond) { @@ -1493,6 +1545,7 @@ static int pthread_cond_broadcast_WRK(pthread_cond_t* cond) // glibc: pthread_cond_init@@GLIBC_2.3.2 // darwin: pthread_cond_init // Solaris: cond_init (pthread_cond_init is built atop on this function) +// FreeBSD: pthread_cond_init // Easy way out: Handling of attr could have been messier. // It turns out that pthread_cond_init under linux ignores // all information in cond_attr, so do we. @@ -1530,6 +1583,11 @@ static int pthread_cond_init_WRK(pthread_cond_t* cond, pthread_condattr_t *cond_ pthread_cond_t* cond, pthread_condattr_t* cond_attr) { return pthread_cond_init_WRK(cond, cond_attr); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZuinit, // pthread_cond_init@* + pthread_cond_t* cond, pthread_condattr_t* cond_attr) { + return pthread_cond_init_WRK(cond, cond_attr); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZuinit, // pthread_cond_init pthread_cond_t* cond, pthread_condattr_t * cond_attr) { @@ -1578,6 +1636,7 @@ PTH_FUNC(int, condZuinit, // cond_init // glibc: pthread_cond_destroy@GLIBC_2.0 // darwin: pthread_cond_destroy // Solaris: cond_destroy (pthread_cond_destroy is a weak alias) +// FreeBSD: pthread_cond_destroy // __attribute__((noinline)) static int pthread_cond_destroy_WRK(pthread_cond_t* cond) @@ -1620,6 +1679,11 @@ static int pthread_cond_destroy_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_destroy_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZudestroy, // pthread_cond_destroy@* + pthread_cond_t* cond) { + return pthread_cond_destroy_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZudestroy, // pthread_cond_destroy pthread_cond_t* cond) { @@ -1656,6 +1720,7 @@ static int pthread_cond_destroy_WRK(pthread_cond_t* cond) // glibc: pthread_barrier_init // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_init +// FreeBSD: pthread_barrier_init PTH_FUNC(int, pthreadZubarrierZuinit, // pthread_barrier_init pthread_barrier_t* bar, pthread_barrierattr_t* attr, unsigned long count) @@ -1693,6 +1758,7 @@ PTH_FUNC(int, pthreadZubarrierZuinit, // pthread_barrier_init // glibc: pthread_barrier_wait // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_wait +// FreeBSD: pthread_barrier_wait PTH_FUNC(int, pthreadZubarrierZuwait, // pthread_barrier_wait pthread_barrier_t* bar) { @@ -1731,6 +1797,7 @@ PTH_FUNC(int, pthreadZubarrierZuwait, // pthread_barrier_wait // glibc: pthread_barrier_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_destroy +// FreeBSD: pthread_barrier_destroy PTH_FUNC(int, pthreadZubarrierZudestroy, // pthread_barrier_destroy pthread_barrier_t* bar) { @@ -1789,6 +1856,8 @@ PTH_FUNC(int, pthreadZubarrierZudestroy, // pthread_barrier_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_spin_init // Solaris: pthread_spin_unlock +// FreeBSD: pthread_spin_init +// FreeBSD: pthread_spin_unlock __attribute__((noinline)) static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, int pshared) { @@ -1826,6 +1895,16 @@ static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, /* this is never actually called */ return pthread_spin_init_or_unlock_WRK(lock, 0/*pshared*/); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init + pthread_spinlock_t* lock, int pshared) { + return pthread_spin_init_or_unlock_WRK(lock, pshared); + } + PTH_FUNC(int, pthreadZuspinZuunlock, // pthread_spin_unlock@* + pthread_spinlock_t* lock) { + /* this is never actually called */ + return pthread_spin_init_or_unlock_WRK(lock, 0/*pshared*/); + } #elif defined(VGO_darwin) #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init @@ -1845,6 +1924,7 @@ static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, // glibc: pthread_spin_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_spin_destroy +// FreeBSD: pthread_spin_destroy __attribute__((noinline)) static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) { @@ -1870,7 +1950,7 @@ static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZudestroy, // pthread_spin_destroy pthread_spinlock_t *lock) { return pthread_spin_destroy_WRK(lock); @@ -1890,6 +1970,7 @@ static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) // glibc: pthread_spin_lock // darwin: (doesn't appear to exist) // Solaris: pthread_spin_lock +// FreeBSD: pthread_spin_lock __attribute__((noinline)) static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) { @@ -1923,7 +2004,7 @@ static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZulock, // pthread_spin_lock pthread_spinlock_t *lock) { return pthread_spin_lock_WRK(lock); @@ -1943,6 +2024,7 @@ static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) // glibc: pthread_spin_trylock // darwin: (doesn't appear to exist) // Solaris: pthread_spin_trylock +// FreeBSD: pthread_spin_trylock __attribute__((noinline)) static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) { @@ -1977,7 +2059,7 @@ static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZutrylock, // pthread_spin_trylock pthread_spinlock_t *lock) { return pthread_spin_trylock_WRK(lock); @@ -2019,6 +2101,7 @@ static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) // darwin: pthread_rwlock_init // darwin: pthread_rwlock_init$UNIX2003 // Solaris: rwlock_init (pthread_rwlock_init is built atop of rwlock_init) +// FreeBSD: pthread_rwlock_init __attribute__((noinline)) static int pthread_rwlock_init_WRK(pthread_rwlock_t *rwl, pthread_rwlockattr_t* attr) @@ -2050,6 +2133,12 @@ static int pthread_rwlock_init_WRK(pthread_rwlock_t *rwl, pthread_rwlockattr_t* attr) { return pthread_rwlock_init_WRK(rwl, attr); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuinit, // pthread_rwlock_init + pthread_rwlock_t *rwl, + pthread_rwlockattr_t* attr) { + return pthread_rwlock_init_WRK(rwl, attr); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuinitZa, // pthread_rwlock_init* pthread_rwlock_t *rwl, @@ -2099,6 +2188,7 @@ PTH_FUNC(int, rwlockZuinit, // rwlock_init // darwin: pthread_rwlock_destroy // darwin: pthread_rwlock_destroy$UNIX2003 // Solaris: rwlock_destroy (pthread_rwlock_destroy is a weak alias) +// FreeBSD: pthread_rwlock_destroy // __attribute__((noinline)) static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) @@ -2129,6 +2219,11 @@ static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) pthread_rwlock_t *rwl) { return pthread_rwlock_destroy_WRK(rwl); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZudestroy, // pthread_rwlock_destroy + pthread_rwlock_t *rwl) { + return pthread_rwlock_destroy_WRK(rwl); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZudestroyZa, // pthread_rwlock_destroy* pthread_rwlock_t *rwl) { @@ -2149,6 +2244,7 @@ static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) // darwin: pthread_rwlock_wrlock // darwin: pthread_rwlock_wrlock$UNIX2003 // Solaris: rw_wrlock (pthread_rwlock_wrlock is a weak alias) +// FreeBSD: pthread_rwlock_wrlock // __attribute__((noinline)) static int pthread_rwlock_wrlock_WRK(pthread_rwlock_t* rwlock) @@ -2183,6 +2279,11 @@ static int pthread_rwlock_wrlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_wrlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuwrlock, // pthread_rwlock_wrlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_wrlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuwrlockZa, // pthread_rwlock_wrlock* pthread_rwlock_t* rwlock) { @@ -2229,6 +2330,7 @@ PTH_FUNC(void, lrwZuwrlock, // lrw_wrlock // darwin: pthread_rwlock_rdlock // darwin: pthread_rwlock_rdlock$UNIX2003 // Solaris: rw_rdlock (pthread_rwlock_rdlock is a weak alias) +// FreeBSD: pthread_rwlock_rdlock // __attribute__((noinline)) static int pthread_rwlock_rdlock_WRK(pthread_rwlock_t* rwlock) @@ -2263,6 +2365,11 @@ static int pthread_rwlock_rdlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_rdlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZurdlock, // pthread_rwlock_rdlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_rdlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZurdlockZa, // pthread_rwlock_rdlock* pthread_rwlock_t* rwlock) { @@ -2309,6 +2416,7 @@ PTH_FUNC(void, lrwZurdlock, // lrw_rdlock // darwin: pthread_rwlock_trywrlock // darwin: pthread_rwlock_trywrlock$UNIX2003 // Solaris: rw_trywrlock (pthread_rwlock_trywrlock is a weak alias) +// FreeBSD: pthread_rwlock_trywrlock // __attribute__((noinline)) static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) @@ -2349,6 +2457,11 @@ static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_trywrlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZutrywrlock, // pthread_rwlock_trywrlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_trywrlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZutrywrlockZa, // pthread_rwlock_trywrlock* pthread_rwlock_t* rwlock) { @@ -2369,6 +2482,7 @@ static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) // darwin: pthread_rwlock_tryrdlock // darwin: pthread_rwlock_tryrdlock$UNIX2003 // Solaris: rw_tryrdlock (pthread_rwlock_tryrdlock is a weak alias) +// FreeBSD: pthread_rwlock_tryrdlock // __attribute__((noinline)) static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) @@ -2410,6 +2524,11 @@ static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_tryrdlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZutryrdlock, // pthread_rwlock_tryrdlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_tryrdlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZutryrdlockZa, // pthread_rwlock_tryrdlock* pthread_rwlock_t* rwlock) { @@ -2430,6 +2549,7 @@ static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) // darwin: Unhandled // Solaris: pthread_rwlock_timedrdlock // Solaris: pthread_rwlock_reltimedrdlock_np +// FreeBSD: pthread_rwlock_timedrdlock // __attribute__((noinline)) __attribute__((unused)) static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, @@ -2462,6 +2582,12 @@ static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, } #if defined(VGO_linux) #elif defined(VGO_darwin) +#elif defined(VGO_freebsd) +PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock + pthread_rwlock_t *rwlock, + const struct timespec *timeout) { + return pthread_rwlock_timedrdlock_WRK(rwlock, timeout); +} #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock pthread_rwlock_t *rwlock, @@ -2483,6 +2609,7 @@ static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, // darwin: Unhandled // Solaris: pthread_rwlock_timedwrlock // Solaris: pthread_rwlock_reltimedwrlock_np +// FreeBSD: pthread_rwlock_timedwrlock // __attribute__((noinline)) __attribute__((unused)) static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, @@ -2515,6 +2642,12 @@ static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, } #if defined(VGO_linux) #elif defined(VGO_darwin) +#elif defined(VGO_freebsd) +PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock + pthread_rwlock_t *rwlock, + const struct timespec *timeout) { + return pthread_rwlock_timedwrlock_WRK(rwlock, timeout); +} #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock pthread_rwlock_t *rwlock, @@ -2536,6 +2669,7 @@ static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, // darwin: pthread_rwlock_unlock // darwin: pthread_rwlock_unlock$UNIX2003 // Solaris: rw_unlock (pthread_rwlock_unlock is a weak alias) +// FreeBSD: pthread_rwlock_unlock __attribute__((noinline)) static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) { @@ -2567,6 +2701,11 @@ static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_unlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuunlock, // pthread_rwlock_unlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_unlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuunlockZa, // pthread_rwlock_unlock* pthread_rwlock_t* rwlock) { @@ -2615,6 +2754,7 @@ static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) // glibc: sem_init@GLIBC_2.0 // darwin: sem_init // Solaris: sema_init (sem_init is built on top of sem_init) +// FreeBSD: sem_init (libc) // #if !defined(VGO_solaris) __attribute__((noinline)) @@ -2655,7 +2795,12 @@ static int sem_init_WRK(sem_t* sem, int pshared, unsigned long value) sem_t* sem, int pshared, unsigned long value) { return sem_init_WRK(sem, pshared, value); } -#else +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZuinit, // sem_init + sem_t* sem, int pshared, unsigned long value) { + return sem_init_WRK(sem, pshared, value); + } + #else # error "Unsupported OS" #endif @@ -2700,6 +2845,7 @@ PTH_FUNC(int, semaZuinit, // sema_init // glibc: sem_destroy@@GLIBC_2.2.5 // darwin: sem_destroy // Solaris: sema_destroy (sem_destroy is built on top of sema_destroy) +// FreeBSD: sem_destroy (libc) __attribute__((noinline)) static int sem_destroy_WRK(sem_t* sem) { @@ -2737,6 +2883,11 @@ static int sem_destroy_WRK(sem_t* sem) sem_t* sem) { return sem_destroy_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZudestroy, // sem_destroy + sem_t* sem) { + return sem_destroy_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZudestroy, // sema_destroy sem_t *sem) { @@ -2755,6 +2906,7 @@ static int sem_destroy_WRK(sem_t* sem) // darwin: sem_wait$NOCANCEL$UNIX2003 // darwin: sem_wait$UNIX2003 // Solaris: sema_wait (sem_wait is built on top of sema_wait) +// FreeBSD: sem_wait (libc) // /* wait: decrement semaphore - acquire lockage */ __attribute__((noinline)) @@ -2801,6 +2953,10 @@ static int sem_wait_WRK(sem_t* sem) PTH_FUNC(int, semZuwaitZDZa, sem_t* sem) { /* sem_wait$* */ return sem_wait_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZuwait, sem_t* sem) { /* sem_wait */ + return sem_wait_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZuwait, sem_t *sem) { /* sema_wait */ return sem_wait_WRK(sem); @@ -2816,6 +2972,7 @@ static int sem_wait_WRK(sem_t* sem) // glibc: sem_post@@GLIBC_2.1 // darwin: sem_post // Solaris: sema_post (sem_post is built on top of sema_post) +// FreeBSD: sem_post (libc) // /* post: increment semaphore - release lockage */ __attribute__((noinline)) @@ -2859,6 +3016,10 @@ static int sem_post_WRK(sem_t* sem) PTH_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ return sem_post_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ + return sem_post_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZupost, sem_t *sem) { /* sema_post */ return sem_post_WRK(sem); @@ -2872,10 +3033,17 @@ static int sem_post_WRK(sem_t* sem) // glibc: sem_open // darwin: sem_open // Solaris: sem_open +// FreeBSD: sem_open // +#if defined(VGO_freebsd) +LIBC_FUNC(sem_t*, semZuopen, + const char* name, long oflag, + long mode, unsigned long value) +#else PTH_FUNC(sem_t*, semZuopen, const char* name, long oflag, long mode, unsigned long value) +#endif { /* A copy of sem_init_WRK (more or less). Is this correct? */ OrigFn fn; @@ -2911,7 +3079,12 @@ PTH_FUNC(sem_t*, semZuopen, // glibc: sem_close // darwin: sem_close // Solaris: sem_close +// FreeBSD: sem_close +#if defined (VGO_freebsd) +LIBC_FUNC(int, sem_close, sem_t* sem) +#else PTH_FUNC(int, sem_close, sem_t* sem) +#endif { OrigFn fn; int ret; |
|
From: Paul F. <pa...@so...> - 2021-10-06 20:16:18
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7074904a377a52c76cbc8feaf618fa31b8a663b7 commit 7074904a377a52c76cbc8feaf618fa31b8a663b7 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 19:49:08 2021 +0200 FreeBSD support, patch 4 DRD code Mainly just intercepts, but also a hairy fix for early acces to pthread_self() Diff: --- drd/drd_main.c | 2 +- drd/drd_pthread_intercepts.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drd/drd_main.c b/drd/drd_main.c old mode 100644 new mode 100755 index 2f2279e52d..4a71eebb5f --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -744,7 +744,7 @@ void drd__atfork_child(ThreadId tid) static void DRD_(post_clo_init)(void) { -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /* fine */ #else VG_(printf)("\nWARNING: DRD has not yet been tested on this operating system.\n\n"); diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 28c0de78bc..8b44543645 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -57,6 +57,10 @@ #include "drd_clientreq.h" #include "pub_tool_redir.h" /* VG_WRAP_FUNCTION_ZZ() */ +#if defined(VGO_freebsd) +#include <dlfcn.h> +#endif + #if defined(VGO_solaris) /* * Solaris usually provides pthread_* functions on top of Solaris threading @@ -168,6 +172,11 @@ static int never_true; fflush(stdout); \ return pth_func_result; \ } +#elif defined(VG_WRAP_THREAD_FUNCTION_LIBPTHREAD_ONLY) +#define PTH_FUNC(ret_ty, zf, implf, argl_decl, argl) \ +ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBPTHREAD_SONAME,zf) argl_decl; \ +ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBPTHREAD_SONAME,zf) argl_decl \ +{ return implf argl; } #elif defined(VG_WRAP_THREAD_FUNCTION_LIBC_ONLY) #define PTH_FUNC(ret_ty, zf, implf, argl_decl, argl) \ ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl; \ @@ -185,6 +194,13 @@ static int never_true; # error "Unknown platform/thread wrapping" #endif +#if defined(VGO_freebsd) +#define LIBC_FUNC(ret_ty, zf, implf, argl_decl, argl) \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl; \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl \ + { return implf argl; } +#endif + /** * Macro for generating three Valgrind interception functions: one with the * Z-encoded name zf, one with ZAZa ("@*") appended to the name zf and one @@ -252,6 +268,27 @@ static void DRD_(sema_up)(DrdSema* sema); */ static void DRD_(init)(void) { +#if defined(VGO_freebsd) + { + /* + * On FreeBSD, pthead functions are all in libthr.so + * However libc.so contains stubs. In this ctor function, + * calling DRD_(set_pthread_id)() results in a call to + * pthread_self() resolving to the libc.so stub which + * returns a junk value for the tid. Subsequent calls + * to pthread_create() then also cause calls to + * DRD_(set_pthread_id)(), but this time with pthread_self() + * resolving to the good libthr.so version (since this is later + * and libthr.so has been loaded). That causes an assert + * since we expect the tid to either be INVALID_POSIX_THREADID + * or the same as the current tid, and the junk value + * is neither. So we force loading of libthr.so, which + * avoids this junk tid value. + */ + dlclose(dlopen("/lib/libthr.so.3", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE)); + } +#endif + DRD_(check_threading_library)(); DRD_(set_pthread_id)(); #if defined(VGO_solaris) @@ -1352,8 +1389,13 @@ int sem_init_intercept(sem_t *sem, int pshared, unsigned int value) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuinit, sem_init_intercept, + (sem_t *sem, int pshared, unsigned int value), (sem, pshared, value)); +#else PTH_FUNCS(int, semZuinit, sem_init_intercept, (sem_t *sem, int pshared, unsigned int value), (sem, pshared, value)); +#endif #if defined(VGO_solaris) static __always_inline @@ -1390,7 +1432,12 @@ int sem_destroy_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); +#endif + #if defined(VGO_solaris) PTH_FUNCS(int, semaZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1414,9 +1461,15 @@ sem_t* sem_open_intercept(const char *name, int oflag, mode_t mode, return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(sem_t *, semZuopen, sem_open_intercept, + (const char *name, int oflag, mode_t mode, unsigned int value), + (name, oflag, mode, value)); +#else PTH_FUNCS(sem_t *, semZuopen, sem_open_intercept, (const char *name, int oflag, mode_t mode, unsigned int value), (name, oflag, mode, value)); +#endif static __always_inline int sem_close_intercept(sem_t *sem) { @@ -1431,7 +1484,11 @@ static __always_inline int sem_close_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); +#endif static __always_inline int sem_wait_intercept(sem_t *sem) { @@ -1446,7 +1503,12 @@ static __always_inline int sem_wait_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); +#endif + #if defined(VGO_solaris) PTH_FUNCS(int, semaZuwait, sem_wait_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1464,7 +1526,11 @@ static __always_inline int sem_trywait_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1483,9 +1549,15 @@ int sem_timedwait_intercept(sem_t *sem, const struct timespec *abs_timeout) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZutimedwait, sem_timedwait_intercept, + (sem_t *sem, const struct timespec *abs_timeout), + (sem, abs_timeout)); +#else PTH_FUNCS(int, semZutimedwait, sem_timedwait_intercept, (sem_t *sem, const struct timespec *abs_timeout), (sem, abs_timeout)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZutimedwait, sem_timedwait_intercept, (sem_t *sem, const struct timespec *timeout), @@ -1508,7 +1580,11 @@ static __always_inline int sem_post_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZupost, sem_post_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ |
|
From: Paul F. <pa...@so...> - 2021-10-06 19:25:50
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7774acbc9c9c4caac2e6e2400635ddde667af6c7 commit 7774acbc9c9c4caac2e6e2400635ddde667af6c7 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 19:02:04 2021 +0200 FreeBSD support, patch 3 include directory New FreeBSD specific headers SONAMES for FreeBSD libraries Diff: --- include/Makefile.am | 6 + include/pub_tool_aspacemgr.h | 3 + include/pub_tool_basics.h | 36 + include/pub_tool_basics_asm.h | 2 +- include/pub_tool_libcproc.h | 2 +- include/pub_tool_libcsetjmp.h | 4 +- include/pub_tool_machine.h | 4 +- include/pub_tool_options.h | 2 +- include/pub_tool_redir.h | 20 +- include/pub_tool_vki.h | 2 + include/pub_tool_vkiscnums.h | 1 - include/pub_tool_vkiscnums_asm.h | 3 + include/valgrind.h | 13 +- include/vki/vki-amd64-freebsd.h | 220 ++ include/vki/vki-freebsd.h | 3077 +++++++++++++++++++++++++ include/vki/vki-machine-types-amd64-freebsd.h | 75 + include/vki/vki-machine-types-x86-freebsd.h | 75 + include/vki/vki-scnums-freebsd.h | 657 ++++++ include/vki/vki-x86-freebsd.h | 247 ++ 19 files changed, 4435 insertions(+), 14 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index 05cec97898..972d394b8f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -47,9 +47,12 @@ nobase_pkginclude_HEADERS = \ pub_tool_xtmemory.h \ valgrind.h \ vki/vki-linux.h \ + vki/vki-freebsd.h \ vki/vki-darwin.h \ vki/vki-solaris.h \ vki/vki-solaris-repcache.h \ + vki/vki-machine-types-amd64-freebsd.h \ + vki/vki-machine-types-x86-freebsd.h \ vki/vki-posixtypes-amd64-linux.h \ vki/vki-posixtypes-arm64-linux.h \ vki/vki-posixtypes-ppc32-linux.h \ @@ -65,6 +68,8 @@ nobase_pkginclude_HEADERS = \ vki/vki-ppc32-linux.h \ vki/vki-ppc64-linux.h \ vki/vki-x86-linux.h \ + vki/vki-amd64-freebsd.h \ + vki/vki-x86-freebsd.h \ vki/vki-arm-linux.h \ vki/vki-s390x-linux.h \ vki/vki-mips32-linux.h \ @@ -75,6 +80,7 @@ nobase_pkginclude_HEADERS = \ vki/vki-scnums-ppc32-linux.h \ vki/vki-scnums-ppc64-linux.h \ vki/vki-scnums-x86-linux.h \ + vki/vki-scnums-freebsd.h \ vki/vki-scnums-arm-linux.h \ vki/vki-scnums-s390x-linux.h \ vki/vki-scnums-mips32-linux.h \ diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h index ccd143bec8..4466345490 100644 --- a/include/pub_tool_aspacemgr.h +++ b/include/pub_tool_aspacemgr.h @@ -110,6 +110,9 @@ typedef Bool hasT; // True --> translations have (or MAY have) // been taken from this segment Bool isCH; // True --> is client heap (SkAnonC ONLY) +#if defined(VGO_freebsd) + Bool isFF; // True --> is a fixed file mapping +#endif } NSegment; diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index d1119e1efa..d22a425238 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -102,6 +102,8 @@ typedef Word PtrdiffT; // 32 64 // always a signed 64-bit int. So we defined our own Off64T as well. #if defined(VGO_linux) || defined(VGO_solaris) typedef Word OffT; // 32 64 +#elif defined(VGO_freebsd) +typedef Long OffT; // 64 64 #elif defined(VGO_darwin) typedef Long OffT; // 64 64 #else @@ -225,6 +227,19 @@ typedef SysResMode _mode; } SysRes; +#elif defined(VGO_freebsd) +typedef + struct { + UWord _val; + UWord _val2; + Bool _isError; +#if defined(VGP_amd64_freebsd) + char padding[7]; +#else + char padding[3]; +#endif + } + SysRes; #elif defined(VGO_solaris) typedef @@ -306,6 +321,27 @@ static inline Bool sr_EQ ( UInt sysno, SysRes sr1, SysRes sr2 ) { && sr1._isError == sr2._isError; } +#elif defined(VGO_freebsd) + +static inline Bool sr_isError ( SysRes sr ) { + return sr._isError; +} +static inline UWord sr_Res ( SysRes sr ) { + return sr._isError ? 0 : sr._val; +} +static inline UWord sr_ResHI ( SysRes sr ) { + return sr._isError ? 0 : sr._val2; +} +static inline UWord sr_Err ( SysRes sr ) { + return sr._isError ? sr._val : 0; +} +static inline Bool sr_EQ ( UInt sysno, SysRes sr1, SysRes sr2 ) { + return sr_Res(sr1) == sr_Res(sr2) + && sr_ResHI(sr1) == sr_ResHI(sr2) + && ((sr_isError(sr1) && sr_isError(sr2)) + || (!sr_isError(sr1) && !sr_isError(sr2))); +} + #elif defined(VGO_darwin) static inline Bool sr_isError ( SysRes sr ) { diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h index 83ac2e4c79..894fd1f5f0 100644 --- a/include/pub_tool_basics_asm.h +++ b/include/pub_tool_basics_asm.h @@ -46,7 +46,7 @@ #define VGAPPEND(str1,str2) str1##str2 -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # define VG_(str) VGAPPEND( vgPlain_, str) # define ML_(str) VGAPPEND( vgModuleLocal_, str) #elif defined(VGO_darwin) diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h index 73d7eca68c..f5d48eae74 100644 --- a/include/pub_tool_libcproc.h +++ b/include/pub_tool_libcproc.h @@ -103,7 +103,7 @@ extern UInt VG_(read_millisecond_timer) ( void ); extern Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz); -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) /* Get the clock value as specified by clk_id. Asserts if unsuccesful. */ extern void VG_(clock_gettime)(struct vki_timespec *ts, vki_clockid_t clk_id); # elif defined(VGO_darwin) diff --git a/include/pub_tool_libcsetjmp.h b/include/pub_tool_libcsetjmp.h index 03da232e44..6b278d285b 100644 --- a/include/pub_tool_libcsetjmp.h +++ b/include/pub_tool_libcsetjmp.h @@ -90,7 +90,7 @@ void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); #elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) || \ - defined(VGP_amd64_solaris) + defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) #define VG_MINIMAL_JMP_BUF(_name) ULong _name [16+1] __attribute__((returns_twice)) @@ -100,7 +100,7 @@ void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); #elif defined(VGP_x86_linux) || defined(VGP_x86_darwin) || \ - defined(VGP_x86_solaris) + defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) #define VG_MINIMAL_JMP_BUF(_name) UInt _name [8+1] __attribute__((returns_twice)) diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h old mode 100644 new mode 100755 index 150b975f59..9bdd4f5143 --- a/include/pub_tool_machine.h +++ b/include/pub_tool_machine.h @@ -32,14 +32,14 @@ #include "pub_tool_basics.h" // ThreadID #include "libvex.h" // VexArchInfo -#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) +#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) # define VG_MIN_INSTR_SZB 1 // min length of native instruction # define VG_MAX_INSTR_SZB 16 // max length of native instruction # define VG_CLREQ_SZB 14 // length of a client request, may // be larger than VG_MAX_INSTR_SZB # define VG_STACK_REDZONE_SZB 0 // number of addressable bytes below %RSP -#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) +#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) # define VG_MIN_INSTR_SZB 1 # define VG_MAX_INSTR_SZB 16 # define VG_CLREQ_SZB 19 diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index e2a896d675..1879226e80 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -163,7 +163,7 @@ extern void VG_(list_clo)(const HChar *qq_option); val, \ &(qq_var))) { \ VG_(fmsg_bad_option)(qq_arg, "%s is an invalid %s set\n", \ - val, qq_option+2); \ + val, &qq_option[2]); \ res = False; } \ res; })) diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h index 2e0365438e..f88d3b571f 100644 --- a/include/pub_tool_redir.h +++ b/include/pub_tool_redir.h @@ -241,7 +241,7 @@ /* --- Soname of the standard C library. --- */ -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # if defined(MUSL_LIBC) # define VG_Z_LIBC_SONAME libcZdZa // libc.* #else @@ -269,7 +269,7 @@ #endif -/* --- Soname of the GNU C++ library. --- */ +/* --- Sonames of the GNU C++ library. --- */ // Valid on all platforms(?) #define VG_Z_LIBSTDCXX_SONAME libstdcZpZpZa // libstdc++* @@ -283,6 +283,8 @@ #if defined(VGO_linux) # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd0 // libpthread.so.0 +#elif defined(VGO_freebsd) +# define VG_Z_LIBPTHREAD_SONAME libthrZdsoZa // libthr.so* #elif defined(VGO_darwin) # define VG_Z_LIBPTHREAD_SONAME libSystemZdZaZddylib // libSystem.*.dylib #elif defined(VGO_solaris) @@ -321,6 +323,18 @@ #endif +/* --- Sonames for FreeBSD ELF linkers, plus unencoded versions. --- */ + +#if defined(VGO_freebsd) + +#define VG_Z_LD_ELF_SO_1 ldZhelfZdsoZd1 // ld-elf.so.1 +#define VG_U_LD_ELF_SO_1 "ld-elf.so.1" + +#define VG_Z_LD_ELF32_SO_1 ldZhelf32ZdsoZd1 // ld-elf32.so.1 +#define VG_U_LD_ELF32_SO_1 "ld-elf32.so.1" + +#endif + /* --- Executable name for Darwin Mach-O linker. --- */ #if defined(VGO_darwin) @@ -391,7 +405,7 @@ Bool VG_(is_soname_ld_so) (const HChar *soname); // FreeBSD is b) pthread functions are lin libthr but semaphore // functions are lin libc -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) #define VG_WRAP_THREAD_FUNCTION_LIBPTHREAD_ONLY #elif defined(VGO_solaris) || (defined(VGO_linux) && defined(MUSL_LIBC)) #define VG_WRAP_THREAD_FUNCTION_LIBC_ONLY diff --git a/include/pub_tool_vki.h b/include/pub_tool_vki.h index 4aa36f388e..24f99cc09f 100644 --- a/include/pub_tool_vki.h +++ b/include/pub_tool_vki.h @@ -51,6 +51,8 @@ # include "vki/vki-darwin.h" #elif defined(VGO_solaris) # include "vki/vki-solaris.h" +#elif defined(VGO_freebsd) +# include "vki/vki-freebsd.h" #else # error Unknown Plat/OS #endif diff --git a/include/pub_tool_vkiscnums.h b/include/pub_tool_vkiscnums.h index cb5f957701..df766ecab9 100644 --- a/include/pub_tool_vkiscnums.h +++ b/include/pub_tool_vkiscnums.h @@ -44,7 +44,6 @@ extern const HChar *VG_(sysnum_string) (Word sysnum); // Macro provided for backward compatibility purposes. #define VG_SYSNUM_STRING(sysnum) VG_(sysnum_string)(sysnum) - #endif // __PUB_TOOL_VKISCNUMS_H /*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_vkiscnums_asm.h b/include/pub_tool_vkiscnums_asm.h index 6ede6f90ef..14b483c4df 100644 --- a/include/pub_tool_vkiscnums_asm.h +++ b/include/pub_tool_vkiscnums_asm.h @@ -74,6 +74,9 @@ # include "vki/vki-scnums-shared-linux.h" # include "vki/vki-scnums-mips64-linux.h" +#elif defined(VGP_x86_freebsd) || defined(VGP_amd64_freebsd) +# include "vki/vki-scnums-freebsd.h" + #elif defined(VGP_x86_darwin) || defined(VGP_amd64_darwin) # include "vki/vki-scnums-darwin.h" diff --git a/include/valgrind.h b/include/valgrind.h index 04a747c7a8..ae04c0faa7 100644 --- a/include/valgrind.h +++ b/include/valgrind.h @@ -110,6 +110,8 @@ */ #undef PLAT_x86_darwin #undef PLAT_amd64_darwin +#undef PLAT_x86_freebsd +#undef PLAT_amd64_freebsd #undef PLAT_x86_win32 #undef PLAT_amd64_win64 #undef PLAT_x86_linux @@ -131,6 +133,10 @@ # define PLAT_x86_darwin 1 #elif defined(__APPLE__) && defined(__x86_64__) # define PLAT_amd64_darwin 1 +#elif defined(__FreeBSD__) && defined(__i386__) +# define PLAT_x86_freebsd 1 +#elif defined(__FreeBSD__) && defined(__amd64__) +# define PLAT_amd64_freebsd 1 #elif (defined(__MINGW32__) && defined(__i386__)) \ || defined(__CYGWIN32__) \ || (defined(_WIN32) && defined(_M_IX86)) @@ -258,7 +264,7 @@ #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ || (defined(PLAT_x86_win32) && defined(__GNUC__)) \ - || defined(PLAT_x86_solaris) + || defined(PLAT_x86_solaris) || defined(PLAT_x86_freebsd) typedef struct { @@ -398,6 +404,7 @@ valgrind_do_client_request_expr(uintptr_t _zzq_default, uintptr_t _zzq_request, #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) \ || defined(PLAT_amd64_solaris) \ + || defined(PLAT_amd64_freebsd) \ || (defined(PLAT_amd64_win64) && defined(__GNUC__)) typedef @@ -1219,7 +1226,7 @@ typedef /* ----------------- x86-{linux,darwin,solaris} ---------------- */ #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ - || defined(PLAT_x86_solaris) + || defined(PLAT_x86_solaris) || defined(PLAT_x86_freebsd) /* These regs are trashed by the hidden call. No need to mention eax as gcc can already see that, plus causes gcc to bomb. */ @@ -1651,7 +1658,7 @@ typedef /* ---------------- amd64-{linux,darwin,solaris} --------------- */ #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) \ - || defined(PLAT_amd64_solaris) + || defined(PLAT_amd64_solaris) || defined(PLAT_amd64_freebsd) /* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */ diff --git a/include/vki/vki-amd64-freebsd.h b/include/vki/vki-amd64-freebsd.h new file mode 100644 index 0000000000..55409dbebd --- /dev/null +++ b/include/vki/vki-amd64-freebsd.h @@ -0,0 +1,220 @@ +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +#ifndef VKI_AMD64_FREEBSD_H +#define VKI_AMD64_FREEBSD_H + +/* PAGE_SHIFT determines the page size. */ +#define VKI_PAGE_SHIFT 12 +#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) +#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT +#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE + +#define VKI_MINSIGSTKSZ 2048 + +//---------------------------------------------------------------------- +// sys/_sigset.h +//---------------------------------------------------------------------- +#define _VKI_NSIG 128 +#define _VKI_NSIG_WORDS 4 +#define _VKI_NSIG_BPW ((_VKI_NSIG) / (_VKI_NSIG_WORDS)) + +#include "vki-machine-types-amd64-freebsd.h" + +typedef struct { + vki_uint32_t sig[_VKI_NSIG_WORDS]; +} vki_sigset_t; + +struct _vki_fpstate { + unsigned short cwd; + unsigned short swd; + unsigned short twd; + unsigned short fop; + unsigned long rip; + unsigned long rdp; + unsigned int mxcsr; + unsigned int mxcsr_mask; + unsigned int st_space[32]; /* 8*16 bytes for each FP-reg */ + unsigned int xmm_space[64]; /* 16*16 bytes for each XMM-reg */ + unsigned int reserved2[24]; +}; + +struct vki_sigcontext { + vki_sigset_t mask; + long onstack; + long rdi; + long rsi; + long rdx; + long rcx; + long r8; + long r9; + long rax; + long rbx; + long rbp; + long r10; + long r11; + long r12; + long r13; + long r14; + long r15; + int trapno; + short fs; + short gs; + long addr; + int flags; + short es; + short ds; + long err; + long rip; + long cs; + long rflags; + long rsp; + long ss; + long len; /* sizeof(mcontext_t) */ + long fpformat; + long ownedfp; + struct _vki_fpstate fpstate; + + long fsbase; + long gsbase; + long xfpustate; + long xfpustate_len; + + long spare[4]; +}; + +/* + * Retrieved from src/sys/amd64/include/reg.h + * Note that on 8.x trapno and err are no-more meaningful, but we + * don't set them anyway. + */ + +struct vki_user_regs_struct { + vki_register_t r15; + vki_register_t r14; + vki_register_t r13; + vki_register_t r12; + vki_register_t r11; + vki_register_t r10; + vki_register_t r9; + vki_register_t r8; + vki_register_t rdi; + vki_register_t rsi; + vki_register_t rbp; + vki_register_t rbx; + vki_register_t rdx; + vki_register_t rcx; + vki_register_t rax; + vki_uint32_t trapno; + vki_uint16_t fs; + vki_uint16_t gs; + vki_uint32_t err; + vki_uint16_t es; + vki_uint16_t ds; + vki_register_t rip; + vki_register_t cs; + vki_register_t rflags; + vki_register_t rsp; + vki_register_t ss; +}; + +struct vki_fpreg { + unsigned long fpr_env[4]; + unsigned char fpr_acc[8][16]; + unsigned char fpr_xacc[16][16]; + unsigned long fpr_spare[12]; +}; + +struct vki_dbreg { + unsigned long dr[16]; +}; + +typedef vki_register_t vki_elf_greg_t; +typedef struct _vki_fpstate vki_elf_fpregset_t; + +#define VKI_AT_SYSINFO 32 +#define VKI_ELF_NGREG \ + (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) + +typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; + +struct vki_mcontext { + vki_register_t onstack; /* XXX - sigcontext compat. */ + vki_register_t rdi; /* machine state (struct trapframe) */ + vki_register_t rsi; + vki_register_t rdx; + vki_register_t rcx; + vki_register_t r8; + vki_register_t r9; + vki_register_t rax; + vki_register_t rbx; + vki_register_t rbp; + vki_register_t r10; + vki_register_t r11; + vki_register_t r12; + vki_register_t r13; + vki_register_t r14; + vki_register_t r15; + vki_uint32_t trapno; + vki_uint16_t fs; + vki_uint16_t gs; + vki_register_t addr; + vki_uint32_t flags; + vki_uint16_t es; + vki_uint16_t ds; + vki_register_t err; + vki_register_t rip; + vki_register_t cs; + vki_register_t rflags; + vki_register_t rsp; + vki_register_t ss; + + long len; + long fpformat; + long ownedfp; + struct _vki_fpstate fpstate;// __attribute__((aligned(16))); + vki_register_t fsbase; + vki_register_t gsbase; + + vki_register_t xfpustate; + vki_register_t xfpustate_len; + + long spare2[4]; +}; + +#define VKI_FPFMT_NODEV 0x10000 +#define VKI_FPFMT_XMM 0x10002 + +#define VKI_FPOWNED_NONE 0x20000 +#define VKI_FPOWNED_FPU 0x20001 +#define VKI_FPOWNED_PCB 0x20002 + +struct vki_sigaction_base { + void (*ksa_handler)(int); + int sa_flags; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; +typedef struct vki_sigaction_base vki_sigaction_toK_t; +typedef struct vki_sigaction_base vki_sigaction_fromK_t; + +#endif /* VKI_AMD64_FREEBSD_H */ diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h new file mode 100644 index 0000000000..eaea7d74c2 --- /dev/null +++ b/include/vki/vki-freebsd.h @@ -0,0 +1,3077 @@ + +/*--------------------------------------------------------------------*/ +/*--- FreeBSD-specific kernel interface. vki-freebsd.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* This file defines types and constants for the kernel interface, and to + make that clear everything is prefixed VKI_/vki_. + + All code is copied verbatim from kernel source files, except that: + - VKI_/vki_ prefixes are added + - some extra explanatory comments are included; they are all within + "[[ ]]" + - for some types, we only care about the size; for a few of them (big + ones that are painful to fully drag in here), a VKI_SIZEOF_* constant + is used. + + The files the code is taken from is indicated. + + Note especially that the types are not the glibc versions, many of which + are different to those in here. + + Also note that this file contains all the generic header info, ie. that + from linux/include/linux/ *.h. The arch-specific header info, eg. that + from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and + vki_posixtypes-$PLATFORM.h. (Two files are required to avoid + circular dependencies between the generic VKI header and the + arch-specific VKI header. It's possible in the future, as more stuff + gets pulled in, that we might have to split files up some more to avoid + further circular dependencies.) + + Finally, note that it is assumed that __KERNEL__ is set for all these + definitions, which affects some of them. +*/ + +#ifndef VKI_FREEBSD_H +#define VKI_FREEBSD_H + +//---------------------------------------------------------------------- +// Arch-specific POSIX types +//---------------------------------------------------------------------- + +#if defined(VGA_x86) +# include "vki-machine-types-x86-freebsd.h" +#elif defined(VGA_amd64) +# include "vki-machine-types-amd64-freebsd.h" +#else +# error Unknown platform +#endif + +#include <sys/fcntl.h> +#include <sys/param.h> + + +//---------------------------------------------------------------------- +// From sys/select.h +//---------------------------------------------------------------------- + +typedef unsigned long __vki_fd_mask; + +#undef __VKI_NFDBITS +#define __VKI_NFDBITS (8 * sizeof(__vki_fd_mask)) + +#undef __VKI_FD_SETSIZE +#define __VKI_FD_SETSIZE 1024U + +#undef __VKI_FDSET_LONGS +#define __VKI_FDSET_LONGS (__VKI_FD_SETSIZE/__VKI_NFDBITS) + +#undef __VKI_FDELT +#define __VKI_FDELT(d) ((d) / __VKI_NFDBITS) + +#undef __VKI_FDMASK +#define __VKI_FDMASK(d) (1UL << ((d) % __VKI_NFDBITS)) + +typedef struct { + unsigned long fds_bits [__VKI_FDSET_LONGS]; +} __vki_fd_set; + +//---------------------------------------------------------------------- +// sys/_types.h +//---------------------------------------------------------------------- +/* MD QQQ 32 on 64 */ +typedef long __vki_key_t; +typedef long __vki_suseconds_t; +typedef struct __timer *__vki_timer_t; +typedef struct __mq *__vki_mqd_t; + +/* MI */ +typedef vki_uint32_t __vki_blksize_t; +typedef vki_int64_t __vki_blkcnt_t; +typedef vki_int32_t __vki_clockid_t; +typedef vki_int32_t __vki_ct_rune_t; +typedef vki_uint32_t __vki_fflags_t; +typedef vki_uint64_t __vki_fsblkcnt_t; +typedef vki_uint64_t __vki_fsfilcnt_t; +typedef vki_uint32_t __vki_gid_t; +typedef vki_int64_t __vki_id_t; +typedef vki_uint32_t __vki_ino_t; +typedef vki_int32_t __vki_lwpid_t; +typedef vki_uint16_t __vki_mode_t; +typedef vki_uint16_t __vki_nlink_t; +typedef vki_int64_t __vki_off_t; +typedef vki_int32_t __vki_pid_t; +typedef vki_int64_t __vki_rlim_t; +typedef vki_uint8_t __vki_sa_family_t; +typedef vki_uint32_t __vki_socklen_t; +typedef vki_uint32_t __vki_uid_t; +typedef vki_int32_t __vki_useconds_t; +typedef __vki_ct_rune_t __vki_rune_t; +typedef __vki_ct_rune_t __vki_wchar_t; +typedef __vki_ct_rune_t __vki_wint_t; +typedef vki_uint32_t __vki_dev_t; +typedef vki_uint32_t __vki_fixpt_t; + + +//---------------------------------------------------------------------- +// sys/types.h +//---------------------------------------------------------------------- + +typedef vki_uint8_t vki_u_int8_t; +typedef vki_uint16_t vki_u_int16_t; +typedef vki_uint32_t vki_u_int32_t; +typedef vki_uint64_t vki_u_int64_t; + +typedef vki_uint64_t vki_u_quad_t; +typedef vki_int64_t vki_quad_t; +typedef __vki_caddr_t vki_caddr_t; +typedef __const __vki_caddr_t vki_c_caddr_t; +typedef __volatile __vki_caddr_t vki_v_caddr_t; + +typedef __vki_blksize_t vki_blksize_t; +typedef __vki_blkcnt_t vki_blkcnt_t; +typedef __vki_clock_t vki_clock_t; +typedef __vki_clockid_t vki_clockid_t; +typedef __vki_dev_t vki_dev_t; +typedef __vki_fflags_t vki_fflags_t; +typedef __vki_fixpt_t vki_fixpt_t; +typedef __vki_fsblkcnt_t vki_fsblkcnt_t; +typedef __vki_fsfilcnt_t vki_fsfilcnt_t; +typedef __vki_gid_t vki_gid_t; +typedef vki_uint32_t vki_in_addr_t; +typedef vki_uint16_t vki_in_port_t; +typedef __vki_id_t vki_id_t; +typedef __vki_ino_t vki_ino_t; +typedef __vki_key_t vki_key_t; +typedef __vki_lwpid_t vki_lwpid_t; +typedef __vki_mode_t vki_mode_t; +typedef __vki_nlink_t vki_nlink_t; +typedef __vki_off_t vki_off_t; +typedef __vki_pid_t vki_pid_t; +typedef __vki_register_t vki_register_t; +typedef __vki_rlim_t vki_rlim_t; +typedef __vki_segsz_t vki_segsz_t; +typedef __vki_size_t vki_size_t; +typedef __vki_ssize_t vki_ssize_t; +typedef __vki_suseconds_t vki_suseconds_t; +typedef __vki_time_t vki_time_t; +typedef __vki_timer_t vki_timer_t; +typedef __vki_mqd_t vki_mqd_t; +typedef __vki_u_register_t vki_u_register_t; +typedef __vki_uid_t vki_uid_t; +typedef __vki_useconds_t vki_useconds_t; +typedef int vki_cpuwhich_t; +typedef int vki_cpulevel_t; +typedef int vki_cpusetid_t; + + +typedef __vki_vm_offset_t vki_vm_offset_t; +typedef __vki_vm_ooffset_t vki_vm_ooffset_t; +typedef __vki_vm_paddr_t vki_vm_paddr_t; +typedef __vki_vm_pindex_t vki_vm_pindex_t; +typedef __vki_vm_size_t vki_vm_size_t; + +//---------------------------------------------------------------------- +// sys/select.h +//---------------------------------------------------------------------- + +typedef __vki_fd_set vki_fd_set; + +//---------------------------------------------------------------------- +// Now the rest of the arch-specific stuff +//---------------------------------------------------------------------- + +#if defined(VGA_x86) +# include "vki-x86-freebsd.h" +#elif defined(VGA_amd64) +# include "vki-amd64-freebsd.h" +#else +# error Unknown platform +#endif + +//---------------------------------------------------------------------- +// linux and freebsd version hacks +//---------------------------------------------------------------------- +#ifndef ELFMAG +#define ELFMAG "\177ELF" /* magic string */ +#endif +#ifndef SELFMAG +#define SELFMAG 4 /* magic string size */ +#endif + +// see http://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239669 +#if !defined(ELF_NOTE_GNU) +#define ELF_NOTE_GNU "GNU" +#endif + +// This is not defined on FreeBSD 10.4 +#if !defined(NT_FREEBSD_ABI_TAG) +#define NT_FREEBSD_ABI_TAG 1 +#endif + +#define VKI_ELF_NOTE_ROUNDSIZE 4 + + +//---------------------------------------------------------------------- +// From sys/syslimits.h +//---------------------------------------------------------------------- + +#define VKI_PATH_MAX 1024 + + +//---------------------------------------------------------------------- +// From sys/timespec.h +//---------------------------------------------------------------------- + +struct vki_timespec { + vki_time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct vki_itimerspec { + struct vki_timespec it_interval; /* timer period */ + struct vki_timespec it_value; /* timer expiration */ +}; + +//---------------------------------------------------------------------- +// From sys/_time.h +//---------------------------------------------------------------------- + +struct vki_timeval { + vki_time_t tv_sec; /* seconds */ + vki_suseconds_t tv_usec; /* microseconds */ +}; + +//---------------------------------------------------------------------- +// From sys/time.h +//---------------------------------------------------------------------- + +#define VKI_CLOCK_REALTIME 0 +#define VKI_CLOCK_MONOTONIC 1 +#define VKI_CLOCK_PROCESS_CPUTIME_ID 2 +#define VKI_CLOCK_THREAD_CPUTIME_ID 3 + +struct vki_timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +struct vki_itimerval { + struct vki_timeval it_interval; /* timer interval */ + struct vki_timeval it_value; /* current value */ +}; + +//---------------------------------------------------------------------- +// From sys/timex.h +//---------------------------------------------------------------------- + +struct vki_ntptimeval { + struct vki_timespec time; + long maxerror; + long esterror; + long tai; + int time_state; +}; + +struct vki_timex { + unsigned int modes; /* mode selector */ + long offset; /* time offset (usec) */ + long freq; /* frequency offset (scaled ppm) */ + long maxerror; /* maximum error (usec) */ + long esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long constant; /* pll time constant */ + long precision; /* clock precision (usec) (read only) */ + long tolerance; /* clock frequency tolerance (ppm) + * (read only) + */ + long ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* pps stability (scaled ppm) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ +}; + +#define MOD_OFFSET 0x0001 /* time offset */ +#define MOD_FREQUENCY 0x0002 /* frequency offset */ +#define MOD_MAXERROR 0x0004 /* maximum time error */ +#define MOD_ESTERROR 0x0008 /* estimated time error */ +#define MOD_STATUS 0x0010 /* clock status */ +#define MOD_TIMECONST 0x0020 /* pll time constant */ +#define MOD_PPSMAX 0x0040 +#define MOD_TAI 0x0080 +#define MOD_MICRO 0x1000 +#define MOD_NANO 0x2000 +#define MOD_CLKB 0x4000 +#define MOD_CLKA 0x8000 + +//---------------------------------------------------------------------- +// From sys/times.h +//---------------------------------------------------------------------- + +struct vki_tms { + vki_clock_t tms_utime; + vki_clock_t tms_stime; + vki_clock_t tms_cutime; + vki_clock_t tms_cstime; +}; + +//---------------------------------------------------------------------- +// From sys/stat.h +//---------------------------------------------------------------------- + +/* QQQ 4.x stat layout */ +struct vki_freebsd11_stat { + vki_dev_t st_dev; + vki_ino_t st_ino; + vki_mode_t st_mode; + vki_nlink_t st_nlink; + vki_uid_t st_uid; + vki_gid_t st_gid; + vki_dev_t st_rdev; +#if 0 + struct vki_timespec st_atimespec; + struct vki_timespec st_mtimespec; + struct vki_timespec st_ctimespec; +#else + vki_time_t st_atime; + long st_atime_nsec; + vki_time_t st_mtime; + long st_mtime_nsec; + vki_time_t st_ctime; + long st_ctime_nsec; +#endif + vki_off_t st_size; + vki_blkcnt_t st_blocks; + vki_blksize_t st_blksize; + vki_fflags_t st_flags; + vki_uint32_t st_gen; + vki_int32_t st_lspare; + struct vki_timespec st_birthtimespec; +unsigned int : + (8 / 2) * (16 - (int)sizeof(struct vki_timespec)); +unsigned int : + (8 / 2) * (16 - (int)sizeof(struct vki_timespec)); +}; + +#if defined(VGP_x86_freebsd) +#define VKI_STAT_TIME_T_EXT 1 +#endif + +/* + * FreeBSD 12 has two versions of the stat struct + * freebsd11_stat, which is the same as vki_stat above + * and just stat, which is the same as vki_stat below + * Since vki_stat is used by other OSes, it's best not to + * use the same naming + */ + +struct vki_stat { + //vki_dev_t st_dev; + vki_uint64_t st_dev; + //vki_ino_t st_ino; + vki_uint64_t st_ino; + //vki_nlink_t st_nlink; + vki_uint64_t st_nlink; + vki_mode_t st_mode; + vki_int16_t st_padding0; + vki_uid_t st_uid; + vki_gid_t st_gid; + vki_int32_t st_padding1; + //vki_dev_t st_rdev; + vki_uint64_t st_rdev; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_atim_ext; +#endif + //struct vki_timespec st_atim; + vki_time_t st_atime; + long st_atime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_mtim_ext; +#endif + //struct vki_timespec st_mtim; + vki_time_t st_mtime; + long st_mtime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_ctim_ext; +#endif + //struct vki_timespec st_ctim; + vki_time_t st_ctime; + long st_ctime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_btim_ext; +#endif + //struct vki_timespec st_birthtim; + vki_time_t st_btime; + long st_btime_nsec; + vki_off_t st_size; + vki_blkcnt_t st_blocks; + vki_blksize_t st_blksize; + vki_fflags_t st_flags; + vki_uint64_t st_gen; + vki_uint64_t st_spare[10]; +}; + + + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sched.h +//---------------------------------------------------------------------- + +struct vki_sched_param { + int sched_priority; +}; + +//---------------------------------------------------------------------- +// From sys/signal.h +//---------------------------------------------------------------------- + +#define VKI_SIG_BLOCK 1 /* block specified signal set */ +#define VKI_SIG_UNBLOCK 2 /* unblock specified signal set */ +#define VKI_SIG_SETMASK 3 /* set specified signal set */ + +#define VKI_SIG_DFL ((__vki_sighandler_t)0) +#define VKI_SIG_IGN ((__vki_sighandler_t)1) +#define VKI_SIG_ERR ((__vki_sighandler_t)-1) + +typedef void __vki_signalfn_t(int); +typedef __vki_signalfn_t *__vki_sighandler_t; + +#define VKI_SIGHUP 1 +#define VKI_SIGINT 2 +#define VKI_SIGQUIT 3 +#define VKI_SIGILL 4 +#define VKI_SIGTRAP 5 +#define VKI_SIGABRT 6 +#define VKI_SIGEMT 7 +#define VKI_SIGFPE 8 +#define VKI_SIGKILL 9 +#define VKI_SIGBUS 10 +#define VKI_SIGSEGV 11 +#define VKI_SIGSYS 12 +#define VKI_SIGPIPE 13 +#define VKI_SIGALRM 14 +#define VKI_SIGTERM 15 +#define VKI_SIGURG 16 +#define VKI_SIGSTOP 17 +#define VKI_SIGTSTP 18 +#define VKI_SIGCONT 19 +#define VKI_SIGCHLD 20 +#define VKI_SIGTTIN 21 +#define VKI_SIGTTOU 22 +#define VKI_SIGIO 23 +#define VKI_SIGXCPU 24 +#define VKI_SIGXFSZ 25 +#define VKI_SIGVTALRM 26 +#define VKI_SIGPROF 27 +#define VKI_SIGWINCH 28 +#define VKI_SIGINFO 29 +#define VKI_SIGUSR1 30 +#define VKI_SIGUSR2 31 +#define VKI_SIGTHR 32 + +#define VKI_SIGRTMIN 65 +#define VKI_SIGRTMAX 126 + +#define VKI_SA_ONSTACK 0x0001 +#define VKI_SA_RESTART 0x0002 +#define VKI_SA_RESETHAND 0x0004 +#define VKI_SA_NOCLDSTOP 0x0008 +#define VKI_SA_NODEFER 0x0010 +#define VKI_SA_NOCLDWAIT 0x0020 +#define VKI_SA_SIGINFO 0x0040 +#define VKI_SA_RESTORER 0 /* FreeBSD doesn't have this */ + +#define VKI_SS_ONSTACK 0x0001 +#define VKI_SS_DISABLE 0x0004 + +#define VKI_SA_ONESHOT VKI_SA_RESETHAND +#define VKI_SA_NOMASK VKI_SA_NODEFER + +struct vki_sigaction { + __vki_sighandler_t ksa_handler; + int sa_flags; + vki_sigset_t sa_mask; +}; + +typedef struct vki_sigaltstack { + void *ss_sp; + vki_size_t ss_size; + int ss_flags; +} vki_stack_t; + +typedef union vki_sigval { + int sival_int; + void *sival_ptr; +} vki_sigval_t; + +typedef struct vki_siginfo { + int si_signo; + int si_errno; + int si_code; + vki_pid_t si_pid; + vki_uid_t si_uid; + int si_status; + void *si_addr; + vki_sigval_t si_value; +// 666: not valid. switch to above def +#ifdef si_band +#undef si_band +#endif + long si_band; + int __spare__[7]; +} vki_siginfo_t; + +/* + * si_code values + */ +#define VKI_SI_USER 0x10001 /* sent by kill, sigsend, raise */ +#define VKI_SI_QUEUE 0x10002 +#define VKI_SI_TIMER 0x10003 +#define VKI_SI_ASYNCIO 0x10004 +#define VKI_SI_MESGQ 0x10005 +#define VKI_SI_KERNEL 0x10006 +#define VKI_SI_LWP 0x10007 +/* + * SIGILL si_codes + */ +#define VKI_ILL_ILLOPC 1 /* illegal opcode */ +#define VKI_ILL_ILLOPN 2 /* illegal operand */ +#define VKI_ILL_ILLADR 3 /* illegal addressing mode */ +#define VKI_ILL_ILLTRP 4 /* illegal trap */ +#define VKI_ILL_PRVOPC 5 /* privileged opcode */ +#define VKI_ILL_PRVREG 6 /* privileged register */ +#define VKI_ILL_COPROC 7 /* coprocessor error */ +#define VKI_ILL_BADSTK 8 /* internal stack error */ + +/* + * SIGFPE si_codes + */ +#define VKI_FPE_INTOVF 1 /* integer overflow */ +#define VKI_FPE_INTDIV 2 /* integer divide by zero */ +#define VKI_FPE_FLTDIV 3 /* floating point divide by zero */ +#define VKI_FPE_FLTOVF 4 /* floating point overflow */ +#define VKI_FPE_FLTUND 5 /* floating point underflow */ +#define VKI_FPE_FLTRES 6 /* floating point inexact result */ +#define VKI_FPE_FLTINV 7 /* floating point invalid operation */ +#define VKI_FPE_FLTSUB 8 /* subscript out of range */ + +/* + * SIGSEGV si_codes + */ +#define VKI_SEGV_MAPERR 1 /* address not mapped to object */ +#define VKI_SEGV_ACCERR 2 /* invalid permissions for mapped object */ +/* XXX i386 and amd64 specific */ +#define VKI_SEGV_PAGE_FAULT 12 + +/* + * SIGBUS si_codes + */ +#define VKI_BUS_ADRALN 1 /* invalid address alignment */ +#define VKI_BUS_ADRERR 2 /* non-existant physical address */ +#define VKI_BUS_OBJERR 3 /* object specific hardware error */ +#define VKI_BUS_OOMERR 100 /* Non-standard: No memory. */ + +/* + * SIGTRAP si_codes + */ +#define VKI_TRAP_BRKPT 1 /* process breakpoint */ +#define VKI_TRAP_TRACE 2 /* process trace trap */ +#define VKI_TRAP_DTRACE 3 /* DTrace induced trap. */ +#define VKI_TRAP_CAP 4 /* Capabilities protective trap. */ + +#if 0 /* freebsd-6 */ +typedef struct vki_sigevent { + int sigev_notify; + int sigev_signo; + vki_sigval_t sigev_value; + union { + int _threadid; + + struct { + void (*_function)(vki_sigval_t); + void *_attribute; /* really pthread_attr_t */ + } _sigev_thread; + long __spare__[8]; + } _sigev_un; +} vki_sigevent_t; +#endif + +struct vki_sigevent { + int sigev_notify; /* Notification type */ + union { + int __sigev_signo; /* Signal number */ + int __sigev_notify_kqueue; + } __sigev_u; + vki_sigval_t sigev_value; /* Signal value */ +}; +#if 0 +#define sigev_signo __sigev_u.__sigev_signo +#define sigev_notify_kqueue __sigev_u.__sigev_notify_kqueue +#endif + +//---------------------------------------------------------------------- +// From sys/_iovec.h +//---------------------------------------------------------------------- + +struct vki_iovec { + void *iov_base; + __vki_size_t iov_len; +}; + +//---------------------------------------------------------------------- +// From sys/socket.h +//---------------------------------------------------------------------- + +typedef __vki_sa_family_t vki_sa_family_t; +typedef __vki_socklen_t vki_socklen_t; + +struct vki_sockaddr { + vki_uint8_t sa_len; + vki_sa_family_t sa_family; /* address family, AF_xxx */ + char sa_data[14]; /* 14 bytes of protocol address */ +}; + +struct vki_msghdr { + void * msg_name; /* Socket name */ + vki_socklen_t msg_namelen; /* Length of name */ + struct vki_iovec * msg_iov; /* Data blocks */ + int msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + vki_socklen_t msg_controllen; /* Length of cmsg list */ + int msg_flags; +}; + +struct vki_cmsghdr { + vki_socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +}; + +#define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg)) +#define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg)) + +#define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) + +#define VKI_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr)))) + +#define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \ + (struct vki_cmsghdr *)(ctl) : \ + (struct vki_cmsghdr *)NULL) +#define VKI_CMSG_FIRSTHDR(msg) __VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) + +// [[Urgh, this is revolting...] +// QQQ check +static __inline struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, vki_socklen_t __size, + struct vki_cmsghdr *__cmsg) +{ + struct vki_cmsghdr * __ptr; + + __ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) + VKI_CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) + return (struct vki_cmsghdr *)0; + + return __ptr; +} + +static __inline struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg) +{ + return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); +} + +#define VKI_SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ + +#define VKI_AF_UNIX 1 /* Unix domain sockets */ +#define VKI_AF_INET 2 /* Internet IP Protocol */ +#define VKI_AF_INET6 28 /* IP version 6 */ + +#define VKI_MSG_NOSIGNAL 0x20000 /* Do not generate SIGPIPE */ + +#define VKI_SOL_SOCKET 0xffff + +#define VKI_SO_TYPE 0x1008 + +#define VKI_SOCK_STREAM 1 + +#include <netinet/tcp.h> + +#define VKI_TCP_NODELAY TCP_NODELAY + +#include <netinet/in.h> + +#define VKI_IPPROTO_TCP IPPROTO_TCP + +struct vki_sf_hdtr { + struct iovec *headers; + int hdr_cnt; + struct iovec *trailers; + int trl_cnt; +}; + + +//---------------------------------------------------------------------- +// From netinet/in.h +//---------------------------------------------------------------------- + +struct vki_in_addr { + vki_in_addr_t s_addr; +}; + +/* Structure describing an Internet (IP) socket address. */ +#define __VKI_SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ +struct vki_sockaddr_in { + vki_uint8_t sin_len; + vki_sa_family_t sin_family; /* Address family */ + vki_in_port_t sin_port; /* Port number */ + struct vki_in_addr sin_addr; /* Internet address */ + char sin_zero[8]; +}; + +//---------------------------------------------------------------------- +// From netinet6/in6.h +//---------------------------------------------------------------------- + +struct vki_in6_addr { + union { + vki_uint8_t u6_addr8[16]; + vki_uint16_t u6_addr16[8]; + vki_uint32_t u6_addr32[4]; + } vki_in6_u; +#define vki_s6_addr vki_in6_u.u6_addr8 +#define vki_s6_addr16 vki_in6_u.u6_addr16 +#define vki_s6_addr32 vki_in6_u.u6_addr32 +}; + +struct vki_sockaddr_in6 { + vki_uint8_t sin6_len; + vki_sa_family_t sin6_family; /* AF_INET6 */ + vki_uint16_t sin6_port; /* Transport layer port # */ + vki_uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct vki_in6_addr sin6_addr; /* IPv6 address */ + vki_uint32_t sin6_scope_id; /* scope id (new in RFC2553) */ +}; + +//---------------------------------------------------------------------- +// From sys/un.h +//---------------------------------------------------------------------- + +#define VKI_UNIX_PATH_MAX 104 /* QQQ overridden by sun_len */ + +struct vki_sockaddr_un { + unsigned char sun_len; + vki_sa_family_t sun_family; /* AF_UNIX */ + char sun_path[VKI_UNIX_PATH_MAX]; /* pathname */ +}; + +//---------------------------------------------------------------------- +// From aio.h +//---------------------------------------------------------------------- + +struct vki___aiocb_private { + long status; + long error; + void *kernelinfo; +}; + +typedef struct vki_aiocb { + int aio_fildes; + vki_off_t aio_offset; + volatile void *aio_buf; + vki_size_t aio_nbytes; + int __spare__[2]; + void *__spare2__; + int aio_lio_opcode; + int aio_reqprio; + struct vki___aiocb_private _aiocb_private; + struct vki_sigevent aio_sigevent; +} aiocb_t; + +#define VKI_LIO_NOP 0x0 +#define VKI_LIO_WRITE 0x1 +#define VKI_LIO_READ 0x2 + +#define VKI_LIO_NOWAIT 0x0 +#define VKI_LIO_WAIT 0x1 + + +#define VKI_LIO_NOWAIT 0x0 + +//---------------------------------------------------------------------- +// From sys/mount.h +//---------------------------------------------------------------------- + +typedef struct vki_fsid { + vki_int32_t val[2]; +} vki_fsid_t; +#define VKI_OMFSNAMELEN 16 +#define VKI_OMNAMELEN (88 - 2 * sizeof(long)) +#define VKI_MFSNAMELEN 16 +#define VKI_FREEBSD11_MNAMELEN 88 + +struct vki_freebsd11_statfs { + vki_uint32_t f_version; + vki_uint32_t f_type; + vki_uint64_t f_flags; + vki_uint64_t f_bsize; + vki_uint64_t f_iosize; + vki_uint64_t f_blocks; + vki_uint64_t f_bfree; + vki_int64_t f_bavail; + vki_uint64_t f_files; + vki_int64_t f_ffree; + vki_uint64_t f_syncwrites; + vki_uint64_t f_asyncwrites; + vki_uint64_t f_syncreads; + vki_uint64_t f_asyncreads; + vki_uint64_t f_spare[10]; + vki_uint32_t f_namemax; + vki_uid_t f_owner; + vki_fsid_t f_fsid; + char f_charspare[80]; + char f_fstypename[VKI_OMFSNAMELEN]; + char f_mntfromname[VKI_FREEBSD11_MNAMELEN]; + char f_mntonname[VKI_FREEBSD11_MNAMELEN]; +}; + + +#define MAXFIDSZ 16 + +struct vki_fid { + vki_uint16_t fid_len; + vki_uint16_t fid_reserved; + char fid_data[MAXFIDSZ]; +}; + +struct vki_fhandle { + vki_fsid_t fh_fsid; + struct vki_fid fh_fid; +}; + + +#define VKI_MNAMELEN 1024 +struct vki_statfs { + vki_uint32_t f_version; + vki_uint32_t f_type; + vki_uint64_t f_flags; + vki_uint64_t f_bsize; + vki_uint64_t f_iosize; + vki_uint64_t f_blocks; + vki_uint64_t f_bfree; + vki_int64_t f_bavail; + vki_uint64_t f_files; + vki_int64_t f_ffree; + vki_uint64_t f_syncwrites; + vki_uint64_t f_asyncwrites; + vki_uint64_t f_syncreads; + vki_uint64_t f_asyncreads; + vki_uint64_t f_spare[10]; + vki_uint32_t f_namemax; + vki_uid_t f_owner; + vki_fsid_t f_fsid; + char f_charspare[80]; + char f_fstypename[VKI_MFSNAMELEN]; + char f_mntfromname[VKI_MNAMELEN]; + char f_mntonname[VKI_MNAMELEN]; +}; + +typedef struct vki_fhandle vki_fhandle_t; + +//---------------------------------------------------------------------- +// From sys/ttycom.h +//---------------------------------------------------------------------- + +struct vki_winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + + +//---------------------------------------------------------------------- +// From sys/termios.h +//---------------------------------------------------------------------- + +typedef unsigned int vki_tcflag_t; +typedef unsigned char vki_cc_t; +typedef unsigned int vki_speed_t; + +#define VKI_NCCS 20 +struct vki_termios { + vki_tcflag_t c_iflag; /* input mode flags */ + vki_tcflag_t c_oflag; /* output mode flags */ + vki_tcflag_t c_cflag; /* control mode flags */ + vki_tcflag_t c_lflag; /* local mode flags */ + vki_cc_t c_cc[VKI_NCCS]; /* control characters */ + vki_speed_t c_ispeed; + vki_speed_t c_ospeed; +}; + +//---------------------------------------------------------------------- +// From sys/ioccom.h +//---------------------------------------------------------------------- + +/* QQQ keep linux's naming, but use our layout */ + +/* + * We actually have a 16 bit "base" ioctl, which may or may not be decoded + * into number/group + */ +#define _VKI_IOC_BASEBITS 16 +#define _VKI_IOC_NRBITS 8 /* "num" on freebsd */ +#define _VKI_IOC_TYPEBITS 8 /* "group" on freebsd */ + +#define _VKI_IOC_SIZEBITS 13 +#define _VKI_IOC_DIRBITS 3 + +#define _VKI_IOC_BASEMASK ((1ul << _VKI_IOC_BASEBITS)-1) +#define _VKI_IOC_NRMASK ((1ul << _VKI_IOC_NRBITS)-1) +#define _VKI_IOC_TYPEMASK ((1ul << _VKI_IOC_TYPEBITS)-1) +#define _VKI_IOC_SIZEMASK ((1ul << _VKI_IOC_SIZEBITS)-1) +#define _VKI_IOC_DIRMASK ((1ul << _VKI_IOC_DIRBITS)-1) + +#define _VKI_IOC_BASESHIFT 0 +#define _VKI_IOC_NRSHIFT 0 +#define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) +#define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) +#define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) + +#define _VKI_IOC_NONE 1U /* "void" on freebsd, as a specific mode */ +#define _VKI_IOC_READ 2U /* "out", copyout in reversed linux terminology */ +#define _VKI_IOC_WRITE 4U /* "in", copyin in reversed linux terminology */ +#define _VKI_IOC_RDWR 6U /* "inout", copyin and copyout */ + +#define _VKI_IOC(dir,type,nr,size) \ + (((dir) << _VKI_IOC_DIRSHIFT) | \ + ((type) << _VKI_IOC_TYPESHIFT) | \ + ((nr) << _VKI_IOC_NRSHIFT) | \ + ((size) << _VKI_IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __vki_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __vki_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode ioctl numbers.. */ +#define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) +#define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK) +#define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK) +#define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) +#define _VKI_IOC_BASE(nr) (((nr) >> _VKI_IOC_BASESHIFT) & _VKI_IOC_BASEMASK) + +//---------------------------------------------------------------------- +// From sys/random.h +//---------------------------------------------------------------------- + +#define VKI_GRND_NONBLOCK 0x1 + +//---------------------------------------------------------------------- +// From sys/termios.h +//---------------------------------------------------------------------- + +#if 0 +#define VKI_TCGETS 0x5401 +#define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ +#define VKI_TCSETSW 0x5403 +#define VKI_TCSETSF 0x5404 +#define VKI_TCGETA 0x5405 y +#define VKI_TCSETA 0x5406 y +#define VKI_TCSETAW 0x5407 y +#define VKI_TCSETAF 0x5408 y +#define VKI_TCSBRK 0x5409 +#define VKI_TCXONC 0x540A +#define VKI_TCFLSH 0x540B y +#define VKI_TIOCSCTTY 0x540E +#define VKI_TIOCGPGRP 0x540F y +#define VKI_TIOCSPGRP 0x5410 y +#define VKI_TIOCOUTQ 0x5411 +#define VKI_TIOCGWINSZ 0x5413 y +#define VKI_TIOCSWINSZ 0x5414 y +#define VKI_TIOCMGET 0x5415 y +#define VKI_TIOCMBIS 0x5416 y +#define VKI_TIOCMBIC 0x5417 y +#define VKI_TIOCMSET 0x5418 y +#define VKI_FIONREAD 0x541B +#define VKI_TIOCLINUX 0x541C +#define VKI_FIONBIO 0x5421 +#define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define VKI_FIOASYNC 0x5452 +#define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */ + +#define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#endif + +#define VKI_TIOCFLUSH _VKI_IOW('t', 16, int); +#define VKI_TIOCGETA _VKI_IOR('t', 19, struct vki_termios) /* get termios */ +#define VKI_TIOCSETA _VKI_IOR('t', 20, struct vki_termios) /* set termios */ +#define VKI_TIOCSETAW _VKI_IOR('t', 21, struct vki_termios) /* drain,set */ +#define VKI_TIOCSETAF _VKI_IOR('t', 22, struct vki_termios) /* flush,set */ + +#define _VKI_TIOCPTMASTER _VKI_IO('t', 28) /* pts master validation */ + +#define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */ +#define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */ + +#define VKI_TIOCMGET _VKI_IOR('t', 106, int) /* get all modem bits */ +#define VKI_TIOCMBIC _VKI_IOW('t', 107, int) /* bic modem bits */ +#define VKI_TIOCMBIS _VKI_IOW('t', 108, int) /* bis modem bits */ +#define VKI_TIOCMSET _VKI_IOW('t', 109, int) /* set all modem bits */ +#define VKI_TIOCSTART _VKI_IO('t', 110) /* start output, like ^Q */ +#define VKI_TIOCSTOP _VKI_IO('t', 111) /* stop output, like ^S */ +#define VKI_TIOCPKT _VKI_IOW('t', 112, int) /* pty: set/clear packet mode */ + +#define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) /* set pgrp */ +#define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) /* get pgrp */ +#define VKI_TIOCCBRK _VKI_IO('t', 122) +#define VKI_TIOCSBRK _VKI_IO('t', 123) + + +//---------------------------------------------------------------------- +// From sys/filio.h +//---------------------------------------------------------------------- + +#define VKI_FIOCLEX _VKI_IO('f', 1) /* close on exec */ +#define VKI_FIONCLEX _VKI_IO('f', 2) /* no close on exec */ +#define VKI_FIONREAD _VKI_IOR('f', 127, int) +#define VKI_FIONBIO _VKI_IOW('f', 126, int) +#define VKI_FIOASYNC _VKI_IOW('f', 125, int) +#define VKI_FIOSETOWN _VKI_IOW('f', 124, int) +#define VKI_FIOGETOWN _VKI_IOW('f', 123, int) + +// See syswrap-freebsd.c PRE/POST(sys_ioctl) +#if 0 +//---------------------------------------------------------------------- +// From net/if.h +//---------------------------------------------------------------------- +#define VKI_IFNAMSIZ 16 + +struct vki_ifmediareq { + char ifm_name[VKI_IFNAMSIZ]; + int ifm_current; + int ifm_mask; + int ifm_status; + int ifm_active; + int ifm_count; + int *ifm_ulist; +}; + + +//---------------------------------------------------------------------- +// From sys/sockio.h +//---------------------------------------------------------------------- +#define VKI_SIOCGIFMEDIA _VKI_IOWR('i', 56, struct vki_ifmediareq) +#endif + +//---------------------------------------------------------------------- +// From sys/poll.h +//---------------------------------------------------------------------- + +#define VKI_POLLIN 0x0001 + +struct vki_pollfd { + int fd; + short events; + short revents; +}; + +//---------------------------------------------------------------------- +// From sys/event.h +//---------------------------------------------------------------------- +struct vki_kevent_freebsd11 { + vki_uintptr_t ident; + vki_int16_t filter; + vki_uint16_t flags; + vki_uint32_t fflags; + vki_intptr_t data; + void *udata; +}; + +struct vki_kevent { + vki_uintptr_t ident; + vki_int16_t filter; + vki_uint16_t flags; + vki_uint32_t fflags; + vki_int64_t data; + void *udata; + vki_uint64_t ext[4]; +}; + + +// QQQ sort + +//---------------------------------------------------------------------- +// From sys/resource.h +//---------------------------------------------------------------------- + +#define VKI_RUSAGE_SELF 0 +#define VKI_RUSAGE_CHILDREN -1 +#define VKI_RUSAGE_THREAD 1 + +struct vki_rusage { + struct vki_timeval ru_utime; /* user time used */ + struct vki_timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +struct vki_rlimit { + vki_rlim_t rlim_cur; + vki_rlim_t rlim_max; +}; + +#define VKI_RLIMIT_DATA 2 /* max data size */ +#define VKI_RLIMIT_STACK 3 /* max stack size */ +#define VKI_RLIMIT_CORE 4 /* max core file size */ +#define VKI_RLIMIT_NOFILE 8 /* max number of open files */ + +struct vki___wrusage { + struct vki_rusage wru_self; + struct vki_rusage wru_children; +}; + + +//---------------------------------------------------------------------- +// From sys/procfs.h +//---------------------------------------------------------------------- + +#define VKI_PRSTATUS_VERSION 1 +struct vki_elf_prstatus { + int pr_version; /* version of struct - PRSTATUS_VERSION */ + vki_size_t pr_statussz; + vki_size_t pr_gregsetsz; + vki_size_t pr_fpregsetsz; + int pr_osreldate; + int pr_cursig; /* Current signal */ + vki_pid_t pr_pid; + vki_elf_gregset_t pr_reg; /* GP registers */ +}; + +#define VKI_ELF_PRARGSZ (80) /* Number of chars for args */ +#define VKI_MAXCOMLEN (16) + +#define VKI_PRPSINFO_VERSION 1 +struct vki_elf_prpsinfo { + int pr_version; /* version of struct - PRPSINFO_VERSION */ + vki_size_t pr_psinfosz; + char pr_fname[VKI_MAXCOMLEN+1]; /* filename of executable */ + char pr_psargs[VKI_ELF_PRARGSZ]; /* initial part of arg list */ +}; + +//---------------------------------------------------------------------- +// From posix4/mqueue.h +//---------------------------------------------------------------------- + +struct vki_mq_attr { + long mq_flags; /* message queue flags */ + long mq_maxmsg; /* maximum number of messages */ + long mq_msgsize; /* maximum message size */ + long mq_curmsgs; /* number of messages currently queued */ +}; + +//---------------------------------------------------------------------- +// From sys/ucontext.h +//---------------------------------------------------------------------- + +#define VKI_UCF_SWAPPED 1 + +struct vki_ucontext { + vki_sigset_t uc_sigmask; + struct vki_mcontext uc_mcontext; + struct vki_ucontext *uc_link; + vki_stack_t uc_stack; + int uc_flags; + unsigned int __spare__[4]; +}; + +//-----------... [truncated message content] |
|
From: Paul F. <pa...@so...> - 2021-10-06 06:24:42
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=33012dd82ba5f3502d3c6c5d95cf22b7af48f6b3 commit 33012dd82ba5f3502d3c6c5d95cf22b7af48f6b3 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 16:06:07 2021 +0200 FreeBSD support, patch 1 Primarily these changes concern the nature of alignment generated signals. On Linux, these produce SIGSEGV and n FreeBSD they produce SIGBUS. Diff: --- VEX/priv/guest_amd64_toIR.c | 131 +++++++++++++++++++++++--------------------- VEX/priv/guest_ppc_toIR.c | 2 +- VEX/priv/host_amd64_defs.c | 1 + VEX/priv/host_amd64_isel.c | 2 + VEX/priv/main_globals.c | 2 +- VEX/pub/libvex.h | 2 +- 6 files changed, 74 insertions(+), 66 deletions(-) diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c index c6296f3987..c7f94b15b5 100644 --- a/VEX/priv/guest_amd64_toIR.c +++ b/VEX/priv/guest_amd64_toIR.c @@ -10132,38 +10132,43 @@ static IRTemp math_PALIGNR_XMM ( IRTemp sV, IRTemp dV, UInt imm8 ) return res; } - /* Generate a SIGSEGV followed by a restart of the current instruction if effective_addr is not 16-aligned. This is required behaviour for some SSE3 instructions and all 128-bit SSSE3 instructions. - This assumes that guest_RIP_curr_instr is set correctly! */ + This assumes that guest_RIP_curr_instr is set correctly! + On FreeBSD, this kind of error generates a SIGBUS. */ static -void gen_SEGV_if_not_XX_aligned ( IRTemp effective_addr, ULong mask ) +void gen_SIGNAL_if_not_XX_aligned ( IRTemp effective_addr, ULong mask ) { stmt( IRStmt_Exit( binop(Iop_CmpNE64, binop(Iop_And64,mkexpr(effective_addr),mkU64(mask)), mkU64(0)), +#if defined(VGO_freebsd) + Ijk_SigBUS, +#else Ijk_SigSEGV, +#endif IRConst_U64(guest_RIP_curr_instr), OFFB_RIP ) ); } -static void gen_SEGV_if_not_16_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 16-1); +static void gen_SIGNAL_if_not_16_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 16-1); } -static void gen_SEGV_if_not_32_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 32-1); +static void gen_SIGNAL_if_not_32_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 32-1); } -static void gen_SEGV_if_not_64_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 64-1); +static void gen_SIGNAL_if_not_64_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 64-1); } + /* Helper for deciding whether a given insn (starting at the opcode byte) may validly be used with a LOCK prefix. The following insns may be used with LOCK when their destination operand is in memory. @@ -11916,7 +11921,7 @@ static Long dis_XSAVE ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_64_aligned(addr); + gen_SIGNAL_if_not_64_aligned(addr); DIP("%sxsave %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -11960,7 +11965,7 @@ static Long dis_FXSAVE ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); DIP("%sfxsave %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12171,7 +12176,7 @@ static Long dis_XRSTOR ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_64_aligned(addr); + gen_SIGNAL_if_not_64_aligned(addr); DIP("%sxrstor %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12241,7 +12246,7 @@ static Long dis_FXRSTOR ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); DIP("%sfxrstor %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12947,7 +12952,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movapd %s,%s\n", dis_buf, @@ -12968,7 +12973,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movaps %s,%s\n", dis_buf, @@ -12992,7 +12997,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movaps %s,%s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf ); @@ -13012,7 +13017,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movapd %s,%s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf ); @@ -13210,7 +13215,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movntp%s %s,%s\n", sz==2 ? "d" : "s", dis_buf, @@ -13955,7 +13960,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movdqa %s,%s\n", dis_buf, @@ -14255,7 +14260,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, nameXMMReg(eregOfRexRM(pfx,modrm))); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); delta += alen; storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movdqa %s, %s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf); @@ -14936,7 +14941,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movntdq %s,%s\n", dis_buf, nameXMMReg(gregOfRexRM(pfx,modrm))); @@ -15363,7 +15368,7 @@ static Long dis_MOVSxDUP_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); DIP("%smovs%cdup %s,%s\n", isAvx ? "v" : "", isL ? 'l' : 'h', dis_buf, nameXMMReg(rG)); @@ -15718,7 +15723,7 @@ static Long dis_PHADD_128 ( const VexAbiInfo* vbi, Prefix pfx, Long delta, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); DIP("%sph%s %s,%s\n", isAvx ? "v" : "", str, dis_buf, nameXMMReg(rG)); @@ -15878,7 +15883,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pshufb %s,%s\n", dis_buf, @@ -16030,7 +16035,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, DIP("pmaddubsw %s,%s\n", nameXMMReg(rE), nameXMMReg(rG)); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pmaddubsw %s,%s\n", dis_buf, nameXMMReg(rG)); @@ -16125,7 +16130,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("psign%s %s,%s\n", str, dis_buf, @@ -16209,7 +16214,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pmulhrsw %s,%s\n", dis_buf, @@ -16288,7 +16293,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pabs%s %s,%s\n", str, dis_buf, @@ -16395,7 +16400,7 @@ Long dis_ESC_0F3A__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); d64 = (Long)getUChar(delta+alen); delta += alen+1; @@ -16940,7 +16945,7 @@ static Long dis_xTESTy_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign(vecE, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "%s%stest%s %s,%s\n", @@ -17742,7 +17747,7 @@ static Long dis_PHMINPOSUW_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("%sphminposuw %s,%s\n", mbV, dis_buf, nameXMMReg(rG)); @@ -17976,7 +17981,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign(vecE, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "%s %s,%s\n", nm, @@ -18109,7 +18114,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movntdqa %s,%s\n", dis_buf, @@ -18138,7 +18143,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( argL, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "packusdw %s,%s\n", @@ -18321,7 +18326,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( argL, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "pmulld %s,%s\n", @@ -19292,7 +19297,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( src0, loadLE(Ity_F32, binop(Iop_Add64, mkexpr(addr), mkU64(0) ))); assign( src1, loadLE(Ity_F32, @@ -19354,7 +19359,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( src0, loadLE(Ity_F64, binop(Iop_Add64, mkexpr(addr), mkU64(0) ))); assign( src1, loadLE(Ity_F64, @@ -19459,7 +19464,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19495,7 +19500,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19532,7 +19537,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19754,7 +19759,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19787,7 +19792,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19823,7 +19828,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19860,7 +19865,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( svec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -22359,7 +22364,7 @@ Long dis_ESC_0F ( /* cmpxchg16b requires an alignment check. */ if (sz == 8) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); /* Get the expected and new values. */ assign( expdHi64, getIReg64(R_RDX) ); @@ -24764,7 +24769,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putYMMRegLoAndZU( rG, loadLE(Ity_V128, mkexpr(addr)) ); DIP("vmovapd %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -24782,7 +24787,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); putYMMReg( rG, loadLE(Ity_V256, mkexpr(addr)) ); DIP("vmovapd %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -24800,7 +24805,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putYMMRegLoAndZU( rG, loadLE(Ity_V128, mkexpr(addr)) ); DIP("vmovaps %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -24818,7 +24823,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); putYMMReg( rG, loadLE(Ity_V256, mkexpr(addr)) ); DIP("vmovaps %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -24839,7 +24844,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovapd %s,%s\n", nameXMMReg(rG), dis_buf ); delta += alen; @@ -24857,7 +24862,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovapd %s,%s\n", nameYMMReg(rG), dis_buf ); delta += alen; @@ -24876,7 +24881,7 @@ Long dis_ESC_0F__VEX ( goto decode_success; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovaps %s,%s\n", nameXMMReg(rG), dis_buf ); delta += alen; @@ -24895,7 +24900,7 @@ Long dis_ESC_0F__VEX ( goto decode_success; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovaps %s,%s\n", nameYMMReg(rG), dis_buf ); delta += alen; @@ -25034,7 +25039,7 @@ Long dis_ESC_0F__VEX ( assign(tS, getXMMReg(rS)); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovntp%c %s,%s\n", have66(pfx) ? 'd' : 's', nameXMMReg(rS), dis_buf); @@ -25050,7 +25055,7 @@ Long dis_ESC_0F__VEX ( assign(tS, getYMMReg(rS)); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovntp%c %s,%s\n", have66(pfx) ? 'd' : 's', nameYMMReg(rS), dis_buf); @@ -26041,7 +26046,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); assign(tD, loadLE(Ity_V256, mkexpr(addr))); DIP("vmovdq%c %s,%s\n", ch, dis_buf, nameYMMReg(rD)); } @@ -26066,7 +26071,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign(tD, loadLE(Ity_V128, mkexpr(addr))); DIP("vmovdq%c %s,%s\n", ch, dis_buf, nameXMMReg(rD)); } @@ -26604,7 +26609,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovdq%c %s,%s\n", ch, nameYMMReg(rS), dis_buf); } @@ -26629,7 +26634,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovdq%c %s,%s\n", ch, nameXMMReg(rS), dis_buf); } @@ -27301,7 +27306,7 @@ Long dis_ESC_0F__VEX ( UInt rG = gregOfRexRM(pfx,modrm); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovntdq %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -27315,7 +27320,7 @@ Long dis_ESC_0F__VEX ( UInt rG = gregOfRexRM(pfx,modrm); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovntdq %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -28936,7 +28941,7 @@ Long dis_ESC_0F38__VEX ( IRTemp tD = newTemp(Ity_V128); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign(tD, loadLE(Ity_V128, mkexpr(addr))); DIP("vmovntdqa %s,%s\n", dis_buf, nameXMMReg(rD)); putYMMRegLoAndZU(rD, mkexpr(tD)); @@ -28950,7 +28955,7 @@ Long dis_ESC_0F38__VEX ( IRTemp tD = newTemp(Ity_V256); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); assign(tD, loadLE(Ity_V256, mkexpr(addr))); DIP("vmovntdqa %s,%s\n", dis_buf, nameYMMReg(rD)); putYMMReg(rD, mkexpr(tD)); diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c index 5d9f6b84a2..d90d566ed1 100644 --- a/VEX/priv/guest_ppc_toIR.c +++ b/VEX/priv/guest_ppc_toIR.c @@ -4776,7 +4776,7 @@ static IRExpr * is_NaN_Vector( IRType element_size, IRExpr *src ) IRTemp zeroV128 = newTemp( Ity_V128 ); IRTemp exp_maskV128 = newTemp( Ity_V128 ); IRTemp frac_maskV128 = newTemp( Ity_V128 ); - IROp opCmpEQ; + IROp opCmpEQ = Iop_INVALID; assign( zeroV128, mkV128( 0 ) ); diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c index 3d237e112d..69afab739c 100644 --- a/VEX/priv/host_amd64_defs.c +++ b/VEX/priv/host_amd64_defs.c @@ -3268,6 +3268,7 @@ Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, case Ijk_NoRedir: trcval = VEX_TRC_JMP_NOREDIR; break; case Ijk_SigTRAP: trcval = VEX_TRC_JMP_SIGTRAP; break; case Ijk_SigSEGV: trcval = VEX_TRC_JMP_SIGSEGV; break; + case Ijk_SigBUS: trcval = VEX_TRC_JMP_SIGBUS; break; case Ijk_Boring: trcval = VEX_TRC_JMP_BORING; break; /* We don't expect to see the following being assisted. */ case Ijk_Ret: diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c index 3299c3df91..8687079c1a 100644 --- a/VEX/priv/host_amd64_isel.c +++ b/VEX/priv/host_amd64_isel.c @@ -5150,6 +5150,7 @@ static void iselStmt ( ISelEnv* env, IRStmt* stmt ) case Ijk_NoDecode: case Ijk_NoRedir: case Ijk_SigSEGV: + case Ijk_SigBUS: case Ijk_SigTRAP: case Ijk_Sys_syscall: case Ijk_Sys_int210: @@ -5246,6 +5247,7 @@ static void iselNext ( ISelEnv* env, case Ijk_NoDecode: case Ijk_NoRedir: case Ijk_SigSEGV: + case Ijk_SigBUS: case Ijk_SigTRAP: case Ijk_Sys_syscall: case Ijk_Sys_int210: diff --git a/VEX/priv/main_globals.c b/VEX/priv/main_globals.c index b2243f565c..9167e8131c 100644 --- a/VEX/priv/main_globals.c +++ b/VEX/priv/main_globals.c @@ -57,7 +57,7 @@ Int vex_debuglevel = 0; Int vex_traceflags = 0; /* Max # guest insns per bb */ -VexControl vex_control = { 0,0,False,0,0,0 }; +VexControl vex_control = { 0,0,VexRegUpd_INVALID,0,0,False,0 }; diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index dcf022159b..8d911db440 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -635,7 +635,7 @@ typedef extern void LibVEX_Init ( /* failure exit function */ -# if __cplusplus == 1 && __GNUC__ && __GNUC__ <= 3 +# if defined(__cplusplus) && defined(__GNUC__) && __GNUC__ <= 3 /* g++ 3.x doesn't understand attributes on function parameters. See #265762. */ # else |
|
From: Peter B. <be...@li...> - 2021-10-05 21:25:36
|
On 9/13/21 11:40 AM, Carl Love wrote:
> Remove deprecated regression tests for mftgpr and mffgpr.
[snip]
> case 0x2DF: { // mftgpr (move floating-point to general purpose register)
> + /* The mftgpr instruction was deprecated in Power 7, 2009 timeframe.
> + Leaving support in Valgrind for now (9/10/2021). Can remove the
> + mftgpr support in Valgrind if the opcode ever gets reused. */
To be pedantic, the mffgpr and mftgpr instructions never made it "officially"
into any cpu. They were planned to be available in POWER6 but were yanked
at the last minute and a supported POWER6 (ie, AT_PLATFORM=power6) will
give you a SIGILL if you execute it. They are available when you boot your
POWER6 system in RAW mode (ie, AT_PLATFORM=power6x), then they will work.
Since RAW mode is unsupported, I think we can treat these instructions as
never really ever being implemented.
Peter
|
|
From: Mark W. <ma...@kl...> - 2021-10-05 16:16:11
|
Hi Carl, On Fri, 2021-10-01 at 14:54 -0700, Carl Love wrote: > I opened a number of Power PC bugzillas for the various items I was > working on. I committed my 13 patch series that fixes all the issues > in the bugzillas that I opened yesterday. I verified that the > regression test run from last night reported the additional three > tests > that were added ran. No new issues were reported. I have now closed > all of the bugzillas for the issues that I opened. > > I looked thru the outstanding Valgrind bugs and closed a couple > additional bugs that have been fixed. Thanks! > There are two bugs that users have reported on Powerpc that are still > open: > > https://bugs.kde.org/show_bug.cgi?id=420780 > https://bugs.kde.org/show_bug.cgi?id=411189 > > [...] > Those are the only two open issues specific to PPC that I am aware > of. > It looks to me that both issues are fixed. Yes, it looks like both these are good now. > I am not aware of any additional powerpc specific issues in Valgrind at > this time. So from the Powerpc perspective, we are ready for the next > Valgrind release. Great. We still have Paul's freebsd patches to land. But it looks like we are fairly close now. I would like to resolve at least the following bugs: https://bugs.kde.org/show_bug.cgi?id=439090 Implement close_range(2) ("WARNING: unhandled amd64-linux syscall: 436") Which has an initial patch, but probably needs to use the file descriptor tracking. https://bugs.kde.org/show_bug.cgi?id=426148 Valgrind crash with "impossible happened" when running BPF CO-RE programs Which is about an extension of the bpf systemcall for which we currently crash, but we should be able to handle. I still have an odd issue on s390x with the vgdb, for which I have a workaround, but no root cause yet: https://bugs.kde.org/show_bug.cgi?id=441474 And it seems that if we get a fatal signal at an unfortunate place in the guest program and we call __libc_freeres things blow up. We might want to only call __libc_freeres on normal program exit, not after processing a fatal signal. Don't have a small reproducer yet. Please let me know if there are any other pending bugs that would be nice to get resolved before the release. Cheers, Mark |
|
From: Mark W. <ma...@so...> - 2021-10-05 10:28:36
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=efe91b114ac9eae3b77bf3dd73f7e0fb14dd7c82 commit efe91b114ac9eae3b77bf3dd73f7e0fb14dd7c82 Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 5 12:27:46 2021 +0200 Add 368960 WARNING: unhandled amd64-linux syscall: 163 (acct) in NEWS Fixed in commit 9aa51a6e2 Hook up acct syscall for amd64, mips32, ppc32 and ppc64 Diff: --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 8f62518401..e4cec71c56 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +368960 WARNING: unhandled amd64-linux syscall: 163 (acct) 423963 Error in child thread when CLONE_PIDFD is used 429375 PPC ISA 3.1 support is missing, part 9 431157 PPC_FEATURE2_SCV needs to be masked in AT_HWCAP2 |
|
From: Andreas A. <ar...@so...> - 2021-10-04 12:51:16
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bc78771b8b7b981dd8dfc9909fefed2d7f77d5a9 commit bc78771b8b7b981dd8dfc9909fefed2d7f77d5a9 Author: Andreas Arnez <ar...@li...> Date: Fri Oct 1 20:10:54 2021 +0200 s390x: Add missing "cc" clobbers in test case inline asms Some inline assemblies in various s390x test cases miss specifying the condition code "cc" in the clobber list. Although this has not actually been seen to cause wrong code generation, it certainly might, so fix this. Diff: --- none/tests/s390x/bfp-2.c | 12 ++++++------ none/tests/s390x/cgij.c | 2 +- none/tests/s390x/cgrj.c | 2 +- none/tests/s390x/cij.c | 2 +- none/tests/s390x/clgij.c | 2 +- none/tests/s390x/clgrj.c | 2 +- none/tests/s390x/clij.c | 2 +- none/tests/s390x/clrj.c | 2 +- none/tests/s390x/crj.c | 2 +- none/tests/s390x/dfp-1.c | 1 + none/tests/s390x/dfp-2.c | 6 ++++-- none/tests/s390x/dfp-3.c | 1 + none/tests/s390x/lsc2.c | 15 ++++++++++----- none/tests/s390x/misc3.c | 2 +- none/tests/s390x/pfpo.c | 3 ++- none/tests/s390x/tre.c | 2 +- none/tests/s390x/troo.c | 2 +- none/tests/s390x/trot.c | 2 +- none/tests/s390x/trto.c | 2 +- none/tests/s390x/trtt.c | 2 +- none/tests/s390x/xc.c | 20 ++++++++++---------- 21 files changed, 48 insertions(+), 38 deletions(-) diff --git a/none/tests/s390x/bfp-2.c b/none/tests/s390x/bfp-2.c index a4295daa9c..73349eddd2 100644 --- a/none/tests/s390x/bfp-2.c +++ b/none/tests/s390x/bfp-2.c @@ -27,7 +27,7 @@ void lnebr(float in) { float out; - __asm__ volatile("lnebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lnebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lnebr %f -> %f\n", in, out); } @@ -35,7 +35,7 @@ void lndbr(double in) { double out; - __asm__ volatile("lndbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lndbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lndbr %f -> %f\n", in, out); } @@ -43,7 +43,7 @@ void lpebr(float in) { float out; - __asm__ volatile("lpebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lpebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lpebr %f -> %f\n", in, out); } @@ -51,7 +51,7 @@ void lpdbr(double in) { double out; - __asm__ volatile("lpdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lpdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lpdbr %f -> %f\n", in, out); } @@ -59,7 +59,7 @@ void lcebr(float in) { float out; - __asm__ volatile("lcebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lcebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lcebr %f -> %f\n", in, out); } @@ -67,7 +67,7 @@ void lcdbr(double in) { double out; - __asm__ volatile("lcdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in)); + __asm__ volatile("lcdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in) : "cc"); printf("lcdbr %f -> %f\n", in, out); } diff --git a/none/tests/s390x/cgij.c b/none/tests/s390x/cgij.c index 799e4240b2..6b69565bc2 100644 --- a/none/tests/s390x/cgij.c +++ b/none/tests/s390x/cgij.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/cgrj.c b/none/tests/s390x/cgrj.c index 3a5abd336b..d11a63242c 100644 --- a/none/tests/s390x/cgrj.c +++ b/none/tests/s390x/cgrj.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/cij.c b/none/tests/s390x/cij.c index 34e24d0ce9..10f0a988cc 100644 --- a/none/tests/s390x/cij.c +++ b/none/tests/s390x/cij.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/clgij.c b/none/tests/s390x/clgij.c index 7cfd509852..d993deadca 100644 --- a/none/tests/s390x/clgij.c +++ b/none/tests/s390x/clgij.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/clgrj.c b/none/tests/s390x/clgrj.c index c7917df505..9ffd1114a2 100644 --- a/none/tests/s390x/clgrj.c +++ b/none/tests/s390x/clgrj.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/clij.c b/none/tests/s390x/clij.c index dc627cdcc9..01636cf7df 100644 --- a/none/tests/s390x/clij.c +++ b/none/tests/s390x/clij.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/clrj.c b/none/tests/s390x/clrj.c index ba42b948db..b88232134f 100644 --- a/none/tests/s390x/clrj.c +++ b/none/tests/s390x/clrj.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/crj.c b/none/tests/s390x/crj.c index df3bd2009a..65d9d0d9ad 100644 --- a/none/tests/s390x/crj.c +++ b/none/tests/s390x/crj.c @@ -2,7 +2,7 @@ #include <stdint.h> #include "opcodes.h" -#define BRASLCLOBBER "0","1","2","3","4","5","14", \ +#define BRASLCLOBBER "cc", "0","1","2","3","4","5","14", \ "f0","f1","f2","f3","f4","f5","f6","f7" void if_eq(void) { printf("equal\n"); } diff --git a/none/tests/s390x/dfp-1.c b/none/tests/s390x/dfp-1.c index 1b7d51b9e3..b9be89963f 100644 --- a/none/tests/s390x/dfp-1.c +++ b/none/tests/s390x/dfp-1.c @@ -15,6 +15,7 @@ volatile _Decimal128 d128_1, d128_2, result_128; "srl %1,28\n\t" \ :"+f" (d1), "=d" (cc) \ :"f"(d2) \ + :"cc" \ ); \ d1; \ }) diff --git a/none/tests/s390x/dfp-2.c b/none/tests/s390x/dfp-2.c index bec51be3df..061fff4c7a 100644 --- a/none/tests/s390x/dfp-2.c +++ b/none/tests/s390x/dfp-2.c @@ -89,7 +89,8 @@ void ltdtr(_Decimal64 in) "ipm %1\n\t" "srl %1,28\n\t" :[out] "=d" (out), "=d" (cc) - :[in] "f" (in)); + :[in] "f" (in) + :"cc"); printf("LTDTR "); DFP_VAL_PRINT(in, _Decimal64); printf(" -> %d\n", cc); @@ -103,7 +104,8 @@ void ltxtr(_Decimal128 in) "ipm %1\n\t" "srl %1,28\n\t" :[out] "=f" (out), "=d" (cc) - :[in] "f" (in)); + :[in] "f" (in) + :"cc"); printf("LTXTR "); DFP_VAL_PRINT(in, _Decimal128); printf(" -> %d\n", cc); diff --git a/none/tests/s390x/dfp-3.c b/none/tests/s390x/dfp-3.c index ed0177c69f..5120ed6b4e 100644 --- a/none/tests/s390x/dfp-3.c +++ b/none/tests/s390x/dfp-3.c @@ -19,6 +19,7 @@ "srl %0,28\n\t" \ :"=d" (cc) \ :"f"(d1), "f"(d2) \ + :"cc" \ ); \ cc; \ }) diff --git a/none/tests/s390x/lsc2.c b/none/tests/s390x/lsc2.c index ecfc5a9816..c026dcbd62 100644 --- a/none/tests/s390x/lsc2.c +++ b/none/tests/s390x/lsc2.c @@ -163,7 +163,8 @@ static bool test_llzrgf(const uint32_t testedValue) : [testedValue] "r"(testedValue), \ [invertedValue] "r"(invertedValue), \ [overrideValue] #ARGUMENT_ASM_TYPE(overrideValue), \ - "[after]"(after)); \ + "[after]"(after) \ + : "cc"); \ \ SMART_RETURN_R64(TESTED_INSTRUCTION); \ } @@ -199,7 +200,8 @@ declare_load_high_on_condition(locfhl, <, m) : [after] "=" #ARGUMENT_ASM_TYPE(after) \ : [testedValue] "r"(testedValue), \ [invertedValue] "r"(invertedValue), \ - [overrideValue] "r"(overrideValue)); \ + [overrideValue] "r"(overrideValue) \ + : "cc"); \ \ SMART_RETURN_R64(TESTED_INSTRUCTION); \ } @@ -235,7 +237,8 @@ declare_store_high_on_condition(stocfhl, <, m) : [after] "=r"(after) \ : [testedValue] "r"(testedValue), \ [invertedValue] "r"(invertedValue), \ - "[after]"(after)); \ + "[after]"(after) \ + : "cc"); \ \ SMART_RETURN_R64(TESTED_INSTRUCTION); \ } @@ -273,7 +276,8 @@ declare_load_halfword_immediate_on_condition(locghil, uint64_t, <, r) : [after] "=r"(after) \ : [testedValue] "r"(testedValue), \ [invertedValue] "r"(invertedValue), \ - "[after]"(after)); \ + "[after]"(after) \ + : "cc"); \ \ SMART_RETURN_R64(TESTED_INSTRUCTION); \ } @@ -314,7 +318,8 @@ static void test_all_locfh() __asm__ volatile("lcbb %[after], %[testedPointer], " #M_FIELD \ "\n" \ : [after] "=r"(after) \ - : [testedPointer] "m"(*testedPointer)); \ + : [testedPointer] "m"(*testedPointer) \ + : "cc"); \ \ SMART_RETURN_R64(lcbb##M_FIELD); \ } diff --git a/none/tests/s390x/misc3.c b/none/tests/s390x/misc3.c index ae6e8d4c2b..fbf4cae682 100644 --- a/none/tests/s390x/misc3.c +++ b/none/tests/s390x/misc3.c @@ -106,7 +106,7 @@ static int test_all_popcnt() [out1] "+d" (out1) \ : [a] "d" (a), \ [b] "d" (b) \ - : ); \ + : "cc"); \ \ printf("\t%016lx %016lx -> %016lx %016lx\n", \ a, b, out0, out1); \ diff --git a/none/tests/s390x/pfpo.c b/none/tests/s390x/pfpo.c index dd4fcec7d1..1bfd8896c7 100644 --- a/none/tests/s390x/pfpo.c +++ b/none/tests/s390x/pfpo.c @@ -36,7 +36,8 @@ "ipm %2\n\t" \ "srl %2,28\n\t" \ :"=f"(dst_reg), "=d"(ret), "=d" (cc) \ - : "f"(src_reg), "d"(fn)); \ + : "f"(src_reg), "d"(fn) \ + : "cc"); \ ret_code = ret; \ dst_reg; \ }) diff --git a/none/tests/s390x/tre.c b/none/tests/s390x/tre.c index dd2e1efce8..da0e38d3e0 100644 --- a/none/tests/s390x/tre.c +++ b/none/tests/s390x/tre.c @@ -31,7 +31,7 @@ tre_regs tre(uint8_t *codepage, uint8_t *addr, uint64_t len, uint8_t test_byte) " ipm %0\n" " srl %0,28\n" :"=d"(cc),"+&d"(a1) - :"d"(a2),"d"(param),"d"(l1),"d"(test_byte): "memory" ); + :"d"(a2),"d"(param),"d"(l1),"d"(test_byte): "cc", "memory" ); regs.addr = a1; regs.len = l1; diff --git a/none/tests/s390x/troo.c b/none/tests/s390x/troo.c index 374f3cd20c..f62ad0d057 100644 --- a/none/tests/s390x/troo.c +++ b/none/tests/s390x/troo.c @@ -41,7 +41,7 @@ troo_regs tr(uint8_t *addr, uint8_t *codepage, uint8_t *dest, uint64_t len, " srl %0,28\n" : "=d"(cc),"+&d"(desaddr) : "d" (srcaddr),"d"(test_byte),"d" (codepage2),"d"(length) - : "memory" ); + : "cc", "memory" ); regs.srcaddr = srcaddr; regs.len = length; diff --git a/none/tests/s390x/trot.c b/none/tests/s390x/trot.c index b4b44c86ae..76072c0277 100644 --- a/none/tests/s390x/trot.c +++ b/none/tests/s390x/trot.c @@ -42,7 +42,7 @@ trot_regs tr(uint8_t *addr, uint16_t *codepage, uint16_t *dest, uint64_t len, " srl %0,28\n" : "=d"(cc),"+&d"(desaddr) : "d" (srcaddr),"d"(test_byte),"d" (codepage2),"d"(length) - : "memory" ); + : "cc", "memory" ); regs.srcaddr = srcaddr; regs.len = length; diff --git a/none/tests/s390x/trto.c b/none/tests/s390x/trto.c index b79721d771..f8ff97645a 100644 --- a/none/tests/s390x/trto.c +++ b/none/tests/s390x/trto.c @@ -41,7 +41,7 @@ trto_regs tr(uint16_t *addr, uint16_t *codepage, uint8_t *dest, uint64_t len, " srl %0,28\n" : "=d"(cc),"+&d"(desaddr) : "d" (srcaddr),"d"(test_byte),"d" (codepage2),"d"(length) - : "memory" ); + : "cc", "memory" ); regs.srcaddr = srcaddr; regs.len = length; diff --git a/none/tests/s390x/trtt.c b/none/tests/s390x/trtt.c index e9cb89902c..c59c6416e6 100644 --- a/none/tests/s390x/trtt.c +++ b/none/tests/s390x/trtt.c @@ -42,7 +42,7 @@ trtt_regs tr(uint16_t *addr, uint16_t *codepage, uint16_t *dest, uint64_t len, " srl %0,28\n" : "=d"(cc),"+d"(desaddr),"+d"(srcaddr) : "d"(test_byte),"d" (codepage2),"d"(length) - : "memory" ); + : "cc", "memory" ); regs.srcaddr = srcaddr; regs.len = length; diff --git a/none/tests/s390x/xc.c b/none/tests/s390x/xc.c index 9c81b59f2c..86dda352d6 100644 --- a/none/tests/s390x/xc.c +++ b/none/tests/s390x/xc.c @@ -10,7 +10,7 @@ void test_oc(void) printf("\nOC:\n"); asm volatile ("oc %O0(1,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 2); @@ -28,12 +28,12 @@ void test_nc(void) printf("\nNC:\n"); asm volatile ("nc %O0(1,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 2); asm volatile ("nc %O0(19,%R0),%1\n"::"Q" (*buf1), - "Q"(*buf2):"memory"); + "Q"(*buf2):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(buf1, 20); } @@ -54,22 +54,22 @@ void test_xc(void) printf("\nXC:\n"); asm volatile ("xc %O0(1,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 4); asm volatile ("xc %O0(10,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 12); asm volatile ("xc %O0(100,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 102); asm volatile ("xc %O0(256,%R0),%0\n"::"Q" (*zero), - "Q"(*zero):"memory"); + "Q"(*zero):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(zero, 257); @@ -78,15 +78,15 @@ void test_xc(void) "ex 1,0(2)\n" "j 2f\n" "1: xc 260(1,%0),260(%0)\n" - "2:\n"::"a" (zero), "a"(zero):"memory", "1", "2"); + "2:\n"::"a" (zero), "a"(zero):"cc","memory", "1", "2"); printf("CC:%d\n", get_cc()); dump_field(zero + 260, 30); asm volatile ("xc 0(19,%0),0(%1)\n"::"a" (buf1), - "a"(buf2):"memory"); + "a"(buf2):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(buf1, 20); - asm volatile ("xc 0(10,%0),0(%0)\n"::"a" (buf3):"memory"); + asm volatile ("xc 0(10,%0),0(%0)\n"::"a" (buf3):"cc","memory"); printf("CC:%d\n", get_cc()); dump_field(buf3, 20); |
|
From: Andreas A. <ar...@so...> - 2021-10-04 12:51:10
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=ebfbc9541753b55fb1b22ba762571f80e4a497f7 commit ebfbc9541753b55fb1b22ba762571f80e4a497f7 Author: Andreas Arnez <ar...@li...> Date: Fri Sep 24 20:06:39 2021 +0200 s390x: Fix compile warnings in test cases Some GCC versions emit the following warnings for some s390x-specific test cases: warning: listing the stack pointer register '15' in a clobber list is deprecated warning: this 'else' clause does not guard... [-Wmisleading-indentation] ...this statement, but... Fix these. Most of inline assemblies declaring r15 as clobbered do not actually change its value. Only in stmg_wrap() it becomes necessary to save and restore r15. Diff: --- none/tests/s390x/cgij.c | 16 ++++++++-------- none/tests/s390x/cgrj.c | 16 ++++++++-------- none/tests/s390x/cij.c | 16 ++++++++-------- none/tests/s390x/clgij.c | 16 ++++++++-------- none/tests/s390x/clgrj.c | 16 ++++++++-------- none/tests/s390x/clij.c | 16 ++++++++-------- none/tests/s390x/clrj.c | 16 ++++++++-------- none/tests/s390x/crj.c | 16 ++++++++-------- none/tests/s390x/cu42.c | 3 ++- none/tests/s390x/stmg.c | 30 +++++++++++------------------- 10 files changed, 77 insertions(+), 84 deletions(-) diff --git a/none/tests/s390x/cgij.c b/none/tests/s390x/cgij.c index 962e56efb5..799e4240b2 100644 --- a/none/tests/s390x/cgij.c +++ b/none/tests/s390x/cgij.c @@ -35,7 +35,7 @@ void compare_never(int64_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -49,7 +49,7 @@ void compare_always(int64_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -63,7 +63,7 @@ void compare_le42(int64_t value) "brasl 14,if_gt\n\t" "j 0f\n\t" "brasl 14,if_le\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -77,7 +77,7 @@ void compare_ge42(int64_t value) "brasl 14,if_lt\n\t" "j 0f\n\t" "brasl 14,if_ge\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -91,7 +91,7 @@ void compare_gt42(int64_t value) "brasl 14,if_le\n\t" "j 0f\n\t" "brasl 14,if_gt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -105,7 +105,7 @@ void compare_lt42(int64_t value) "brasl 14,if_ge\n\t" "j 0f\n\t" "brasl 14,if_lt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -119,7 +119,7 @@ void compare_eq42(int64_t value) "brasl 14,if_ne\n\t" "j 0f\n\t" "brasl 14,if_eq\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_ne42(int64_t value) "brasl 14,if_eq\n\t" "j 0f\n\t" "brasl 14,if_ne\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/cgrj.c b/none/tests/s390x/cgrj.c index f269918402..3a5abd336b 100644 --- a/none/tests/s390x/cgrj.c +++ b/none/tests/s390x/cgrj.c @@ -37,7 +37,7 @@ void compare_never(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -53,7 +53,7 @@ void compare_always(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -69,7 +69,7 @@ void compare_le(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_le\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -85,7 +85,7 @@ void compare_ge(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_ge\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -101,7 +101,7 @@ void compare_gt(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_gt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -117,7 +117,7 @@ void compare_lt(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_lt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_eq(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_eq\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -149,7 +149,7 @@ void compare_ne(int64_t value1, int64_t value2) "j 0f\n\t" "brasl 14,if_ne\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/cij.c b/none/tests/s390x/cij.c index 4f2913e89b..34e24d0ce9 100644 --- a/none/tests/s390x/cij.c +++ b/none/tests/s390x/cij.c @@ -35,7 +35,7 @@ void compare_never(int32_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -49,7 +49,7 @@ void compare_always(int32_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -63,7 +63,7 @@ void compare_le42(int32_t value) "brasl 14,if_gt\n\t" "j 0f\n\t" "brasl 14,if_le\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -77,7 +77,7 @@ void compare_ge42(int32_t value) "brasl 14,if_lt\n\t" "j 0f\n\t" "brasl 14,if_ge\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -91,7 +91,7 @@ void compare_gt42(int32_t value) "brasl 14,if_le\n\t" "j 0f\n\t" "brasl 14,if_gt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -105,7 +105,7 @@ void compare_lt42(int32_t value) "brasl 14,if_ge\n\t" "j 0f\n\t" "brasl 14,if_lt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -119,7 +119,7 @@ void compare_eq42(int32_t value) "brasl 14,if_ne\n\t" "j 0f\n\t" "brasl 14,if_eq\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_ne42(int32_t value) "brasl 14,if_eq\n\t" "j 0f\n\t" "brasl 14,if_ne\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/clgij.c b/none/tests/s390x/clgij.c index 87d3a3a367..7cfd509852 100644 --- a/none/tests/s390x/clgij.c +++ b/none/tests/s390x/clgij.c @@ -35,7 +35,7 @@ void compare_never(uint64_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -49,7 +49,7 @@ void compare_always(uint64_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -63,7 +63,7 @@ void compare_le42(uint64_t value) "brasl 14,if_gt\n\t" "j 0f\n\t" "brasl 14,if_le\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -77,7 +77,7 @@ void compare_ge42(uint64_t value) "brasl 14,if_lt\n\t" "j 0f\n\t" "brasl 14,if_ge\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -91,7 +91,7 @@ void compare_gt42(uint64_t value) "brasl 14,if_le\n\t" "j 0f\n\t" "brasl 14,if_gt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -105,7 +105,7 @@ void compare_lt42(uint64_t value) "brasl 14,if_ge\n\t" "j 0f\n\t" "brasl 14,if_lt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -119,7 +119,7 @@ void compare_eq42(uint64_t value) "brasl 14,if_ne\n\t" "j 0f\n\t" "brasl 14,if_eq\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_ne42(uint64_t value) "brasl 14,if_eq\n\t" "j 0f\n\t" "brasl 14,if_ne\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/clgrj.c b/none/tests/s390x/clgrj.c index de6b825025..c7917df505 100644 --- a/none/tests/s390x/clgrj.c +++ b/none/tests/s390x/clgrj.c @@ -37,7 +37,7 @@ void compare_never(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -53,7 +53,7 @@ void compare_always(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -69,7 +69,7 @@ void compare_le(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_le\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -85,7 +85,7 @@ void compare_ge(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_ge\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -101,7 +101,7 @@ void compare_gt(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_gt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -117,7 +117,7 @@ void compare_lt(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_lt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_eq(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_eq\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -149,7 +149,7 @@ void compare_ne(uint64_t value1, uint64_t value2) "j 0f\n\t" "brasl 14,if_ne\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/clij.c b/none/tests/s390x/clij.c index 3b62e1c08b..dc627cdcc9 100644 --- a/none/tests/s390x/clij.c +++ b/none/tests/s390x/clij.c @@ -35,7 +35,7 @@ void compare_never(uint32_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -49,7 +49,7 @@ void compare_always(uint32_t value) "brasl 14,if_not_taken\n\t" "j 0f\n\t" "brasl 14,if_taken\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -63,7 +63,7 @@ void compare_le42(uint32_t value) "brasl 14,if_gt\n\t" "j 0f\n\t" "brasl 14,if_le\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -77,7 +77,7 @@ void compare_ge42(uint32_t value) "brasl 14,if_lt\n\t" "j 0f\n\t" "brasl 14,if_ge\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -91,7 +91,7 @@ void compare_gt42(uint32_t value) "brasl 14,if_le\n\t" "j 0f\n\t" "brasl 14,if_gt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -105,7 +105,7 @@ void compare_lt42(uint32_t value) "brasl 14,if_ge\n\t" "j 0f\n\t" "brasl 14,if_lt\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -119,7 +119,7 @@ void compare_eq42(uint32_t value) "brasl 14,if_ne\n\t" "j 0f\n\t" "brasl 14,if_eq\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_ne42(uint32_t value) "brasl 14,if_eq\n\t" "j 0f\n\t" "brasl 14,if_ne\n\t" - "0: aghi 15,160\n\t" : : "d"(val) : "15", BRASLCLOBBER); + "0: aghi 15,160\n\t" : : "d"(val) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/clrj.c b/none/tests/s390x/clrj.c index 4e3454f4dc..ba42b948db 100644 --- a/none/tests/s390x/clrj.c +++ b/none/tests/s390x/clrj.c @@ -37,7 +37,7 @@ void compare_never(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -53,7 +53,7 @@ void compare_always(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -69,7 +69,7 @@ void compare_le(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_le\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -85,7 +85,7 @@ void compare_ge(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_ge\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -101,7 +101,7 @@ void compare_gt(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_gt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -117,7 +117,7 @@ void compare_lt(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_lt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_eq(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_eq\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -149,7 +149,7 @@ void compare_ne(uint32_t value1, uint32_t value2) "j 0f\n\t" "brasl 14,if_ne\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/crj.c b/none/tests/s390x/crj.c index 936b70cae8..df3bd2009a 100644 --- a/none/tests/s390x/crj.c +++ b/none/tests/s390x/crj.c @@ -37,7 +37,7 @@ void compare_never(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -53,7 +53,7 @@ void compare_always(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_taken\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -69,7 +69,7 @@ void compare_le(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_le\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -85,7 +85,7 @@ void compare_ge(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_ge\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -101,7 +101,7 @@ void compare_gt(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_gt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -117,7 +117,7 @@ void compare_lt(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_lt\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -133,7 +133,7 @@ void compare_eq(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_eq\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } @@ -149,7 +149,7 @@ void compare_ne(int32_t value1, int32_t value2) "j 0f\n\t" "brasl 14,if_ne\n\t" "0: aghi 15,160\n\t" - : : "d"(val1), "d"(val2) : "15", BRASLCLOBBER); + : : "d"(val1), "d"(val2) : BRASLCLOBBER); return; } diff --git a/none/tests/s390x/cu42.c b/none/tests/s390x/cu42.c index 2b41d76b30..91e7e9df54 100644 --- a/none/tests/s390x/cu42.c +++ b/none/tests/s390x/cu42.c @@ -97,11 +97,12 @@ run_test(uint16_t *dst, uint64_t dst_len, uint32_t *src, uint64_t src_len) printf("UTF16: "); if (dst_len - result.len1 == 0) printf(" <none>"); - else + else { assert((dst_len - result.len1) % 2 == 0); for (i = 0; i < (dst_len - result.len1) / 2; ++i) { printf(" %04x", dst[i]); } + } printf("\n"); printf(" cc = %d\n", result.cc); diff --git a/none/tests/s390x/stmg.c b/none/tests/s390x/stmg.c index 38ec4f6d97..21765f3854 100644 --- a/none/tests/s390x/stmg.c +++ b/none/tests/s390x/stmg.c @@ -1,4 +1,4 @@ -#include <unistd.h> +#include <stdio.h> char base[] ="0123456789012345678901234567890123456789"; @@ -16,44 +16,36 @@ stmg_no_wrap(void) : "a" (base) : "5", "6", "7"); /* Write out BUF */ - asm volatile( "lghi 2, 1\n\t" // stdout - "lgr 3, %0\n\t" // buf - "lghi 4, 24\n\t" // len = 3*8 bytes - "svc 4\n\t" - : : "a" (buf) - : "2", "3", "4"); + fwrite(buf, sizeof(buf), 1, stdout); } void stmg_wrap(void) { - char buf[64]; + char buf[32]; /* Wrap around case; copies 32 bytes from BASE to BUF */ - asm volatile( "lg 15, 0(%1)\n\t" + asm volatile( "lgr 3, 15\n\t" /* save stack pointer */ "lg 0, 8(%1)\n\t" "lg 1, 16(%1)\n\t" "lg 2, 24(%1)\n\t" + "lg 15, 0(%1)\n\t" "stmg 15, 2, %0\n\t" - :"=m" (buf) + "lgr 15, 3" /* restore stack pointer */ + :"=S" (buf) : "a" (base) - : "15", "0", "1", "2"); + : "0", "1", "2", "3"); /* Write out BUF */ - asm volatile( "lghi 2, 1\n\t" // stdout - "lgr 3, %0\n\t" // buf - "lghi 4, 32\n\t" // len = 4*8 bytes - "svc 4\n\t" - : : "a" (buf) - : "2", "3", "4"); + fwrite(buf, sizeof(buf), 1, stdout); } int main(void) { stmg_no_wrap(); - write(1, "\n", 1); + putchar('\n'); stmg_wrap(); - write(1, "\n", 1); + putchar('\n'); return 0; } |
|
From: Mark W. <ma...@so...> - 2021-10-04 09:37:11
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=9aa51a6e25f21b990cbb75b8e3f486653e6173e4 commit 9aa51a6e25f21b990cbb75b8e3f486653e6173e4 Author: Mark Wielaard <ma...@kl...> Date: Mon Oct 4 11:34:05 2021 +0200 Hook up acct syscall for amd64, mips32, ppc32 and ppc64 There was already a generic linux wrapper for acct, but it was not hooked up for all linux arches. Diff: --- coregrind/m_syswrap/syswrap-amd64-linux.c | 2 +- coregrind/m_syswrap/syswrap-mips32-linux.c | 2 +- coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 +- coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 3b2dcb8e30..46d6b5bebd 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -665,7 +665,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_setrlimit, sys_setrlimit), // 160 GENX_(__NR_chroot, sys_chroot), // 161 GENX_(__NR_sync, sys_sync), // 162 - // (__NR_acct, sys_acct), // 163 + GENX_(__NR_acct, sys_acct), // 163 GENX_(__NR_settimeofday, sys_settimeofday), // 164 LINX_(__NR_mount, sys_mount), // 165 diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index b62129111b..f957c6f583 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -815,7 +815,7 @@ static SyscallTableEntry syscall_main_table[] = { //.. // (__NR_signal, sys_signal), // 48 GENX_ (__NR_geteuid, sys_geteuid), // 49 GENX_ (__NR_getegid, sys_getegid), // 50 - //.. GENX_(__NR_acct, sys_acct), // 51 + GENX_ (__NR_acct, sys_acct), // 51 LINX_ (__NR_umount2, sys_umount), // 52 //.. GENX_(__NR_lock, sys_ni_syscall), // 53 LINXY (__NR_ioctl, sys_ioctl), // 54 diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 1e2efc6777..7f9c9fa9bc 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -672,7 +672,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_geteuid, sys_geteuid), // 49 GENX_(__NR_getegid, sys_getegid), // 50 -//.. GENX_(__NR_acct, sys_acct), // 51 + GENX_(__NR_acct, sys_acct), // 51 LINX_(__NR_umount2, sys_umount), // 52 //.. GENX_(__NR_lock, sys_ni_syscall), // 53 LINXY(__NR_ioctl, sys_ioctl), // 54 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index f1a88f7ceb..43cde73271 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -661,7 +661,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_geteuid, sys_geteuid), // 49 GENX_(__NR_getegid, sys_getegid), // 50 -// _____(__NR_acct, sys_acct), // 51 + GENX_(__NR_acct, sys_acct), // 51 LINX_(__NR_umount2, sys_umount), // 52 // _____(__NR_lock, sys_lock), // 53 LINXY(__NR_ioctl, sys_ioctl), // 54 |
|
From: Mark W. <ma...@so...> - 2021-10-02 10:12:30
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3adeaba2325c83f82ec3729a0132e37b90744d0c commit 3adeaba2325c83f82ec3729a0132e37b90744d0c Author: Mark Wielaard <ma...@kl...> Date: Sat Oct 2 12:03:46 2021 +0200 Ajust filter_gdb for arm64 with eglibc 2.19 and gdb 7.7.1 Older ubuntu arm64 setups used eglibc 2.19 and gdb 7.7.1. In that case select.c could be under linux/generic and the select argument list could be split up differently over several lines. Adjust filter_gdb to catch those differences. Also checked against an Debian arm64 with glibc 2.31 and gdb 10.1. Diff: --- gdbserver_tests/filter_gdb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdbserver_tests/filter_gdb b/gdbserver_tests/filter_gdb index 4a5b5d7a5b..219039abcd 100755 --- a/gdbserver_tests/filter_gdb +++ b/gdbserver_tests/filter_gdb @@ -112,8 +112,11 @@ s/\(0x........\) in ?? ()$/\1 in syscall .../ # return SYSCALL_CANCEL.... s/in __select .*/in syscall .../ s/in __select$/in syscall .../ -/exceptfds/d +/nfds=/d +/exceptfds=/d +/timeout=/d /sysv\/linux\/select\.c/d +/sysv\/linux\/generic\/select.c/d /return SYSCALL_CANCEL /d # a more specialised system call select stack trace part |
|
From: Mark W. <ma...@so...> - 2021-10-02 08:32:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=9f6b917af2eddac10f374ee9c167f1eccb94b473 commit 9f6b917af2eddac10f374ee9c167f1eccb94b473 Author: Mark Wielaard <ma...@kl...> Date: Sat Oct 2 10:29:44 2021 +0200 Add shell.stderr.exp-dash4 to none/tests/scripts/Makefile.am EXTRA_DIST Diff: --- none/tests/scripts/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/none/tests/scripts/Makefile.am b/none/tests/scripts/Makefile.am index 6d711ccfe7..56aad05c3a 100644 --- a/none/tests/scripts/Makefile.am +++ b/none/tests/scripts/Makefile.am @@ -12,6 +12,7 @@ EXTRA_DIST = \ bug338606 bug338606.vgtest bug338606.stderr.exp \ shell shell.vgtest shell.stderr.exp \ shell.stderr.exp-dash shell.stderr.exp-dash2 shell.stderr.exp-dash3 \ + shell.stderr.exp-dash4 \ shell.stdout.exp shell.stderr.exp-illumos \ shell.stderr.exp-solaris shell.stderr.exp-solaris-spawn \ shell_badinterp shell_badinterp.vgtest shell_badinterp.stderr.exp \ |
|
From: Carl L. <ce...@us...> - 2021-10-01 21:55:02
|
Mark: I opened a number of Power PC bugzillas for the various items I was working on. I committed my 13 patch series that fixes all the issues in the bugzillas that I opened yesterday. I verified that the regression test run from last night reported the additional three tests that were added ran. No new issues were reported. I have now closed all of the bugzillas for the issues that I opened. I looked thru the outstanding Valgrind bugs and closed a couple additional bugs that have been fixed. There are two bugs that users have reported on Powerpc that are still open: https://bugs.kde.org/show_bug.cgi?id=420780 https://bugs.kde.org/show_bug.cgi?id=411189 The second one is for the darn instruction support. That support has been committed. I ran the user's test progam and it seems to be fine. Similarly, I ran the test case in the first bug and it too seems to be resolved by a gcc fix from Michael Ellerman. I put a comment in both bugs asking the reporter to verify the issue is fixed on the upstream valgrind code base. If so, they can close the issue. Those are the only two open issues specific to PPC that I am aware of. It looks to me that both issues are fixed. I am not aware of any additional powerpc specific issues in Valgrind at this time. So from the Powerpc perspective, we are ready for the next Valgrind release. Carl Love |
|
From: Mark W. <ma...@so...> - 2021-10-01 20:47:10
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=345edda439510e41e12388621db0c7a19ed354d8 commit 345edda439510e41e12388621db0c7a19ed354d8 Author: Mark Wielaard <ma...@kl...> Date: Fri Oct 1 22:44:16 2021 +0200 Extend filter_vgdb for GNU gdb (Debian 10.1-2) 10.1.90.20210103-git On Debian 11.0 arm64 gdb will emit a similar (stray) ENOTTY message as on SLES11, but for _exit.c instead of rtld.c. Diff: --- gdbserver_tests/filter_vgdb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdbserver_tests/filter_vgdb b/gdbserver_tests/filter_vgdb index 679ca4b31c..2a9e90b7be 100755 --- a/gdbserver_tests/filter_vgdb +++ b/gdbserver_tests/filter_vgdb @@ -19,6 +19,8 @@ sed -e '/relaying data between gdb and process/d' \ # filter some debuginfo problems with ld.so and SLES11 sed -e '/^1 rtld.c: No such file or directory\./d' | sed -e '/rtld.c: Inappropriate ioctl for device\./d' | +# similar for Debian 11.0 arm64 +sed -e '/_exit.c: Inappropriate ioctl for device\./d' | # and filter out any remaining empty lines sed -e '/^$/d' |