diff options
author | Duncan Coutts <duncan@well-typed.com> | 2011-05-26 18:44:41 +0100 |
---|---|---|
committer | Duncan Coutts <duncan@well-typed.com> | 2011-05-26 18:47:38 +0100 |
commit | e8832eb9f05ca46d9315250c3baf7010eb0630a4 (patch) | |
tree | be08e88284b463362f14673175aedca35bcfcb8c /rts/Trace.c | |
parent | 43c7d555c8d7eea6ba0d76bce33be8d25a01c6fd (diff) | |
download | haskell-e8832eb9f05ca46d9315250c3baf7010eb0630a4.tar.gz |
Emit various bits of OS process info into the eventlog
The process ID, parent process ID, rts name and version
The program arguments and environment.
Diffstat (limited to 'rts/Trace.c')
-rw-r--r-- | rts/Trace.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/rts/Trace.c b/rts/Trace.c index faa54d7741..e472c5ade7 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -15,11 +15,16 @@ #ifdef TRACING #include "GetTime.h" +#include "GetEnv.h" #include "Stats.h" #include "eventlog/EventLog.h" #include "Threads.h" #include "Printer.h" +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifdef DEBUG // debugging flags, set with +RTS -D<something> int DEBUG_sched; @@ -284,6 +289,50 @@ void traceCapsetModify_ (EventTypeNum tag, } } +void traceOSProcessInfo_(void) { + if (eventlog_enabled) { + postCapsetModifyEvent(EVENT_OSPROCESS_PID, + CAPSET_OSPROCESS_DEFAULT, + getpid()); + +#if !defined(cygwin32_HOST_OS) && !defined (mingw32_HOST_OS) +/* Windows has no strong concept of process heirarchy, so no getppid(). + * In any case, this trace event is mainly useful for tracing programs + * that use 'forkProcess' which Windows doesn't support anyway. + */ + postCapsetModifyEvent(EVENT_OSPROCESS_PPID, + CAPSET_OSPROCESS_DEFAULT, + getppid()); +#endif + { + char buf[256]; + snprintf(buf, sizeof(buf), "GHC-%s %s", ProjectVersion, RtsWay); + postCapsetStrEvent(EVENT_RTS_IDENTIFIER, + CAPSET_OSPROCESS_DEFAULT, + buf); + } + { + int argc = 0; char **argv; + getFullProgArgv(&argc, &argv); + if (argc != 0) { + postCapsetVecEvent(EVENT_PROGRAM_ARGS, + CAPSET_OSPROCESS_DEFAULT, + argc, argv); + } + } + { + int envc = 0; char **envv; + getProgEnvv(&envc, &envv); + if (envc != 0) { + postCapsetVecEvent(EVENT_PROGRAM_ENV, + CAPSET_OSPROCESS_DEFAULT, + envc, envv); + } + freeProgEnvv(envc, envv); + } + } +} + void traceEvent_ (Capability *cap, EventTypeNum tag) { #ifdef DEBUG |