svn path=/branches/mono-1-1-9/mcs/; revision=51216
[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 ths 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 developping and debugging, and for testing and
41 debugging the runtime itself.
42 .SH RUNTIME OPTIONS
43 The following options are available:
44 .TP
45 .I "--aot"
46 This option is used to precompile the CIL code in the specified
47 assembly to native code.  The generated code is stored in a file with
48 the extension .so.  This file will be automatically picked up by the
49 runtime when the assembly is executed.  
50 .Sp 
51 Ahead-of-Time compilation is most useful if you use it in combination
52 with the -O=all,-shared flag which enables all of the optimizations in
53 the code generator to be performed.  Some of those optimizations are
54 not practical for Just-in-Time compilation since they might be very
55 time consuming.
56 .Sp
57 Unlike the .NET Framework, Ahead-of-Time compilation will not generate
58 domain independent code: it generates the same code that the
59 Just-in-Time compiler would produce.   Since most applications use a
60 single domain, this is fine.   If you want to optimize the generated
61 code for use in multi-domain applications, consider using the
62 -O=shared flag.
63 .Sp
64 This pre-compiles the methods, but the original assembly is still
65 required to execute as this one contains the metadata and exception
66 information which is not availble on the generated file.  When
67 precompiling code, you might want to compile with all optimizations
68 (-O=all).  Pre-compiled code is position independent code.
69 .Sp
70 Pre compilation is just a mechanism to reduce startup time, and avoid
71 just-in-time compilation costs.  The original assembly must still be
72 present, as the metadata is contained there.
73 .TP
74 .I "--config filename"
75 Load the specified configuration file instead of the default one(s).
76 The default files are /etc/mono/config and ~/.mono/config or the file
77 specified in the MONO_CONFIG environment variable, if set.  See the
78 mono-config(5) man page for details on the format of this file.
79 .TP
80 .I "--help", "-h"
81 Displays usage instructions.
82 .TP
83 .I "--optimize=MODE", "-O=mode"
84 MODE is a comma separated list of optimizations.  They also allow
85 optimizations to be turned off by prefixing the optimization name with
86 a minus sign.
87 .Sp
88 The following optimizations are implemented:
89 .nf
90              all        Turn on all optimizations
91              peephole   Peephole postpass
92              branch     Branch optimizations
93              inline     Inline method calls
94              cfold      Constant folding
95              consprop   Constant propagation
96              copyprop   Copy propagation
97              deadce     Dead code elimination
98              linears    Linear scan global reg allocation
99              cmov       Conditional moves
100              shared     Emit per-domain code
101              sched      Instruction scheduling
102              intrins    Intrinsic method implementations
103              tailc      Tail recursion and tail calls
104              loop       Loop related optimizations
105              fcmov      Fast x86 FP compares
106              leaf       Leaf procedures optimizations
107              aot        Usage of Ahead Of Time compiled code
108              precomp    Precompile all methods before executing Main
109              abcrem     Array bound checks removal
110              ssapre     SSA based Partial Redundancy Elimination
111 .fi
112 .Sp
113 For example, to enable all the optimization but dead code
114 elimination and inlining, you can use:
115 .nf
116         -O=all,-deadce,-inline
117 .fi
118 .TP
119 .I "--security"
120 Activate the security manager (experimental feature in 1.1). This allows 
121 mono to support declarative security attributes (e.g. execution of, CAS 
122 or non-CAS, security demands). The security manager is OFF by default 
123 (experimental).
124 .TP
125 .I "-V", "--version"
126 Prints JIT version information.
127
128
129 .SH DEVELOPMENT OPTIONS
130 The following options are used to help when developing a JITed application.
131 .TP
132 .I "--debug"
133 Turns on the debugging mode in the runtime.  If an assembly was
134 compiled with debugging information, it will produce line number
135 information for stack traces. 
136 .TP
137 .I "--profile[=profiler[:profiler_args]]"
138 Turns on profiling.  For more information about profiling applications
139 and code coverage see the sections "PROFILING" and "CODE COVERAGE"
140 below. 
141 .TP
142 .I "--trace[=expression]"
143 Shows method names as they are invoked.  By default all methods are
144 traced. 
145 .Sp
146 The trace can be customized to include or exclude methods, classes or
147 assemblies.  A trace expression is a comma separated list of targets,
148 each target can be prefixed with a minus sign to turn off a particular
149 target.  The words `program' and `all' have special meaning.
150 `program' refers to the main program being executed, and `all' means
151 all the method calls. 
152 .Sp
153 Assemblies are specified by their name, for example, to trace all
154 calls in the System assembly, use:
155 .nf
156
157         mono --trace=System app.exe
158
159 .fi
160 Classes are specified with the T: prefix.  For example, to trace all
161 calls to the System.String class, use:
162 .nf
163
164         mono --trace=T:System.String app.exe
165
166 .fi
167 And individual methods are referenced with the M: prefix, and the
168 standar method notation:
169 .nf
170
171         mono --trace=M:System.Console:WriteLine app.exe
172
173 .fi
174 As previously noted, various rules can be specified at once:
175 .nf
176
177         mono --trace=T:System.String,T:System.Random app.exe
178
179 .fi
180 You can exclude pieces, the next example traces calls to
181 System.String except for the System.String:Concat method.
182 .nf
183
184         mono --trace=T:System.String,-M:System.String:Concat
185
186 .fi
187 Finally, namespaces can be specified using the N: prefix:
188 .nf
189
190         mono --trace=N:System.Xml
191
192 .fi
193 .SH JIT MAINTAINER OPTIONS
194 The maintainer options are only used by those developing the runtime
195 itself, and not typically of interest to runtime users or developers.
196 .TP
197 .I "--compile name"
198 This compiles a method (namespace.name:methodname), this is used for
199 testing the compiler performance or to examine the output of the code
200 generator. 
201 .TP
202 .I "--compileall"
203 Compiles all the methods in an assembly.  This is used to test the
204 compiler performance or to examine the output of the code generator
205 .TP 
206 .I "--graph=TYPE METHOD"
207 This generates a postscript file with a graph with the details about
208 the specified method (namespace.name:methodname).  This requires `dot'
209 and ghostview to be installed (it expects Ghostview to be called
210 "gv"). 
211 .Sp
212 The following graphs are available:
213 .nf
214           cfg        Control Flow Graph (CFG)
215           dtree      Dominator Tree
216           code       CFG showing code
217           ssa        CFG showing code after SSA translation
218           optcode    CFG showing code after IR optimizations
219 .fi
220 .Sp
221 Some graphs will only be available if certain optimizations are turned
222 on.
223 .TP
224 .I "--ncompile"
225 Instruct the runtime on the number of times that the method specified
226 by --compile (or all the methods if --compileall is used) to be
227 compiled.  This is used for testing the code generator performance. 
228 .TP
229 .I "-v", "--verbose"
230 Increases the verbosity level, each time it is listed, increases the
231 verbosity level to include more information (including, for example, 
232 a disassembly of the native code produced, code selector info etc.).
233 .TP
234 .I "--break method"
235 Inserts a breakpoint before the method whose name is `method'
236 (namespace.class:methodname).  Use `Main' as method name to insert a
237 breakpoint on the application's main method.
238 .TP
239 .I "--breakonex"
240 Inserts a breakpoint on exceptions.  This allows you to debug your
241 application with a native debugger when an exception is thrown.
242 .SH PROFILING
243 The mono runtime includes a profiler that can be used to explore
244 various performance related problems in your application.  The
245 profiler is activated by passing the --profile command line argument
246 to the Mono runtime, the format is:
247 .nf
248
249         --profile[=profiler[:profiler_args]]
250
251 .fi
252 Mono has a built-in profiler called 'default' (and is also the default
253 if no arguments are specified), but developers can write custom
254 profilers, see the section "CUSTOM PROFILERS" for more details.
255 .PP
256 If a 
257 .I profiler 
258 is not specified, the default profiler is used.
259 .Sp
260 The 
261 .I profiler_args 
262 is a profiler-specific string of options for the profiler itself.
263 .Sp
264 The default profiler accepts the following options 'alloc' to profile
265 memory consumption by the application; 'time' to profile the time
266 spent on each routine and 'stat' to perform sample statistical
267 profiling.  If no options are provided the default is 'alloc,time'.
268 .Sp
269 For example:
270 .nf
271
272         mono --profile program.exe
273
274 .fi
275 .Sp
276 That will run the program with the default profiler and will do time
277 and allocation profiling.
278 .Sp
279 .nf
280
281         mono --profile=default:stat,alloc program.exe
282
283 .fi
284 Will do  sample statistical profiling and allocation profiling on
285 program.exe.
286 .SH CUSTOM PROFILERS
287 Mono provides a mechanism for loading other profiling modules which in
288 the form of shared libraries.  These profiling modules can hook up to
289 various parts of the Mono runtime to gather information about the code
290 being executed.  
291 .PP
292 To use a third party profiler you must pass the name of the profiler
293 to Mono, like this:
294 .nf
295
296         mono --profile=custom program.exe
297
298 .fi
299 .PP
300 In the above sample Mono will load the user defined profiler from the
301 shared library `mono-profiler-custom.so'.  This profiler module must
302 be on your dynamic linker library path.
303 .PP 
304 A list of other third party profilers is available from Mono's web
305 site (www.mono-project.com/Performance_Tips)
306 .PP
307 Custom profiles are written as shared libraries.  The shared library
308 must be called `mono-profiler-NAME.so' where `NAME' is the name of
309 your profiler.
310 .PP
311 For a sample of how to write your own custom profiler look in the
312 Mono source tree for in the samples/profiler.c.
313 .SH CODE COVERAGE
314 Mono ships with a code coverage module.  This module is activated by
315 using the Mono --profile=cov option.  The format is:
316 .I "--profile=cov[:assembly-name[/namespace]] test-suite.exe"
317 .PP
318 By default code coverage will default to all the assemblies loaded,
319 you can limit this by specifying the assembly name, for example to
320 perform code coverage in the routines of your program use, for example
321 the following command line limits the code coverage to routines in the
322 "demo" assembly:
323 .nf
324
325         mono --profile=cov:demo demo.exe
326
327 .fi
328 .PP
329 Notice that the 
330 .I assembly-name
331 does not include the extension.
332 .PP
333 You can further restrict the code coverage output by specifying a
334 namespace:
335 .nf
336
337         mono --profile=cov:demo/My.Utilities demo.exe
338
339 .fi
340 .PP
341 Which will only perform code coverage in the given assembly and
342 namespace.  
343 .PP
344 Typical output looks like this:
345 .nf
346
347         Not covered: Class:.ctor ()
348         Not covered: Class:A ()
349         Not covered: Driver:.ctor ()
350         Not covered: Driver:method ()
351         Partial coverage: Driver:Main ()
352                 offset 0x000a
353
354 .fi
355 .PP
356 The offsets displayed are IL offsets.
357 .SH DEBUGGING
358 .PP
359 You can use the MONO_LOG_LEVEL and MONO_LOG_MASK environment variables
360 to get verbose debugging output about the execution of your
361 application within Mono.
362 .PP
363 The 
364 .I MONO_LOG_LEVEL
365 environment variable if set, the logging level is changed to the set
366 value. Possible values are "error", "critical", "warning", "message",
367 "info", "debug". The default value is "error". Messages with a logging
368 level greater then or equal to the log level will be printed to
369 stdout/stderr.
370 .PP
371 Use "info" to track the dynamic loading of assemblies.
372 .PP
373 .PP
374 Use the 
375 .I MONO_LOG_MASK
376 environment variable to limit the extent of the messages you get: 
377 If set, the log mask is changed to the set value. Possible values are
378 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
379 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
380 The default value is "all". Changing the mask value allows you to display only 
381 messages for a certain component. You can use multiple masks by comma 
382 separating them. For example to see config file messages and assembly loader
383 messages set you mask to "asm,cfg".
384 .PP
385 The following is a common use to track down problems with P/Invoke:
386 .nf
387
388         $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
389
390 .fi
391 .PP
392 .SH SERIALIZATION
393 Mono's XML serialization engine by default will use a reflection-based
394 approach to serialize which might be slow for continous processing
395 (web service applications).  The serialization engine will determine
396 when a class must use a hand-tuned serializer based on a few
397 parameters and if needed it will produce a customized C# serializer
398 for your types at runtime.  This customized serializer then gets
399 dynamically loaded into your application.
400 .PP
401 You can control this with the MONO_XMLSERIALIZER_THS environment
402 variable.
403 .PP
404 The possible values are 
405 .B `no' 
406 to disable the use of a C# customized
407 serializer, or an integer that is the minimum number of uses before
408 the runtime will produce a custom serializer (0 will produce a
409 custom serializer on the first access, 50 will produce a serializer on
410 the 50th use).
411 .SH ENVIRONMENT VARIABLES
412 .TP
413 .I "GC_DONT_GC"
414 Turns off the garbage collection in Mono.  This should be only used
415 for debugging purposes
416 .TP
417 .I "MONO_AOT_CACHE"
418 If set, this variable will instruct Mono to ahead-of-time compile new
419 assemblies on demand and store the result into a cache in
420 ~/.mono/aot-cache. 
421 .TP
422 .I "MONO_ASPNET_NODELETE"
423 If set to any value, temporary source files generated by ASP.NET support
424 classes will not be removed. They will be kept in the user's temporary
425 directory.
426 .TP
427 .I "MONO_CFG_DIR"
428 If set, this variable overrides the default system configuration directory
429 ($PREFIX/etc). It's used to locate machine.config file.
430 .TP
431 .I "MONO_CONFIG"
432 If set, this variable overrides the default runtime configuration file
433 ($PREFIX/etc/mono/config). The --config command line options overrides the
434 environment variable.
435 .TP
436 .I "MONO_DEBUG"
437 If set, enables some features of the runtime useful for debugging.
438 This variable should contain a comma separated list of debugging options.
439 Currently, the following options are supported:
440 .RS
441 .ne 8
442 .TP
443 .I "keep-delegates"
444 This option will leak delegate trampolines that are no longer
445 referenced as to present the user with more information about a
446 delegate missuse.  Basically a delegate instance might be created,
447 passed to unmanaged code, and no references kept in managed code,
448 which will garbage collect the code.  With this option it is possible
449 to track down the source of the problems. 
450 .TP
451 .I "abort-on-sigsegv"
452 This option will make the runtime abort when it receives a SIGSEGV signal
453 while executing unmanaged (native) code. This is useful for debugging
454 problems when interfacing with native code.
455 .ne
456 .RE
457 .TP
458 .I "MONO_DISABLE_AIO"
459 If set, tells mono NOT to attempt using native asynchronous I/O services. In
460 that case, a default select/poll implementation is used. Currently only epoll()
461 is supported.
462 .TP
463 .I "MONO_EGD_SOCKET"
464 For platforms that do not otherwise have a way of obtaining random bytes
465 this can be set to the name of a file system socket on which an egd or
466 prngd daemon is listening.
467 .TP
468 .I "MONO_EXTERNAL_ENCODINGS"
469 If set, contains a colon-separated list of text encodings to try when
470 turning externally-generated text (e.g. command-line arguments or
471 filenames) into Unicode.  The encoding names come from the list
472 provided by iconv, and the special case "default_locale" which refers
473 to the current locale's default encoding.
474 .IP
475 When reading externally-generated text strings UTF-8 is tried first,
476 and then this list is tried in order with the first successful
477 conversion ending the search.  When writing external text (e.g. new
478 filenames or arguments to new processes) the first item in this list
479 is used, or UTF-8 if the environment variable is not set.
480 .TP
481 .I "MONO_GAC_PREFIX"
482 Provides a prefix the runtime uses to look for Global Assembly Caches.
483 Directories are separated by the platform path separator (colons on
484 unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
485 install. Or to the directory provided in the gacutil /gacdir command. Example:
486 .B /home/username/.mono:/usr/local/mono/
487 .TP
488 .I "MONO_LOG_LEVEL"
489 The logging level, possible values are `error', `critical', `warning',
490 `message', `info' and `debug'.  See the DEBUGGING section for more
491 details.
492 .TP
493 .I "MONO_LOG_MASK"
494 Controls the domain of the Mono runtime that logging will apply to. 
495 If set, the log mask is changed to the set value. Possible values are
496 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
497 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
498 The default value is "all". Changing the mask value allows you to display only 
499 messages for a certain component. You can use multiple masks by comma 
500 separating them. For example to see config file messages and assembly loader
501 messages set you mask to "asm,cfg".
502 .TP
503 .I "MONO_MANAGED_WATCHER"
504 If set to any value, System.IO.FileSystemWatcher will use the default
505 managed implementation (slow). If unset, mono will try to use FAM under
506 Unix systems and native API calls on Windows, falling back to the
507 managed implementation on error.
508 .TP
509 .I "MONO_PATH"
510 Provides a search path to the runtime where to look for library files.
511 Directories are separated by the platform path separator (colons on unix). Example:
512 .B /home/username/lib:/usr/local/mono/lib
513 .TP
514 .I "MONO_RTC"
515 Experimental RTC support in the statistical profiler: if the user has
516 the permission, more accurate statistics are gathered.  The MONO_RTC
517 value must be restricted to what the linux rtc allows: power of two
518 from 64 to 8192 Hz. To enable higher frequencies like 4096 Hz, run as root:
519 .nf
520
521         echo 4096 > /proc/sys/dev/rtc/max-user-freq
522
523 .fi
524 .Sp
525 For example:
526 .nf
527
528         MONO_RTC=4096 mono --profiler=default:stat program.exe
529
530 .fi
531 .TP
532 .I "MONO_NO_TLS"
533 Disable inlining of thread local accesses. Try setting this if you get a segfault
534 early on in the execution of mono.
535 .TP 
536 .I "MONO_SHARED_DIR"
537 If set its the directory where the ".wapi" handle state is stored.
538 This is the directory where the Windows I/O Emulation layer stores its
539 shared state data (files, events, mutexes, pipes).  By default Mono
540 will store the ".wapi" directory in the users's home directory.
541 .TP
542 .I "MONO_THREADS_PER_CPU"
543 The maximum number of threads in the general threadpool will be
544 20 + (MONO_THREADS_PER_CPU * number of CPUs). The default value for this
545 variable is 5.
546 .TP
547 .I "MONO_TRACE"
548 Used for runtime tracing of method calls. The format of the comma separated
549 trace options is:
550 .nf
551
552         [-]M:method name
553         [-]N:namespace
554         [-]T:class name
555         [-]all
556         [-]program
557         disabled                Trace output off upon start.
558
559 .fi
560 You can toggle trace output on/off sending a SIGUSR2 signal to the program.
561 .TP
562 .I "MONO_TRACE_LISTENER"
563 If set, enables the System.Diagnostics.DefaultTraceListener, which will 
564 print the output of the System.Diagnostics Trace and Debug classes.  
565 It can be set to a filename, and to Console.Out or Console.Error to display
566 output to standard output or standard error, respectively. If it's set to
567 Console.Out or Console.Error you can append an optional prefix that will
568 be used when writing messages like this: Console.Error:MyProgramName.
569 See the System.Diagnostics.DefaultTraceListener documentation for more
570 information.
571 .TP
572 .I "MONO_XMLSERIALIZER_THS"
573 Controls the threshold for the XmlSerializer to produce a custom
574 serializer for a given class instead of using the Reflection-based
575 interpreter.  The possible values are `no' to disable the use of a
576 custom serializer or a number to indicate when the XmlSerializer
577 should start serializing.   The default value is 50, which means that
578 the a custom serializer will be produced on the 50th use.
579 .SH FILES
580 On Unix assemblies are loaded from the installation lib directory.  If you set
581 `prefix' to /usr, the assemblies will be located in /usr/lib.  On
582 Windows, the assemblies are loaded from the directory where mono and
583 mint live.
584 .PP
585 ~/.mono/aot-cache
586 .PP
587 The directory for the ahead-of-time compiler demand creation
588 assemblies are located. 
589 .PP
590 /etc/mono/config, ~/.mono/config
591 .PP
592 Mono runtime configuration file.  See the mono-config(5) manual page
593 for more information.
594 .PP
595 ~/.config/.mono/certs, /usr/share/.mono/certs
596 .PP
597 Contains Mono certificate stores for users / machine. See the certmgr(1) 
598 manual page for more information on managing certificate stores.
599 .PP
600 ~/.config/.mono/keypairs, /usr/share/.mono/keypairs
601 .PP
602 Contains Mono cryptographic keypairs for users / machine. They can be 
603 accessed by using a CspParameters object with DSACryptoServiceProvider
604 and RSACryptoServiceProvider classes.
605 .PP
606 ~/.config/.isolatedstorage, ~/.local/share/.isolatedstorage, /usr/share/.isolatedstorage
607 .PP
608 Contains Mono isolated storage for non-roaming users, roaming users and 
609 local machine. Isolated storage can be accessed using the classes from 
610 the System.IO.IsolatedStorage namespace.
611 .SH MAILING LISTS
612 Mailing lists are listed at the
613 http://www.mono-project.com/Mailing_Lists
614 .SH WEB SITE
615 http://www.mono-project.com
616 .SH SEE ALSO
617 .BR mcs(1), mint(1), monodis(1), mono-config(5), certmgr(1).
618 .PP
619 For ASP.NET-related documentation, see the xsp(1) manual page