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