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
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
(6) |
|
2
(6) |
3
(9) |
4
(4) |
5
(1) |
6
|
7
|
8
|
|
9
|
10
(2) |
11
(1) |
12
(2) |
13
(4) |
14
(6) |
15
(8) |
|
16
(9) |
17
(5) |
18
(13) |
19
(6) |
20
(15) |
21
(17) |
22
(19) |
|
23
(2) |
24
(4) |
25
(2) |
26
(10) |
27
(6) |
28
(9) |
29
(3) |
|
30
|
|
|
|
|
|
|
|
From: Paul F. <pj...@wa...> - 2023-04-22 19:22:29
|
On 22-04-23 19:44, Mark Wielaard wrote: > > But why do you want to reformat all the exiting code? > Isn't it enough if people have easy tools to format new hunks? > > I am happy if we encourage people to use code formatters for > new/changed code. But forcing a reformat of the whole project on > people seems like a bad idea. > > I think Paul's recent accident with clang-format shows why it is not a > good idea to try to reformat any existing code. It just introduces > huge arbitrary changes. The main thing for me is that the current indentation isn't too bad. Things like line breaks, continuation, align with assignment, multiple statements on a line are less consistent. That also means bigger diffs if reformatting. I wasn't expecting the diffs to be so big. For now I don't see enough benefit for large scale reformatting, but I am planning to continue using it for new blocks of code and new files. A+ Paul |
|
From: Paul F. <pj...@wa...> - 2023-04-22 19:09:33
|
On 22-04-23 16:35, Paul Floyd wrote:
>
>
> On 22-04-23 16:25, Mark Wielaard wrote:
>
>>
>> That is one giant patch. I assume accidential?
>> It also seems to break the build.
>> Could you please revert this (minus the NEWS typo).
>
> Yes I screwed up and pushed changes from experimenting with clang-format.
>
> Wonder how it broke the build - not very encouraging.
The error was
In file included from mc_main.c:49:
../include/pub_tool_xtmemory.h:41:38: error: unknown type name
‘XT_filter_IPs_t’
41 | extern void VG_(XTMemory_Full_init) (XT_filter_IPs_t
filter_IPs_Fn);
The compilation failure was because clang-format reordered all the
headers in mc_main.c into alphabetical order.
pub_tool_xtmemory.h has a dependency upon pub_tool_xtree.h but doesn't
include it and also pub_tool_xtree.h sorts alphabetically after
pub_tool_xtmemory.h which broke the dependency.
A+
Paul
|
|
From: Mark W. <ma...@kl...> - 2023-04-22 18:30:12
|
On Sat, Apr 22, 2023 at 09:53:22AM +1000, Nicholas Nethercote wrote: > Failing to add test files to Makefile.am is a really easy mistake to make, > and one I've done multiple times recently. Mark, you've often fixed these, > how do you detect them? I did a try push beforehand and it didn't detect > the missing file. There are two ways. make regtest does a quick check. Paul pointed out that can also be triggered by make post-regtest-checks. Maybe we should make that part of make check instead? The other is make distcheck. Which creates a dist and then tries to do a buid and make check (plus a srcdir != builddir build). The fedora-latest builder actually does a make distcheck, but since make auxchecks fails there it isn't in the try builders and doesn't show up as a new failure. I'll remove the auxchecks step and add it to the try builders. Cheers, Mark |
|
From: Mark W. <ma...@kl...> - 2023-04-22 17:45:20
|
Hi Nick, On Fri, Apr 21, 2023 at 09:06:06AM +1000, Nicholas Nethercote wrote: > On Fri, 21 Apr 2023 at 07:06, Bart Van Assche <bva...@ac...> wrote: > > > No matter how > > much time is spent on tuning the .clang-format file, there will always > > be code for which the formatting is made worse by clang-format than the > > existing code. > > > > It's true that there are rare cases where an auto-formatter does a bad job, > such as code in tabular form. > > Fortunately there's an easy workaround for that too: you just put `// > clang-format off` at the start of the block and `// clang-format on` at the > end of the block. But why do you want to reformat all the exiting code? Isn't it enough if people have easy tools to format new hunks? I am happy if we encourage people to use code formatters for new/changed code. But forcing a reformat of the whole project on people seems like a bad idea. I think Paul's recent accident with clang-format shows why it is not a good idea to try to reformat any existing code. It just introduces huge arbitrary changes. Cheers, Mark |
|
From: Mark W. <ma...@kl...> - 2023-04-22 17:25:23
|
Hi Nick,
On Fri, Apr 21, 2023 at 06:51:42AM +1000, Nicholas Nethercote wrote:
> On Fri, 21 Apr 2023 at 06:02, Mark Wielaard <ma...@kl...> wrote:
> > Sure you can work around it, but I don't think that is a great
> > solution. It requires everyone to make some local changes.
> >
>
> You can send up a .gitconfig for the project, so it'll work automatically
> for everyone.
How? If you can install the .gitconfig automatically that would be
interesting, but I believe you'll always have to install .gitconfig
tweaks by hand.
> > I am not a fan, but also not dead against.
>
> Have you ever worked on a project that uses auto-formatting? Skepticism
> followed by enthusiasm is common. Paul, Julian, and I all have used it on
> other codebases and are now advocates. I'm using it for Cachegrind's Python
> code right now. It makes life easier.
I can see how it would work nicely for new python code. gdb also uses
python black (plus a buildbot checker) to auto-format their python
code. If you like we could add the same to the buildbot for valgrind.
BTW. Trying the various formatters listed in auxprogs/pybuild.sh gives
me (pylint suggests to use a range generator instead of an array, then
black reformates the file to get everything on one line:
diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in
index c76a760be..cba91aec7 100755
--- a/cachegrind/cg_annotate.in
+++ b/cachegrind/cg_annotate.in
@@ -1090,9 +1090,7 @@ def print_annotated_src_files(
# mtimes as if they are all as early as the earliest one.
# Therefore, we warn only if the earliest source file is
# more recent than the cgout file.
- min_ofl_st_mtime_ns = min(
- [os.stat(ofl).st_mtime_ns for ofl in ofls]
- )
+ min_ofl_st_mtime_ns = min(os.stat(ofl).st_mtime_ns for ofl in ofls)
for cgout_filename in args.cgout_filename:
if min_ofl_st_mtime_ns > os.stat(cgout_filename).st_mtime_ns:
> Personally I am happy with emacs M-x indent-region on the code I edit.
> > There is a .dir-locals.el in git which catches some (but certainly not
> > all) formatting things.
> >
>
> What about people who don't use emacs?
:) That sound like the start of a joke... I assume other editors have
something similar to M-X ident-region. But have no experience with
that. I just mentioned it to show that I do have a little experience
with formatters and do like valgrind having a .dir-locals.el. So if
the .clang-format gives the same kind of experience to others then
that is nice.
Cheers,
Mark
|
|
From: Mark W. <ma...@kl...> - 2023-04-22 16:13:46
|
Hi Tobias, On Sat, Apr 22, 2023 at 08:28:40AM +0200, Tobias Bading wrote: > Building c8832cb2d on Ubuntu (MATE) 20.04.6 LTS with gcc 9.4.0 > (Ubuntu 9.4.0-1ubuntu1~20.04.1) produces these 3 warnings: > > vgdb.c: In function ‘do_multi_mode’: > vgdb.c:1332:11: warning: ignoring return value of ‘asprintf’, declared > with attribute warn_unused_result [-Wunused-result] > 1332 | asprintf (&reply, > | ^~~~~~~~~~~~~~~~~ > […] > 1347 | "QSetWorkingDir+", (UInt)PBUFSIZ - 1); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > vgdb.c: In function ‘fork_and_exec_valgrind’: > vgdb.c:1228:13: warning: ignoring return value of ‘write’, declared with > attribute warn_unused_result [-Wunused-result] > 1228 | write (pipefd[1], &err, sizeof (int)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > vgdb.c:1283:7: warning: ignoring return value of ‘write’, declared with > attribute warn_unused_result [-Wunused-result] > 1283 | write (pipefd[1], &err, sizeof (int)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks for reporting. We are in trouble if these calls to asprintf or write fail and cannot do much more than exit at that point. But I fixed all three places so to explicitly check if those calls fail. > 8 bits of contribution in NEWS: > > - from different terminals. So for example to start you program > + from different terminals. So for example to start your program Thanks. Paul already fixed this. Cheers, Mark |
|
From: Mark W. <ma...@so...> - 2023-04-22 16:10:04
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=83602059684aaf92e5ac701ca4e79fe44e3d6a00 commit 83602059684aaf92e5ac701ca4e79fe44e3d6a00 Author: Mark Wielaard <ma...@kl...> Date: Sat Apr 22 18:02:25 2023 +0200 vgdb: Always check the result from asprintf and write calls Diff: --- coregrind/vgdb.c | 57 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c index 6e5e819563..21e67c65b7 100644 --- a/coregrind/vgdb.c +++ b/coregrind/vgdb.c @@ -1225,7 +1225,14 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, if (chdir (working_dir) != 0) { err = errno; perror("chdir"); - write (pipefd[1], &err, sizeof (int)); + // We try to write the result to the parent, but always exit. + int written = 0; + while (written < sizeof (int)) { + int nrw = write (pipefd[1], &err, sizeof (int) - written); + if (nrw == -1) + break; + written += nrw; + } _exit (-1); } } @@ -1280,7 +1287,14 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, perror or printf in this situation since they aren't async-safe. */ // perror ("execvp valgrind"); // printf ("execve returned??? confusing: %d\n", res); - write (pipefd[1], &err, sizeof (int)); + // We try to write the result to the parent, but always exit. + int written = 0; + while (written < sizeof (int)) { + int nrw = write (pipefd[1], &err, sizeof (int) - written); + if (nrw == -1) + break; + written += nrw; + } _exit (-1); } @@ -1329,24 +1343,27 @@ void do_multi_mode(void) char *reply; strcpy(q_buf, buf); // Keep this in sync with coregrind/m_gdbserver/server.c - asprintf (&reply, - "PacketSize=%x;" - "QStartNoAckMode+;" - "QPassSignals+;" - "QCatchSyscalls+;" - /* Just report support always. */ - "qXfer:auxv:read+;" - /* We'll force --vgdb-shadow-registers=yes */ - "qXfer:features:read+;" - "qXfer:exec-file:read+;" - "qXfer:siginfo:read+;" - /* Some extra's vgdb support before valgrind starts up. */ - "QEnvironmentHexEncoded+;" - "QEnvironmentReset+;" - "QEnvironmentUnset+;" - "QSetWorkingDir+", (UInt)PBUFSIZ - 1); - send_packet(reply, noackmode); - free (reply); + if (asprintf (&reply, + "PacketSize=%x;" + "QStartNoAckMode+;" + "QPassSignals+;" + "QCatchSyscalls+;" + /* Just report support always. */ + "qXfer:auxv:read+;" + /* We'll force --vgdb-shadow-registers=yes */ + "qXfer:features:read+;" + "qXfer:exec-file:read+;" + "qXfer:siginfo:read+;" + /* Extra vgdb support before valgrind starts up. */ + "QEnvironmentHexEncoded+;" + "QEnvironmentReset+;" + "QEnvironmentUnset+;" + "QSetWorkingDir+", (UInt)PBUFSIZ - 1) != -1) { + send_packet(reply, noackmode); + free (reply); + } else { + XERROR(errno, "asprintf failed\n"); + } } else if (strncmp(STARTNOACKMODE, buf, strlen(STARTNOACKMODE)) == 0) { // We have to ack this one |
|
From: Paul F. <pj...@wa...> - 2023-04-22 14:35:31
|
On 22-04-23 16:25, Mark Wielaard wrote: > > That is one giant patch. I assume accidential? > It also seems to break the build. > Could you please revert this (minus the NEWS typo). Yes I screwed up and pushed changes from experimenting with clang-format. Wonder how it broke the build - not very encouraging. A+ Paul |
|
From: Paul F. <pa...@so...> - 2023-04-22 14:32:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=945b64a97f7165cf59dbe73ab83ed127cf0f9c05 commit 945b64a97f7165cf59dbe73ab83ed127cf0f9c05 Author: Paul Floyd <pj...@wa...> Date: Sat Apr 22 16:31:45 2023 +0200 Typo in NEWS (Try again, without a ton of changes from testing clang-format) Thanks Tobias, on valgrind-developers Diff: --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index bff5b5d760..35a9ce3cd2 100644 --- a/NEWS +++ b/NEWS @@ -37,7 +37,7 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. * The vgdb utility now supports extended-remote protocol when invoked with --multi. In this mode the GDB run command is supported. Which means you don't need to run gdb and valgrind - from different terminals. So for example to start you program + from different terminals. So for example to start your program in gdb and run it under valgrind you can do: $ gdb prog (gdb) set remote exec-file prog |
|
From: Paul F. <pa...@so...> - 2023-04-22 14:29:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=76d6b4591a5a05e43e1a819bf630c0d8ee857a7e commit 76d6b4591a5a05e43e1a819bf630c0d8ee857a7e Author: Paul Floyd <pj...@wa...> Date: Sat Apr 22 16:29:27 2023 +0200 Revert "Typo in NEWS" This reverts commit bf347551c99313a4af9c38bdeda9b946c9795945. Diff: --- NEWS | 2 +- coregrind/m_syswrap/syswrap-freebsd.c | 4505 ++++++++++++------------ memcheck/mc_main.c | 6134 ++++++++++++++++----------------- shared/vg_replace_strmem.c | 3195 ++++++++--------- 4 files changed, 6718 insertions(+), 7118 deletions(-) diff --git a/NEWS b/NEWS index 35a9ce3cd2..bff5b5d760 100644 --- a/NEWS +++ b/NEWS @@ -37,7 +37,7 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. * The vgdb utility now supports extended-remote protocol when invoked with --multi. In this mode the GDB run command is supported. Which means you don't need to run gdb and valgrind - from different terminals. So for example to start your program + from different terminals. So for example to start you program in gdb and run it under valgrind you can do: $ gdb prog (gdb) set remote exec-file prog diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index bde7430bf3..fd4dff4da4 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -29,57 +29,62 @@ #if defined(VGO_freebsd) -#include "pub_core_aspacemgr.h" #include "pub_core_basics.h" +#include "pub_core_vki.h" +#include "pub_core_vkiscnums.h" +#include "pub_core_threadstate.h" +#include "pub_core_aspacemgr.h" +#include "pub_core_debuginfo.h" // VG_(di_notify_*) +#include "pub_core_transtab.h" // VG_(discard_translations) +#include "pub_core_xarray.h" #include "pub_core_clientstate.h" -#include "pub_core_debuginfo.h" // VG_(di_notify_*) #include "pub_core_debuglog.h" -#include "pub_core_inner.h" -#include "pub_core_libcassert.h" #include "pub_core_libcbase.h" +#include "pub_core_libcassert.h" #include "pub_core_libcfile.h" #include "pub_core_libcprint.h" #include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_machine.h" #include "pub_core_mallocfree.h" +#include "pub_core_tooliface.h" #include "pub_core_options.h" -#include "pub_core_pathscan.h" #include "pub_core_scheduler.h" #include "pub_core_signals.h" #include "pub_core_stacks.h" #include "pub_core_syscall.h" #include "pub_core_syswrap.h" -#include "pub_core_threadstate.h" -#include "pub_core_tooliface.h" -#include "pub_core_transtab.h" // VG_(discard_translations) -#include "pub_core_vki.h" -#include "pub_core_vkiscnums.h" -#include "pub_core_xarray.h" +#include "pub_core_inner.h" +#include "pub_core_pathscan.h" #if defined(ENABLE_INNER_CLIENT_REQUEST) #include "pub_core_clreq.h" #endif -#include "priv_syswrap-freebsd.h" +#include "priv_types_n_macros.h" #include "priv_syswrap-generic.h" #include "priv_syswrap-main.h" -#include "priv_types_n_macros.h" +#include "priv_syswrap-freebsd.h" static Bool capabiltyMode = False; -Bool VG_(get_capability_mode)(void) { return capabiltyMode; } +Bool VG_(get_capability_mode)(void) +{ + return capabiltyMode; +} + // Run a thread from beginning to end and return the thread's // scheduler-return-code. static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) { VgSchedReturnCode ret; - ThreadId tid = (ThreadId)tidW; - Int lwpid = VG_(gettid)(); - ThreadState* tst = VG_(get_ThreadState)(tid); + ThreadId tid = (ThreadId)tidW; + Int lwpid = VG_(gettid)(); + ThreadState* tst = VG_(get_ThreadState)(tid); VG_(debugLog)(1, "syswrap-freebsd", - "thread_wrapper(tid=%u,lwpid=%d): entry\n", tid, lwpid); + "thread_wrapper(tid=%u,lwpid=%d): entry\n", + tid, lwpid); vg_assert(tst->status == VgTs_Init); @@ -87,7 +92,8 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)"); if (0) { - VG_(printf)("thread tid %u started: stack = %p\n", tid, (void*)&tid); + VG_(printf)("thread tid %u started: stack = %p\n", + tid, (void*)&tid); } /* Make sure error reporting is enabled in the new thread. */ @@ -118,24 +124,27 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) return ret; } + /* --------------------------------------------------------------------- clone-related stuff ------------------------------------------------------------------ */ /* Run a thread all the way to the end, then do appropriate exit actions (this is the last-one-out-turn-off-the-lights bit). */ -__attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) +__attribute__((noreturn)) +static void run_a_thread_NORETURN ( Word tidW ) { ThreadId tid = (ThreadId)tidW; VgSchedReturnCode src; Int c; ThreadState* tst; #ifdef ENABLE_INNER_CLIENT_REQUEST - Int registered_vgstack_id; + Int registered_vgstack_id; #endif VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", tid); + "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", + tid); tst = VG_(get_ThreadState)(tid); vg_assert(tst); @@ -148,15 +157,17 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) When Valgrind runs as an inner, it must signals that its (real) stack is the stack to use by the outer to e.g. do stacktraces. */ - INNER_REQUEST(registered_vgstack_id = VALGRIND_STACK_REGISTER( - tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST + (registered_vgstack_id + = VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); /* Run the thread all the way through. */ src = thread_wrapper(tid); VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", tid); + "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", + tid); c = VG_(count_living_threads)(); vg_assert(c >= 1); /* stay sane */ @@ -167,7 +178,7 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) } // Tell the tool this thread is exiting - VG_TRACK(pre_thread_ll_exit, tid); + VG_TRACK( pre_thread_ll_exit, tid ); /* If the thread is exiting with errors disabled, complain loudly; doing so is bad (does the user know this has happened?) Also, @@ -176,13 +187,17 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) should be unnecessary since the flag should be cleared when the slot is reallocated, in thread_wrapper(). */ if (tst->err_disablement_level > 0) { - VG_(umsg)("WARNING: exiting thread has error reporting disabled.\n" - "WARNING: possibly as a result of some mistake in the use\n" - "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"); - VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): " - "WARNING: exiting thread has err_disablement_level = %u\n", - tid, tst->err_disablement_level); + VG_(umsg)( + "WARNING: exiting thread has error reporting disabled.\n" + "WARNING: possibly as a result of some mistake in the use\n" + "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n" + ); + VG_(debugLog)( + 1, "syswrap-freebsd", + "run_a_thread_NORETURN(tid=%u): " + "WARNING: exiting thread has err_disablement_level = %u\n", + tid, tst->err_disablement_level + ); } tst->err_disablement_level = 0; @@ -196,7 +211,7 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) /* We are the last one standing. Keep hold of the lock and carry on to show final tool results, then exit the entire system. Use the continuation pointer set at startup in m_main. */ - (*VG_(address_of_m_main_shutdown_actions_NORETURN))(tid, src); + ( * VG_(address_of_m_main_shutdown_actions_NORETURN) ) (tid, src); } else { VG_(debugLog)(1, "syswrap-freebsd", @@ -212,7 +227,7 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) vg_assert(sizeof(tst->status) == 4); vg_assert(sizeof(tst->os_state.exitcode) == sizeof(Word)); - INNER_REQUEST(VALGRIND_STACK_DEREGISTER(registered_vgstack_id)); + INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id)); /* We have to use this sequence to terminate the thread to prevent a subtle race. If VG_(exit_thread)() had left the @@ -222,32 +237,34 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) reallocation. We need to make sure we don't touch the stack between marking it Empty and exiting. Hence the assembler. */ -#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ - __asm__ volatile( +#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ + __asm__ volatile ( "movl %1, %0\n" /* set tst->status = VgTs_Empty */ - "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */ - "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */ - "pushl %%ebx\n" /* arg on stack */ - "pushl %%ebx\n" /* fake return address */ - "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ - "popl %%ebx\n" /* fake return address */ - "popl %%ebx\n" /* arg off stack */ - : "=m"(tst->status) - : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(tst->os_state.exitcode) - : "eax", "ebx"); + "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */ + "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */ + "pushl %%ebx\n" /* arg on stack */ + "pushl %%ebx\n" /* fake return address */ + "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ + "popl %%ebx\n" /* fake return address */ + "popl %%ebx\n" /* arg off stack */ + : "=m" (tst->status) + : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) + : "eax", "ebx" + ); #elif defined(VGP_amd64_freebsd) - __asm__ volatile( + __asm__ volatile ( "movl %1, %0\n" /* set tst->status = VgTs_Empty */ - "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */ - "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */ - "pushq %%rdi\n" /* fake return address */ - "syscall\n" /* thr_exit(tst->os_state.exitcode) */ - "popq %%rdi\n" /* fake return address */ - : "=m"(tst->status) - : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(tst->os_state.exitcode) - : "rax", "rdi"); + "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */ + "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */ + "pushq %%rdi\n" /* fake return address */ + "syscall\n" /* thr_exit(tst->os_state.exitcode) */ + "popq %%rdi\n" /* fake return address */ + : "=m" (tst->status) + : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) + : "rax", "rdi" + ); #else -#error Unknown platform +# error Unknown platform #endif VG_(core_panic)("Thread exit failed?\n"); @@ -257,12 +274,12 @@ __attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) vg_assert(0); } -Word ML_(start_thread_NORETURN)(void* arg) +Word ML_(start_thread_NORETURN) ( void* arg ) { ThreadState* tst = (ThreadState*)arg; ThreadId tid = tst->tid; - run_a_thread_NORETURN((Word)tid); + run_a_thread_NORETURN ( (Word)tid ); /*NOTREACHED*/ vg_assert(0); } @@ -291,7 +308,7 @@ Addr ML_(allocstack)(ThreadId tid) /* If no stack is present, allocate one. */ if (tst->os_state.valgrind_stack_base == 0) { - stack = VG_(am_alloc_VgStack)(&initial_SP); + stack = VG_(am_alloc_VgStack)( &initial_SP ); if (stack) { tst->os_state.valgrind_stack_base = (Addr)stack; tst->os_state.valgrind_stack_init_SP = initial_SP; @@ -299,9 +316,10 @@ Addr ML_(allocstack)(ThreadId tid) } if (0) { - VG_(printf)("stack for tid %u at %p; init_SP=%p\n", tid, - (void*)tst->os_state.valgrind_stack_base, - (void*)tst->os_state.valgrind_stack_init_SP); + VG_(printf)( "stack for tid %u at %p; init_SP=%p\n", + tid, + (void*)tst->os_state.valgrind_stack_base, + (void*)tst->os_state.valgrind_stack_init_SP ); } return tst->os_state.valgrind_stack_init_SP; @@ -312,7 +330,8 @@ Addr ML_(allocstack)(ThreadId tid) (VG_(interim_stack)) it's better to allocate a new one, so that overflow detection works uniformly for all threads. */ -__attribute__((noreturn)) void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) +__attribute__((noreturn)) +void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) { Addr sp; VG_(debugLog)(1, "syswrap-freebsd", @@ -325,9 +344,10 @@ __attribute__((noreturn)) void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind // reports 'write error' on the non registered stack. ThreadState* tst = VG_(get_ThreadState)(tid); - INNER_REQUEST( - (void)VALGRIND_STACK_REGISTER(tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST + ((void) + VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); } #endif @@ -336,20 +356,22 @@ __attribute__((noreturn)) void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) vg_assert2(sp != 0, "%s", "Cannot allocate main thread's stack."); /* shouldn't be any other threads around yet */ - vg_assert(VG_(count_living_threads)() == 1); + vg_assert( VG_(count_living_threads)() == 1 ); - ML_(call_on_new_stack_0_1)((Addr)sp, /* stack */ - 0, /* bogus return address */ - run_a_thread_NORETURN, /* fn to call */ - (Word)tid /* arg to give it */ + ML_(call_on_new_stack_0_1)( + (Addr)sp, /* stack */ + 0, /* bogus return address */ + run_a_thread_NORETURN, /* fn to call */ + (Word)tid /* arg to give it */ ); /*NOTREACHED*/ vg_assert(0); } + /* Do a fork() */ -SysRes ML_(do_fork)(ThreadId tid) +SysRes ML_(do_fork) ( ThreadId tid ) { vki_sigset_t fork_saved_mask; vki_sigset_t mask; @@ -362,7 +384,7 @@ SysRes ML_(do_fork)(ThreadId tid) VG_(do_atfork_pre)(tid); - res = VG_(do_syscall0)(__NR_fork); + res = VG_(do_syscall0)( __NR_fork ); if (!sr_isError(res)) { if (sr_Res(res) == 0) { @@ -389,15 +411,15 @@ SysRes ML_(do_fork)(ThreadId tid) return res; } -static Addr ML_(make_safe_mask)(const HChar* malloc_message, Addr mask_pointer) +static Addr ML_(make_safe_mask) ( const HChar* malloc_message, Addr mask_pointer ) { - vki_sigset_t* new_mask; - const vki_sigset_t* old_mask = (vki_sigset_t*)mask_pointer; + vki_sigset_t* new_mask; + const vki_sigset_t* old_mask = (vki_sigset_t *)mask_pointer; if (!ML_(safe_to_deref)(old_mask, sizeof(vki_sigset_t))) { new_mask = (vki_sigset_t*)1; /* Something recognisable to POST() hook. */ } else { - new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); + new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); *new_mask = *old_mask; VG_(sanitize_client_sigmask)(new_mask); } @@ -405,13 +427,14 @@ static Addr ML_(make_safe_mask)(const HChar* malloc_message, Addr mask_pointer) return (Addr)new_mask; } -static void ML_(free_safe_mask)(Addr mask_pointer) +static void ML_(free_safe_mask) ( Addr mask_pointer ) { if (mask_pointer != 0 && mask_pointer != 1) { - VG_(free)((vki_sigset_t*)mask_pointer); + VG_(free)((vki_sigset_t *) mask_pointer); } } + /* --------------------------------------------------------------------- PRE/POST wrappers for arch-generic, FreeBSD-specific syscalls ------------------------------------------------------------------ */ @@ -419,8 +442,8 @@ static void ML_(free_safe_mask)(Addr mask_pointer) // Nb: See the comment above the generic PRE/POST wrappers in // m_syswrap/syswrap-generic.c for notes about how they work. -#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) -#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) +#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) +#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) /* On FreeBSD, if any thread calls exit(2), then they are all shut down, pretty * much like linux's exit_group(). @@ -429,25 +452,25 @@ static void ML_(free_safe_mask)(Addr mask_pointer) // void exit(int status); PRE(sys_exit) { - ThreadId t; + ThreadId t; PRINT("exit( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(void, "exit", int, status); /* Mark all threads (including this one) to exit. */ for (t = 1; t < VG_N_THREADS; t++) { - if (/* not alive */ VG_(threads)[t].status == VgTs_Empty) { + if ( /* not alive */ VG_(threads)[t].status == VgTs_Empty ) { continue; } - // VG_(threads)[t].exitreason = VgSrc_ExitThread; + //VG_(threads)[t].exitreason = VgSrc_ExitThread; VG_(threads)[t].os_state.exitcode = ARG1; // if (t != tid) // VG_(get_thread_out_of_syscall)(t); /* unblock it, if blocked */ } - VG_(nuke_all_threads_except)(tid, VgSrc_ExitProcess); + VG_(nuke_all_threads_except)( tid, VgSrc_ExitProcess ); VG_(reap_threads)(tid); VG_(threads)[tid].exitreason = VgSrc_ExitThread; @@ -462,7 +485,7 @@ PRE(sys_fork) PRINT("%s", "sys_fork ()"); PRE_REG_READ0(pid_t, "fork"); - SET_STATUS_from_SysRes(ML_(do_fork)(tid)); + SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -519,13 +542,12 @@ PRE(sys_mount) // We are conservative and check everything, except the memory pointed to // by 'data'. *flags |= SfMayBlock; - PRINT("sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "mount", const char*, type, char*, dir, int, flags, void*, - data); - PRE_MEM_RASCIIZ("mount(type)", ARG1); - PRE_MEM_RASCIIZ("mount(path)", ARG2); + PRINT( "sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); + PRE_REG_READ4(int, "mount", + const char *, type, char *, dir, int, flags, + void *, data); + PRE_MEM_RASCIIZ( "mount(type)", ARG1); + PRE_MEM_RASCIIZ( "mount(path)", ARG2); } // SYS_unmount 22 @@ -533,8 +555,8 @@ PRE(sys_mount) PRE(sys_unmount) { PRINT("sys_umount( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "unmount", const char*, dir, int, flags); - PRE_MEM_RASCIIZ("unmount(path)", ARG1); + PRE_REG_READ2(int, "unmount", const char *, dir, int, flags); + PRE_MEM_RASCIIZ( "unmount(path)", ARG1); } // SYS_setuid 23 @@ -550,13 +572,10 @@ PRE(sys_unmount) // int ptrace(int request, pid_t pid, caddr_t addr, int data); PRE(sys_ptrace) { - struct vki_ptrace_io_desc* io_desc; - PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD - "x, %" FMT_REGWORD "u)", - ARG1, ARG2, ARG3, ARG4); + struct vki_ptrace_io_desc *io_desc; + PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %" FMT_REGWORD "u)", ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, - data); + PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, data); switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -568,15 +587,15 @@ PRE(sys_ptrace) case VKI_PTRACE_IO: PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_ptrace_io_desc)); - io_desc = (struct vki_ptrace_io_desc*)ARG3; + io_desc = (struct vki_ptrace_io_desc *)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: - PRE_MEM_WRITE("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_WRITE( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; case VKI_PIOD_WRITE_D: case VKI_PIOD_WRITE_I: - PRE_MEM_READ("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_READ( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; } break; @@ -620,7 +639,7 @@ PRE(sys_ptrace) break; case VKI_PTRACE_GETLWPLIST: - PRE_MEM_WRITE("ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); + PRE_MEM_WRITE( "ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); break; case VKI_PTRACE_SETSTEP: @@ -633,14 +652,14 @@ PRE(sys_ptrace) case VKI_PTRACE_VM_TIMESTAMP: break; case VKI_PTRACE_VM_ENTRY: - PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); + PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); break; } } POST(sys_ptrace) { - struct vki_ptrace_io_desc* io_desc; + struct vki_ptrace_io_desc *io_desc; switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -651,7 +670,7 @@ POST(sys_ptrace) break; case VKI_PTRACE_IO: - io_desc = (struct vki_ptrace_io_desc*)ARG3; + io_desc = (struct vki_ptrace_io_desc *)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: @@ -737,18 +756,15 @@ POST(sys_ptrace) PRE(sys_recvmsg) { *flags |= SfMayBlock; - PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD - "d )", - SARG1, ARG2, SARG3); - PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr*, msg, int, - flags); - ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2); + PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )",SARG1,ARG2,SARG3); + PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr *, msg, int, flags); + ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2); } POST(sys_recvmsg) { - ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2, RES); + ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2, RES); } // SYS_sendmsg 28 @@ -756,34 +772,30 @@ POST(sys_recvmsg) PRE(sys_sendmsg) { *flags |= SfMayBlock; - PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(ssize_t, "sendmsg", int, s, const struct msghdr*, msg, int, - flags); - ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr*)ARG2); + PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRE_REG_READ3(ssize_t, "sendmsg", + int, s, const struct msghdr *, msg, int, flags); + ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr *)ARG2); } // SYS_recvfrom 29 // ssize_t recvfrom(int s, void *buf, size_t len, int flags, -// struct sockaddr * restrict from, socklen_t * restrict -// fromlen); +// struct sockaddr * restrict from, socklen_t * restrict fromlen); PRE(sys_recvfrom) { *flags |= SfMayBlock; - PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - SARG1, ARG2, ARG3, SARG4, ARG5, ARG6); - PRE_REG_READ6(ssize_t, "recvfrom", int, s, void*, buf, size_t, len, int, - flags, struct sockaddr*, from, int*, fromlen); - ML_(generic_PRE_sys_recvfrom)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3,SARG4,ARG5,ARG6); + PRE_REG_READ6(ssize_t, "recvfrom", + int, s, void *, buf, size_t, len, int, flags, + struct sockaddr *, from, int *, fromlen); + ML_(generic_PRE_sys_recvfrom)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); } POST(sys_recvfrom) { vg_assert(SUCCESS); - ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), ARG1, ARG2, - ARG3, ARG4, ARG5, ARG6); + ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), + ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); } // SYS_accept 30 @@ -792,19 +804,18 @@ POST(sys_recvfrom) PRE(sys_accept) { *flags |= SfMayBlock; - PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "accept", int, s, struct sockaddr*, addr, int, *addrlen); - ML_(generic_PRE_sys_accept)(tid, ARG1, ARG2, ARG3); + PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "accept", + int, s, struct sockaddr *, addr, int, *addrlen); + ML_(generic_PRE_sys_accept)(tid, ARG1,ARG2,ARG3); } POST(sys_accept) { SysRes r; vg_assert(SUCCESS); - r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), ARG1, - ARG2, ARG3); + r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), + ARG1,ARG2,ARG3); SET_STATUS_from_SysRes(r); } @@ -813,19 +824,17 @@ POST(sys_accept) // socklen_t * restrict namelen); PRE(sys_getpeername) { - PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD - "x, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "getpeername", int, s, struct sockaddr*, name, socklen_t*, - namelen); - ML_(generic_PRE_sys_getpeername)(tid, ARG1, ARG2, ARG3); + PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "getpeername", + int, s, struct sockaddr *, name, socklen_t *, namelen); + ML_(generic_PRE_sys_getpeername)(tid, ARG1,ARG2,ARG3); } POST(sys_getpeername) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), ARG1, - ARG2, ARG3); + ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), + ARG1,ARG2,ARG3); } // SYS_getsockname 32 @@ -833,19 +842,17 @@ POST(sys_getpeername) // socklen_t * restrict namelen); PRE(sys_getsockname) { - PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD - "x, %#" FMT_REGWORD "x )", - SARG1, ARG2, ARG3); - PRE_REG_READ3(long, "getsockname", int, s, struct sockaddr*, name, int*, - namelen); - ML_(generic_PRE_sys_getsockname)(tid, ARG1, ARG2, ARG3); + PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3); + PRE_REG_READ3(long, "getsockname", + int, s, struct sockaddr *, name, int *, namelen); + ML_(generic_PRE_sys_getsockname)(tid, ARG1,ARG2,ARG3); } POST(sys_getsockname) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), ARG1, - ARG2, ARG3); + ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), + ARG1,ARG2,ARG3); } // SYS_access 33 @@ -855,17 +862,17 @@ POST(sys_getsockname) // int chflags(const char *path, unsigned long flags) PRE(sys_chflags) { - PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1, - (char*)ARG1, ARG2); - PRE_REG_READ2(int, "chflags", const char*, path, unsigned long, flags); - PRE_MEM_RASCIIZ("chflags(path)", ARG1); + PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); + PRE_REG_READ2(int, "chflags", + const char *, path, unsigned long, flags); + PRE_MEM_RASCIIZ( "chflags(path)", ARG1 ); } // SYS_fchflags 35 // int fchflags(int fd, unsigned long flags); PRE(sys_fchflags) { - PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); + PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2); PRE_REG_READ2(int, "fchflags", int, fd, unsigned long, flags); } @@ -884,15 +891,18 @@ PRE(sys_fchflags) // Pipe on freebsd doesn't have args, and uses dual returns! // SYS_freebsd10_pipe 42 // int pipe(void); -PRE(sys_pipe) { PRINT("%s", "sys_pipe ()"); } +PRE(sys_pipe) +{ + PRINT("%s", "sys_pipe ()"); +} POST(sys_pipe) { if (!ML_(fd_allowed)(RES, "pipe", tid, True) || - !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { + !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { VG_(close)(RES); VG_(close)(RESHI); - SET_STATUS_Failure(VKI_EMFILE); + SET_STATUS_Failure( VKI_EMFILE ); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); @@ -920,20 +930,23 @@ POST(sys_pipe) // so let's go with those names PRE(sys_getlogin) { - PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "getlogin", char*, buf, u_int, len); - PRE_MEM_WRITE("getlogin(name)", ARG1, ARG2); + PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); + PRE_REG_READ2(int, "getlogin", char *, buf, u_int, len); + PRE_MEM_WRITE( "getlogin(name)", ARG1, ARG2 ); } -POST(sys_getlogin) { POST_MEM_WRITE(ARG1, ARG2); } +POST(sys_getlogin) +{ + POST_MEM_WRITE(ARG1, ARG2 ); +} // SYS_setlogin 50 // int setlogin(const char *name); PRE(sys_setlogin) { - PRINT("sys_setlogin ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(long, "setlogin", char*, buf); - PRE_MEM_RASCIIZ("setlogin(buf)", ARG1); + PRINT("sys_setlogin ( %#" FMT_REGWORD "x )",ARG1); + PRE_REG_READ1(long, "setlogin", char *, buf); + PRE_MEM_RASCIIZ( "setlogin(buf)", ARG1 ); } // SYS_acct 51 @@ -950,31 +963,27 @@ PRE(sys_ioctl) UInt size = _VKI_IOC_SIZE(ARG2); *flags |= SfMayBlock; // @todo PJF presumably the presence of ARG3 depends on ARG2 - PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD - "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "ioctl", int, fd, unsigned long, request, unsigned long, - arg); + PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "ioctl", + int, fd, unsigned long, request, unsigned long, arg); - /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder - */ + /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */ if (SimHintiS(SimHint_lax_ioctls, VG_(clo_sim_hints))) { /* - * Be very lax about ioctl handling; the only - * assumption is that the size is correct. Doesn't - * require the full buffer to be initialized when - * writing. Without this, using some device - * drivers with a large number of strange ioctl - * commands becomes very tiresome. - */ + * Be very lax about ioctl handling; the only + * assumption is that the size is correct. Doesn't + * require the full buffer to be initialized when + * writing. Without this, using some device + * drivers with a large number of strange ioctl + * commands becomes very tiresome. + */ } else if (dir == _VKI_IOC_NONE && size > 0) { static UWord unknown_ioctl[10]; - static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); + static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); if (moans > 0 && !VG_(clo_xml)) { /* Check if have not already moaned for this request. */ UInt i; - for (i = 0; i < sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); - i++) { + for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) { if (unknown_ioctl[i] == ARG2) { break; } @@ -982,22 +991,20 @@ PRE(sys_ioctl) unknown_ioctl[i] = ARG2; moans--; VG_(umsg)("Warning: noted but unhandled ioctl 0x%lx" - " with no direction hints.\n", - ARG2); - VG_(umsg)( - " This could cause spurious value errors to appear.\n"); + " with no direction hints.\n", ARG2); + VG_(umsg)(" This could cause spurious value errors to appear.\n"); VG_(umsg)(" See README_MISSING_SYSCALL_OR_IOCTL for " - "guidance on writing a proper wrapper.\n"); + "guidance on writing a proper wrapper.\n" ); return; } } } } else { if ((dir & _VKI_IOC_WRITE) && size > 0) { - PRE_MEM_READ("ioctl(generic)", ARG3, size); + PRE_MEM_READ( "ioctl(generic)", ARG3, size); } if ((dir & _VKI_IOC_READ) && size > 0) { - PRE_MEM_WRITE("ioctl(generic)", ARG3, size); + PRE_MEM_WRITE( "ioctl(generic)", ARG3, size); } } @@ -1068,7 +1075,8 @@ POST(sys_ioctl) UInt dir = _VKI_IOC_DIR(ARG2); UInt size = _VKI_IOC_SIZE(ARG2); vg_assert(SUCCESS); - if (size > 0 && (dir & _VKI_IOC_READ) && RES == 0 && ARG3 != (Addr)NULL) { + if (size > 0 && (dir & _VKI_IOC_READ) + && RES == 0 && ARG3 != (Addr)NULL) { POST_MEM_WRITE(ARG3, size); } @@ -1124,61 +1132,57 @@ PRE(sys_reboot) PRE(sys_revoke) { PRINT("sys_revoke ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); - PRE_REG_READ1(long, "revoke", const char*, path); - PRE_MEM_RASCIIZ("revoke(path)", ARG1); + PRE_REG_READ1(long, "revoke", const char *, path); + PRE_MEM_RASCIIZ( "revoke(path)", ARG1); } // SYS_symlink 57 // generic -static void do_readlink(const HChar* path, - HChar* buf, - SizeT bufsize, - SyscallStatus* status, - Bool* curproc_file) +static void do_readlink(const HChar* path, HChar *buf, SizeT bufsize, SyscallStatus* status, Bool* curproc_file) { HChar name[30]; VG_(sprintf)(name, "/proc/%d/file", VG_(getpid)()); - if (ML_(safe_to_deref)(path, 1) && - (VG_(strcmp)(path, name) == 0 || - VG_(strcmp)(path, "/proc/curproc/file") == 0)) { + if (ML_(safe_to_deref)(path, 1) + && (VG_(strcmp)(path, name) == 0 + || VG_(strcmp)(path, "/proc/curproc/file") == 0)) { vg_assert(VG_(resolved_exename)); - Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); + Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); SET_STATUS_Success(len); *curproc_file = True; } } // SYS_readlink 58 -// ssize_t readlink(const char *restrict path, char *restrict buf, size_t -// bufsiz); +// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsiz); PRE(sys_readlink) { FUSE_COMPATIBLE_MAY_BLOCK(); - Word saved = SYSNO; + Word saved = SYSNO; Bool curproc_file = False; PRINT("sys_readlink ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %llu )", ARG1, (char*)(Addr)ARG1, ARG2, (ULong)ARG3); - PRE_REG_READ3(long, "readlink", const char*, path, char*, buf, int, bufsiz); - PRE_MEM_RASCIIZ("readlink(path)", ARG1); - PRE_MEM_WRITE("readlink(buf)", ARG2, ARG3); + PRE_REG_READ3(long, "readlink", + const char *, path, char *, buf, int, bufsiz); + PRE_MEM_RASCIIZ( "readlink(path)", ARG1 ); + PRE_MEM_WRITE( "readlink(buf)", ARG2,ARG3 ); - if (VG_(have_slash_proc) == True) { + if (VG_(have_slash_proc) == True) + { /* * Handle the case where readlink is looking at /proc/curproc/file or * /proc/<pid>/file */ - do_readlink((const HChar*)ARG1, (HChar*)ARG2, (SizeT)ARG3, status, - &curproc_file); + do_readlink((const HChar *)ARG1, (HChar *)ARG2, (SizeT)ARG3, status, &curproc_file); } if (!curproc_file) { /* Normal case */ - SET_STATUS_from_SysRes(VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); + SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); } if (SUCCESS && RES > 0) { - POST_MEM_WRITE(ARG2, RES); + POST_MEM_WRITE( ARG2, RES ); } } @@ -1202,7 +1206,7 @@ PRE(sys_vfork) PRE_REG_READ0(pid_t, "vfork"); /* Pretend vfork == fork. Not true, but will have to do. */ - SET_STATUS_from_SysRes(ML_(do_fork)(tid)); + SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -1214,7 +1218,7 @@ PRE(sys_vfork) // void * sbrk(intptr_t incr); PRE(sys_sbrk) { - PRINT("sys_sbrk ( %#" FMT_REGWORD "x )", ARG1); + PRINT("sys_sbrk ( %#" FMT_REGWORD "x )",ARG1); PRE_REG_READ1(void*, "sbrk", vki_intptr_t, incr); } @@ -1252,9 +1256,9 @@ PRE(sys_sbrk) // int swapon(const char *special); PRE(sys_swapon) { - PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); - PRE_REG_READ1(int, "swapon", const char*, special); - PRE_MEM_RASCIIZ("swapon(special)", ARG1); + PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1,(char*)ARG1); + PRE_REG_READ1(int, "swapon", const char*, special ); + PRE_MEM_RASCIIZ( "swapon(special)", ARG1 ); } // SYS_getitimer 86 @@ -1282,7 +1286,7 @@ PRE(sys_fcntl) case VKI_F_GETOWN: case VKI_F_GET_SEALS: case VKI_F_ISUNIONSTACK: - PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); + PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2); PRE_REG_READ2(int, "fcntl", int, fd, int, cmd); break; @@ -1295,10 +1299,9 @@ PRE(sys_fcntl) case VKI_F_READAHEAD: case VKI_F_RDAHEAD: case VKI_F_ADD_SEALS: - PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD - "d, %" FMT_REGWORD "d )", - SARG1, SARG2, SARG3); - PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, int, arg); + PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2,SARG3); + PRE_REG_READ3(int, "fcntl", + int, fd, int, cmd, int, arg); break; // These ones use ARG3 as "lock" - obsolete. @@ -1307,20 +1310,20 @@ PRE(sys_fcntl) /* FALLTHROUGH */ case VKI_F_OGETLK: case VKI_F_OSETLK: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct oflock*, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "fcntl", + int, fd, int, cmd, + struct oflock *, lock); break; // This one uses ARG3 as "oldd" and ARG4 as "newd". case VKI_F_DUP2FD: case VKI_F_DUP2FD_CLOEXEC: - PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD - "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", - ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "fcntl", int, fd, int, cmd, unsigned long, oldd, - unsigned long, newd); + PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", + ARG1,ARG2,ARG3,ARG4); + PRE_REG_READ4(int, "fcntl", + int, fd, int, cmd, + unsigned long, oldd, unsigned long, newd); break; // These ones use ARG3 as "lock". @@ -1330,26 +1333,24 @@ PRE(sys_fcntl) case VKI_F_GETLK: case VKI_F_SETLK: case VKI_F_SETLK_REMOTE: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct flock*, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "fcntl", + int, fd, int, cmd, + struct flock *, lock); break; case VKI_F_KINFO: - PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct vki_kinfo_file*, - kinfo); + PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "fcntl", + int, fd, int, cmd, + struct vki_kinfo_file *, kinfo); if (ARG3) { struct vki_kinfo_file* p_kinfo_file = (struct vki_kinfo_file*)ARG3; - PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, - p_kinfo_file->vki_kf_structsize); + PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, p_kinfo_file->vki_kf_structsize); } break; default: - PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1, ARG2, ARG3); + PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1,ARG2,ARG3); I_die_here; } } @@ -1360,7 +1361,7 @@ POST(sys_fcntl) if (ARG2 == VKI_F_DUPFD) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure(VKI_EMFILE); + SET_STATUS_Failure( VKI_EMFILE ); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1369,7 +1370,7 @@ POST(sys_fcntl) } else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure(VKI_EMFILE); + SET_STATUS_Failure( VKI_EMFILE ); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1391,9 +1392,7 @@ POST(sys_fcntl) // int socket(int domain, int type, int protocol); PRE(sys_socket) { - PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD - "d )", - SARG1, SARG2, SARG3); + PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2,SARG3); PRE_REG_READ3(int, "socket", int, domain, int, type, int, protocol); } @@ -1410,12 +1409,10 @@ POST(sys_socket) PRE(sys_connect) { *flags |= SfMayBlock; - PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "connect", int, s, const struct sockaddr*, name, int, - namelen); - ML_(generic_PRE_sys_connect)(tid, ARG1, ARG2, ARG3); + PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "connect", + int, s, const struct sockaddr *, name, int, namelen); + ML_(generic_PRE_sys_connect)(tid, ARG1,ARG2,ARG3); } // SYS_getpriority 100 @@ -1425,11 +1422,10 @@ PRE(sys_connect) // int bind(int s, const struct sockaddr *addr, socklen_t addrlen); PRE(sys_bind) { - PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "bind", int, s, struct sockaddr*, addr, int, addrlen); - ML_(generic_PRE_sys_bind)(tid, ARG1, ARG2, ARG3); + PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); + PRE_REG_READ3(int, "bind", + int, s, struct sockaddr *, addr, int, addrlen); + ML_(generic_PRE_sys_bind)(tid, ARG1,ARG2,ARG3); } // SYS_setsockopt 105 @@ -1437,24 +1433,23 @@ PRE(sys_bind) // socklen_t optlen); PRE(sys_setsockopt) { - PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD - "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", - SARG1, SARG2, SARG3, ARG4, ARG5); - PRE_REG_READ5(int, "setsockopt", int, s, int, level, int, optname, - const void*, optval, vki_socklen_t, optlen); - ML_(generic_PRE_sys_setsockopt)(tid, ARG1, ARG2, ARG3, ARG4, ARG5); + PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",SARG1,SARG2,SARG3,ARG4,ARG5); + PRE_REG_READ5(int, "setsockopt", + int, s, int, level, int, optname, + const void *, optval, vki_socklen_t, optlen); + ML_(generic_PRE_sys_setsockopt)(tid, ARG1,ARG2,ARG3,ARG4,ARG5); } // SYS_listen 106 // int listen(int s, int backlog); PRE(sys_listen) { - PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); + PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2); PRE_REG_READ2(int, "listen", int, s, int, backlog); } -// SYS_gettimeofday 116 -// generic +//SYS_gettimeofday 116 +// generic // SYS_getrusage 117 // generic @@ -1466,14 +1461,14 @@ PRE(sys_getsockopt) { Addr optval_p = ARG4; Addr optlen_p = ARG5; - PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3, ARG4, ARG5); - PRE_REG_READ5(int, "getsockopt", int, s, int, level, int, optname, void*, - optval, int, *optlen); + PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4,ARG5); + PRE_REG_READ5(int, "getsockopt", + int, s, int, level, int, optname, + void *, optval, int, *optlen); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_pre_check)(tid, optval_p, optlen_p, "getsockopt(optval)", - "getsockopt(optlen)"); + ML_(buf_and_len_pre_check) ( tid, optval_p, optlen_p, + "getsockopt(optval)", + "getsockopt(optlen)" ); } } @@ -1483,8 +1478,9 @@ POST(sys_getsockopt) Addr optlen_p = ARG5; vg_assert(SUCCESS); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_post_check)(tid, VG_(mk_SysRes_Success)(RES), optval_p, - optlen_p, "getsockopt(optlen_out)"); + ML_(buf_and_len_post_check) ( tid, VG_(mk_SysRes_Success)(RES), + optval_p, optlen_p, + "getsockopt(optlen_out)" ); } } @@ -1519,11 +1515,9 @@ POST(sys_getsockopt) // int mkfifo(const char *path, mode_t mode); PRE(sys_mkfifo) { - PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD - "x, 0x%" FMT_REGWORD "x )", - ARG1, (char*)ARG1, ARG2, ARG3); - PRE_REG_READ2(int, "mkfifo", const char*, path, int, mode); - PRE_MEM_RASCIIZ("mkfifo(path)", ARG1); + PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1, (char *)ARG1, ARG2, ARG3 ); + PRE_REG_READ2(int, "mkfifo", const char *, path, int, mode); + PRE_MEM_RASCIIZ( "mkfifo(path)", ARG1 ); } // SYS_sendto 133 @@ -1532,12 +1526,12 @@ PRE(sys_mkfifo) PRE(sys_sendto) { *flags |= SfMayBlock; - PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD - "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", - ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); - PRE_REG_READ6(ssize_t, "sendto", int, s, const void*, msg, int, len, int, - flags, const struct sockaddr*, to, socklen_t, tolen); - ML_(generic_PRE_sys_sendto)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + PRE_REG_READ6(ssize_t, "sendto", + int, s, const void *, msg, int, len, + int, flags, + const struct sockaddr *, to, socklen_t, tolen); + ML_(generic_PRE_sys_sendto)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); } // SYS_shutdown 134 @@ -1545,7 +1539,7 @@ PRE(sys_sendto) PRE(sys_shutdown) { *flags |= SfMayBlock; - PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); + PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2); PRE_REG_READ2(int, "shutdown", int, s, int, how); } @@ -1553,19 +1547,17 @@ PRE(sys_shutdown) // int socketpair(int domain, int type, int protocol, int *sv); PRE(sys_socketpair) { - PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "socketpair", int, domain, int, type, int, protocol, int*, - sv); - ML_(generic_PRE_sys_socketpair)(tid, ARG1, ARG2, ARG3, ARG4); + PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); + PRE_REG_READ4(int, "socketpair", + int, domain, int, type, int, protocol, int *, sv); + ML_(generic_PRE_sys_socketpair)(tid, ARG1,ARG2,ARG3,ARG4); } POST(sys_socketpair) { vg_assert(SUCCESS); - ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), ARG1, - ARG2, ARG3, ARG4); + ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), + ARG1,ARG2,ARG3,ARG4); } // SYS_mkdir 136 @@ -1581,9 +1573,9 @@ POST(sys_socketpair) // int adjtime(const struct timeval *delta, struct timeval *olddelta); PRE(sys_adjtime) { - PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); - PRE_REG_READ2(int, "adjtime", const struct vki_timeval*, delta, - struct vki_timeval*, olddelta); + PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); + PRE_REG_READ2(int, "adjtime", + const struct vki_timeval *, delta, struct vki_timeval *, olddelta); PRE_MEM_READ("adjtime(delta)", ARG1, sizeof(struct vki_timeval)); if (ARG2) { PRE_MEM_WRITE("adjtime(olddelta)", ARG1, sizeof(struct vki_timeval)); @@ -1604,31 +1596,31 @@ POST(sys_adjtime) /* int quotactl(const char *path, int cmd, int id, void *addr); */ PRE(sys_quotactl) { - PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD - "u, %#" FMT_REGWORD "x )", - ARG1, ARG2, ARG3, ARG4); + PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3, ARG4); switch (ARG2) { case VKI_Q_QUOTAON: case VKI_Q_SETQUOTA: case VKI_Q_SETUSE: case VKI_Q_GETQUOTASIZE: - PRE_REG_READ4(int, "quotactl", const char*, path, int, cmd, int, id, - void*, addr); - PRE_MEM_RASCIIZ("quotactl(path)", ARG1); + PRE_REG_READ4(int, "quotactl", + const char *, path, int, cmd, int, id, + void *, addr); + PRE_MEM_RASCIIZ( "quotactl(path)", ARG1 ); break; case VKI_Q_GETQUOTA: if (VG_(tdict).track_pre_reg_read) { - + \ PRRSN; - PRA1("quotactl", const char*, path); - PRA2("quotactl", int, cmd); - PRA4("quotactl", void*, addr); + PRA1("quotactl",const char*,path); + PRA2("quotactl",int,cmd); + PRA4("quotactl",void*,addr); } break; case VKI_Q_QUOTAOFF: case VKI_Q_SYNC: - PRE_REG_READ2(int, "quotactl", const char*, path, int, cmd); + PRE_REG_READ2(int, "quotactl", + const char *, path, int, cmd); break; default: break; @@ -1650,11 +1642,14 @@ PRE(sys_lgetfh) { PRINT("sys_lgetfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "lgetfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ("lgetfh(path)", ARG1); + PRE_MEM_RASCIIZ( "lgetfh(path)", ARG1 ); PRE_MEM_WRITE("lgetfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_lgetfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } +POST(sys_lgetfh) +{ + POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); +} // SYS_getfh 161 // int getfh(const char *path, fhandle_t *fhp); @@ -1662,27 +1657,30 @@ PRE(sys_getfh) { PRINT("sys_getfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "getfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ("getfh(path)", ARG1); + PRE_MEM_RASCIIZ( "getfh(path)", ARG1 ); PRE_MEM_WRITE("getfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_getfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } +POST(sys_getfh) +{ + POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); +} #if (FREEBSD_VERS <= FREEBSD_10) // 162 // int getdomainname(char *domainname, int len); PRE(sys_freebsd4_getdomainname) { - PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", - ARG1, ARG2); - PRE_REG_READ2(int, "getdomainname", char*, domainname, int, len); - PRE_MEM_WRITE("getdomainname(domainname)", ARG1, ARG2); + PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); + PRE_REG_READ2(int, "getdomainname", + char *, domainname, int, len); + PRE_MEM_WRITE( "getdomainname(domainname)", ARG1, ARG2 ); } POST(sys_freebsd4_getdomainname) { if (ARG1 != 0) { - POST_MEM_WRITE(ARG1, ARG2); + POST_MEM_WRITE( ARG1, ARG2 ); } } @@ -1690,9 +1688,9 @@ POST(sys_freebsd4_getdomainname) // int setdomainname(char *domainname, int len); PRE(sys_freebsd4_setdomainname) { - PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ2(int, "setdomainname", char*, domainname, int, len); - PRE_MEM_RASCIIZ("setdomainname(domainname)", ARG1); + PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )",ARG1); + PRE_REG_READ2(int, "setdomainname", char *, domainname, int, len); + PRE_MEM_RASCIIZ( "setdomainname(domainname)", ARG1 ); } // 164 @@ -1700,14 +1698,14 @@ PRE(sys_freebsd4_setdomainname) PRE(sys_freebsd4_uname) { PRINT("sys_freebsd4_uname ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "uname", struct utsname*, name); - PRE_MEM_WRITE("uname(name)", ARG1, sizeof(struct vki_utsname)); + PRE_REG_READ1(int, "uname", struct utsname *, name); + PRE_MEM_WRITE( "uname(name)", ARG1, sizeof(struct vki_utsname) ); } POST(sys_freebsd4_uname) { if (ARG1 != 0) { - POST_MEM_WRITE(ARG1, sizeof(struct vki_utsname)); + POST_MEM_WRITE( ARG1, sizeof(struct vki_utsname) ); } } #endif @@ -1718,14 +1716,13 @@ POST(sys_freebsd4_uname) // SYS_rtprio 166 PRE(sys_rtprio) { - PRINT("sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD - "x )", - ARG1, ARG2, ARG3); - PRE_REG_READ3(int, "rtprio", int, function, pid_t, pid, struct rtprio*, rtp); + PRINT( "sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3 ); + PRE_REG_READ3(int, "rtprio", + int, function, pid_t, pid, struct rtprio *, rtp); if (ARG1 == VKI_RTP_SET) { - PRE_MEM_READ("rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_READ( "rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); } else if (ARG1 == VKI_RTP_LOOKUP) { - PRE_MEM_WRITE("rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_WRITE( "rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); } else { /* PHK ?? */ } @@ -1734,7 +1731,7 @@ PRE(sys_rtprio) POST(sys_rtprio) { if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { - POST_MEM_WRITE(ARG3, sizeof(struct vki_rtprio)); + POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); } } @@ -1775,55 +1772,53 @@ PRE(sys_seteuid) PRE_REG_READ1(long, "seteuid", vki_uid_t, uid); } + #if (FREEBSD_VERS >= FREEBSD_12) // SYS_freebsd11_stat 188 // int stat(char *path, struct freebsd11_stat *sb); PRE(sys_freebsd11_stat) { - PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", - ARG1, (char*)ARG1, ARG2); - PRE_REG_READ2(int, "stat", char*, path, struct freebsd11_stat*, sb); - PRE_MEM_RASCIIZ("stat(path)", ARG1); - PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); + PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); + PRE_REG_READ2(int, "stat", char *, path, struct freebsd11_stat *, sb); + PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); + PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); } POST(sys_freebsd11_stat) { - POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); + POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); } // SYS_freebsd11_fstat 189 // int fstat(int fd, struct stat *sb); PRE(sys_freebsd11_fstat) { - PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, - ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat*, sb); - PRE_MEM_WRITE("fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); + PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); + PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); + PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); } POST(sys_freebsd11_fstat) { - POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); + POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); } // SYS_freebsd11_lstat 190 // int lstat(const char * restrict path, struct stat * restrict sb); PRE(sys_freebsd11_lstat) { - PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", - ARG1, (char*)ARG1, ARG2); - PRE_REG_READ2(sb, "lstat", const char*, path, struct freebsd11_stat*, sb); - PRE_MEM_RASCIIZ("lstat(path)", ARG1); - PRE_MEM_WRITE("lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); + PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); + PRE_REG_READ2(sb, "lstat", const char *, path, struct freebsd11_stat *, sb); + PRE_MEM_RASCIIZ( "lstat(path)", ARG1 ); + PRE_MEM_WRITE( "lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); } POST(sys_freebsd11_lstat) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); + POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); } } @@ -1831,38 +1826,43 @@ POST(sys_freebsd11_lstat) PRE(sys_stat) { - PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, - (char*)ARG1, ARG2); - PRE_REG_READ2(int, "stat", char*, path, struct stat*, sb); - PRE_MEM_RASCIIZ("stat(path)", ARG1); - PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); + PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); + PRE_REG_READ2(int, "stat", char *, path, struct stat *, sb); + PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); + PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); +} + +POST(sys_stat) +{ + POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); } -POST(sys_stat) { POST_MEM_WRITE(ARG2, ... [truncated message content] |
|
From: Mark W. <ma...@kl...> - 2023-04-22 14:25:40
|
Hi Paul, On Sat, Apr 22, 2023 at 02:09:28PM +0000, Paul Floyd wrote: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bf347551c99313a4af9c38bdeda9b946c9795945 > > commit bf347551c99313a4af9c38bdeda9b946c9795945 > Author: Paul Floyd <pj...@wa...> > Date: Sat Apr 22 16:08:28 2023 +0200 > > Typo in NEWS > > Thanks Tobias, on valgrind-developers > > Diff: > --- > NEWS | 2 +- > coregrind/m_syswrap/syswrap-freebsd.c | 4505 ++++++++++++------------ > memcheck/mc_main.c | 6134 +++++++++++++++++---------------- > shared/vg_replace_strmem.c | 3195 +++++++++-------- That is one giant patch. I assume accidential? It also seems to break the build. Could you please revert this (minus the NEWS typo). Thanks, Mark |
|
From: Paul F. <pa...@so...> - 2023-04-22 14:09:40
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bf347551c99313a4af9c38bdeda9b946c9795945 commit bf347551c99313a4af9c38bdeda9b946c9795945 Author: Paul Floyd <pj...@wa...> Date: Sat Apr 22 16:08:28 2023 +0200 Typo in NEWS Thanks Tobias, on valgrind-developers Diff: --- NEWS | 2 +- coregrind/m_syswrap/syswrap-freebsd.c | 4505 ++++++++++++------------ memcheck/mc_main.c | 6134 +++++++++++++++++---------------- shared/vg_replace_strmem.c | 3195 +++++++++-------- 4 files changed, 7118 insertions(+), 6718 deletions(-) diff --git a/NEWS b/NEWS index bff5b5d760..35a9ce3cd2 100644 --- a/NEWS +++ b/NEWS @@ -37,7 +37,7 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. * The vgdb utility now supports extended-remote protocol when invoked with --multi. In this mode the GDB run command is supported. Which means you don't need to run gdb and valgrind - from different terminals. So for example to start you program + from different terminals. So for example to start your program in gdb and run it under valgrind you can do: $ gdb prog (gdb) set remote exec-file prog diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index fd4dff4da4..bde7430bf3 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -29,62 +29,57 @@ #if defined(VGO_freebsd) -#include "pub_core_basics.h" -#include "pub_core_vki.h" -#include "pub_core_vkiscnums.h" -#include "pub_core_threadstate.h" #include "pub_core_aspacemgr.h" -#include "pub_core_debuginfo.h" // VG_(di_notify_*) -#include "pub_core_transtab.h" // VG_(discard_translations) -#include "pub_core_xarray.h" +#include "pub_core_basics.h" #include "pub_core_clientstate.h" +#include "pub_core_debuginfo.h" // VG_(di_notify_*) #include "pub_core_debuglog.h" -#include "pub_core_libcbase.h" +#include "pub_core_inner.h" #include "pub_core_libcassert.h" +#include "pub_core_libcbase.h" #include "pub_core_libcfile.h" #include "pub_core_libcprint.h" #include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_machine.h" #include "pub_core_mallocfree.h" -#include "pub_core_tooliface.h" #include "pub_core_options.h" +#include "pub_core_pathscan.h" #include "pub_core_scheduler.h" #include "pub_core_signals.h" #include "pub_core_stacks.h" #include "pub_core_syscall.h" #include "pub_core_syswrap.h" -#include "pub_core_inner.h" -#include "pub_core_pathscan.h" +#include "pub_core_threadstate.h" +#include "pub_core_tooliface.h" +#include "pub_core_transtab.h" // VG_(discard_translations) +#include "pub_core_vki.h" +#include "pub_core_vkiscnums.h" +#include "pub_core_xarray.h" #if defined(ENABLE_INNER_CLIENT_REQUEST) #include "pub_core_clreq.h" #endif -#include "priv_types_n_macros.h" +#include "priv_syswrap-freebsd.h" #include "priv_syswrap-generic.h" #include "priv_syswrap-main.h" -#include "priv_syswrap-freebsd.h" +#include "priv_types_n_macros.h" static Bool capabiltyMode = False; -Bool VG_(get_capability_mode)(void) -{ - return capabiltyMode; -} - +Bool VG_(get_capability_mode)(void) { return capabiltyMode; } // Run a thread from beginning to end and return the thread's // scheduler-return-code. static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) { VgSchedReturnCode ret; - ThreadId tid = (ThreadId)tidW; - Int lwpid = VG_(gettid)(); - ThreadState* tst = VG_(get_ThreadState)(tid); + ThreadId tid = (ThreadId)tidW; + Int lwpid = VG_(gettid)(); + ThreadState* tst = VG_(get_ThreadState)(tid); VG_(debugLog)(1, "syswrap-freebsd", - "thread_wrapper(tid=%u,lwpid=%d): entry\n", - tid, lwpid); + "thread_wrapper(tid=%u,lwpid=%d): entry\n", tid, lwpid); vg_assert(tst->status == VgTs_Init); @@ -92,8 +87,7 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)"); if (0) { - VG_(printf)("thread tid %u started: stack = %p\n", - tid, (void*)&tid); + VG_(printf)("thread tid %u started: stack = %p\n", tid, (void*)&tid); } /* Make sure error reporting is enabled in the new thread. */ @@ -124,27 +118,24 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) return ret; } - /* --------------------------------------------------------------------- clone-related stuff ------------------------------------------------------------------ */ /* Run a thread all the way to the end, then do appropriate exit actions (this is the last-one-out-turn-off-the-lights bit). */ -__attribute__((noreturn)) -static void run_a_thread_NORETURN ( Word tidW ) +__attribute__((noreturn)) static void run_a_thread_NORETURN(Word tidW) { ThreadId tid = (ThreadId)tidW; VgSchedReturnCode src; Int c; ThreadState* tst; #ifdef ENABLE_INNER_CLIENT_REQUEST - Int registered_vgstack_id; + Int registered_vgstack_id; #endif VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", - tid); + "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n", tid); tst = VG_(get_ThreadState)(tid); vg_assert(tst); @@ -157,17 +148,15 @@ static void run_a_thread_NORETURN ( Word tidW ) When Valgrind runs as an inner, it must signals that its (real) stack is the stack to use by the outer to e.g. do stacktraces. */ - INNER_REQUEST - (registered_vgstack_id - = VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST(registered_vgstack_id = VALGRIND_STACK_REGISTER( + tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); /* Run the thread all the way through. */ src = thread_wrapper(tid); VG_(debugLog)(1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", - tid); + "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n", tid); c = VG_(count_living_threads)(); vg_assert(c >= 1); /* stay sane */ @@ -178,7 +167,7 @@ static void run_a_thread_NORETURN ( Word tidW ) } // Tell the tool this thread is exiting - VG_TRACK( pre_thread_ll_exit, tid ); + VG_TRACK(pre_thread_ll_exit, tid); /* If the thread is exiting with errors disabled, complain loudly; doing so is bad (does the user know this has happened?) Also, @@ -187,17 +176,13 @@ static void run_a_thread_NORETURN ( Word tidW ) should be unnecessary since the flag should be cleared when the slot is reallocated, in thread_wrapper(). */ if (tst->err_disablement_level > 0) { - VG_(umsg)( - "WARNING: exiting thread has error reporting disabled.\n" - "WARNING: possibly as a result of some mistake in the use\n" - "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n" - ); - VG_(debugLog)( - 1, "syswrap-freebsd", - "run_a_thread_NORETURN(tid=%u): " - "WARNING: exiting thread has err_disablement_level = %u\n", - tid, tst->err_disablement_level - ); + VG_(umsg)("WARNING: exiting thread has error reporting disabled.\n" + "WARNING: possibly as a result of some mistake in the use\n" + "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"); + VG_(debugLog)(1, "syswrap-freebsd", + "run_a_thread_NORETURN(tid=%u): " + "WARNING: exiting thread has err_disablement_level = %u\n", + tid, tst->err_disablement_level); } tst->err_disablement_level = 0; @@ -211,7 +196,7 @@ static void run_a_thread_NORETURN ( Word tidW ) /* We are the last one standing. Keep hold of the lock and carry on to show final tool results, then exit the entire system. Use the continuation pointer set at startup in m_main. */ - ( * VG_(address_of_m_main_shutdown_actions_NORETURN) ) (tid, src); + (*VG_(address_of_m_main_shutdown_actions_NORETURN))(tid, src); } else { VG_(debugLog)(1, "syswrap-freebsd", @@ -227,7 +212,7 @@ static void run_a_thread_NORETURN ( Word tidW ) vg_assert(sizeof(tst->status) == 4); vg_assert(sizeof(tst->os_state.exitcode) == sizeof(Word)); - INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id)); + INNER_REQUEST(VALGRIND_STACK_DEREGISTER(registered_vgstack_id)); /* We have to use this sequence to terminate the thread to prevent a subtle race. If VG_(exit_thread)() had left the @@ -237,34 +222,32 @@ static void run_a_thread_NORETURN ( Word tidW ) reallocation. We need to make sure we don't touch the stack between marking it Empty and exiting. Hence the assembler. */ -#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ - __asm__ volatile ( +#if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ + __asm__ volatile( "movl %1, %0\n" /* set tst->status = VgTs_Empty */ - "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */ - "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */ - "pushl %%ebx\n" /* arg on stack */ - "pushl %%ebx\n" /* fake return address */ - "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ - "popl %%ebx\n" /* fake return address */ - "popl %%ebx\n" /* arg off stack */ - : "=m" (tst->status) - : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) - : "eax", "ebx" - ); + "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */ + "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */ + "pushl %%ebx\n" /* arg on stack */ + "pushl %%ebx\n" /* fake return address */ + "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */ + "popl %%ebx\n" /* fake return address */ + "popl %%ebx\n" /* arg off stack */ + : "=m"(tst->status) + : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(tst->os_state.exitcode) + : "eax", "ebx"); #elif defined(VGP_amd64_freebsd) - __asm__ volatile ( + __asm__ volatile( "movl %1, %0\n" /* set tst->status = VgTs_Empty */ - "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */ - "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */ - "pushq %%rdi\n" /* fake return address */ - "syscall\n" /* thr_exit(tst->os_state.exitcode) */ - "popq %%rdi\n" /* fake return address */ - : "=m" (tst->status) - : "n" (VgTs_Empty), "n" (__NR_thr_exit), "m" (tst->os_state.exitcode) - : "rax", "rdi" - ); + "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */ + "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */ + "pushq %%rdi\n" /* fake return address */ + "syscall\n" /* thr_exit(tst->os_state.exitcode) */ + "popq %%rdi\n" /* fake return address */ + : "=m"(tst->status) + : "n"(VgTs_Empty), "n"(__NR_thr_exit), "m"(tst->os_state.exitcode) + : "rax", "rdi"); #else -# error Unknown platform +#error Unknown platform #endif VG_(core_panic)("Thread exit failed?\n"); @@ -274,12 +257,12 @@ static void run_a_thread_NORETURN ( Word tidW ) vg_assert(0); } -Word ML_(start_thread_NORETURN) ( void* arg ) +Word ML_(start_thread_NORETURN)(void* arg) { ThreadState* tst = (ThreadState*)arg; ThreadId tid = tst->tid; - run_a_thread_NORETURN ( (Word)tid ); + run_a_thread_NORETURN((Word)tid); /*NOTREACHED*/ vg_assert(0); } @@ -308,7 +291,7 @@ Addr ML_(allocstack)(ThreadId tid) /* If no stack is present, allocate one. */ if (tst->os_state.valgrind_stack_base == 0) { - stack = VG_(am_alloc_VgStack)( &initial_SP ); + stack = VG_(am_alloc_VgStack)(&initial_SP); if (stack) { tst->os_state.valgrind_stack_base = (Addr)stack; tst->os_state.valgrind_stack_init_SP = initial_SP; @@ -316,10 +299,9 @@ Addr ML_(allocstack)(ThreadId tid) } if (0) { - VG_(printf)( "stack for tid %u at %p; init_SP=%p\n", - tid, - (void*)tst->os_state.valgrind_stack_base, - (void*)tst->os_state.valgrind_stack_init_SP ); + VG_(printf)("stack for tid %u at %p; init_SP=%p\n", tid, + (void*)tst->os_state.valgrind_stack_base, + (void*)tst->os_state.valgrind_stack_init_SP); } return tst->os_state.valgrind_stack_init_SP; @@ -330,8 +312,7 @@ Addr ML_(allocstack)(ThreadId tid) (VG_(interim_stack)) it's better to allocate a new one, so that overflow detection works uniformly for all threads. */ -__attribute__((noreturn)) -void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) +__attribute__((noreturn)) void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) { Addr sp; VG_(debugLog)(1, "syswrap-freebsd", @@ -344,10 +325,9 @@ void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind // reports 'write error' on the non registered stack. ThreadState* tst = VG_(get_ThreadState)(tid); - INNER_REQUEST - ((void) - VALGRIND_STACK_REGISTER (tst->os_state.valgrind_stack_base, - tst->os_state.valgrind_stack_init_SP)); + INNER_REQUEST( + (void)VALGRIND_STACK_REGISTER(tst->os_state.valgrind_stack_base, + tst->os_state.valgrind_stack_init_SP)); } #endif @@ -356,22 +336,20 @@ void VG_(main_thread_wrapper_NORETURN)(ThreadId tid) vg_assert2(sp != 0, "%s", "Cannot allocate main thread's stack."); /* shouldn't be any other threads around yet */ - vg_assert( VG_(count_living_threads)() == 1 ); + vg_assert(VG_(count_living_threads)() == 1); - ML_(call_on_new_stack_0_1)( - (Addr)sp, /* stack */ - 0, /* bogus return address */ - run_a_thread_NORETURN, /* fn to call */ - (Word)tid /* arg to give it */ + ML_(call_on_new_stack_0_1)((Addr)sp, /* stack */ + 0, /* bogus return address */ + run_a_thread_NORETURN, /* fn to call */ + (Word)tid /* arg to give it */ ); /*NOTREACHED*/ vg_assert(0); } - /* Do a fork() */ -SysRes ML_(do_fork) ( ThreadId tid ) +SysRes ML_(do_fork)(ThreadId tid) { vki_sigset_t fork_saved_mask; vki_sigset_t mask; @@ -384,7 +362,7 @@ SysRes ML_(do_fork) ( ThreadId tid ) VG_(do_atfork_pre)(tid); - res = VG_(do_syscall0)( __NR_fork ); + res = VG_(do_syscall0)(__NR_fork); if (!sr_isError(res)) { if (sr_Res(res) == 0) { @@ -411,15 +389,15 @@ SysRes ML_(do_fork) ( ThreadId tid ) return res; } -static Addr ML_(make_safe_mask) ( const HChar* malloc_message, Addr mask_pointer ) +static Addr ML_(make_safe_mask)(const HChar* malloc_message, Addr mask_pointer) { - vki_sigset_t* new_mask; - const vki_sigset_t* old_mask = (vki_sigset_t *)mask_pointer; + vki_sigset_t* new_mask; + const vki_sigset_t* old_mask = (vki_sigset_t*)mask_pointer; if (!ML_(safe_to_deref)(old_mask, sizeof(vki_sigset_t))) { new_mask = (vki_sigset_t*)1; /* Something recognisable to POST() hook. */ } else { - new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); + new_mask = VG_(malloc)(malloc_message, sizeof(vki_sigset_t)); *new_mask = *old_mask; VG_(sanitize_client_sigmask)(new_mask); } @@ -427,14 +405,13 @@ static Addr ML_(make_safe_mask) ( const HChar* malloc_message, Addr mask_pointer return (Addr)new_mask; } -static void ML_(free_safe_mask) ( Addr mask_pointer ) +static void ML_(free_safe_mask)(Addr mask_pointer) { if (mask_pointer != 0 && mask_pointer != 1) { - VG_(free)((vki_sigset_t *) mask_pointer); + VG_(free)((vki_sigset_t*)mask_pointer); } } - /* --------------------------------------------------------------------- PRE/POST wrappers for arch-generic, FreeBSD-specific syscalls ------------------------------------------------------------------ */ @@ -442,8 +419,8 @@ static void ML_(free_safe_mask) ( Addr mask_pointer ) // Nb: See the comment above the generic PRE/POST wrappers in // m_syswrap/syswrap-generic.c for notes about how they work. -#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) -#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) +#define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name) +#define POST(name) DEFN_POST_TEMPLATE(freebsd, name) /* On FreeBSD, if any thread calls exit(2), then they are all shut down, pretty * much like linux's exit_group(). @@ -452,25 +429,25 @@ static void ML_(free_safe_mask) ( Addr mask_pointer ) // void exit(int status); PRE(sys_exit) { - ThreadId t; + ThreadId t; PRINT("exit( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(void, "exit", int, status); /* Mark all threads (including this one) to exit. */ for (t = 1; t < VG_N_THREADS; t++) { - if ( /* not alive */ VG_(threads)[t].status == VgTs_Empty ) { + if (/* not alive */ VG_(threads)[t].status == VgTs_Empty) { continue; } - //VG_(threads)[t].exitreason = VgSrc_ExitThread; + // VG_(threads)[t].exitreason = VgSrc_ExitThread; VG_(threads)[t].os_state.exitcode = ARG1; // if (t != tid) // VG_(get_thread_out_of_syscall)(t); /* unblock it, if blocked */ } - VG_(nuke_all_threads_except)( tid, VgSrc_ExitProcess ); + VG_(nuke_all_threads_except)(tid, VgSrc_ExitProcess); VG_(reap_threads)(tid); VG_(threads)[tid].exitreason = VgSrc_ExitThread; @@ -485,7 +462,7 @@ PRE(sys_fork) PRINT("%s", "sys_fork ()"); PRE_REG_READ0(pid_t, "fork"); - SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); + SET_STATUS_from_SysRes(ML_(do_fork)(tid)); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -542,12 +519,13 @@ PRE(sys_mount) // We are conservative and check everything, except the memory pointed to // by 'data'. *flags |= SfMayBlock; - PRINT( "sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "mount", - const char *, type, char *, dir, int, flags, - void *, data); - PRE_MEM_RASCIIZ( "mount(type)", ARG1); - PRE_MEM_RASCIIZ( "mount(path)", ARG2); + PRINT("sys_mount( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "mount", const char*, type, char*, dir, int, flags, void*, + data); + PRE_MEM_RASCIIZ("mount(type)", ARG1); + PRE_MEM_RASCIIZ("mount(path)", ARG2); } // SYS_unmount 22 @@ -555,8 +533,8 @@ PRE(sys_mount) PRE(sys_unmount) { PRINT("sys_umount( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); - PRE_REG_READ2(int, "unmount", const char *, dir, int, flags); - PRE_MEM_RASCIIZ( "unmount(path)", ARG1); + PRE_REG_READ2(int, "unmount", const char*, dir, int, flags); + PRE_MEM_RASCIIZ("unmount(path)", ARG1); } // SYS_setuid 23 @@ -572,10 +550,13 @@ PRE(sys_unmount) // int ptrace(int request, pid_t pid, caddr_t addr, int data); PRE(sys_ptrace) { - struct vki_ptrace_io_desc *io_desc; - PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %" FMT_REGWORD "u)", ARG1, ARG2, ARG3, ARG4); + struct vki_ptrace_io_desc* io_desc; + PRINT("sys_ptrace ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, 0x%" FMT_REGWORD + "x, %" FMT_REGWORD "u)", + ARG1, ARG2, ARG3, ARG4); - PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, data); + PRE_REG_READ4(int, "ptrace", int, request, pid_t, pid, caddr_t, addr, int, + data); switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -587,15 +568,15 @@ PRE(sys_ptrace) case VKI_PTRACE_IO: PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_ptrace_io_desc)); - io_desc = (struct vki_ptrace_io_desc *)ARG3; + io_desc = (struct vki_ptrace_io_desc*)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: - PRE_MEM_WRITE( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_WRITE("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; case VKI_PIOD_WRITE_D: case VKI_PIOD_WRITE_I: - PRE_MEM_READ( "ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); + PRE_MEM_READ("ptrace", (UWord)io_desc->piod_addr, io_desc->piod_len); break; } break; @@ -639,7 +620,7 @@ PRE(sys_ptrace) break; case VKI_PTRACE_GETLWPLIST: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(vki_lwpid_t) * ARG4); break; case VKI_PTRACE_SETSTEP: @@ -652,14 +633,14 @@ PRE(sys_ptrace) case VKI_PTRACE_VM_TIMESTAMP: break; case VKI_PTRACE_VM_ENTRY: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); break; } } POST(sys_ptrace) { - struct vki_ptrace_io_desc *io_desc; + struct vki_ptrace_io_desc* io_desc; switch (ARG1) { case VKI_PTRACE_TRACEME: @@ -670,7 +651,7 @@ POST(sys_ptrace) break; case VKI_PTRACE_IO: - io_desc = (struct vki_ptrace_io_desc *)ARG3; + io_desc = (struct vki_ptrace_io_desc*)ARG3; switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: @@ -756,15 +737,18 @@ POST(sys_ptrace) PRE(sys_recvmsg) { *flags |= SfMayBlock; - PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d )",SARG1,ARG2,SARG3); - PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr *, msg, int, flags); - ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2); + PRINT("sys_recvmsg ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "d )", + SARG1, ARG2, SARG3); + PRE_REG_READ3(vki_ssize_t, "recvmsg", int, s, struct msghdr*, msg, int, + flags); + ML_(generic_PRE_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2); } POST(sys_recvmsg) { - ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr *)ARG2, RES); + ML_(generic_POST_sys_recvmsg)(tid, "recvmsg", (struct vki_msghdr*)ARG2, RES); } // SYS_sendmsg 28 @@ -772,30 +756,34 @@ POST(sys_recvmsg) PRE(sys_sendmsg) { *flags |= SfMayBlock; - PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(ssize_t, "sendmsg", - int, s, const struct msghdr *, msg, int, flags); - ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr *)ARG2); + PRINT("sys_sendmsg ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(ssize_t, "sendmsg", int, s, const struct msghdr*, msg, int, + flags); + ML_(generic_PRE_sys_sendmsg)(tid, "sendmsg", (struct vki_msghdr*)ARG2); } // SYS_recvfrom 29 // ssize_t recvfrom(int s, void *buf, size_t len, int flags, -// struct sockaddr * restrict from, socklen_t * restrict fromlen); +// struct sockaddr * restrict from, socklen_t * restrict +// fromlen); PRE(sys_recvfrom) { *flags |= SfMayBlock; - PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3,SARG4,ARG5,ARG6); - PRE_REG_READ6(ssize_t, "recvfrom", - int, s, void *, buf, size_t, len, int, flags, - struct sockaddr *, from, int *, fromlen); - ML_(generic_PRE_sys_recvfrom)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + PRINT("sys_recvfrom ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3, SARG4, ARG5, ARG6); + PRE_REG_READ6(ssize_t, "recvfrom", int, s, void*, buf, size_t, len, int, + flags, struct sockaddr*, from, int*, fromlen); + ML_(generic_PRE_sys_recvfrom)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); } POST(sys_recvfrom) { vg_assert(SUCCESS); - ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + ML_(generic_POST_sys_recvfrom)(tid, VG_(mk_SysRes_Success)(RES), ARG1, ARG2, + ARG3, ARG4, ARG5, ARG6); } // SYS_accept 30 @@ -804,18 +792,19 @@ POST(sys_recvfrom) PRE(sys_accept) { *flags |= SfMayBlock; - PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "accept", - int, s, struct sockaddr *, addr, int, *addrlen); - ML_(generic_PRE_sys_accept)(tid, ARG1,ARG2,ARG3); + PRINT("sys_accept ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "accept", int, s, struct sockaddr*, addr, int, *addrlen); + ML_(generic_PRE_sys_accept)(tid, ARG1, ARG2, ARG3); } POST(sys_accept) { SysRes r; vg_assert(SUCCESS); - r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + r = ML_(generic_POST_sys_accept)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); SET_STATUS_from_SysRes(r); } @@ -824,17 +813,19 @@ POST(sys_accept) // socklen_t * restrict namelen); PRE(sys_getpeername) { - PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "getpeername", - int, s, struct sockaddr *, name, socklen_t *, namelen); - ML_(generic_PRE_sys_getpeername)(tid, ARG1,ARG2,ARG3); + PRINT("sys_getpeername ( %" FMT_REGWORD "u, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "getpeername", int, s, struct sockaddr*, name, socklen_t*, + namelen); + ML_(generic_PRE_sys_getpeername)(tid, ARG1, ARG2, ARG3); } POST(sys_getpeername) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + ML_(generic_POST_sys_getpeername)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); } // SYS_getsockname 32 @@ -842,17 +833,19 @@ POST(sys_getpeername) // socklen_t * restrict namelen); PRE(sys_getsockname) { - PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",SARG1,ARG2,ARG3); - PRE_REG_READ3(long, "getsockname", - int, s, struct sockaddr *, name, int *, namelen); - ML_(generic_PRE_sys_getsockname)(tid, ARG1,ARG2,ARG3); + PRINT("sys_getsockname ( %" FMT_REGWORD "d, %#" FMT_REGWORD + "x, %#" FMT_REGWORD "x )", + SARG1, ARG2, ARG3); + PRE_REG_READ3(long, "getsockname", int, s, struct sockaddr*, name, int*, + namelen); + ML_(generic_PRE_sys_getsockname)(tid, ARG1, ARG2, ARG3); } POST(sys_getsockname) { vg_assert(SUCCESS); - ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3); + ML_(generic_POST_sys_getsockname)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3); } // SYS_access 33 @@ -862,17 +855,17 @@ POST(sys_getsockname) // int chflags(const char *path, unsigned long flags) PRE(sys_chflags) { - PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "chflags", - const char *, path, unsigned long, flags); - PRE_MEM_RASCIIZ( "chflags(path)", ARG1 ); + PRINT("sys_chflags ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "chflags", const char*, path, unsigned long, flags); + PRE_MEM_RASCIIZ("chflags(path)", ARG1); } // SYS_fchflags 35 // int fchflags(int fd, unsigned long flags); PRE(sys_fchflags) { - PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2); + PRINT("sys_fchflags ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(int, "fchflags", int, fd, unsigned long, flags); } @@ -891,18 +884,15 @@ PRE(sys_fchflags) // Pipe on freebsd doesn't have args, and uses dual returns! // SYS_freebsd10_pipe 42 // int pipe(void); -PRE(sys_pipe) -{ - PRINT("%s", "sys_pipe ()"); -} +PRE(sys_pipe) { PRINT("%s", "sys_pipe ()"); } POST(sys_pipe) { if (!ML_(fd_allowed)(RES, "pipe", tid, True) || - !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { + !ML_(fd_allowed)(RESHI, "pipe", tid, True)) { VG_(close)(RES); VG_(close)(RESHI); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); @@ -930,23 +920,20 @@ POST(sys_pipe) // so let's go with those names PRE(sys_getlogin) { - PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); - PRE_REG_READ2(int, "getlogin", char *, buf, u_int, len); - PRE_MEM_WRITE( "getlogin(name)", ARG1, ARG2 ); + PRINT("sys_getlogin ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2); + PRE_REG_READ2(int, "getlogin", char*, buf, u_int, len); + PRE_MEM_WRITE("getlogin(name)", ARG1, ARG2); } -POST(sys_getlogin) -{ - POST_MEM_WRITE(ARG1, ARG2 ); -} +POST(sys_getlogin) { POST_MEM_WRITE(ARG1, ARG2); } // SYS_setlogin 50 // int setlogin(const char *name); PRE(sys_setlogin) { - PRINT("sys_setlogin ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ1(long, "setlogin", char *, buf); - PRE_MEM_RASCIIZ( "setlogin(buf)", ARG1 ); + PRINT("sys_setlogin ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(long, "setlogin", char*, buf); + PRE_MEM_RASCIIZ("setlogin(buf)", ARG1); } // SYS_acct 51 @@ -963,27 +950,31 @@ PRE(sys_ioctl) UInt size = _VKI_IOC_SIZE(ARG2); *flags |= SfMayBlock; // @todo PJF presumably the presence of ARG3 depends on ARG2 - PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "ioctl", - int, fd, unsigned long, request, unsigned long, arg); + PRINT("sys_ioctl ( %" FMT_REGWORD "u, 0x%" FMT_REGWORD "x, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "ioctl", int, fd, unsigned long, request, unsigned long, + arg); - /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */ + /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder + */ if (SimHintiS(SimHint_lax_ioctls, VG_(clo_sim_hints))) { /* - * Be very lax about ioctl handling; the only - * assumption is that the size is correct. Doesn't - * require the full buffer to be initialized when - * writing. Without this, using some device - * drivers with a large number of strange ioctl - * commands becomes very tiresome. - */ + * Be very lax about ioctl handling; the only + * assumption is that the size is correct. Doesn't + * require the full buffer to be initialized when + * writing. Without this, using some device + * drivers with a large number of strange ioctl + * commands becomes very tiresome. + */ } else if (dir == _VKI_IOC_NONE && size > 0) { static UWord unknown_ioctl[10]; - static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); + static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); if (moans > 0 && !VG_(clo_xml)) { /* Check if have not already moaned for this request. */ UInt i; - for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) { + for (i = 0; i < sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]); + i++) { if (unknown_ioctl[i] == ARG2) { break; } @@ -991,20 +982,22 @@ PRE(sys_ioctl) unknown_ioctl[i] = ARG2; moans--; VG_(umsg)("Warning: noted but unhandled ioctl 0x%lx" - " with no direction hints.\n", ARG2); - VG_(umsg)(" This could cause spurious value errors to appear.\n"); + " with no direction hints.\n", + ARG2); + VG_(umsg)( + " This could cause spurious value errors to appear.\n"); VG_(umsg)(" See README_MISSING_SYSCALL_OR_IOCTL for " - "guidance on writing a proper wrapper.\n" ); + "guidance on writing a proper wrapper.\n"); return; } } } } else { if ((dir & _VKI_IOC_WRITE) && size > 0) { - PRE_MEM_READ( "ioctl(generic)", ARG3, size); + PRE_MEM_READ("ioctl(generic)", ARG3, size); } if ((dir & _VKI_IOC_READ) && size > 0) { - PRE_MEM_WRITE( "ioctl(generic)", ARG3, size); + PRE_MEM_WRITE("ioctl(generic)", ARG3, size); } } @@ -1075,8 +1068,7 @@ POST(sys_ioctl) UInt dir = _VKI_IOC_DIR(ARG2); UInt size = _VKI_IOC_SIZE(ARG2); vg_assert(SUCCESS); - if (size > 0 && (dir & _VKI_IOC_READ) - && RES == 0 && ARG3 != (Addr)NULL) { + if (size > 0 && (dir & _VKI_IOC_READ) && RES == 0 && ARG3 != (Addr)NULL) { POST_MEM_WRITE(ARG3, size); } @@ -1132,57 +1124,61 @@ PRE(sys_reboot) PRE(sys_revoke) { PRINT("sys_revoke ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); - PRE_REG_READ1(long, "revoke", const char *, path); - PRE_MEM_RASCIIZ( "revoke(path)", ARG1); + PRE_REG_READ1(long, "revoke", const char*, path); + PRE_MEM_RASCIIZ("revoke(path)", ARG1); } // SYS_symlink 57 // generic -static void do_readlink(const HChar* path, HChar *buf, SizeT bufsize, SyscallStatus* status, Bool* curproc_file) +static void do_readlink(const HChar* path, + HChar* buf, + SizeT bufsize, + SyscallStatus* status, + Bool* curproc_file) { HChar name[30]; VG_(sprintf)(name, "/proc/%d/file", VG_(getpid)()); - if (ML_(safe_to_deref)(path, 1) - && (VG_(strcmp)(path, name) == 0 - || VG_(strcmp)(path, "/proc/curproc/file") == 0)) { + if (ML_(safe_to_deref)(path, 1) && + (VG_(strcmp)(path, name) == 0 || + VG_(strcmp)(path, "/proc/curproc/file") == 0)) { vg_assert(VG_(resolved_exename)); - Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); + Int len = VG_(snprintf)(buf, bufsize, "%s", VG_(resolved_exename)); SET_STATUS_Success(len); *curproc_file = True; } } // SYS_readlink 58 -// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsiz); +// ssize_t readlink(const char *restrict path, char *restrict buf, size_t +// bufsiz); PRE(sys_readlink) { FUSE_COMPATIBLE_MAY_BLOCK(); - Word saved = SYSNO; + Word saved = SYSNO; Bool curproc_file = False; PRINT("sys_readlink ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %llu )", ARG1, (char*)(Addr)ARG1, ARG2, (ULong)ARG3); - PRE_REG_READ3(long, "readlink", - const char *, path, char *, buf, int, bufsiz); - PRE_MEM_RASCIIZ( "readlink(path)", ARG1 ); - PRE_MEM_WRITE( "readlink(buf)", ARG2,ARG3 ); + PRE_REG_READ3(long, "readlink", const char*, path, char*, buf, int, bufsiz); + PRE_MEM_RASCIIZ("readlink(path)", ARG1); + PRE_MEM_WRITE("readlink(buf)", ARG2, ARG3); - if (VG_(have_slash_proc) == True) - { + if (VG_(have_slash_proc) == True) { /* * Handle the case where readlink is looking at /proc/curproc/file or * /proc/<pid>/file */ - do_readlink((const HChar *)ARG1, (HChar *)ARG2, (SizeT)ARG3, status, &curproc_file); + do_readlink((const HChar*)ARG1, (HChar*)ARG2, (SizeT)ARG3, status, + &curproc_file); } if (!curproc_file) { /* Normal case */ - SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); + SET_STATUS_from_SysRes(VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); } if (SUCCESS && RES > 0) { - POST_MEM_WRITE( ARG2, RES ); + POST_MEM_WRITE(ARG2, RES); } } @@ -1206,7 +1202,7 @@ PRE(sys_vfork) PRE_REG_READ0(pid_t, "vfork"); /* Pretend vfork == fork. Not true, but will have to do. */ - SET_STATUS_from_SysRes( ML_(do_fork)(tid) ); + SET_STATUS_from_SysRes(ML_(do_fork)(tid)); if (SUCCESS) { /* Thread creation was successful; let the child have the chance to run */ @@ -1218,7 +1214,7 @@ PRE(sys_vfork) // void * sbrk(intptr_t incr); PRE(sys_sbrk) { - PRINT("sys_sbrk ( %#" FMT_REGWORD "x )",ARG1); + PRINT("sys_sbrk ( %#" FMT_REGWORD "x )", ARG1); PRE_REG_READ1(void*, "sbrk", vki_intptr_t, incr); } @@ -1256,9 +1252,9 @@ PRE(sys_sbrk) // int swapon(const char *special); PRE(sys_swapon) { - PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1,(char*)ARG1); - PRE_REG_READ1(int, "swapon", const char*, special ); - PRE_MEM_RASCIIZ( "swapon(special)", ARG1 ); + PRINT("sys_swapon ( %#" FMT_REGWORD "x(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(int, "swapon", const char*, special); + PRE_MEM_RASCIIZ("swapon(special)", ARG1); } // SYS_getitimer 86 @@ -1286,7 +1282,7 @@ PRE(sys_fcntl) case VKI_F_GETOWN: case VKI_F_GET_SEALS: case VKI_F_ISUNIONSTACK: - PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2); + PRINT("sys_fcntl ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); PRE_REG_READ2(int, "fcntl", int, fd, int, cmd); break; @@ -1299,9 +1295,10 @@ PRE(sys_fcntl) case VKI_F_READAHEAD: case VKI_F_RDAHEAD: case VKI_F_ADD_SEALS: - PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1,SARG2,SARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, int, arg); + PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %" FMT_REGWORD "d )", + SARG1, SARG2, SARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, int, arg); break; // These ones use ARG3 as "lock" - obsolete. @@ -1310,20 +1307,20 @@ PRE(sys_fcntl) /* FALLTHROUGH */ case VKI_F_OGETLK: case VKI_F_OSETLK: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct oflock *, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct oflock*, lock); break; // This one uses ARG3 as "oldd" and ARG4 as "newd". case VKI_F_DUP2FD: case VKI_F_DUP2FD_CLOEXEC: - PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", - ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "fcntl", - int, fd, int, cmd, - unsigned long, oldd, unsigned long, newd); + PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD + "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "fcntl", int, fd, int, cmd, unsigned long, oldd, + unsigned long, newd); break; // These ones use ARG3 as "lock". @@ -1333,24 +1330,26 @@ PRE(sys_fcntl) case VKI_F_GETLK: case VKI_F_SETLK: case VKI_F_SETLK_REMOTE: - PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct flock *, lock); + PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct flock*, lock); break; case VKI_F_KINFO: - PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "fcntl", - int, fd, int, cmd, - struct vki_kinfo_file *, kinfo); + PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "fcntl", int, fd, int, cmd, struct vki_kinfo_file*, + kinfo); if (ARG3) { struct vki_kinfo_file* p_kinfo_file = (struct vki_kinfo_file*)ARG3; - PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, p_kinfo_file->vki_kf_structsize); + PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3, + p_kinfo_file->vki_kf_structsize); } break; default: - PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1,ARG2,ARG3); + PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1, ARG2, ARG3); I_die_here; } } @@ -1361,7 +1360,7 @@ POST(sys_fcntl) if (ARG2 == VKI_F_DUPFD) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1370,7 +1369,7 @@ POST(sys_fcntl) } else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) { VG_(close)(RES); - SET_STATUS_Failure( VKI_EMFILE ); + SET_STATUS_Failure(VKI_EMFILE); } else { if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); @@ -1392,7 +1391,9 @@ POST(sys_fcntl) // int socket(int domain, int type, int protocol); PRE(sys_socket) { - PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2,SARG3); + PRINT("sys_socket ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD + "d )", + SARG1, SARG2, SARG3); PRE_REG_READ3(int, "socket", int, domain, int, type, int, protocol); } @@ -1409,10 +1410,12 @@ POST(sys_socket) PRE(sys_connect) { *flags |= SfMayBlock; - PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "connect", - int, s, const struct sockaddr *, name, int, namelen); - ML_(generic_PRE_sys_connect)(tid, ARG1,ARG2,ARG3); + PRINT("sys_connect ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "connect", int, s, const struct sockaddr*, name, int, + namelen); + ML_(generic_PRE_sys_connect)(tid, ARG1, ARG2, ARG3); } // SYS_getpriority 100 @@ -1422,10 +1425,11 @@ PRE(sys_connect) // int bind(int s, const struct sockaddr *addr, socklen_t addrlen); PRE(sys_bind) { - PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3); - PRE_REG_READ3(int, "bind", - int, s, struct sockaddr *, addr, int, addrlen); - ML_(generic_PRE_sys_bind)(tid, ARG1,ARG2,ARG3); + PRINT("sys_bind ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "bind", int, s, struct sockaddr*, addr, int, addrlen); + ML_(generic_PRE_sys_bind)(tid, ARG1, ARG2, ARG3); } // SYS_setsockopt 105 @@ -1433,23 +1437,24 @@ PRE(sys_bind) // socklen_t optlen); PRE(sys_setsockopt) { - PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",SARG1,SARG2,SARG3,ARG4,ARG5); - PRE_REG_READ5(int, "setsockopt", - int, s, int, level, int, optname, - const void *, optval, vki_socklen_t, optlen); - ML_(generic_PRE_sys_setsockopt)(tid, ARG1,ARG2,ARG3,ARG4,ARG5); + PRINT("sys_setsockopt ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD + "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + SARG1, SARG2, SARG3, ARG4, ARG5); + PRE_REG_READ5(int, "setsockopt", int, s, int, level, int, optname, + const void*, optval, vki_socklen_t, optlen); + ML_(generic_PRE_sys_setsockopt)(tid, ARG1, ARG2, ARG3, ARG4, ARG5); } // SYS_listen 106 // int listen(int s, int backlog); PRE(sys_listen) { - PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )",SARG1,SARG2); + PRINT("sys_listen ( %" FMT_REGWORD "d, %" FMT_REGWORD "d )", SARG1, SARG2); PRE_REG_READ2(int, "listen", int, s, int, backlog); } -//SYS_gettimeofday 116 -// generic +// SYS_gettimeofday 116 +// generic // SYS_getrusage 117 // generic @@ -1461,14 +1466,14 @@ PRE(sys_getsockopt) { Addr optval_p = ARG4; Addr optlen_p = ARG5; - PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(int, "getsockopt", - int, s, int, level, int, optname, - void *, optval, int, *optlen); + PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "getsockopt", int, s, int, level, int, optname, void*, + optval, int, *optlen); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_pre_check) ( tid, optval_p, optlen_p, - "getsockopt(optval)", - "getsockopt(optlen)" ); + ML_(buf_and_len_pre_check)(tid, optval_p, optlen_p, "getsockopt(optval)", + "getsockopt(optlen)"); } } @@ -1478,9 +1483,8 @@ POST(sys_getsockopt) Addr optlen_p = ARG5; vg_assert(SUCCESS); if (optval_p != (Addr)NULL) { - ML_(buf_and_len_post_check) ( tid, VG_(mk_SysRes_Success)(RES), - optval_p, optlen_p, - "getsockopt(optlen_out)" ); + ML_(buf_and_len_post_check)(tid, VG_(mk_SysRes_Success)(RES), optval_p, + optlen_p, "getsockopt(optlen_out)"); } } @@ -1515,9 +1519,11 @@ POST(sys_getsockopt) // int mkfifo(const char *path, mode_t mode); PRE(sys_mkfifo) { - PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1, (char *)ARG1, ARG2, ARG3 ); - PRE_REG_READ2(int, "mkfifo", const char *, path, int, mode); - PRE_MEM_RASCIIZ( "mkfifo(path)", ARG1 ); + PRINT("sys_mkfifo ( %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD + "x, 0x%" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2, ARG3); + PRE_REG_READ2(int, "mkfifo", const char*, path, int, mode); + PRE_MEM_RASCIIZ("mkfifo(path)", ARG1); } // SYS_sendto 133 @@ -1526,12 +1532,12 @@ PRE(sys_mkfifo) PRE(sys_sendto) { *flags |= SfMayBlock; - PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); - PRE_REG_READ6(ssize_t, "sendto", - int, s, const void *, msg, int, len, - int, flags, - const struct sockaddr *, to, socklen_t, tolen); - ML_(generic_PRE_sys_sendto)(tid, ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); + PRINT("sys_sendto ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD + "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(ssize_t, "sendto", int, s, const void*, msg, int, len, int, + flags, const struct sockaddr*, to, socklen_t, tolen); + ML_(generic_PRE_sys_sendto)(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); } // SYS_shutdown 134 @@ -1539,7 +1545,7 @@ PRE(sys_sendto) PRE(sys_shutdown) { *flags |= SfMayBlock; - PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2); + PRINT("sys_shutdown ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(int, "shutdown", int, s, int, how); } @@ -1547,17 +1553,19 @@ PRE(sys_shutdown) // int socketpair(int domain, int type, int protocol, int *sv); PRE(sys_socketpair) { - PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4); - PRE_REG_READ4(int, "socketpair", - int, domain, int, type, int, protocol, int *, sv); - ML_(generic_PRE_sys_socketpair)(tid, ARG1,ARG2,ARG3,ARG4); + PRINT("sys_socketpair ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "socketpair", int, domain, int, type, int, protocol, int*, + sv); + ML_(generic_PRE_sys_socketpair)(tid, ARG1, ARG2, ARG3, ARG4); } POST(sys_socketpair) { vg_assert(SUCCESS); - ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), - ARG1,ARG2,ARG3,ARG4); + ML_(generic_POST_sys_socketpair)(tid, VG_(mk_SysRes_Success)(RES), ARG1, + ARG2, ARG3, ARG4); } // SYS_mkdir 136 @@ -1573,9 +1581,9 @@ POST(sys_socketpair) // int adjtime(const struct timeval *delta, struct timeval *olddelta); PRE(sys_adjtime) { - PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2); - PRE_REG_READ2(int, "adjtime", - const struct vki_timeval *, delta, struct vki_timeval *, olddelta); + PRINT("sys_adjtime ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); + PRE_REG_READ2(int, "adjtime", const struct vki_timeval*, delta, + struct vki_timeval*, olddelta); PRE_MEM_READ("adjtime(delta)", ARG1, sizeof(struct vki_timeval)); if (ARG2) { PRE_MEM_WRITE("adjtime(olddelta)", ARG1, sizeof(struct vki_timeval)); @@ -1596,31 +1604,31 @@ POST(sys_adjtime) /* int quotactl(const char *path, int cmd, int id, void *addr); */ PRE(sys_quotactl) { - PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2,ARG3, ARG4); + PRINT("sys_quotactl ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD + "u, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3, ARG4); switch (ARG2) { case VKI_Q_QUOTAON: case VKI_Q_SETQUOTA: case VKI_Q_SETUSE: case VKI_Q_GETQUOTASIZE: - PRE_REG_READ4(int, "quotactl", - const char *, path, int, cmd, int, id, - void *, addr); - PRE_MEM_RASCIIZ( "quotactl(path)", ARG1 ); + PRE_REG_READ4(int, "quotactl", const char*, path, int, cmd, int, id, + void*, addr); + PRE_MEM_RASCIIZ("quotactl(path)", ARG1); break; case VKI_Q_GETQUOTA: if (VG_(tdict).track_pre_reg_read) { - \ + PRRSN; - PRA1("quotactl",const char*,path); - PRA2("quotactl",int,cmd); - PRA4("quotactl",void*,addr); + PRA1("quotactl", const char*, path); + PRA2("quotactl", int, cmd); + PRA4("quotactl", void*, addr); } break; case VKI_Q_QUOTAOFF: case VKI_Q_SYNC: - PRE_REG_READ2(int, "quotactl", - const char *, path, int, cmd); + PRE_REG_READ2(int, "quotactl", const char*, path, int, cmd); break; default: break; @@ -1642,14 +1650,11 @@ PRE(sys_lgetfh) { PRINT("sys_lgetfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "lgetfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ( "lgetfh(path)", ARG1 ); + PRE_MEM_RASCIIZ("lgetfh(path)", ARG1); PRE_MEM_WRITE("lgetfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_lgetfh) -{ - POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); -} +POST(sys_lgetfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } // SYS_getfh 161 // int getfh(const char *path, fhandle_t *fhp); @@ -1657,30 +1662,27 @@ PRE(sys_getfh) { PRINT("sys_getfh ( %#" FMT_REGWORD "x, %" FMT_REGWORD "x ", ARG1, ARG2); PRE_REG_READ2(int, "getfh", const char*, path, vki_fhandle_t*, fhp); - PRE_MEM_RASCIIZ( "getfh(path)", ARG1 ); + PRE_MEM_RASCIIZ("getfh(path)", ARG1); PRE_MEM_WRITE("getfh(fhp)", ARG2, sizeof(vki_fhandle_t)); } -POST(sys_getfh) -{ - POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); -} +POST(sys_getfh) { POST_MEM_WRITE(ARG2, sizeof(vki_fhandle_t)); } #if (FREEBSD_VERS <= FREEBSD_10) // 162 // int getdomainname(char *domainname, int len); PRE(sys_freebsd4_getdomainname) { - PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",ARG1,ARG2); - PRE_REG_READ2(int, "getdomainname", - char *, domainname, int, len); - PRE_MEM_WRITE( "getdomainname(domainname)", ARG1, ARG2 ); + PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", + ARG1, ARG2); + PRE_REG_READ2(int, "getdomainname", char*, domainname, int, len); + PRE_MEM_WRITE("getdomainname(domainname)", ARG1, ARG2); } POST(sys_freebsd4_getdomainname) { if (ARG1 != 0) { - POST_MEM_WRITE( ARG1, ARG2 ); + POST_MEM_WRITE(ARG1, ARG2); } } @@ -1688,9 +1690,9 @@ POST(sys_freebsd4_getdomainname) // int setdomainname(char *domainname, int len); PRE(sys_freebsd4_setdomainname) { - PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )",ARG1); - PRE_REG_READ2(int, "setdomainname", char *, domainname, int, len); - PRE_MEM_RASCIIZ( "setdomainname(domainname)", ARG1 ); + PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ2(int, "setdomainname", char*, domainname, int, len); + PRE_MEM_RASCIIZ("setdomainname(domainname)", ARG1); } // 164 @@ -1698,14 +1700,14 @@ PRE(sys_freebsd4_setdomainname) PRE(sys_freebsd4_uname) { PRINT("sys_freebsd4_uname ( %#" FMT_REGWORD "x )", ARG1); - PRE_REG_READ1(int, "uname", struct utsname *, name); - PRE_MEM_WRITE( "uname(name)", ARG1, sizeof(struct vki_utsname) ); + PRE_REG_READ1(int, "uname", struct utsname*, name); + PRE_MEM_WRITE("uname(name)", ARG1, sizeof(struct vki_utsname)); } POST(sys_freebsd4_uname) { if (ARG1 != 0) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_utsname) ); + POST_MEM_WRITE(ARG1, sizeof(struct vki_utsname)); } } #endif @@ -1716,13 +1718,14 @@ POST(sys_freebsd4_uname) // SYS_rtprio 166 PRE(sys_rtprio) { - PRINT( "sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3 ); - PRE_REG_READ3(int, "rtprio", - int, function, pid_t, pid, struct rtprio *, rtp); + PRINT("sys_rtprio ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD + "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(int, "rtprio", int, function, pid_t, pid, struct rtprio*, rtp); if (ARG1 == VKI_RTP_SET) { - PRE_MEM_READ( "rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_READ("rtprio(rtp#set)", ARG3, sizeof(struct vki_rtprio)); } else if (ARG1 == VKI_RTP_LOOKUP) { - PRE_MEM_WRITE( "rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); + PRE_MEM_WRITE("rtprio(rtp#lookup)", ARG3, sizeof(struct vki_rtprio)); } else { /* PHK ?? */ } @@ -1731,7 +1734,7 @@ PRE(sys_rtprio) POST(sys_rtprio) { if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { - POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); + POST_MEM_WRITE(ARG3, sizeof(struct vki_rtprio)); } } @@ -1772,53 +1775,55 @@ PRE(sys_seteuid) PRE_REG_READ1(long, "seteuid", vki_uid_t, uid); } - #if (FREEBSD_VERS >= FREEBSD_12) // SYS_freebsd11_stat 188 // int stat(char *path, struct freebsd11_stat *sb); PRE(sys_freebsd11_stat) { - PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "stat", char *, path, struct freebsd11_stat *, sb); - PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); - PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2); + PRE_REG_READ2(int, "stat", char*, path, struct freebsd11_stat*, sb); + PRE_MEM_RASCIIZ("stat(path)", ARG1); + PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_stat) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } // SYS_freebsd11_fstat 189 // int fstat(int fd, struct stat *sb); PRE(sys_freebsd11_fstat) { - PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); - PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1, + ARG2); + PRE_REG_READ2(int, "fstat", int, fd, struct stat*, sb); + PRE_MEM_WRITE("fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_fstat) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } // SYS_freebsd11_lstat 190 // int lstat(const char * restrict path, struct stat * restrict sb); PRE(sys_freebsd11_lstat) { - PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(sb, "lstat", const char *, path, struct freebsd11_stat *, sb); - PRE_MEM_RASCIIZ( "lstat(path)", ARG1 ); - PRE_MEM_WRITE( "lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", + ARG1, (char*)ARG1, ARG2); + PRE_REG_READ2(sb, "lstat", const char*, path, struct freebsd11_stat*, sb); + PRE_MEM_RASCIIZ("lstat(path)", ARG1); + PRE_MEM_WRITE("lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } POST(sys_freebsd11_lstat) { vg_assert(SUCCESS); if (RES == 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } } @@ -1826,43 +1831,38 @@ POST(sys_freebsd11_lstat) PRE(sys_stat) { - PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2); - PRE_REG_READ2(int, "stat", char *, path, struct stat *, sb); - PRE_MEM_RASCIIZ( "stat(path)", ARG1 ); - PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) ); -} - -POST(sys_stat) -{ - POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) ); + PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1, + (char*)ARG1, ARG2); + PRE_REG_READ2(int, "stat", char*, path, struct stat*, sb); + PRE_MEM_RASCIIZ("stat(path)", ARG1); + PRE_MEM_WRITE("stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat)); } +POST(sys_stat) { POST_MEM_WRITE(ARG2, sizeof(struct vki_freebsd11_stat)); } PRE(sys_fstat) { - PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2); - PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb); - PRE_MEM_WRITE( "fstat(sb)", ARG2, siz... [truncated message content] |
|
From: Paul F. <pj...@wa...> - 2023-04-22 10:53:24
|
On 22-04-23 01:53, Nicholas Nethercote wrote: > Failing to add test files to Makefile.am is a really easy mistake to > make, and one I've done multiple times recently. Mark, you've often > fixed these, how do you detect them? I did a try push beforehand and it > didn't detect the missing file. Hi Nick [g]make post-regtest-checks does checking that the Makefile.am EXTRA_DIST matches the .exp files (and probably more). It also gets executed, as the name implies, by [g]make regtest. You can run it directly, for instance from the top directory tests/post_regtest_checks . dhat ...checking makefile consistency ...checking header files and include directives A+ Paul |
|
From: Paul F. <pj...@wa...> - 2023-04-22 09:55:24
|
On 20-04-23 22:22, Bart Van Assche wrote: > On 4/17/23 20:30, Nicholas Nethercote wrote: >> Is there any appetite for clang-formatting Valgrind's code? > > Why to reformat the entire code base? Auto-formatting can be used > without reformatting the entire code base. This is how I reformat Linux > kernel and Android patches before I publish these: > > git clang-format HEAD^ > git diff # to review the changes > git commit -a --amend --no-edit # to keep the changes > git reset --hard # to discard the changes > > Plugins are available for many editors (including Emacs and vi) that > support clang-format. Yes, Qt Creator (and I expect VS code as well) has ways to beautify a file, selected text, from the current line and to insert markup to disable clang-format. I expect that's mainly how I'll be using it (on selected blocks of code). A+ Paul |
|
From: Paul F. <pa...@so...> - 2023-04-22 07:39:01
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3b93737876f443709ee0cec81627fe1186f44862 commit 3b93737876f443709ee0cec81627fe1186f44862 Author: Paul Floyd <pj...@wa...> Date: Sat Apr 22 09:37:25 2023 +0200 regtest: add C++11 flag to build of user_histo1.cpp For old compilers that don't default to C++11 or later Diff: --- dhat/tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/dhat/tests/Makefile.am b/dhat/tests/Makefile.am index 818cc10d08..aba7f06fdf 100644 --- a/dhat/tests/Makefile.am +++ b/dhat/tests/Makefile.am @@ -37,3 +37,4 @@ big_CFLAGS = $(AM_CFLAGS) -Wno-unused-result copy_CFLAGS = $(AM_CFLAGS) -fno-builtin user_histo1_SOURCES = user_histo1.cpp +user_histo1_CXXFLAGS = $(AM_CXXFLAGS) -std=c++11 |
|
From: Tobias B. <tb...@we...> - 2023-04-22 06:29:10
|
Hi, a big “THANK YOU!” to all Valgrind developers. Unfortunately, these days I have to deal primarily with nonsensical Java code instead of nonsensical C++ code, so I rarely get to use my favorite tool memcheck anymore. XD From NEWS: > […] It is for example possible to do: > (gdb) memcheck who_point_at &some_struct sizeof(some_struct) > instead of: > (gdb) p &some_struct > $2 = (some_struct_type *) 0x1130a0 <some_struct> > (gdb) p sizeof(some_struct) > $3 = 40 > (gdb) monitor who_point_at 0x1130a0 40 That sounds awesome, thanks! Minor nitpicking: Building c8832cb2d on Ubuntu (MATE) 20.04.6 LTS with gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) produces these 3 warnings: vgdb.c: In function ‘do_multi_mode’: vgdb.c:1332:11: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result] 1332 | asprintf (&reply, | ^~~~~~~~~~~~~~~~~ […] 1347 | "QSetWorkingDir+", (UInt)PBUFSIZ - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vgdb.c: In function ‘fork_and_exec_valgrind’: vgdb.c:1228:13: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 1228 | write (pipefd[1], &err, sizeof (int)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vgdb.c:1283:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 1283 | write (pipefd[1], &err, sizeof (int)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 bits of contribution in NEWS: - from different terminals. So for example to start you program + from different terminals. So for example to start your program Tobias On 22.04.23 03:47, Mark Wielaard wrote: > An RC2 tarball for 3.21.0 is now available at > https://sourceware.org/pub/valgrind/valgrind-3.21.0.RC2.tar.bz2 > (md5sum = f33407fdffbfa78f5014781cc92297cf) > (sha1sum = c520ee0c28d9e20d28aa25d05ce2525c39a69135) > https://sourceware.org/pub/valgrind/valgrind-3.21.0.RC2.tar.bz2.asc > > Please give it a try in configurations that are important for you and > report any problems you have, either on this mailing list, or > (preferably) via our bug tracker at > https://bugs.kde.org/enter_bug.cgi?product=valgrind > > Please check the NEWS entry below for new features that could use some > extra testing. Note that there has also been a dhat extension which > hasn't yet been added to NEWS. > > There is now a a client request for DHAT to mark memory to be > histogrammed: > https://bugs.kde.org/464103 > https://snapshots.sourceware.org/valgrind/trunk/latest/html/dh-manual.html#dh-access-counts > > If nothing critical emerges, a final release will happen on > Friday 28 April. > > * ==================== CORE CHANGES =================== > > * When GDB is used to debug a program running under valgrind using > the valgrind gdbserver, GDB will automatically load some > python code provided in valgrind defining GDB front end commands > corresponding to the valgrind monitor commands. > These GDB front end commands accept the same format as > the monitor commands directly sent to the Valgrind gdbserver. > These GDB front end commands provide a better integration > in the GDB command line interface, so as to use for example > GDB auto-completion, command specific help, searching for > a command or command help matching a regexp, ... > For relevant monitor commands, GDB will evaluate arguments > to make the use of monitor commands easier. > For example, instead of having to print the address of a variable > to pass it to a subsequent monitor command, the GDB front end > command will evaluate the address argument. It is for example > possible to do: > (gdb) memcheck who_point_at &some_struct sizeof(some_struct) > instead of: > (gdb) p &some_struct > $2 = (some_struct_type *) 0x1130a0 <some_struct> > (gdb) p sizeof(some_struct) > $3 = 40 > (gdb) monitor who_point_at 0x1130a0 40 > > * The vgdb utility now supports extended-remote protocol when > invoked with --multi. In this mode the GDB run command is > supported. Which means you don't need to run gdb and valgrind > from different terminals. So for example to start you program > in gdb and run it under valgrind you can do: > $ gdb prog > (gdb) set remote exec-file prog > (gdb) set sysroot / > (gdb) target extended-remote | vgdb --multi > (gdb) start > > * The behaviour of realloc with a size of zero can now > be changed for tools that intercept malloc. Those > tools are memcheck, helgrind, drd, massif and dhat. > Realloc implementations generally do one of two things > - free the memory like free() and return NULL > (GNU libc and ptmalloc). > - either free the memory and then allocate a > minumum siized block or just return the > original pointer. Return NULL if the > allocation of the minimum sized block fails > (jemalloc, musl, snmalloc, Solaris, macOS). > When Valgrind is configured and built it will > try to match the OS and libc behaviour. However > if you are using a non-default library to replace > malloc and family (e.g., musl on a glibc Linux or > tcmalloc on FreeBSD) then you can use a command line > option to change the behaviour of Valgrind: > --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] > > * ================== PLATFORM CHANGES ================= > > * Make the address space limit on FreeBSD amd64 128Gbytes > (the same as Linux and Solaris, it was 32Gbytes) > > * ==================== TOOL CHANGES =================== > > * Memcheck: > - When doing a delta leak_search, it is now possible to only > output the new loss records compared to the previous leak search. > This is available in the memcheck monitor command 'leak_search' > by specifying the "new" keyword or in your program by using > the client request VALGRIND_DO_NEW_LEAK_CHECK. > Whenever a "delta" leak search is done (i.e. when specifying > "new" or "increased" or "changed" in the monitor command), > the new loss records have a "new" marker. > - Valgrind now contains python code that defines GDB memcheck > front end monitor commands. See CORE CHANGES. > - Performs checks for the use of realloc with a size of zero. > This is non-portable and a source of errors. If memcheck > detects such a usage it will generate an error > realloc() with size 0 > followed by the usual callstacks. > A switch has been added to allow this to be turned off: > --show-realloc-size-zero=yes|no [yes] > > * Helgrind: > - The option ---history-backtrace-size=<number> allows to configure > the number of entries to record in the stack traces of "old" > accesses. Previously, this number was hardcoded to 8. > - Valgrind now contains python code that defines GDB helgrind > front end monitor commands. See CORE CHANGES. > > * Cachegrind: > - `--cache-sim=no` is now the default. The cache simulation is old and > unlikely to match any real modern machine. This means only the `Ir` > event are gathered by default, but that is by far the most useful > event. > - `cg_annotate`, `cg_diff`, and `cg_merge` have been rewritten in > Python. As a result, they all have more flexible command line > argument handling, e.g. supporting `--show-percs` and > `--no-show-percs` forms as well as the existing `--show-percs=yes` > and `--show-percs=no`. > - `cg_annotate` has some functional changes. > - It's much faster, e.g. 3-4x on common cases. > - It now supports diffing (with `--diff`, `--mod-filename`, and > `--mod-funcname`) and merging (by passing multiple data files). > - It now provides more information at the file and function level. > There are now "File:function" and "Function:file" sections. These > are very useful for programs that use inlining a lot. > - Support for user-annotated files and the `-I`/`--include` option > has been removed, because it was of little use and blocked other > improvements. > - The `--auto` option is renamed `--annotate`, though the old > `--auto=yes`/`--auto=no` forms are still supported. > - `cg_diff` and `cg_merge` are now deprecated, because `cg_annotate` > now does a better job of diffing and merging. > - The Cachegrind output file format has changed very slightly, but in > ways nobody is likely to notice. > > * Callgrind: > - Valgrind now contains python code that defines GDB callgrind > front end monitor commands. See CORE CHANGES. > > * Massif: > - Valgrind now contains python code that defines GDB massif > front end monitor commands. See CORE CHANGES. > > > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users |
|
From: Mark W. <ma...@kl...> - 2023-04-22 01:47:41
|
An RC2 tarball for 3.21.0 is now available at https://sourceware.org/pub/valgrind/valgrind-3.21.0.RC2.tar.bz2 (md5sum = f33407fdffbfa78f5014781cc92297cf) (sha1sum = c520ee0c28d9e20d28aa25d05ce2525c39a69135) https://sourceware.org/pub/valgrind/valgrind-3.21.0.RC2.tar.bz2.asc Please give it a try in configurations that are important for you and report any problems you have, either on this mailing list, or (preferably) via our bug tracker at https://bugs.kde.org/enter_bug.cgi?product=valgrind Please check the NEWS entry below for new features that could use some extra testing. Note that there has also been a dhat extension which hasn't yet been added to NEWS. There is now a a client request for DHAT to mark memory to be histogrammed: https://bugs.kde.org/464103 https://snapshots.sourceware.org/valgrind/trunk/latest/html/dh-manual.html#dh-access-counts If nothing critical emerges, a final release will happen on Friday 28 April. * ==================== CORE CHANGES =================== * When GDB is used to debug a program running under valgrind using the valgrind gdbserver, GDB will automatically load some python code provided in valgrind defining GDB front end commands corresponding to the valgrind monitor commands. These GDB front end commands accept the same format as the monitor commands directly sent to the Valgrind gdbserver. These GDB front end commands provide a better integration in the GDB command line interface, so as to use for example GDB auto-completion, command specific help, searching for a command or command help matching a regexp, ... For relevant monitor commands, GDB will evaluate arguments to make the use of monitor commands easier. For example, instead of having to print the address of a variable to pass it to a subsequent monitor command, the GDB front end command will evaluate the address argument. It is for example possible to do: (gdb) memcheck who_point_at &some_struct sizeof(some_struct) instead of: (gdb) p &some_struct $2 = (some_struct_type *) 0x1130a0 <some_struct> (gdb) p sizeof(some_struct) $3 = 40 (gdb) monitor who_point_at 0x1130a0 40 * The vgdb utility now supports extended-remote protocol when invoked with --multi. In this mode the GDB run command is supported. Which means you don't need to run gdb and valgrind from different terminals. So for example to start you program in gdb and run it under valgrind you can do: $ gdb prog (gdb) set remote exec-file prog (gdb) set sysroot / (gdb) target extended-remote | vgdb --multi (gdb) start * The behaviour of realloc with a size of zero can now be changed for tools that intercept malloc. Those tools are memcheck, helgrind, drd, massif and dhat. Realloc implementations generally do one of two things - free the memory like free() and return NULL (GNU libc and ptmalloc). - either free the memory and then allocate a minumum siized block or just return the original pointer. Return NULL if the allocation of the minimum sized block fails (jemalloc, musl, snmalloc, Solaris, macOS). When Valgrind is configured and built it will try to match the OS and libc behaviour. However if you are using a non-default library to replace malloc and family (e.g., musl on a glibc Linux or tcmalloc on FreeBSD) then you can use a command line option to change the behaviour of Valgrind: --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] * ================== PLATFORM CHANGES ================= * Make the address space limit on FreeBSD amd64 128Gbytes (the same as Linux and Solaris, it was 32Gbytes) * ==================== TOOL CHANGES =================== * Memcheck: - When doing a delta leak_search, it is now possible to only output the new loss records compared to the previous leak search. This is available in the memcheck monitor command 'leak_search' by specifying the "new" keyword or in your program by using the client request VALGRIND_DO_NEW_LEAK_CHECK. Whenever a "delta" leak search is done (i.e. when specifying "new" or "increased" or "changed" in the monitor command), the new loss records have a "new" marker. - Valgrind now contains python code that defines GDB memcheck front end monitor commands. See CORE CHANGES. - Performs checks for the use of realloc with a size of zero. This is non-portable and a source of errors. If memcheck detects such a usage it will generate an error realloc() with size 0 followed by the usual callstacks. A switch has been added to allow this to be turned off: --show-realloc-size-zero=yes|no [yes] * Helgrind: - The option ---history-backtrace-size=<number> allows to configure the number of entries to record in the stack traces of "old" accesses. Previously, this number was hardcoded to 8. - Valgrind now contains python code that defines GDB helgrind front end monitor commands. See CORE CHANGES. * Cachegrind: - `--cache-sim=no` is now the default. The cache simulation is old and unlikely to match any real modern machine. This means only the `Ir` event are gathered by default, but that is by far the most useful event. - `cg_annotate`, `cg_diff`, and `cg_merge` have been rewritten in Python. As a result, they all have more flexible command line argument handling, e.g. supporting `--show-percs` and `--no-show-percs` forms as well as the existing `--show-percs=yes` and `--show-percs=no`. - `cg_annotate` has some functional changes. - It's much faster, e.g. 3-4x on common cases. - It now supports diffing (with `--diff`, `--mod-filename`, and `--mod-funcname`) and merging (by passing multiple data files). - It now provides more information at the file and function level. There are now "File:function" and "Function:file" sections. These are very useful for programs that use inlining a lot. - Support for user-annotated files and the `-I`/`--include` option has been removed, because it was of little use and blocked other improvements. - The `--auto` option is renamed `--annotate`, though the old `--auto=yes`/`--auto=no` forms are still supported. - `cg_diff` and `cg_merge` are now deprecated, because `cg_annotate` now does a better job of diffing and merging. - The Cachegrind output file format has changed very slightly, but in ways nobody is likely to notice. * Callgrind: - Valgrind now contains python code that defines GDB callgrind front end monitor commands. See CORE CHANGES. * Massif: - Valgrind now contains python code that defines GDB massif front end monitor commands. See CORE CHANGES. |
|
From: Mark W. <ma...@so...> - 2023-04-22 01:42:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=c8832cb2ddf08c6f8c28ff4fd511561e15ec120e commit c8832cb2ddf08c6f8c28ff4fd511561e15ec120e Author: Mark Wielaard <ma...@kl...> Date: Sat Apr 22 03:41:04 2023 +0200 Add helgrind/tests/garbage.filtered.out to .gitignore Diff: --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 71f1828d66..27183b99b9 100644 --- a/.gitignore +++ b/.gitignore @@ -661,6 +661,7 @@ /helgrind/tests/cond_timedwait_invalid /helgrind/tests/cond_timedwait_test /helgrind/tests/free_is_write +/helgrind/tests/garbage.filtered.out /helgrind/tests/hg01_all_ok /helgrind/tests/hg02_deadlock /helgrind/tests/hg03_inherit |
|
From: Mark W. <ma...@so...> - 2023-04-22 01:21:27
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=181b3f24673145e6d1591d974d8f592d391bf731 commit 181b3f24673145e6d1591d974d8f592d391bf731 Author: Mark Wielaard <ma...@kl...> Date: Sat Apr 22 03:00:27 2023 +0200 Set version to 3.21.0-RC2 Diff: --- NEWS | 1 + configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 373de5ef1a..bff5b5d760 100644 --- a/NEWS +++ b/NEWS @@ -190,6 +190,7 @@ To see details of a given bug, visit where XXXXXX is the bug number as listed above. (3.21.0.RC1: 14 Apr 2023) +(3.21.0.RC2: 21 Apr 2023) Release 3.20.0 (24 Oct 2022) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configure.ac b/configure.ac index 8217136d9e..8470daebd1 100755 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ m4_define([v_major_ver], [3]) m4_define([v_minor_ver], [21]) m4_define([v_micro_ver], [0]) -m4_define([v_suffix_ver], [RC1]) -m4_define([v_rel_date], ["14 Apr 2023"]) +m4_define([v_suffix_ver], [RC2]) +m4_define([v_rel_date], ["21 Apr 2023"]) m4_define([v_version], m4_if(v_suffix_ver, [], [v_major_ver.v_minor_ver.v_micro_ver], |