Move GC tracing into a separate trace class
[ghc.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 nat stkChunkSize; /* in *words* */
33 nat stkChunkBufferSize; /* in *words* */
34
35 nat maxHeapSize; /* in *blocks* */
36 nat minAllocAreaSize; /* in *blocks* */
37 nat minOldGenSize; /* in *blocks* */
38 nat heapSizeSuggestion; /* in *blocks* */
39 rtsBool heapSizeSuggestionAuto;
40 double oldGenFactor;
41 double pcFreeHeap;
42
43 nat generations;
44 nat steps;
45 rtsBool squeezeUpdFrames;
46
47 rtsBool compact; /* True <=> "compact all the time" */
48 double compactThreshold;
49
50 rtsBool sweep; /* use "mostly mark-sweep" instead of copying
51 * for the oldest generation */
52 rtsBool ringBell;
53 rtsBool frontpanel;
54
55 int idleGCDelayTime; /* in milliseconds */
56
57 StgWord heapBase; /* address to ask the OS for memory */
58 };
59
60 struct DEBUG_FLAGS {
61 /* flags to control debugging output & extra checking in various subsystems */
62 rtsBool scheduler; /* 's' */
63 rtsBool interpreter; /* 'i' */
64 rtsBool weak; /* 'w' */
65 rtsBool gccafs; /* 'G' */
66 rtsBool gc; /* 'g' */
67 rtsBool block_alloc; /* 'b' */
68 rtsBool sanity; /* 'S' warning: might be expensive! */
69 rtsBool stable; /* 't' */
70 rtsBool prof; /* 'p' */
71 rtsBool linker; /* 'l' the object linker */
72 rtsBool apply; /* 'a' */
73 rtsBool stm; /* 'm' */
74 rtsBool squeeze; /* 'z' stack squeezing & lazy blackholing */
75 rtsBool hpc; /* 'c' coverage */
76 rtsBool sparks; /* 'r' */
77 };
78
79 struct COST_CENTRE_FLAGS {
80 unsigned int doCostCentres;
81 # define COST_CENTRES_SUMMARY 1
82 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
83 # define COST_CENTRES_ALL 3
84 # define COST_CENTRES_XML 4
85
86 int profilerTicks; /* derived */
87 int msecsPerTick; /* derived */
88 };
89
90 struct PROFILING_FLAGS {
91 unsigned int doHeapProfile;
92 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
93 # define HEAP_BY_CCS 1
94 # define HEAP_BY_MOD 2
95 # define HEAP_BY_DESCR 4
96 # define HEAP_BY_TYPE 5
97 # define HEAP_BY_RETAINER 6
98 # define HEAP_BY_LDV 7
99
100 # define HEAP_BY_CLOSURE_TYPE 8
101
102 nat profileInterval; /* delta between samples (in ms) */
103 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
104 rtsBool includeTSOs;
105
106
107 rtsBool showCCSOnException;
108
109 nat maxRetainerSetSize;
110
111 nat ccsLength;
112
113 char* modSelector;
114 char* descrSelector;
115 char* typeSelector;
116 char* ccSelector;
117 char* ccsSelector;
118 char* retainerSelector;
119 char* bioSelector;
120
121 };
122
123 #define TRACE_NONE 0
124 #define TRACE_EVENTLOG 1
125 #define TRACE_STDERR 2
126
127 struct TRACE_FLAGS {
128 int tracing;
129 rtsBool timestamp; /* show timestamp in stderr output */
130 rtsBool scheduler; /* trace scheduler events */
131 rtsBool gc; /* trace GC events */
132 rtsBool sparks; /* trace spark events */
133 };
134
135 struct CONCURRENT_FLAGS {
136 int ctxtSwitchTime; /* in milliseconds */
137 int ctxtSwitchTicks; /* derived */
138 };
139
140 struct MISC_FLAGS {
141 int tickInterval; /* in milliseconds */
142 rtsBool install_signal_handlers;
143 rtsBool machineReadable;
144 StgWord linkerMemBase; /* address to ask the OS for memory
145 * for the linker, NULL ==> off */
146 };
147
148 #ifdef THREADED_RTS
149 struct PAR_FLAGS {
150 nat nNodes; /* number of threads to run simultaneously */
151 rtsBool migrate; /* migrate threads between capabilities */
152 unsigned int maxLocalSparks;
153 rtsBool parGcEnabled; /* enable parallel GC */
154 unsigned int parGcGen; /* do parallel GC in this generation
155 * and higher only */
156 rtsBool parGcLoadBalancingEnabled;
157 /* enable load-balancing in the
158 * parallel GC */
159 unsigned int parGcLoadBalancingGen;
160 /* do load-balancing in this
161 * generation and higher only */
162 rtsBool setAffinity; /* force thread affinity with CPUs */
163 };
164 #endif /* THREADED_RTS */
165
166 struct TICKY_FLAGS {
167 rtsBool showTickyStats;
168 FILE *tickyFile;
169 };
170
171 #ifdef USE_PAPI
172 #define MAX_PAPI_USER_EVENTS 8
173
174 struct PAPI_FLAGS {
175 nat eventType; /* The type of events to count */
176 nat numUserEvents;
177 char * userEvents[MAX_PAPI_USER_EVENTS];
178 /* Allow user to enter either PAPI preset or native events */
179 nat userEventsKind[MAX_PAPI_USER_EVENTS];
180 };
181
182 #define PAPI_FLAG_CACHE_L1 1
183 #define PAPI_FLAG_CACHE_L2 2
184 #define PAPI_FLAG_BRANCH 3
185 #define PAPI_FLAG_STALLS 4
186 #define PAPI_FLAG_CB_EVENTS 5
187 #define PAPI_USER_EVENTS 6
188 #define PAPI_PRESET_EVENT_KIND 0
189 #define PAPI_NATIVE_EVENT_KIND 1
190
191 #endif
192
193 /* Put them together: */
194
195 typedef struct _RTS_FLAGS {
196 /* The first portion of RTS_FLAGS is invariant. */
197 struct GC_FLAGS GcFlags;
198 struct CONCURRENT_FLAGS ConcFlags;
199 struct MISC_FLAGS MiscFlags;
200 struct DEBUG_FLAGS DebugFlags;
201 struct COST_CENTRE_FLAGS CcFlags;
202 struct PROFILING_FLAGS ProfFlags;
203 struct TRACE_FLAGS TraceFlags;
204 struct TICKY_FLAGS TickyFlags;
205
206 #if defined(THREADED_RTS)
207 struct PAR_FLAGS ParFlags;
208 #endif
209 #ifdef USE_PAPI
210 struct PAPI_FLAGS PapiFlags;
211 #endif
212 } RTS_FLAGS;
213
214 #ifdef COMPILING_RTS_MAIN
215 extern DLLIMPORT RTS_FLAGS RtsFlags;
216 #elif IN_STG_CODE
217 /* Hack because the C code generator can't generate '&label'. */
218 extern RTS_FLAGS RtsFlags[];
219 #else
220 extern RTS_FLAGS RtsFlags;
221 #endif
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 */