Add man page
[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 Instructs the runtime to collect profiling information about execution
139 times and memory allocation, and dump it at the end of the execution.
140 If a profiler is not specified, the default profiler is used.
141 .Sp
142 Mono has a built-in profiler called `default' (and is also the default
143 if no arguments are specified), but developers can write custom
144 profilers as shared libraries.  The shared library must be called
145 `mono-profiler-NAME.so' where `NAME' is the name of your profiler.
146 .Sp
147 For a sample of the custom profilers look in the Mono source tree for
148 in the samples/profiler.c.
149 .Sp
150 The 
151 .I profiler_args 
152 is a profiler-specific string of options for the profiler itself.
153 .Sp
154 The default profiler is called `default' and it accepts `alloc' to
155 profile memory consumption by the application; `time' to profile the
156 time spent on each routine and `stat' to perform sample statistical
157 profiling.  If no options are provided the default is `alloc,time'.
158 .Sp
159 For example:
160 .nf
161         mono --profile program.exe
162 .fi
163 .Sp
164 That will run the program with the default profiler and will do time
165 and allocation profiling.
166 .Sp
167 .nf
168         mono --profile=default:stat,alloc program.exe
169 .fi
170 Will do  sample statistical profiling and allocation profiling on
171 program.exe.
172 .TP
173 .nf
174         mono --profile=custom program.exe
175 .fi
176 .Sp
177 In the above sample Mono will load the user defined profiler from the
178 shared library `mono-profiler-custom.so'.
179 .SH JIT MAINTAINER OPTIONS
180 The maintainer options are only used by those developing the runtime
181 itself, and not typically of interest to runtime users or developers.
182 .TP
183 .I "--compile name"
184 This compiles a method (namespace.name:methodname), this is used for
185 testing the compiler performance or to examine the output of the code
186 generator. 
187 .TP
188 .I "--compileall"
189 Compiles all the methods in an assembly.  This is used to test the
190 compiler performance or to examine the output of the code generator
191 .TP 
192 .I "--graph=TYPE METHOD"
193 This generates a postscript file with a graph with the details about
194 the specified method (namespace.name:methodname).  This requires `dot'
195 and ghostview to be installed (it expects Ghostview to be called
196 "gv"). 
197 .Sp
198 The following graphs are available:
199 .nf
200           cfg        Control Flow Graph (CFG)
201           dtree      Dominator Tree
202           code       CFG showing code
203           ssa        CFG showing code after SSA translation
204           optcode    CFG showing code after IR optimizations
205 .fi
206 .Sp
207 Some graphs will only be available if certain optimizations are turned
208 on.
209 .TP
210 .I "--ncompile"
211 Instruct the runtime on the number of times that the method specified
212 by --compile (or all the methods if --compileall is used) to be
213 compiled.  This is used for testing the code generator performance. 
214 .TP
215 .I "-v", "--verbose"
216 Increases the verbosity level, each time it is listed, increases the
217 verbosity level to include more information (including, for example, 
218 a disassembly of the native code produced, code selector info etc.).
219 .TP
220 .I "--break method"
221 Inserts a breakpoint before the method whose name is `method'
222 (namespace.class:methodname).  Use `Main' as method name to insert a
223 breakpoint on the application's main method.
224 .TP
225 .I "--breakonex"
226 Inserts a breakpoint on exceptions.  This allows you to debug your
227 application with a native debugger when an exception is thrown.
228 .TP
229 .I "--trace[=expression]"
230 Shows method names as they are invoked.  By default all methods are
231 traced. 
232 .Sp
233 The trace can be customized to include or exclude methods, classes or
234 assemblies.  A trace expression is a comma separated list of targets,
235 each target can be prefixed with a minus sign to turn off a particular
236 target.  The words `program' and `all' have special meaning.
237 `program' refers to the main program being executed, and `all' means
238 all the method calls. 
239 .Sp
240 Assemblies are specified by their name, for example, to trace all
241 calls in the System assembly, use:
242 .nf
243
244         mono --trace=System app.exe
245
246 .fi
247 Classes are specified with the T: prefix.  For example, to trace all
248 calls to the System.String class, use:
249 .nf
250
251         mono --trace=T:System.String app.exe
252
253 .fi
254 And individual methods are referenced with the M: prefix, and the
255 standar method notation:
256 .nf
257
258         mono --trace=M:System.Console:WriteLine app.exe
259
260 .fi
261 As previously noted, various rules can be specified at once:
262 .nf
263
264         mono --trace=T:System.String,T:System.Random app.exe
265
266 .fi
267 You can exclude pieces, the next example traces calls to
268 System.String except for the System.String:Concat method.
269 .nf
270
271         mono --trace=T:System.String,-M:System.String:Concat
272
273 .fi
274 Finally, namespaces can be specified using the N: prefix:
275 .nf
276
277         mono --trace=N:System.Xml
278
279 .fi
280 .SH DEBUGGING
281 .PP
282 You can use the MONO_LOG_LEVEL and MONO_LOG_MASK environment variables
283 to get verbose debugging output about the execution of your
284 application within Mono.
285 .PP
286 The 
287 .I MONO_LOG_LEVEL
288 environment variable if set, the logging level is changed to the set
289 value. Possible values are "error", "critical", "warning", "message",
290 "info", "debug". The default value is "error". Messages with a logging
291 level greater then or equal to the log level will be printed to
292 stdout/stderr.
293 .PP
294 Use "info" to track the dynamic loading of assemblies.
295 .PP
296 .PP
297 Use the 
298 .I MONO_LOG_MASK
299 environment variable to limit the extent of the messages you get: 
300 If set, the log mask is changed to the set value. Possible values are
301 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
302 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
303 The default value is "all". Changing the mask value allows you to display only 
304 messages for a certain component. You can use multiple masks by comma 
305 separating them. For example to see config file messages and assembly loader
306 messages set you mask to "asm,cfg".
307 .PP
308 The following is a common use to track down problems with P/Invoke:
309 .nf
310         $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
311 .fi
312 .PP
313 .SH SERIALIZATION
314 Mono's XML serialization engine by default will use a reflection-based
315 approach to serialize which might be slow for continous processing
316 (web service applications).  The serialization engine will determine
317 when a class must use a hand-tuned serializer based on a few
318 parameters and if needed it will produce a customized C# serializer
319 for your types at runtime.  This customized serializer then gets
320 dynamically loaded into your application.
321 .PP
322 You can control this with the MONO_XMLSERIALIZER_THS environment
323 variable.
324 .PP
325 The possible values are 
326 .B `no' 
327 to disable the use of a C# customized
328 serializer, or an integer that is the minimum number of uses before
329 the runtime will produce a custom serializer (0 will produce a
330 custom serializer on the first access, 50 will produce a serializer on
331 the 50th use).
332 .SH ENVIRONMENT VARIABLES
333 .TP
334 .I "GC_DONT_GC"
335 Turns off the garbage collection in Mono.  This should be only used
336 for debugging purposes
337 .TP
338 .I "MONO_AOT_CACHE"
339 If set, this variable will instruct Mono to ahead-of-time compile new
340 assemblies on demand and store the result into a cache in
341 ~/.mono/aot-cache. 
342 .TP
343 .I "MONO_ASPNET_NODELETE"
344 If set to any value, temporary source files generated by ASP.NET support
345 classes will not be removed. They will be kept in the user's temporary
346 directory.
347 .TP
348 .I "MONO_CFG_DIR"
349 If set, this variable overrides the default system configuration directory
350 ($PREFIX/etc). It's used to locate machine.config file.
351 .TP
352 .I "MONO_CONFIG"
353 If set, this variable overrides the default runtime configuration file
354 ($PREFIX/etc/mono/config). The --config command line options overrides the
355 environment variable.
356 .TP
357 .I "MONO_DEBUG"
358 If set, enables some features of the runtime useful for debugging.
359 Currently this enables two features: stack traces when interrupting
360 the process from the shell;  Visible error messages on assembly
361 loading and also to track problems with delegates that are released,
362 but a reference is kept in unmanaged code.
363 .TP
364 The stack tracing option makes the runtime display the stack traces
365 for all the threads running and exit when mono is interrupted (Ctrl-C)
366 and print some additional messages on error conditions. It may not
367 exit cleanly. Use at your own risk.
368 .TP
369 Also, this option will leak delegate trampolines that are no longer
370 referenced as to present the user with more information about a
371 delegate missuse.  Basically a delegate instance might be created,
372 passed to unmanaged code, and no references kept in managed code,
373 which will garbage collect the code.  With this option it is possible
374 to track down the source of the problems. 
375 .TP
376 .I "MONO_DISABLE_AIO"
377 If set, tells mono NOT to attempt using native asynchronous I/O services. In
378 that case, the threadpool is used for asynchronous I/O on files and sockets.
379 .TP
380 .I "MONO_DISABLE_SHM"
381 If this variable is set, it disables the shared memory part of the
382 Windows I/O Emulation layer, and handles (files, events, mutexes,
383 pipes) will not be shared across processes.  Process creation is also
384 disabled.  This option is only available on Unix.
385 .TP
386 .I "MONO_EGD_SOCKET"
387 For platforms that do not otherwise have a way of obtaining random bytes
388 this can be set to the name of a file system socket on which an egd or
389 prngd daemon is listening.
390 .TP
391 .I "MONO_EXTERNAL_ENCODINGS"
392 If set, contains a colon-separated list of text encodings to try when
393 turning externally-generated text (e.g. command-line arguments or
394 filenames) into Unicode.  The encoding names come from the list
395 provided by iconv, and the special case "default_locale" which refers
396 to the current locale's default encoding.
397 .IP
398 When reading externally-generated text strings UTF-8 is tried first,
399 and then this list is tried in order with the first successful
400 conversion ending the search.  When writing external text (e.g. new
401 filenames or arguments to new processes) the first item in this list
402 is used, or UTF-8 if the environment variable is not set.
403 .TP
404 .I "MONO_GAC_PREFIX"
405 Provides a prefix the runtime uses to look for Global Assembly Caches.
406 Directories are separated by the platform path separator (colons on
407 unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
408 install. Or to the directory provided in the gacutil /gacdir command. Example:
409 .B /home/username/.mono:/usr/local/mono/
410 .TP
411 .I "MONO_LOG_LEVEL"
412 The logging level, possible values are `error', `critical', `warning',
413 `message', `info' and `debug'.  See the DEBUGGING section for more
414 details.
415 .TP
416 .I "MONO_LOG_MASK"
417 Controls the domain of the Mono runtime that logging will apply to. 
418 If set, the log mask is changed to the set value. Possible values are
419 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
420 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
421 The default value is "all". Changing the mask value allows you to display only 
422 messages for a certain component. You can use multiple masks by comma 
423 separating them. For example to see config file messages and assembly loader
424 messages set you mask to "asm,cfg".
425 .TP
426 .I "MONO_MANAGED_WATCHER"
427 If set to any value, System.IO.FileSystemWatcher will use the default
428 managed implementation (slow). If unset, mono will try to use FAM under
429 Unix systems and native API calls on Windows, falling back to the
430 managed implementation on error.
431 .TP
432 .I "MONO_PATH"
433 Provides a search path to the runtime where to look for library files.
434 Directories are separated by the platform path separator (colons on unix). Example:
435 .B /home/username/lib:/usr/local/mono/lib
436 .TP
437 .I "MONO_RTC"
438 Experimental RTC support in the statistical profiler: if the user has
439 the permission, more accurate statistics are gathered.  The MONO_RTC
440 value must be restricted to what the linux rtc allows: power of two
441 from 64 to 8192 Hz. To enable higher frequencies like 4096 Hz, run as root:
442 .nf
443         echo 4096 > /proc/sys/dev/rtc/max-user-freq
444 .fi
445 .Sp
446 For example:
447 .nf
448         MONO_RTC=4096 mono --profiler=default:stat program.exe
449 .fi
450 .TP
451 .I "MONO_NO_TLS"
452 Disable inlining of thread local accesses. Try setting this if you get a segfault
453 early on in the execution of mono.
454 .TP 
455 .I "MONO_SHARED_DIR"
456 If set its the directory where the ".wapi" handle state is stored.
457 This is the directory where the Windows I/O Emulation layer stores its
458 shared state data (files, events, mutexes, pipes).  By default Mono
459 will store the ".wapi" directory in the users's home directory.
460 .TP
461 .I "MONO_THREADS_PER_CPU"
462 Sets the maximum number of threads in the threadpool per CPU. The default is
463 50 for non-windows systems and 25 for windows.
464 .TP
465 .I "MONO_TRACE"
466 If set, enables the System.Diagnostics.DefaultTraceListener, which will 
467 print the output of the System.Diagnostics Trace and Debug classes.  
468 It can be set to a filename, and to Console.Out or Console.Error to display
469 output to standard output or standard error, respectively.
470 See the System.Diagnostics.DefaultTraceListener documentation for more
471 information.
472 .TP
473 .I "MONO_XMLSERIALIZER_THS"
474 Controls the threshold for the XmlSerializer to produce a custom
475 serializer for a given class instead of using the Reflection-based
476 interpreter.  The possible values are `no' to disable the use of a
477 custom serializer or a number to indicate when the XmlSerializer
478 should start serializing.   The default value is 50, which means that
479 the a custom serializer will be produced on the 50th use.
480 .SH FILES
481 On Unix assemblies are loaded from the installation lib directory.  If you set
482 `prefix' to /usr, the assemblies will be located in /usr/lib.  On
483 Windows, the assemblies are loaded from the directory where mono and
484 mint live.
485 .PP
486 ~/.mono/aot-cache
487 .PP
488 The directory for the ahead-of-time compiler demand creation
489 assemblies are located. 
490 .PP
491 /etc/mono/config, ~/.mono/config
492 .PP
493 Mono runtime configuration file.  See the mono-config(5) manual page
494 for more information.
495 .PP
496 ~/.config/.mono/certs, /usr/share/.mono/certs
497 .PP
498 Contains Mono certificate stores for users / machine. See the certmgr(1) 
499 manual page for more information on managing certificate stores.
500 .PP
501 ~/.config/.mono/keypairs, /usr/share/.mono/keypairs
502 .PP
503 Contains Mono cryptographic keypairs for users / machine. They can be 
504 accessed by using a CspParameters object with DSACryptoServiceProvider
505 and RSACryptoServiceProvider classes.
506 .PP
507 ~/.config/.isolatedstorage, ~/.local/share/.isolatedstorage, /usr/share/.isolatedstorage
508 .PP
509 Contains Mono isolated storage for non-roaming users, roaming users and 
510 local machine. Isolated storage can be accessed using the classes from 
511 the System.IO.IsolatedStorage namespace.
512 .SH MAILING LISTS
513 Visit http://lists.ximian.com/mailman/listinfo/mono-list for details.
514 .SH WEB SITE
515 Visit: http://www.mono-project.com for details
516 .SH SEE ALSO
517 .BR mcs(1), mint(1), monodis(1), mono-config(5), certmgr(1).
518 .PP
519 For ASP.NET-related documentation, see the xsp(1) manual page