2008-04-17 Marek Habersack <mhabersack@novell.com>
[mono.git] / man / mono.1
1 .\" 
2 .\" mono manual page.
3 .\" (C) 2003 Ximian, Inc. 
4 .\" (C) 2004-2005 Novell, Inc. 
5 .\" Author:
6 .\"   Miguel de Icaza (miguel@gnu.org)
7 .\"
8 .de Sp \" Vertical space (when we can't use .PP)
9 .if t .sp .5v
10 .if n .sp
11 ..
12 .TH Mono "Mono 1.0"
13 .SH NAME
14 mono \- Mono's ECMA-CLI native code generator (Just-in-Time and Ahead-of-Time)
15 .SH SYNOPSIS
16 .PP
17 .B mono [options] file [arguments...]
18 .SH DESCRIPTION
19 \fImono\fP is a runtime implementation of the ECMA Common Language
20 Infrastructure.  This can be used to run ECMA and .NET applications.
21 .PP
22 The runtime contains a native code generator that transforms the
23 Common Intermediate Language into native code.
24 .PP
25 The code generator can operate in two modes: just in time compilation
26 (JIT) or ahead of time compilation (AOT).  Since code can be
27 dynamically loaded, the runtime environment and the JIT are always
28 present, even if code is compiled ahead of time.
29 .PP
30 The runtime loads the specified
31 .I file
32 and optionally passes
33 the
34 .I arguments
35 to it.  The 
36 .I file
37 is an ECMA assembly.  They typically have a .exe or .dll extension.
38 .PP
39 The runtime provides a number of configuration options for running
40 applications, for developing and debugging, and for testing and
41 debugging the runtime itself.
42 .SH PORTABILITY
43 On Unix-based systems, Mono provides a mechanism to emulate the 
44 Windows-style file access, this includes providing a case insensitive
45 view of the file system, directory separator mapping (from \\ to /) and
46 stripping the drive letters.
47 .PP
48 This functionality is enabled by setting the 
49 .B MONO_IOMAP 
50 environment variable to one of 
51 .B all, drive
52 and 
53 .B case.
54 .PP
55 See the description for 
56 .B MONO_IOMAP
57 in the environment variables section for more details.
58 .SH RUNTIME OPTIONS
59 The following options are available:
60 .TP
61 .I "--aot"
62 This option is used to precompile the CIL code in the specified
63 assembly to native code.  The generated code is stored in a file with
64 the extension .so.  This file will be automatically picked up by the
65 runtime when the assembly is executed.  
66 .Sp 
67 Ahead-of-Time compilation is most useful if you use it in combination
68 with the -O=all,-shared flag which enables all of the optimizations in
69 the code generator to be performed.  Some of those optimizations are
70 not practical for Just-in-Time compilation since they might be very
71 time consuming.
72 .Sp
73 Unlike the .NET Framework, Ahead-of-Time compilation will not generate
74 domain independent code: it generates the same code that the
75 Just-in-Time compiler would produce.   Since most applications use a
76 single domain, this is fine.   If you want to optimize the generated
77 code for use in multi-domain applications, consider using the
78 -O=shared flag.
79 .Sp
80 This pre-compiles the methods, but the original assembly is still
81 required to execute as this one contains the metadata and exception
82 information which is not available on the generated file.  When
83 precompiling code, you might want to compile with all optimizations
84 (-O=all).  Pre-compiled code is position independent code.
85 .Sp
86 Pre compilation is just a mechanism to reduce startup time, increase
87 code sharing across multiple mono processes and avoid just-in-time
88 compilation program startup costs.  The original assembly must still
89 be present, as the metadata is contained there.
90 .Sp
91 AOT code typically can not be moved from one computer to another
92 (CPU-specific optimizations that are detected at runtime) so you
93 should not try to move the pre-generated assemblies or package the
94 pre-generated assemblies for deployment.    
95 .Sp
96 For more information about AOT, see: http://www.mono-project.com/AOT
97 .TP
98 .I "--config filename"
99 Load the specified configuration file instead of the default one(s).
100 The default files are /etc/mono/config and ~/.mono/config or the file
101 specified in the MONO_CONFIG environment variable, if set.  See the
102 mono-config(5) man page for details on the format of this file.
103 .TP
104 .I "--desktop"
105 Configures the virtual machine to be better suited for desktop
106 applications.  Currently this sets the GC system to avoid expanding
107 the heap as much as possible at the expense of slowing down garbage
108 collection a bit.
109 .TP
110 .I "--help", "-h"
111 Displays usage instructions.
112 .TP
113 .I "--optimize=MODE", "-O=MODE"
114 MODE is a comma separated list of optimizations.  They also allow
115 optimizations to be turned off by prefixing the optimization name with
116 a minus sign.
117 .Sp
118 In general, Mono has been tuned to use the default set of flags,
119 before using these flags for a deployment setting, you might want to
120 actually measure the benefits of using them.    
121 .Sp
122 The following optimizations are implemented:
123 .nf
124              all        Turn on all optimizations
125              peephole   Peephole postpass
126              branch     Branch optimizations
127              inline     Inline method calls
128              cfold      Constant folding
129              consprop   Constant propagation
130              copyprop   Copy propagation
131              deadce     Dead code elimination
132              linears    Linear scan global reg allocation
133              cmov       Conditional moves [arch-dependency]
134              shared     Emit per-domain code
135              sched      Instruction scheduling
136              intrins    Intrinsic method implementations
137              tailc      Tail recursion and tail calls
138              loop       Loop related optimizations
139              fcmov      Fast x86 FP compares [arch-dependency]
140              leaf       Leaf procedures optimizations
141              aot        Usage of Ahead Of Time compiled code
142              precomp    Precompile all methods before executing Main
143              abcrem     Array bound checks removal
144              ssapre     SSA based Partial Redundancy Elimination
145              sse2       SSE2 instructions on x86 [arch-dependency]
146 .fi
147 .Sp
148 For example, to enable all the optimization but dead code
149 elimination and inlining, you can use:
150 .nf
151         -O=all,-deadce,-inline
152 .fi
153 .Sp
154 The flags that are flagged with [arch-dependency] indicate that the
155 given option if used in combination with Ahead of Time compilation
156 (--aot flag) would produce pre-compiled code that will depend on the
157 current CPU and might not be safely moved to another computer. 
158 .TP
159 .I "--runtime=VERSION"
160 Mono supports different runtime versions. The version used depends on the program
161 that is being run or on its configuration file (named program.exe.config). This option
162 can be used to override such autodetection, by forcing a different runtime version
163 to be used. Note that this should only be used to select a later compatible runtime
164 version than the one the program was compiled against. A typical usage is for
165 running a 1.1 program on a 2.0 version:
166 .nf
167          mono --runtime=v2.0.50727 program.exe
168 .fi
169 .TP
170 .I "--security", "--security=mode"
171 Activate the security manager, a currently experimental feature in
172 Mono and it is OFF by default. The new code verifier can be enabled
173 with this option as well.
174 .RS
175 .ne 8
176 .PP
177 Using security without parameters is equivalent as calling it with the
178 "cas" parameter.  
179 .PP
180 The following modes are supported:
181 .TP
182 .I cas
183 This allows mono to support declarative security attributes,
184 e.g. execution of Code Access Security (CAS) or non-CAS demands.
185 .TP 
186 .I core-clr
187 Enables the core-clr security system, typically used for
188 Moonlight/Silverlight applications.  It provides a much simpler
189 security system than CAS, see http://www.mono-project.com/Moonlight
190 for more details and links to the descriptions of this new system. 
191 .TP
192 .I validil
193 Enables the new verifier and performs basic verification for code
194 validity.  In this mode, unsafe code and P/Invoke are allowed. This
195 mode provides a better safety guarantee but it is still possible
196 for managed code to crash Mono. 
197 .TP
198 .I verifiable
199 Enables the new verifier and performs full verification of the code
200 being executed.  It only allows verifiable code to be executed.
201 Unsafe code is not allowed but P/Invoke is.  This mode should
202 not allow managed code to crash mono.  The verification is not as
203 strict as ECMA 335 standard in order to stay compatible with the MS
204 runtime.
205 .ne
206 .RE
207 .TP
208 .I "--server"
209 Configures the virtual machine to be better suited for server
210 operations (currently, a no-op).
211 .TP
212 .I "-V", "--version"
213 Prints JIT version information (system configuration, release number
214 and branch names if available). 
215
216
217 .SH DEVELOPMENT OPTIONS
218 The following options are used to help when developing a JITed application.
219 .TP
220 .I "--debug"
221 Turns on the debugging mode in the runtime.  If an assembly was
222 compiled with debugging information, it will produce line number
223 information for stack traces. 
224 .TP
225 .I "--debug=casts"
226 Produces a detailed error when throwing a InvalidCastException.  This
227 option is turned off by default as it generates much larger code at
228 runtime.
229 .TP
230 .I "--profile[=profiler[:profiler_args]]"
231 Turns on profiling.  For more information about profiling applications
232 and code coverage see the sections "PROFILING" and "CODE COVERAGE"
233 below. 
234 .TP
235 .I "--trace[=expression]"
236 Shows method names as they are invoked.  By default all methods are
237 traced. 
238 .Sp
239 The trace can be customized to include or exclude methods, classes or
240 assemblies.  A trace expression is a comma separated list of targets,
241 each target can be prefixed with a minus sign to turn off a particular
242 target.  The words `program', `all' and `disabled' have special
243 meaning.  `program' refers to the main program being executed, and
244 `all' means all the method calls.
245 .Sp
246 The `disabled' option is used to start up with tracing disabled.  It
247 can be enabled at a later point in time in the program by sending the
248 SIGUSR2 signal to the runtime.
249 .Sp
250 Assemblies are specified by their name, for example, to trace all
251 calls in the System assembly, use:
252 .nf
253
254         mono --trace=System app.exe
255
256 .fi
257 Classes are specified with the T: prefix.  For example, to trace all
258 calls to the System.String class, use:
259 .nf
260
261         mono --trace=T:System.String app.exe
262
263 .fi
264 And individual methods are referenced with the M: prefix, and the
265 standard method notation:
266 .nf
267
268         mono --trace=M:System.Console:WriteLine app.exe
269
270 .fi
271 As previously noted, various rules can be specified at once:
272 .nf
273
274         mono --trace=T:System.String,T:System.Random app.exe
275
276 .fi
277 You can exclude pieces, the next example traces calls to
278 System.String except for the System.String:Concat method.
279 .nf
280
281         mono --trace=T:System.String,-M:System.String:Concat
282
283 .fi
284 Finally, namespaces can be specified using the N: prefix:
285 .nf
286
287         mono --trace=N:System.Xml
288
289 .fi
290 .SH JIT MAINTAINER OPTIONS
291 The maintainer options are only used by those developing the runtime
292 itself, and not typically of interest to runtime users or developers.
293 .TP
294 .I "--break method"
295 Inserts a breakpoint before the method whose name is `method'
296 (namespace.class:methodname).  Use `Main' as method name to insert a
297 breakpoint on the application's main method.
298 .TP
299 .I "--breakonex"
300 Inserts a breakpoint on exceptions.  This allows you to debug your
301 application with a native debugger when an exception is thrown.
302 .TP
303 .I "--compile name"
304 This compiles a method (namespace.name:methodname), this is used for
305 testing the compiler performance or to examine the output of the code
306 generator. 
307 .TP
308 .I "--compileall"
309 Compiles all the methods in an assembly.  This is used to test the
310 compiler performance or to examine the output of the code generator
311 .TP 
312 .I "--graph=TYPE METHOD"
313 This generates a postscript file with a graph with the details about
314 the specified method (namespace.name:methodname).  This requires `dot'
315 and ghostview to be installed (it expects Ghostview to be called
316 "gv"). 
317 .Sp
318 The following graphs are available:
319 .nf
320           cfg        Control Flow Graph (CFG)
321           dtree      Dominator Tree
322           code       CFG showing code
323           ssa        CFG showing code after SSA translation
324           optcode    CFG showing code after IR optimizations
325 .fi
326 .Sp
327 Some graphs will only be available if certain optimizations are turned
328 on.
329 .TP
330 .I "--ncompile"
331 Instruct the runtime on the number of times that the method specified
332 by --compile (or all the methods if --compileall is used) to be
333 compiled.  This is used for testing the code generator performance. 
334 .TP 
335 .I "--stats"
336 Displays information about the work done by the runtime during the
337 execution of an application. 
338 .TP
339 .I "--wapi=hps|semdel"
340 Perform maintenance of the process shared data.
341 .Sp
342 semdel will delete the global semaphore.
343 .Sp
344 hps will list the currently used handles.
345 .TP
346 .I "-v", "--verbose"
347 Increases the verbosity level, each time it is listed, increases the
348 verbosity level to include more information (including, for example, 
349 a disassembly of the native code produced, code selector info etc.).
350 .SH PROFILING
351 The mono runtime includes a profiler that can be used to explore
352 various performance related problems in your application.  The
353 profiler is activated by passing the --profile command line argument
354 to the Mono runtime, the format is:
355 .nf
356
357         --profile[=profiler[:profiler_args]]
358
359 .fi
360 Mono has a built-in profiler called 'default' (and is also the default
361 if no arguments are specified), but developers can write custom
362 profilers, see the section "CUSTOM PROFILERS" for more details.
363 .PP
364 If a 
365 .I profiler 
366 is not specified, the default profiler is used.
367 .Sp
368 The 
369 .I profiler_args 
370 is a profiler-specific string of options for the profiler itself.
371 .Sp
372 The default profiler accepts the following options 'alloc' to profile
373 memory consumption by the application; 'time' to profile the time
374 spent on each routine; 'jit' to collect time spent JIT-compiling methods
375 and 'stat' to perform sample statistical profiling.
376 If no options are provided the default is 'alloc,time,jit'. 
377 .PP
378 By default the
379 profile data is printed to stdout: to change this, use the 'file=filename'
380 option to output the data to filename.
381 .Sp
382 For example:
383 .nf
384
385         mono --profile program.exe
386
387 .fi
388 .Sp
389 That will run the program with the default profiler and will do time
390 and allocation profiling.
391 .Sp
392 .nf
393
394         mono --profile=default:stat,alloc,file=prof.out program.exe
395
396 .fi
397 Will do  sample statistical profiling and allocation profiling on
398 program.exe. The profile data is put in prof.out.
399 .Sp
400 Note that the statistical profiler has a very low overhead and should
401 be the preferred profiler to use (for better output use the full path
402 to the mono binary when running and make sure you have installed the
403 addr2line utility that comes from the binutils package).
404 .SH PROFILERS
405 There are a number of external profilers that have been developed for
406 Mono, we will update this section to contain the profilers.
407 .PP
408 The heap Shot profiler can track all live objects, and references to
409 these objects, and includes a GUI tool, this is our recommended
410 profiler.
411 To install you must download the profiler
412 from Mono's SVN:
413 .nf
414         svn co svn://svn.myrealbox.com/source/trunk/heap-shot
415         cd heap-shot
416         ./autogen
417         make
418         make install
419 .fi
420 .PP
421 See the included documentation for details on using it.
422 .PP
423 The Live Type profiler shows at every GC iteration all of the live
424 objects of a given type.   To install you must download the profiler
425 from Mono's SVN:
426 .nf
427         svn co svn://svn.myrealbox.com/source/trunk/heap-prof
428         cd heap-prof
429         ./autogen
430         make
431         make install
432 .fi
433 .PP
434 To use the profiler, execute:
435 .nf
436         mono --profile=desc-heap program.exe
437 .fi
438 .PP
439 The output of this profiler looks like this:
440 .nf
441         Checkpoint at 102 for heap-resize
442            System.MonoType : 708
443            System.Threading.Thread : 352
444            System.String : 3230
445            System.String[] : 104
446            Gnome.ModuleInfo : 112
447            System.Object[] : 160
448            System.Collections.Hashtable : 96
449            System.Int32[] : 212
450            System.Collections.Hashtable+Slot[] : 296
451            System.Globalization.CultureInfo : 108
452            System.Globalization.NumberFormatInfo : 144
453 .fi
454 .PP
455 The first line describes the iteration number for the GC, in this case
456 checkpoint 102.
457 .PP
458 Then on each line the type is displayed as well as the number of bytes
459 that are being consumed by live instances of this object.
460 .PP 
461 The AOT profiler is used to feed back information to the AOT compiler
462 about how to order code based on the access patterns for pages.  To
463 use it, use:
464 .nf
465         mono --profile=aot program.exe
466 .fi
467 The output of this profile can be fed back into Mono's AOT compiler to
468 order the functions on the disk to produce precompiled images that
469 have methods in sequential pages.
470 .PP
471 The
472 .I logging profiler
473 will eventually replace the default one. It is a
474 "general purpose" profiler, which can report method execution time,
475 allocations, jit time, and can also work in statistical mode. You invoke
476 it with:
477 .nf
478         mono --profile=logging program.exe
479 .fi
480 Its main characteristic is that it does not print the profiling data
481 at the end of the program execution, and in fact it does not elaborate
482 the events at all; instead, it logs them into a file periodically
483 during the program execution. The file is binary, and encoded as packed
484 as possible, so to see the data you must use a decoder program, which
485 you can find in svn in the "Mono.Profiler" module.
486 .PP
487 Some examples: to use the statistical profiler:
488 .nf
489         mono --profile=logging:s program.exe
490 .fi
491 To profile method enter-exit and allocations:
492 .nf
493         mono --profile=logging:c,a program.exe
494 .fi
495 To profile method enter-exit and jit time, and write the data to "mydata.mprof":
496 .nf
497         mono --profile=logging:c,j,o=mydata.mprof program.exe
498 .fi
499 Then you would need to invoke the decoder on "mydata.mprof" to see the
500 profiling results.
501 .PP
502 In its current state, this profiler can also perform heap analysis (like
503 heap-shot), and the decoder is already able to read the data, however
504 the user interface for this feature has not yet been written (which means
505 that the data is not printed by the decoder).
506 .PP
507 More explanations are provided here: "http://www.mono-project.com/LoggingProfiler".
508 .PP
509 The whole set of options accepted by the logging profiler is the following:
510 .TP
511 .I output
512 (or "out" or "o", default "o=profiler-log.prof"): the name of the output file.
513 .TP
514 .I jit
515 (or "j"): collect information about time spent jitting methods.
516 .TP
517 .I allocations
518 (or "alloc" or "a"): collect information about each allocation (object class
519 and size).
520 .TP
521 .I enter-leave
522 (or "calls" or "c"): measure the time spent inside each method call.
523 .TP
524 .I statistical
525 (or "stat" or "s"): do statistical profiling. 
526 .TP
527 .I unreachable
528 (or "free" or "f"): enable garbage collection profiling in its lightweight
529 form (at each collection, the list if unreachable objects is dumped, and
530 for each object the class and size is provided, which together with the
531 basic allocation information allows to compute the heap size broken down
532 by class).
533 .TP
534 .I heap-shot
535 (or "heap" or "h"): enable full heap profiling, in this case at each
536 collection a full heap snapshot is dumped to disk.
537 .TP
538 .I gc-commands
539 (or "gc-c" or "gcc", default none, file name required): the name of the
540 file that controls the heap snapshot dumps.
541 .TP
542 .I gc-dumps
543 (or "gc-d" or "gcd", default "gcd=0"): the initial number of heap
544 snapshots to dump (if the control file is not used). 
545 .TP
546 .I per-thread-buffer-size
547 (or "tbs", default "tbs=10000"): the number of events that a thread buffer
548 can hold, when it's full it is written to disk (the writing thread is the
549 one that filled its buffer).
550 .TP
551 .I statistical-thread-buffer-size
552 (or "sbs", default "sbs=10000"): the number of statistical samples that
553 are hold in memory before they are dumped to disk (the system does
554 double-buffering and the statistical samples are written by a helper
555 thread).
556 .TP
557 .I write-buffer-size
558 (or "wbs", default "wbs=1024"): size in bytes of the internal write
559 buffers. 
560 .SH CUSTOM PROFILERS
561 Mono provides a mechanism for loading other profiling modules which in
562 the form of shared libraries.  These profiling modules can hook up to
563 various parts of the Mono runtime to gather information about the code
564 being executed.
565 .PP
566 To use a third party profiler you must pass the name of the profiler
567 to Mono, like this:
568 .nf
569
570         mono --profile=custom program.exe
571
572 .fi
573 .PP
574 In the above sample Mono will load the user defined profiler from the
575 shared library `mono-profiler-custom.so'.  This profiler module must
576 be on your dynamic linker library path.
577 .PP 
578 A list of other third party profilers is available from Mono's web
579 site (www.mono-project.com/Performance_Tips)
580 .PP
581 Custom profiles are written as shared libraries.  The shared library
582 must be called `mono-profiler-NAME.so' where `NAME' is the name of
583 your profiler.
584 .PP
585 For a sample of how to write your own custom profiler look in the
586 Mono source tree for in the samples/profiler.c.
587 .SH CODE COVERAGE
588 Mono ships with a code coverage module.  This module is activated by
589 using the Mono --profile=cov option.  The format is:
590 .I "--profile=cov[:assembly-name[/namespace]] test-suite.exe"
591 .PP
592 By default code coverage will default to all the assemblies loaded,
593 you can limit this by specifying the assembly name, for example to
594 perform code coverage in the routines of your program use, for example
595 the following command line limits the code coverage to routines in the
596 "demo" assembly:
597 .nf
598
599         mono --profile=cov:demo demo.exe
600
601 .fi
602 .PP
603 Notice that the 
604 .I assembly-name
605 does not include the extension.
606 .PP
607 You can further restrict the code coverage output by specifying a
608 namespace:
609 .nf
610
611         mono --profile=cov:demo/My.Utilities demo.exe
612
613 .fi
614 .PP
615 Which will only perform code coverage in the given assembly and
616 namespace.  
617 .PP
618 Typical output looks like this:
619 .nf
620
621         Not covered: Class:.ctor ()
622         Not covered: Class:A ()
623         Not covered: Driver:.ctor ()
624         Not covered: Driver:method ()
625         Partial coverage: Driver:Main ()
626                 offset 0x000a
627
628 .fi
629 .PP
630 The offsets displayed are IL offsets.
631 .PP
632 A more powerful coverage tool is available in the module `monocov'.
633 See the monocov(1) man page for details.
634 .SH DEBUGGING
635 It is possible to obtain a stack trace of all the active threads in
636 Mono by sending the QUIT signal to Mono, you can do this from the
637 command line, like this:
638 .nf
639
640         kill -QUIT pid
641
642 .fi
643 Where pid is the Process ID of the Mono process you want to examine.
644 The process will continue running afterwards, but its state is not
645 guaranteed.
646 .PP
647 .B Important:
648 this is a last-resort mechanism for debugging applications and should
649 not be used to monitor or probe a production application.  The
650 integrity of the runtime after sending this signal is not guaranteed
651 and the application might crash or terminate at any given point
652 afterwards.   
653 .PP
654 You can use the MONO_LOG_LEVEL and MONO_LOG_MASK environment variables
655 to get verbose debugging output about the execution of your
656 application within Mono.
657 .PP
658 The 
659 .I MONO_LOG_LEVEL
660 environment variable if set, the logging level is changed to the set
661 value. Possible values are "error", "critical", "warning", "message",
662 "info", "debug". The default value is "error". Messages with a logging
663 level greater then or equal to the log level will be printed to
664 stdout/stderr.
665 .PP
666 Use "info" to track the dynamic loading of assemblies.
667 .PP
668 .PP
669 Use the 
670 .I MONO_LOG_MASK
671 environment variable to limit the extent of the messages you get: 
672 If set, the log mask is changed to the set value. Possible values are
673 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
674 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
675 The default value is "all". Changing the mask value allows you to display only 
676 messages for a certain component. You can use multiple masks by comma 
677 separating them. For example to see config file messages and assembly loader
678 messages set you mask to "asm,cfg".
679 .PP
680 The following is a common use to track down problems with P/Invoke:
681 .nf
682
683         $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
684
685 .fi
686 .PP
687 .SH SERIALIZATION
688 Mono's XML serialization engine by default will use a reflection-based
689 approach to serialize which might be slow for continuous processing
690 (web service applications).  The serialization engine will determine
691 when a class must use a hand-tuned serializer based on a few
692 parameters and if needed it will produce a customized C# serializer
693 for your types at runtime.  This customized serializer then gets
694 dynamically loaded into your application.
695 .PP
696 You can control this with the MONO_XMLSERIALIZER_THS environment
697 variable.
698 .PP
699 The possible values are 
700 .B `no' 
701 to disable the use of a C# customized
702 serializer, or an integer that is the minimum number of uses before
703 the runtime will produce a custom serializer (0 will produce a
704 custom serializer on the first access, 50 will produce a serializer on
705 the 50th use). Mono will fallback to an interpreted serializer if the
706 serializer generation somehow fails. This behavior can be disabled
707 by setting the option
708 .B `nofallback'
709 (for example: MONO_XMLSERIALIZER_THS=0,nofallback).
710 .SH ENVIRONMENT VARIABLES
711 .TP
712 .I "GC_DONT_GC"
713 Turns off the garbage collection in Mono.  This should be only used
714 for debugging purposes
715 .TP
716 .I "MONO_AOT_CACHE"
717 If set, this variable will instruct Mono to ahead-of-time compile new
718 assemblies on demand and store the result into a cache in
719 ~/.mono/aot-cache. 
720 .TP
721 .I "MONO_CFG_DIR"
722 If set, this variable overrides the default system configuration directory
723 ($PREFIX/etc). It's used to locate machine.config file.
724 .TP
725 .I "MONO_COM"
726 Sets the style of COM interop.  If the value of this variable is "MS"
727 Mono will use string marhsalling routines from the liboleaut32 for the
728 BSTR type library, any other values will use the mono-builtin BSTR
729 string marshalling.
730 .TP
731 .I "MONO_CONFIG"
732 If set, this variable overrides the default runtime configuration file
733 ($PREFIX/etc/mono/config). The --config command line options overrides the
734 environment variable.
735 .TP
736 .I "MONO_DEBUG"
737 If set, enables some features of the runtime useful for debugging.
738 This variable should contain a comma separated list of debugging options.
739 Currently, the following options are supported:
740 .RS
741 .ne 8
742 .TP
743 .I "collect-pagefault-stats"
744 Collects information about pagefaults.   This is used internally to
745 track the number of page faults produced to load metadata.  To display
746 this information you must use this option with "--stats" command line option.
747 .TP
748 .I "handle-sigint"
749 Captures the interrupt signal (Control-C) and displays a stack trace
750 when pressed.  Useful to find out where the program is executing at a
751 given point.  This only displays the stack trace of a single thread. 
752 .TP
753 .I "keep-delegates"
754 This option will leak delegate trampolines that are no longer
755 referenced as to present the user with more information about a
756 delegate misuse.  Basically a delegate instance might be created,
757 passed to unmanaged code, and no references kept in managed code,
758 which will garbage collect the code.  With this option it is possible
759 to track down the source of the problems. 
760 .TP
761 .I "break-on-unverified"
762 If this variable is set, when the Mono VM runs into a verification
763 problem, instead of throwing an exception it will break into the
764 debugger.  This is useful when debugging verifier problems
765 .ne
766 .RE
767 .TP
768 .I "MONO_DISABLE_AIO"
769 If set, tells mono NOT to attempt using native asynchronous I/O services. In
770 that case, a default select/poll implementation is used. Currently only epoll()
771 is supported.
772 .TP
773 .I "MONO_DISABLE_MANAGED_COLLATION"
774 If this environment variable is `yes', the runtime uses unmanaged
775 collation (which actually means no culture-sensitive collation). It
776 internally disables managed collation functionality invoked via the
777 members of System.Globalization.CompareInfo class. Collation is
778 enabled by default.
779 .TP
780 .I "MONO_EGD_SOCKET"
781 For platforms that do not otherwise have a way of obtaining random bytes
782 this can be set to the name of a file system socket on which an egd or
783 prngd daemon is listening.
784 .TP
785 .I "MONO_EVENTLOG_TYPE"
786 Sets the type of event log provider to use (for System.Diagnostics.EventLog).
787 .Sp
788 Possible values are:
789 .RS
790 .TP
791 .I "local[:path]"
792 .Sp
793 Persists event logs and entries to the local file system.
794 .Sp
795 The directory in which to persist the event logs, event sources and entries
796 can be specified as part of the value.
797 .Sp
798 If the path is not explicitly set, it defaults to "/var/lib/mono/eventlog"
799 on unix and "%APPDATA%\mono\eventlog" on Windows.
800 .TP
801 .I "win32"
802 .Sp
803 .B 
804 Uses the native win32 API to write events and registers event logs and
805 event sources in the registry.   This is only available on Windows. 
806 .Sp
807 On Unix, the directory permission for individual event log and event source
808 directories is set to 777 (with +t bit) allowing everyone to read and write
809 event log entries while only allowing entries to be deleted by the user(s)
810 that created them.
811 .TP
812 .I "null"
813 .Sp
814 Silently discards any events.
815 .ne
816 .PP
817 The default is "null" on Unix (and versions of Windows before NT), and 
818 "win32" on Windows NT (and higher).
819 .RE
820 .TP
821 .I "MONO_EXTERNAL_ENCODINGS"
822 If set, contains a colon-separated list of text encodings to try when
823 turning externally-generated text (e.g. command-line arguments or
824 filenames) into Unicode.  The encoding names come from the list
825 provided by iconv, and the special case "default_locale" which refers
826 to the current locale's default encoding.
827 .IP
828 When reading externally-generated text strings UTF-8 is tried first,
829 and then this list is tried in order with the first successful
830 conversion ending the search.  When writing external text (e.g. new
831 filenames or arguments to new processes) the first item in this list
832 is used, or UTF-8 if the environment variable is not set.
833 .IP
834 The problem with using MONO_EXTERNAL_ENCODINGS to process your
835 files is that it results in a problem: although its possible to get
836 the right file name it is not necessarily possible to open the file.
837 In general if you have problems with encodings in your filenames you
838 should use the "convmv" program.
839 .TP
840 .I "MONO_GAC_PREFIX"
841 Provides a prefix the runtime uses to look for Global Assembly Caches.
842 Directories are separated by the platform path separator (colons on
843 unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
844 install. Or to the directory provided in the gacutil /gacdir command. Example:
845 .B /home/username/.mono:/usr/local/mono/
846 .TP
847 .I "MONO_IOMAP"
848 Enables some filename rewriting support to assist badly-written
849 applications that hard-code Windows paths.  Set to a colon-separated
850 list of "drive" to strip drive letters, or "case" to do
851 case-insensitive file matching in every directory in a path.  "all"
852 enables all rewriting methods.  (Backslashes are always mapped to
853 slashes if this variable is set to a valid option.)
854 .fi
855 .Sp
856 For example, this would work from the shell:
857 .nf
858
859         MONO_IOMAP=drive:case
860         export MONO_IOMAP
861
862 .fi
863 If you are using mod_mono to host your web applications, you can use
864 the 
865 .B MonoSetEnv
866 directive, like this:
867 .nf
868
869         MonoSetEnv MONO_IOMAP=all
870
871 .fi
872 .TP
873 .I "MONO_MANAGED_WATCHER"
874 If set to "disabled", System.IO.FileSystemWatcher will use a file watcher 
875 implementation which silently ignores all the watching requests.
876 If set to any other value, System.IO.FileSystemWatcher will use the default
877 managed implementation (slow). If unset, mono will try to use inotify, FAM, 
878 Gamin, kevent under Unix systems and native API calls on Windows, falling 
879 back to the managed implementation on error.
880 .TP
881 .I "MONO_NO_SMP"
882 If set causes the mono process to be bound to a single processor. This may be
883 useful when debugging or working around race conditions.
884 .TP
885 .I "MONO_PATH"
886 Provides a search path to the runtime where to look for library
887 files.   This is a tool convenient for debugging applications, but
888 should not be used by deployed applications as it breaks the assembly
889 loader in subtle ways. 
890 .Sp
891 Directories are separated by the platform path separator (colons on unix). Example:
892 .B /home/username/lib:/usr/local/mono/lib
893 .Sp
894 Alternative solutions to MONO_PATH include: installing libraries into
895 the Global Assembly Cache (see gacutil(1)) or having the dependent
896 libraries side-by-side with the main executable.
897 .Sp
898 For a complete description of recommended practices for application
899 deployment, see the
900 http://www.mono-project.com/Guidelines:Application_Deployment page. 
901 .TP
902 .I "MONO_RTC"
903 Experimental RTC support in the statistical profiler: if the user has
904 the permission, more accurate statistics are gathered.  The MONO_RTC
905 value must be restricted to what the Linux rtc allows: power of two
906 from 64 to 8192 Hz. To enable higher frequencies like 4096 Hz, run as root:
907 .nf
908
909         echo 4096 > /proc/sys/dev/rtc/max-user-freq
910
911 .fi
912 .Sp
913 For example:
914 .nf
915
916         MONO_RTC=4096 mono --profiler=default:stat program.exe
917
918 .fi
919 .TP
920 .I "MONO_NO_TLS"
921 Disable inlining of thread local accesses. Try setting this if you get a segfault
922 early on in the execution of mono.
923 .TP 
924 .I "MONO_SHARED_DIR"
925 If set its the directory where the ".wapi" handle state is stored.
926 This is the directory where the Windows I/O Emulation layer stores its
927 shared state data (files, events, mutexes, pipes).  By default Mono
928 will store the ".wapi" directory in the users's home directory.
929 .TP 
930 .I "MONO_SHARED_HOSTNAME"
931 Uses the string value of this variable as a replacement for the host name when
932 creating file names in the ".wapi" directory. This helps if the host name of
933 your machine is likely to be changed when a mono application is running or if
934 you have a .wapi directory shared among several different computers.
935 .Sp
936 Mono typically uses the hostname to create the files that are used to
937 share state across multiple Mono processes.  This is done to support
938 home directories that might be shared over the network.
939 .TP
940 .I "MONO_STRICT_IO_EMULATION"
941 If set, extra checks are made during IO operations.  Currently, this
942 includes only advisory locks around file writes.
943 .TP
944 .I "MONO_DISABLE_SHM"
945 If set, disables the shared memory files used for cross-process
946 handles: process have only private handles.  This means that process
947 and thread handles are not available to other processes, and named
948 mutexes, named events and named semaphores are not visible between
949 processes.
950 .Sp
951 This is can also be enabled by default by passing the
952 "--disable-shared-handles" option to configure.
953 .TP
954 .I "MONO_THEME"
955 The name of the theme to be used by Windows.Forms.   Available themes today
956 include "clearlooks", "nice" and "win32".
957 .Sp
958 The default is "win32".  
959 .TP
960 .I "MONO_TLS_SESSION_CACHE_TIMEOUT"
961 The time, in seconds, that the SSL/TLS session cache will keep it's entry to
962 avoid a new negotiation between the client and a server. Negotiation are very
963 CPU intensive so an application-specific custom value may prove useful for 
964 small embedded systems.
965 .Sp
966 The default is 180 seconds.
967 .TP
968 .I "MONO_THREADS_PER_CPU"
969 The maximum number of threads in the general threadpool will be
970 20 + (MONO_THREADS_PER_CPU * number of CPUs). The default value for this
971 variable is 5.
972 .TP
973 .I "MONO_XMLSERIALIZER_THS"
974 Controls the threshold for the XmlSerializer to produce a custom
975 serializer for a given class instead of using the Reflection-based
976 interpreter.  The possible values are `no' to disable the use of a
977 custom serializer or a number to indicate when the XmlSerializer
978 should start serializing.   The default value is 50, which means that
979 the a custom serializer will be produced on the 50th use.
980 .TP
981 .I "MONO_XMLSERIALIZER_DEBUG"
982 Set this value to 1 to prevent the serializer from removing the
983 temporary files that are created for fast serialization;  This might
984 be useful when debugging.
985 .TP
986 .I "MONO_ASPNET_INHIBIT_SETTINGSMAP"
987 Mono contains a feature which allows modifying settings in the .config files shipped
988 with Mono by using config section mappers. The mappers and the mapping rules are
989 defined in the $prefix/etc/mono/2.0/settings.map file and, optionally, in the
990 settings.map file found in the top-level directory of your ASP.NET application.
991 Both files are read by System.Web on application startup, if they are found at the
992 above locations. If you don't want the mapping to be performed you can set this
993 variable in your environment before starting the application and no action will
994 be taken.
995 .SH ENVIRONMENT VARIABLES FOR DEBUGGING
996 .TP
997 .I "MONO_ASPNET_NODELETE"
998 If set to any value, temporary source files generated by ASP.NET support
999 classes will not be removed. They will be kept in the user's temporary
1000 directory.
1001 .TP
1002 .I "MONO_LOG_LEVEL"
1003 The logging level, possible values are `error', `critical', `warning',
1004 `message', `info' and `debug'.  See the DEBUGGING section for more
1005 details.
1006 .TP
1007 .I "MONO_LOG_MASK"
1008 Controls the domain of the Mono runtime that logging will apply to. 
1009 If set, the log mask is changed to the set value. Possible values are
1010 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
1011 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
1012 The default value is "all". Changing the mask value allows you to display only 
1013 messages for a certain component. You can use multiple masks by comma 
1014 separating them. For example to see config file messages and assembly loader
1015 messages set you mask to "asm,cfg".
1016 .TP
1017 .I "MONO_TRACE"
1018 Used for runtime tracing of method calls. The format of the comma separated
1019 trace options is:
1020 .nf
1021
1022         [-]M:method name
1023         [-]N:namespace
1024         [-]T:class name
1025         [-]all
1026         [-]program
1027         disabled                Trace output off upon start.
1028
1029 .fi
1030 You can toggle trace output on/off sending a SIGUSR2 signal to the program.
1031 .TP
1032 .I "MONO_TRACE_LISTENER"
1033 If set, enables the System.Diagnostics.DefaultTraceListener, which will 
1034 print the output of the System.Diagnostics Trace and Debug classes.  
1035 It can be set to a filename, and to Console.Out or Console.Error to display
1036 output to standard output or standard error, respectively. If it's set to
1037 Console.Out or Console.Error you can append an optional prefix that will
1038 be used when writing messages like this: Console.Error:MyProgramName.
1039 See the System.Diagnostics.DefaultTraceListener documentation for more
1040 information.
1041 .TP
1042 .I "MONO_XEXCEPTIONS"
1043 This throws an exception when a X11 error is encountered; by default a
1044 message is displayed but execution continues
1045 .TP
1046 .I "MONO_XSYNC"
1047 This is used in the System.Windows.Forms implementation when running
1048 with the X11 backend.  This is used to debug problems in Windows.Forms
1049 as it forces all of the commands send to X11 server to be done
1050 synchronously.   The default mode of operation is asynchronous which
1051 makes it hard to isolate the root of certain problems.
1052 .TP
1053 .I "MONO_GENERIC_SHARING"
1054 This environment variable is completely unsupported, don't use it.
1055 This controls for which classes to enable generic code sharing in
1056 principle.  Permissible values are "all", "corlib" and "none".  The
1057 default is "corlib", meaning that sharing can only happen for corlib
1058 classes.  Note that to enable generation of shared code the "gshared"
1059 compiler option has to be set as well.
1060 .SH VALGRIND
1061 If you want to use Valgrind, you will find the file `mono.supp'
1062 useful, it contains the suppressions for the GC which trigger
1063 incorrect warnings.  Use it like this:
1064 .nf
1065     valgrind --suppressions=mono.supp mono ...
1066 .fi
1067 .SH FILES
1068 On Unix assemblies are loaded from the installation lib directory.  If you set
1069 `prefix' to /usr, the assemblies will be located in /usr/lib.  On
1070 Windows, the assemblies are loaded from the directory where mono and
1071 mint live.
1072 .TP
1073 .B ~/.mono/aot-cache
1074 .Sp
1075 The directory for the ahead-of-time compiler demand creation
1076 assemblies are located. 
1077 .TP
1078 .B /etc/mono/config, ~/.mono/config
1079 .Sp
1080 Mono runtime configuration file.  See the mono-config(5) manual page
1081 for more information.
1082 .TP
1083 .B ~/.config/.mono/certs, /usr/share/.mono/certs
1084 .Sp
1085 Contains Mono certificate stores for users / machine. See the certmgr(1) 
1086 manual page for more information on managing certificate stores and
1087 the mozroots(1) page for information on how to import the Mozilla root
1088 certificates into the Mono certificate store. 
1089 .TP
1090 .B ~/.mono/assemblies/ASSEMBLY/ASSEMBLY.config
1091 .Sp
1092 Files in this directory allow a user to customize the configuration
1093 for a given system assembly, the format is the one described in the
1094 mono-config(5) page. 
1095 .TP
1096 .B ~/.config/.mono/keypairs, /usr/share/.mono/keypairs
1097 .Sp
1098 Contains Mono cryptographic keypairs for users / machine. They can be 
1099 accessed by using a CspParameters object with DSACryptoServiceProvider
1100 and RSACryptoServiceProvider classes.
1101 .TP
1102 .B ~/.config/.isolatedstorage, ~/.local/share/.isolatedstorage, /usr/share/.isolatedstorage
1103 .Sp
1104 Contains Mono isolated storage for non-roaming users, roaming users and 
1105 local machine. Isolated storage can be accessed using the classes from 
1106 the System.IO.IsolatedStorage namespace.
1107 .TP
1108 .B <assembly>.config
1109 .Sp
1110 Configuration information for individual assemblies is loaded by the
1111 runtime from side-by-side files with the .config files, see the
1112 http://www.mono-project.com/Config for more information.
1113 .TP
1114 .B Web.config, web.config
1115 .Sp
1116 ASP.NET applications are configured through these files, the
1117 configuration is done on a per-directory basis.  For more information
1118 on this subject see the http://www.mono-project.com/Config_system.web
1119 page. 
1120 .SH MAILING LISTS
1121 Mailing lists are listed at the
1122 http://www.mono-project.com/Mailing_Lists
1123 .SH WEB SITE
1124 http://www.mono-project.com
1125 .SH SEE ALSO
1126 .PP
1127 certmgr(1), mcs(1), monocov(1), monodis(1), mono-config(5), mozroots(1), xsp(1).
1128 .PP
1129 For more information on AOT:
1130 http://www.mono-project.com/AOT
1131 .PP
1132 For ASP.NET-related documentation, see the xsp(1) manual page