|
From: <sv...@va...> - 2005-06-12 04:20:12
|
Author: njn
Date: 2005-06-12 05:19:17 +0100 (Sun, 12 Jun 2005)
New Revision: 3896
Log:
Moved more stuff out of core_os.c into better places.
Modified:
trunk/coregrind/core.h
trunk/coregrind/linux/core_os.c
trunk/coregrind/m_main.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/pub_core_main.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-12 02:49:35 UTC (rev 3895)
+++ trunk/coregrind/core.h 2005-06-12 04:19:17 UTC (rev 3896)
@@ -163,21 +163,12 @@
// wait until all other threads are dead
extern void VGA_(reap_threads)(ThreadId self);
=20
-// handle an arch-specific client request
-extern Bool VGA_(client_request)(ThreadId tid, UWord *args);
-
// For attaching the debugger
extern Int VGA_(ptrace_setregs_from_tst) ( Int pid, ThreadArchState* ar=
ch );
=20
// Used by leakcheck
extern void VGA_(mark_from_registers)(ThreadId tid, void (*marker)(Addr)=
);
=20
-// Set up the libc freeres wrapper
-extern void VGA_(intercept_libc_freeres_wrapper)(Addr);
-
-// Clean up the client by calling before the final reports
-extern void VGA_(final_tidyup)(ThreadId tid);
-
/* ---------------------------------------------------------------------
Finally - autoconf-generated settings
------------------------------------------------------------------ */
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-12 02:49:35 UTC (rev 3895)
+++ trunk/coregrind/linux/core_os.c 2005-06-12 04:19:17 UTC (rev 3896)
@@ -103,84 +103,6 @@
vg_assert(i_am_the_only_thread());
}
=20
-/* The we need to know the address of it so it can be
- called at program exit. */
-static Addr __libc_freeres_wrapper;
-
-void VGA_(intercept_libc_freeres_wrapper)(Addr addr)
-{
- __libc_freeres_wrapper =3D addr;
-}
-
-/* Final clean-up before terminating the process. =20
- Clean up the client by calling __libc_freeres() (if requested) */
-void VGA_(final_tidyup)(ThreadId tid)
-{
- vg_assert(VG_(is_running_thread)(tid));
- =20
- if (!VG_(needs).libc_freeres ||
- !VG_(clo_run_libc_freeres) ||
- __libc_freeres_wrapper =3D=3D 0)
- return; /* can't/won't do it */
-
- if (VG_(clo_verbosity) > 2 ||
- VG_(clo_trace_syscalls) ||
- VG_(clo_trace_sched))
- VG_(message)(Vg_DebugMsg,=20
- "Caught __NR_exit; running __libc_freeres()");
- =20
- /* point thread context to point to libc_freeres_wrapper */
- INSTR_PTR(VG_(threads)[tid].arch) =3D __libc_freeres_wrapper;
- // XXX should we use a special stack?
-
- /* Block all blockable signals by copying the real block state into
- the thread's block state*/
- VG_(sigprocmask)(VKI_SIG_BLOCK, NULL, &VG_(threads)[tid].sig_mask);
- VG_(threads)[tid].tmp_sig_mask =3D VG_(threads)[tid].sig_mask;
-
- /* and restore handlers to default */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(set_default_handler)(VKI_SIGBUS);
- VG_(set_default_handler)(VKI_SIGILL);
- VG_(set_default_handler)(VKI_SIGFPE);
-
- // We were exiting, so assert that...
- vg_assert(VG_(is_exiting)(tid));
- // ...but now we're not again
- VG_(threads)[tid].exitreason =3D VgSrc_None;
-
- // run until client thread exits - ideally with LIBC_FREERES_DONE,
- // but exit/exitgroup/signal will do
- VG_(scheduler)(tid);
-
- vg_assert(VG_(is_exiting)(tid));
-}
-
-// Arch-specific client requests
-Bool VGA_(client_request)(ThreadId tid, UWord *args)
-{
- Bool handled =3D True;
-
- vg_assert(VG_(is_running_thread)(tid));
-
- switch(args[0]) {
- case VG_USERREQ__LIBC_FREERES_DONE:
- /* This is equivalent to an exit() syscall, but we don't set the
- exitcode (since it might already be set) */
- if (0 || VG_(clo_trace_syscalls) || VG_(clo_trace_sched))
- VG_(message)(Vg_DebugMsg,=20
- "__libc_freeres() done; really quitting!");
- VG_(threads)[tid].exitreason =3D VgSrc_ExitSyscall;
- break;
-
- default:
- handled =3D False;
- break;
- }
-
- return handled;
-}
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
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-12 02:49:35 UTC (rev 3895)
+++ trunk/coregrind/m_main.c 2005-06-12 04:19:17 UTC (rev 3896)
@@ -2802,6 +2802,61 @@
}
=20
=20
+/* The we need to know the address of it so it can be
+ called at program exit. */
+static Addr __libc_freeres_wrapper;
+
+void VGA_(intercept_libc_freeres_wrapper)(Addr addr)
+{
+ __libc_freeres_wrapper =3D addr;
+}
+
+/* Final clean-up before terminating the process. =20
+ Clean up the client by calling __libc_freeres() (if requested)=20
+ This is Linux-specific?
+*/
+static void final_tidyup(ThreadId tid)
+{
+ vg_assert(VG_(is_running_thread)(tid));
+ =20
+ if (!VG_(needs).libc_freeres ||
+ !VG_(clo_run_libc_freeres) ||
+ __libc_freeres_wrapper =3D=3D 0)
+ return; /* can't/won't do it */
+
+ if (VG_(clo_verbosity) > 2 ||
+ VG_(clo_trace_syscalls) ||
+ VG_(clo_trace_sched))
+ VG_(message)(Vg_DebugMsg,=20
+ "Caught __NR_exit; running __libc_freeres()");
+ =20
+ /* point thread context to point to libc_freeres_wrapper */
+ INSTR_PTR(VG_(threads)[tid].arch) =3D __libc_freeres_wrapper;
+ // XXX should we use a special stack?
+
+ /* Block all blockable signals by copying the real block state into
+ the thread's block state*/
+ VG_(sigprocmask)(VKI_SIG_BLOCK, NULL, &VG_(threads)[tid].sig_mask);
+ VG_(threads)[tid].tmp_sig_mask =3D VG_(threads)[tid].sig_mask;
+
+ /* and restore handlers to default */
+ VG_(set_default_handler)(VKI_SIGSEGV);
+ VG_(set_default_handler)(VKI_SIGBUS);
+ VG_(set_default_handler)(VKI_SIGILL);
+ VG_(set_default_handler)(VKI_SIGFPE);
+
+ // We were exiting, so assert that...
+ vg_assert(VG_(is_exiting)(tid));
+ // ...but now we're not again
+ VG_(threads)[tid].exitreason =3D VgSrc_None;
+
+ // run until client thread exits - ideally with LIBC_FREERES_DONE,
+ // but exit/exitgroup/signal will do
+ VG_(scheduler)(tid);
+
+ vg_assert(VG_(is_exiting)(tid));
+}
+
/* Do everything which needs doing when the last thread exits */
void VG_(shutdown_actions_NORETURN) ( ThreadId tid,=20
VgSchedReturnCode tids_schedretcod=
e )
@@ -2817,7 +2872,7 @@
VG_(clo_model_pthreads) =3D False;
=20
// Clean the client up before the final report
- VGA_(final_tidyup)(tid);
+ final_tidyup(tid);
=20
// OK, done
VG_(exit_thread)(tid);
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-12 02:49:35 UTC (rev =
3895)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-12 04:19:17 UTC (rev =
3896)
@@ -983,6 +983,32 @@
Handle client requests.
------------------------------------------------------------------ */
=20
+// OS-specific(?) client requests
+static Bool os_client_request(ThreadId tid, UWord *args)
+{
+ Bool handled =3D True;
+
+ vg_assert(VG_(is_running_thread)(tid));
+
+ switch(args[0]) {
+ case VG_USERREQ__LIBC_FREERES_DONE:
+ /* This is equivalent to an exit() syscall, but we don't set the
+ exitcode (since it might already be set) */
+ if (0 || VG_(clo_trace_syscalls) || VG_(clo_trace_sched))
+ VG_(message)(Vg_DebugMsg,=20
+ "__libc_freeres() done; really quitting!");
+ VG_(threads)[tid].exitreason =3D VgSrc_ExitSyscall;
+ break;
+
+ default:
+ handled =3D False;
+ break;
+ }
+
+ return handled;
+}
+
+
/* 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
@@ -1109,8 +1135,8 @@
break;
=20
default:
- if (VGA_(client_request)(tid, arg)) {
- /* architecture handled the client request */
+ if (os_client_request(tid, arg)) {
+ // do nothing, os_client_request() handled it
} else if (VG_(needs).client_requests) {
UWord ret;
=20
Modified: trunk/coregrind/pub_core_main.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_main.h 2005-06-12 02:49:35 UTC (rev 3895)
+++ trunk/coregrind/pub_core_main.h 2005-06-12 04:19:17 UTC (rev 3896)
@@ -54,6 +54,8 @@
/* 64-bit counter for the number of basic blocks done. */
extern ULong VG_(bbs_done);
=20
+// Set up the libc freeres wrapper (XXX: currently unused -- ?!)
+extern void VGA_(intercept_libc_freeres_wrapper)(Addr);
=20
#endif // __PUB_CORE_MAIN_H
=20
|