Managed to kill linux/core_os.h, hooray.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3872
#include "tool.h" // tool stuff
#include "core_arch.h" // arch-specific stuff, eg. x86/core_arch.h
-#include "core_os.h" // OS-specific stuff, eg. linux/core_os.h
-
#include <setjmp.h> // for jmp_buf
#include "pub_core_mallocfree.h" // for type 'ArenaId'
Addr esp_at_startup,
/*MOD*/ ThreadArchState* arch );
-// 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.
extern VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tid);
-// 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);
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-noinst_HEADERS = \
- core_os.h
-
noinst_LIBRARIES = libos.a
libos_a_SOURCES = \
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
-void VGO_(os_state_clear)(ThreadState *tst)
-{
- tst->os_state.lwpid = 0;
- tst->os_state.threadgroup = 0;
-}
-
-void VGO_(os_state_init)(ThreadState *tst)
-{
- tst->os_state.valgrind_stack_base = 0;
- tst->os_state.valgrind_stack_szB = 0;
-
- VGO_(os_state_clear)(tst);
-}
-
static Bool i_am_the_only_thread ( void )
{
Int c = VG_(count_living_threads)();
return c == 1;
}
-
-void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src)
-{
- VG_(debugLog)(1, "core_os",
- "VGO_(terminate_NORETURN)(tid=%lld)\n", (ULong)tid);
-
- vg_assert(VG_(count_living_threads)() == 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 != 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. */
#ifndef __LINUX_CORE_OS_H
#define __LINUX_CORE_OS_H
-/* 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
/*--------------------------------------------------------------------*/
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 );
+ /* Ok, finally exit in the os-specific way, according to the scheduler'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",
+ "VGO_(terminate_NORETURN)(tid=%lld)\n", (ULong)tid);
+
+ vg_assert(VG_(count_living_threads)() == 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 != 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");
+ }
}
/*--------------------------------------------------------------------*/
}
+static void os_state_clear(ThreadState *tst)
+{
+ tst->os_state.lwpid = 0;
+ tst->os_state.threadgroup = 0;
+}
+
+static void os_state_init(ThreadState *tst)
+{
+ tst->os_state.valgrind_stack_base = 0;
+ tst->os_state.valgrind_stack_szB = 0;
+
+ os_state_clear(tst);
+}
+
static
void mostly_clear_thread_record ( ThreadId tid )
{
VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
VG_(sigemptyset)(&VG_(threads)[tid].tmp_sig_mask);
- VGO_(os_state_clear)(&VG_(threads)[tid]);
+ os_state_clear(&VG_(threads)[tid]);
/* start with no altstack */
VG_(threads)[tid].altstack.ss_sp = (void *)0xdeadbeef;
VG_(threads)[i].sig_queue = NULL;
- VGO_(os_state_init)(&VG_(threads)[i]);
+ os_state_init(&VG_(threads)[i]);
mostly_clear_thread_record(i);
VG_(threads)[i].status = VgTs_Empty;
}
ThreadArchState;
+/* 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;
+
typedef struct {
/* ThreadId == 0 (and hence vg_threads[0]) is NEVER USED.