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
(13) |
2
(33) |
3
(25) |
4
(22) |
5
(22) |
6
(21) |
7
(19) |
|
8
(29) |
9
(34) |
10
(29) |
11
(37) |
12
(36) |
13
(28) |
14
(25) |
|
15
(28) |
16
(23) |
17
(36) |
18
(21) |
19
(12) |
20
(14) |
21
(10) |
|
22
(7) |
23
(15) |
24
(41) |
25
(15) |
26
(9) |
27
(7) |
28
(6) |
|
29
(16) |
30
(24) |
31
(22) |
|
|
|
|
|
From: <sv...@va...> - 2005-05-30 23:52:52
|
Author: sewardj
Date: 2005-05-31 00:52:47 +0100 (Tue, 31 May 2005)
New Revision: 3818
Modified:
trunk/coregrind/m_debuglog.c
trunk/coregrind/m_syscalls/syscalls.c
trunk/coregrind/pub_core_debuglog.h
trunk/coregrind/vg_main.c
Log:
debug-logging (-d) totally didn't work when one Valgrindified process
exec's another. This commit fixes it.
Modified: trunk/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuglog.c 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/m_debuglog.c 2005-05-30 23:52:47 UTC (rev 3818)
@@ -449,8 +449,8 @@
=20
static Int loglevel =3D 0;
=20
+/* Module startup. */
/* EXPORTED */
-/* Module startup. */
void VG_(debugLog_startup) ( Int level, HChar* who )
{
if (level < 0) level =3D 0;
@@ -462,6 +462,16 @@
who, loglevel);
}
=20
+/* Get the logging threshold level, as set by the most recent call to
+ VG_(debugLog_startup), or zero if there have been no such calls so
+ far. */
+/* EXPORTED */
+Int VG_(debugLog_getLevel) ( void )
+{
+ return loglevel;
+}
+
+
/* ------------ */
=20
typedef=20
Modified: trunk/coregrind/m_syscalls/syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:20:51 UTC (rev 38=
17)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:52:47 UTC (rev 38=
18)
@@ -29,6 +29,7 @@
*/
=20
#include "core.h"
+#include "pub_core_debuglog.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_stacktrace.h"
#include "pub_core_syscalls.h"
@@ -964,10 +965,17 @@
}
return False;
}
- else if (soft && fd >=3D VG_(fd_soft_limit)) {
+ else=20
+ if (soft && fd >=3D VG_(fd_soft_limit)) {
return False;
}
- return True;
+ else=20
+ if (fd =3D=3D 2 && VG_(debugLog_getLevel)() > 0) {
+ return False;
+ }=20
+ else {
+ return True;
+ }
}
=20
=20
@@ -2369,6 +2377,8 @@
path =3D VG_(build_child_exename)();
}
=20
+ VG_(debugLog)(1, "syscalls", "Exec of %s\n", (HChar*)ARG1);
+
if (0) {
Char **cpp;
=20
Modified: trunk/coregrind/pub_core_debuglog.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_debuglog.h 2005-05-30 23:20:51 UTC (rev 3817=
)
+++ trunk/coregrind/pub_core_debuglog.h 2005-05-30 23:52:47 UTC (rev 3818=
)
@@ -58,6 +58,14 @@
extern=20
void VG_(debugLog_startup) ( Int level, HChar* who );
=20
+
+/* Get the logging threshold level, as set by the most recent call to
+ VG_(debugLog_startup), or zero if there have been no such calls so
+ far. */
+extern
+Int VG_(debugLog_getLevel) ( void );
+
+
/* Send debugging output. Nothing happens unless 'level'=20
does not exceed the logging threshold level. */
extern
@@ -65,6 +73,7 @@
void VG_(debugLog) ( Int level, const HChar* modulename,
const HChar* format, ... );
=20
+
/* A simple vprintf(). For each emitted byte, (*send) is called with
that byte, and 'send_arg2' as its second param. */
extern
Modified: trunk/coregrind/vg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_main.c 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/vg_main.c 2005-05-30 23:52:47 UTC (rev 3818)
@@ -2480,17 +2480,17 @@
"-d"s were specified. This is a pre-scan of the command line. */
loglevel =3D 0;
for (i =3D 1; i < argc; i++) {
- if (argv[i][0] !=3D '-')
- break;
- if (0 =3D=3D local_strcmp(argv[i], "--"))=20
- break;
- if (0 =3D=3D local_strcmp(argv[i], "-d"))=20
- loglevel++;
+ if (argv[i][0] !=3D '-')
+ break;
+ if (0 =3D=3D local_strcmp(argv[i], "--"))=20
+ break;
+ if (0 =3D=3D local_strcmp(argv[i], "-d"))=20
+ loglevel++;
}
=20
/* ... and start the debug logger. Now we can safely emit logging
messages all through startup. */
- VG_(debugLog_startup)(loglevel, "Stage 2");
+ VG_(debugLog_startup)(loglevel, "Stage 2 (main)");
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// Command line argument handling order:
@@ -2540,6 +2540,22 @@
get_command_line(argc, argv, &vg_argc, &vg_argv, &cl_argv);
pre_process_cmd_line_options(&need_help, &tool, &exec);
=20
+ /* If this process was created by exec done by another Valgrind
+ process, the arguments will only show up at this point. Hence
+ we need to also snoop around in vg_argv to see if anyone is
+ asking for debug logging. */
+ if (loglevel =3D=3D 0) {
+ for (i =3D 1; i < vg_argc; i++) {
+ if (vg_argv[i][0] !=3D '-')
+ break;
+ if (0 =3D=3D local_strcmp(vg_argv[i], "--"))=20
+ break;
+ if (0 =3D=3D local_strcmp(vg_argv[i], "-d"))=20
+ loglevel++;
+ }
+ VG_(debugLog_startup)(loglevel, "Stage 2 (second go)");
+ }
+
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// Nb: once a tool is specified, the tool.so must be loaded even if=20
// they specified --help or didn't specify a client program.
|
|
From: <sv...@va...> - 2005-05-30 23:20:55
|
Author: njn
Date: 2005-05-31 00:20:51 +0100 (Tue, 31 May 2005)
New Revision: 3817
Added:
trunk/coregrind/m_scheduler/
trunk/coregrind/m_scheduler/Makefile.am
trunk/coregrind/m_scheduler/priv_sema.h
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/m_scheduler/sema.c
trunk/coregrind/pub_core_scheduler.h
Removed:
trunk/coregrind/linux/sema.c
trunk/coregrind/vg_scheduler.c
Modified:
trunk/configure.in
trunk/coregrind/Makefile.am
trunk/coregrind/core.h
trunk/coregrind/linux/Makefile.am
trunk/coregrind/linux/core_os.h
Log:
Modularised m_scheduler.
Modified: trunk/configure.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/configure.in 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/configure.in 2005-05-30 23:20:51 UTC (rev 3817)
@@ -391,6 +391,7 @@
coregrind/m_demangle/Makefile=20
coregrind/m_dispatch/Makefile=20
coregrind/m_replacemalloc/Makefile=20
+ coregrind/m_scheduler/Makefile=20
coregrind/m_sigframe/Makefile=20
coregrind/m_syscalls/Makefile=20
coregrind/amd64/Makefile
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/Makefile.am 2005-05-30 23:20:51 UTC (rev 3817)
@@ -6,6 +6,7 @@
m_demangle \
m_dispatch \
m_replacemalloc \
+ m_scheduler \
m_sigframe \
m_syscalls
=20
@@ -47,6 +48,7 @@
pub_core_options.h \
pub_core_redir.h \
pub_core_replacemalloc.h\
+ pub_core_scheduler.h \
pub_core_sigframe.h \
pub_core_skiplist.h \
pub_core_stacktrace.h \
@@ -92,7 +94,6 @@
m_transtab.c \
ume.c \
\
- vg_scheduler.c \
vg_main.c \
vg_messages.c \
vg_mylibc.c \
@@ -105,7 +106,9 @@
vg_stabs.c \
vg_symtypes.c
=20
+## Nb: libscheduler.a must precede libdispatch.a in this list.
stage2_extra=3D \
+ m_scheduler/libscheduler.a \
m_dispatch/libdispatch.a \
m_demangle/libdemangle.a \
m_aspacemgr/libaspacemgr.a \
Modified: trunk/coregrind/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/core.h 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/core.h 2005-05-30 23:20:51 UTC (rev 3817)
@@ -37,11 +37,12 @@
=20
#include "core_os.h" // OS-specific stuff, eg. linux/core_os.h
=20
+#include <setjmp.h> // for jmp_buf
+
#include "pub_core_mallocfree.h" // for type 'ArenaId'
+#include "pub_core_scheduler.h" // for types 'ThreadState', 'ThreadArc=
hState'
#include "pub_core_stacktrace.h" // for type 'StackTrace'
=20
-#include <setjmp.h> /* for jmp_buf */
-
/* ---------------------------------------------------------------------
Global macros.
------------------------------------------------------------------ */
@@ -137,230 +138,6 @@
=20
=20
/* ---------------------------------------------------------------------
- Exports of vg_scheduler.c
- ------------------------------------------------------------------ */
-
-/*=20
- Thread state machine:
-
- Empty -> Init -> Runnable <=3D> WaitSys/Yielding
- ^ |
- \---- Zombie -----/ =20
- */
-typedef
- enum ThreadStatus {=20
- VgTs_Empty, /* this slot is not in use */
- VgTs_Init, /* just allocated */
- VgTs_Runnable, /* ready to run */
- VgTs_WaitSys, /* waiting for a syscall to complete */
- VgTs_Yielding, /* temporarily yielding the CPU */
- VgTs_Zombie, /* transient state just before exiting */
- }
- ThreadStatus;
-
-/* Return codes from the scheduler. */
-typedef
- enum {=20
- VgSrc_None, /* not exiting yet */
- VgSrc_ExitSyscall, /* client called exit(). This is the normal
- route out. */
- VgSrc_FatalSig /* Killed by the default action of a fatal
- signal */
- }
- VgSchedReturnCode;
-
-
-#if defined(VGA_x86)
- typedef VexGuestX86State VexGuestArchState;
-#elif defined(VGA_amd64)
- typedef VexGuestAMD64State VexGuestArchState;
-#elif defined(VGA_arm)
- typedef VexGuestARMState VexGuestArchState;
-#else
-# error Unknown architecture
-#endif
-
-
-typedef=20
- struct {
- /* --- BEGIN vex-mandated guest state --- */
-
- /* Saved machine context. */
- VexGuestArchState vex;
-
- /* Saved shadow context. */
- VexGuestArchState vex_shadow;
-
- /* Spill area. */
- UChar vex_spill[LibVEX_N_SPILL_BYTES];
-
- /* --- END vex-mandated guest state --- */
- }=20
- ThreadArchState;
-
-
-typedef struct {
- /* ThreadId =3D=3D 0 (and hence vg_threads[0]) is NEVER USED.
- The thread identity is simply the index in vg_threads[].
- ThreadId =3D=3D 1 is the root thread and has the special property
- that we don't try and allocate or deallocate its stack. For
- convenience of generating error message, we also put the
- ThreadId in this tid field, but be aware that it should
- ALWAYS =3D=3D the index in vg_threads[]. */
- ThreadId tid;
-
- /* Current scheduling status. */
- ThreadStatus status;
-
- /* This is set if the thread is in the process of exiting for any
- reason. The precise details of the exit are in the OS-specific
- state. */
- VgSchedReturnCode exitreason;
-
- /* Architecture-specific thread state. */
- ThreadArchState arch;
-
- /* This thread's blocked-signals mask. Semantics is that for a
- signal to be delivered to this thread, the signal must not be
- blocked by this signal mask. If more than one thread accepts a
- signal, then it will be delivered to one at random. If all
- threads block the signal, it will remain pending until either a
- thread unblocks it or someone uses sigwaitsig/sigtimedwait. */
- vki_sigset_t sig_mask;
-
- /* tmp_sig_mask is usually the same as sig_mask, and is kept in
- sync whenever sig_mask is changed. The only time they have
- different values is during the execution of a sigsuspend, where
- tmp_sig_mask is the temporary mask which sigsuspend installs.
- It is only consulted to compute the signal mask applied to a
- signal handler. */
- vki_sigset_t tmp_sig_mask;
-
- /* A little signal queue for signals we can't get the kernel to
- queue for us. This is only allocated as needed, since it should
- be rare. */
- struct SigQueue *sig_queue;
-
- /* Syscall the Thread is currently running; -1 if none. Should only
- be set while Thread is in VgTs_WaitSys. */
- Int syscallno;
-
- /* Client stacks. When a thread slot is freed, we don't deallocate i=
ts
- stack; we just leave it lying around for the next use of the
- slot. If the next use of the slot requires a larger stack,
- only then is the old one deallocated and a new one
- allocated.=20
-
- For the main thread (threadid =3D=3D 0), this mechanism doesn't
- apply. We don't know the size of the stack since we didn't
- allocate it, and furthermore we never reallocate it. */
-
- /* The allocated size of this thread's stack (permanently zero
- if this is ThreadId =3D=3D 0, since we didn't allocate its stack) =
*/
- SizeT client_stack_szB;
-
- /* Address of the highest legitimate word in this stack. This is
- used for error messages only -- not critical for execution
- correctness. Is is set for all stacks, specifically including
- ThreadId =3D=3D 0 (the main thread). */
- Addr client_stack_highest_word;
-
- /* Alternate signal stack */
- vki_stack_t altstack;
-
- /* OS-specific thread state */
- os_thread_t os_state;
-
- /* Used in the syscall handlers. Set to True to indicate that the
- PRE routine for a syscall has set the syscall result already and
- so the syscall does not need to be handed to the kernel. */
- Bool syscall_result_set;
- =20
- /* Per-thread jmp_buf to resume scheduler after a signal */
- Bool sched_jmpbuf_valid;
- jmp_buf sched_jmpbuf;
-}
-ThreadState;
-
-
-/* The thread table. */
-extern ThreadState VG_(threads)[VG_N_THREADS];
-
-/* Allocate a new ThreadState */
-extern ThreadId VG_(alloc_ThreadState)(void);
-
-/* A thread exits. tid must currently be running. */
-extern void VG_(exit_thread)(ThreadId tid);
-
-/* Kill a thread. This interrupts whatever a thread is doing, and
- makes it exit ASAP. This does not set the exitreason or
- exitcode. */
-extern void VG_(kill_thread)(ThreadId tid);
-
-/* Check that tid is in range and denotes a non-Empty thread. */
-extern Bool VG_(is_valid_tid) ( ThreadId tid );
-
-/* Get the ThreadState for a particular thread */
-extern ThreadState *VG_(get_ThreadState)(ThreadId tid);
-
-/* Given an LWP id (ie, real kernel thread id), find the corresponding
- ThreadId */
-extern ThreadId VG_(get_lwp_tid)(Int lwpid);
-
-/* Returns true if a thread is currently running (ie, has the CPU lock) =
*/
-extern Bool VG_(is_running_thread)(ThreadId tid);
-
-/* Returns true if the thread is in the process of exiting */
-extern Bool VG_(is_exiting)(ThreadId tid);
-
-/* Return the number of non-dead Threads */
-extern Int VG_(count_living_threads)(void);
-
-/* Nuke all threads except tid. */
-extern void VG_(nuke_all_threads_except) ( ThreadId me,
- VgSchedReturnCode reason );
-
-/* Make a thread the running thread. The thread must previously been
- sleeping, and not holding the CPU semaphore. This will set the
- thread state to VgTs_Runnable, and the thread will attempt to take
- the CPU semaphore. By the time it returns, tid will be the running
- thread. */
-extern void VG_(set_running) ( ThreadId tid );
-
-/* Set a thread into a sleeping state. Before the call, the thread
- must be runnable, and holding the CPU semaphore. When this call
- returns, the thread will be set to the specified sleeping state,
- and will not be holding the CPU semaphore. Note that another
- thread could be running by the time this call returns, so the
- caller must be careful not to touch any shared state. It is also
- the caller's responsibility to actually block until the thread is
- ready to run again. */
-extern void VG_(set_sleeping) ( ThreadId tid, ThreadStatus state );
-
-/* Yield the CPU for a while */
-extern void VG_(vg_yield)(void);
-
-// The scheduler.
-extern VgSchedReturnCode VG_(scheduler) ( ThreadId tid );
-
-// Do everything which needs doing before the process finally ends,
-// like printing reports, etc
-extern void VG_(shutdown_actions_NORETURN) (
- ThreadId tid,=20
- VgSchedReturnCode tids_schedretcode=20
- );
-
-extern void VG_(scheduler_init) ( void );
-
-extern void VG_(pp_sched_status) ( void );
-
-// Longjmp back to the scheduler and thus enter the sighandler immediate=
ly.
-extern void VG_(resume_scheduler) ( ThreadId tid );
-
-/* If true, a fault is Valgrind-internal (ie, a bug) */
-extern Bool VG_(my_fault);
-
-/* ---------------------------------------------------------------------
Exports of vg_signals.c
------------------------------------------------------------------ */
=20
Modified: trunk/coregrind/linux/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/Makefile.am 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/linux/Makefile.am 2005-05-30 23:20:51 UTC (rev 3817)
@@ -7,5 +7,4 @@
noinst_LIBRARIES =3D libos.a
=20
libos_a_SOURCES =3D \
- core_os.c \
- sema.c
+ core_os.c
Modified: trunk/coregrind/linux/core_os.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/core_os.h 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/linux/core_os.h 2005-05-30 23:20:51 UTC (rev 3817)
@@ -32,17 +32,6 @@
#ifndef __LINUX_CORE_OS_H
#define __LINUX_CORE_OS_H
=20
-/* Not really a semaphore, but use a pipe for a token-passing scheme */
-typedef struct {
- Int pipe[2];
- Int owner_thread; /* who currently has it */
-} vg_sema_t;
-
-void VGO_(sema_init)(vg_sema_t *);
-void VGO_(sema_deinit)(vg_sema_t *);
-void VGO_(sema_down)(vg_sema_t *sema);
-void VGO_(sema_up)(vg_sema_t *sema);
-
/* OS-specific thread state */
typedef struct {
/* who we are */
Deleted: trunk/coregrind/linux/sema.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/sema.c 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/linux/sema.c 2005-05-30 23:20:51 UTC (rev 3817)
@@ -1,97 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Semaphore stuff. linux/sema.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward
- js...@ac...
- (except where noted below)
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "core.h"
-
-/*=20
- Slower (than the removed futex-based sema scheme) but more portable
- pipe-based token passing scheme.
- */
-
-void VGO_(sema_init)(vg_sema_t *sema)
-{
- VG_(pipe)(sema->pipe);
- sema->pipe[0] =3D VG_(safe_fd)(sema->pipe[0]);
- sema->pipe[1] =3D VG_(safe_fd)(sema->pipe[1]);
-
- sema->owner_thread =3D -1;
-
- /* create initial token */
- VG_(write)(sema->pipe[1], "T", 1);
-}
-
-void VGO_(sema_deinit)(vg_sema_t *sema)
-{
- VG_(close)(sema->pipe[0]);
- VG_(close)(sema->pipe[1]);
- sema->pipe[0] =3D sema->pipe[1] =3D -1;
-}
-
-/* get a token */
-void VGO_(sema_down)(vg_sema_t *sema)
-{
- Char buf[2] =3D { 'x' };
- Int ret;
- Int lwpid =3D VG_(gettid)();
-
- vg_assert(sema->owner_thread !=3D lwpid); /* can't have it already */
-
- again:
- ret =3D VG_(read)(sema->pipe[0], buf, 2);
-
- if (ret =3D=3D -VKI_EINTR)
- goto again;
-
- vg_assert(ret =3D=3D 1); /* should get exactly 1 token */
- vg_assert(buf[0] =3D=3D 'T');
-
- sema->owner_thread =3D lwpid;
-}
-
-/* put token back */
-void VGO_(sema_up)(vg_sema_t *sema)
-{
- Int ret;
-
- vg_assert(sema->owner_thread =3D=3D VG_(gettid)()); /* must have it *=
/
-
- sema->owner_thread =3D 0;
-
- ret =3D VG_(write)(sema->pipe[1], "T", 1);
-
- vg_assert(ret =3D=3D 1);
-}
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
-
-
Added: trunk/coregrind/m_scheduler/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_scheduler/Makefile.am 2005-05-30 21:44:08 UTC (rev =
3816)
+++ trunk/coregrind/m_scheduler/Makefile.am 2005-05-30 23:20:51 UTC (rev =
3817)
@@ -0,0 +1,12 @@
+include $(top_srcdir)/Makefile.all.am
+include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
+
+noinst_HEADERS =3D \
+ priv_sema.h
+
+noinst_LIBRARIES =3D libscheduler.a
+
+libscheduler_a_SOURCES =3D \
+ scheduler.c \
+ sema.c
+
Added: trunk/coregrind/m_scheduler/priv_sema.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_scheduler/priv_sema.h 2005-05-30 21:44:08 UTC (rev =
3816)
+++ trunk/coregrind/m_scheduler/priv_sema.h 2005-05-30 23:20:51 UTC (rev =
3817)
@@ -0,0 +1,54 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Private scheduler header. priv_sema.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PRIV_SEMA_H
+#define __PRIV_SEMA_H
+
+/* Not really a semaphore, but use a pipe for a token-passing scheme */
+/* Not really a semaphore, but use a pipe for a token-passing scheme */
+typedef struct {
+ Int pipe[2];
+ Int owner_thread; /* who currently has it */
+} vg_sema_t;
+
+// Nb: this may be OS-specific, but let's not factor it out until we
+// implement an OS port for which this isn't ok. Then we can rename the=
m
+// VGO_(sema_init)(), etc.
+void VG_(sema_init) ( vg_sema_t *sema );
+void VG_(sema_deinit) ( vg_sema_t *sema );
+void VG_(sema_down) ( vg_sema_t *sema );
+void VG_(sema_up) ( vg_sema_t *sema );
+
+#endif // __PRIV_SEMA_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
+
Copied: trunk/coregrind/m_scheduler/scheduler.c (from rev 3816, trunk/cor=
egrind/vg_scheduler.c)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_scheduler.c 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-05-30 23:20:51 UTC (rev =
3817)
@@ -0,0 +1,1130 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Thread scheduling. scheduler.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, an extensible x86 protected-mode
+ emulator for monitoring program execution on x86-Unixes.
+
+ Copyright (C) 2000-2005 Julian Seward=20
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+/*=20
+ Overview
+
+ Valgrind tries to emulate the kernel's threading as closely as
+ possible. The client does all threading via the normal syscalls
+ (on Linux: clone, etc). Valgrind emulates this by creating exactly
+ the same process structure as would be created without Valgrind.
+ There are no extra threads.
+
+ The main difference is that Valgrind only allows one client thread
+ to run at once. This is controlled with the VCPU semaphore,
+ "run_sema". Any time a thread wants to run client code or
+ manipulate any shared state (which is anything other than its own
+ ThreadState entry), it must hold the run_sema.
+
+ When a thread is about to block in a blocking syscall, it releases
+ run_sema, and re-takes it when it becomes runnable again (either
+ because the syscall finished, or we took a signal).
+
+ VG_(scheduler) therefore runs in each thread. It returns only when
+ the thread is exiting, either because it exited itself, or it was
+ told to exit by another thread.
+
+ This file is almost entirely OS-independent. The details of how
+ the OS handles threading and signalling are abstracted away and
+ implemented elsewhere.
+ */
+
+#include "valgrind.h" /* for VG_USERREQ__RUNNING_ON_VALGRIND and
+ VG_USERREQ__DISCARD_TRANSLATIONS, and other=
s */
+#include "core.h"
+
+#include "pub_core_dispatch.h"
+#include "pub_core_errormgr.h"
+#include "pub_core_options.h"
+#include "pub_core_replacemalloc.h"
+#include "pub_core_scheduler.h"
+#include "pub_core_stacktrace.h"
+#include "pub_core_syscalls.h"
+#include "pub_core_tooliface.h"
+#include "pub_core_translate.h"
+#include "pub_core_transtab.h"
+#include "vki_unistd.h"
+#include "priv_sema.h"
+
+/* ---------------------------------------------------------------------
+ Types and globals for the scheduler.
+ ------------------------------------------------------------------ */
+
+/* ThreadId and ThreadState are defined in core.h. */
+
+/* Defines the thread-scheduling timeslice, in terms of the number of
+ basic blocks we attempt to run each thread for. Smaller values
+ give finer interleaving but much increased scheduling overheads. */
+#define SCHEDULING_QUANTUM 50000
+
+/* Globals. A statically allocated array of threads. NOTE: [0] is
+ never used, to simplify the simulation of initialisers for
+ LinuxThreads. */
+ThreadState VG_(threads)[VG_N_THREADS];
+
+/* If true, a fault is Valgrind-internal (ie, a bug) */
+Bool VG_(my_fault) =3D True;
+
+/* Counts downwards in VG_(run_innerloop). */
+UInt VG_(dispatch_ctr);
+
+/* Forwards */
+static void do_client_request ( ThreadId tid );
+static void scheduler_sanity ( ThreadId tid );
+static void mostly_clear_thread_record ( ThreadId tid );
+static const HChar *name_of_thread_state ( ThreadStatus );
+
+/* Stats. */
+static UInt n_scheduling_events_MINOR =3D 0;
+static UInt n_scheduling_events_MAJOR =3D 0;
+
+
+void VG_(print_scheduler_stats)(void)
+{
+ VG_(message)(Vg_DebugMsg,
+ " %d/%d major/minor sched events.",=20
+ n_scheduling_events_MAJOR, n_scheduling_events_MINOR);
+}
+
+/* CPU semaphore, so that threads can run exclusively */
+static vg_sema_t run_sema;
+static ThreadId running_tid =3D VG_INVALID_THREADID;
+
+
+/* ---------------------------------------------------------------------
+ Helper functions for the scheduler.
+ ------------------------------------------------------------------ */
+
+__inline__
+Bool VG_(is_valid_tid) ( ThreadId tid )
+{
+ /* tid is unsigned, hence no < 0 test. */
+ if (tid =3D=3D 0) return False;
+ if (tid >=3D VG_N_THREADS) return False;
+ if (VG_(threads)[tid].status =3D=3D VgTs_Empty) return False;
+ return True;
+}
+
+
+/* For constructing error messages only: try and identify a thread
+ whose stack satisfies the predicate p, or return VG_INVALID_THREADID
+ if none do.
+*/
+ThreadId VG_(first_matching_thread_stack)
+ ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ),
+ void* d )
+{
+ ThreadId tid;
+
+ for (tid =3D 1; tid < VG_N_THREADS; tid++) {
+ if (VG_(threads)[tid].status =3D=3D VgTs_Empty) continue;
+
+ if ( p ( STACK_PTR(VG_(threads)[tid].arch),
+ VG_(threads)[tid].client_stack_highest_word, d ) )
+ return tid;
+ }
+ return VG_INVALID_THREADID;
+}
+=20
+void VG_(mark_from_registers)(void (*mark_addr)(Addr))
+{
+ ThreadId tid;
+
+ for(tid =3D 1; tid < VG_N_THREADS; tid++) {
+ if (!VG_(is_valid_tid)(tid))
+ continue;
+ VGA_(mark_from_registers)(tid, mark_addr);
+ }
+}
+
+/* Print the scheduler status. */
+void VG_(pp_sched_status) ( void )
+{
+ Int i;=20
+ VG_(printf)("\nsched status:\n");=20
+ VG_(printf)(" running_tid=3D%d\n", running_tid);
+ for (i =3D 1; i < VG_N_THREADS; i++) {
+ if (VG_(threads)[i].status =3D=3D VgTs_Empty) continue;
+ VG_(printf)("\nThread %d: status =3D %s\n", i, name_of_thread_stat=
e(VG_(threads)[i].status));
+ VG_(get_and_pp_StackTrace)( i, VG_(clo_backtrace_size) );
+ }
+ VG_(printf)("\n");
+}
+
+static
+void print_sched_event ( ThreadId tid, Char* what )
+{
+ VG_(message)(Vg_DebugMsg, " SCHED[%d]: %s", tid, what );
+}
+
+static
+HChar* name_of_sched_event ( UInt event )
+{
+ switch (event) {
+ case VEX_TRC_JMP_SYSCALL: return "SYSCALL";
+ case VEX_TRC_JMP_CLIENTREQ: return "CLIENTREQ";
+ case VEX_TRC_JMP_YIELD: return "YIELD";
+ case VEX_TRC_JMP_NODECODE: return "NODECODE";
+ case VG_TRC_INNER_COUNTERZERO: return "COUNTERZERO";
+ case VG_TRC_INNER_FASTMISS: return "FASTMISS";
+ case VG_TRC_FAULT_SIGNAL: return "FAULTSIGNAL";
+ default: return "??UNKNOWN??";
+ }
+}
+
+static
+const HChar* name_of_thread_state ( ThreadStatus state )
+{
+ switch (state) {
+ case VgTs_Empty: return "VgTs_Empty";
+ case VgTs_Init: return "VgTs_Init";
+ case VgTs_Runnable: return "VgTs_Runnable";
+ case VgTs_WaitSys: return "VgTs_WaitSys";
+ case VgTs_Yielding: return "VgTs_Yielding";
+ case VgTs_Zombie: return "VgTs_Zombie";
+ default: return "VgTs_???";
+ }
+}
+
+/* Allocate a completely empty ThreadState record. */
+ThreadId VG_(alloc_ThreadState) ( void )
+{
+ Int i;
+ for (i =3D 1; i < VG_N_THREADS; i++) {
+ if (VG_(threads)[i].status =3D=3D VgTs_Empty) {
+ VG_(threads)[i].status =3D VgTs_Init;
+ VG_(threads)[i].exitreason =3D VgSrc_None;
+ return i;
+ }
+ }
+ VG_(printf)("vg_alloc_ThreadState: no free slots available\n");
+ VG_(printf)("Increase VG_N_THREADS, rebuild and try again.\n");
+ VG_(core_panic)("VG_N_THREADS is too low");
+ /*NOTREACHED*/
+}
+
+ThreadState *VG_(get_ThreadState)(ThreadId tid)
+{
+ vg_assert(tid >=3D 0 && tid < VG_N_THREADS);
+ return &VG_(threads)[tid];
+}
+
+/* Given an LWP id (ie, real kernel thread id), find the corresponding
+ ThreadId */
+ThreadId VG_(get_lwp_tid)(Int lwp)
+{
+ ThreadId tid;
+ =20
+ for(tid =3D 1; tid < VG_N_THREADS; tid++)
+ if (VG_(threads)[tid].status !=3D VgTs_Empty && VG_(threads)[tid].=
os_state.lwpid =3D=3D lwp)
+ return tid;
+
+ return VG_INVALID_THREADID;
+}
+
+/*=20
+ Mark a thread as Runnable. This will block until the run_sema is
+ available, so that we get exclusive access to all the shared
+ structures and the CPU. Up until we get the sema, we must not
+ touch any shared state.
+
+ When this returns, we'll actually be running.
+ */
+void VG_(set_running)(ThreadId tid)
+{
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ vg_assert(tst->status !=3D VgTs_Runnable);
+ =20
+ tst->status =3D VgTs_Runnable;
+ =20
+ VG_(sema_down)(&run_sema);
+ if (running_tid !=3D VG_INVALID_THREADID)
+ VG_(printf)("tid %d found %d running\n", tid, running_tid);
+ vg_assert(running_tid =3D=3D VG_INVALID_THREADID);
+ running_tid =3D tid;
+
+ if (VG_(clo_trace_sched))
+ print_sched_event(tid, "now running");
+}
+
+ThreadId VG_(get_running_tid)(void)
+{
+ return running_tid;
+}
+
+Bool VG_(is_running_thread)(ThreadId tid)
+{
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ return=20
+// tst->os_state.lwpid =3D=3D VG_(gettid)() && /* check we're this =
tid */
+ running_tid =3D=3D tid && /* and that we've got the loc=
k */
+ tst->status =3D=3D VgTs_Runnable; /* and we're runnable */
+}
+
+/* Return the number of non-dead Threads */
+Int VG_(count_living_threads)(void)
+{
+ Int count =3D 0;
+ ThreadId tid;
+
+ for(tid =3D 1; tid < VG_N_THREADS; tid++)
+ if (VG_(threads)[tid].status !=3D VgTs_Empty &&
+ VG_(threads)[tid].status !=3D VgTs_Zombie)
+ count++;
+
+ return count;
+}
+
+/*=20
+ Set a thread into a sleeping state, and give up exclusive access to
+ the CPU. On return, the thread must be prepared to block until it
+ is ready to run again (generally this means blocking in a syscall,
+ but it may mean that we remain in a Runnable state and we're just
+ yielding the CPU to another thread).
+ */
+void VG_(set_sleeping)(ThreadId tid, ThreadStatus sleepstate)
+{
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ vg_assert(tst->status =3D=3D VgTs_Runnable);
+
+ vg_assert(sleepstate =3D=3D VgTs_WaitSys ||
+ sleepstate =3D=3D VgTs_Yielding);
+
+ tst->status =3D sleepstate;
+
+ vg_assert(running_tid =3D=3D tid);
+ running_tid =3D VG_INVALID_THREADID;
+
+ /* Release the run_sema; this will reschedule any runnable
+ thread. */
+ VG_(sema_up)(&run_sema);
+
+ if (VG_(clo_trace_sched)) {
+ Char buf[50];
+ VG_(sprintf)(buf, "now sleeping in state %s", name_of_thread_state=
(sleepstate));
+ print_sched_event(tid, buf);
+ }
+}
+
+/* Return true if the thread is still alive but in the process of
+ exiting. */
+inline Bool VG_(is_exiting)(ThreadId tid)
+{
+ vg_assert(VG_(is_valid_tid)(tid));
+ return VG_(threads)[tid].exitreason !=3D VgSrc_None;
+}
+
+/* Clear out the ThreadState and release the semaphore. Leaves the
+ ThreadState in VgTs_Zombie state, so that it doesn't get
+ reallocated until the caller is really ready. */
+void VG_(exit_thread)(ThreadId tid)
+{
+ vg_assert(VG_(is_valid_tid)(tid));
+ vg_assert(VG_(is_running_thread)(tid));
+ vg_assert(VG_(is_exiting)(tid));
+
+ mostly_clear_thread_record(tid);
+ running_tid =3D VG_INVALID_THREADID;
+
+ /* There should still be a valid exitreason for this thread */
+ vg_assert(VG_(threads)[tid].exitreason !=3D VgSrc_None);
+
+ VG_(sema_up)(&run_sema);
+}
+
+/* Kill a thread. This interrupts whatever a thread is doing, and
+ makes it exit ASAP. This does not set the exitreason or
+ exitcode. */
+void VG_(kill_thread)(ThreadId tid)
+{
+ vg_assert(VG_(is_valid_tid)(tid));
+ vg_assert(!VG_(is_running_thread)(tid));
+ vg_assert(VG_(is_exiting)(tid));
+
+ if (VG_(threads)[tid].status =3D=3D VgTs_WaitSys) {
+ if (VG_(clo_trace_signals))
+ VG_(message)(Vg_DebugMsg, "kill_thread zaps tid %d lwp %d",
+ tid, VG_(threads)[tid].os_state.lwpid);
+ VG_(tkill)(VG_(threads)[tid].os_state.lwpid, VKI_SIGVGKILL);
+ }
+}
+
+/*=20
+ Yield the CPU for a short time to let some other thread run.
+ */
+void VG_(vg_yield)(void)
+{
+ struct vki_timespec ts =3D { 0, 1 };
+ ThreadId tid =3D running_tid;
+
+ vg_assert(tid !=3D VG_INVALID_THREADID);
+ vg_assert(VG_(threads)[tid].os_state.lwpid =3D=3D VG_(gettid)());
+
+ VG_(set_sleeping)(tid, VgTs_Yielding);
+
+ //VG_(printf)("tid %d yielding EIP=3D%p\n", tid, VG_(threads)[tid].ar=
ch.m_eip);
+
+ /*=20
+ Tell the kernel we're yielding.
+ */
+ if (1)
+ VG_(do_syscall0)(__NR_sched_yield);
+ else
+ VG_(nanosleep)(&ts);
+
+ VG_(set_running)(tid);
+
+ VG_(poll_signals)(tid); /* something might have happened */
+}
+
+
+void VG_(resume_scheduler)(ThreadId tid)
+{
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ vg_assert(tst->os_state.lwpid =3D=3D VG_(gettid)());
+
+ if (tst->sched_jmpbuf_valid) {
+ /* Can't continue; must longjmp back to the scheduler and thus
+ enter the sighandler immediately. */
+ =20
+ longjmp(tst->sched_jmpbuf, True);
+ }
+}
+
+/* Set the standard set of blocked signals, used wheneever we're not
+ running a client syscall. */
+static void block_signals(ThreadId tid)
+{
+ vki_sigset_t mask;
+
+ VG_(sigfillset)(&mask);
+
+ /* Don't block these because they're synchronous */
+ VG_(sigdelset)(&mask, VKI_SIGSEGV);
+ VG_(sigdelset)(&mask, VKI_SIGBUS);
+ VG_(sigdelset)(&mask, VKI_SIGFPE);
+ VG_(sigdelset)(&mask, VKI_SIGILL);
+ VG_(sigdelset)(&mask, VKI_SIGTRAP);
+
+ /* Can't block these anyway */
+ VG_(sigdelset)(&mask, VKI_SIGSTOP);
+ VG_(sigdelset)(&mask, VKI_SIGKILL);
+
+ VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
+}
+
+/* Use libc setjmp/longjmp. longjmp must not restore signal mask
+ state, but does need to pass "val" through. */
+#define SCHEDSETJMP(tid, jumped, stmt) \
+ do { \
+ ThreadState * volatile _qq_tst =3D VG_(get_ThreadState)(tid); \
+ \
+ (jumped) =3D setjmp(_qq_tst->sched_jmpbuf); =
\
+ if ((jumped) =3D=3D 0) { \
+ vg_assert(!_qq_tst->sched_jmpbuf_valid); \
+ _qq_tst->sched_jmpbuf_valid =3D True; \
+ stmt; \
+ } else if (VG_(clo_trace_sched)) \
+ VG_(printf)("SCHEDSETJMP(line %d) tid %d, jumped=3D%d\n", __LINE__, ti=
d, jumped); \
+ vg_assert(_qq_tst->sched_jmpbuf_valid); \
+ _qq_tst->sched_jmpbuf_valid =3D False; \
+ } while(0)
+
+/* Run the thread tid for a while, and return a VG_TRC_* value to the
+ scheduler indicating what happened. */
+static
+UInt run_thread_for_a_while ( ThreadId tid )
+{
+ volatile Bool jumped;
+ volatile ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ volatile UInt trc =3D 0;
+ volatile Int dispatch_ctr_SAVED =3D VG_(dispatch_ctr);
+ volatile Int done_this_time;
+
+ /* For paranoia purposes only */
+ volatile Addr a_vex =3D (Addr) & VG_(threads)[tid].arch.vex;
+ volatile Addr a_vexsh =3D (Addr) & VG_(threads)[tid].arch.vex_shadow=
;
+ volatile Addr a_spill =3D (Addr) & VG_(threads)[tid].arch.vex_spill;
+ volatile UInt sz_vex =3D (UInt) sizeof VG_(threads)[tid].arch.vex;
+ volatile UInt sz_vexsh =3D (UInt) sizeof VG_(threads)[tid].arch.vex_s=
hadow;
+ volatile UInt sz_spill =3D (UInt) sizeof VG_(threads)[tid].arch.vex_s=
pill;
+
+ /* Paranoia */
+ vg_assert(VG_(is_valid_tid)(tid));
+ vg_assert(VG_(is_valid_tid)(tid));
+ vg_assert(VG_(is_running_thread)(tid));
+ vg_assert(!VG_(is_exiting)(tid));
+
+ /* Even more paranoia. Check that what we have matches
+ Vex's guest state layout requirements. */
+ if (0)
+ VG_(printf)("%p %d %p %d %p %d\n",
+ (void*)a_vex, sz_vex, (void*)a_vexsh, sz_vexsh,
+ (void*)a_spill, sz_spill );
+
+ vg_assert(VG_IS_8_ALIGNED(sz_vex));
+ vg_assert(VG_IS_8_ALIGNED(sz_vexsh));
+ vg_assert(VG_IS_16_ALIGNED(sz_spill));
+
+ vg_assert(VG_IS_4_ALIGNED(a_vex));
+ vg_assert(VG_IS_4_ALIGNED(a_vexsh));
+ vg_assert(VG_IS_4_ALIGNED(a_spill));
+
+ vg_assert(sz_vex =3D=3D sz_vexsh);
+ vg_assert(a_vex + sz_vex =3D=3D a_vexsh);
+
+ vg_assert(sz_spill =3D=3D LibVEX_N_SPILL_BYTES);
+ vg_assert(a_vex + 2 * sz_vex =3D=3D a_spill);
+
+ VGP_PUSHCC(VgpRun);
+
+ /* there should be no undealt-with signals */
+ //vg_assert(VG_(threads)[tid].siginfo.si_signo =3D=3D 0);
+
+ //VG_(printf)("running EIP =3D %p ESP=3D%p\n", VG_(threads)[tid].arch=
.m_eip, VG_(threads)[tid].arch.m_esp);
+
+ vg_assert(VG_(my_fault));
+ VG_(my_fault) =3D False;
+
+ SCHEDSETJMP(tid, jumped,=20
+ trc =3D (UInt)VG_(run_innerloop)( (void*)&tst->arch.=
vex ));
+
+ //nextEIP =3D tst->arch.m_eip;
+ //if (nextEIP >=3D VG_(client_end))
+ // VG_(printf)("trc=3D%d jump to %p from %p\n",
+ // trc, nextEIP, EIP);
+ =20
+ VG_(my_fault) =3D True;
+
+ if (jumped) {
+ /* We get here if the client took a fault, which caused our
+ signal handler to longjmp. */
+ vg_assert(trc =3D=3D 0);
+ trc =3D VG_TRC_FAULT_SIGNAL;
+ block_signals(tid);
+ }=20
+
+ done_this_time =3D (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) -=
0;
+
+ vg_assert(done_this_time >=3D 0);
+ VG_(bbs_done) +=3D (ULong)done_this_time;
+
+ VGP_POPCC(VgpRun);
+ return trc;
+}
+
+
+static=20
+void mostly_clear_thread_record ( ThreadId tid )
+{
+ vki_sigset_t savedmask;
+
+ vg_assert(tid >=3D 0 && tid < VG_N_THREADS);
+ VGP_(cleanup_thread)(&VG_(threads)[tid].arch);
+ VG_(threads)[tid].tid =3D tid;
+
+ /* Leave the thread in Zombie, so that it doesn't get reallocated
+ until the caller is finally done with the thread stack. */
+ VG_(threads)[tid].status =3D VgTs_Zombie;
+
+ VG_(threads)[tid].syscallno =3D -1;
+
+ VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
+ VG_(sigemptyset)(&VG_(threads)[tid].tmp_sig_mask);
+
+ VGO_(os_state_clear)(&VG_(threads)[tid]);
+
+ /* start with no altstack */
+ VG_(threads)[tid].altstack.ss_sp =3D (void *)0xdeadbeef;
+ VG_(threads)[tid].altstack.ss_size =3D 0;
+ VG_(threads)[tid].altstack.ss_flags =3D VKI_SS_DISABLE;
+
+ VG_(clear_out_queued_signals)(tid, &savedmask);
+
+ VG_(threads)[tid].sched_jmpbuf_valid =3D False;
+}
+
+/* =
=20
+ Called in the child after fork. If the parent has multiple =
=20
+ threads, then we've inhereted a VG_(threads) array describing them, =
=20
+ but only the thread which called fork() is actually alive in the =
=20
+ child. This functions needs to clean up all those other thread =
=20
+ structures. =
=20
+ =
=20
+ Whichever tid in the parent which called fork() becomes the =
=20
+ master_tid in the child. That's because the only living slot in =
=20
+ VG_(threads) in the child after fork is VG_(threads)[tid], and it =
=20
+ would be too hard to try to re-number the thread and relocate the =
=20
+ thread state down to VG_(threads)[1]. =
=20
+ =
=20
+ This function also needs to reinitialize the run_sema, since =
=20
+ otherwise we may end up sharing its state with the parent, which =
=20
+ would be deeply confusing. =
=20
+*/ =20
+static void sched_fork_cleanup(ThreadId me)
+{
+ ThreadId tid;
+ vg_assert(running_tid =3D=3D me);
+
+ VG_(threads)[me].os_state.lwpid =3D VG_(gettid)();
+ VG_(threads)[me].os_state.threadgroup =3D VG_(getpid)();
+
+ /* clear out all the unused thread slots */
+ for (tid =3D 1; tid < VG_N_THREADS; tid++) {
+ if (tid !=3D me) {
+ mostly_clear_thread_record(tid);
+ VG_(threads)[tid].status =3D VgTs_Empty;
+ }
+ }
+
+ /* re-init and take the sema */
+ VG_(sema_deinit)(&run_sema);
+ VG_(sema_init)(&run_sema);
+ VG_(sema_down)(&run_sema);
+}
+
+
+/* Initialise the scheduler. Create a single "main" thread ready to
+ run, with special ThreadId of one. This is called at startup. The
+ caller subsequently initialises the guest state components of this
+ main thread, thread 1. =20
+*/
+void VG_(scheduler_init) ( void )
+{
+ Int i;
+ ThreadId tid_main;
+
+ VG_(sema_init)(&run_sema);
+
+ for (i =3D 0 /* NB; not 1 */; i < VG_N_THREADS; i++) {
+ VG_(threads)[i].sig_queue =3D NULL;
+
+ VGO_(os_state_init)(&VG_(threads)[i]);
+ mostly_clear_thread_record(i);
+
+ VG_(threads)[i].status =3D VgTs_Empty;
+ VG_(threads)[i].client_stack_szB =3D 0;
+ VG_(threads)[i].client_stack_highest_word =3D (Addr)NULL;
+ }
+
+ tid_main =3D VG_(alloc_ThreadState)();
+
+ /* Initial thread's stack is the original process stack */
+ VG_(threads)[tid_main].client_stack_highest_word=20
+ =3D VG_(clstk_end) - sizeof(=
UWord);
+ VG_(threads)[tid_main].client_stack_szB =3D VG_(client_rlimit_stack)=
.rlim_cur;
+
+ VG_(atfork)(NULL, NULL, sched_fork_cleanup);
+}
+
+
+/* ---------------------------------------------------------------------
+ The scheduler proper.
+ ------------------------------------------------------------------ */
+
+static void handle_tt_miss ( ThreadId tid )
+{
+ Bool found;
+ Addr ip =3D INSTR_PTR(VG_(threads)[tid].arch);
+
+ /* Trivial event. Miss in the fast-cache. Do a full
+ lookup for it. */
+ found =3D VG_(search_transtab)( NULL,
+ ip, True/*upd_fast_cache*/ );
+ if (!found) {
+ /* Not found; we need to request a translation. */
+ if (VG_(translate)( tid, ip, /*debug*/False, 0/*not verbose*/ )) {
+ found =3D VG_(search_transtab)( NULL, ip, True );=20
+ vg_assert2(found, "VG_TRC_INNER_FASTMISS: missing tt_fast entry=
");
+ =20
+ } else {
+ // If VG_(translate)() fails, it's because it had to throw a
+ // signal because the client jumped to a bad address. That
+ // means that either a signal has been set up for delivery,
+ // or the thread has been marked for termination. Either
+ // way, we just need to go back into the scheduler loop.
+ }
+ }
+}
+
+static void handle_syscall(ThreadId tid)
+{
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+ Bool jumped;=20
+
+ /* Syscall may or may not block; either way, it will be
+ complete by the time this call returns, and we'll be
+ runnable again. We could take a signal while the
+ syscall runs. */
+ SCHEDSETJMP(tid, jumped, VG_(client_syscall)(tid));
+
+ if (!VG_(is_running_thread)(tid))
+ VG_(printf)("tid %d not running; running_tid=3D%d, tid %d status %=
d\n",
+ tid, running_tid, tid, tst->status);
+ vg_assert(VG_(is_running_thread)(tid));
+ =20
+ if (jumped) {
+ block_signals(tid);
+ VG_(poll_signals)(tid);
+ }
+}
+
+/*=20
+ Run a thread until it wants to exit.
+ =20
+ We assume that the caller has already called VG_(set_running) for
+ us, so we own the VCPU. Also, all signals are blocked.
+ */
+VgSchedReturnCode VG_(scheduler) ( ThreadId tid )
+{
+ UInt trc;
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ if (VG_(clo_trace_sched))
+ print_sched_event(tid, "entering VG_(scheduler)"); =20
+
+ VGP_PUSHCC(VgpSched);
+
+ /* set the proper running signal mask */
+ block_signals(tid);
+ =20
+ vg_assert(VG_(is_running_thread)(tid));
+
+ VG_(dispatch_ctr) =3D SCHEDULING_QUANTUM + 1;
+
+ while(!VG_(is_exiting)(tid)) {
+ if (VG_(dispatch_ctr) =3D=3D 1) {
+ /* Our slice is done, so yield the CPU to another thread. This
+ doesn't sleep between sleeping and running, since that would
+ take too much time. */
+ VG_(set_sleeping)(tid, VgTs_Yielding);
+ /* nothing */
+ VG_(set_running)(tid);
+ //VG_(tm_thread_switchto)(tid);
+
+ /* OK, do some relatively expensive housekeeping stuff */
+ scheduler_sanity(tid);
+ VG_(sanity_check_general)(False);
+
+ /* Look for any pending signals for this thread, and set them up
+ for delivery */
+ VG_(poll_signals)(tid);
+
+ if (VG_(is_exiting)(tid))
+ break; /* poll_signals picked up a fatal signal */
+
+ /* For stats purposes only. */
+ n_scheduling_events_MAJOR++;
+
+ /* Figure out how many bbs to ask vg_run_innerloop to do. Note
+ that it decrements the counter before testing it for zero, so
+ that if tst->dispatch_ctr is set to N you get at most N-1
+ iterations. Also this means that tst->dispatch_ctr must
+ exceed zero before entering the innerloop. Also also, the
+ decrement is done before the bb is actually run, so you
+ always get at least one decrement even if nothing happens. */
+ VG_(dispatch_ctr) =3D SCHEDULING_QUANTUM + 1;
+
+ /* paranoia ... */
+ vg_assert(tst->tid =3D=3D tid);
+ vg_assert(tst->os_state.lwpid =3D=3D VG_(gettid)());
+ }
+
+ /* For stats purposes only. */
+ n_scheduling_events_MINOR++;
+
+ if (0)
+ VG_(message)(Vg_DebugMsg, "thread %d: running for %d bbs",=20
+ tid, VG_(dispatch_ctr) - 1 );
+
+ trc =3D run_thread_for_a_while ( tid );
+
+ if (VG_(clo_trace_sched) && VG_(clo_verbosity) > 2) {
+ Char buf[50];
+ VG_(sprintf)(buf, "TRC: %s", name_of_sched_event(trc));
+ print_sched_event(tid, buf);
+ }
+
+ switch(trc) {
+ case VG_TRC_INNER_FASTMISS:
+ vg_assert(VG_(dispatch_ctr) > 1);
+ handle_tt_miss(tid);
+ break;
+ =20
+ case VEX_TRC_JMP_CLIENTREQ:
+ do_client_request(tid);
+ break;
+ =20
+ case VEX_TRC_JMP_SYSCALL:
+ handle_syscall(tid);
+ if (VG_(clo_sanity_level) > 2)
+ VG_(sanity_check_general)(True); /* sanity-check every syscall */
+ break;
+
+ case VEX_TRC_JMP_YIELD:
+ /* Explicit yield, because this thread is in a spin-lock
+ or something. Only let the thread run for a short while
+ longer. Because swapping to another thread is expensive,
+ we're prepared to let this thread eat a little more CPU
+ before swapping to another. That means that short term
+ spins waiting for hardware to poke memory won't cause a
+ thread swap. */
+ if (VG_(dispatch_ctr) > 100)=20
+ VG_(dispatch_ctr) =3D 100;
+ break;
+
+ case VG_TRC_INNER_COUNTERZERO:
+ /* Timeslice is out. Let a new thread be scheduled. */
+ vg_assert(VG_(dispatch_ctr) =3D=3D 1);
+ break;
+
+ case VG_TRC_FAULT_SIGNAL:
+ /* Everything should be set up (either we're exiting, or
+ about to start in a signal handler). */
+ break;
+
+ case VEX_TRC_JMP_MAPFAIL:
+ /* Failure of arch-specific address translation (x86/amd64
+ segment override use) */
+ /* jrs 2005 03 11: is this correct? */
+ VG_(synth_fault)(tid);
+ break;
+
+ case VEX_TRC_JMP_EMWARN: {
+ static Int counts[EmWarn_NUMBER];
+ static Bool counts_initted =3D False;
+ VexEmWarn ew;
+ HChar* what;
+ Bool show;
+ Int q;
+ if (!counts_initted) {
+ counts_initted =3D True;
+ for (q =3D 0; q < EmWarn_NUMBER; q++)
+ counts[q] =3D 0;
+ }
+ ew =3D (VexEmWarn)VG_(threads)[tid].arch.vex.guest_EMWARN;
+ what =3D (ew < 0 || ew >=3D EmWarn_NUMBER)
+ ? "unknown (?!)"
+ : LibVEX_EmWarn_string(ew);
+ show =3D (ew < 0 || ew >=3D EmWarn_NUMBER)
+ ? True
+ : counts[ew]++ < 3;
+ if (show && VG_(clo_show_emwarns)) {
+ VG_(message)( Vg_UserMsg,
+ "Emulation warning: unsupported action:");
+ VG_(message)( Vg_UserMsg, " %s", what);
+ VG_(get_and_pp_StackTrace)( tid, VG_(clo_backtrace_size) );
+ }
+ break;
+ }
+
+ case VEX_TRC_JMP_NODECODE:
+ VG_(synth_sigill)(tid, INSTR_PTR(VG_(threads)[tid].arch));
+ break;
+
+ default:=20
+ vg_assert2(0, "VG_(scheduler), phase 3: "
+ "unexpected thread return code (%u)", trc);
+ /* NOTREACHED */
+ break;
+
+ } /* switch (trc) */
+ }
+
+ if (VG_(clo_trace_sched))
+ print_sched_event(tid, "exiting VG_(scheduler)");
+
+ vg_assert(VG_(is_exiting)(tid));
+
+ VGP_POPCC(VgpSched);
+
+ //if (VG_(clo_model_pthreads))
+ // VG_(tm_thread_exit)(tid);
+ =20
+ return tst->exitreason;
+}
+
+
+/*=20
+ This causes all threads to forceably exit. They aren't actually
+ dead by the time this returns; you need to call
+ VGA_(reap_threads)() to wait for them.
+ */
+void VG_(nuke_all_threads_except) ( ThreadId me, VgSchedReturnCode src )
+{
+ ThreadId tid;
+
+ vg_assert(VG_(is_running_thread)(me));
+
+ for (tid =3D 1; tid < VG_N_THREADS; tid++) {
+ if (tid =3D=3D me
+ || VG_(threads)[tid].status =3D=3D VgTs_Empty)
+ continue;
+ if (0)
+ VG_(printf)(
+ "VG_(nuke_all_threads_except): nuking tid %d\n", tid);
+
+ VG_(threads)[tid].exitreason =3D src;
+ VG_(kill_thread)(tid);
+ }
+}
+
+
+/* ---------------------------------------------------------------------
+ Specifying shadow register values
+ ------------------------------------------------------------------ */
+
+// These macros write a value to a client's thread register, and tell th=
e
+// tool that it's happened (if necessary).
+
+#define SET_CLREQ_RETVAL(zztid, zzval) \
+ do { CLREQ_RET(VG_(threads)[zztid].arch) =3D (zzval); \
+ VG_TRACK( post_reg_write, \
+ Vg_CoreClientReq, zztid, O_CLREQ_RET, sizeof(UWord)); =
\
+ } while (0)
+
+#define SET_CLCALL_RETVAL(zztid, zzval, f) \
+ do { CLREQ_RET(VG_(threads)[zztid].arch) =3D (zzval); \
+ VG_TRACK( post_reg_write_clientcall_return, \
+ zztid, O_CLREQ_RET, sizeof(UWord), f); \
+ } while (0)
+
+void VG_(set_shadow_regs_area) ( ThreadId tid, OffT offset, SizeT size,
+ const UChar* area )
+{
+ ThreadState* tst;
+
+ vg_assert(VG_(is_valid_tid)(tid));
+ tst =3D & VG_(threads)[tid];
+
+ // Bounds check
+ vg_assert(0 <=3D offset && offset < sizeof(VexGuestArchState));
+ vg_assert(offset + size <=3D sizeof(VexGuestArchState));
+
+ VG_(memcpy)( (void*)(((Addr)(&tst->arch.vex_shadow)) + offset), area,=
size);
+}
+
+void VG_(get_shadow_regs_area) ( ThreadId tid, OffT offset, SizeT size,
+ UChar* area )
+{
+ ThreadState* tst;
+
+ vg_assert(VG_(is_valid_tid)(tid));
+ tst =3D & VG_(threads)[tid];
+
+ // Bounds check
+ vg_assert(0 <=3D offset && offset < sizeof(VexGuestArchState));
+ vg_assert(offset + size <=3D sizeof(VexGuestArchState));
+
+ VG_(memcpy)( area, (void*)(((Addr)&(tst->arch.vex_shadow)) + offset),=
size);
+}
+
+/* ---------------------------------------------------------------------
+ Handle client requests.
+ ------------------------------------------------------------------ */
+
+/* Do a client request for the thread tid. After the request, tid may
+ or may not still be runnable; if not, the scheduler will have to
+ choose a new thread to run. =20
+*/
+static
+void do_client_request ( ThreadId tid )
+{
+ UWord* arg =3D (UWord*)(CLREQ_ARGS(VG_(threads)[tid].arch));
+ UWord req_no =3D arg[0];
+
+ if (0)
+ VG_(printf)("req no =3D 0x%llx, arg =3D %p\n", (ULong)req_no, arg)=
;
+ switch (req_no) {
+
+ case VG_USERREQ__CLIENT_CALL0: {
+ UWord (*f)(ThreadId) =3D (void*)arg[1];
+ if (f =3D=3D NULL)
+ VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL0: func=3D%p\n", =
f);
+ else
+ SET_CLCALL_RETVAL(tid, f ( tid ), (Addr)f);
+ break;
+ }
+ case VG_USERREQ__CLIENT_CALL1: {
+ UWord (*f)(ThreadId, UWord) =3D (void*)arg[1];
+ if (f =3D=3D NULL)
+ VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL1: func=3D%p\n", =
f);
+ else
+ SET_CLCALL_RETVAL(tid, f ( tid, arg[2] ), (Addr)f );
+ break;
+ }
+ case VG_USERREQ__CLIENT_CALL2: {
+ UWord (*f)(ThreadId, UWord, UWord) =3D (void*)arg[1];
+ if (f =3D=3D NULL)
+ VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL2: func=3D%p\n", =
f);
+ else
+ SET_CLCALL_RETVAL(tid, f ( tid, arg[2], arg[3] ), (Addr)f );
+ break;
+ }
+ case VG_USERREQ__CLIENT_CALL3: {
+ UWord (*f)(ThreadId, UWord, UWord, UWord) =3D (void*)arg[1];
+ if (f =3D=3D NULL)
+ VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL3: func=3D%p\n", =
f);
+ else
+ SET_CLCALL_RETVAL(tid, f ( tid, arg[2], arg[3], arg[4] ), (Addr)f )=
;
+ break;
+ }
+
+ // Nb: this looks like a circular definition, because it kind of i=
s.
+ // See comment in valgrind.h to understand what's going on.
+ case VG_USERREQ__RUNNING_ON_VALGRIND:
+ SET_CLREQ_RETVAL(tid, RUNNING_ON_VALGRIND+1);
+ break;
+
+ case VG_USERREQ__PRINTF: {
+ int count =3D=20
+ VG_(vmessage)( Vg_ClientMsg, (char *)arg[1], (void*)arg[2] )=
;
+ SET_CLREQ_RETVAL( tid, count );
+ break; }
+
+ case VG_USERREQ__INTERNAL_PRINTF: {
+ int count =3D=20
+ VG_(vmessage)( Vg_DebugMsg, (char *)arg[1], (void*)arg[2] );
+ SET_CLREQ_RETVAL( tid, count );
+ break; }
+
+ case VG_USERREQ__PRINTF_BACKTRACE: {
+ int count =3D
+ VG_(vmessage)( Vg_ClientMsg, (char *)arg[1], (void*)arg[2] )=
;
+ VG_(get_and_pp_StackTrace)( tid, VG_(clo_backtrace_size) );
+ SET_CLREQ_RETVAL( tid, count );
+ break; }
+
+ case VG_USERREQ__GET_MALLOCFUNCS: {
+ struct vg_mallocfunc_info *info =3D (struct vg_mallocfunc_info *)arg[1=
];
+
+ info->tl_malloc =3D VG_(tdict).malloc_malloc;
+ info->tl_calloc =3D VG_(tdict).malloc_calloc;
+ info->tl_realloc =3D VG_(tdict).malloc_realloc;
+ info->tl_memalign =3D VG_(tdict).malloc_memalign;
+ info->tl___builtin_new =3D VG_(tdict).malloc___builtin_new;
+ info->tl___builtin_vec_new =3D VG_(tdict).malloc___builtin_vec_new;
+ info->tl_free =3D VG_(tdict).malloc_free;
+ info->tl___builtin_delete =3D VG_(tdict).malloc___builtin_delete;
+ info->tl___builtin_vec_delete =3D VG_(tdict).malloc___builtin_vec_dele=
te;
+
+ info->arena_payload_szB =3D VG_(arena_payload_szB);
+ info->clo_trace_malloc =3D VG_(clo_trace_malloc);
+
+ SET_CLREQ_RETVAL( tid, 0 ); /* return value is meaningless =
*/
+
+ break;
+ }
+
+ /* Requests from the client program */
+
+ case VG_USERREQ__DISCARD_TRANSLATIONS:
+ if (VG_(clo_verbosity) > 2)
+ VG_(printf)( "client request: DISCARD_TRANSLATIONS,"
+ " addr %p, len %d\n",
+ (void*)arg[1], arg[2] );
+
+ VG_(discard_translations)( arg[1], arg[2] );
+
+ SET_CLREQ_RETVAL( tid, 0 ); /* return value is meaningless =
*/
+ break;
+
+ case VG_USERREQ__COUNT_ERRORS: =20
+ SET_CLREQ_RETVAL( tid, VG_(get_n_errs_found)() );
+ break;
+
+ default:
+ if (VGA_(client_request)(tid, arg)) {
+ /* architecture handled the client request */
+ } else if (VG_(needs).client_requests) {
+ UWord ret;
+
+ if (VG_(clo_verbosity) > 2)
+ VG_(printf)("client request: code %x, addr %p, len %d\n=
",
+ arg[0], (void*)arg[1], arg[2] );
+
+ if ( VG_TDICT_CALL(tool_handle_client_request, tid, arg, &ret) )
+ SET_CLREQ_RETVAL(tid, ret);
+ } else {
+ static Bool whined =3D False;
+
+ if (!whined && VG_(clo_verbosity) > 2) {
+ // Allow for requests in core, but defined by tools, whic=
h
+ // have 0 and 0 in their two high bytes.
+ Char c1 =3D (arg[0] >> 24) & 0xff;
+ Char c2 =3D (arg[0] >> 16) & 0xff;
+ if (c1 =3D=3D 0) c1 =3D '_';
+ if (c2 =3D=3D 0) c2 =3D '_';
+ VG_(message)(Vg_UserMsg, "Warning:\n"
+ " unhandled client request: 0x%x (%c%c+0x%x). Perha=
ps\n"=20
+ " VG_(needs).client_requests should be set?\n",
+ arg[0], c1, c2, arg[0] & 0xffff);
+ whined =3D True;
+ }
+ }
+ break;
+ }
+}
+
+
+/* ---------------------------------------------------------------------
+ Sanity checking.
+ ------------------------------------------------------------------ */
+
+/* Internal consistency checks on the sched structures. */
+static
+void scheduler_sanity ( ThreadId tid )
+{
+ Bool bad =3D False;
+
+ if (!VG_(is_running_thread)(tid)) {
+ VG_(message)(Vg_DebugMsg,
+ "Thread %d is supposed to be running, but doesn't own run_sema (own=
ed by %d)\n",=20
+ tid, running_tid);
+ bad =3D True;
+ }
+
+ if (VG_(gettid)() !=3D VG_(threads)[tid].os_state.lwpid) {
+ VG_(message)(Vg_DebugMsg,
+ "Thread %d supposed to be in LWP %d, but we're actual=
ly %d\n",
+ tid, VG_(threads)[tid].os_state.lwpid, VG_(gettid)())=
;
+ bad =3D True;
+ }
+}
+
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Copied: trunk/coregrind/m_scheduler/sema.c (from rev 3816, trunk/coregrin=
d/linux/sema.c)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/sema.c 2005-05-30 21:44:08 UTC (rev 3816)
+++ trunk/coregrind/m_scheduler/sema.c 2005-05-30 23:20:51 UTC (rev 3817)
@@ -0,0 +1,97 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Semaphore stuff. sema.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include "core.h"
+#include "priv_sema.h"
+
+/*=20
+ Slower (than the removed futex-based sema scheme) but more portable
+ pipe-based token passing scheme.
+ */
+
+void VG_(sema_init)(vg_sema_t *sema)
+{
+ VG_(pipe)(sema->pipe);
+ sema->pipe[0] =3D VG_(safe_fd)(sema->pipe[0]);
+ sema->pipe[1] =3D VG_(safe_fd)(sema->pipe[1]);
+
+ sema->owner_thread =3D -1;
+
+ /* create initial token */
+ VG_(write)(sema->pipe[1], "T", 1);
+}
+
+void VG_(sema_deinit)(vg_sema_t *sema)
+{
+ VG_(close)(sema->pipe[0]);
+ VG_(close)(sema->pipe[1]);
+ sema->pipe[0] =3D sema->pipe[1] =3D -1;
+}
+
+/* get a token */
+void VG_(sema_down)(vg_sema_t *sema)
+{
+ Char buf[2] =3D { 'x' };
+ Int ret;
+ Int lwpid =3D VG_(gettid)();
+
+ vg_assert(sema->owner_thread !=3D lwpid); /* can't have it already */
+
+ again:
+ ret =3D VG_(read)(sema->pipe[0], buf, 2);
+
+ if (ret =3D=3D -VKI_EINTR)
+ goto again;
+
+ vg_assert(ret =3D=3D 1); /* should get exactly 1 token */
+ vg_assert(buf[0] =3D=3D 'T');
+
+ sema->owner_thread =3D lwpid;
+}
+
+/* put token back */
+void VG_(sema_up)(vg_sema_t *sema)
+{
+ Int ret;
+
+ vg_assert(sema->owner_thread =3D=3D VG_(gettid)()); /* must have it *=
/
+
+ sema->owner_thread =3D 0;...
[truncated message content] |
|
From: Robert W. <rj...@du...> - 2005-05-30 22:11:32
|
> Oh, yes, you'd have to expose VG_(handle_stack_new) to the client.=20 > Scratch that, then. Fair enough. Thanks for the feedback. Regards, Robert. --=20 Robert Walsh Amalgamated Durables, Inc. - "We don't make the things you buy." Email: rj...@du... |
|
From: Nicholas N. <nj...@cs...> - 2005-05-30 22:10:55
|
On Mon, 30 May 2005, Robert Walsh wrote:
>> Another comment: you've introduced new VG_USERREQ__* constants. These
>> could be avoided by using the VG_USERREQ__CLIENT_CALL* constants to call
>> VG_(handle_stack_new)() and the other functions.
>
> That would be nice. How does one use these, exactly? I can't find
> anything that currently uses them to use as an example. It looks like
> it should be something like this:
>
> #define VALGRIND_STACK_REGISTER(start, end) \
> VALGRIND_NON_SIMD_CALL2(VG_(handle_stack_new), start, end)
>
> But wouldn't that mean having to expose the VG_(...) stuff into user
> land, or something? I'm a little confused by these, I guess.
Oh, yes, you'd have to expose VG_(handle_stack_new) to the client.
Scratch that, then.
>> The functions would have
>> to take a ThreadId as their first arg, but that's not difficult.
>
> Really? I don't see that in the code anywhere:
>
> case VG_USERREQ__CLIENT_CALL2: {
> UWord (*f)(UWord, UWord) = (void*)arg[1];
> if (f == NULL)
> VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL2: func=%p\n", f);
> else
> SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3] ), (Addr)f );
> break;
> }
>
> The function is invoked only with the args passed into the client
> request.
It's a 2.4 --> 3.0 change.
Nick
|
|
From: Josef W. <Jos...@gm...> - 2005-05-30 22:03:01
|
Hi, I have a question on Valgrind scheduling (I have a bug here in my tool): as callgrind has "shadow" call stacks for each thread, it always needs to know which thread currently is running. Usually, this is no problem with VG_(track_thread_run). I also track signal handlers. And these can switch the running thread. VG_(track_thread_run) is not called directly after a signal handlers return. So the question is, what thread is resumed when a signal handler returns? Do I have to track this myself? And if, how to do this? Can there be a thread switch while a signal handler is running? Thanks for any answer; I somehow can see the solution from Valgrinds source. Josef |
|
From: <sv...@va...> - 2005-05-30 21:44:13
|
Author: sewardj
Date: 2005-05-30 22:44:08 +0100 (Mon, 30 May 2005)
New Revision: 3816
Modified:
trunk/coregrind/core.h
trunk/coregrind/linux/core_os.c
trunk/coregrind/m_syscalls/syscalls-x86-linux.c
trunk/coregrind/m_syscalls/syscalls.c
trunk/coregrind/vg_main.c
trunk/coregrind/vg_scheduler.c
trunk/coregrind/vg_signals.c
trunk/include/vki-linux.h
Log:
Change the way thread termination is handled. Until now, there has
been a concept of a 'master thread'. This is the first thread in the
process. There was special logic which kept the master thread alive
artificially should it attempt to exit before its children. So the
master would wait for all children to exit and then exit itself, in
the process emitting the final summary of errors, leaks, etc.
This has the advantage that any process waiting on this one will see
the final summaries appearing before its sys_wait call returns. In
other words, the final summary output is synchronous with the
master-thread exiting.
Unfortunately the master-thread idea has a serious drawback, namely
that it can and sometimes does cause threaded programs to deadlock at
exit. It introduces an artificial dependency which is that the master
thread cannot really exit until all its children have exited. If --
by any means at all -- the children are waiting for the master to exit
before exiting themselves, deadlock results. There are now two known
examples of such deadlocks.
This commit removes the master thread concept and lets threads exit in
the order which they would have exited without Valgrind's involvement.
The last thread to exit prints the final summaries. This has the
disadvantage that final output may appear arbitrarily later relative
to the exit of the initial thread. Whether this is a problem in
practice remains to be seen.
As a minor side effect of this change, some functions have had
_NORETURN added to their names. Such functions do not return. The
thread in which they execute is guaranteed to exit before they return.
This makes the logic somewhat easier to follow.
amd64 compilation is now broken. I will fix it shortly.
Modified: trunk/coregrind/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/core.h 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/coregrind/core.h 2005-05-30 21:44:08 UTC (rev 3816)
@@ -345,7 +345,10 @@
=20
// Do everything which needs doing before the process finally ends,
// like printing reports, etc
-extern void VG_(shutdown_actions)(ThreadId tid);
+extern void VG_(shutdown_actions_NORETURN) (
+ ThreadId tid,=20
+ VgSchedReturnCode tids_schedretcode=20
+ );
=20
extern void VG_(scheduler_init) ( void );
=20
@@ -524,12 +527,6 @@
Char* VG_(build_child_VALGRINDCLO) ( Char* exename );
Char* VG_(build_child_exename) ( void );
=20
-/* The master thread the one which will be responsible for mopping
- everything up at exit. Normally it is tid 1, since that's the
- first thread created, but it may be something else after a
- fork(). */
-extern ThreadId VG_(master_tid);
-
/* Called when some unhandleable client behaviour is detected.
Prints a msg and aborts. */
extern void VG_(unimplemented) ( Char* msg )
@@ -608,21 +605,23 @@
/*MOD*/ ThreadArchState* arch );
=20
// OS/Platform-specific thread clear (after thread exit)
-extern void VGA_(os_state_clear)(ThreadState *);
+extern void VGO_(os_state_clear)(ThreadState *);
=20
// OS/Platform-specific thread init (at scheduler init time)
-extern void VGA_(os_state_init)(ThreadState *);
+extern void VGO_(os_state_init)(ThreadState *);
=20
-// Run a thread from beginning to end. Does not return if tid =3D=3D VG=
_(master_tid).
-void VGA_(thread_wrapper)(Word /*ThreadId*/ tid);
+// Run a thread from beginning to end.=20
+extern VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tid);
=20
-// Like VGA_(thread_wrapper), but it allocates a stack before calling
-// to VGA_(thread_wrapper) on that stack, as if it had been set up by
-// clone()
-void VGA_(main_thread_wrapper)(ThreadId tid) __attribute__ ((__noreturn_=
_));
+// Call here to exit the entire Valgrind system.
+extern void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src=
);
=20
+// Allocates a stack for the first thread, then runs it,
+// as if the thread had been set up by clone()
+extern void VGP_(main_thread_wrapper_NORETURN)(ThreadId tid);
+
// Return how many bytes of a thread's Valgrind stack are unused
-SSizeT VGA_(stack_unused)(ThreadId tid);
+extern SSizeT VGA_(stack_unused)(ThreadId tid);
=20
// wait until all other threads are dead
extern void VGA_(reap_threads)(ThreadId self);
Modified: trunk/coregrind/linux/core_os.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/linux/core_os.c 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/coregrind/linux/core_os.c 2005-05-30 21:44:08 UTC (rev 3816)
@@ -29,26 +29,37 @@
*/
=20
#include "core.h"
+#include "pub_core_debuglog.h"
#include "pub_core_options.h"
#include "pub_core_tooliface.h"
=20
-void VGA_(os_state_clear)(ThreadState *tst)
+void VGO_(os_state_clear)(ThreadState *tst)
{
tst->os_state.lwpid =3D 0;
tst->os_state.threadgroup =3D 0;
}
=20
-void VGA_(os_state_init)(ThreadState *tst)
+void VGO_(os_state_init)(ThreadState *tst)
{
tst->os_state.valgrind_stack_base =3D 0;
tst->os_state.valgrind_stack_szB =3D 0;
=20
- VGA_(os_state_clear)(tst);
+ VGO_(os_state_clear)(tst);
}
=20
-static void terminate(ThreadId tid, VgSchedReturnCode src)
+static Bool i_am_the_only_thread ( void )
{
- vg_assert(tid =3D=3D VG_(master_tid));
+ Int c =3D VG_(count_living_threads)();
+ vg_assert(c >=3D 1); /* stay sane */
+ return c =3D=3D 1;
+}
+
+
+void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src)
+{
+ VG_(debugLog)(1, "core_os",=20
+ "VGO_(terminate_NORETURN)(tid=3D%lld)\n", (ULong)tid=
);
+
vg_assert(VG_(count_living_threads)() =3D=3D 0);
=20
//--------------------------------------------------------------
@@ -56,15 +67,15 @@
//--------------------------------------------------------------
switch (src) {
case VgSrc_ExitSyscall: /* the normal way out */
- VG_(exit)( VG_(threads)[VG_(master_tid)].os_state.exitcode );
+ VG_(exit)( VG_(threads)[tid].os_state.exitcode );
/* NOT ALIVE HERE! */
VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
break; /* what the hell :) */
=20
case VgSrc_FatalSig:
/* We were killed by a fatal signal, so replicate the effect */
- vg_assert(VG_(threads)[VG_(master_tid)].os_state.fatalsig !=3D 0);
- VG_(kill_self)(VG_(threads)[VG_(master_tid)].os_state.fatalsig);
+ vg_assert(VG_(threads)[tid].os_state.fatalsig !=3D 0);
+ VG_(kill_self)(VG_(threads)[tid].os_state.fatalsig);
VG_(core_panic)("main(): signal was supposed to be fatal");
break;
=20
@@ -73,9 +84,16 @@
}
}
=20
-/* Run a thread from beginning to end. Does not return. */
-void VGA_(thread_wrapper)(Word /*ThreadId*/ tidW)
+
+/* Run a thread from beginning to end and return the thread's
+ scheduler-return-code. */
+
+VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tidW)
{
+ VG_(debugLog)(1, "core_os",=20
+ "VGO_(thread_wrapper)(tid=3D%lld): entry\n",=20
+ (ULong)tidW);
+
VgSchedReturnCode ret;
ThreadId tid =3D (ThreadId)tidW;
ThreadState* tst =3D VG_(get_ThreadState)(tid);
@@ -103,81 +121,26 @@
=20
vg_assert(tst->status =3D=3D VgTs_Runnable);
vg_assert(VG_(is_running_thread)(tid));
- =20
- if (tid =3D=3D VG_(master_tid)) {
- VG_(shutdown_actions)(tid);
- terminate(tid, ret);
- }
-}
=20
-/* wait until all other threads are dead */
-static Bool alldead(void *v)
-{
- /* master_tid must be alive... */
- Int c =3D VG_(count_living_threads)();
- //VG_(printf)("alldead: count=3D%d\n", c);
- return c <=3D 1;
-}
+ VG_(debugLog)(1, "core_os",=20
+ "VGO_(thread_wrapper)(tid=3D%lld): done\n",=20
+ (ULong)tidW);
=20
-static void sigvgchld_handler(Int sig)
-{
- VG_(printf)("got a sigvgchld?\n");
+ /* Return to caller, still holding the lock. */
+ return ret;
}
=20
-/*=20
- Wait until some predicate about threadstates is satisfied.
=20
- This uses SIGVGCHLD as a notification that it is now worth
- re-evaluating the predicate.
- */
-static void wait_for_threadstate(Bool (*pred)(void *), void *arg)
+/* Wait until all other threads disappear. */
+void VGA_(reap_threads)(ThreadId self)
{
- vki_sigset_t set, saved;
- struct vki_sigaction sa, old_sa;
-
- /*=20
- SIGVGCHLD is set to be ignored, and is unblocked by default.
- This means all such signals are simply discarded.
-
- In this loop, we actually block it, and then poll for it with
- sigtimedwait.
- */
- VG_(sigemptyset)(&set);
- VG_(sigaddset)(&set, VKI_SIGVGCHLD);
-
- VG_(set_sleeping)(VG_(master_tid), VgTs_Yielding);
- VG_(sigprocmask)(VKI_SIG_BLOCK, &set, &saved);
-
- /* It shouldn't be necessary to set a handler, since the signal is
- always blocked, but it seems to be necessary to convice the
- kernel not to just toss the signal... */
- sa.ksa_handler =3D sigvgchld_handler;
- sa.sa_flags =3D 0;
- VG_(sigfillset)(&sa.sa_mask);
- VG_(sigaction)(VKI_SIGVGCHLD, &sa, &old_sa);
-
- vg_assert(old_sa.ksa_handler =3D=3D VKI_SIG_IGN);
-
- while(!(*pred)(arg)) {
- struct vki_siginfo si;
- Int ret =3D VG_(sigtimedwait)(&set, &si, NULL);
-
- if (ret > 0 && VG_(clo_trace_signals))
- VG_(message)(Vg_DebugMsg, "Got %d (code=3D%d) from tid lwp %d",
- ret, si.si_code, si._sifields._kill._pid);
+ while (!i_am_the_only_thread()) {
+ /* Let other thread(s) run */
+ VG_(vg_yield)();
}
-
- VG_(sigaction)(VKI_SIGVGCHLD, &old_sa, NULL);
- VG_(sigprocmask)(VKI_SIG_SETMASK, &saved, NULL);
- VG_(set_running)(VG_(master_tid));
+ vg_assert(i_am_the_only_thread());
}
=20
-void VGA_(reap_threads)(ThreadId self)
-{
- vg_assert(self =3D=3D VG_(master_tid));
- wait_for_threadstate(alldead, NULL);
-}
-
/* The we need to know the address of it so it can be
called at program exit. */
static Addr __libc_freeres_wrapper;
Modified: trunk/coregrind/m_syscalls/syscalls-x86-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls-x86-linux.c 2005-05-30 03:12:09 U=
TC (rev 3815)
+++ trunk/coregrind/m_syscalls/syscalls-x86-linux.c 2005-05-30 21:44:08 U=
TC (rev 3816)
@@ -35,6 +35,7 @@
=20
#include "core.h"
#include "ume.h" /* for jmp_with_stack */
+#include "pub_core_debuglog.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_sigframe.h"
#include "pub_core_syscalls.h"
@@ -244,64 +245,116 @@
return ((Addr)p) - tst->os_state.valgrind_stack_base;
}
=20
-/*
- Allocate a stack for the main thread, and call VGA_(thread_wrapper)
- on that stack.
- */
-void VGA_(main_thread_wrapper)(ThreadId tid)
+
+/* Run a thread all the way to the end, then do appropriate exit actions
+ (this is the last-one-out-turn-off-the-lights bit).=20
+*/
+static void run_a_thread_NORETURN ( Word tidW )
{
- UWord* esp =3D allocstack(tid);
+ ThreadId tid =3D (ThreadId)tidW;
=20
- vg_assert(tid =3D=3D VG_(master_tid));
+ VG_(debugLog)(1, "syscalls-x86-linux",=20
+ "run_a_thread_NORETURN(tid=3D%lld): "
+ "VGO_(thread_wrapper) called\n",
+ (ULong)tidW);
=20
- call_on_new_stack_0_1(=20
- (Addr)esp, /* stack */
- 0, /*bogus return address*/
- VGA_(thread_wrapper), /* fn to call */
- (Word)tid /* arg to give it */
- );
+ /* Run the thread all the way through. */
+ VgSchedReturnCode src =3D VGO_(thread_wrapper)(tid); =20
=20
+ VG_(debugLog)(1, "syscalls-x86-linux",=20
+ "run_a_thread_NORETURN(tid=3D%lld): "
+ "VGO_(thread_wrapper) done\n",
+ (ULong)tidW);
+
+ Int c =3D VG_(count_living_threads)();
+ vg_assert(c >=3D 1); /* stay sane */
+
+ if (c =3D=3D 1) {
+
+ VG_(debugLog)(1, "syscalls-x86-linux",=20
+ "run_a_thread_NORETURN(tid=3D%lld): "
+ "last one standing\n",
+ (ULong)tidW);
+
+ /* We are the last one standing. Keep hold of the lock and
+ carry on to show final tool results, then exit the entire syste=
m. */
+ VG_(shutdown_actions_NORETURN)(tid, src);
+
+ } else {
+
+ VG_(debugLog)(1, "syscalls-x86-linux",=20
+ "run_a_thread_NORETURN(tid=3D%lld): "
+ "not last one standing\n",
+ (ULong)tidW);
+
+ /* OK, thread is dead, but others still exist. Just exit. */
+ ThreadState *tst =3D VG_(get_ThreadState)(tid);
+
+ /* This releases the run lock */
+ VG_(exit_thread)(tid);
+ vg_assert(tst->status =3D=3D VgTs_Zombie);
+
+ /* We have to use this sequence to terminate the thread to
+ prevent a subtle race. If VG_(exit_thread)() had left the
+ ThreadState as Empty, then it could have been reallocated,
+ reusing the stack while we're doing these last cleanups.
+ Instead, VG_(exit_thread) leaves it as Zombie to prevent
+ reallocation. We need to make sure we don't touch the stack
+ between marking it Empty and exiting. Hence the
+ assembler. */
+ asm volatile (
+ "movl %1, %0\n" /* set tst->status =3D VgTs_Empty */
+ "movl %2, %%eax\n" /* set %eax =3D __NR_exit */
+ "movl %3, %%ebx\n" /* set %ebx =3D tst->os_state.exitcode */
+ "int $0x80\n" /* exit(tst->os_state.exitcode) */
+ : "=3Dm" (tst->status)
+ : "n" (VgTs_Empty), "n" (__NR_exit), "m" (tst->os_state.exitcod=
e));
+
+ VG_(core_panic)("Thread exit failed?\n");
+ }
+
/*NOTREACHED*/
vg_assert(0);
}
=20
-static Int start_thread(void *arg)
+
+/*
+ Allocate a stack for the main thread, and run it all the way to the
+ end. =20
+*/
+void VGP_(main_thread_wrapper_NORETURN)(ThreadId tid)
{
- ThreadState *tst =3D (ThreadState *)arg;
- ThreadId tid =3D tst->tid;
+ VG_(debugLog)(1, "syscalls-x86-linux",=20
+ "entering VGP_(main_thread_wrapper_NORETURN)\n");
=20
- VGA_(thread_wrapper)(tid);
+ UWord* esp =3D allocstack(tid);
=20
- /* OK, thread is dead; this releases the run lock */
- VG_(exit_thread)(tid);
+ /* shouldn't be any other threads around yet */
+ vg_assert( VG_(count_living_threads)() =3D=3D 1 );
=20
- vg_assert(tst->status =3D=3D VgTs_Zombie);
+ call_on_new_stack_0_1(=20
+ (Addr)esp, /* stack */
+ 0, /*bogus return address*/
+ run_a_thread_NORETURN, /* fn to call */
+ (Word)tid /* arg to give it */
+ );
=20
- /* Poke the reaper */
- if (VG_(clo_trace_signals))
- VG_(message)(Vg_DebugMsg, "Sending SIGVGCHLD to master tid=3D%d lw=
p=3D%d",=20
- VG_(master_tid), VG_(threads)[VG_(master_tid)].os_state.lwpid);
+ /*NOTREACHED*/
+ vg_assert(0);
+}
=20
- VG_(tkill)(VG_(threads)[VG_(master_tid)].os_state.lwpid, VKI_SIGVGCHL=
D);
=20
- /* We have to use this sequence to terminate the thread to prevent
- a subtle race. If VG_(exit_thread)() had left the ThreadState
- as Empty, then it could have been reallocated, reusing the stack
- while we're doing these last cleanups. Instead,
- VG_(exit_thread) leaves it as Zombie to prevent reallocation.
- We need to make sure we don't touch the stack between marking it
- Empty and exiting. Hence the assembler. */
- asm volatile (
- "movl %1, %0\n" /* set tst->status =3D VgTs_Empty */
- "movl %2, %%eax\n" /* set %eax =3D __NR_exit */
- "movl %3, %%ebx\n" /* set %ebx =3D tst->os_state.exitcode */
- "int $0x80\n" /* exit(tst->os_state.exitcode) */
- : "=3Dm" (tst->status)
- : "n" (VgTs_Empty), "n" (__NR_exit), "m" (tst->os_state.exitcode))=
;
+static Int start_thread_NORETURN ( void* arg )
+{
+ ThreadState* tst =3D (ThreadState*)arg;
+ ThreadId tid =3D tst->tid;
=20
- VG_(core_panic)("Thread exit failed?\n");
+ run_a_thread_NORETURN ( (Word)tid );
+ /*NOTREACHED*/
+ vg_assert(0);
}
=20
+
/* ---------------------------------------------------------------------
clone() handling
------------------------------------------------------------------ */
@@ -404,7 +457,7 @@
VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask);
=20
/* Create the new thread */
- ret =3D VG_(clone)(start_thread, stack, flags, &VG_(threads)[ctid],
+ ret =3D VG_(clone)(start_thread_NORETURN, stack, flags, &VG_(threads)=
[ctid],
child_tidptr, parent_tidptr, NULL);
=20
VG_(sigprocmask)(VKI_SIG_SETMASK, &savedmask, NULL);
@@ -1470,7 +1523,7 @@
GENX_(__NR_chroot, sys_chroot), // 61
// (__NR_ustat, sys_ustat) // 62 SVr4 -- depr=
ecated
GENXY(__NR_dup2, sys_dup2), // 63
- GENXY(__NR_getppid, sys_getppid), // 64
+ GENX_(__NR_getppid, sys_getppid), // 64
=20
GENX_(__NR_getpgrp, sys_getpgrp), // 65
GENX_(__NR_setsid, sys_setsid), // 66
Modified: trunk/coregrind/m_syscalls/syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 03:12:09 UTC (rev 38=
15)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 21:44:08 UTC (rev 38=
16)
@@ -2345,29 +2345,19 @@
/* Resistance is futile. Nuke all other threads. POSIX mandates
this. (Really, nuke them all, since the new process will make
its own new thread.) */
- VG_(master_tid) =3D tid; /* become the master */
VG_(nuke_all_threads_except)( tid, VgSrc_ExitSyscall );
VGA_(reap_threads)(tid);
=20
- if (0) {
- /* Shut down cleanly and report final state
- XXX Is this reasonable? */
- tst->exitreason =3D VgSrc_ExitSyscall;
- VG_(shutdown_actions)(tid);
+ { // Remove the valgrind-specific stuff from the environment so the
+ // child doesn't get vg_inject.so, vgpreload.so, etc. This is
+ // done unconditionally, since if we are tracing the child,
+ // stage1/2 will set up the appropriate client environment.
+ Char** envp =3D (Char**)ARG3;
+ if (envp !=3D NULL) {
+ VG_(env_remove_valgrind_env_stuff)( envp );
+ }
}
=20
- {
- // Remove the valgrind-specific stuff from the environment so the
- // child doesn't get vg_inject.so, vgpreload.so, etc. This is
- // done unconditionally, since if we are tracing the child,
- // stage1/2 will set up the appropriate client environment.
- Char** envp =3D (Char**)ARG3;
-
- if (envp !=3D NULL) {
- VG_(env_remove_valgrind_env_stuff)( envp );
- }
- }
-
if (VG_(clo_trace_children)) {
Char* optvar =3D VG_(build_child_VALGRINDCLO)( (Char*)ARG1 );
=20
@@ -2952,16 +2942,6 @@
PRE_REG_READ0(long, "getppid");
}
=20
-POST(sys_getppid)
-{
- /* If the master thread has already exited, and it is this thread's
- parent, then force getppid to return 1 (init) rather than the
- real ppid, so that it thinks its parent has exited. */
- if (VG_(threads)[VG_(master_tid)].os_state.lwpid =3D=3D RES &&
- VG_(is_exiting)(VG_(master_tid)))
- RES =3D 1;
-}
-
static void common_post_getrlimit(ThreadId tid, UWord a1, UWord a2)
{
POST_MEM_WRITE( a2, sizeof(struct vki_rlimit) );
@@ -6068,15 +6048,6 @@
VG_(sigdelset)(mask, VKI_SIGSTOP);
=20
VG_(sigdelset)(mask, VKI_SIGVGKILL); /* never block */
-
- /* SIGVGCHLD is used by threads to indicate their state changes to
- the master thread. Mostly it doesn't care, so it leaves the
- signal ignored and unblocked. Everyone else should have it
- blocked, so there's at most 1 thread with it unblocked. */
- if (tid =3D=3D VG_(master_tid))
- VG_(sigdelset)(mask, VKI_SIGVGCHLD);
- else
- VG_(sigaddset)(mask, VKI_SIGVGCHLD);
}
=20
void VG_(client_syscall) ( ThreadId tid )
Modified: trunk/coregrind/vg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_main.c 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/coregrind/vg_main.c 2005-05-30 21:44:08 UTC (rev 3816)
@@ -137,12 +137,6 @@
static Int vg_argc;
static Char **vg_argv;
=20
-/* The master thread the one which will be responsible for mopping
- everything up at exit. Normally it is tid 1, since that's the
- first thread created, but it may be something else after a
- fork(). */
-ThreadId VG_(master_tid) =3D VG_INVALID_THREADID;
-
/* Application-visible file descriptor limits */
Int VG_(fd_soft_limit) =3D -1;
Int VG_(fd_hard_limit) =3D -1;
@@ -2817,24 +2811,29 @@
//--------------------------------------------------------------
VGP_POPCC(VgpStartup);
=20
- vg_assert(VG_(master_tid) =3D=3D 1);
-
if (VG_(clo_xml)) {
VG_(message)(Vg_UserMsg, "<status>RUNNING</status>");
VG_(message)(Vg_UserMsg, "");
}
=20
VG_(debugLog)(1, "main", "Running thread 1\n");
- VGA_(main_thread_wrapper)(1);
+ /* As a result of the following call, the last thread standing
+ eventually winds up running VG_(shutdown_actions_NORETURN) just
+ below. */
+ VGP_(main_thread_wrapper_NORETURN)(1);
=20
- abort();
+ /*NOTREACHED*/
+ vg_assert(0);
}
=20
=20
/* Do everything which needs doing when the last thread exits */
-void VG_(shutdown_actions)(ThreadId tid)
+void VG_(shutdown_actions_NORETURN) ( ThreadId tid,=20
+ VgSchedReturnCode tids_schedretcod=
e )
{
- vg_assert(tid =3D=3D VG_(master_tid));
+ VG_(debugLog)(1, "main", "entering VG_(shutdown_actions_NORETURN)\n")=
;
+
+ vg_assert( VG_(count_living_threads)() =3D=3D 1 );
vg_assert(VG_(is_running_thread)(tid));
=20
// Wait for all other threads to exit.
@@ -2896,6 +2895,12 @@
/* Print Vex storage stats */
if (0)
LibVEX_ShowAllocStats();
+
+ /* Ok, finally exit in the os-specific way. In short, if the
+ (last) thread exited by calling sys_exit, do likewise; if the
+ (last) thread stopped due to a fatal signal, terminate the
+ entire system with that same fatal signal. */
+ VGO_(terminate_NORETURN)( tid, tids_schedretcode );
}
=20
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/vg_scheduler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_scheduler.c 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/coregrind/vg_scheduler.c 2005-05-30 21:44:08 UTC (rev 3816)
@@ -439,10 +439,6 @@
VG_(sigdelset)(&mask, VKI_SIGSTOP);
VG_(sigdelset)(&mask, VKI_SIGKILL);
=20
- /* Master doesn't block this */
- if (tid =3D=3D VG_(master_tid))
- VG_(sigdelset)(&mask, VKI_SIGVGCHLD);
-
VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
}
=20
@@ -566,7 +562,7 @@
VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
VG_(sigemptyset)(&VG_(threads)[tid].tmp_sig_mask);
=20
- VGA_(os_state_clear)(&VG_(threads)[tid]);
+ VGO_(os_state_clear)(&VG_(threads)[tid]);
=20
/* start with no altstack */
VG_(threads)[tid].altstack.ss_sp =3D (void *)0xdeadbeef;
@@ -600,8 +596,6 @@
ThreadId tid;
vg_assert(running_tid =3D=3D me);
=20
- VG_(master_tid) =3D me;
-
VG_(threads)[me].os_state.lwpid =3D VG_(gettid)();
VG_(threads)[me].os_state.threadgroup =3D VG_(getpid)();
=20
@@ -635,7 +629,7 @@
for (i =3D 0 /* NB; not 1 */; i < VG_N_THREADS; i++) {
VG_(threads)[i].sig_queue =3D NULL;
=20
- VGA_(os_state_init)(&VG_(threads)[i]);
+ VGO_(os_state_init)(&VG_(threads)[i]);
mostly_clear_thread_record(i);
=20
VG_(threads)[i].status =3D VgTs_Empty;
@@ -645,8 +639,6 @@
=20
tid_main =3D VG_(alloc_ThreadState)();
=20
- VG_(master_tid) =3D tid_main;
-
/* Initial thread's stack is the original process stack */
VG_(threads)[tid_main].client_stack_highest_word=20
=3D VG_(clstk_end) - sizeof(=
UWord);
Modified: trunk/coregrind/vg_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_signals.c 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/coregrind/vg_signals.c 2005-05-30 21:44:08 UTC (rev 3816)
@@ -303,8 +303,6 @@
// cases in the switch, so we handle them in the 'default' case=
.
if (sig =3D=3D VKI_SIGVGKILL)
skss_handler =3D sigvgkill_handler;
- else if (sig =3D=3D VKI_SIGVGCHLD)
- skss_handler =3D VKI_SIG_IGN; /* we only poll for it */
else {
if (scss_handler =3D=3D VKI_SIG_IGN)
skss_handler =3D VKI_SIG_IGN;
@@ -1358,7 +1356,8 @@
#endif
=20
/* stash fatal signal in main thread */
- VG_(threads)[VG_(master_tid)].os_state.fatalsig =3D sigNo;
+ // what's this for?
+ //VG_(threads)[VG_(master_tid)].os_state.fatalsig =3D sigNo;
=20
/* everyone dies */
VG_(nuke_all_threads_except)(tid, VgSrc_FatalSig);
@@ -1884,8 +1883,10 @@
if (0)
VG_(kill_self)(sigNo); /* generate a core dump */
=20
- if (tid =3D=3D 0) /* could happen after everyone has ex=
ited */
- tid =3D VG_(master_tid);
+ //if (tid =3D=3D 0) /* could happen after everyone has =
exited */
+ // tid =3D VG_(master_tid);
+ vg_assert(tid !=3D 0);
+
tst =3D VG_(get_ThreadState)(tid);
VG_(get_StackTrace2)(ips, VG_(clo_backtrace_size),=20
VGP_UCONTEXT_INSTR_PTR(uc),
@@ -1967,8 +1968,6 @@
for(i =3D 0; i < _VKI_NSIG_WORDS; i++)
pollset.sig[i] =3D ~tst->sig_mask.sig[i];
=20
- VG_(sigdelset)(&pollset, VKI_SIGVGCHLD); /* already dealt with */
-
//VG_(printf)("tid %d pollset=3D%08x%08x\n", tid, pollset.sig[1], pol=
lset.sig[0]);
=20
block_all_host_signals(&saved_mask); // protect signal queue
@@ -2063,19 +2062,18 @@
VG_(message)(Vg_DebugMsg, "Max kernel-supported signal is %d", VG_=
(max_signal));
=20
/* Our private internal signals are treated as ignored */
- scss.scss_per_sig[VKI_SIGVGCHLD].scss_handler =3D VKI_SIG_IGN;
- scss.scss_per_sig[VKI_SIGVGCHLD].scss_flags =3D VKI_SA_SIGINFO;
- VG_(sigfillset)(&scss.scss_per_sig[VKI_SIGVGCHLD].scss_mask);
-
scss.scss_per_sig[VKI_SIGVGKILL].scss_handler =3D VKI_SIG_IGN;
scss.scss_per_sig[VKI_SIGVGKILL].scss_flags =3D VKI_SA_SIGINFO;
VG_(sigfillset)(&scss.scss_per_sig[VKI_SIGVGKILL].scss_mask);
=20
/* Copy the process' signal mask into the root thread. */
- vg_assert(VG_(threads)[VG_(master_tid)].status =3D=3D VgTs_Init);
- VG_(threads)[VG_(master_tid)].sig_mask =3D saved_procmask;
- VG_(threads)[VG_(master_tid)].tmp_sig_mask =3D saved_procmask;
+ vg_assert(VG_(threads)[1].status =3D=3D VgTs_Init);
+ for (i =3D 2; i < VG_N_THREADS; i++)
+ vg_assert(VG_(threads)[i].status =3D=3D VgTs_Empty);
=20
+ VG_(threads)[1].sig_mask =3D saved_procmask;
+ VG_(threads)[1].tmp_sig_mask =3D saved_procmask;
+
/* Calculate SKSS and apply it. This also sets the initial kernel
mask we need to run with. */
handle_SCSS_change( True /* forced update */ );
Modified: trunk/include/vki-linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/vki-linux.h 2005-05-30 03:12:09 UTC (rev 3815)
+++ trunk/include/vki-linux.h 2005-05-30 21:44:08 UTC (rev 3816)
@@ -351,8 +351,7 @@
=20
/* Use high signals because native pthreads wants to use low */
#define VKI_SIGVGKILL (VG_(max_signal)-0) // [[internal: kill]]
-#define VKI_SIGVGCHLD (VG_(max_signal)-1) // [[internal: thread de=
ath]]
-#define VKI_SIGVGRTUSERMAX (VG_(max_signal)-2) // [[internal: last user=
-usable RT signal]]
+#define VKI_SIGVGRTUSERMAX (VG_(max_signal)-1) // [[internal: last user=
-usable RT signal]]
=20
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/asm-generic/siginfo.h
|
|
From: Robert W. <rj...@du...> - 2005-05-30 21:42:00
|
> Another comment: you've introduced new VG_USERREQ__* constants. These=20
> could be avoided by using the VG_USERREQ__CLIENT_CALL* constants to call=20
> VG_(handle_stack_new)() and the other functions.
That would be nice. How does one use these, exactly? I can't find
anything that currently uses them to use as an example. It looks like
it should be something like this:
#define VALGRIND_STACK_REGISTER(start, end) \
VALGRIND_NON_SIMD_CALL2(VG_(handle_stack_new), start, end)
But wouldn't that mean having to expose the VG_(...) stuff into user
land, or something? I'm a little confused by these, I guess.
> The functions would have=20
> to take a ThreadId as their first arg, but that's not difficult.
Really? I don't see that in the code anywhere:
case VG_USERREQ__CLIENT_CALL2: {
UWord (*f)(UWord, UWord) =3D (void*)arg[1];
if (f =3D=3D NULL)
VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL2: func=3D%p\=
n", f);
else
SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3] ), (Addr)f );
break;
}
The function is invoked only with the args passed into the client
request.
Regards,
Robert.
--=20
Robert Walsh
Amalgamated Durables, Inc. - "We don't make the things you buy."
Email: rj...@du...
|
|
From: Robert W. <rj...@du...> - 2005-05-30 21:30:46
|
On Mon, 2005-05-30 at 14:41 -0500, Nicholas Nethercote wrote: > On Mon, 30 May 2005, Robert Walsh wrote: >=20 > > * id =3D VALGRIND_STACK_NEW(start, end) registers the memory betwe= en > > start and end as a new stack and returns an id you can use for > > the other client requests described below. This doesn't > > allocate memory or anything - it just records that a particular > > memory range is a stack. > > > > * VALGRIND_STACK_DELETE(id) removes the stack association for > > stack "id". This doesn't free memory or anything - it just > > tells Valgrind that the piece of memory register earlier is no > > longer a stack. >=20 > Perhaps VALGRIND_STACK_REGISTER and VALGRIND_STACK_DEREGISTER would be=20 > better names? You'd avoid the confusion with memory allocation. Yes. I'll do that. Regards, Robert. --=20 Robert Walsh Amalgamated Durables, Inc. - "We don't make the things you buy." Email: rj...@du... |
|
From: Nicholas N. <nj...@cs...> - 2005-05-30 19:46:42
|
On Mon, 30 May 2005, Robert Walsh wrote: > Hi all, > > I've put a new patch on my web site against the 2.4 tree: > > http://www.durables.org/~rjwalsh/software/valgrind Another comment: you've introduced new VG_USERREQ__* constants. These could be avoided by using the VG_USERREQ__CLIENT_CALL* constants to call VG_(handle_stack_new)() and the other functions. The functions would have to take a ThreadId as their first arg, but that's not difficult. N |
|
From: Nicholas N. <nj...@cs...> - 2005-05-30 19:41:50
|
On Mon, 30 May 2005, Robert Walsh wrote: > * id = VALGRIND_STACK_NEW(start, end) registers the memory between > start and end as a new stack and returns an id you can use for > the other client requests described below. This doesn't > allocate memory or anything - it just records that a particular > memory range is a stack. > > * VALGRIND_STACK_DELETE(id) removes the stack association for > stack "id". This doesn't free memory or anything - it just > tells Valgrind that the piece of memory register earlier is no > longer a stack. Perhaps VALGRIND_STACK_REGISTER and VALGRIND_STACK_DEREGISTER would be better names? You'd avoid the confusion with memory allocation. N |
|
From: Mark A. <ma...@al...> - 2005-05-30 19:23:46
|
On May 30, 2005, at 12:26 AM, Julian Seward wrote:
> Mark, could you explain how the use of uninitialised values from memory
> is made safe here? I'm looking at this
>
> do {
> } while (*++scan == *++match && *++scan == *++match &&
> *++scan == *++match && *++scan == *++match &&
> *++scan == *++match && *++scan == *++match &&
> *++scan == *++match && *++scan == *++match &&
> scan < strend);
>
> and it's not clear how scan can be moved forward some indeterminate
> amount based on garbage in memory and yet the deflate result is
> well-defined.
The output of the loop is where the first mismatch is (scan). If
uninitialized data is accessed in the process, then all of the
initialized data matched, and maybe some of the uninitialized data as
well. Later the length of the match is truncated to the length of the
initialized data, so it doesn't matter how far into the uninitialized
data the loop progressed.
This line limits nice_match to be no longer than the uninitialized data:
if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
This line exits the longest match search loop if a match that long is
found (or longer if some uninitialized data matched):
if (len >= nice_match) break;
And these lines return a match length limited to the length of the
initialized data:
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
return s->lookahead;
> An ideal outcome is that Mark explains how this behaviour
> is safe in zlib. I can then look at Memcheck's instrumentation
> phase to determine if/how it is possible to avoid these
> reports.
valgrind would have to be pretty smart to figure out what s->lookahead
means, trace the values of nice_match, len, and best_len, and figure
out from all that that the uninitialized data didn't affect the return
value. The only semi-reasonable automatic process I could imagine
would be for valgrind to set the first unintialized byte to all 256
values, run the code each time, and see that the returned value is not
affected (as well as all the side effects of the routine on the state
structure). Then if another uninitialized byte is accessed, which it
will be for one of the previous uninitialized byte values, do that all
over again, and so on. Good luck.
mark
|
|
From: Robert W. <rj...@du...> - 2005-05-30 17:37:59
|
> I was wondering if you can simply use the --max-stackframe flag in > the 3 line to get the same result .. >=20 > > if delta %esp > some value, then assume a thread change >=20 > This allows you to set 'some value' on the command line. =20 > Furthermore if you don't do that it will tell you plausible > values to try anyway. >=20 > Could you try out --max-stackframe to see if it is good enough? I haven't tried this, but I'm fairly certain that it won't work in the case of the coroutine library we're using at work. We use lots of coroutines (thousands) each with a relatively small stack (1K, and maybe less when we get around to tuning it) that's allocated using malloc. They end up essentially being right next to each other in memory. The main CPU stack still needs to be able to handle big stack allocations, as it does all of the nasty GUI work, etc. when the coroutines are done. I like the idea of being able to have the client program explain where stacks are. For programs that don't do that, --max-stackframe is a good idea, but for programs that do, it means you don't have to have magic numbers on the command line or worry about different classes of stack (big v. small like we have.) Regards, Robert. --=20 Robert Walsh Amalgamated Durables, Inc. - "We don't make the things you buy." Email: rj...@du... |
|
From: <sv...@va...> - 2005-05-30 11:20:00
|
Author: sewardj
Date: 2005-05-30 12:19:54 +0100 (Mon, 30 May 2005)
New Revision: 1204
Modified:
trunk/priv/guest-x86/toIR.c
Log:
Apparently someone somewhere in some obscure library deep in the
basement of mozilla requires 'lods'.
Modified: trunk/priv/guest-x86/toIR.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-x86/toIR.c 2005-05-25 00:44:13 UTC (rev 1203)
+++ trunk/priv/guest-x86/toIR.c 2005-05-30 11:19:54 UTC (rev 1204)
@@ -3039,42 +3039,31 @@
void dis_MOVS ( Int sz, IRTemp t_inc )
{
IRType ty =3D szToITy(sz);
- //IRTemp tv =3D newTemp(ty); /* value being copied */
IRTemp td =3D newTemp(Ity_I32); /* EDI */
IRTemp ts =3D newTemp(Ity_I32); /* ESI */
=20
- //uInstr2(cb, GET, 4, ArchReg, R_EDI, TempReg, td);
- //uInstr2(cb, GET, 4, ArchReg, R_ESI, TempReg, ts);
assign( td, getIReg(4, R_EDI) );
assign( ts, getIReg(4, R_ESI) );
=20
- //uInstr2(cb, LOAD, sz, TempReg, ts, TempReg, tv);
- //uInstr2(cb, STORE,sz, TempReg, tv, TempReg, td);
storeLE( mkexpr(td), loadLE(ty,mkexpr(ts)) );
=20
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, td);
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, ts);
-
- //uInstr2(cb, PUT, 4, TempReg, td, ArchReg, R_EDI);
- //uInstr2(cb, PUT, 4, TempReg, ts, ArchReg, R_ESI);
putIReg( 4, R_EDI, binop(Iop_Add32, mkexpr(td), mkexpr(t_inc)) );
putIReg( 4, R_ESI, binop(Iop_Add32, mkexpr(ts), mkexpr(t_inc)) );
}
=20
-//-- static=20
-//-- void dis_LODS ( UCodeBlock* cb, Int sz, Int t_inc )
-//-- {
-//-- Int ta =3D newTemp(cb); /* EAX */
-//-- Int ts =3D newTemp(cb); /* ESI */
-//--=20
-//-- uInstr2(cb, GET, 4, ArchReg, R_ESI, TempReg, ts);
-//-- uInstr2(cb, LOAD, sz, TempReg, ts, TempReg, ta);
-//-- uInstr2(cb, PUT, sz, TempReg, ta, ArchReg, R_EAX);
-//--=20
-//-- uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, ts);
-//-- uInstr2(cb, PUT, 4, TempReg, ts, ArchReg, R_ESI);
-//-- }
+static=20
+void dis_LODS ( Int sz, IRTemp t_inc )
+{
+ IRType ty =3D szToITy(sz);
+ IRTemp ts =3D newTemp(Ity_I32); /* ESI */
=20
+ assign( ts, getIReg(4, R_ESI) );
+
+ putIReg( sz, R_EAX, loadLE(ty, mkexpr(ts)) );
+
+ putIReg( 4, R_ESI, binop(Iop_Add32, mkexpr(ts), mkexpr(t_inc)) );
+}
+
static=20
void dis_STOS ( Int sz, IRTemp t_inc )
{
@@ -3082,17 +3071,11 @@
IRTemp ta =3D newTemp(ty); /* EAX */
IRTemp td =3D newTemp(Ity_I32); /* EDI */
=20
- //uInstr2(cb, GET, sz, ArchReg, R_EAX, TempReg, ta);
assign( ta, getIReg(sz, R_EAX) );
-
- //uInstr2(cb, GET, 4, ArchReg, R_EDI, TempReg, td);
assign( td, getIReg(4, R_EDI) );
=20
- //uInstr2(cb, STORE, sz, TempReg, ta, TempReg, td);
storeLE( mkexpr(td), mkexpr(ta) );
=20
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, td);
- //uInstr2(cb, PUT, 4, TempReg, td, ArchReg, R_EDI);
putIReg( 4, R_EDI, binop(Iop_Add32, mkexpr(td), mkexpr(t_inc)) );
}
=20
@@ -3102,34 +3085,18 @@
IRType ty =3D szToITy(sz);
IRTemp tdv =3D newTemp(ty); /* (EDI) */
IRTemp tsv =3D newTemp(ty); /* (ESI) */
- //IRTemp res =3D newTemp(ty);
IRTemp td =3D newTemp(Ity_I32); /* EDI */
IRTemp ts =3D newTemp(Ity_I32); /* ESI */
=20
- //uInstr2(cb, GET, 4, ArchReg, R_EDI, TempReg, td);
assign( td, getIReg(4, R_EDI) );
-
- //uInstr2(cb, GET, 4, ArchReg, R_ESI, TempReg, ts);
assign( ts, getIReg(4, R_ESI) );
=20
- //uInstr2(cb, LOAD, sz, TempReg, td, TempReg, tdv);
assign( tdv, loadLE(ty,mkexpr(td)) );
-
- //uInstr2(cb, LOAD, sz, TempReg, ts, TempReg, tsv);
assign( tsv, loadLE(ty,mkexpr(ts)) );
=20
- //uInstr2(cb, SUB, sz, TempReg, tdv, TempReg, tsv);=20
- //setFlagsFromUOpcode(cb, SUB);
- //assign( res, binop(mkSizedOp(ty, Iop_Sub8), mkexpr(tsv), mkexpr(tdv=
)) );
setFlags_DEP1_DEP2 ( Iop_Sub8, tsv, tdv, ty );
=20
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, td);
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, ts);
-
- //uInstr2(cb, PUT, 4, TempReg, td, ArchReg, R_EDI);
putIReg(4, R_EDI, binop(Iop_Add32, mkexpr(td), mkexpr(t_inc)) );
-
- //uInstr2(cb, PUT, 4, TempReg, ts, ArchReg, R_ESI);
putIReg(4, R_ESI, binop(Iop_Add32, mkexpr(ts), mkexpr(t_inc)) );
}
=20
@@ -3140,24 +3107,13 @@
IRTemp ta =3D newTemp(ty); /* EAX */
IRTemp td =3D newTemp(Ity_I32); /* EDI */
IRTemp tdv =3D newTemp(ty); /* (EDI) */
- //IRTemp res =3D newTemp(ty);
=20
- //uInstr2(cb, GET, sz, ArchReg, R_EAX, TempReg, ta);
assign( ta, getIReg(sz, R_EAX) );
-
- //uInstr2(cb, GET, 4, ArchReg, R_EDI, TempReg, td);
assign( td, getIReg(4, R_EDI) );
=20
- //uInstr2(cb, LOAD, sz, TempReg, td, TempReg, tdv);
assign( tdv, loadLE(ty,mkexpr(td)) );
-
- //uInstr2(cb, SUB, sz, TempReg, tdv, TempReg, ta);
- //setFlagsFromUOpcode(cb, SUB);
- //assign( res, binop(mkSizedOp(ty, Iop_Sub8), mkexpr(ta), mkexpr(tdv)=
) );
setFlags_DEP1_DEP2 ( Iop_Sub8, ta, tdv, ty );
=20
- //uInstr2(cb, ADD, 4, TempReg, t_inc, TempReg, td);
- //uInstr2(cb, PUT, 4, TempReg, td, ArchReg, R_EDI);
putIReg(4, R_EDI, binop(Iop_Add32, mkexpr(td), mkexpr(t_inc)) );
}
=20
@@ -3173,17 +3129,12 @@
IRTemp t_inc =3D newTemp(Ity_I32);
IRTemp tc =3D newTemp(Ity_I32); /* ECX */
=20
- //uInstr2 (cb, GET, 4, ArchReg, R_ECX, TempReg, tc);
assign( tc, getIReg(4,R_ECX) );
=20
- //uInstr2 (cb, JIFZ, 4, TempReg, tc, Literal, 0);
- //uLiteral(cb, eip_next);
stmt( IRStmt_Exit( binop(Iop_CmpEQ32,mkexpr(tc),mkU32(0)),
Ijk_Boring,
IRConst_U32(eip_next) ) );
=20
- //uInstr1 (cb, DEC, 4, TempReg, tc);
- //uInstr2 (cb, PUT, 4, TempReg, tc, ArchReg, R_ECX);
putIReg(4, R_ECX, binop(Iop_Sub32, mkexpr(tc), mkU32(1)) );
=20
dis_string_op_increment(sz, t_inc);
@@ -11325,10 +11276,10 @@
dis_string_op( dis_STOS, ( opc =3D=3D 0xAA ? 1 : sz ), "stos", sor=
b );
break;
=20
-//-- case 0xAC: /* LODS, no REP prefix */
-//-- case 0xAD:
-//-- dis_string_op( cb, dis_LODS, ( opc =3D=3D 0xAC ? 1 : sz ), "l=
ods", sorb );
-//-- break;
+ case 0xAC: /* LODS, no REP prefix */
+ case 0xAD:
+ dis_string_op( dis_LODS, ( opc =3D=3D 0xAC ? 1 : sz ), "lods", sor=
b );
+ break;
=20
case 0xAE: /* SCAS, no REP prefix */
case 0xAF:
|
|
From: Julian S. <js...@ac...> - 2005-05-30 08:09:54
|
Robert Interesting patch. I was wondering if you can simply use the --max-stackframe flag in the 3 line to get the same result .. > if delta %esp > some value, then assume a thread change This allows you to set 'some value' on the command line. Furthermore if you don't do that it will tell you plausible values to try anyway. Could you try out --max-stackframe to see if it is good enough? J |
|
From: Julian S. <js...@ac...> - 2005-05-30 07:26:34
|
Hi. This is an interesting one. First off, I can reproduce this using zlib-1.2.2 and the test program posted at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270070, using current Valgrind 3 sources, on x86. I'm reluctant to add these suppressions without understanding what's going in on detail. A lot of thought and effort went into making Valgrind (Memcheck) have a low false-positive rate, and if this shows up a flaw in Memcheck's instrumentation scheme I want to know what it is. In http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270070 Mark writes: > I went through that in detail about a year or two ago and concluded > that it was not a problem, and furthermore could not even cause > indeterminism in the result of deflating. It was intentional in the > design to improve speed. Mark, could you explain how the use of uninitialised values from memory is made safe here? I'm looking at this do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); and it's not clear how scan can be moved forward some indeterminate amount based on garbage in memory and yet the deflate result is well-defined. As background: Memcheck does occasionally generate false errors. These have been looked into quite extensively, and as far as I know always revolve around getting the x86 %eflags register into a partially defined state at high levels of optimisation. This one seems different -- removing -O3/2/1 from the compile flags does not make the report go away. An ideal outcome is that Mark explains how this behaviour is safe in zlib. I can then look at Memcheck's instrumentation phase to determine if/how it is possible to avoid these reports. J On Thursday 26 May 2005 14:07, Tilman Sauerbeck wrote: > Hi, > I suggest to add the following two suppressions to the default set: > > { > bogus warning in zlib > Memcheck:Cond > obj:/usr/lib/libz.so.1.2.2 > obj:/usr/lib/libz.so.1.2.2 > fun:deflate > fun:compress2 > } > { > bogus warning in zlib > Memcheck:Cond > obj:/usr/lib/libz.so.1.2.2 > obj:/usr/lib/libz.so.1.2.2 > fun:deflate > fun:compress2 > } > > According to Mark Adler, that bug is safe and it probably won't be > fixed: > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270070 > > Regards, > Tilman |
|
From: Robert W. <rj...@du...> - 2005-05-30 07:08:18
|
Hi all, I've put a new patch on my web site against the 2.4 tree: http://www.durables.org/~rjwalsh/software/valgrind The patch allows user-land thread packages (e.g. coroutines) to deal with stack changes gracefully. Currently, Valgrind notices when %esp changes and uses a heuristic to figure out if that possibly means a thread change, or just that something large was pushed onto the stack. It often gets it wrong, since the heuristic is basically: if delta %esp > some value, then assume a thread change The problem is, it's hard to know what a good "some value" is since it depends a lot of how your program is written. The change I've made allows you to register a memory range as a stack with Valgrind. Valgrind spots when %esp changes and checks if it's changed to a different registered stack. If it has, then it assumes a thread change. Usage: * id =3D VALGRIND_STACK_NEW(start, end) registers the memory between start and end as a new stack and returns an id you can use for the other client requests described below. This doesn't allocate memory or anything - it just records that a particular memory range is a stack. * VALGRIND_STACK_DELETE(id) removes the stack association for stack "id". This doesn't free memory or anything - it just tells Valgrind that the piece of memory register earlier is no longer a stack. * VALGRIND_STACK_CHANGE(id, start, end) changes the stack "id" to a new start-end range. Useful if you're implementing stack growth in user-land, too. See the stack_changes.c file in corecheck/tests for an example. Some points: * This is currently only against the 2.4 tree. I'll port it to 3.0 in the next day or so. * I haven't measured this for performance impact yet. * I haven't tested VALGRIND_STACK_DELETE at all. * I've only tested VALGRIND_STACK_CHANGE for the default process stack, not for anything registered by the user. * Right now, it falls back to the old algorithm if the new one doesn't indicate a stack change. Probably this should just go away. * It could probably be made a bit more efficient by using an interval skip-list to store the registered stack data instead of a simple linked-list. After I see the performance impact, I'll decide about this. If you have any thoughts, let me know. If there's going to be another 2.4 release, this might be useful to include. Regards, Robert. --=20 Robert Walsh Amalgamated Durables, Inc. - "We don't make the things you buy." Email: rj...@du... |
|
From: <sv...@va...> - 2005-05-30 03:12:16
|
Author: njn
Date: 2005-05-30 04:12:09 +0100 (Mon, 30 May 2005)
New Revision: 3815
Modified:
trunk/coregrind/m_syscalls/syscalls.c
Log:
Unbreak AMD64 compilation.
Modified: trunk/coregrind/m_syscalls/syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-29 23:30:48 UTC (rev 38=
14)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 03:12:09 UTC (rev 38=
15)
@@ -4483,7 +4483,7 @@
#if defined(VGP_x86_linux)
// do nothing
#else
- vg_assert(0, "old_mmap should only be called on x86/Linux");
+ vg_assert2(0, "old_mmap should only be called on x86/Linux");
#endif
=20
UWord a1, a2, a3, a4, a5, a6;
|
|
From: <js...@ac...> - 2005-05-30 02:50:07
|
Nightly build on phoenix ( SuSE 9.1 ) started at 2005-05-30 03:50:00 BST Checking out source tree ... done Configuring ... done Building ... done Running regression tests ... done Last 20 lines of log.verbose follow Nightly build on phoenix ( SuSE 9.1 ) started at 2005-05-30 03:50:00 BST |
|
From: Tom H. <to...@co...> - 2005-05-30 02:36:20
|
Nightly build on dunsmere ( athlon, Fedora Core 3 ) started at 2005-05-30 03:30:03 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 176 tests, 8 stderr failures, 1 stdout failure ================= memcheck/tests/execve (stderr) memcheck/tests/execve2 (stderr) memcheck/tests/x86/scalar (stderr) memcheck/tests/x86/scalar_supp (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/selfrun (stdout) none/tests/selfrun (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-05-30 02:30:43
|
Nightly build on audi ( i686, Red Hat 9 ) started at 2005-05-30 03:25:03 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 175 tests, 4 stderr failures, 0 stdout failures ================= memcheck/tests/xml1 (stderr) corecheck/tests/fdleak_cmsg (stderr) none/tests/faultstatus (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-05-30 02:20:44
|
Nightly build on alvis ( i686, Red Hat 7.3 ) started at 2005-05-30 03:15:03 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 174 tests, 13 stderr failures, 1 stdout failure ================= memcheck/tests/addressable (stderr) memcheck/tests/describe-block (stderr) memcheck/tests/leak-0 (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-regroot (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/match-overrun (stderr) memcheck/tests/pointer-trace (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/xml1 (stderr) corecheck/tests/fdleak_cmsg (stderr) none/tests/faultstatus (stderr) none/tests/x86/int (stderr) none/tests/yield (stdout) |
|
From: Tom H. <th...@cy...> - 2005-05-30 02:11:22
|
Nightly build on dellow ( x86_64, Fedora Core 3 ) started at 2005-05-30 03:10:03 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... failed Last 20 lines of log.verbose follow ranlib libsigframe.a make[3]: Leaving directory `/tmp/valgrind.27050/valgrind/coregrind/m_sigframe' Making all in m_syscalls make[3]: Entering directory `/tmp/valgrind.27050/valgrind/coregrind/m_syscalls' gcc -I../../coregrind -I../.. -I../../coregrind/amd64 -I../../coregrind/linux -I../../coregrind/amd64-linux -I../../include -I/tmp/valgrind.27050/vex/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -m64 -Wa,-gstabs -Wno-long-long -c syscall-amd64-linux.S if gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../coregrind -I../.. -I../../coregrind/amd64 -I../../coregrind/linux -I../../coregrind/amd64-linux -I../../include -I/tmp/valgrind.27050/vex/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -fpie -m64 -fomit-frame-pointer -DELFSZ=64 -Wmissing-prototypes -Winline -Wall -Wshadow -O -g -Wno-long-long -MT syscalls.o -MD -MP -MF ".deps/syscalls.Tpo" -c -o syscalls.o syscalls.c; \ then mv -f ".deps/syscalls.Tpo" ".deps/syscalls.Po"; else rm -f ".deps/syscalls.Tpo"; exit 1; fi syscalls.c:4486:62: macro "vg_assert" passed 2 arguments, but takes just 1 syscalls.c: In function `vgArch_gen_old_mmap_before': syscalls.c:4486: error: `vg_assert' undeclared (first use in this function) syscalls.c:4486: error: (Each undeclared identifier is reported only once syscalls.c:4486: error: for each function it appears in.) syscalls.c:4536: warning: cast from pointer to integer of different size make[3]: *** [syscalls.o] Error 1 make[3]: Leaving directory `/tmp/valgrind.27050/valgrind/coregrind/m_syscalls' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/tmp/valgrind.27050/valgrind/coregrind' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/tmp/valgrind.27050/valgrind' make: *** [all] Error 2 |
|
From: Robert W. <rj...@du...> - 2005-05-30 02:03:54
|
SVN commit 419608 by rjwalsh: Update the ignore stuff so svn status doesn't complain so much. _M trunk/valgrind (directory) =20 _M addrcheck (directory) =20 _M auxprogs (directory) =20 _M cachegrind (directory) =20 _M cachegrind/tests (directory) =20 _M cachegrind/x86 (directory) =20 _M corecheck (directory) =20 _M corecheck/tests (directory) =20 _M coregrind (directory) =20 _M coregrind/demangle (directory) =20 _M coregrind/linux (directory) =20 _M coregrind/x86 (directory) =20 _M coregrind/x86-linux (directory) =20 _M helgrind (directory) =20 _M helgrind/tests (directory) =20 _M include (directory) =20 _M lackey (directory) =20 _M massif (directory) =20 _M massif/hp2ps (directory) =20 _M memcheck (directory) =20 _M memcheck/tests (directory) =20 _M memcheck/tests/x86 (directory) =20 _M none (directory) =20 _M none/tests (directory) =20 _M none/tests/x86 (directory) =20 _M tests (directory) =20 |
|
From: Tom H. <th...@cy...> - 2005-05-30 02:01:42
|
Nightly build on gill ( x86_64, Fedora Core 2 ) started at 2005-05-30 03:00:03 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... failed Last 20 lines of log.verbose follow ranlib libsigframe.a make[3]: Leaving directory `/tmp/valgrind.24082/valgrind/coregrind/m_sigframe' Making all in m_syscalls make[3]: Entering directory `/tmp/valgrind.24082/valgrind/coregrind/m_syscalls' gcc -I../../coregrind -I../.. -I../../coregrind/amd64 -I../../coregrind/linux -I../../coregrind/amd64-linux -I../../include -I/tmp/valgrind.24082/vex/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -m64 -Wa,-gstabs -Wno-long-long -c syscall-amd64-linux.S if gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../coregrind -I../.. -I../../coregrind/amd64 -I../../coregrind/linux -I../../coregrind/amd64-linux -I../../include -I/tmp/valgrind.24082/vex/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -fpie -m64 -fomit-frame-pointer -DELFSZ=64 -Wmissing-prototypes -Winline -Wall -Wshadow -O -g -Wno-long-long -MT syscalls.o -MD -MP -MF ".deps/syscalls.Tpo" -c -o syscalls.o syscalls.c; \ then mv -f ".deps/syscalls.Tpo" ".deps/syscalls.Po"; else rm -f ".deps/syscalls.Tpo"; exit 1; fi syscalls.c:4486:62: macro "vg_assert" passed 2 arguments, but takes just 1 syscalls.c: In function `vgArch_gen_old_mmap_before': syscalls.c:4486: error: `vg_assert' undeclared (first use in this function) syscalls.c:4486: error: (Each undeclared identifier is reported only once syscalls.c:4486: error: for each function it appears in.) syscalls.c:4536: warning: cast from pointer to integer of different size make[3]: *** [syscalls.o] Error 1 make[3]: Leaving directory `/tmp/valgrind.24082/valgrind/coregrind/m_syscalls' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/tmp/valgrind.24082/valgrind/coregrind' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/tmp/valgrind.24082/valgrind' make: *** [all] Error 2 |