Normalize line endings.
[mono.git] / man / mono.1
1 .\" 
2 .\" mono manual page.
3 .\" Copyright 2003 Ximian, Inc. 
4 .\" Copyright 2004-2009 Novell, Inc. 
5 .\" Author:
6 .\"   Miguel de Icaza (miguel@gnu.org)
7 .\"
8 .TH Mono "Mono 2.5"
9 .SH NAME
10 mono \- Mono's ECMA-CLI native code generator (Just-in-Time and Ahead-of-Time)
11 .SH SYNOPSIS
12 .PP
13 .B mono [options] file [arguments...]
14 .PP
15 .B mono-sgen [options] file [arguments...]
16 .SH DESCRIPTION
17 \fImono\fP is a runtime implementation of the ECMA Common Language
18 Infrastructure.  This can be used to run ECMA and .NET applications.
19 .PP
20 The runtime contains a native code generator that transforms the
21 Common Intermediate Language into native code.
22 .PP
23 The code generator can operate in two modes: just in time compilation
24 (JIT) or ahead of time compilation (AOT).  Since code can be
25 dynamically loaded, the runtime environment and the JIT are always
26 present, even if code is compiled ahead of time.
27 .PP
28 The runtime loads the specified
29 .I file
30 and optionally passes
31 the
32 .I arguments
33 to it.  The 
34 .I file
35 is an ECMA assembly.  They typically have a .exe or .dll extension.
36 .PP
37 The runtime provides a number of configuration options for running
38 applications, for developing and debugging, and for testing and
39 debugging the runtime itself.
40 .PP
41 The \fImono\fP command uses the Boehm conservative garbage collector
42 while the \fImono-sgen\fP command uses a moving and generational
43 garbage collector.
44 .SH PORTABILITY
45 On Unix-based systems, Mono provides a mechanism to emulate the 
46 Windows-style file access, this includes providing a case insensitive
47 view of the file system, directory separator mapping (from \\ to /) and
48 stripping the drive letters.
49 .PP
50 This functionality is enabled by setting the 
51 .B MONO_IOMAP 
52 environment variable to one of 
53 .B all, drive
54 and 
55 .B case.
56 .PP
57 See the description for 
58 .B MONO_IOMAP
59 in the environment variables section for more details.
60 .SH RUNTIME OPTIONS
61 The following options are available:
62 .TP
63 \fB--aot\fR, \fB--aot[=options]\fR
64 This option is used to precompile the CIL code in the specified
65 assembly to native code.  The generated code is stored in a file with
66 the extension .so.  This file will be automatically picked up by the
67 runtime when the assembly is executed.  
68 .Sp 
69 Ahead-of-Time compilation is most useful if you use it in combination
70 with the -O=all,-shared flag which enables all of the optimizations in
71 the code generator to be performed.  Some of those optimizations are
72 not practical for Just-in-Time compilation since they might be very
73 time consuming.
74 .Sp
75 Unlike the .NET Framework, Ahead-of-Time compilation will not generate
76 domain independent code: it generates the same code that the
77 Just-in-Time compiler would produce.   Since most applications use a
78 single domain, this is fine.   If you want to optimize the generated
79 code for use in multi-domain applications, consider using the
80 -O=shared flag.
81 .Sp
82 This pre-compiles the methods, but the original assembly is still
83 required to execute as this one contains the metadata and exception
84 information which is not available on the generated file.  When
85 precompiling code, you might want to compile with all optimizations
86 (-O=all).  Pre-compiled code is position independent code.
87 .Sp
88 Pre compilation is just a mechanism to reduce startup time, increase
89 code sharing across multiple mono processes and avoid just-in-time
90 compilation program startup costs.  The original assembly must still
91 be present, as the metadata is contained there.
92 .Sp
93 AOT code typically can not be moved from one computer to another
94 (CPU-specific optimizations that are detected at runtime) so you
95 should not try to move the pre-generated assemblies or package the
96 pre-generated assemblies for deployment.    
97 .Sp
98 A few options are available as a parameter to the 
99 .B --aot 
100 command line option.   The options are separated by commas, and more
101 than one can be specified:
102 .RS
103 .ne 8
104 .TP
105 .I bind-to-runtime-version
106 .Sp
107 If specified, forces the generated AOT files to be bound to the
108 runtime version of the compiling Mono.   This will prevent the AOT
109 files from being consumed by a different Mono runtime.
110 .I full
111 This is currently an experimental feature as it is not complete.
112 This instructs Mono to precompile code that has historically not been
113 precompiled with AOT.   
114 .TP
115 .I outfile=[filename]
116 Instructs the AOT compiler to save the output to the specified file.
117 .TP
118 .I write-symbols
119 Instructs the AOT compiler to emit debug symbol information.
120 .TP
121 .I save-temps,keep-temps
122 Instructs the AOT compiler to keep temporary files.
123 .TP
124 .I threads=[number]
125 This is an experimental option for the AOT compiler to use multiple threads
126 when compiling the methods.
127 .TP
128 .I nodebug
129 Instructs the AOT compiler to not output any debugging information.
130 .TP
131 .I ntrampolines=[number]
132 When compiling in full aot mode, the method trampolines must be precreated
133 in the AOT image.  You can add additional method trampolines with this argument.
134 Defaults to 1024.
135 .TP
136 .I nrgctx-trampolines=[number]
137 When compiling in full aot mode, the generic sharing trampolines must be precreated
138 in the AOT image.  You can add additional method trampolines with this argument.
139 Defaults to 1024.
140 .TP
141 .I nimt-trampolines=[number]
142 When compiling in full aot mode, the IMT trampolines must be precreated
143 in the AOT image.  You can add additional method trampolines with this argument.
144 Defaults to 128.
145 .TP
146 .I print-skipped-methods
147 If the AOT compiler cannot compile a method for any reason, enabling this flag
148 will output the skipped methods to the console.
149 .TP
150 .I autoreg
151 The AOT compiler will emit a (ELF only) library initializer to automatically
152 register the aot compiled module with the runtime.  This is only useful in static
153 mode
154 .TP
155 .I asmonly
156 Instructs the AOT compiler to output assembly code instead of an object file.
157 .TP
158 .I soft-debug
159 This instructs the compiler to generate sequence point checks that
160 allow Mono's soft debugger to debug applications even on systems where
161 it is not possible to set breakpoints or to single step (certain
162 hardware configurations like the cell phones and video gaming
163 consoles). 
164 .TP
165 .I static
166 Create an ELF object file (.o) which can be statically linked into an executable
167 when embedding the mono runtime. When this option is used, the object file needs to
168 be registered with the embedded runtime using the mono_aot_register_module function
169 which takes as its argument the mono_aot_module_<ASSEMBLY NAME>_info global symbol 
170 from the object file:
171
172 .nf
173 extern void *mono_aot_module_hello_info;
174
175 mono_aot_register_module (mono_aot_module_hello_info);
176 .fi
177 .ne
178
179 .PP
180 For more information about AOT, see: http://www.mono-project.com/AOT
181 .RE
182 .TP
183 \fB--attach=[options]\fR
184 Currently the only option supported by this command line argument is
185 \fBdisable\fR which disables the attach functionality.
186 .TP
187 \fB--config filename\fR
188 Load the specified configuration file instead of the default one(s).
189 The default files are /etc/mono/config and ~/.mono/config or the file
190 specified in the MONO_CONFIG environment variable, if set.  See the
191 mono-config(5) man page for details on the format of this file.
192 .TP
193 \fB--debugger-agent=[options]\fR 
194 This instructs the Mono runtime to
195 start a debugging agent inside the Mono runtime and connect it to a
196 client user interface will control the Mono process.
197 This option is typically used by IDEs, like the MonoDevelop IDE.
198 .PP
199 The
200 configuration is specified using one of more of the following options:
201 .RS
202 .ne 8
203 .TP
204 .I transport=transport_name
205 .Sp
206 This is used to specify the transport that the debugger will use to
207 communicate.   It must be specified and currently requires this to
208 be 'dt_socket'. 
209 .TP
210 .I address=host:port
211 .Sp
212 Use this option to specify the IP address where your debugger client is
213 listening to.
214 .TP
215 .I loglevel=LEVEL
216 .Sp
217 Specifies the diagnostics log level for 
218 .TP
219 .I logfile=filename
220 .Sp
221 Used to specify the file where the log will be stored, it defaults to
222 standard output.
223 .ne
224 .RE
225 .TP
226 \fB--desktop\fR
227 Configures the virtual machine to be better suited for desktop
228 applications.  Currently this sets the GC system to avoid expanding
229 the heap as much as possible at the expense of slowing down garbage
230 collection a bit.
231 .TP
232 \fB--full-aot\fR
233 This is an experimental flag that instructs the Mono runtime to not
234 generate any code at runtime and depend exclusively on the code
235 generated from using mono --aot=full previously.   This is useful for
236 platforms that do not permit dynamic code generation.
237 .Sp
238 Notice that this feature will abort execution at runtime if a codepath
239 in your program, or Mono's class libraries attempts to generate code
240 dynamically.  You should test your software upfront and make sure that
241 you do not use any dynamic features.
242 .TP
243 \fB--gc=boehm\fR, \fB--gc=sgen\fR
244 Selects the Garbage Collector engine for Mono to use, Boehm or SGen.
245 Currently this merely ensures that you are running either the
246 \fImono\fR or \fImono-sgen\fR commands.    This flag can be set in the
247 \fBMONO_ENV_OPTIONS\fR environment variable to force all of your child
248 processes to use one particular kind of GC with the Mono runtime.
249 .TP
250 \fB--help\fR, \fB-h\fR
251 Displays usage instructions.
252 .TP
253 \fB--llvm\fR
254 If the Mono runtime has been compiled with LLVM support (not available
255 in all configurations), Mono will use the LLVM optimization and code
256 generation engine to JIT or AOT compile.     
257 .Sp
258 For more information, consult: http://www.mono-project.com/Mono_LLVM
259 .TP
260 \fB--nollvm\fR
261 When using a Mono that has been compiled with LLVM support, it forces
262 Mono to fallback to its JIT engine and not use the LLVM backend.
263 .TP
264 \fB--optimize=MODE\fR, \fB-O=MODE\fR
265 MODE is a comma separated list of optimizations.  They also allow
266 optimizations to be turned off by prefixing the optimization name with
267 a minus sign.
268 .Sp
269 In general, Mono has been tuned to use the default set of flags,
270 before using these flags for a deployment setting, you might want to
271 actually measure the benefits of using them.    
272 .Sp
273 The following optimizations are implemented:
274 .nf
275              all        Turn on all optimizations
276              peephole   Peephole postpass
277              branch     Branch optimizations
278              inline     Inline method calls
279              cfold      Constant folding
280              consprop   Constant propagation
281              copyprop   Copy propagation
282              deadce     Dead code elimination
283              linears    Linear scan global reg allocation
284              cmov       Conditional moves [arch-dependency]
285              shared     Emit per-domain code
286              sched      Instruction scheduling
287              intrins    Intrinsic method implementations
288              tailc      Tail recursion and tail calls
289              loop       Loop related optimizations
290              fcmov      Fast x86 FP compares [arch-dependency]
291              leaf       Leaf procedures optimizations
292              aot        Usage of Ahead Of Time compiled code
293              precomp    Precompile all methods before executing Main
294              abcrem     Array bound checks removal
295              ssapre     SSA based Partial Redundancy Elimination
296              sse2       SSE2 instructions on x86 [arch-dependency]
297              gshared    Enable generic code sharing.
298 .fi
299 .Sp
300 For example, to enable all the optimization but dead code
301 elimination and inlining, you can use:
302 .nf
303         -O=all,-deadce,-inline
304 .fi
305 .Sp
306 The flags that are flagged with [arch-dependency] indicate that the
307 given option if used in combination with Ahead of Time compilation
308 (--aot flag) would produce pre-compiled code that will depend on the
309 current CPU and might not be safely moved to another computer. 
310 .TP
311 \fB--runtime=VERSION\fR
312 Mono supports different runtime versions. The version used depends on the program
313 that is being run or on its configuration file (named program.exe.config). This option
314 can be used to override such autodetection, by forcing a different runtime version
315 to be used. Note that this should only be used to select a later compatible runtime
316 version than the one the program was compiled against. A typical usage is for
317 running a 1.1 program on a 2.0 version:
318 .nf
319          mono --runtime=v2.0.50727 program.exe
320 .fi
321 .TP
322 \fB--security\fR, \fB--security=mode\fR
323 Activate the security manager, a currently experimental feature in
324 Mono and it is OFF by default. The new code verifier can be enabled
325 with this option as well.
326 .RS
327 .ne 8
328 .PP
329 Using security without parameters is equivalent as calling it with the
330 "cas" parameter.  
331 .PP
332 The following modes are supported:
333 .TP
334 .I cas
335 This allows mono to support declarative security attributes,
336 e.g. execution of Code Access Security (CAS) or non-CAS demands.
337 .TP 
338 .I core-clr
339 Enables the core-clr security system, typically used for
340 Moonlight/Silverlight applications.  It provides a much simpler
341 security system than CAS, see http://www.mono-project.com/Moonlight
342 for more details and links to the descriptions of this new system. 
343 .TP
344 .I validil
345 Enables the new verifier and performs basic verification for code
346 validity.  In this mode, unsafe code and P/Invoke are allowed. This
347 mode provides a better safety guarantee but it is still possible
348 for managed code to crash Mono. 
349 .TP
350 .I verifiable
351 Enables the new verifier and performs full verification of the code
352 being executed.  It only allows verifiable code to be executed.
353 Unsafe code is not allowed but P/Invoke is.  This mode should
354 not allow managed code to crash mono.  The verification is not as
355 strict as ECMA 335 standard in order to stay compatible with the MS
356 runtime.
357 .PP
358 The security system acts on user code: code contained in mscorlib or
359 the global assembly cache is always trusted.
360 .ne
361 .RE
362 .TP
363 \fB--server\fR
364 Configures the virtual machine to be better suited for server
365 operations (currently, a no-op).
366 .TP
367 \fB--verify-all\fR 
368 Verifies mscorlib and assemblies in the global
369 assembly cache for valid IL, and all user code for IL
370 verifiability. 
371
372 This is different from \fB--security\fR's verifiable
373 or validil in that these options only check user code and skip
374 mscorlib and assemblies located on the global assembly cache.
375 .TP
376 \fB-V\fR, \fB--version\fR
377 Prints JIT version information (system configuration, release number
378 and branch names if available). 
379
380
381 .SH DEVELOPMENT OPTIONS
382 The following options are used to help when developing a JITed application.
383 .TP
384 \fB--debug\fR, \fB--debug=OPTIONS\fR
385 Turns on the debugging mode in the runtime.  If an assembly was
386 compiled with debugging information, it will produce line number
387 information for stack traces. 
388 .RS
389 .ne 8
390 .PP
391 The optional OPTIONS argument is a comma separated list of debugging
392 options.  These options are turned off by default since they generate
393 much larger and slower code at runtime.
394 .TP
395 The following options are supported:
396 .TP
397 .I casts
398 Produces a detailed error when throwing a InvalidCastException.   This
399 option needs to be enabled as this generates more verbose code at
400 execution time. 
401 .TP
402 .I mdb-optimizations
403 Disable some JIT optimizations which are usually only disabled when
404 running inside the debugger.  This can be helpful if you want to attach
405 to the running process with mdb.
406 .TP
407 .I gdb
408 Generate and register debugging information with gdb. This is only supported on some
409 platforms, and only when using gdb 7.0 or later.
410 .ne
411 .RE
412 .TP
413 \fB--profile[=profiler[:profiler_args]]\fR
414 Turns on profiling.  For more information about profiling applications
415 and code coverage see the sections "PROFILING" and "CODE COVERAGE"
416 below. 
417 .TP
418 \fB--trace[=expression]\fR
419 Shows method names as they are invoked.  By default all methods are
420 traced. 
421 .Sp
422 The trace can be customized to include or exclude methods, classes or
423 assemblies.  A trace expression is a comma separated list of targets,
424 each target can be prefixed with a minus sign to turn off a particular
425 target.  The words `program', `all' and `disabled' have special
426 meaning.  `program' refers to the main program being executed, and
427 `all' means all the method calls.
428 .Sp
429 The `disabled' option is used to start up with tracing disabled.  It
430 can be enabled at a later point in time in the program by sending the
431 SIGUSR2 signal to the runtime.
432 .Sp
433 Assemblies are specified by their name, for example, to trace all
434 calls in the System assembly, use:
435 .nf
436
437         mono --trace=System app.exe
438
439 .fi
440 Classes are specified with the T: prefix.  For example, to trace all
441 calls to the System.String class, use:
442 .nf
443
444         mono --trace=T:System.String app.exe
445
446 .fi
447 And individual methods are referenced with the M: prefix, and the
448 standard method notation:
449 .nf
450
451         mono --trace=M:System.Console:WriteLine app.exe
452
453 .fi
454 Exceptions can also be traced, it will cause a stack trace to be
455 printed every time an exception of the specified type is thrown.
456 The exception type can be specified with or without the namespace,
457 and to trace all exceptions, specify 'all' as the type name.
458 .nf
459
460         mono --trace=E:System.Exception app.exe
461
462 .fi
463 As previously noted, various rules can be specified at once:
464 .nf
465
466         mono --trace=T:System.String,T:System.Random app.exe
467
468 .fi
469 You can exclude pieces, the next example traces calls to
470 System.String except for the System.String:Concat method.
471 .nf
472
473         mono --trace=T:System.String,-M:System.String:Concat
474
475 .fi
476 Finally, namespaces can be specified using the N: prefix:
477 .nf
478
479         mono --trace=N:System.Xml
480
481 .fi
482 .TP
483 \fB--no-x86-stack-align\fR
484 Don't align stack frames on the x86 architecture.  By default, Mono
485 aligns stack frames to 16 bytes on x86, so that local floating point
486 and SIMD variables can be properly aligned.  This option turns off the
487 alignment, which usually saves one intruction per call, but might
488 result in significantly lower floating point and SIMD performance.
489 .TP
490 \fB--jitmap\fR
491 Generate a JIT method map in a /tmp/perf-PID.map file. This file is then
492 used, for example, by the perf tool included in recent Linux kernels.
493 Each line in the file has:
494 .nf
495
496         HEXADDR HEXSIZE methodname
497
498 .fi
499 Currently this option is only supported on Linux.
500 .SH JIT MAINTAINER OPTIONS
501 The maintainer options are only used by those developing the runtime
502 itself, and not typically of interest to runtime users or developers.
503 .TP
504 \fB--break method\fR
505 Inserts a breakpoint before the method whose name is `method'
506 (namespace.class:methodname).  Use `Main' as method name to insert a
507 breakpoint on the application's main method.
508 .TP
509 \fB--breakonex\fR
510 Inserts a breakpoint on exceptions.  This allows you to debug your
511 application with a native debugger when an exception is thrown.
512 .TP
513 \fB--compile name\fR
514 This compiles a method (namespace.name:methodname), this is used for
515 testing the compiler performance or to examine the output of the code
516 generator. 
517 .TP
518 \fB--compileall\fR
519 Compiles all the methods in an assembly.  This is used to test the
520 compiler performance or to examine the output of the code generator
521 .TP 
522 \fB--graph=TYPE METHOD\fR
523 This generates a postscript file with a graph with the details about
524 the specified method (namespace.name:methodname).  This requires `dot'
525 and ghostview to be installed (it expects Ghostview to be called
526 "gv"). 
527 .Sp
528 The following graphs are available:
529 .nf
530           cfg        Control Flow Graph (CFG)
531           dtree      Dominator Tree
532           code       CFG showing code
533           ssa        CFG showing code after SSA translation
534           optcode    CFG showing code after IR optimizations
535 .fi
536 .Sp
537 Some graphs will only be available if certain optimizations are turned
538 on.
539 .TP
540 \fB--ncompile\fR
541 Instruct the runtime on the number of times that the method specified
542 by --compile (or all the methods if --compileall is used) to be
543 compiled.  This is used for testing the code generator performance. 
544 .TP 
545 \fB--stats\fR
546 Displays information about the work done by the runtime during the
547 execution of an application. 
548 .TP
549 \fB--wapi=hps|semdel\fR
550 Perform maintenance of the process shared data.
551 .Sp
552 semdel will delete the global semaphore.
553 .Sp
554 hps will list the currently used handles.
555 .TP
556 \fB-v\fR, \fB--verbose\fR
557 Increases the verbosity level, each time it is listed, increases the
558 verbosity level to include more information (including, for example, 
559 a disassembly of the native code produced, code selector info etc.).
560 .SH ATTACH SUPPORT
561 The Mono runtime allows external processes to attach to a running
562 process and load assemblies into the running program.   To attach to
563 the process, a special protocol is implemented in the Mono.Management
564 assembly. 
565 .PP
566 With this support it is possible to load assemblies that have an entry
567 point (they are created with -target:exe or -target:winexe) to be
568 loaded and executed in the Mono process.
569 .PP
570 The code is loaded into the root domain, and it starts execution on
571 the special runtime attach thread.    The attached program should
572 create its own threads and return after invocation.
573 .PP
574 This support allows for example debugging applications by having the
575 csharp shell attach to running processes.
576 .SH PROFILING
577 The mono runtime includes a profiler that can be used to explore
578 various performance related problems in your application.  The
579 profiler is activated by passing the --profile command line argument
580 to the Mono runtime, the format is:
581 .nf
582
583         --profile[=profiler[:profiler_args]]
584
585 .fi
586 Mono has a built-in profiler called 'default' (and is also the default
587 if no arguments are specified), but developers can write custom
588 profilers, see the section "CUSTOM PROFILERS" for more details.
589 .PP
590 If a 
591 .I profiler 
592 is not specified, the default profiler is used.
593 .Sp
594 The 
595 .I profiler_args 
596 is a profiler-specific string of options for the profiler itself.
597 .Sp
598 The default profiler accepts the following options 'alloc' to profile
599 memory consumption by the application; 'time' to profile the time
600 spent on each routine; 'jit' to collect time spent JIT-compiling methods
601 and 'stat' to perform sample statistical profiling.
602 If no options are provided the default is 'alloc,time,jit'. 
603 .PP
604 By default the
605 profile data is printed to stdout: to change this, use the 'file=filename'
606 option to output the data to filename.
607 .Sp
608 For example:
609 .nf
610
611         mono --profile program.exe
612
613 .fi
614 .Sp
615 That will run the program with the default profiler and will do time
616 and allocation profiling.
617 .Sp
618 .nf
619
620         mono --profile=default:stat,alloc,file=prof.out program.exe
621
622 .fi
623 Will do  sample statistical profiling and allocation profiling on
624 program.exe. The profile data is put in prof.out.
625 .Sp
626 Note that the statistical profiler has a very low overhead and should
627 be the preferred profiler to use (for better output use the full path
628 to the mono binary when running and make sure you have installed the
629 addr2line utility that comes from the binutils package).
630 .SH LOGGING PROFILER
631 .PP
632 The
633 .I logging profiler
634 is a general purpose profiler that can track many different kinds of
635 events and logs those into a file as the program executes.   This is
636 different than previous profilers in Mono that kept the information in
637 memory and rendered a summary of the results when the program shut
638 down.
639 .PP
640 Using the logging profiler means that useful information can be
641 gathered for long-running applications, applications that terminate
642 abormally (crashes, segfaults, complicated tear down processes) or
643 when no data about the shutdown is required.
644 .PP
645 The data collected by the running threads is kept independent of each
646 other to minimize the runtime overhead and the information dumped into
647 the log at regular intervals. 
648 .PP
649 A sample use is very simple:
650 .nf
651         $ mono --profile=logging program.exe
652
653         $ mprof-decoder program.mprof
654 .fi
655 .PP
656 In the above example the logging profiler is used in its default mode
657 that merely records GC statistics for the execution of program.exe.
658 The profiling data collected is stored in the file program.mprof.  The
659 mprof-decoder tool is then used to analyze the data.
660 .PP
661 You can instruct the logging profiler to record different one or more
662 sets of events.   These are the modes supported:
663 .IP
664 .I Statistical Profiling (stat)
665 the program instruction pointer is periodically sampled to determine
666 where the program is spending most of its time.   Statistical
667 profiling has a very low impact on a running application and it is
668 very useful to get a general picture of where time is being spent on a
669 program.   
670 .IP 
671 If call chains are requested, for each sample the profiler gets a
672 partial stack trace (limited by the specified depth) so that
673 caller-callee information is available.
674 .IP
675 .I Instrumenting:
676 each method enter and exit is logged with a timestamp; further processing of
677 the data can show the methods that took the longer to execute, with complete
678 accounting for callers and callees. However, this way of profiling is rather
679 intrusive and slows down the application significantly.
680 .IP
681 .I Allocation:
682 each allocation is logged.
683 .IP
684 .I Allocation summary:
685 shows, for each collection, a summary of the heap contents broken down by
686 class (for each class the number of allocated and released objects is
687 given, together with their aggregated size in bytes).
688 .IP
689 .I Heap snapshot mode:
690 dumps the whole heap contents at every collection (or at user specified
691 collections). It is also possible to request a collection and snapshot dump
692 with a signal.
693 .PP
694 Moreover, other events can be logged and analyzed, like jit time for each
695 method, load and unload for assemblies, modules and and individual classes,
696 and appdomain and thread creation and destruction.
697 .PP
698 This profiler is activated passing the \fB--profile=logging\fR option to
699 the mono runtime, and is controlled attaching further options, like
700 \fB--profile=logging:statistical\fR for doing statistical profiling (multiple
701 options are separated by commas).
702 .PP
703 As a quick primer, here are a few examples of the most common usage modes:
704 .PP
705 To perform statistical profiling:
706 .nf
707
708         mono --profile=logging:stat program.exe
709 .fi
710 .PP
711 To perform statistical profiling, inspecting call chains up to depth 8:
712 .nf
713
714         mono --profile=logging:stat=8 program.exe
715 .fi
716 .PP
717 To profile allocations (by default the call stack will be analized for
718 each allocation, producing detailed caller method attribution infornation):
719 .nf
720
721         mono --profile=logging:allocations program.exe
722 .fi
723 .PP
724 To profile garbage collection activity at a high level (collection time and objects freed
725 at each collection for each class are reported, but heap snapshots are not saved to disk):
726 .nf
727
728         mono --profile=logging:allocations-summary program.exe
729 .fi
730 .PP
731 To perform heap profiling taking heap snapshots:
732 .nf
733
734         mono --profile=logging:heap=all program.exe
735 .fi
736 .PP
737 To write the resulting data to a different file:
738 .nf
739
740         mono --profile=logging:output=mydata.mprof program.exe
741 .fi
742 .PP
743 Then you would need to invoke the decoder \fImprof-decoder(1)\fR
744 on the output file to see the profiling results, or to examine heap
745 snapshots and allocations in detail \fImprof-heap-viewer(1)\fR.
746 .PP
747 The operating modes described above are the default ones, and are sufficient
748 to use the profiler.
749 .PP
750 To further customize the profiler behavior there are more options, described
751 below.
752 .PP
753 These options can be individually enabled and disabled prefixing them
754 with an (optional) '+' character or a '-' character.  For instance,
755 the "allocations" option by default records also the full call stack
756 at each allocation.  If only the caller is wanted, one should use
757 "allocations,-save-allocation-stack", or to disable call tracking
758 completely (making the profiler less intrusive)
759 "allocations,-save-allocation-caller,-save-allocation-stack".  In
760 practice the "allocation" option by default behaves like
761 "allocations,save-allocation-caller,save-allocation-stack", but the
762 user can tune this to his needs.
763 .PP
764 These are all the available options, organized by category:
765 .PP
766 \fBExecution profiling modes\fR
767 .RS
768 .ne 8
769 .TP
770 \fIstatistical\fR, \fIstat\fR or \fIs\fR
771 Performs statistical profiling.   This is a lightweight profiling
772 mechanism and it has a much lower overhead than the \fIenter-leave\fR
773 profiling as it works by sampling where the program is spending its
774 time by using a timer.
775 If specified with \fIs=<number>\fR, also inspect call chains up to level
776 <number>.
777 .TP
778 \fIenter-leave\fR, \fIcalls\fR or \fIc\fR
779 Measure the time spent inside each method call, this is done by
780 logging the time when a method enters and when the method leaves.
781 This can be a time consuming operation. 
782 .TP
783 \fIjit\fR, \fIj\fR
784 Collect information about time spent by the JIT engine compiling
785 methods. 
786 .ne
787 .RE
788 .PP
789 \fBAllocation profiling modes\fR
790 .RS
791 .ne 8
792 .TP
793 \fIallocations\fR, \fIalloc\fR or \fIa\fR
794 Collect information about each allocation (object class and size).
795 By default this also implies "+save-allocation-caller" and
796 "+save-allocation-stack".
797 .TP
798 \fIsave-allocation-caller\fR, \fIsac\fR
799 Save the direct caller of each allocation. The profiler filters out wrapper
800 methods, and also recognizes if the allocation has been performed by the
801 runtime while jitting a method.
802 .TP
803 \fIsave-allocation-stack\fR, \fIsas\fR
804 Save the full managed execution stack at each allocation.
805 While the "sac" option saves the direct caller, this one records the whole
806 stack trace.
807 Note that in the call stack the wrapper methods are not filtered out.
808 Anyway the "sac" and "sas" options can be combined, and the decoder will
809 attribute the allocation to the correct method even if the wrapper is at the
810 top of the stack trace.
811 .TP
812 \fIallocations-summary\fR or \fIas\fR
813 At each collection dump a summary
814 of the heap contents (for each class, the number and collective size of all
815 live and freed heap objects). This very lightweight compared to full heap
816 snapshots.
817 .TP
818 \fIunreachable\fR, \fIfree\fR or \fIf\fR
819 Performs a lightweight profile of the garbage collector.  On each
820 collection performed by the GC, the list of unreachable objects is
821 recorded, and for each object the class and size is provided.  This
822 information can be used to compute the heap size broken down by class
823 (combined with "a" can give the same information of "as", but the log
824 file contains info about each individual object, while in "as" the
825 processing is done directly at runtime and the log file contains only
826 the summarized data broken down by class).
827 .TP
828 \fIgc\fR or \fIg\fR
829 Measure the time spent in each collection, and also trace heap resizes.
830 .TP
831 \fIheap-shot[=ARG]\fR, \fIheap[=ARG]\fR or \fIh[=ARH]\fR
832 Performs full heap profiling.   In this case on each
833 collection a full heap snapshot is recorded to disk.
834 Inside the snapshots, each object reference is still represented so
835 that it's possible to investigate who is responsible for keeping objects
836 alive.
837 .PP
838 If the value of ARG is 
839 .B all, 
840 a heap snapshot is taken at each collection.  
841 .PP
842 If the value is an integer
843 .B n,
844 a snapshot will be taken at the first
845 .B n
846 collections (like setting
847 .B gcd=n
848 );
849 .PP
850 If no additional argument is given to the heap option, the only way to take
851 heap snapshots is to requeste them using the runtime socket based command
852 interface described below (see "Profiler activity control").
853 .PP
854 Heap profiling also enables full allocation profiling (with call
855 stacks), and each allocation can be related to its corresponding
856 object in the snapshots, enabling investigations like "find all
857 objects of a given class allocated by a given method and still live at
858 a given collection, and then find all objects referencing them".
859 .PP
860 This kind of heap snapshot analysis is performed using the mprof-heap-viewer(1)
861 application.
862 .PP
863 The number of heap snapshots taken (and the moment in which they are taken)
864 can be further customized with the following options: 
865 .TP
866 \fIgc-dumps=N\fR, \fIgc-d=N\fR, \fIgcd=N\fR
867 states the number of snapshots that must be dumped (since the application
868 starts).  Zero means no dumps at all, -1 means dump at all collections.
869 .TP
870 These options exist because it can happen that the user wants to investigate
871 what happens during collections but without forcing a collection using the
872 command interface, because forcing a collection alters the program behavior.
873 Of course it is possible to simply take a snapshot at every collection, but
874 in some workloads this is could not be feasible (too much data).
875 So we have this "garbage collection dumps" counter to control how many
876 snapshots to take.
877 .ne
878 .RE
879 .PP
880 \fBProfiler activity control\fR
881 .RS
882 .ne 8
883 .TP
884 \fIoutput=FILE\fR, \fIout=FILE\fR or \fIo=FILE\fR
885 Use this option to provide the output file name for the profile log.
886 If this option is not specified, it will default to "<program-name>.mprof".
887 .TP
888 \fIoutput-suffix=SUFFIX\fR, \fIsuffix=SUFFIX\fR or \fIos=SUFFIX\fR: makes
889 the output file name equals to "<program-name>-SUFFIX.mprof".
890 .TP
891 \fIstart-enabled\fR or \fIse\fR: start with the profiler active
892 (which is the default).
893 .TP
894 \fIstart-disabled\fR or \fIsd\fR: start with the profiler inactive.
895 .TP
896 \fIforce-accurate-timer\fR (or \fIfac\fR): the profiler by default uses
897 rtdsc to acquire timestamps for frequent events, but this can be imprecise;
898 using this option you force the use of "gettimeofday" at every event, which
899 is more accurate but much slower.
900 .TP
901 \fIcommand-port=port\fR or \fIcp=port\fR (where port is an integer between
902 1024 nd 65535):
903 Choose a TCP port where the profiler will listen for user commands.
904 The protocol is ASCII based and line oriented (one line per command), and the
905 profiler answers with one line containing either "OK" or "ERROR" to each
906 received command.
907 .PP
908 The user can telnet to this port and give commands manually, or a GUI can
909 use this facility to control the profiler at runtime.
910 .PP
911 The available commands are:
912 .TP
913 \fIenable\fR: Enables the profiler.
914 .TP
915 \fIdisable\fR: Disables the profiler.
916 .TP
917 \fIheap-snapshot\fR: Takes a heap snapshot now (forces a full garbage collection).
918 .TP
919 \fIheap-snapshot-counter=arg\fR: Set the counter of the next heap snapshots
920 that must be taken, where arg can be "all" (take a snapshot at every
921 collection), "none" (do not take snapshots), or an integer "n" (take a heap
922 snapshot for the next "n" collections).
923 .ne
924 .RE
925 .PP
926 \fBInternal buffer sizes\fR
927 .RS
928 .ne 8
929 .TP
930 \fIper-thread-buffer-size=N\fR, \fItbs=N\fR
931 Use to specify the number of events that a thread buffer
932 can hold.   When the thread buffer is full, a log block is
933 written to disk.
934 .Sp
935 This defaults to tbs=10000.
936 .TP
937 \fIstatistical-thread-buffer-size=N\fR, \fIsbs=N\fR
938 The number of statistical samples that
939 are held in memory before they are dumped to disk (the system does
940 double-buffering and the statistical samples are written by a helper
941 thread, so the statistical profiler never stops and is able to profile
942 the profiler itself).  
943 .Sp
944 This defaults to sbs=10000.
945 .TP
946 \fIwrite-buffer-size\fR, \fIwbs\fR
947 Specifies the size in bytes of the internal write buffers.
948 .Sp
949 This defaults to wbs=1024.
950 .ne
951 .RE
952 .PP
953 In its current state, this profiler can also perform heap analysis
954 like the HeapShot profiler, but there is no UI to process this
955 information. 
956 .PP
957 Another known issue is that if the timer is not strictly monotonic (like
958 rtdsc), differences between times can underflow (they are handled as
959 unsigned integers) and weird numbers can show up in the logs.
960 .PP
961 Finally, it can happen that when exceptions are thrown the profiler temporarily
962 loses track of the execution stack and misattributes the caller for a few
963 allocations (and method execution time).
964 .PP
965 The output file contains compressed events, to process the data you should
966 use tools like the "Mono.Profiler" tool provided on the Mono SVN
967 repository.  
968 .PP
969 More explanations are provided here: "http://www.mono-project.com/LoggingProfiler".
970 .SH EXTERNAL PROFILERS
971 There are a number of external profilers that have been developed for
972 Mono, we will update this section to contain the profilers.
973 .PP
974 The heap Shot profiler can track all live objects, and references to
975 these objects, and includes a GUI tool, this is our recommended
976 profiler.
977 To install you must download the profiler
978 from Mono's SVN:
979 .nf
980         svn co svn://anonsvn.mono-project.com/source/trunk/heap-shot
981         cd heap-shot
982         ./autogen
983         make
984         make install
985 .fi
986 .PP
987 See the included documentation for details on using it.
988 .PP
989 The Live Type profiler shows at every GC iteration all of the live
990 objects of a given type.   To install you must download the profiler
991 from Mono's SVN:
992 .nf
993         svn co svn://anonsvn.mono-project.com/source/trunk/heap-prof
994         cd heap-prof
995         ./autogen
996         make
997         make install
998 .fi
999 .PP
1000 To use the profiler, execute:
1001 .nf
1002         mono --profile=desc-heap program.exe
1003 .fi
1004 .PP
1005 The output of this profiler looks like this:
1006 .nf
1007         Checkpoint at 102 for heap-resize
1008            System.MonoType : 708
1009            System.Threading.Thread : 352
1010            System.String : 3230
1011            System.String[] : 104
1012            Gnome.ModuleInfo : 112
1013            System.Object[] : 160
1014            System.Collections.Hashtable : 96
1015            System.Int32[] : 212
1016            System.Collections.Hashtable+Slot[] : 296
1017            System.Globalization.CultureInfo : 108
1018            System.Globalization.NumberFormatInfo : 144
1019 .fi
1020 .PP
1021 The first line describes the iteration number for the GC, in this case
1022 checkpoint 102.
1023 .PP
1024 Then on each line the type is displayed as well as the number of bytes
1025 that are being consumed by live instances of this object.
1026 .PP 
1027 The AOT profiler is used to feed back information to the AOT compiler
1028 about how to order code based on the access patterns for pages.  To
1029 use it, use:
1030 .nf
1031         mono --profile=aot program.exe
1032 .fi
1033 The output of this profile can be fed back into Mono's AOT compiler to
1034 order the functions on the disk to produce precompiled images that
1035 have methods in sequential pages.
1036 .SH CUSTOM PROFILERS
1037 Mono provides a mechanism for loading other profiling modules which in
1038 the form of shared libraries.  These profiling modules can hook up to
1039 various parts of the Mono runtime to gather information about the code
1040 being executed.
1041 .PP
1042 To use a third party profiler you must pass the name of the profiler
1043 to Mono, like this:
1044 .nf
1045
1046         mono --profile=custom program.exe
1047
1048 .fi
1049 .PP
1050 In the above sample Mono will load the user defined profiler from the
1051 shared library `mono-profiler-custom.so'.  This profiler module must
1052 be on your dynamic linker library path.
1053 .PP 
1054 A list of other third party profilers is available from Mono's web
1055 site (www.mono-project.com/Performance_Tips)
1056 .PP
1057 Custom profiles are written as shared libraries.  The shared library
1058 must be called `mono-profiler-NAME.so' where `NAME' is the name of
1059 your profiler.
1060 .PP
1061 For a sample of how to write your own custom profiler look in the
1062 Mono source tree for in the samples/profiler.c.
1063 .SH CODE COVERAGE
1064 Mono ships with a code coverage module.  This module is activated by
1065 using the Mono --profile=cov option.  The format is:
1066 \fB--profile=cov[:assembly-name[/namespace]] test-suite.exe\fR
1067 .PP
1068 By default code coverage will default to all the assemblies loaded,
1069 you can limit this by specifying the assembly name, for example to
1070 perform code coverage in the routines of your program use, for example
1071 the following command line limits the code coverage to routines in the
1072 "demo" assembly:
1073 .nf
1074
1075         mono --profile=cov:demo demo.exe
1076
1077 .fi
1078 .PP
1079 Notice that the 
1080 .I assembly-name
1081 does not include the extension.
1082 .PP
1083 You can further restrict the code coverage output by specifying a
1084 namespace:
1085 .nf
1086
1087         mono --profile=cov:demo/My.Utilities demo.exe
1088
1089 .fi
1090 .PP
1091 Which will only perform code coverage in the given assembly and
1092 namespace.  
1093 .PP
1094 Typical output looks like this:
1095 .nf
1096
1097         Not covered: Class:.ctor ()
1098         Not covered: Class:A ()
1099         Not covered: Driver:.ctor ()
1100         Not covered: Driver:method ()
1101         Partial coverage: Driver:Main ()
1102                 offset 0x000a
1103
1104 .fi
1105 .PP
1106 The offsets displayed are IL offsets.
1107 .PP
1108 A more powerful coverage tool is available in the module `monocov'.
1109 See the monocov(1) man page for details.
1110 .SH DEBUGGING AIDS
1111 To debug managed applications, you can use the 
1112 .B mdb
1113 command, a command line debugger.  
1114 .PP
1115 It is possible to obtain a stack trace of all the active threads in
1116 Mono by sending the QUIT signal to Mono, you can do this from the
1117 command line, like this:
1118 .nf
1119
1120         kill -QUIT pid
1121
1122 .fi
1123 Where pid is the Process ID of the Mono process you want to examine.
1124 The process will continue running afterwards, but its state is not
1125 guaranteed.
1126 .PP
1127 .B Important:
1128 this is a last-resort mechanism for debugging applications and should
1129 not be used to monitor or probe a production application.  The
1130 integrity of the runtime after sending this signal is not guaranteed
1131 and the application might crash or terminate at any given point
1132 afterwards.   
1133 .PP
1134 The \fB--debug=casts\fR option can be used to get more detailed
1135 information for Invalid Cast operations, it will provide information
1136 about the types involved.   
1137 .PP
1138 You can use the MONO_LOG_LEVEL and MONO_LOG_MASK environment variables
1139 to get verbose debugging output about the execution of your
1140 application within Mono.
1141 .PP
1142 The 
1143 .I MONO_LOG_LEVEL
1144 environment variable if set, the logging level is changed to the set
1145 value. Possible values are "error", "critical", "warning", "message",
1146 "info", "debug". The default value is "error". Messages with a logging
1147 level greater then or equal to the log level will be printed to
1148 stdout/stderr.
1149 .PP
1150 Use "info" to track the dynamic loading of assemblies.
1151 .PP
1152 .PP
1153 Use the 
1154 .I MONO_LOG_MASK
1155 environment variable to limit the extent of the messages you get: 
1156 If set, the log mask is changed to the set value. Possible values are
1157 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
1158 (garbage collector), "cfg" (config file loader), "aot" (precompiler),
1159 "security" (e.g. Moonlight CoreCLR support) and "all". 
1160 The default value is "all". Changing the mask value allows you to display only 
1161 messages for a certain component. You can use multiple masks by comma 
1162 separating them. For example to see config file messages and assembly loader
1163 messages set you mask to "asm,cfg".
1164 .PP
1165 The following is a common use to track down problems with P/Invoke:
1166 .nf
1167
1168         $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
1169
1170 .fi
1171 .PP
1172 .SH SERIALIZATION
1173 Mono's XML serialization engine by default will use a reflection-based
1174 approach to serialize which might be slow for continuous processing
1175 (web service applications).  The serialization engine will determine
1176 when a class must use a hand-tuned serializer based on a few
1177 parameters and if needed it will produce a customized C# serializer
1178 for your types at runtime.  This customized serializer then gets
1179 dynamically loaded into your application.
1180 .PP
1181 You can control this with the MONO_XMLSERIALIZER_THS environment
1182 variable.
1183 .PP
1184 The possible values are 
1185 .B `no' 
1186 to disable the use of a C# customized
1187 serializer, or an integer that is the minimum number of uses before
1188 the runtime will produce a custom serializer (0 will produce a
1189 custom serializer on the first access, 50 will produce a serializer on
1190 the 50th use). Mono will fallback to an interpreted serializer if the
1191 serializer generation somehow fails. This behavior can be disabled
1192 by setting the option
1193 .B `nofallback'
1194 (for example: MONO_XMLSERIALIZER_THS=0,nofallback).
1195 .SH ENVIRONMENT VARIABLES
1196 .TP
1197 \fBGC_DONT_GC\fR
1198 Turns off the garbage collection in Mono.  This should be only used
1199 for debugging purposes
1200 .TP
1201 \fBLVM_COUNT\fR
1202 When Mono is compiled with LLVM support, this instructs the runtime to
1203 stop using LLVM after the specified number of methods are JITed.
1204 This is a tool used in diagnostics to help isolate problems in the
1205 code generation backend.   For example \fBLLVM_COUNT=10\fR would only
1206 compile 10 methods with LLVM and then switch to the Mono JIT engine.
1207 \fBLLVM_COUNT=0\fR would disable the LLVM engine altogether.
1208 .TP
1209 \fBMONO_AOT_CACHE\fR
1210 If set, this variable will instruct Mono to ahead-of-time compile new
1211 assemblies on demand and store the result into a cache in
1212 ~/.mono/aot-cache. 
1213 .TP
1214 \fBMONO_ASPNET_INHIBIT_SETTINGSMAP\fR
1215 Mono contains a feature which allows modifying settings in the .config files shipped
1216 with Mono by using config section mappers. The mappers and the mapping rules are
1217 defined in the $prefix/etc/mono/2.0/settings.map file and, optionally, in the
1218 settings.map file found in the top-level directory of your ASP.NET application.
1219 Both files are read by System.Web on application startup, if they are found at the
1220 above locations. If you don't want the mapping to be performed you can set this
1221 variable in your environment before starting the application and no action will
1222 be taken.
1223 .TP
1224 \fBMONO_CFG_DIR\fR
1225 If set, this variable overrides the default system configuration directory
1226 ($PREFIX/etc). It's used to locate machine.config file.
1227 .TP
1228 \fBMONO_COM\fR
1229 Sets the style of COM interop.  If the value of this variable is "MS"
1230 Mono will use string marhsalling routines from the liboleaut32 for the
1231 BSTR type library, any other values will use the mono-builtin BSTR
1232 string marshalling.
1233 .TP
1234 \fBMONO_CONFIG\fR
1235 If set, this variable overrides the default runtime configuration file
1236 ($PREFIX/etc/mono/config). The --config command line options overrides the
1237 environment variable.
1238 .TP
1239 \fBMONO_CPU_ARCH\fR
1240 Override the automatic cpu detection mechanism. Currently used only on arm.
1241 The format of the value is as follows:
1242 .nf
1243
1244         "armvV [thumb]"
1245
1246 .fi
1247 where V is the architecture number 4, 5, 6, 7 and the options can be currently be
1248 "thunb". Example:
1249 .nf
1250
1251         MONO_CPU_ARCH="armv4 thumb" mono ...
1252
1253 .fi
1254 .TP
1255 \fBMONO_DISABLE_AIO\fR
1256 If set, tells mono NOT to attempt using native asynchronous I/O services. In
1257 that case, a default select/poll implementation is used. Currently only epoll()
1258 is supported.
1259 .TP
1260 \fBMONO_DISABLE_MANAGED_COLLATION\fR
1261 If this environment variable is `yes', the runtime uses unmanaged
1262 collation (which actually means no culture-sensitive collation). It
1263 internally disables managed collation functionality invoked via the
1264 members of System.Globalization.CompareInfo class. Collation is
1265 enabled by default.
1266 .TP
1267 \fBMONO_DISABLE_SHM\fR
1268 Unix only: If set, disables the shared memory files used for
1269 cross-process handles: process have only private handles.  This means
1270 that process and thread handles are not available to other processes,
1271 and named mutexes, named events and named semaphores are not visible
1272 between processes.
1273 .Sp
1274 This is can also be enabled by default by passing the
1275 "--disable-shared-handles" option to configure.
1276 .Sp
1277 This is the default from mono 2.8 onwards.
1278 .TP
1279 \fBMONO_EGD_SOCKET\fR
1280 For platforms that do not otherwise have a way of obtaining random bytes
1281 this can be set to the name of a file system socket on which an egd or
1282 prngd daemon is listening.
1283 .TP
1284 \fBMONO_ENABLE_SHM\fR
1285 Unix only: Enable support for cross-process handles.  Cross-process
1286 handles are used to expose process handles, thread handles, named
1287 mutexes, named events and named semaphores across Unix processes.
1288 .TP
1289 \fBMONO_ENV_OPTIONS\fR
1290 This environment variable allows you to pass command line arguments to
1291 a Mono process through the environment.   This is useful for example
1292 to force all of your Mono processes to use LLVM or SGEN without having
1293 to modify any launch scripts.
1294 .TP
1295 \fBMONO_EVENTLOG_TYPE\fR
1296 Sets the type of event log provider to use (for System.Diagnostics.EventLog).
1297 .Sp
1298 Possible values are:
1299 .RS
1300 .TP
1301 .I "local[:path]"
1302 .Sp
1303 Persists event logs and entries to the local file system.
1304 .Sp
1305 The directory in which to persist the event logs, event sources and entries
1306 can be specified as part of the value.
1307 .Sp
1308 If the path is not explicitly set, it defaults to "/var/lib/mono/eventlog"
1309 on unix and "%APPDATA%\mono\eventlog" on Windows.
1310 .TP
1311 .I "win32"
1312 .Sp
1313 .B 
1314 Uses the native win32 API to write events and registers event logs and
1315 event sources in the registry.   This is only available on Windows. 
1316 .Sp
1317 On Unix, the directory permission for individual event log and event source
1318 directories is set to 777 (with +t bit) allowing everyone to read and write
1319 event log entries while only allowing entries to be deleted by the user(s)
1320 that created them.
1321 .TP
1322 .I "null"
1323 .Sp
1324 Silently discards any events.
1325 .ne
1326 .PP
1327 The default is "null" on Unix (and versions of Windows before NT), and 
1328 "win32" on Windows NT (and higher).
1329 .RE
1330 .TP
1331 \fBMONO_EXTERNAL_ENCODINGS\fR
1332 If set, contains a colon-separated list of text encodings to try when
1333 turning externally-generated text (e.g. command-line arguments or
1334 filenames) into Unicode.  The encoding names come from the list
1335 provided by iconv, and the special case "default_locale" which refers
1336 to the current locale's default encoding.
1337 .IP
1338 When reading externally-generated text strings UTF-8 is tried first,
1339 and then this list is tried in order with the first successful
1340 conversion ending the search.  When writing external text (e.g. new
1341 filenames or arguments to new processes) the first item in this list
1342 is used, or UTF-8 if the environment variable is not set.
1343 .IP
1344 The problem with using MONO_EXTERNAL_ENCODINGS to process your
1345 files is that it results in a problem: although its possible to get
1346 the right file name it is not necessarily possible to open the file.
1347 In general if you have problems with encodings in your filenames you
1348 should use the "convmv" program.
1349 .TP
1350 \fBMONO_GC_DEBUG\fR
1351 When using Mono with the SGen garbage collector this environment
1352 variable can be used to control different aspects of the GC processs.
1353 The value of this variable is a comma separated list of words.   
1354 .RS
1355 .ne 8
1356 .TP
1357 \fInumber\fR
1358 Sets the debug level to the specified number.
1359 .TP
1360 \fBcollect-before-allocs\fR
1361 .TP
1362 \fBcheck-at-minor-collections\fR
1363 This performs a consistency check on minor collections and also clears
1364 the nursery at collection time, instead of the default, when buffers
1365 are allocated (clear-at-gc).   The consistency check ensures that
1366 there are no major to minor references that are not on the remembered
1367 sets. 
1368 .TP
1369 \fBxdomain-checks\fR
1370 Performs a check to make sure that no references are left to an
1371 unloaded AppDomain.
1372 .TP
1373 \fBclear-at-gc\fR
1374 This clears the nursery at GC time instead of doing it when the thread
1375 local allocation buffer (TLAB) is created.  The default is to clear
1376 the nursery at TLAB creation time.
1377 .TP
1378 \fBconservative-stack-mark\fR
1379 Forces the GC to scan the stack conservatively, even if precise
1380 scanning is available.
1381 .TP
1382 \fBcheck-scan-starts\fR
1383 If set, does a plausibility check on the scan_starts before and after each collection
1384 .TP
1385 \fBheap-dump=\fIfile\fR
1386 Dumps the heap contents to the specified file.   To visualize the
1387 information, use the mono-heapviz tool.
1388 .TP
1389 \fBbinary-protocol=\fIfile\fR
1390 Outputs the debugging output to the specified file.   For this to
1391 work, Mono needs to be compiled with the BINARY_PROTOCOL define on
1392 sgen-gc.c.   You can then use this command to explore the output
1393 .nf
1394                 sgen-grep-binprot 0x1234 0x5678 < file
1395 .fi
1396 .ne
1397 .RE
1398 .TP
1399 \fBMONO_GAC_PREFIX\fR
1400 Provides a prefix the runtime uses to look for Global Assembly Caches.
1401 Directories are separated by the platform path separator (colons on
1402 unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
1403 install. Or to the directory provided in the gacutil /gacdir command. Example:
1404 .B /home/username/.mono:/usr/local/mono/
1405 .TP
1406 \fBMONO_IOMAP\fR
1407 Enables some filename rewriting support to assist badly-written
1408 applications that hard-code Windows paths.  Set to a colon-separated
1409 list of "drive" to strip drive letters, or "case" to do
1410 case-insensitive file matching in every directory in a path.  "all"
1411 enables all rewriting methods.  (Backslashes are always mapped to
1412 slashes if this variable is set to a valid option).
1413 .fi
1414 .Sp
1415 For example, this would work from the shell:
1416 .nf
1417
1418         MONO_IOMAP=drive:case
1419         export MONO_IOMAP
1420
1421 .fi
1422 If you are using mod_mono to host your web applications, you can use
1423 the 
1424 .B MonoIOMAP
1425 directive instead, like this:
1426 .nf
1427
1428         MonoIOMAP <appalias> all
1429
1430 .fi
1431 See mod_mono(8) for more details.
1432
1433 Additionally. Mono includes a profiler module which allows one to track what
1434 adjustements to file paths IOMAP code needs to do. The tracking code reports
1435 the managed location (full stack trace) from which the IOMAP-ed call was made and,
1436 on process exit, the locations where all the IOMAP-ed strings were created in
1437 managed code. The latter report is only approximate as it is not always possible
1438 to estimate the actual location where the string was created. The code uses simple
1439 heuristics - it analyzes stack trace leading back to the string allocation location
1440 and ignores all the managed code which lives in assemblies installed in GAC as well as in the
1441 class libraries shipped with Mono (since they are assumed to be free of case-sensitivity
1442 issues). It then reports the first location in the user's code - in most cases this will be
1443 the place where the string is allocated or very close to the location. The reporting code
1444 is implemented as a custom profiler module (see the "PROFILING" section) and can be loaded
1445 in the following way:
1446 .fi
1447 .Sp
1448 .nf
1449
1450         mono --profile=iomap yourapplication.exe
1451
1452 .fi
1453 Note, however, that Mono currently supports only one profiler module
1454 at a time.
1455 .TP
1456 \fBMONO_LLVM\fR
1457 When Mono is using the LLVM code generation backend you can use this
1458 environment variable to pass code generation options to the LLVM
1459 compiler.   
1460 .TP
1461 \fBMONO_MANAGED_WATCHER\fR
1462 If set to "disabled", System.IO.FileSystemWatcher will use a file watcher 
1463 implementation which silently ignores all the watching requests.
1464 If set to any other value, System.IO.FileSystemWatcher will use the default
1465 managed implementation (slow). If unset, mono will try to use inotify, FAM, 
1466 Gamin, kevent under Unix systems and native API calls on Windows, falling 
1467 back to the managed implementation on error.
1468 .TP
1469 \fBMONO_MESSAGING_PROVIDER\fR
1470 Mono supports a plugin model for its implementation of System.Messaging making
1471 it possible to support a variety of messaging implementations (e.g. AMQP, ActiveMQ).
1472 To specify which messaging implementation is to be used the evironement variable
1473 needs to be set to the full class name for the provider.  E.g. to use the RabbitMQ based
1474 AMQP implementation the variable should be set to:
1475
1476 .nf
1477 Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider,Mono.Messaging.RabbitMQ
1478 .TP
1479 \fBMONO_NO_SMP\fR
1480 If set causes the mono process to be bound to a single processor. This may be
1481 useful when debugging or working around race conditions.
1482 .TP
1483 \fBMONO_NO_TLS\fR
1484 Disable inlining of thread local accesses. Try setting this if you get a segfault
1485 early on in the execution of mono.
1486 .TP
1487 \fBMONO_PATH\fR
1488 Provides a search path to the runtime where to look for library
1489 files.   This is a tool convenient for debugging applications, but
1490 should not be used by deployed applications as it breaks the assembly
1491 loader in subtle ways. 
1492 .Sp
1493 Directories are separated by the platform path separator (colons on unix). Example:
1494 .B /home/username/lib:/usr/local/mono/lib
1495 .Sp
1496 Alternative solutions to MONO_PATH include: installing libraries into
1497 the Global Assembly Cache (see gacutil(1)) or having the dependent
1498 libraries side-by-side with the main executable.
1499 .Sp
1500 For a complete description of recommended practices for application
1501 deployment, see
1502 http://www.mono-project.com/Guidelines:Application_Deployment
1503 .TP
1504 \fBMONO_RTC\fR
1505 Experimental RTC support in the statistical profiler: if the user has
1506 the permission, more accurate statistics are gathered.  The MONO_RTC
1507 value must be restricted to what the Linux rtc allows: power of two
1508 from 64 to 8192 Hz. To enable higher frequencies like 4096 Hz, run as root:
1509 .nf
1510
1511         echo 4096 > /proc/sys/dev/rtc/max-user-freq
1512
1513 .fi
1514 .Sp
1515 For example:
1516 .nf
1517
1518         MONO_RTC=4096 mono --profiler=default:stat program.exe
1519
1520 .fi
1521 .TP 
1522 \fBMONO_SHARED_DIR\fR
1523 If set its the directory where the ".wapi" handle state is stored.
1524 This is the directory where the Windows I/O Emulation layer stores its
1525 shared state data (files, events, mutexes, pipes).  By default Mono
1526 will store the ".wapi" directory in the users's home directory.
1527 .TP 
1528 \fBMONO_SHARED_HOSTNAME\fR
1529 Uses the string value of this variable as a replacement for the host name when
1530 creating file names in the ".wapi" directory. This helps if the host name of
1531 your machine is likely to be changed when a mono application is running or if
1532 you have a .wapi directory shared among several different computers.
1533 .Sp
1534 Mono typically uses the hostname to create the files that are used to
1535 share state across multiple Mono processes.  This is done to support
1536 home directories that might be shared over the network.
1537 .TP
1538 \fBMONO_STRICT_IO_EMULATION\fR
1539 If set, extra checks are made during IO operations.  Currently, this
1540 includes only advisory locks around file writes.
1541 .TP
1542 \fBMONO_THEME\fR
1543 The name of the theme to be used by Windows.Forms.   Available themes today
1544 include "clearlooks", "nice" and "win32".
1545 .Sp
1546 The default is "win32".  
1547 .TP
1548 \fBMONO_TLS_SESSION_CACHE_TIMEOUT\fR
1549 The time, in seconds, that the SSL/TLS session cache will keep it's entry to
1550 avoid a new negotiation between the client and a server. Negotiation are very
1551 CPU intensive so an application-specific custom value may prove useful for 
1552 small embedded systems.
1553 .Sp
1554 The default is 180 seconds.
1555 .TP
1556 \fBMONO_THREADS_PER_CPU\fR
1557 The maximum number of threads in the general threadpool will be
1558 20 + (MONO_THREADS_PER_CPU * number of CPUs). The default value for this
1559 variable is 10.
1560 .TP
1561 \fBMONO_XMLSERIALIZER_THS\fR
1562 Controls the threshold for the XmlSerializer to produce a custom
1563 serializer for a given class instead of using the Reflection-based
1564 interpreter.  The possible values are `no' to disable the use of a
1565 custom serializer or a number to indicate when the XmlSerializer
1566 should start serializing.   The default value is 50, which means that
1567 the a custom serializer will be produced on the 50th use.
1568 .SH ENVIRONMENT VARIABLES FOR DEBUGGING
1569 .TP
1570 \fBMONO_ASPNET_NODELETE\fR
1571 If set to any value, temporary source files generated by ASP.NET support
1572 classes will not be removed. They will be kept in the user's temporary
1573 directory.
1574 .TP
1575 \fBMONO_DEBUG\fR
1576 If set, enables some features of the runtime useful for debugging.
1577 This variable should contain a comma separated list of debugging options.
1578 Currently, the following options are supported:
1579 .RS
1580 .ne 8
1581 .TP
1582 \fBbreak-on-unverified\fR
1583 If this variable is set, when the Mono VM runs into a verification
1584 problem, instead of throwing an exception it will break into the
1585 debugger.  This is useful when debugging verifier problems
1586 .TP
1587 \fBcasts\fR
1588 This option can be used to get more detailed information from
1589 InvalidCast exceptions, it will provide information about the types
1590 involved.     
1591 .TP
1592 \fBcollect-pagefault-stats\fR
1593 Collects information about pagefaults.   This is used internally to
1594 track the number of page faults produced to load metadata.  To display
1595 this information you must use this option with "--stats" command line
1596 option.
1597 .TP
1598 \fBdont-free-domains\fR
1599 This is an Optimization for multi-AppDomain applications (most
1600 commonly ASP.NET applications).  Due to internal limitations Mono,
1601 Mono by default does not use typed allocations on multi-appDomain
1602 applications as they could leak memory when a domain is unloaded. 
1603 .Sp
1604 Although this is a fine default, for applications that use more than
1605 on AppDomain heavily (for example, ASP.NET applications) it is worth
1606 trading off the small leaks for the increased performance
1607 (additionally, since ASP.NET applications are not likely going to
1608 unload the application domains on production systems, it is worth
1609 using this feature). 
1610 .TP
1611 \fBhandle-sigint\fR
1612 Captures the interrupt signal (Control-C) and displays a stack trace
1613 when pressed.  Useful to find out where the program is executing at a
1614 given point.  This only displays the stack trace of a single thread. 
1615 .TP
1616 \fBkeep-delegates\fR
1617 This option will leak delegate trampolines that are no longer
1618 referenced as to present the user with more information about a
1619 delegate misuse.  Basically a delegate instance might be created,
1620 passed to unmanaged code, and no references kept in managed code,
1621 which will garbage collect the code.  With this option it is possible
1622 to track down the source of the problems. 
1623 .TP
1624 \fBreverse-pinvoke-exceptions
1625 This option will cause mono to abort with a descriptive message when
1626 during stack unwinding after an exception it reaches a native stack
1627 frame. This happens when a managed delegate is passed to native code,
1628 and the managed delegate throws an exception. Mono will normally try
1629 to unwind the stack to the first (managed) exception handler, and it
1630 will skip any native stack frames in the process. This leads to 
1631 undefined behaviour (since mono doesn't know how to process native
1632 frames), leaks, and possibly crashes too.
1633 .TP
1634 \fBno-gdb-backtrace\fR
1635 This option will disable the GDB backtrace emitted by the runtime
1636 after a SIGSEGV or SIGABRT in unmanaged code.
1637 .TP
1638 \fBsuspend-on-sigsegv\fR
1639
1640 This option will suspend the program when a native SIGSEGV is received.
1641 This is useful for debugging crashes which do not happen under gdb,
1642 since a live process contains more information than a core file.
1643 .ne
1644 .RE
1645 .TP
1646 \fBMONO_LOG_LEVEL\fR
1647 The logging level, possible values are `error', `critical', `warning',
1648 `message', `info' and `debug'.  See the DEBUGGING section for more
1649 details.
1650 .TP
1651 \fBMONO_LOG_MASK\fR
1652 Controls the domain of the Mono runtime that logging will apply to. 
1653 If set, the log mask is changed to the set value. Possible values are
1654 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
1655 (garbage collector), "cfg" (config file loader), "aot" (precompiler),
1656 "security" (e.g. Moonlight CoreCLR support) and "all". 
1657 The default value is "all". Changing the mask value allows you to display only 
1658 messages for a certain component. You can use multiple masks by comma 
1659 separating them. For example to see config file messages and assembly loader
1660 messages set you mask to "asm,cfg".
1661 .TP
1662 \fBMONO_TRACE\fR
1663 Used for runtime tracing of method calls. The format of the comma separated
1664 trace options is:
1665 .nf
1666
1667         [-]M:method name
1668         [-]N:namespace
1669         [-]T:class name
1670         [-]all
1671         [-]program
1672         disabled                Trace output off upon start.
1673
1674 .fi
1675 You can toggle trace output on/off sending a SIGUSR2 signal to the program.
1676 .TP
1677 \fBMONO_TRACE_LISTENER\fR
1678 If set, enables the System.Diagnostics.DefaultTraceListener, which will 
1679 print the output of the System.Diagnostics Trace and Debug classes.  
1680 It can be set to a filename, and to Console.Out or Console.Error to display
1681 output to standard output or standard error, respectively. If it's set to
1682 Console.Out or Console.Error you can append an optional prefix that will
1683 be used when writing messages like this: Console.Error:MyProgramName.
1684 See the System.Diagnostics.DefaultTraceListener documentation for more
1685 information.
1686 .TP
1687 \fBMONO_XEXCEPTIONS\fR
1688 This throws an exception when a X11 error is encountered; by default a
1689 message is displayed but execution continues
1690 .TP
1691 \fBMONO_XMLSERIALIZER_DEBUG\fR
1692 Set this value to 1 to prevent the serializer from removing the
1693 temporary files that are created for fast serialization;  This might
1694 be useful when debugging.
1695 .TP
1696 \fBMONO_XSYNC\fR
1697 This is used in the System.Windows.Forms implementation when running
1698 with the X11 backend.  This is used to debug problems in Windows.Forms
1699 as it forces all of the commands send to X11 server to be done
1700 synchronously.   The default mode of operation is asynchronous which
1701 makes it hard to isolate the root of certain problems.
1702 .TP
1703 \fBMONO_GENERIC_SHARING\fR
1704 This environment variable controls the kind of generic sharing used.
1705 This variable is used by internal JIT developers and should not be
1706 changed in production.  Do not use it.
1707 .Sp
1708 The variable controls which classes will have generic code sharing
1709 enabled.
1710 .Sp
1711 Permissible values are:
1712 .RS
1713 .TP 
1714 .I "all" 
1715 All generated code can be shared. 
1716 .TP
1717 .I "collections" 
1718 Only the classes in System.Collections.Generic will have its code
1719 shared (this is the default value).
1720 .TP
1721 .I "corlib"
1722 Only code in corlib will have its code shared.
1723 .TP
1724 .I "none"
1725 No generic code sharing will be performed.
1726 .RE
1727 .Sp
1728 Generic code sharing by default only applies to collections.   The
1729 Mono JIT by default turns this on.
1730 .TP
1731 \fBMONO_XDEBUG\fR
1732 When the the MONO_XDEBUG env var is set, debugging info for JITted
1733 code is emitted into a shared library, loadable into gdb. This enables,
1734 for example, to see managed frame names on gdb backtraces.
1735 .TP
1736 \fBMONO_VERBOSE_METHOD\fR
1737 Enables the maximum JIT verbosity for the specified method. This is
1738 very helpfull to diagnose a miscompilation problems of a specific
1739 method.
1740 .SH VALGRIND
1741 If you want to use Valgrind, you will find the file `mono.supp'
1742 useful, it contains the suppressions for the GC which trigger
1743 incorrect warnings.  Use it like this:
1744 .nf
1745     valgrind --suppressions=mono.supp mono ...
1746 .fi
1747 .SH DTRACE
1748 On some platforms, Mono can expose a set of DTrace probes (also known
1749 as user-land statically defined, USDT Probes).
1750 .TP
1751 They are defined in the file `mono.d'.
1752 .TP
1753 .B ves-init-begin, ves-init-end
1754 .Sp
1755 Begin and end of runtime initialization.
1756 .TP
1757 .B method-compile-begin, method-compile-end
1758 .Sp
1759 Begin and end of method compilation.
1760 The probe arguments are class name, method name and signature,
1761 and in case of method-compile-end success or failure of compilation.
1762 .TP
1763 .B gc-begin, gc-end
1764 .Sp
1765 Begin and end of Garbage Collection.
1766 .TP
1767 To verify the availability of the probes, run:
1768 .nf
1769     dtrace -P mono'$target' -l -c mono
1770 .fi
1771 .SH PERMISSIONS
1772 Mono's Ping implementation for detecting network reachability can
1773 create the ICMP packets itself without requiring the system ping
1774 command to do the work.  If you want to enable this on Linux for
1775 non-root users, you need to give the Mono binary special permissions.
1776 .PP
1777 As root, run this command:
1778 .nf
1779    # setcap cap_net_raw=+ep /usr/bin/mono
1780 .fi
1781 .SH FILES
1782 On Unix assemblies are loaded from the installation lib directory.  If you set
1783 `prefix' to /usr, the assemblies will be located in /usr/lib.  On
1784 Windows, the assemblies are loaded from the directory where mono and
1785 mint live.
1786 .TP
1787 .B ~/.mono/aot-cache
1788 .Sp
1789 The directory for the ahead-of-time compiler demand creation
1790 assemblies are located. 
1791 .TP
1792 .B /etc/mono/config, ~/.mono/config
1793 .Sp
1794 Mono runtime configuration file.  See the mono-config(5) manual page
1795 for more information.
1796 .TP
1797 .B ~/.config/.mono/certs, /usr/share/.mono/certs
1798 .Sp
1799 Contains Mono certificate stores for users / machine. See the certmgr(1) 
1800 manual page for more information on managing certificate stores and
1801 the mozroots(1) page for information on how to import the Mozilla root
1802 certificates into the Mono certificate store. 
1803 .TP
1804 .B ~/.mono/assemblies/ASSEMBLY/ASSEMBLY.config
1805 .Sp
1806 Files in this directory allow a user to customize the configuration
1807 for a given system assembly, the format is the one described in the
1808 mono-config(5) page. 
1809 .TP
1810 .B ~/.config/.mono/keypairs, /usr/share/.mono/keypairs
1811 .Sp
1812 Contains Mono cryptographic keypairs for users / machine. They can be 
1813 accessed by using a CspParameters object with DSACryptoServiceProvider
1814 and RSACryptoServiceProvider classes.
1815 .TP
1816 .B ~/.config/.isolatedstorage, ~/.local/share/.isolatedstorage, /usr/share/.isolatedstorage
1817 .Sp
1818 Contains Mono isolated storage for non-roaming users, roaming users and 
1819 local machine. Isolated storage can be accessed using the classes from 
1820 the System.IO.IsolatedStorage namespace.
1821 .TP
1822 .B <assembly>.config
1823 .Sp
1824 Configuration information for individual assemblies is loaded by the
1825 runtime from side-by-side files with the .config files, see the
1826 http://www.mono-project.com/Config for more information.
1827 .TP
1828 .B Web.config, web.config
1829 .Sp
1830 ASP.NET applications are configured through these files, the
1831 configuration is done on a per-directory basis.  For more information
1832 on this subject see the http://www.mono-project.com/Config_system.web
1833 page. 
1834 .SH MAILING LISTS
1835 Mailing lists are listed at the
1836 http://www.mono-project.com/Mailing_Lists
1837 .SH WEB SITE
1838 http://www.mono-project.com
1839 .SH SEE ALSO
1840 .PP
1841 certmgr(1), csharp(1), mcs(1), mdb(1), monocov(1), monodis(1),
1842 mono-config(5), mozroots(1), pdb2mdb(1), xsp(1), mod_mono(8).
1843 .PP
1844 For more information on AOT:
1845 http://www.mono-project.com/AOT
1846 .PP
1847 For ASP.NET-related documentation, see the xsp(1) manual page