README_DEVELOPERS: fix a couple of typos
[valgrind.git] / README.freebsd
blob8fa83896661ec1432a230f26f4c2123216145b52
1 Installing from ports or via pkg
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 You can install Valgrind using either
6 pkg install devel/valgrind
8 or alternatively from ports (if installed)
10 cd /usr/ports/devel/valgrind && make install clean
12 devel/valgrind is updated with official releases of Valgrind, normally
13 in April and October each year. There is an alternative port,
14 devel/valgrind-devel which occasionally gets updated from the latest
15 Valgrind source. If you want to have the latest port, check on
16 https://www.freshports.org/ to see which is the most recent. If you
17 want to have the very latest version, you will need to build a copy
18 from source. See README for instructions on getting the source with git.
21 Building Valgrind
22 ~~~~~~~~~~~~~~~~~
24 Install ports for autotools, gmake and python.
26 $ sh autogen.sh
27 $ ./configure --prefix=/where/ever
28 $ gmake
29 $ gmake install
31 If you are using a jail for building, make sure that it is configured so that
32 "uname -r" returns a string that matches the pattern "XX.Y-*" where XX is the
33 major version (12, 13, 14 ...) and Y is the minor version (0, 1, 2, 3).
35 Known Limitations (June 2022)
37 0. Be aware that if you use a wrapper script and run Valgrind on the wrapper
38    script Valgrind may hit restrictions if the wrapper script runs any
39    Capsicum enabled applications. Examples of Capsicum enabled applications
40    are echo, basename, tee, uniq and wc. It is recommended that you either
41    avoid these applications or that you run Valgrind directly on your test
42    application.
43 1. There are some limitations when running Valgrind on code that was compiled
44    with clang.  These issues are not present with code compiled with GCC.
45    a) There may be missing source information concerning variables due
46       to DWARF extensions used by GCC.
47    b) Code that uses OpenMP will generate spurious errors.
48 2. vgdb invoker, which uses ptrace, may cause system calls to be
49    interrupted. As an example, if the debuggee seems to have be
50    stuck and you press Ctrl-C in gdb the debuggee may execute
51    one more statement before stopping and returning control to
52    gdb.
54 Notes for Developers
55 ~~~~~~~~~~~~~~~~~~~~
57 See README_DEVELOPERS, README_MISSING_SYSCALL_OR_IOCTL and docs/*
58 for more general information for developers.
60 0. Adding syscalls.
62 When adding syscalls, you need to look at the manpage and also syscalls.master
63 (online at
64 https://github.com/freebsd/freebsd/blob/master/sys/kern/syscalls.master
65 and for 32bit
66 https://github.com/freebsd/freebsd/blob/master/sys/compat/freebsd32/syscalls.master
68 and if you installed the src package there should also be
70 /usr/src/sys/kern/syscalls.master
71 and
72 /usr/src/sys/compat/freebsd32/syscalls.master)
74 syscalls.master is particularly useful for seeing quickly whether parameters
75 are inputs or outputs.
77 The syscall wrappers can vary from trivial to difficult. Fortunately, many are
78 either trivial (no arguments) or easy (Valgrind just needs to know what memory
79 is being read or written). Some syscalls, such as those involving process
80 creation and termination, signals and memory mapping require deeper interaction
81 with Valgrind.
83 When you add syscalls you will need to modify several files
84    a) include/vki/vki-scnums-freebsd.h
85       This file contains one #define for each syscall. The _NR_ prefix (Linux
86       style) is used rather than SYS_ for compatibility with the rest of the
87       Valgrind source.
88    b) coregrind/m_syswrap/priv_syswrap-freebsd.h
89       This uses the DECL_TEMPLATE macro to generate declarations for the syscall
90       before and after wrappers.
91    c) coregrind/m_syswrap/syswrap-freebsd.c
92       This is where the bulk of the code resides. Toward the end of the file
93       the BSDX_/BSDXY macros are used to generate entries in the table of
94       syscalls. BSDX_ is used for wrappers that only have a 'before', BSDXY
95       if both wrappers are required. In general, syscalls that have no arguments
96       or only input arguments just need a BSDX_ macro (before only). Syscalls
97       with output arguments need a BSDXY macro (before and after).
98    d) If the syscall uses 64bit arguments (long long) then instead of putting
99       the wrapper definitions in syswrap-freebsd.c there will be two kinds of
100       definition. A 32bit version with split 64bit arguments for x86 in
101       syswrap-x86-freebsd.c and 64bit versions without any splitting for amd64
102       and arm64 in syswrap-amd64-freebsd.c/syswrap-arm64-freebsd.c.
103       Each long long needs to be split into two ARGs in the x86 version.
105 The PRE (before) wrapper
106 ------------------------
108 Each PRE wrapper always contains the following two macro calls
110 PRINT. This outputs the syscall name and argument values when Valgrind is
111 executed with
112 --trace-syscalls=yes
114 PRE_READ_REGX. This macro lets Valgrind know about the number and types of the
115 syscall arguments which allows Valgrind to check that they are initialized.
116 X is the number of arguments. It is best that the argument names match
117 the man page, but they must match the types and number of arguments in
118 syscalls.master. Occasionally there are differences between the two.
120 If the syscall takes pointers to memory there will be one of the following for
121 each pointer argument.
123 PRE_MEM_RASCIIZ for NULL terminated ascii strings.
125 PRE_MEM_READ for pointers to structures or arrays that are read.
127 PRE_MEM_WRITE for pointers to structures or arrays that are written.
129 As a rule, the definitions of structures are copied into vki-freebsd.h
130 with the vki- prefix. [vki - Valgrind kernel interface; this was done
131 historically to protect against discrepancies between user include
132 structure definitions and kernel definitions on Linux].
134 The POST (after) wrapper
135 ------------------------
137 These are much easier.
139 They just contain a POST_MEM_WRITE macro for each output argument.
141 1. Frequent causes of problems
143 - New _umtx_op codes. Valgrind will print "WARNING: _umtx_op unsupported value".
144   See syswrap-freebsd.c and add new cases for the new codes.
145 - Additions to auxv. Depending on the entry it may need to be simply copied
146   from the host to the guest, it may need to be modified for the guest or
147   it may need to be ignored. See initimg-freebsd.c.
148 - Versioned ioctls. ioctls such as CAMIOCOMMAND are versioned (with
149   CAM_VERSION). When the version number is increased the result is a new
150   ioctl ID. That means that the ioctl checking code no longer gets called.
151   New versions require updates to the version number and the structs that
152   are used. (Backwards compatibility is maintained by adding fixed macros
153   like CAM_VERSION_0x19, but these are not currently supported in Valgrind).
154 - ELF PT_LOAD mappings. Either Valgrind will assert or there will be no source
155   information in error reports. See VG_(di_notify_mmap) in debuginfo.c
156 - Because they contain many deliberate errors the regression tests are prone
157   to change with changes of compiler. Liberal use of 'volatile' and
158   '-Wno-warning-flag' can help - see configure.ac
160 2. Running regression tests
162 In order to run all of the regression tests you will need to install
163 the following packages
165 gsed
167 In addition to running "gmake" you will need to run
168 "gmake check" to build the regression test exectutables
169 and "gmake regtest".  Again, more details can be seen in
170 README_DEVELOPERS.
172 If you want to run the 'nightly' script (see nightly/README.txt)
173 you will need to install coreutils (for GNU cp) and modify the
174 nightly/conf/freebsd.* files. The default configuration
175 sends an e-mail to the valgrind-testresults mailing list.
177 Feedback
178 ~~~~~~~~
180 If you find any problems please create a bugzilla report at
181 https://bugs.kde.org using the Valgrind product.
183 Alternatively you can use the FreeBSD bugzilla
184 https://bugs.freebsd.org
186 Credits
187 ~~~~~~~
189 Valgrind was originally ported to FreeBSD by Doug Rabson
190 in 2004.
192 Paul Floyd (that's me), started looking at this project in late 2018,
193 took a long pause and then continued in earnest in January 2020.
195 A big thanks to Nick Briggs for helping with the x86 version.
197 Kyle Evans and Ed Maste for contributing patches and helping with the
198 integration with FreeBSD ports.
200 Prior to 2018 many others have also contributed.
202 Dimitry Andric
203 Simon Barner
204 Roman Bogorodskiy
205 Rebecca Cran
206 Bryan Drewery
207 Brian Fundakowski Feldman
208 Denis Generalov
209 Mikolaj Golub
210 Eugene Kilachkoff
211 Xin LI
212 Phil Longstaff
213 Pav Lucistnik
214 Conrad Meyer
215 Julien Nadeau
216 Frerich Raabe
217 Doug Rabson
218 Craig Rodrigues
219 Tom Russo
220 Stephen Sanders
221 Stanislav Sedov
222 Andrei V. Shetuhin
223 Niklas Sorensson
224 Ryan Stone
225 Jerry Toung
226 Yuri