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