|
From: <sv...@va...> - 2005-06-10 22:59:58
|
Author: njn
Date: 2005-06-10 23:59:56 +0100 (Fri, 10 Jun 2005)
New Revision: 3872
Log:
Moved various pieces of linux/core_os.c to the modules that use them.
Managed to kill linux/core_os.h, hooray.
Modified:
trunk/coregrind/core.h
trunk/coregrind/linux/Makefile.am
trunk/coregrind/linux/core_os.c
trunk/coregrind/linux/core_os.h
trunk/coregrind/m_main.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/pub_core_scheduler.h
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-06-10 22:39:04 UTC (rev 3871)
+++ trunk/coregrind/core.h 2005-06-10 22:59:56 UTC (rev 3872)
@@ -35,8 +35,6 @@
#include "tool.h" // tool stuff
#include "core_arch.h" // arch-specific stuff, eg. x86/core_arch.h
=20
-#include "core_os.h" // OS-specific stuff, eg. linux/core_os.h
-
#include <setjmp.h> // for jmp_buf
=20
#include "pub_core_mallocfree.h" // for type 'ArenaId'
@@ -177,18 +175,9 @@
Addr esp_at_startup,
/*MOD*/ ThreadArchState* arch );
=20
-// OS/Platform-specific thread clear (after thread exit)
-extern void VGO_(os_state_clear)(ThreadState *);
-
-// OS/Platform-specific thread init (at scheduler init time)
-extern void VGO_(os_state_init)(ThreadState *);
-
// Run a thread from beginning to end.=20
extern VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tid);
=20
-// Call here to exit the entire Valgrind system.
-extern void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src=
);
-
// 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);
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-06-10 22:39:04 UTC (rev 3871)
+++ trunk/coregrind/linux/Makefile.am 2005-06-10 22:59:56 UTC (rev 3872)
@@ -1,9 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
=20
-noinst_HEADERS =3D \
- core_os.h
-
noinst_LIBRARIES =3D libos.a
=20
libos_a_SOURCES =3D \
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-06-10 22:39:04 UTC (rev 3871)
+++ trunk/coregrind/linux/core_os.c 2005-06-10 22:59:56 UTC (rev 3872)
@@ -38,20 +38,6 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
=20
-void VGO_(os_state_clear)(ThreadState *tst)
-{
- tst->os_state.lwpid =3D 0;
- tst->os_state.threadgroup =3D 0;
-}
-
-void VGO_(os_state_init)(ThreadState *tst)
-{
- tst->os_state.valgrind_stack_base =3D 0;
- tst->os_state.valgrind_stack_szB =3D 0;
-
- VGO_(os_state_clear)(tst);
-}
-
static Bool i_am_the_only_thread ( void )
{
Int c =3D VG_(count_living_threads)();
@@ -59,37 +45,6 @@
return c =3D=3D 1;
}
=20
-
-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);
-
- //--------------------------------------------------------------
- // Exit, according to the scheduler's return code
- //--------------------------------------------------------------
- switch (src) {
- case VgSrc_ExitSyscall: /* the normal way out */
- VG_(exit)( VG_(threads)[tid].os_state.exitcode );
- /* NOT ALIVE HERE! */
- VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
- break; /* what the hell :) */
-
- case VgSrc_FatalSig:
- /* We were killed by a fatal signal, so replicate the effect */
- 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;
-
- default:
- VG_(core_panic)("main(): unexpected scheduler return code");
- }
-}
-
-
/* Run a thread from beginning to end and return the thread's
scheduler-return-code. */
=20
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-06-10 22:39:04 UTC (rev 3871)
+++ trunk/coregrind/linux/core_os.h 2005-06-10 22:59:56 UTC (rev 3872)
@@ -32,23 +32,6 @@
#ifndef __LINUX_CORE_OS_H
#define __LINUX_CORE_OS_H
=20
-/* OS-specific thread state */
-typedef struct {
- /* who we are */
- Int lwpid; /* PID of kernel task */
- Int threadgroup; /* thread group id */
-
- ThreadId parent; /* parent tid (if any) */
-
- /* runtime details */
- Addr valgrind_stack_base; /* Valgrind's stack base */
- SizeT valgrind_stack_szB; /* stack size in bytes */
-
- /* exit details */
- Int exitcode; /* in the case of exitgroup, set by someone else */
- Int fatalsig; /* fatal signal */
-} os_thread_t;
-
#endif // __LINUX_CORE_OS_H
=20
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_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/m_main.c 2005-06-10 22:39:04 UTC (rev 3871)
+++ trunk/coregrind/m_main.c 2005-06-10 22:59:56 UTC (rev 3872)
@@ -2877,11 +2877,32 @@
if (0)
LibVEX_ShowAllocStats();
=20
- /* 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 );
+ /* Ok, finally exit in the os-specific way, according to the schedule=
r's
+ return code. 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. *=
/
+ VG_(debugLog)(1, "core_os",=20
+ "VGO_(terminate_NORETURN)(tid=3D%lld)\n", (ULong)tid=
);
+
+ vg_assert(VG_(count_living_threads)() =3D=3D 0);
+
+ switch (tids_schedretcode) {
+ case VgSrc_ExitSyscall: /* the normal way out */
+ VG_(exit)( VG_(threads)[tid].os_state.exitcode );
+ /* NOT ALIVE HERE! */
+ VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
+ break; /* what the hell :) */
+
+ case VgSrc_FatalSig:
+ /* We were killed by a fatal signal, so replicate the effect */
+ 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;
+
+ default:
+ VG_(core_panic)("main(): unexpected scheduler return code");
+ }
}
=20
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_scheduler/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/m_scheduler/scheduler.c 2005-06-10 22:39:04 UTC (rev =
3871)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-10 22:59:56 UTC (rev =
3872)
@@ -553,6 +553,20 @@
}
=20
=20
+static void os_state_clear(ThreadState *tst)
+{
+ tst->os_state.lwpid =3D 0;
+ tst->os_state.threadgroup =3D 0;
+}
+
+static void os_state_init(ThreadState *tst)
+{
+ tst->os_state.valgrind_stack_base =3D 0;
+ tst->os_state.valgrind_stack_szB =3D 0;
+
+ os_state_clear(tst);
+}
+
static=20
void mostly_clear_thread_record ( ThreadId tid )
{
@@ -569,7 +583,7 @@
VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
VG_(sigemptyset)(&VG_(threads)[tid].tmp_sig_mask);
=20
- VGO_(os_state_clear)(&VG_(threads)[tid]);
+ os_state_clear(&VG_(threads)[tid]);
=20
/* start with no altstack */
VG_(threads)[tid].altstack.ss_sp =3D (void *)0xdeadbeef;
@@ -641,7 +655,7 @@
=20
VG_(threads)[i].sig_queue =3D NULL;
=20
- VGO_(os_state_init)(&VG_(threads)[i]);
+ os_state_init(&VG_(threads)[i]);
mostly_clear_thread_record(i);
=20
VG_(threads)[i].status =3D VgTs_Empty;
Modified: trunk/coregrind/pub_core_scheduler.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_scheduler.h 2005-06-10 22:39:04 UTC (rev 387=
1)
+++ trunk/coregrind/pub_core_scheduler.h 2005-06-10 22:59:56 UTC (rev 387=
2)
@@ -95,7 +95,24 @@
}=20
ThreadArchState;
=20
+/* OS-specific thread state */
+typedef struct {
+ /* who we are */
+ Int lwpid; // PID of kernel task
+ Int threadgroup; // thread group id
=20
+ ThreadId parent; // parent tid (if any)
+
+ /* runtime details */
+ Addr valgrind_stack_base; // Valgrind's stack base
+ SizeT valgrind_stack_szB; // stack size in bytes
+
+ /* exit details */
+ Int exitcode; // in the case of exitgroup, set by someone else
+ Int fatalsig; // fatal signal
+} os_thread_t;
+
+
typedef struct {
/* ThreadId =3D=3D 0 (and hence vg_threads[0]) is NEVER USED.
The thread identity is simply the index in vg_threads[].
|