Add a way to generate tracing events programmatically
[ghc-hetmet.git] / includes / rts / Flags.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2009
4  *
5  * Datatypes that holds the command-line flag settings.
6  *
7  * Do not #include this file directly: #include "Rts.h" instead.
8  *
9  * To understand the structure of the RTS headers, see the wiki:
10  *   http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11  *
12  * ---------------------------------------------------------------------------*/
13
14 #ifndef RTS_FLAGS_H
15 #define RTS_FLAGS_H
16
17 #include <stdio.h>
18
19 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
20
21 struct GC_FLAGS {
22     FILE   *statsFile;
23     nat     giveStats;
24 #define NO_GC_STATS      0
25 #define COLLECT_GC_STATS 1
26 #define ONELINE_GC_STATS 2
27 #define SUMMARY_GC_STATS 3
28 #define VERBOSE_GC_STATS 4
29
30     nat     maxStkSize;         /* in *words* */
31     nat     initialStkSize;     /* in *words* */
32
33     nat     maxHeapSize;        /* in *blocks* */
34     nat     minAllocAreaSize;   /* in *blocks* */
35     nat     minOldGenSize;      /* in *blocks* */
36     nat     heapSizeSuggestion; /* in *blocks* */
37     double  oldGenFactor;
38     double  pcFreeHeap;
39
40     nat     generations;
41     nat     steps;
42     rtsBool squeezeUpdFrames;
43
44     rtsBool compact;            /* True <=> "compact all the time" */
45     double  compactThreshold;
46
47     rtsBool sweep;              /* use "mostly mark-sweep" instead of copying
48                                  * for the oldest generation */
49     rtsBool ringBell;
50     rtsBool frontpanel;
51
52     int idleGCDelayTime;        /* in milliseconds */
53
54     StgWord heapBase;           /* address to ask the OS for memory */
55 };
56
57 struct DEBUG_FLAGS {  
58     /* flags to control debugging output & extra checking in various subsystems */
59     rtsBool scheduler;      /* 's' */
60     rtsBool interpreter;    /* 'i' */
61     rtsBool weak;           /* 'w' */
62     rtsBool gccafs;         /* 'G' */
63     rtsBool gc;             /* 'g' */
64     rtsBool block_alloc;    /* 'b' */
65     rtsBool sanity;         /* 'S'   warning: might be expensive! */
66     rtsBool stable;         /* 't' */
67     rtsBool prof;           /* 'p' */
68     rtsBool linker;         /* 'l'   the object linker */
69     rtsBool apply;          /* 'a' */
70     rtsBool stm;            /* 'm' */
71     rtsBool squeeze;        /* 'z'  stack squeezing & lazy blackholing */
72     rtsBool hpc;            /* 'c' coverage */
73     rtsBool sparks;         /* 'r' */
74 };
75
76 struct COST_CENTRE_FLAGS {
77     unsigned int            doCostCentres;
78 # define COST_CENTRES_SUMMARY   1
79 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
80 # define COST_CENTRES_ALL       3
81 # define COST_CENTRES_XML       4
82
83     int     profilerTicks;   /* derived */
84     int     msecsPerTick;    /* derived */
85 };
86
87 struct PROFILING_FLAGS {
88     unsigned int        doHeapProfile;
89 # define NO_HEAP_PROFILING      0       /* N.B. Used as indexes into arrays */
90 # define HEAP_BY_CCS            1
91 # define HEAP_BY_MOD            2
92 # define HEAP_BY_DESCR          4
93 # define HEAP_BY_TYPE           5
94 # define HEAP_BY_RETAINER       6
95 # define HEAP_BY_LDV            7
96
97 # define HEAP_BY_CLOSURE_TYPE   8
98
99     nat                 profileInterval;      /* delta between samples (in ms) */
100     nat                 profileIntervalTicks; /* delta between samples (in 'ticks') */
101     rtsBool             includeTSOs;
102
103
104     rtsBool             showCCSOnException;
105
106     nat                 maxRetainerSetSize;
107
108     nat                 ccsLength;
109
110     char*               modSelector;
111     char*               descrSelector;
112     char*               typeSelector;
113     char*               ccSelector;
114     char*               ccsSelector;
115     char*               retainerSelector;
116     char*               bioSelector;
117
118 };
119
120 #define TRACE_NONE      0
121 #define TRACE_EVENTLOG  1
122 #define TRACE_STDERR    2
123
124 struct TRACE_FLAGS {
125     int tracing;
126     rtsBool timestamp;      /* show timestamp in stderr output */
127
128     rtsBool scheduler;      /* trace scheduler events */
129 };
130
131 struct CONCURRENT_FLAGS {
132     int ctxtSwitchTime;         /* in milliseconds */
133     int ctxtSwitchTicks;        /* derived */
134 };
135
136 struct MISC_FLAGS {
137     int tickInterval;     /* in milliseconds */
138     rtsBool install_signal_handlers;
139     rtsBool machineReadable;
140     StgWord linkerMemBase;       /* address to ask the OS for memory
141                                   * for the linker, NULL ==> off */
142 };
143
144 #ifdef THREADED_RTS
145 struct PAR_FLAGS {
146   nat            nNodes;         /* number of threads to run simultaneously */
147   rtsBool        migrate;        /* migrate threads between capabilities */
148   rtsBool        wakeupMigrate;  /* migrate a thread on wakeup */
149   unsigned int   maxLocalSparks;
150   rtsBool        parGcEnabled;   /* enable parallel GC */
151   unsigned int   parGcGen;       /* do parallel GC in this generation
152                                   * and higher only */
153   rtsBool        parGcLoadBalancingEnabled; 
154                                  /* enable load-balancing in the
155                                   * parallel GC */
156   unsigned int   parGcLoadBalancingGen;
157                                  /* do load-balancing in this
158                                   * generation and higher only */
159   rtsBool        setAffinity;    /* force thread affinity with CPUs */
160 };
161 #endif /* THREADED_RTS */
162
163 struct TICKY_FLAGS {
164     rtsBool showTickyStats;
165     FILE   *tickyFile;
166 };
167
168 #ifdef USE_PAPI
169 #define MAX_PAPI_USER_EVENTS 8
170
171 struct PAPI_FLAGS {
172     nat     eventType;          /* The type of events to count */
173     nat     numUserEvents;
174     char *  userEvents[MAX_PAPI_USER_EVENTS];
175 };
176
177 #define PAPI_FLAG_CACHE_L1 1
178 #define PAPI_FLAG_CACHE_L2 2
179 #define PAPI_FLAG_BRANCH 3
180 #define PAPI_FLAG_STALLS 4
181 #define PAPI_FLAG_CB_EVENTS 5
182 #define PAPI_USER_EVENTS 6
183
184 #endif
185
186 /* Put them together: */
187
188 typedef struct _RTS_FLAGS {
189     /* The first portion of RTS_FLAGS is invariant. */
190     struct GC_FLAGS          GcFlags;
191     struct CONCURRENT_FLAGS  ConcFlags;
192     struct MISC_FLAGS        MiscFlags;
193     struct DEBUG_FLAGS       DebugFlags;
194     struct COST_CENTRE_FLAGS CcFlags;
195     struct PROFILING_FLAGS   ProfFlags;
196     struct TRACE_FLAGS       TraceFlags;
197     struct TICKY_FLAGS       TickyFlags;
198
199 #if defined(THREADED_RTS)
200     struct PAR_FLAGS    ParFlags;
201 #endif
202 #ifdef USE_PAPI
203     struct PAPI_FLAGS   PapiFlags;
204 #endif
205 } RTS_FLAGS;
206
207 #ifdef COMPILING_RTS_MAIN
208 extern DLLIMPORT RTS_FLAGS RtsFlags;
209 #elif IN_STG_CODE
210 /* Hack because the C code generator can't generate '&label'. */
211 extern RTS_FLAGS RtsFlags[];
212 #else
213 extern RTS_FLAGS RtsFlags;
214 #endif
215
216 /* Routines that operate-on/to-do-with RTS flags: */
217
218 void initRtsFlagsDefaults(void);
219 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
220 void setProgName(char *argv[]);
221
222
223 /*
224  * The printf formats are here, so we are less likely to make
225  * overly-long filenames (with disastrous results).  No more than 128
226  * chars, please!  
227  */
228
229 #define STATS_FILENAME_MAXLEN   128
230
231 #define GR_FILENAME_FMT         "%0.124s.gr"
232 #define GR_FILENAME_FMT_GUM     "%0.120s.%03d.%s"
233 #define HP_FILENAME_FMT         "%0.124s.hp"
234 #define LIFE_FILENAME_FMT       "%0.122s.life"
235 #define PROF_FILENAME_FMT       "%0.122s.prof"
236 #define PROF_FILENAME_FMT_GUM   "%0.118s.%03d.prof"
237 #define QP_FILENAME_FMT         "%0.124s.qp"
238 #define STAT_FILENAME_FMT       "%0.122s.stat"
239 #define TICKY_FILENAME_FMT      "%0.121s.ticky"
240 #define TIME_FILENAME_FMT       "%0.122s.time"
241 #define TIME_FILENAME_FMT_GUM   "%0.118s.%03d.time"
242
243 /* an "int" so as to match normal "argc" */
244 /* Now defined in Stg.h (lib/std/cbits need these too.)
245 extern int     prog_argc;
246 extern char  **prog_argv;
247 */
248 extern int     rts_argc;  /* ditto */
249 extern char   *rts_argv[];
250
251 #endif  /* RTS_FLAGS_H */