/* The scheduler. */
-extern VgSchedReturnCode VG_(scheduler) ( void );
+extern VgSchedReturnCode VG_(scheduler) ( Int* exit_code );
extern void VG_(scheduler_init) ( void );
/* This is the ThreadId of the last thread the scheduler ran. */
extern ThreadId VG_(last_run_tid);
-/* This is the argument to __NR_exit() supplied by the first thread to
- call that syscall. We eventually pass that to __NR_exit() for
- real. */
-extern Int VG_(exitcode);
-
/* If we're doing the default action of a fatal signal */
extern jmp_buf VG_(fatal_signal_jmpbuf);
extern Bool VG_(fatal_signal_set); /* jmp_buf is valid */
descriptor or a socket descriptor. */
Bool VG_(logging_to_filedes) = True;
-/* This is the argument to __NR_exit() supplied by the first thread to
- call that syscall. We eventually pass that to __NR_exit() for
- real. */
-Int VG_(exitcode) = 0;
-
/*====================================================================*/
/*=== Counters, for profiling purposes only ===*/
Addr esp_at_startup; /* client's %esp at the point we gained control. */
UInt * client_auxv;
VgSchedReturnCode src;
+ Int exitcode = 0;
vki_rlimit zero = { 0, 0 };
//============================================================
if (__builtin_setjmp(&VG_(fatal_signal_jmpbuf)) == 0) {
VG_(fatal_signal_set) = True;
- src = VG_(scheduler)();
+ src = VG_(scheduler)( &exitcode );
} else
src = VgSrc_FatalSig;
if (VG_(needs).core_errors || VG_(needs).skin_errors)
VG_(show_all_errors)();
- SK_(fini)( VG_(exitcode) );
+ SK_(fini)( exitcode );
VG_(do_sanity_checks)( True /*include expensive checks*/ );
/* The thread's %EBX at the time it did __NR_exit() will hold
the arg to __NR_exit(), so we just do __NR_exit() with
that arg. */
- VG_(exit)( VG_(exitcode) );
+ VG_(exit)( exitcode );
/* NOT ALIVE HERE! */
VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
break; /* what the hell :) */
* One thread asks to shutdown Valgrind
* The specified number of basic blocks has gone by.
*/
-VgSchedReturnCode VG_(scheduler) ( void )
+VgSchedReturnCode VG_(scheduler) ( Int* exitcode )
{
ThreadId tid, tid_next;
UInt trc;
/* All threads have exited - pretend someone called exit() */
if (n_waiting_for_reaper == n_exists) {
- VG_(exitcode) = 0; /* ? */
+ *exitcode = 0; /* ? */
return VgSrc_ExitSyscall;
}
) {
/* If __NR_exit, remember the supplied argument. */
- VG_(exitcode) = VG_(threads)[tid].m_ebx; /* syscall arg1 */
+ *exitcode = VG_(threads)[tid].m_ebx; /* syscall arg1 */
/* Only run __libc_freeres if the tool says it's ok and
it hasn't been overridden with --run-libc-freeres=no