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
|
2
|
3
|
|
4
|
5
|
6
|
7
(1) |
8
|
9
|
10
|
|
11
|
12
|
13
|
14
|
15
|
16
|
17
|
|
18
|
19
|
20
|
21
|
22
(4) |
23
(3) |
24
(2) |
|
25
(9) |
26
(2) |
27
(1) |
28
|
29
(7) |
30
(5) |
31
(2) |
|
From: Paul F. <pa...@so...> - 2022-12-25 21:33:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=67bb7eeec920ffcc2edef5fdf48db04e653f10b9 commit 67bb7eeec920ffcc2edef5fdf48db04e653f10b9 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 25 22:31:55 2022 +0100 Fix suppression file inconsistency from previous commit for Bug 392331 Diff: --- helgrind/tests/{bug392331.suppr => bug392331.supp} | 0 helgrind/tests/bug392331_supp.vgtest | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/helgrind/tests/bug392331.suppr b/helgrind/tests/bug392331.supp similarity index 100% rename from helgrind/tests/bug392331.suppr rename to helgrind/tests/bug392331.supp diff --git a/helgrind/tests/bug392331_supp.vgtest b/helgrind/tests/bug392331_supp.vgtest index 8e0fc7a38c..611b4ca814 100644 --- a/helgrind/tests/bug392331_supp.vgtest +++ b/helgrind/tests/bug392331_supp.vgtest @@ -1,2 +1,2 @@ -vgopts: -q --suppressions=bug392331.suppr +vgopts: -q --suppressions=bug392331.supp prog: bug392331 |
|
From: Paul F. <pa...@so...> - 2022-12-25 20:51:14
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7d0389956e5e6ff182fdf4c2a3a9f8a202a927d4 commit 7d0389956e5e6ff182fdf4c2a3a9f8a202a927d4 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 25 21:43:36 2022 +0100 Bug 392331 - Spurious lock not held error from inside pthread_cond_timedwait Added a "Dubious" error category to cover this kind of error. Diff: --- .gitignore | 1 + NEWS | 1 + helgrind/hg_errors.c | 74 +++++++++++++++++++++++++++++++- helgrind/hg_errors.h | 5 +++ helgrind/hg_main.c | 2 +- helgrind/tests/Makefile.am | 7 +++ helgrind/tests/bug392331.cpp | 58 +++++++++++++++++++++++++ helgrind/tests/bug392331.stderr.exp | 31 +++++++++++++ helgrind/tests/bug392331.stdout.exp | 4 ++ helgrind/tests/bug392331.suppr | 7 +++ helgrind/tests/bug392331.vgtest | 2 + helgrind/tests/bug392331_supp.stderr.exp | 0 helgrind/tests/bug392331_supp.stdout.exp | 4 ++ helgrind/tests/bug392331_supp.vgtest | 2 + 14 files changed, 195 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a72b1dcae0..20282b8a20 100644 --- a/.gitignore +++ b/.gitignore @@ -653,6 +653,7 @@ /helgrind/tests/bar_bad /helgrind/tests/bar_trivial /helgrind/tests/bug322621 +/helgrind/tests/bug392331 /helgrind/tests/cond_init_destroy /helgrind/tests/cond_timedwait_invalid /helgrind/tests/cond_timedwait_test diff --git a/NEWS b/NEWS index e1befb56f5..b538ad5241 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 170510 Don't warn about ioctl of size 0 without direction hint 351857 confusing error message about valid command line option +392331 Spurious lock not held error from inside pthread_cond_timedwait 444110 priv/guest_ppc_toIR.c:36198:31: warning: duplicated 'if' condition. 444488 Use glibc.pthread.stack_cache_size tunable 444568 drd/tests/pth_barrier_thr_cr fails on Fedora 38 diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c index e612449b54..638739dc6e 100644 --- a/helgrind/hg_errors.c +++ b/helgrind/hg_errors.c @@ -293,7 +293,9 @@ typedef XE_UnlockBogus, // unlocking an address not known to be a lock XE_PthAPIerror, // error from the POSIX pthreads API XE_LockOrder, // lock order error - XE_Misc // misc other error (w/ string to describe it) + XE_Misc, // misc other error (w/ string to describe it) + XE_Dubious // a bit like misc for cases where the POSIX + // spec is unclear on error conditons } XErrorTag; @@ -381,7 +383,8 @@ typedef XS_UnlockBogus, XS_PthAPIerror, XS_LockOrder, - XS_Misc + XS_Misc, + XS_Dubious } XSuppTag; @@ -654,6 +657,30 @@ void HG_(record_error_Misc) ( Thread* thr, const HChar* errstr ) HG_(record_error_Misc_w_aux)(thr, errstr, NULL, NULL); } +void HG_(record_error_Dubious_w_aux) ( Thread* thr, const HChar* errstr, + const HChar* auxstr, ExeContext* auxctx ) +{ + XError xe; + tl_assert( HG_(is_sane_Thread)(thr) ); + tl_assert(errstr); + init_XError(&xe); + xe.tag = XE_Dubious; + xe.XE.Misc.thr = thr; + xe.XE.Misc.errstr = string_table_strdup(errstr); + xe.XE.Misc.auxstr = auxstr ? string_table_strdup(auxstr) : NULL; + xe.XE.Misc.auxctx = auxctx; + // FIXME: tid vs thr + tl_assert( HG_(is_sane_ThreadId)(thr->coretid) ); + tl_assert( thr->coretid != VG_INVALID_THREADID ); + VG_(maybe_record_error)( thr->coretid, + XE_Dubious, 0, NULL, &xe ); +} + +void HG_(record_error_Dubious) ( Thread* thr, const HChar* errstr ) +{ + HG_(record_error_Dubious_w_aux)(thr, errstr, NULL, NULL); +} + Bool HG_(eq_Error) ( VgRes not_used, const Error* e1, const Error* e2 ) { XError *xe1, *xe2; @@ -692,6 +719,9 @@ Bool HG_(eq_Error) ( VgRes not_used, const Error* e1, const Error* e2 ) case XE_Misc: return xe1->XE.Misc.thr == xe2->XE.Misc.thr && 0==VG_(strcmp)(xe1->XE.Misc.errstr, xe2->XE.Misc.errstr); + case XE_Dubious: + return xe1->XE.Misc.thr == xe2->XE.Misc.thr + && 0==VG_(strcmp)(xe1->XE.Misc.errstr, xe2->XE.Misc.errstr); default: tl_assert(0); } @@ -872,6 +902,9 @@ void HG_(before_pp_Error) ( const Error* err ) tl_assert(xe); switch (VG_(get_error_kind)(err)) { + case XE_Dubious: + announce_one_thread( xe->XE.Misc.thr ); + break; case XE_Misc: announce_one_thread( xe->XE.Misc.thr ); break; @@ -931,6 +964,40 @@ void HG_(pp_Error) ( const Error* err ) emit( " <kind>%s</kind>\n", HG_(get_error_name)(err)); switch (VG_(get_error_kind)(err)) { + case XE_Dubious: { + tl_assert( HG_(is_sane_Thread)( xe->XE.Misc.thr ) ); + + if (xml) { + + emit( " <xwhat>\n" ); + emit( " <text>Thread #%d: %s</text>\n", + (Int)xe->XE.Misc.thr->errmsg_index, + xe->XE.Misc.errstr ); + emit( " <hthreadid>%d</hthreadid>\n", + (Int)xe->XE.Misc.thr->errmsg_index ); + emit( " </xwhat>\n" ); + VG_(pp_ExeContext)( VG_(get_error_where)(err) ); + if (xe->XE.Misc.auxstr) { + emit(" <auxwhat>%s</auxwhat>\n", xe->XE.Misc.auxstr); + if (xe->XE.Misc.auxctx) + VG_(pp_ExeContext)( xe->XE.Misc.auxctx ); + } + + } else { + + emit( "Thread #%d: %s\n", + (Int)xe->XE.Misc.thr->errmsg_index, + xe->XE.Misc.errstr ); + VG_(pp_ExeContext)( VG_(get_error_where)(err) ); + if (xe->XE.Misc.auxstr) { + emit(" %s\n", xe->XE.Misc.auxstr); + if (xe->XE.Misc.auxctx) + VG_(pp_ExeContext)( xe->XE.Misc.auxctx ); + } + + } + break; + } case XE_Misc: { tl_assert( HG_(is_sane_Thread)( xe->XE.Misc.thr ) ); @@ -1325,6 +1392,7 @@ const HChar* HG_(get_error_name) ( const Error* err ) case XE_PthAPIerror: return "PthAPIerror"; case XE_LockOrder: return "LockOrder"; case XE_Misc: return "Misc"; + case XE_Dubious: return "Dubious"; default: tl_assert(0); /* fill in missing case */ } } @@ -1344,6 +1412,7 @@ Bool HG_(recognised_suppression) ( const HChar* name, Supp *su ) TRY("PthAPIerror", XS_PthAPIerror); TRY("LockOrder", XS_LockOrder); TRY("Misc", XS_Misc); + TRY("Dubious", XS_Dubious); return False; # undef TRY } @@ -1366,6 +1435,7 @@ Bool HG_(error_matches_suppression) ( const Error* err, const Supp* su ) case XS_PthAPIerror: return VG_(get_error_kind)(err) == XE_PthAPIerror; case XS_LockOrder: return VG_(get_error_kind)(err) == XE_LockOrder; case XS_Misc: return VG_(get_error_kind)(err) == XE_Misc; + case XS_Dubious: return VG_(get_error_kind)(err) == XE_Dubious; //case XS_: return VG_(get_error_kind)(err) == XE_; default: tl_assert(0); /* fill in missing cases */ } diff --git a/helgrind/hg_errors.h b/helgrind/hg_errors.h index 08191e1b3d..5824151c9a 100644 --- a/helgrind/hg_errors.h +++ b/helgrind/hg_errors.h @@ -78,6 +78,11 @@ void HG_(record_error_Misc_w_aux) ( Thread*, const HChar* errstr, ExeContext* auxctx ); void HG_(record_error_Misc) ( Thread* thr, const HChar* errstr ); +void HG_(record_error_Dubious_w_aux) ( Thread*, const HChar* errstr, + const HChar* auxstr, + ExeContext* auxctx ); +void HG_(record_error_Dubious) ( Thread* thr, const HChar* errstr ); + /* Statistics pertaining to error management. */ extern ULong HG_(stats__LockN_to_P_queries); diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 490fc38fef..813c983a4c 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -2448,7 +2448,7 @@ static void evh__HG_PTHREAD_COND_SIGNAL_PRE ( ThreadId tid, void* cond ) "pthread_cond_{signal,broadcast}: associated lock is a rwlock"); } if (lk->heldBy == NULL) { - HG_(record_error_Misc)(thr, + HG_(record_error_Dubious)(thr, "pthread_cond_{signal,broadcast}: dubious: " "associated lock is not held by any thread"); } diff --git a/helgrind/tests/Makefile.am b/helgrind/tests/Makefile.am index 05e145f7b8..926a367c7e 100755 --- a/helgrind/tests/Makefile.am +++ b/helgrind/tests/Makefile.am @@ -16,6 +16,9 @@ EXTRA_DIST = \ annotate_smart_pointer.vgtest annotate_smart_pointer.stdout.exp \ annotate_smart_pointer.stderr.exp \ bug322621.vgtest bug322621.stderr.exp \ + bug392331.vgtest bug392331.stdout.exp bug392331.stderr.exp \ + bug392331_supp.vgtest bug392331_supp.stdout.exp bug392331_supp.stderr.exp \ + bug392331.supp \ cond_init_destroy.vgtest cond_init_destroy.stderr.exp \ cond_timedwait_invalid.vgtest cond_timedwait_invalid.stdout.exp \ cond_timedwait_invalid.stderr.exp \ @@ -139,6 +142,7 @@ noinst_HEADERS = safe-pthread.h safe-semaphore.h # should be conditionally compiled like tc20_verifywrap is. check_PROGRAMS = \ annotate_hbefore \ + bug392331 \ cond_init_destroy \ cond_timedwait_invalid \ cond_timedwait_test \ @@ -238,3 +242,6 @@ annotate_hbefore_CFLAGS = $(AM_CFLAGS) endif bug322621_SOURCES = bug322621.cpp +bug392331_SOURCES = bug392331.cpp +bug392331_CXXFLAGS = $(AM_CXXFLAGS) -std=c++17 + diff --git a/helgrind/tests/bug392331.cpp b/helgrind/tests/bug392331.cpp new file mode 100644 index 0000000000..ff26883b76 --- /dev/null +++ b/helgrind/tests/bug392331.cpp @@ -0,0 +1,58 @@ +// For this Bugzilla item https://bugs.kde.org/show_bug.cgi?id=392331 +// Example from https://en.cppreference.com/w/cpp/thread/condition_variable + +#include <iostream> +#include <string> +#include <thread> +#include <mutex> +#include <condition_variable> + +std::mutex m; +std::condition_variable cv; +std::string data; +bool ready = false; +bool processed = false; + +void worker_thread() +{ + // Wait until main() sends data + std::unique_lock lk(m); + cv.wait(lk, []{return ready;}); + + // after the wait, we own the lock. + std::cout << "Worker thread is processing data\n"; + data += " after processing"; + + // Send data back to main() + processed = true; + std::cout << "Worker thread signals data processing completed\n"; + + // Manual unlocking is done before notifying, to avoid waking up + // the waiting thread only to block again (see notify_one for details) + lk.unlock(); + cv.notify_one(); +} + +int main() +{ + std::thread worker(worker_thread); + + data = "Example data"; + // send data to the worker thread + { + std::lock_guard lk(m); + ready = true; + std::cout << "main() signals data ready for processing\n"; + } + cv.notify_one(); + + // wait for the worker + { + std::unique_lock lk(m); + cv.wait(lk, []{return processed;}); + } + std::cout << "Back in main(), data = " << data << '\n'; + + worker.join(); +} + diff --git a/helgrind/tests/bug392331.stderr.exp b/helgrind/tests/bug392331.stderr.exp new file mode 100644 index 0000000000..f278e3b089 --- /dev/null +++ b/helgrind/tests/bug392331.stderr.exp @@ -0,0 +1,31 @@ +---Thread-Announcement------------------------------------------ + +Thread #x is the program's root thread + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread + at 0x........: pthread_cond_signal_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_signal (hg_intercepts.c:...) + ... + by 0x........: main (bug392331.cpp:47) + +---Thread-Announcement------------------------------------------ + +Thread #x was created + ... + by 0x........: pthread_create@* (hg_intercepts.c:...) + ... + by 0x........: main (bug392331.cpp:38) + +---------------------------------------------------------------- + +Thread #x: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread + at 0x........: pthread_cond_signal_WRK (hg_intercepts.c:...) + by 0x........: pthread_cond_signal (hg_intercepts.c:...) + ... + by 0x........: worker_thread() (bug392331.cpp:33) + ... + by 0x........: mythread_wrapper (hg_intercepts.c:...) + ... + diff --git a/helgrind/tests/bug392331.stdout.exp b/helgrind/tests/bug392331.stdout.exp new file mode 100644 index 0000000000..4d6f703ee5 --- /dev/null +++ b/helgrind/tests/bug392331.stdout.exp @@ -0,0 +1,4 @@ +main() signals data ready for processing +Worker thread is processing data +Worker thread signals data processing completed +Back in main(), data = Example data after processing diff --git a/helgrind/tests/bug392331.suppr b/helgrind/tests/bug392331.suppr new file mode 100644 index 0000000000..8262d142e1 --- /dev/null +++ b/helgrind/tests/bug392331.suppr @@ -0,0 +1,7 @@ +{ + Check that Dubious suppression works + Helgrind:Dubious + fun:pthread_cond_signal_WRK + fun:pthread_cond_signal + fun:_ZNSt3__118condition_variable10notify_oneEv +} diff --git a/helgrind/tests/bug392331.vgtest b/helgrind/tests/bug392331.vgtest new file mode 100644 index 0000000000..6c4aff6bf1 --- /dev/null +++ b/helgrind/tests/bug392331.vgtest @@ -0,0 +1,2 @@ +vgopts: -q +prog: bug392331 diff --git a/helgrind/tests/bug392331_supp.stderr.exp b/helgrind/tests/bug392331_supp.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/helgrind/tests/bug392331_supp.stdout.exp b/helgrind/tests/bug392331_supp.stdout.exp new file mode 100644 index 0000000000..4d6f703ee5 --- /dev/null +++ b/helgrind/tests/bug392331_supp.stdout.exp @@ -0,0 +1,4 @@ +main() signals data ready for processing +Worker thread is processing data +Worker thread signals data processing completed +Back in main(), data = Example data after processing diff --git a/helgrind/tests/bug392331_supp.vgtest b/helgrind/tests/bug392331_supp.vgtest new file mode 100644 index 0000000000..8e0fc7a38c --- /dev/null +++ b/helgrind/tests/bug392331_supp.vgtest @@ -0,0 +1,2 @@ +vgopts: -q --suppressions=bug392331.suppr +prog: bug392331 |
|
From: Paul F. <pa...@so...> - 2022-12-25 17:38:17
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=227fa1d53bccaa236af3a72764d5efe763bcf036 commit 227fa1d53bccaa236af3a72764d5efe763bcf036 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 25 18:36:20 2022 +0100 Cleanup for clangd, mostly FreeBSD Consistently use braces. Make some bitwise expressions use unsigned. Use some named variables for magic numbers. Diff: --- coregrind/m_debuginfo/readpdb.c | 3 +- coregrind/m_initimg/initimg-freebsd.c | 132 +++++--- coregrind/m_sigframe/sigframe-amd64-freebsd.c | 22 +- coregrind/m_syswrap/priv_types_n_macros.h | 12 +- coregrind/m_syswrap/syswrap-amd64-freebsd.c | 10 +- coregrind/m_syswrap/syswrap-freebsd.c | 459 ++++++++++++++------------ include/vki/vki-amd64-freebsd.h | 2 +- include/vki/vki-freebsd.h | 16 +- 8 files changed, 380 insertions(+), 276 deletions(-) diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c index f3a3817d89..7c5467d379 100644 --- a/coregrind/m_debuginfo/readpdb.c +++ b/coregrind/m_debuginfo/readpdb.c @@ -1545,8 +1545,9 @@ static ULong DEBUG_SnarfLinetab( Bool debug = di->trace_symtab; ULong n_lines_read = 0; - if (debug) + if (debug) { VG_(umsg)("BEGIN SnarfLineTab linetab=%p size=%d\n", linetab, size); + } /* * Now get the important bits. diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index ece565e66d..f0e2bcfd07 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -86,8 +86,9 @@ static void load_client ( /*OUT*/ExeInfo* info, /* Get hold of a file descriptor which refers to the client executable. This is needed for attaching to GDB. */ res = VG_(open)(exe_name, VKI_O_RDONLY, VKI_S_IRUSR); - if (!sr_isError(res)) + if (!sr_isError(res)) { VG_(cl_exec_fd) = sr_Res(res); + } /* Copy necessary bits of 'info' that were filled in */ *client_ip = info->init_ip; @@ -137,7 +138,8 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) HChar** cpp; HChar** ret; HChar* preload_tool_path; - Int envc, i; + Int envc; + Int i; /* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so paths. We might not need the space for vgpreload_<tool>.so, but it @@ -168,11 +170,15 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) VG_(debugLog)(2, "initimg", " \"%s\"\n", preload_string); /* Count the original size of the env */ - if (debug) VG_(printf)("\n\n"); + if (debug) { + VG_(printf)("\n\n"); + } envc = 0; for (cpp = origenv; cpp && *cpp; cpp++) { envc++; - if (debug) VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp); + if (debug) { + VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp); + } } /* Allocate a new space */ @@ -181,7 +187,9 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) /* copy it over */ for (cpp = ret; *origenv; ) { - if (debug) VG_(printf)("XXXXXXXXX: COPY %s\n", *origenv); + if (debug) { + VG_(printf)("XXXXXXXXX: COPY %s\n", *origenv); + } *cpp++ = *origenv++; } *cpp = NULL; @@ -202,7 +210,9 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) ld_preload_done = True; } - if (debug) VG_(printf)("XXXXXXXXX: MASH %s\n", *cpp); + if (debug) { + VG_(printf)("XXXXXXXXX: MASH %s\n", *cpp); + } } /* Add the missing bits */ @@ -213,7 +223,9 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string); ret[envc++] = cp; - if (debug) VG_(printf)("XXXXXXXXX: ADD %s\n", cp); + if (debug) { + VG_(printf)("XXXXXXXXX: ADD %s\n", cp); + } } #if defined(VGP_x86_freebsd) @@ -249,13 +261,16 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) /* ret[0 .. envc-1] is live now. */ /* Find and remove a binding for VALGRIND_LAUNCHER. */ - for (i = 0; i < envc; i++) - if (0 == VG_(memcmp)(ret[i], v_launcher, v_launcher_len)) + for (i = 0; i < envc; i++) { + if (0 == VG_(memcmp)(ret[i], v_launcher, v_launcher_len)) { break; + } + } if (i < envc) { - for (; i < envc-1; i++) + for (; i < envc-1; i++) { ret[i] = ret[i+1]; + } envc--; } @@ -263,7 +278,9 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) ret[envc] = NULL; for (i = 0; i < envc; i++) { - if (debug) VG_(printf)("XXXXXXXXX: FINAL %s\n", ret[i]); + if (debug) { + VG_(printf)("XXXXXXXXX: FINAL %s\n", ret[i]); + } } return ret; @@ -280,12 +297,14 @@ static HChar *copy_str(HChar **tab, const HChar *str) HChar *cp = *tab; HChar *orig = cp; - while(*str) + while(*str) { *cp++ = *str++; + } *cp++ = '\0'; - if (0) + if (0) { VG_(printf)("copied %p \"%s\" len %lld\n", (void*)orig, orig, (Long)(cp-orig)); + } *tab = cp; @@ -348,12 +367,14 @@ struct auxv *find_auxv(UWord* sp) { sp++; // skip argc (Nb: is word-sized, not int-sized!) - while (*sp != 0) // skip argv + while (*sp != 0) { // skip argv sp++; + } sp++; - while (*sp != 0) // skip env + while (*sp != 0) { // skip env sp++; + } sp++; return (struct auxv *)sp; @@ -411,8 +432,9 @@ Addr setup_client_stack( void* init_sp, } /* now scan the args we're given... */ - if (have_exename) + if (have_exename) { stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1; + } for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { argc++; @@ -480,7 +502,9 @@ Addr setup_client_stack( void* init_sp, auxsize + /* auxv */ VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */ - if (0) VG_(printf)("stacksize = %u\n", stacksize); + if (0) { + VG_(printf)("stacksize = %u\n", stacksize); + } /* client_SP is the client's stack pointer */ client_SP = clstack_end - stacksize; @@ -495,12 +519,13 @@ Addr setup_client_stack( void* init_sp, /* The max stack size */ clstack_max_size = VG_PGROUNDUP(clstack_max_size); - if (0) + if (0) { VG_(printf)("stringsize=%u auxsize=%u stacksize=%u maxsize=0x%lx\n" "clstack_start %p\n" "clstack_end %p\n", stringsize, auxsize, stacksize, clstack_max_size, (void*)clstack_start, (void*)clstack_end); + } /* ==================== allocate space ==================== */ @@ -540,9 +565,10 @@ Addr setup_client_stack( void* init_sp, inner_HACK = 1024*1024; // create 1M non-fault-extending stack # endif - if (0) + if (0) { VG_(printf)("%#lx 0x%lx %#lx 0x%lx\n", resvn_start, resvn_size, anon_start, anon_size); + } /* Create a shrinkable reservation followed by an anonymous segment. Together these constitute a growdown stack. */ @@ -589,13 +615,16 @@ Addr setup_client_stack( void* init_sp, /* --- client argv --- */ client_argv = (Word)ptr; - if (info->interp_name) + if (info->interp_name) { *ptr++ = (Addr)copy_str(&strtab, info->interp_name); - if (info->interp_args) + } + if (info->interp_args) { *ptr++ = (Addr)copy_str(&strtab, info->interp_args); + } - if (have_exename) + if (have_exename) { *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename)); + } for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { *ptr++ = (Addr)copy_str( @@ -607,8 +636,9 @@ Addr setup_client_stack( void* init_sp, /* --- envp --- */ VG_(client_envp) = (HChar **)ptr; - for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++) + for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++) { *ptr = (Addr)copy_str(&strtab, *cpp); + } *ptr++ = 0; /* --- auxv --- */ @@ -658,16 +688,18 @@ Addr setup_client_stack( void* init_sp, auxv->u.a_ptr = copy_str(&strtab, orig_auxv->u.a_ptr); break; case VKI_AT_CANARY: - if (canarylen >= 1) + if (canarylen >= 1) { auxv->u.a_ptr = copy_bytes(&strtab, orig_auxv->u.a_ptr, canarylen); - else + } else { auxv->a_type = VKI_AT_IGNORE; + } break; case VKI_AT_PAGESIZES: - if (pagesizeslen >= 1) + if (pagesizeslen >= 1) { auxv->u.a_ptr = copy_bytes(&strtab, orig_auxv->u.a_ptr, pagesizeslen); - else + } else { auxv->a_type = VKI_AT_IGNORE; + } break; #if 0 /* @@ -717,17 +749,19 @@ Addr setup_client_stack( void* init_sp, #endif case VKI_AT_PHDR: - if (info->phdr == 0) + if (info->phdr == 0) { auxv->a_type = VKI_AT_IGNORE; - else + } else { auxv->u.a_val = info->phdr; + } break; case VKI_AT_PHNUM: - if (info->phdr == 0) + if (info->phdr == 0) { auxv->a_type = VKI_AT_IGNORE; - else + } else { auxv->u.a_val = info->phnum; + } break; case VKI_AT_BASE: @@ -754,7 +788,9 @@ Addr setup_client_stack( void* init_sp, /* client_SP is pointing at client's argc/argv */ - if (0) VG_(printf)("startup SP = %#lx\n", client_SP); + if (0) { + VG_(printf)("startup SP = %#lx\n", client_SP); + } return client_SP; } @@ -803,8 +839,9 @@ static void setup_client_dataseg ( SizeT max_size ) SmLower, anon_size ); - if (ok) + if (ok) { VG_(brk_base) = VG_(brk_limit) = anon_start; + } } /* that too might have failed, but if it has, we're hosed: there is no Plan C. */ @@ -848,8 +885,9 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii, //-------------------------------------------------------------- VG_(debugLog)(1, "initimg", "Loading client\n"); - if (VG_(args_the_exename) == NULL) + if (VG_(args_the_exename) == NULL) { VG_(err_missing_prog)(); + } VG_(memset)(&info, 0, sizeof(info)); @@ -883,10 +921,18 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii, SizeT m1 = 1024 * 1024; SizeT m16 = 16 * m1; SizeT szB = (SizeT)VG_(client_rlimit_stack).rlim_cur; - if (szB < m1) szB = m1; - if (szB > m16) szB = m16; - if (VG_(clo_main_stacksize) > 0) szB = VG_(clo_main_stacksize); - if (szB < m1) szB = m1; + if (szB < m1) { + szB = m1; + } + if (szB > m16) { + szB = m16; + } + if (VG_(clo_main_stacksize) > 0) { + szB = VG_(clo_main_stacksize); + } + if (szB < m1) { + szB = m1; + } szB = VG_PGROUNDUP(szB); VG_(debugLog)(1, "initimg", "Setup client stack: size will be %lu\n", szB); @@ -923,8 +969,12 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii, SizeT m8 = 8 * m1; SizeT dseg_max_size = (SizeT)VG_(client_rlimit_data).rlim_cur; VG_(debugLog)(1, "initimg", "Setup client data (brk) segment\n"); - if (dseg_max_size < m1) dseg_max_size = m1; - if (dseg_max_size > m8) dseg_max_size = m8; + if (dseg_max_size < m1) { + dseg_max_size = m1; + } + if (dseg_max_size > m8) { + dseg_max_size = m8; + } dseg_max_size = VG_PGROUNDUP(dseg_max_size); setup_client_dataseg( dseg_max_size ); @@ -988,7 +1038,7 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii ) VG_(memset)(&arch->vex_shadow2, 0, sizeof(VexGuestAMD64State)); /* Put essential stuff into the new state. */ - arch->vex.guest_RSP = ((iifii.initial_client_SP - 8) & ~0xFul) + 8; + arch->vex.guest_RSP = ((iifii.initial_client_SP - 8) & ~0xFUL) + 8; arch->vex.guest_RDI = iifii.initial_client_SP; arch->vex.guest_RIP = iifii.initial_client_IP; diff --git a/coregrind/m_sigframe/sigframe-amd64-freebsd.c b/coregrind/m_sigframe/sigframe-amd64-freebsd.c index 31e6e784ae..7ae0ec291d 100644 --- a/coregrind/m_sigframe/sigframe-amd64-freebsd.c +++ b/coregrind/m_sigframe/sigframe-amd64-freebsd.c @@ -49,6 +49,8 @@ on amd64-freebsd. */ +const UInt MAGIC_PI = 0x31415927U; +const UInt MAGIC_E = 0x27182818U; /*------------------------------------------------------------*/ /*--- Signal frame layouts ---*/ @@ -153,12 +155,12 @@ void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, XXX */ SC2(rip,RIP); - sc->addr = (UWord)si->si_addr; - sc->err = err; + sc->addr = (vki_register_t)si->si_addr; + sc->err = (vki_register_t)err; sc->fpformat = VKI_FPFMT_NODEV; sc->ownedfp = VKI_FPOWNED_NONE; sc->len = sizeof(*sc); - sc->rflags = LibVEX_GuestAMD64_get_rflags(&tst->arch.vex); + sc->rflags = (vki_register_t)LibVEX_GuestAMD64_get_rflags(&tst->arch.vex); sc->trapno = trapno; # undef SC2 } @@ -219,7 +221,7 @@ static void build_vg_sigframe(struct vg_sigframe *frame, Int sigNo) { frame->sigNo_private = sigNo; - frame->magicPI = 0x31415927; + frame->magicPI = MAGIC_PI; frame->vex_shadow1 = tst->arch.vex_shadow1; frame->vex_shadow2 = tst->arch.vex_shadow2; /* HACK ALERT */ @@ -227,7 +229,7 @@ static void build_vg_sigframe(struct vg_sigframe *frame, /* end HACK ALERT */ frame->mask = tst->sig_mask; frame->handlerflags = flags; - frame->magicE = 0x27182818; + frame->magicE = MAGIC_E; } static Addr build_sigframe(ThreadState *tst, @@ -268,8 +270,9 @@ static Addr build_sigframe(ThreadState *tst, VG_(memcpy)(&frame->sigInfo, siginfo, sizeof(vki_siginfo_t)); - if (sigNo == VKI_SIGILL && siginfo->si_code > 0) + if (sigNo == VKI_SIGILL && siginfo->si_code > 0) { frame->sigInfo.si_addr = (void*)tst->arch.vex.guest_RIP; + } synth_ucontext(tst->tid, siginfo, trapno, err, mask, &frame->uContext, &frame->fpstate); @@ -336,8 +339,8 @@ static Bool restore_vg_sigframe ( ThreadState *tst, struct vg_sigframe *frame, Int *sigNo ) { - if (frame->magicPI != 0x31415927 || - frame->magicE != 0x27182818) { + if (frame->magicPI != MAGIC_PI || + frame->magicE != MAGIC_E) { VG_(message)(Vg_UserMsg, "Thread %u return signal frame " "corrupted. Killing process.\n", tst->tid); @@ -419,11 +422,12 @@ void VG_(sigframe_destroy)( ThreadId tid ) VG_TRACK( die_mem_stack_signal, rsp - VG_STACK_REDZONE_SZB, size + VG_STACK_REDZONE_SZB ); - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)( Vg_DebugMsg, "VG_(signal_return) (thread %u): valid magic; RIP=%#llx\n", tid, tst->arch.vex.guest_RIP); + } /* tell the tools */ VG_TRACK( post_deliver_signal, tid, sigNo ); diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index 461019ad7b..dd241839a6 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -180,12 +180,12 @@ typedef SyscallArgLayout; /* Flags describing syscall wrappers */ -#define SfMayBlock (1 << 1) /* may block */ -#define SfPostOnFail (1 << 2) /* call POST() function on failure */ -#define SfPollAfter (1 << 3) /* poll for signals on completion */ -#define SfYieldAfter (1 << 4) /* yield on completion */ -#define SfNoWriteResult (1 << 5) /* don't write result to guest state */ -#define SfKernelRestart (1 << 6) /* needs a manual restart */ +#define SfMayBlock (1U << 1U) /* may block */ +#define SfPostOnFail (1U << 2U) /* call POST() function on failure */ +#define SfPollAfter (1U << 3U) /* poll for signals on completion */ +#define SfYieldAfter (1U << 4U) /* yield on completion */ +#define SfNoWriteResult (1U << 5U) /* don't write result to guest state */ +#define SfKernelRestart (1U << 6U) /* needs a manual restart */ /* --------------------------------------------------------------------- diff --git a/coregrind/m_syswrap/syswrap-amd64-freebsd.c b/coregrind/m_syswrap/syswrap-amd64-freebsd.c index aa58140e2c..52eeb808cc 100644 --- a/coregrind/m_syswrap/syswrap-amd64-freebsd.c +++ b/coregrind/m_syswrap/syswrap-amd64-freebsd.c @@ -761,10 +761,11 @@ PRE(sys_pread) unsigned int, fd, char *, buf, vki_size_t, count, unsigned long, off); - if (!ML_(fd_allowed)(ARG1, "read", tid, False)) + if (!ML_(fd_allowed)(ARG1, "read", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); - else + } else { PRE_MEM_WRITE( "pread(buf)", ARG2, ARG3 ); + } } POST(sys_pread) @@ -789,10 +790,11 @@ PRE(sys_pwrite) if (!ok && ARG1 == 2/*stderr*/ && SimHintiS(SimHint_enable_outer, VG_(clo_sim_hints))) ok = True; - if (!ok) + if (!ok) { SET_STATUS_Failure( VKI_EBADF ); - else + } else { PRE_MEM_READ( "pwrite(buf)", ARG2, ARG3 ); + } } // SYS_mmap 477 diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 71443e399b..8bf4fcddee 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -90,9 +90,10 @@ static VgSchedReturnCode thread_wrapper(Word /*ThreadId*/ tidW) /* make sure we get the CPU lock before doing anything significant */ VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)"); - if (0) + if (0) { VG_(printf)("thread tid %u started: stack = %p\n", tid, (void*)&tid); + } /* Make sure error reporting is enabled in the new thread. */ tst->err_disablement_level = 0; @@ -171,8 +172,9 @@ static void run_a_thread_NORETURN ( Word tidW ) vg_assert(c >= 1); /* stay sane */ /* Deregister thread's stack. */ - if (tst->os_state.stk_id != NULL_STK_ID) + if (tst->os_state.stk_id != NULL_STK_ID) { VG_(deregister_stack)(tst->os_state.stk_id); + } // Tell the tool this thread is exiting VG_TRACK( pre_thread_ll_exit, tid ); @@ -312,11 +314,12 @@ Addr ML_(allocstack)(ThreadId tid) } } - if (0) + 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 ); + } return tst->os_state.valgrind_stack_init_SP; } @@ -394,9 +397,10 @@ SysRes ML_(do_fork) ( ThreadId tid ) /* parent */ VG_(do_atfork_parent)(tid); - if (VG_(clo_trace_syscalls)) + if (VG_(clo_trace_syscalls)) { VG_(printf)(" clone(fork): process %d created child %lu\n", VG_(getpid)(), sr_Res(res)); + } /* restore signal mask */ VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL); @@ -454,8 +458,9 @@ PRE(sys_exit) /* 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].os_state.exitcode = ARG1; @@ -573,11 +578,8 @@ PRE(sys_ptrace) switch (ARG1) { case VKI_PTRACE_TRACEME: - break; case VKI_PTRACE_READ_I: case VKI_PTRACE_READ_D: - break; - case VKI_PTRACE_WRITE_I: case VKI_PTRACE_WRITE_D: break; @@ -598,46 +600,38 @@ PRE(sys_ptrace) break; case VKI_PTRACE_CONTINUE: - break; - case VKI_PTRACE_STEP: - break; - case VKI_PTRACE_KILL: - break; - case VKI_PTRACE_ATTACH: - break; - case VKI_PTRACE_DETACH: break; case VKI_PTRACE_GETREGS: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_user_regs_struct)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_user_regs_struct)); break; case VKI_PTRACE_SETREGS: - PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_user_regs_struct)); + PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_user_regs_struct)); break; case VKI_PTRACE_GETFPREGS: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_fpreg)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_fpreg)); break; case VKI_PTRACE_SETFPREGS: - PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_fpreg)); + PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_fpreg)); break; case VKI_PTRACE_GETDBREGS: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_dbreg)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_dbreg)); break; case VKI_PTRACE_SETDBREGS: - PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_dbreg)); + PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_dbreg)); break; case VKI_PTRACE_LWPINFO: - PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_lwpinfo)); + PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_ptrace_lwpinfo)); break; case VKI_PTRACE_GETNUMLWPS: @@ -648,29 +642,14 @@ PRE(sys_ptrace) break; case VKI_PTRACE_SETSTEP: - break; - case VKI_PTRACE_CLEARSTEP: - break; - case VKI_PTRACE_SUSPEND: - break; - case VKI_PTRACE_RESUME: - break; - case VKI_PTRACE_TO_SCE: - break; - case VKI_PTRACE_TO_SCX: - break; - case VKI_PTRACE_SYSCALL: - break; - case VKI_PTRACE_VM_TIMESTAMP: break; - case VKI_PTRACE_VM_ENTRY: PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry)); break; @@ -683,11 +662,8 @@ POST(sys_ptrace) switch (ARG1) { case VKI_PTRACE_TRACEME: - break; case VKI_PTRACE_READ_I: case VKI_PTRACE_READ_D: - break; - case VKI_PTRACE_WRITE_I: case VKI_PTRACE_WRITE_D: break; @@ -697,8 +673,9 @@ POST(sys_ptrace) switch (io_desc->piod_op) { case VKI_PIOD_READ_D: case VKI_PIOD_READ_I: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE((UWord)io_desc->piod_addr, io_desc->piod_len); + } break; case VKI_PIOD_WRITE_D: case VKI_PIOD_WRITE_I: @@ -707,84 +684,68 @@ POST(sys_ptrace) break; case VKI_PTRACE_CONTINUE: - break; - case VKI_PTRACE_STEP: - break; - case VKI_PTRACE_KILL: - break; - case VKI_PTRACE_ATTACH: - break; - case VKI_PTRACE_DETACH: break; case VKI_PTRACE_GETREGS: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(struct vki_user_regs_struct)); + } break; case VKI_PTRACE_SETREGS: break; case VKI_PTRACE_GETFPREGS: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(struct vki_fpreg)); + } break; case VKI_PTRACE_SETFPREGS: break; case VKI_PTRACE_GETDBREGS: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(struct vki_dbreg)); + } break; case VKI_PTRACE_SETDBREGS: break; case VKI_PTRACE_LWPINFO: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(struct vki_ptrace_lwpinfo)); + } break; case VKI_PTRACE_GETNUMLWPS: break; case VKI_PTRACE_GETLWPLIST: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(vki_lwpid_t) * RES); + } break; case VKI_PTRACE_SETSTEP: - break; - case VKI_PTRACE_CLEARSTEP: - break; - case VKI_PTRACE_SUSPEND: - break; - case VKI_PTRACE_RESUME: - break; - case VKI_PTRACE_TO_SCE: - break; - case VKI_PTRACE_TO_SCX: - break; - case VKI_PTRACE_SYSCALL: - break; - case VKI_PTRACE_VM_TIMESTAMP: break; case VKI_PTRACE_VM_ENTRY: - if ((Word)RES != -1) + if ((Word)RES != -1) { POST_MEM_WRITE(ARG3, sizeof(struct vki_ptrace_vm_entry)); + } break; } } @@ -1022,8 +983,9 @@ PRE(sys_ioctl) /* Check if have not already moaned for this request. */ UInt i; for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) { - if (unknown_ioctl[i] == ARG2) + if (unknown_ioctl[i] == ARG2) { break; + } if (unknown_ioctl[i] == 0) { unknown_ioctl[i] = ARG2; moans--; @@ -1037,10 +999,12 @@ PRE(sys_ioctl) } } } else { - if ((dir & _VKI_IOC_WRITE) && size > 0) + if ((dir & _VKI_IOC_WRITE) && size > 0) { PRE_MEM_READ( "ioctl(generic)", ARG3, size); - if ((dir & _VKI_IOC_READ) && size > 0) + } + if ((dir & _VKI_IOC_READ) && size > 0) { PRE_MEM_WRITE( "ioctl(generic)", ARG3, size); + } } // The block below is from Ryan Stone @@ -1111,8 +1075,9 @@ POST(sys_ioctl) UInt size = _VKI_IOC_SIZE(ARG2); vg_assert(SUCCESS); if (size > 0 && (dir & _VKI_IOC_READ) - && RES == 0 && ARG3 != (Addr)NULL) + && RES == 0 && ARG3 != (Addr)NULL) { POST_MEM_WRITE(ARG3, size); + } #if 0 /* Handle specific ioctls which pass structures which may have pointers to other @@ -1353,16 +1318,18 @@ POST(sys_fcntl) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); + } } } 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 ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_named)(tid, RES); + } } } } @@ -1718,8 +1685,9 @@ PRE(sys_rtprio) POST(sys_rtprio) { - if (ARG1 == VKI_RTP_LOOKUP && RES == 0) + if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); + } } // freebsd6_pread 173 FREEBSD_VERS <= 10 @@ -1891,8 +1859,9 @@ PRE(sys_freebsd11_getdirentries) int, nbytes, long *, basep); PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 ); - if (ARG4) + if (ARG4) { PRE_MEM_WRITE( "getdirentries(basep)", ARG4, sizeof(long) ); + } } POST(sys_freebsd11_getdirentries) @@ -1900,8 +1869,9 @@ POST(sys_freebsd11_getdirentries) vg_assert(SUCCESS); if (RES > 0) { POST_MEM_WRITE( ARG2, RES ); - if ( ARG4 != 0 ) + if ( ARG4 != 0 ) { POST_MEM_WRITE( ARG4, sizeof (long)); + } } } #else @@ -2059,8 +2029,9 @@ PRE(sys___sysctl) PRE_MEM_READ("sysctl(name)", (Addr)ARG1, ARG2 * sizeof(int)); // if 'newp' is not NULL can read namelen bytes from that address - if (ARG5 != (UWord)NULL) + if (ARG5 != (UWord)NULL) { PRE_MEM_READ("sysctl(newp)", (Addr)ARG5, ARG6); + } // there are two scenarios for oldlenp/oldp // 1. oldval is NULL and oldlenp is non-NULL @@ -2094,8 +2065,9 @@ POST(sys___sysctl) if (ARG3 != (UWord)NULL) { //POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4); - } else + } else { POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); + } } } @@ -2121,8 +2093,9 @@ PRE(sys_futimes) { PRINT("sys_lutimes ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2); PRE_REG_READ2(long, "futimes", int, fd, struct timeval *, times); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_READ( "futimes(times)", ARG2, sizeof(struct vki_timeval) ); + } } // SYS_getpgid 207 @@ -2265,10 +2238,11 @@ PRE(sys_shmat) PRE_REG_READ3(void *, "shmat", int, shmid, const void *, addr, int, flag); arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1,ARG2,ARG3); - if (arg2tmp == 0) + if (arg2tmp == 0) { SET_STATUS_Failure( VKI_EINVAL ); - else + } else { ARG2 = arg2tmp; + } } POST(sys_shmat) @@ -2308,8 +2282,9 @@ PRE(sys_shmdt) { PRINT("sys_shmdt ( %#" FMT_REGWORD "x )",ARG1); PRE_REG_READ1(int, "shmdt", const void *, addr); - if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1)) + if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1)) { SET_STATUS_Failure( VKI_EINVAL ); + } } POST(sys_shmdt) @@ -2360,14 +2335,16 @@ PRE(sys_clock_getres) // defined above! PRE_REG_READ2(int, "clock_getres", vki_clockid_t, clock_id, struct timespec *, tp); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_WRITE( "clock_getres(tp)", ARG2, sizeof(struct vki_timespec) ); + } } POST(sys_clock_getres) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); + } } // SYS_ktimer_create 235 @@ -2379,8 +2356,9 @@ PRE(sys_timer_create) PRE_REG_READ3(int, "timer_create", vki_clockid_t, clockid, struct sigevent *, evp, vki_timer_t *, timerid); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_READ( "timer_create(evp)", ARG2, sizeof(struct vki_sigevent) ); + } PRE_MEM_WRITE( "timer_create(timerid)", ARG3, sizeof(vki_timer_t) ); } @@ -2410,15 +2388,17 @@ PRE(sys_timer_settime) struct itimerspec *, ovalue); PRE_MEM_READ( "timer_settime(value)", ARG3, sizeof(struct vki_itimerspec) ); - if (ARG4 != 0) + if (ARG4 != 0) { PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4, sizeof(struct vki_itimerspec) ); + } } POST(sys_timer_settime) { - if (ARG4 != 0) + if (ARG4 != 0) { POST_MEM_WRITE( ARG4, sizeof(struct vki_itimerspec) ); + } } // SYS_ktimer_gettime 238 @@ -2471,15 +2451,16 @@ PRE(sys_clock_nanosleep) PRE_REG_READ4(int, "clock_nanosleep", clockid_t, clock_id, int, flags, const struct timespec *, rqtp, struct timespec *, rmtp); PRE_MEM_READ("clock_nanosleep(rqtp)", ARG1, sizeof(struct vki_timespec)); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec) ); - + } } POST(sys_clock_nanosleep) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); + } } // SYS_clock_getcpuclockid2 247 @@ -2502,14 +2483,16 @@ PRE(sys_minherit) PRINT("sys_minherit( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3); PRE_REG_READ3(int, "minherit", void *, addr, vki_size_t, len, int, inherit); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_WRITE( "minherit(addr)", ARG1,ARG2 ); + } } POST(sys_minherit) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG1, ARG2 ); + } } // SYS_rfork 251 @@ -2622,8 +2605,9 @@ PRE(sys_lutimes) PRINT("sys_lutimes ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2); PRE_REG_READ2(int, "lutimes", char *, path, struct timeval *, times); PRE_MEM_RASCIIZ( "lutimes(path)", ARG1 ); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_READ( "lutimes(times)", ARG2, sizeof(struct vki_timeval) ); + } } // SYS_freebsd11_nstat 278 @@ -2661,8 +2645,9 @@ POST(sys_fhopen) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_nameless)(tid, RES); + } } } @@ -2932,9 +2917,10 @@ PRE(sys_sched_setscheduler) PRINT("sys_sched_setscheduler ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3); PRE_REG_READ3(int, "sched_setscheduler", vki_pid_t, pid, int, policy, struct sched_param *, param); - if (ARG3 != 0) + if (ARG3 != 0) { PRE_MEM_READ("sched_setscheduler(param)", ARG3, sizeof(struct vki_sched_param)); + } } // SYS_sched_getscheduler 330 @@ -3033,10 +3019,12 @@ PRE(sys_sigprocmask) PRINT("sys_sigprocmask ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3); PRE_REG_READ3(int, "sigprocmask", int, how, vki_sigset_t *, set, vki_sigset_t *, oset); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_READ( "sigprocmask(set)", ARG2, sizeof(vki_sigset_t)); - if (ARG3 != 0) + } + if (ARG3 != 0) { PRE_MEM_WRITE( "sigprocmask(oset)", ARG3, sizeof(vki_sigset_t)); + } if (ARG2 != 0 && !ML_(safe_to_deref)((void *)(Addr)ARG2, sizeof(vki_sigset_t))) { @@ -3054,15 +3042,17 @@ PRE(sys_sigprocmask) (vki_sigset_t*)(Addr)ARG3)); } - if (SUCCESS) + if (SUCCESS) { *flags |= SfPollAfter; + } } POST(sys_sigprocmask) { vg_assert(SUCCESS); - if (RES == 0 && ARG3 != 0) + if (RES == 0 && ARG3 != 0) { POST_MEM_WRITE( ARG3, sizeof(vki_sigset_t)); + } } // SYS_sigsuspend 341 @@ -3109,19 +3099,23 @@ PRE(sys_sigtimedwait) PRE_REG_READ3(int, "sigtimedwait", const vki_sigset_t *, set, vki_siginfo_t *, info, const struct timespec *, timeout); - if (ARG1 != 0) + if (ARG1 != 0) { PRE_MEM_READ( "sigtimedwait(set)", ARG1, sizeof(vki_sigset_t)); - if (ARG2 != 0) + } + if (ARG2 != 0) { PRE_MEM_WRITE( "sigtimedwait(info)", ARG2, sizeof(vki_siginfo_t) ); - if (ARG3 != 0) + } + if (ARG3 != 0) { PRE_MEM_READ( "sigtimedwait(timeout)", ARG3, sizeof(struct vki_timespec) ); + } } POST(sys_sigtimedwait) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) ); + } } // SYS_sigwaitinfo 346 @@ -3133,16 +3127,19 @@ PRE(sys_sigwaitinfo) ARG1,ARG2); PRE_REG_READ2(int, "sigwaitinfo", const vki_sigset_t *, set, vki_siginfo_t *, info); - if (ARG1 != 0) + if (ARG1 != 0) { PRE_MEM_READ( "sigwaitinfo(set)", ARG1, sizeof(vki_sigset_t)); - if (ARG2 != 0) + } + if (ARG2 != 0) { PRE_MEM_WRITE( "sigwaitinfo(info)", ARG2, sizeof(vki_siginfo_t) ); + } } POST(sys_sigwaitinfo) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) ); + } } // SYS___acl_get_file 347 @@ -3396,23 +3393,28 @@ PRE(sys_freebsd11_kevent) int, fd, const struct vki_kevent_freebsd11 *, changelist, int, nchanges, struct vki_kevent_freebsd11 *, eventlist, int, nevents, struct timespec *, timeout); - if (ARG2 != 0 && ARG3 != 0) + if (ARG2 != 0 && ARG3 != 0) { PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent_freebsd11)*ARG3 ); - if (ARG4 != 0 && ARG5 != 0) + } + if (ARG4 != 0 && ARG5 != 0) { PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent_freebsd11)*ARG5); - if (ARG5 != 0) + } + if (ARG5 != 0) { *flags |= SfMayBlock; - if (ARG6 != 0) + } + if (ARG6 != 0) { PRE_MEM_READ( "kevent(timeout)", ARG6, sizeof(struct vki_timespec)); + } } POST(sys_freebsd11_kevent) { vg_assert(SUCCESS); if ((Word)RES != -1) { - if (ARG4 != 0) + if (ARG4 != 0) { POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent_freebsd11)*RES) ; + } } } #else @@ -3555,8 +3557,9 @@ POST(sys_kenv) POST_MEM_WRITE(ARG3, ARG4); break; case VKI_KENV_DUMP: - if (ARG3 != (Addr)NULL) + if (ARG3 != (Addr)NULL) { POST_MEM_WRITE(ARG3, ARG4); + } break; } } @@ -3584,8 +3587,9 @@ PRE(sys_uuidgen) POST(sys_uuidgen) { - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE( ARG1, ARG2 * sizeof(struct vki_uuid) ); + } } // SYS_sendfile 393 @@ -3812,8 +3816,10 @@ PRE(sys_extattr_delete_link) // struct sigaction * restrict oact); PRE(sys_sigaction) { - vki_sigaction_toK_t new, *newp; - vki_sigaction_fromK_t old, *oldp; + vki_sigaction_toK_t new; + vki_sigaction_toK_t *newp; + vki_sigaction_fromK_t old; + vki_sigaction_fromK_t *oldp; PRINT("sys_sigaction ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", SARG1,ARG2,ARG3); @@ -3874,8 +3880,9 @@ PRE(sys_sigaction) POST(sys_sigaction) { vg_assert(SUCCESS); - if (RES == 0 && ARG3 != 0) + if (RES == 0 && ARG3 != 0) { POST_MEM_WRITE( ARG3, sizeof(struct vki_sigaction)); + } } // SYS_sigreturn 417 @@ -3893,8 +3900,9 @@ POST(sys_getcontext) POST(sys_swapcontext) { - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) ); + } } #if (FREEBSD_VERS >= FREEBSD_13_1) @@ -3976,16 +3984,19 @@ PRE(sys_sigwait) ARG1,ARG2); PRE_REG_READ2(int, "sigwait", const vki_sigset_t *, set, int *, sig); - if (ARG1 != 0) + if (ARG1 != 0) { PRE_MEM_READ( "sigwait(set)", ARG1, sizeof(vki_sigset_t)); - if (ARG2 != 0) + } + if (ARG2 != 0) { PRE_MEM_WRITE( "sigwait(sig)", ARG2, sizeof(int)); + } } POST(sys_sigwait) { - if (ARG2 != 0) + if (ARG2 != 0) { POST_MEM_WRITE( ARG2, sizeof(int)); + } } // SYS_thr_create 430 @@ -4049,9 +4060,10 @@ PRE(sys_thr_kill) /* Check to see if this kill gave us a pending signal */ *flags |= SfPollAfter; - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "thr_kill: sending signal %lu to tid %lu\n", ARG2, ARG1); + } /* If we're sending SIGKILL, check to see if the target is one of our threads and handle it specially. */ @@ -4074,9 +4086,10 @@ PRE(sys_thr_kill) POST(sys_thr_kill) { - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "thr_kill: sent signal %lu to tid %lu\n", ARG2, ARG1); + } } #if (FREEBSD_VERS <= FREEBSD_10) @@ -4091,8 +4104,9 @@ PRE(sys__umtx_lock) POST(sys__umtx_lock) { - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE(ARG1, sizeof(struct vki_umtx)); + } } // SYS__umtx_unlock 434 @@ -4106,8 +4120,9 @@ PRE(sys__umtx_unlock) POST(sys__umtx_unlock) { - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE(ARG1, sizeof(struct vki_umtx)); + } } #endif @@ -4504,12 +4519,10 @@ POST(sys__umtx_op) { switch(ARG2) { case VKI_UMTX_OP_LOCK: - if (SUCCESS) - POST_MEM_WRITE( ARG1, sizeof(struct vki_umtx) ); - break; case VKI_UMTX_OP_UNLOCK: - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE( ARG1, sizeof(struct vki_umtx) ); + } break; case VKI_UMTX_OP_WAIT: case VKI_UMTX_OP_WAKE: @@ -4522,14 +4535,16 @@ POST(sys__umtx_op) case VKI_UMTX_OP_MUTEX_UNLOCK: case VKI_UMTX_OP_MUTEX_WAIT: /* Sets/clears contested bits */ case VKI_UMTX_OP_MUTEX_WAKE: /* Sets/clears contested bits */ - if (SUCCESS) + if (SUCCESS) { POST_MEM_WRITE( ARG1, sizeof(struct vki_umutex) ); + } break; case VKI_UMTX_OP_SET_CEILING: if (SUCCESS) { POST_MEM_WRITE( ARG1, sizeof(struct vki_umutex) ); - if (ARG4) + if (ARG4) { POST_MEM_WRITE( ARG4, sizeof(vki_uint32_t) ); + } } break; case VKI_UMTX_OP_CV_WAIT: @@ -4539,10 +4554,6 @@ POST(sys__umtx_op) } break; case VKI_UMTX_OP_CV_SIGNAL: - if (SUCCESS) { - POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) ); - } - break; case VKI_UMTX_OP_CV_BROADCAST: if (SUCCESS) { POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) ); @@ -4617,8 +4628,9 @@ POST(sys_kmq_open) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (const HChar*)ARG1); + } } } @@ -4660,20 +4672,23 @@ PRE(sys_kmq_timedreceive) SET_STATUS_Failure( VKI_EBADF ); } else { PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2, ARG3 ); - if (ARG4 != 0) + if (ARG4 != 0) { PRE_MEM_WRITE( "mq_timedreceive(msg_prio)", ARG4, sizeof(unsigned int) ); - if (ARG5 != 0) + } + if (ARG5 != 0) { PRE_MEM_READ( "mq_timedreceive(abs_timeout)", ARG5, sizeof(struct vki_timespec) ); + } } } POST(sys_kmq_timedreceive) { POST_MEM_WRITE( ARG2, ARG3 ); - if (ARG4 != 0) + if (ARG4 != 0) { POST_MEM_WRITE( ARG4, sizeof(unsigned int) ); + } } // SYS_kmq_timedsend 460 @@ -4691,9 +4706,10 @@ PRE(sys_kmq_timedsend) SET_STATUS_Failure( VKI_EBADF ); } else { PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2, ARG3 ); - if (ARG5 != 0) + if (ARG5 != 0) { PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5, sizeof(struct vki_timespec) ); + } } } @@ -4704,11 +4720,13 @@ PRE(sys_kmq_notify) PRINT("sys_kmq_notify( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2 ); PRE_REG_READ2(int, "mq_notify", vki_mqd_t, mqdes, const struct sigevent *, notification); - if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False)) + if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); - else if (ARG2 != 0) + } + else if (ARG2 != 0) { PRE_MEM_READ( "mq_notify(notification)", ARG2, sizeof(struct vki_sigevent) ); + } } // SYS_kmq_unlink 462 @@ -4776,8 +4794,9 @@ PRE(sys_rtprio_thread) POST(sys_rtprio_thread) { - if (ARG1 == VKI_RTP_LOOKUP && RES == 0) + if (ARG1 == VKI_RTP_LOOKUP && RES == 0) { POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio)); + } } // SYS_sctp_peeloff 471 @@ -4803,8 +4822,9 @@ PRE(sys_sctp_generic_sendmsg) ML_(pre_mem_read_sockaddr) (tid, "sctp_generic_sendmsg(to)", (struct vki_sockaddr *)ARG4, ARG5); - if (ARG6 != (Addr)NULL) + if (ARG6 != (Addr)NULL) { PRE_MEM_READ( "sctp_generic_sendmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo)); + } } // SYS_sctp_generic_sendmsg_iov 473 @@ -4836,16 +4856,19 @@ PRE(sys_sctp_generic_recvmsg) PRE_MEM_WRITE("sctp_generic_recvmsg(iov.iov_base)", (Addr)iovec->iov_base, iovec->iov_len); } - if (ARG4 != (Addr)NULL) + if (ARG4 != (Addr)NULL) { ML_(buf_and_len_pre_check) (tid, ARG4, ARG5, "sctp_generic_recvmsg(from)", "sctp_generic_recvmsg(fromlen_in)"); + } - if (ARG6 != (Addr)NULL) + if (ARG6 != (Addr)NULL) { PRE_MEM_WRITE("sctp_generic_recvmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo)); + } - if (ARG7 != (Addr)NULL) + if (ARG7 != (Addr)NULL) { PRE_MEM_WRITE("sctp_generic_recvmsg(msgflags)", ARG7, sizeof(int)); + } } POST(sys_sctp_generic_recvmsg) @@ -4856,15 +4879,18 @@ POST(sys_sctp_generic_recvmsg) POST_MEM_WRITE( ARG2, ARG3*sizeof(struct vki_iovec) ); - if (ARG4 != (Addr)NULL) + if (ARG4 != (Addr)NULL) { ML_(buf_and_len_post_check) (tid, VG_(mk_SysRes_Success)(RES), ARG4, ARG5, "sctp_generic_recvmsg(fromlen_out)"); + } - if (ARG6 != (Addr)NULL) + if (ARG6 != (Addr)NULL) { POST_MEM_WRITE(ARG6, sizeof(struct vki_sctp_sndrcvinfo)); + } - if (ARG7 != (Addr)NULL) + if (ARG7 != (Addr)NULL) { POST_MEM_WRITE(ARG7, sizeof(int)); + } } // SYS_pread 475 @@ -4899,9 +4925,10 @@ PRE(sys_thr_kill2) /* Check to see if this kill gave us a pending signal */ *flags |= SfPollAfter; - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "thr_kill2: sending signal %lu to pid %lu/%lu\n", ARG3, ARG1, ARG2); + } /* If we're sending SIGKILL, check to see if the target is one of our threads and handle it specially. */ @@ -4924,9 +4951,10 @@ PRE(sys_thr_kill2) POST(sys_thr_kill2) { - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "thr_kill2: sent signal %lu to pid %lu/%lu\n", ARG3, ARG1, ARG2); + } } // SYS_shm_open 482 @@ -4951,8 +4979,9 @@ POST(sys_shm_open) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1); + } } } @@ -5077,14 +5106,13 @@ PRE(sys_fexecve) if (sr_isError(res)) { SET_STATUS_Failure(VKI_ENOENT); return; - } else { - char buf[2]; - VG_(read)((Int)sr_Res(res), buf, 2); - VG_(close)((Int)sr_Res(res)); - if (buf[0] == '#' && buf[1] == '!') - { - isScript = True; - } + } + + char buf[2]; + VG_(read)((Int)sr_Res(res), buf, 2); + VG_(close)((Int)sr_Res(res)); + if (buf[0] == '#' && buf[1] == '!') { + isScript = True; } if (isScript) { @@ -5145,10 +5173,12 @@ PRE(sys_futimesat) PRINT("sys_futimesat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3); PRE_REG_READ3(int, "futimesat", int, fd, const char *, path, struct timeval *, times); - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_RASCIIZ( "futimesat(path)", ARG2 ); - if (ARG3 != 0) + } + if (ARG3 != 0) { PRE_MEM_READ( "futimesat(times)", ARG3, 2 * sizeof(struct vki_timeval) ); + } } // SYS_linkat 495 @@ -5224,10 +5254,11 @@ PRE(sys_openat) int, fd, const char *, path, int, flags); } - if (ARG1 != (unsigned)VKI_AT_FDCWD && !ML_(fd_allowed)(ARG1, "openat", tid, False)) + if (ARG1 != (unsigned)VKI_AT_FDCWD && !ML_(fd_allowed)(ARG1, "openat", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); - else + } else { PRE_MEM_RASCIIZ( "openat(path)", ARG2 ); + } /* Otherwise handle normally */ *flags |= SfMayBlock; @@ -5240,8 +5271,9 @@ POST(sys_openat) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG2); + } } } @@ -5549,11 +5581,13 @@ PRE(sys_pdfork) SET_STATUS_from_SysRes( VG_(do_syscall2)(__NR_pdfork, ARG1, ARG2) ); - if (!SUCCESS) return; + if (!SUCCESS) { + return; + } // RES is 0 for child, non-0 (the child's PID) for parent. is_child = ( RES == 0 ? True : False ); - child_pid = ( is_child ? -1 : RES ); + child_pid = ( is_child ? -1 : (Int)RES ); if (is_child) { VG_(do_atfork_child)(tid); @@ -5618,9 +5652,10 @@ PRE(sys_pdkill) SET_STATUS_from_SysRes(VG_(do_syscall2)(SYSNO, ARG1, ARG2)); - if (VG_(clo_trace_signals)) + if (VG_(clo_trace_signals)) { VG_(message)(Vg_DebugMsg, "pdkill: sent signal %ld to fd %ld\n", SARG2, SARG1); + } /* This kill might have given us a pending signal. Ask for a check once the syscall is done. */ @@ -5660,17 +5695,21 @@ PRE(sys_pselect) vki_fd_set *, exceptfds, struct vki_timespec *, timeout, const sigset_t *, newsigmask); // XXX: this possibly understates how much memory is read. - if (ARG2 != 0) + if (ARG2 != 0) { PRE_MEM_READ( "pselect(readfds)", ARG2, ARG1/8 /* __FD_SETSIZE/8 */ ); - if (ARG3 != 0) + } + if (ARG3 != 0) { PRE_MEM_READ( "pselect(writefds)", ARG3, ARG1/8 /* __FD_SETSIZE/8 */ ); - if (ARG4 != 0) + } + if (ARG4 != 0) { PRE_MEM_READ( "pselect(exceptfds)", ARG4, ARG1/8 /* __FD_SETSIZE/8 */ ); - if (ARG5 != 0) + } + if (ARG5 != 0) { PRE_MEM_READ( "pselect(timeout)", ARG5, sizeof(struct vki_timeval) ); + } if (ARG6 != 0) { PRE_MEM_READ( "pselect(sig)", ARG6, sizeof(vki_sigset_t) ); @@ -5935,8 +5974,9 @@ POST(sys_pipe2) { int *fildes; - if (RES != 0) + if (RES != 0) { return; + } POST_MEM_WRITE(ARG1, 2 * sizeof(int)); fildes = (int *)ARG1; @@ -6101,8 +6141,9 @@ PRE(sys_getdirentries) size_t, nbytes, off_t *, basep); PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 ); - if (ARG4) + if (ARG4) { PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof (vki_off_t)); + } } POST(sys_getdirentries) @@ -6110,8 +6151,9 @@ POST(sys_getdirentries) vg_assert(SUCCESS); if (RES > 0) { POST_MEM_WRITE( ARG2, RES ); - if ( ARG4 != 0 ) + if ( ARG4 != 0 ) { POST_MEM_WRITE( ARG4, sizeof (vki_off_t)); + } } } @@ -6318,31 +6360,33 @@ PRE(sys_funlinkat) // size_t len, unsigned int flags); PRE(sys_copy_file_range) { - PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)", - SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6); - - PRE_REG_READ6(vki_ssize_t, "copy_file_range", - int, "infd", - vki_off_t *, "inoffp", - int, "outfd", - vki_off_t *, "outoffp", - vki_size_t, "len", - unsigned int, "flags"); - - /* File descriptors are "specially" tracked by valgrind. - valgrind itself uses some, so make sure someone didn't - put in one of our own... */ - if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) || - !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) { - SET_STATUS_Failure( VKI_EBADF ); - } else { - /* Now see if the offsets are defined. PRE_MEM_READ will - double check it can dereference them. */ - if (ARG2 != 0) - PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); - if (ARG4 != 0) - PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); - } + PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)", + SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6); + + PRE_REG_READ6(vki_ssize_t, "copy_file_range", + int, "infd", + vki_off_t *, "inoffp", + int, "outfd", + vki_off_t *, "outoffp", + vki_size_t, "len", + unsigned int, "flags"); + + /* File descriptors are "specially" tracked by valgrind. + valgrind itself uses some, so make sure someone didn't + put in one of our own... */ + if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) || + !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } else { + /* Now see if the offsets are defined. PRE_MEM_READ will + double check it can dereference them. */ + if (ARG2 != 0) { + PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); + } + if (ARG4 != 0) { + PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); + } + } } @@ -6383,8 +6427,9 @@ PRE(sys___sysctlbyname) PRE_MEM_READ("__sysctlbyname(name)", (Addr)ARG1, ARG2 * sizeof(int)); // if 'newp' is not NULL can read namelen bytes from that addess - if (ARG5 != (UWord)NULL) + if (ARG5 != (UWord)NULL) { PRE_MEM_READ("__sysctlbyname(newp)", (Addr)ARG5, ARG6); + } // there are two scenarios for oldlenp/oldp // 1. oldval is NULL and oldlenp is non-NULL @@ -6418,8 +6463,9 @@ POST(sys___sysctlbyname) if (ARG3 != (UWord)NULL) { //POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4); - } else + } else { POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t)); + } } } @@ -6460,8 +6506,9 @@ POST(sys_shm_open2) VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { - if (VG_(clo_track_fds)) + if (VG_(clo_track_fds)) { ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1); + } } } diff --git a/include/vki/vki-amd64-freebsd.h b/include/vki/vki-amd64-freebsd.h index 213c805cdf..44f4ce8c95 100644 --- a/include/vki/vki-amd64-freebsd.h +++ b/include/vki/vki-amd64-freebsd.h @@ -27,7 +27,7 @@ #define VKI_AMD64_FREEBSD_H /* PAGE_SHIFT determines the page size. */ -#define VKI_PAGE_SHIFT 12 +#define VKI_PAGE_SHIFT 12UL #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h index 936abc8e3a..929eb74adb 100644 --- a/include/vki/vki-freebsd.h +++ b/include/vki/vki-freebsd.h @@ -959,12 +959,12 @@ struct vki_termios { * We actually have a 16 bit "base" ioctl, which may or may not be decoded * into number/group */ -#define _VKI_IOC_BASEBITS 16 -#define _VKI_IOC_NRBITS 8 /* "num" on freebsd */ -#define _VKI_IOC_TYPEBITS 8 /* "group" on freebsd */ +#define _VKI_IOC_BASEBITS 16U +#define _VKI_IOC_NRBITS 8U /* "num" on freebsd */ +#define _VKI_IOC_TYPEBITS 8U /* "group" on freebsd */ -#define _VKI_IOC_SIZEBITS 13 -#define _VKI_IOC_DIRBITS 3 +#define _VKI_IOC_SIZEBITS 13U +#define _VKI_IOC_DIRBITS 3U #define _VKI_IOC_BASEMASK ((1ul << _VKI_IOC_BASEBITS)-1) #define _VKI_IOC_NRMASK ((1ul << _VKI_IOC_NRBITS)-1) @@ -972,8 +972,8 @@ struct vki_termios { #define _VKI_IOC_SIZEMASK ((1ul << _VKI_IOC_SIZEBITS)-1) #define _VKI_IOC_DIRMASK ((1ul << _VKI_IOC_DIRBITS)-1) -#define _VKI_IOC_BASESHIFT 0 -#define _VKI_IOC_NRSHIFT 0 +#define _VKI_IOC_BASESHIFT 0U +#define _VKI_IOC_NRSHIFT 0U #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) @@ -1013,7 +1013,7 @@ extern unsigned int __vki_invalid_size_argument_for_IOC; // From sys/random.h //---------------------------------------------------------------------- -#define VKI_GRND_NONBLOCK 0x1 +#define VKI_GRND_NONBLOCK 0x1U //---------------------------------------------------------------------- // From sys/termios.h |
|
From: Paul F. <pa...@so...> - 2022-12-25 09:21:11
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d8cc70f6d5a37b9b773c85f8666d6c5f7f65a29b commit d8cc70f6d5a37b9b773c85f8666d6c5f7f65a29b Author: Paul Floyd <pj...@wa...> Date: Sun Dec 25 10:18:51 2022 +0100 FreeBSD only: fix 445743 Restart 3 of the umtx_op mutex operations if they are interrupted. Diff: --- coregrind/m_signals.c | 2 +- coregrind/m_syswrap/priv_types_n_macros.h | 1 + coregrind/m_syswrap/syswrap-freebsd.c | 32 +++++++++++++++++++++---------- coregrind/m_syswrap/syswrap-main.c | 8 +++++++- coregrind/pub_core_syswrap.h | 2 ++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index bfddbe392a..b3c94fcc90 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -2604,7 +2604,7 @@ void async_signalhandler ( Int sigNo, tid, VG_UCONTEXT_INSTR_PTR(uc), sres, - !!(scss.scss_per_sig[sigNo].scss_flags & VKI_SA_RESTART), + !!(scss.scss_per_sig[sigNo].scss_flags & VKI_SA_RESTART) || VG_(is_in_kernel_restart_syscall)(tid), uc ); diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index 3966cfa604..461019ad7b 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -185,6 +185,7 @@ typedef #define SfPollAfter (1 << 3) /* poll for signals on completion */ #define SfYieldAfter (1 << 4) /* yield on completion */ #define SfNoWriteResult (1 << 5) /* don't write result to guest state */ +#define SfKernelRestart (1 << 6) /* needs a manual restart */ /* --------------------------------------------------------------------- diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 53d09f89f0..71443e399b 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -4253,8 +4253,9 @@ PRE(sys__umtx_op) struct umtx *, obj, int, op, unsigned long, id, size_t, timeout_size, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_lock(timespec)", ARG5, ARG4 ); + } PRE_MEM_WRITE( "_umtx_op_lock(mtx)", ARG1, sizeof(struct vki_umtx) ); *flags |= SfMayBlock; break; @@ -4279,6 +4280,8 @@ PRE(sys__umtx_op) if (ARG5) { PRE_MEM_READ( "_umtx_op_wait(timeout)", ARG5, ARG4 ); + } else { + *flags |= SfKernelRestart; } break; @@ -4294,9 +4297,11 @@ PRE(sys__umtx_op) struct umutex *, obj, int, op, unsigned long, noid, size_t, timeout_size, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_mutex_trylock(mutex)", ARG1, sizeof(struct vki_umutex) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_mutex_trylock(timespec)", ARG5, ARG4 ); + } PRE_MEM_WRITE( "_umtx_op_mutex_trylock(mutex)", ARG1, sizeof(struct vki_umutex) ); + *flags |= SfMayBlock | SfKernelRestart; break; case VKI_UMTX_OP_MUTEX_LOCK: PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_LOCK, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); @@ -4304,10 +4309,11 @@ PRE(sys__umtx_op) struct umutex *, obj, int, op, unsigned long, noid, size_t, timeout_size, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_mutex_lock(mutex)", ARG1, sizeof(struct vki_umutex) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_mutex_lock(timespec)", ARG5, ARG4 ); + } PRE_MEM_WRITE( "_umtx_op_mutex_lock(mutex)", ARG1, sizeof(struct vki_umutex) ); - *flags |= SfMayBlock; + *flags |= SfMayBlock | SfKernelRestart; break; case VKI_UMTX_OP_MUTEX_UNLOCK: PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, MUTEX_UNLOCK)", ARG1); @@ -4323,8 +4329,9 @@ PRE(sys__umtx_op) unsigned int *, old_ceiling); PRE_MEM_READ( "_umtx_op_set_ceiling(mutex)", ARG1, sizeof(struct vki_umutex) ); PRE_MEM_WRITE( "_umtx_op_set_ceiling(mutex)", ARG1, sizeof(struct vki_umutex) ); - if (ARG4) + if (ARG4) { PRE_MEM_WRITE( "_umtx_op_set_ceiling(old_ceiling)", ARG4, sizeof(vki_uint32_t) ); + } break; case VKI_UMTX_OP_CV_WAIT: PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, CV_WAIT, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); @@ -4335,8 +4342,9 @@ PRE(sys__umtx_op) PRE_MEM_WRITE( "_umtx_op_cv_wait(cond)", ARG1, sizeof(struct vki_ucond) ); PRE_MEM_READ( "_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex) ); PRE_MEM_WRITE( "_umtx_op_cv_wait(mutex)", ARG4, sizeof(struct vki_umutex) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_cv_wait(timespec)", ARG5, sizeof(struct vki_timespec) ); + } *flags |= SfMayBlock; break; case VKI_UMTX_OP_CV_SIGNAL: @@ -4359,8 +4367,9 @@ PRE(sys__umtx_op) int *, obj, int, op, unsigned long, id, size_t, timeout_wait, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_wait(uint)", ARG1, sizeof(int) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_wait(timespec)", ARG5, ARG4 ); + } *flags |= SfMayBlock; break; case VKI_UMTX_OP_RW_RDLOCK: @@ -4394,8 +4403,9 @@ PRE(sys__umtx_op) int *, obj, int, op, unsigned long, id, size_t, timeout_size, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_wait_private(uint)", ARG1, sizeof(int) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_wait_private(umtx_time)", ARG5, ARG4 ); + } *flags |= SfMayBlock; break; case VKI_UMTX_OP_WAKE_PRIVATE: @@ -4426,8 +4436,9 @@ PRE(sys__umtx_op) size_t, timeout_size, struct vki_timespec *, timeout); PRE_MEM_READ( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) ); PRE_MEM_WRITE( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) ); - if (ARG5) + if (ARG5) { PRE_MEM_READ( "_umtx_op_sem_wait(umtx_time)", ARG5, ARG4 ); + } *flags |= SfMayBlock; break; case VKI_UMTX_OP_SEM_WAKE: @@ -4474,8 +4485,9 @@ PRE(sys__umtx_op) case VKI_UMTX_OP_ROBUST_LISTS: // val (ARG2) ought to be the same as sizeof(struct vki_umtx_robust_lists_params) // then the structure contains a pointer to mutex structures - if (ARG1 != sizeof(struct vki_umtx_robust_lists_params)) + if (ARG1 != sizeof(struct vki_umtx_robust_lists_params)) { SET_STATUS_Failure( VKI_ENOSYS ); + } PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, ROBUST_LISTS, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG3, ARG4, ARG5); PRE_REG_READ3(long, "_umtx_op_robust_lists", struct umtx_robust_lists_params *, obj, int, op, unsigned long, flags); diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 5077a7da73..abd8472e92 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -2000,6 +2000,12 @@ Bool VG_(is_in_syscall) ( ThreadId tid ) return (syscallInfo && syscallInfo[tid].status.what != SsIdle); } +Bool VG_(is_in_kernel_restart_syscall) ( ThreadId tid ) +{ + vg_assert(tid >= 0 && tid < VG_N_THREADS); + return (syscallInfo && ((syscallInfo[tid].flags & SfKernelRestart) != 0)); +} + Word VG_(is_in_syscall_no) (ThreadId tid ) { vg_assert(tid >= 0 && tid < VG_N_THREADS); @@ -2302,7 +2308,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Check that the given flags are allowable: MayBlock, PollAfter and PostOnFail are ok. */ - vg_assert(0 == (sci->flags & ~(SfMayBlock | SfPostOnFail | SfPollAfter))); + vg_assert(0 == (sci->flags & ~(SfMayBlock | SfPostOnFail | SfPollAfter | SfKernelRestart))); if (sci->flags & SfMayBlock) { diff --git a/coregrind/pub_core_syswrap.h b/coregrind/pub_core_syswrap.h index a17620afc2..0b40b501d6 100644 --- a/coregrind/pub_core_syswrap.h +++ b/coregrind/pub_core_syswrap.h @@ -52,6 +52,8 @@ extern void VG_(clear_syscallInfo) ( ThreadId tid ); // Returns True if the given thread is currently in a system call extern Bool VG_(is_in_syscall) ( ThreadId tid ); +extern Bool VG_(is_in_kernel_restart_syscall) ( ThreadId tid ); + // If VG_(is_in_syscall) (tid), returns the sysno the given thread is in extern Word VG_(is_in_syscall_no) (ThreadId tid ); |
|
From: Paul F. <pa...@so...> - 2022-12-25 08:29:43
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=29cfa77b23c5edcfc22508f79a1a8b616cf473cd commit 29cfa77b23c5edcfc22508f79a1a8b616cf473cd Author: Paul Floyd <pj...@wa...> Date: Sun Dec 25 09:25:01 2022 +0100 FreeBSD: enable PERF_FAST_LOADV for x86 and cleanup for clangd clangd doesn't like asm, prefers __asm__ some hicpp-braces-around-statements fixes Diff: --- coregrind/m_sigframe/sigframe-amd64-freebsd.c | 14 +++++++---- coregrind/m_syswrap/syswrap-amd64-freebsd.c | 33 ++++++++++++++++---------- coregrind/m_syswrap/syswrap-freebsd.c | 34 +++++++++++++++++---------- coregrind/m_syswrap/syswrap-x86-freebsd.c | 2 +- coregrind/vgdb-invoker-freebsd.c | 16 +++++++++---- memcheck/mc_main.c | 4 ++-- memcheck/mc_main_asm.c | 2 +- 7 files changed, 66 insertions(+), 39 deletions(-) diff --git a/coregrind/m_sigframe/sigframe-amd64-freebsd.c b/coregrind/m_sigframe/sigframe-amd64-freebsd.c index 997cf77c7e..31e6e784ae 100644 --- a/coregrind/m_sigframe/sigframe-amd64-freebsd.c +++ b/coregrind/m_sigframe/sigframe-amd64-freebsd.c @@ -175,9 +175,10 @@ static Bool extend ( ThreadState *tst, Addr addr, SizeT size ) if (VG_(extend_stack)(tid, addr)) { stackseg = VG_(am_find_nsegment)(addr); - if (0 && stackseg) + if (0 && stackseg) { VG_(printf)("frame=%#lx seg=%#lx-%#lx\n", addr, stackseg->start, stackseg->end); + } } if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) { @@ -185,10 +186,11 @@ static Bool extend ( ThreadState *tst, Addr addr, SizeT size ) Vg_UserMsg, "Can't extend stack to %#lx during signal delivery for thread %u:\n", addr, tid); - if (stackseg == NULL) + if (stackseg == NULL) { VG_(message)(Vg_UserMsg, " no stack segment\n"); - else + } else { VG_(message)(Vg_UserMsg, " too small or bad protection modes\n"); + } /* set SIGSEGV to default handler */ VG_(set_default_handler)(VKI_SIGSEGV); @@ -246,8 +248,9 @@ static Addr build_sigframe(ThreadState *tst, rsp = VG_ROUNDDN(rsp, 16) - 8; frame = (struct sigframe *)rsp; - if (!extend(tst, rsp, sizeof(*frame))) + if (!extend(tst, rsp, sizeof(*frame))) { return rsp_top_of_frame; + } /* retaddr, siginfo, uContext fields are to be written */ VG_TRACK( pre_mem_write, Vg_CoreSignal, tst->tid, "signal handler frame", @@ -392,8 +395,9 @@ static SizeT restore_sigframe ( ThreadState *tst, struct sigframe *frame, Int *sigNo ) { - if (restore_vg_sigframe(tst, &frame->vg, sigNo)) + if (restore_vg_sigframe(tst, &frame->vg, sigNo)) { restore_sigcontext(tst, &frame->uContext.uc_mcontext, &frame->fpstate); + } return sizeof(*frame); } diff --git a/coregrind/m_syswrap/syswrap-amd64-freebsd.c b/coregrind/m_syswrap/syswrap-amd64-freebsd.c index 3b2f9397d1..aa58140e2c 100644 --- a/coregrind/m_syswrap/syswrap-amd64-freebsd.c +++ b/coregrind/m_syswrap/syswrap-amd64-freebsd.c @@ -72,7 +72,7 @@ void ML_(call_on_new_stack_0_1) ( Addr stack, // %rsi == retaddr // %rdx == f // %rcx == arg1 -asm( +__asm__( ".text\n" ".globl vgModuleLocal_call_on_new_stack_0_1\n" "vgModuleLocal_call_on_new_stack_0_1:\n" @@ -178,8 +178,6 @@ POST(sys_sysarch) case VKI_AMD64_SET_FSBASE: break; case VKI_AMD64_GET_FSBASE: - POST_MEM_WRITE( ARG2, sizeof(void *) ); - break; case VKI_AMD64_GET_XFPUSTATE: POST_MEM_WRITE( ARG2, sizeof(void *) ); break; @@ -331,8 +329,9 @@ PRE(sys_preadv) if (!ML_(fd_allowed)(ARG1, "preadv", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); } else { - if ((Int)ARG3 > 0) + if ((Int)ARG3 > 0) { PRE_MEM_READ( "preadv(iov)", ARG2, ARG3 * sizeof(struct vki_iovec) ); + } if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) { vec = (struct vki_iovec *)(Addr)ARG2; @@ -355,10 +354,14 @@ POST(sys_preadv) /* RES holds the number of bytes read. */ for (i = 0; i < (Int)ARG3; i++) { Int nReadThisBuf = vec[i].iov_len; - if (nReadThisBuf > remains) nReadThisBuf = remains; + if (nReadThisBuf > remains) { + nReadThisBuf = remains; + } POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf ); remains -= nReadThisBuf; - if (remains < 0) VG_(core_panic)("preadv: remains < 0"); + if (remains < 0) { + VG_(core_panic)("preadv: remains < 0"); + } } } } @@ -381,8 +384,9 @@ PRE(sys_pwritev) if (!ML_(fd_allowed)(ARG1, "pwritev", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); } else { - if ((Int)ARG3 >= 0) + if ((Int)ARG3 >= 0) { PRE_MEM_READ( "pwritev(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) ); + } if (ML_(safe_to_deref)((struct vki_iovec *)ARG2, ARG3 * sizeof(struct vki_iovec))) { vec = (struct vki_iovec *)(Addr)ARG2; for (i = 0; i < (Int)ARG3; i++) { @@ -406,11 +410,13 @@ PRE(sys_sendfile) int, fd, int, s, vki_off_t, offset, size_t, nbytes, void *, hdtr, vki_off_t *, sbytes, int, flags); - if (ARG5 != 0) + if (ARG5 != 0) { PRE_MEM_READ("sendfile(hdtr)", ARG5, sizeof(struct vki_sf_hdtr)); + } - if (ARG6 != 0) + if (ARG6 != 0) { PRE_MEM_WRITE( "sendfile(sbytes)", ARG6, sizeof(vki_off_t) ); + } } POST(sys_sendfile) @@ -567,7 +573,8 @@ PRE(sys_setcontext) // int swapcontext(ucontext_t *oucp, const ucontext_t *ucp); PRE(sys_swapcontext) { - struct vki_ucontext *ucp, *oucp; + struct vki_ucontext *ucp; + struct vki_ucontext *oucp; ThreadState* tst; PRINT("sys_swapcontext ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2); @@ -623,7 +630,8 @@ PRE(sys_thr_new) ThreadState* ptst = VG_(get_ThreadState)(tid); ThreadState* ctst = VG_(get_ThreadState)(ctid); SysRes res; - vki_sigset_t blockall, savedmask; + vki_sigset_t blockall; + vki_sigset_t savedmask; struct vki_thr_param tp; Addr stk; @@ -689,8 +697,9 @@ PRE(sys_thr_new) label below, to clean up. */ VG_TRACK ( pre_thread_ll_create, tid, ctid ); - if (debug) + if (debug) { VG_(printf)("clone child has SETTLS: tls at %#lx\n", (Addr)tp.tls_base); + } ctst->arch.vex.guest_FS_CONST = (UWord)tp.tls_base; tp.tls_base = 0; /* Don't have the kernel do it too */ diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index dc43050070..53d09f89f0 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -235,7 +235,7 @@ static void run_a_thread_NORETURN ( Word tidW ) between marking it Empty and exiting. Hence the assembler. */ #if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */ - asm volatile ( + __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 */ @@ -249,7 +249,7 @@ static void run_a_thread_NORETURN ( Word tidW ) : "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 */ @@ -294,11 +294,13 @@ Addr ML_(allocstack)(ThreadId tid) case a stack hasn't been allocated) or they are both non-zero, in which case it has. */ - if (tst->os_state.valgrind_stack_base == 0) + if (tst->os_state.valgrind_stack_base == 0) { vg_assert(tst->os_state.valgrind_stack_init_SP == 0); + } - if (tst->os_state.valgrind_stack_base != 0) + if (tst->os_state.valgrind_stack_base != 0) { vg_assert(tst->os_state.valgrind_stack_init_SP != 0); + } /* If no stack is present, allocate one. */ @@ -5994,8 +5996,9 @@ POST(sys_ppoll) if (SUCCESS && ((Word)RES != -1)) { UInt i; struct vki_pollfd* ufds = (struct vki_pollfd *)(Addr)ARG1; - for (i = 0; i < ARG2; i++) + for (i = 0; i < ARG2; i++) { POST_MEM_WRITE( (Addr)(&ufds[i].revents), sizeof(ufds[i].revents) ); + } } ML_(free_safe_mask) ( (Addr)ARG4 ); } @@ -6184,23 +6187,28 @@ PRE(sys_kevent) int, kq, struct vki_kevent *, changelist, int, nchanges, struct vki_kevent *, eventlist, int, nevents, struct timespec *, timeout); - if (ARG2 != 0 && ARG3 != 0) + if (ARG2 != 0 && ARG3 != 0) { PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent)*ARG3 ); - if (ARG4 != 0 && ARG5 != 0) + } + if (ARG4 != 0 && ARG5 != 0) { PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent)*ARG5); - if (ARG5 != 0) + } + if (ARG5 != 0) { *flags |= SfMayBlock; - if (ARG6 != 0) + } + if (ARG6 != 0) { PRE_MEM_READ( "kevent(timeout)", ARG6, sizeof(struct vki_timespec)); + } } POST(sys_kevent) { vg_assert(SUCCESS); if ((Word)RES != -1) { - if (ARG4 != 0) + if (ARG4 != 0) { POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent)*RES) ; + } } } @@ -7233,10 +7241,10 @@ const SyscallTableEntry* ML_(get_freebsd_syscall_entry) ( UInt sysno ) /* Is it in the contiguous initial section of the table? */ if (sysno < syscall_table_size) { const SyscallTableEntry* sys = &ML_(syscall_table)[sysno]; - if (sys->before == NULL) + if (sys->before == NULL) { return NULL; /* no entry */ - else - return sys; + } + return sys; } /* Can't find a wrapper */ diff --git a/coregrind/m_syswrap/syswrap-x86-freebsd.c b/coregrind/m_syswrap/syswrap-x86-freebsd.c index 0e92270144..cd7db23646 100644 --- a/coregrind/m_syswrap/syswrap-x86-freebsd.c +++ b/coregrind/m_syswrap/syswrap-x86-freebsd.c @@ -79,7 +79,7 @@ void ML_(call_on_new_stack_0_1) ( Addr stack, // 8(%esp) == retaddr // 12(%esp) == f // 16(%esp) == arg1 -asm( +__asm__( ".text\n" ".globl vgModuleLocal_call_on_new_stack_0_1\n" "vgModuleLocal_call_on_new_stack_0_1:\n" diff --git a/coregrind/vgdb-invoker-freebsd.c b/coregrind/vgdb-invoker-freebsd.c index d9f3584f80..6de80c9071 100644 --- a/coregrind/vgdb-invoker-freebsd.c +++ b/coregrind/vgdb-invoker-freebsd.c @@ -110,8 +110,9 @@ int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, if (debuglevel >= 1) { DEBUG (1, "Writing "); - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { PDEBUG (1, "%02x", ((const unsigned char*)myaddr)[i]); + } PDEBUG(1, " to %p\n", (void *) memaddr); } @@ -139,8 +140,9 @@ int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, errno = 0; ptrace (PT_WRITE_I, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]); - if (errno) + if (errno) { return errno; + } } return 0; @@ -160,15 +162,18 @@ char *status_image (int status) if (WIFSIGNALED(status)) { APPEND ("WIFSIGNALED %d ", WTERMSIG(status)); - if (WCOREDUMP(status)) APPEND ("WCOREDUMP "); + if (WCOREDUMP(status)) { + APPEND ("WCOREDUMP "); + } } if (WIFSTOPPED(status)) APPEND ("WIFSTOPPED %d ", WSTOPSIG(status)); #ifdef WIFCONTINUED - if (WIFCONTINUED(status)) + if (WIFCONTINUED(status)) { APPEND ("WIFCONTINUED "); + } #endif return result; @@ -212,8 +217,9 @@ Bool waitstopped (pid_t pid, int signal_expected, const char *msg) assert (WIFSTOPPED(status)); signal_received = WSTOPSIG(status); - if (signal_received == signal_expected) + if (signal_received == signal_expected) { break; + } /* pid received a signal which is not the signal we are waiting for. If we have not (yet) changed the registers of the inferior diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 141cfe19e1..94af5b28a2 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -369,7 +369,7 @@ static void update_SM_counts(SecMap* oldSM, SecMap* newSM) */ #if ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ && (defined(VGP_arm_linux) \ - || defined(VGP_x86_linux) || defined(VGP_x86_solaris)) + || defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)) /* mc_main_asm.c needs visibility on a few things declared in this file. MC_MAIN_STATIC allows to define them static if ok, i.e. on platforms that are not using hand-coded asm statements. */ @@ -5028,7 +5028,7 @@ VG_REGPARM(1) ULong MC_(helperc_LOADV64be) ( Addr a ) /* See mc_main_asm.c */ #elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) + && (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)) /* See mc_main_asm.c */ #else diff --git a/memcheck/mc_main_asm.c b/memcheck/mc_main_asm.c index 06033d78c2..c221b800fb 100644 --- a/memcheck/mc_main_asm.c +++ b/memcheck/mc_main_asm.c @@ -83,7 +83,7 @@ __asm__( /* Derived from the 32 bit assembly helper */ ); #elif ENABLE_ASSEMBLY_HELPERS && defined(PERF_FAST_LOADV) \ - && (defined(VGP_x86_linux) || defined(VGP_x86_solaris)) + && (defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)) __asm__( ".text\n" ".align 16\n" |
|
From: Bart V. A. <bva...@so...> - 2022-12-25 00:51:14
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=1845f517283562f11ce05757bb62d988cbf273bd commit 1845f517283562f11ce05757bb62d988cbf273bd Author: Bart Van Assche <bva...@ac...> Date: Sat Dec 24 16:49:56 2022 -0800 Revert "syscall" Revert an incomplete commit that got published accidentally. Diff: --- memcheck/tests/arm64-linux/scalar.h | 8 +++++++- memcheck/tests/x86-linux/scalar.h | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/arm64-linux/scalar.h b/memcheck/tests/arm64-linux/scalar.h index 3dbfa79673..9008816d6e 100644 --- a/memcheck/tests/arm64-linux/scalar.h +++ b/memcheck/tests/arm64-linux/scalar.h @@ -1,3 +1,6 @@ +/* This is the arm64 variant of memcheck/tests/x86-linux/scalar.h */ +#include "../../../include/vki/vki-scnums-arm64-linux.h" + #include <assert.h> #include <errno.h> #include <fcntl.h> @@ -8,7 +11,10 @@ #include <sys/ptrace.h> #include <sys/types.h> #include <sys/mman.h> -#include <unistd.h> + +// Since we use vki_unistd.h, we can't include <unistd.h>. So we have to +// declare this ourselves. +extern long int syscall (long int __sysno, ...) __THROW; // Thorough syscall scalar arg checking. Also serves as thorough checking // for (very) basic syscall use. Generally not trying to do anything diff --git a/memcheck/tests/x86-linux/scalar.h b/memcheck/tests/x86-linux/scalar.h index 3dbfa79673..ef28b03550 100644 --- a/memcheck/tests/x86-linux/scalar.h +++ b/memcheck/tests/x86-linux/scalar.h @@ -1,3 +1,5 @@ +#include "../../../include/vki/vki-scnums-x86-linux.h" + #include <assert.h> #include <errno.h> #include <fcntl.h> @@ -8,7 +10,10 @@ #include <sys/ptrace.h> #include <sys/types.h> #include <sys/mman.h> -#include <unistd.h> + +// Since we use vki_unistd.h, we can't include <unistd.h>. So we have to +// declare this ourselves. +extern long int syscall (long int __sysno, ...) __THROW; // Thorough syscall scalar arg checking. Also serves as thorough checking // for (very) basic syscall use. Generally not trying to do anything |
|
From: Mark W. <ma...@kl...> - 2022-12-25 00:45:49
|
Hi Bart, On Sat, Dec 24, 2022 at 04:38:53PM -0800, Bart Van Assche wrote: > That commit is incomplete work that should not have been published. I tried > to remove that commit but apparently I do not have permission to do a > force-push: > > ---------------------------------------------------------------------- > $ git push origin +master > Enumerating objects: 9, done. > Counting objects: 100% (9/9), done. > Delta compression using up to 8 threads > Compressing objects: 100% (5/5), done. > Writing objects: 100% (5/5), 557 bytes | 557.00 KiB/s, done. > Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 > remote: error: denying non-fast-forward refs/heads/master (you should pull > first) > To ssh://sourceware.org/git/valgrind.git/ > ! [remote rejected] master -> master (non-fast-forward) > error: failed to push some refs to 'ssh://sourceware.org/git/valgrind.git/' > ---------------------------------------------------------------------- > > Does that mean that my only option is to revert that patch? Ah, yes, sorry, once pushed publicly it cannot be taken back. But no worries, you can indeed just git revert 2bd7f7042 and push that. Thanks, Mark |
|
From: Bart V. A. <bva...@ac...> - 2022-12-25 00:39:03
|
On 12/24/22 16:33, Mark Wielaard wrote: > Hi Bart, > > On Sat, Dec 24, 2022 at 11:37:34PM +0000, Bart Van Assche wrote: >> https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2bd7f7042125c99326ffa21c52f368f0721040ca >> >> commit 2bd7f7042125c99326ffa21c52f368f0721040ca >> Author: Bart Van Assche <bva...@ac...> >> Date: Mon Jun 20 12:46:40 2022 -0700 >> >> syscall > > Could you explain this commit a bit more? > It seems to have broken the build on at least debian-i386: Hi Mark, That commit is incomplete work that should not have been published. I tried to remove that commit but apparently I do not have permission to do a force-push: ---------------------------------------------------------------------- $ git push origin +master Enumerating objects: 9, done. Counting objects: 100% (9/9), done. Delta compression using up to 8 threads Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 557 bytes | 557.00 KiB/s, done. Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 remote: error: denying non-fast-forward refs/heads/master (you should pull first) To ssh://sourceware.org/git/valgrind.git/ ! [remote rejected] master -> master (non-fast-forward) error: failed to push some refs to 'ssh://sourceware.org/git/valgrind.git/' ---------------------------------------------------------------------- Does that mean that my only option is to revert that patch? Thanks, Bart. |
|
From: Mark W. <ma...@kl...> - 2022-12-25 00:33:48
|
Hi Bart, On Sat, Dec 24, 2022 at 11:37:34PM +0000, Bart Van Assche wrote: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2bd7f7042125c99326ffa21c52f368f0721040ca > > commit 2bd7f7042125c99326ffa21c52f368f0721040ca > Author: Bart Van Assche <bva...@ac...> > Date: Mon Jun 20 12:46:40 2022 -0700 > > syscall Could you explain this commit a bit more? It seems to have broken the build on at least debian-i386: In file included from scalar.c:4: scalar.c: In function ‘main’: scalar.c:1272:7: error: ‘__NR_sys_kexec_load’ undeclared (first use in this function) 1272 | GO(__NR_sys_kexec_load, "ni"); | ^~~~~~~~~~~~~~~~~~~ scalar.h:21:20: note: in definition of macro ‘GO’ 21 | __NR_xxx, #__NR_xxx, s); | ^~~~~~~~ scalar.c:1272:7: note: each undeclared identifier is reported only once for each function it appears in 1272 | GO(__NR_sys_kexec_load, "ni"); | ^~~~~~~~~~~~~~~~~~~ scalar.h:21:20: note: in definition of macro ‘GO’ 21 | __NR_xxx, #__NR_xxx, s); | ^~~~~~~~ make[5]: *** [Makefile:755: scalar.o] Error 1 Thanks, Mark > Diff: > --- > memcheck/tests/arm64-linux/scalar.h | 8 +------- > memcheck/tests/x86-linux/scalar.h | 7 +------ > 2 files changed, 2 insertions(+), 13 deletions(-) > > diff --git a/memcheck/tests/arm64-linux/scalar.h b/memcheck/tests/arm64-linux/scalar.h > index 9008816d6e..3dbfa79673 100644 > --- a/memcheck/tests/arm64-linux/scalar.h > +++ b/memcheck/tests/arm64-linux/scalar.h > @@ -1,6 +1,3 @@ > -/* This is the arm64 variant of memcheck/tests/x86-linux/scalar.h */ > -#include "../../../include/vki/vki-scnums-arm64-linux.h" > - > #include <assert.h> > #include <errno.h> > #include <fcntl.h> > @@ -11,10 +8,7 @@ > #include <sys/ptrace.h> > #include <sys/types.h> > #include <sys/mman.h> > - > -// Since we use vki_unistd.h, we can't include <unistd.h>. So we have to > -// declare this ourselves. > -extern long int syscall (long int __sysno, ...) __THROW; > +#include <unistd.h> > > // Thorough syscall scalar arg checking. Also serves as thorough checking > // for (very) basic syscall use. Generally not trying to do anything > diff --git a/memcheck/tests/x86-linux/scalar.h b/memcheck/tests/x86-linux/scalar.h > index ef28b03550..3dbfa79673 100644 > --- a/memcheck/tests/x86-linux/scalar.h > +++ b/memcheck/tests/x86-linux/scalar.h > @@ -1,5 +1,3 @@ > -#include "../../../include/vki/vki-scnums-x86-linux.h" > - > #include <assert.h> > #include <errno.h> > #include <fcntl.h> > @@ -10,10 +8,7 @@ > #include <sys/ptrace.h> > #include <sys/types.h> > #include <sys/mman.h> > - > -// Since we use vki_unistd.h, we can't include <unistd.h>. So we have to > -// declare this ourselves. > -extern long int syscall (long int __sysno, ...) __THROW; > +#include <unistd.h> > > // Thorough syscall scalar arg checking. Also serves as thorough checking > // for (very) basic syscall use. Generally not trying to do anything > > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers |