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