| 1 |
<html> |
| 2 |
<head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 4 |
<title>14. README.freebsd</title> |
| 5 |
<link rel="stylesheet" type="text/css" href="vg_basic.css"> |
| 6 |
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"> |
| 7 |
<link rel="home" href="index.html" title="Valgrind Documentation"> |
| 8 |
<link rel="up" href="dist.html" title="Valgrind Distribution Documents"> |
| 9 |
<link rel="prev" href="dist.readme-solaris.html" title="13. README.solaris"> |
| 10 |
<link rel="next" href="licenses.html" title="GNU Licenses"> |
| 11 |
</head> |
| 12 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 13 |
<div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr> |
| 14 |
<td width="22px" align="center" valign="middle"><a accesskey="p" href="dist.readme-solaris.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td> |
| 15 |
<td width="25px" align="center" valign="middle"><a accesskey="u" href="dist.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td> |
| 16 |
<td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td> |
| 17 |
<th align="center" valign="middle">Valgrind Distribution Documents</th> |
| 18 |
<td width="22px" align="center" valign="middle"><a accesskey="n" href="licenses.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td> |
| 19 |
</tr></table></div> |
| 20 |
<div class="chapter"> |
| 21 |
<div class="titlepage"><div><div><h1 class="title"> |
| 22 |
<a name="dist.readme-freebsd"></a>14. README.freebsd</h1></div></div></div> |
| 23 |
<div class="literallayout"><p><br> |
| 24 |
Installing from ports or via pkg<br> |
| 25 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br> |
| 26 |
<br> |
| 27 |
You can install Valgrind using either<br> |
| 28 |
<br> |
| 29 |
pkg install devel/valgrind<br> |
| 30 |
<br> |
| 31 |
or alternatively from ports (if installed)<br> |
| 32 |
<br> |
| 33 |
cd /usr/ports/devel/valgrind && make install clean<br> |
| 34 |
<br> |
| 35 |
devel/valgrind is updated with official releases of Valgrind, normally<br> |
| 36 |
in April and October each year. There is an alternative port,<br> |
| 37 |
devel/valgrind-devel which occasionally gets updated from the latest<br> |
| 38 |
Valgrind source. If you want to have the latest port, check on<br> |
| 39 |
https://www.freshports.org/ to see which is the most recent. If you<br> |
| 40 |
want to have the very latest version, you will need to build a copy<br> |
| 41 |
from source. See README for instructions on getting the source with git.<br> |
| 42 |
<br> |
| 43 |
<br> |
| 44 |
Building Valgrind<br> |
| 45 |
~~~~~~~~~~~~~~~~~<br> |
| 46 |
<br> |
| 47 |
Install ports for autotools, gmake and python.<br> |
| 48 |
<br> |
| 49 |
$ sh autogen.sh<br> |
| 50 |
$ ./configure --prefix=/where/ever<br> |
| 51 |
$ gmake<br> |
| 52 |
$ gmake install<br> |
| 53 |
<br> |
| 54 |
If you are using a jail for building, make sure that it is configured so that<br> |
| 55 |
"uname -r" returns a string that matches the pattern "XX.Y-*" where XX is the<br> |
| 56 |
major version (12, 13, 14 ...) and Y is the minor version (0, 1, 2, 3).<br> |
| 57 |
<br> |
| 58 |
Known Limitations (June 2022)<br> |
| 59 |
<br> |
| 60 |
0. Be aware that if you use a wrapper script and run Valgrind on the wrapper<br> |
| 61 |
script Valgrind may hit restrictions if the wrapper script runs any<br> |
| 62 |
Capsicum enabled applications. Examples of Capsicum enabled applications<br> |
| 63 |
are echo, basename, tee, uniq and wc. It is recommended that you either<br> |
| 64 |
avoid these applications or that you run Valgrind directly on your test<br> |
| 65 |
application.<br> |
| 66 |
1. There are some limitations when running Valgrind on code that was compiled<br> |
| 67 |
with clang. These issues are not present with code compiled with GCC.<br> |
| 68 |
a) There may be missing source information concerning variables due<br> |
| 69 |
to DWARF extensions used by GCC.<br> |
| 70 |
b) Code that uses OpenMP will generate spurious errors.<br> |
| 71 |
2. vgdb invoker, which uses ptrace, may cause system calls to be<br> |
| 72 |
interrupted. As an example, if the debuggee seems to have be<br> |
| 73 |
stuck and you press Ctrl-C in gdb the debuggee may execute<br> |
| 74 |
one more statement before stopping and returning control to<br> |
| 75 |
gdb.<br> |
| 76 |
<br> |
| 77 |
Notes for Developers<br> |
| 78 |
~~~~~~~~~~~~~~~~~~~~<br> |
| 79 |
<br> |
| 80 |
See README_DEVELOPERS, README_MISSING_SYSCALL_OR_IOCTL and docs/*<br> |
| 81 |
for more general information for developers.<br> |
| 82 |
<br> |
| 83 |
0. Adding syscalls.<br> |
| 84 |
<br> |
| 85 |
When adding syscalls, you need to look at the manpage and also syscalls.master<br> |
| 86 |
(online at<br> |
| 87 |
https://github.com/freebsd/freebsd/blob/master/sys/kern/syscalls.master<br> |
| 88 |
and for 32bit<br> |
| 89 |
https://github.com/freebsd/freebsd/blob/master/sys/compat/freebsd32/syscalls.master<br> |
| 90 |
<br> |
| 91 |
and if you installed the src package there should also be<br> |
| 92 |
<br> |
| 93 |
/usr/src/sys/kern/syscalls.master<br> |
| 94 |
and<br> |
| 95 |
/usr/src/sys/compat/freebsd32/syscalls.master)<br> |
| 96 |
<br> |
| 97 |
syscalls.master is particularly useful for seeing quickly whether parameters<br> |
| 98 |
are inputs or outputs.<br> |
| 99 |
<br> |
| 100 |
The syscall wrappers can vary from trivial to difficult. Fortunately, many are<br> |
| 101 |
either trivial (no arguments) or easy (Valgrind just needs to know what memory<br> |
| 102 |
is being read or written). Some syscalls, such as those involving process<br> |
| 103 |
creation and termination, signals and memory mapping require deeper interaction<br> |
| 104 |
with Valgrind.<br> |
| 105 |
<br> |
| 106 |
When you add syscalls you will need to modify several files<br> |
| 107 |
a) include/vki/vki-scnums-freebsd.h<br> |
| 108 |
This file contains one #define for each syscall. The _NR_ prefix (Linux<br> |
| 109 |
style) is used rather than SYS_ for compatibility with the rest of the<br> |
| 110 |
Valgrind source.<br> |
| 111 |
b) coregrind/m_syswrap/priv_syswrap-freebsd.h<br> |
| 112 |
This uses the DECL_TEMPLATE macro to generate declarations for the syscall<br> |
| 113 |
before and after wrappers.<br> |
| 114 |
c) coregrind/m_syswrap/syswrap-freebsd.c<br> |
| 115 |
This is where the bulk of the code resides. Toward the end of the file<br> |
| 116 |
the BSDX_/BSDXY macros are used to generate entries in the table of<br> |
| 117 |
syscalls. BSDX_ is used for wrappers that only have a 'before', BSDXY<br> |
| 118 |
if both wrappers are required. In general, syscalls that have no arguments<br> |
| 119 |
or only input arguments just need a BSDX_ macro (before only). Syscalls<br> |
| 120 |
with output arguments need a BSDXY macro (before and after).<br> |
| 121 |
d) If the syscall uses 64bit arguments (long long) then instead of putting<br> |
| 122 |
the wrapper definitions in syswrap-freebsd.c there will be two kinds of<br> |
| 123 |
definition. A 32bit version with split 64bit arguments for x86 in<br> |
| 124 |
syswrap-x86-freebsd.c and 64bit versions without any splitting for amd64<br> |
| 125 |
and arm64 in syswrap-amd64-freebsd.c/syswrap-arm64-freebsd.c.<br> |
| 126 |
Each long long needs to be split into two ARGs in the x86 version.<br> |
| 127 |
<br> |
| 128 |
The PRE (before) wrapper<br> |
| 129 |
------------------------<br> |
| 130 |
<br> |
| 131 |
Each PRE wrapper always contains the following two macro calls<br> |
| 132 |
<br> |
| 133 |
PRINT. This outputs the syscall name and argument values when Valgrind is<br> |
| 134 |
executed with<br> |
| 135 |
--trace-syscalls=yes<br> |
| 136 |
<br> |
| 137 |
PRE_READ_REGX. This macro lets Valgrind know about the number and types of the<br> |
| 138 |
syscall arguments which allows Valgrind to check that they are initialized.<br> |
| 139 |
X is the number of arguments. It is best that the argument names match<br> |
| 140 |
the man page, but they must match the types and number of arguments in<br> |
| 141 |
syscalls.master. Occasionally there are differences between the two.<br> |
| 142 |
<br> |
| 143 |
If the syscall takes pointers to memory there will be one of the following for<br> |
| 144 |
each pointer argument.<br> |
| 145 |
<br> |
| 146 |
PRE_MEM_RASCIIZ for NULL terminated ascii strings.<br> |
| 147 |
<br> |
| 148 |
PRE_MEM_READ for pointers to structures or arrays that are read.<br> |
| 149 |
<br> |
| 150 |
PRE_MEM_WRITE for pointers to structures or arrays that are written.<br> |
| 151 |
<br> |
| 152 |
As a rule, the definitions of structures are copied into vki-freebsd.h<br> |
| 153 |
with the vki- prefix. [vki - Valgrind kernel interface; this was done<br> |
| 154 |
historically to protect against discrepancies between user include<br> |
| 155 |
structure definitions and kernel definitions on Linux].<br> |
| 156 |
<br> |
| 157 |
The POST (after) wrapper<br> |
| 158 |
------------------------<br> |
| 159 |
<br> |
| 160 |
These are much easier.<br> |
| 161 |
<br> |
| 162 |
They just contain a POST_MEM_WRITE macro for each output argument.<br> |
| 163 |
<br> |
| 164 |
1. Frequent causes of problems<br> |
| 165 |
<br> |
| 166 |
- New _umtx_op codes. Valgrind will print "WARNING: _umtx_op unsupported value".<br> |
| 167 |
See syswrap-freebsd.c and add new cases for the new codes.<br> |
| 168 |
- Additions to auxv. Depending on the entry it may need to be simply copied<br> |
| 169 |
from the host to the guest, it may need to be modified for the guest or<br> |
| 170 |
it may need to be ignored. See initimg-freebsd.c.<br> |
| 171 |
- Versioned ioctls. ioctls such as CAMIOCOMMAND are versioned (with<br> |
| 172 |
CAM_VERSION). When the version number is increased the result is a new<br> |
| 173 |
ioctl ID. That means that the ioctl checking code no longer gets called.<br> |
| 174 |
New versions require updates to the version number and the structs that<br> |
| 175 |
are used. (Backwards compatibility is maintained by adding fixed macros<br> |
| 176 |
like CAM_VERSION_0x19, but these are not currently supported in Valgrind).<br> |
| 177 |
- ELF PT_LOAD mappings. Either Valgrind will assert or there will be no source<br> |
| 178 |
information in error reports. See VG_(di_notify_mmap) in debuginfo.c<br> |
| 179 |
- Because they contain many deliberate errors the regression tests are prone<br> |
| 180 |
to change with changes of compiler. Liberal use of 'volatile' and<br> |
| 181 |
'-Wno-warning-flag' can help - see configure.ac<br> |
| 182 |
<br> |
| 183 |
2. Running regression tests<br> |
| 184 |
<br> |
| 185 |
In order to run all of the regression tests you will need to install<br> |
| 186 |
the following packages<br> |
| 187 |
gdb<br> |
| 188 |
gsed<br> |
| 189 |
<br> |
| 190 |
In addition to running "gmake" you will need to run<br> |
| 191 |
"gmake check" to build the regression test exectutables<br> |
| 192 |
and "gmake regtest". Again, more details can be seen in<br> |
| 193 |
README_DEVELOPERS.<br> |
| 194 |
<br> |
| 195 |
If you want to run the 'nightly' script (see nightly/README.txt)<br> |
| 196 |
you will need to install coreutils (for GNU cp) and modify the<br> |
| 197 |
nightly/conf/freebsd.* files. The default configuration<br> |
| 198 |
sends an e-mail to the valgrind-testresults mailing list.<br> |
| 199 |
<br> |
| 200 |
3. Version specific code<br> |
| 201 |
<br> |
| 202 |
For its own use of syscalls and memory layout Valgrind sometimes needs<br> |
| 203 |
to detect which version of FreeBSD it is being built on. Historically<br> |
| 204 |
that was done using 'uname' at configure time. It can also be achieved<br> |
| 205 |
using the __FreeBSD_version macro (in osreldate.h and sys/param.h).<br> |
| 206 |
The former header just defines that macro. To see what changes are associated<br> |
| 207 |
with different values of the macro you can search the FreeBSD source and<br> |
| 208 |
git history. You can also look at<br> |
| 209 |
<br> |
| 210 |
https://docs.freebsd.org/en/books/porters-handbook/versions/<br> |
| 211 |
<br> |
| 212 |
<br> |
| 213 |
Feedback<br> |
| 214 |
~~~~~~~~<br> |
| 215 |
<br> |
| 216 |
If you find any problems please create a bugzilla report at<br> |
| 217 |
https://bugs.kde.org using the Valgrind product.<br> |
| 218 |
<br> |
| 219 |
Alternatively you can use the FreeBSD bugzilla<br> |
| 220 |
https://bugs.freebsd.org<br> |
| 221 |
<br> |
| 222 |
Credits<br> |
| 223 |
~~~~~~~<br> |
| 224 |
<br> |
| 225 |
Valgrind was originally ported to FreeBSD by Doug Rabson<br> |
| 226 |
in 2004.<br> |
| 227 |
<br> |
| 228 |
Paul Floyd (that's me), started looking at this project in late 2018,<br> |
| 229 |
took a long pause and then continued in earnest in January 2020.<br> |
| 230 |
<br> |
| 231 |
A big thanks to Nick Briggs for helping with the x86 version.<br> |
| 232 |
<br> |
| 233 |
Kyle Evans and Ed Maste for contributing patches and helping with the<br> |
| 234 |
integration with FreeBSD ports.<br> |
| 235 |
<br> |
| 236 |
Prior to 2018 many others have also contributed.<br> |
| 237 |
<br> |
| 238 |
Dimitry Andric<br> |
| 239 |
Simon Barner<br> |
| 240 |
Roman Bogorodskiy<br> |
| 241 |
Rebecca Cran<br> |
| 242 |
Bryan Drewery<br> |
| 243 |
Brian Fundakowski Feldman<br> |
| 244 |
Denis Generalov<br> |
| 245 |
Mikolaj Golub<br> |
| 246 |
Eugene Kilachkoff<br> |
| 247 |
Xin LI<br> |
| 248 |
Phil Longstaff<br> |
| 249 |
Pav Lucistnik<br> |
| 250 |
Conrad Meyer<br> |
| 251 |
Julien Nadeau<br> |
| 252 |
Frerich Raabe<br> |
| 253 |
Doug Rabson<br> |
| 254 |
Craig Rodrigues<br> |
| 255 |
Tom Russo<br> |
| 256 |
Stephen Sanders<br> |
| 257 |
Stanislav Sedov<br> |
| 258 |
Andrei V. Shetuhin<br> |
| 259 |
Niklas Sorensson<br> |
| 260 |
Ryan Stone<br> |
| 261 |
Jerry Toung<br> |
| 262 |
Yuri<br> |
| 263 |
<br> |
| 264 |
<br> |
| 265 |
</p></div> |
| 266 |
</div> |
| 267 |
<div> |
| 268 |
<br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer"> |
| 269 |
<tr> |
| 270 |
<td rowspan="2" width="40%" align="left"> |
| 271 |
<a accesskey="p" href="dist.readme-solaris.html"><< 13. README.solaris</a> </td> |
| 272 |
<td width="20%" align="center"><a accesskey="u" href="dist.html">Up</a></td> |
| 273 |
<td rowspan="2" width="40%" align="right"> <a accesskey="n" href="licenses.html">GNU Licenses >></a> |
| 274 |
</td> |
| 275 |
</tr> |
| 276 |
<tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr> |
| 277 |
</table> |
| 278 |
</div> |
| 279 |
</body> |
| 280 |
</html> |