2005-02-03 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / man / mono.1
1 .\" 
2 .\" mono manual page.
3 .\" (C) 2003 Ximian, Inc. 
4 .\" Author:
5 .\"   Miguel de Icaza (miguel@gnu.org)
6 .\"
7 .de Sp \" Vertical space (when we can't use .PP)
8 .if t .sp .5v
9 .if n .sp
10 ..
11 .TH Mono "Mono 1.0"
12 .SH NAME
13 mono \- Mono's ECMA-CLI native code generator (Just-in-Time and Ahead-of-Time)
14 .SH SYNOPSIS
15 .PP
16 .B mono [options] file [arguments...]
17 .SH DESCRIPTION
18 \fImono\fP is a runtime implementation of the ECMA Common Language
19 Infrastructure.  This can be used to run ECMA and .NET applications.
20 .PP
21 The runtime contains a native code generator that transforms the
22 Common Intermediate Language into native code.
23 .PP
24 The code generator can operate in two modes: just in time compilation
25 (JIT) or ahead of time compilation (AOT).  Since code can be
26 dynamically loaded, the runtime environment and the JIT are always
27 present, even if code is compiled ahead of time.
28 .PP
29 The runtime loads ths specified
30 .I file
31 and optionally passes
32 the
33 .I arguments
34 to it.  The 
35 .I file
36 is an ECMA assembly.  They typically have a .exe or .dll extension.
37 .PP
38 The runtime provides a number of configuration options for running
39 applications, for developping and debugging, and for testing and
40 debugging the runtime itself.
41 .SH RUNTIME OPTIONS
42 The following options are available:
43 .TP
44 .I "--aot"
45 This option is used to precompile the CIL code in the specified
46 assembly to native code.  The generated code is stored in a file with
47 the extension .so.  This file will be automatically picked up by the
48 runtime when the assembly is executed.  
49 .Sp 
50 Ahead-of-Time compilation is most useful if you use it in combination
51 with the -O=all,-shared flag which enables all of the optimizations in
52 the code generator to be performed.  Some of those optimizations are
53 not practical for Just-in-Time compilation since they might be very
54 time consuming.
55 .Sp
56 Unlike the .NET Framework, Ahead-of-Time compilation will not generate
57 domain independent code: it generates the same code that the
58 Just-in-Time compiler would produce.   Since most applications use a
59 single domain, this is fine.   If you want to optimize the generated
60 code for use in multi-domain applications, consider using the
61 -O=shared flag.
62 .Sp
63 This pre-compiles the methods, but the original assembly is still
64 required to execute as this one contains the metadata and exception
65 information which is not availble on the generated file.  When
66 precompiling code, you might want to compile with all optimizations
67 (-O=all).  Pre-compiled code is position independent code.
68 .Sp
69 Pre compilation is just a mechanism to reduce startup time, and avoid
70 just-in-time compilation costs.  The original assembly must still be
71 present, as the metadata is contained there.
72 .TP
73 .I "--config filename"
74 Load the specified configuration file instead of the default one(s).
75 The default files are /etc/mono/config and ~/.mono/config or the file
76 specified in the MONO_CONFIG environment variable, if set.  See the
77 mono-config(5) man page for details on the format of this file.
78 .TP
79 .I "--help", "-h"
80 Displays usage instructions.
81 .TP
82 .I "--optimize=MODE", "-O=mode"
83 MODE is a comma separated list of optimizations.  They also allow
84 optimizations to be turned off by prefixing the optimization name with
85 a minus sign.
86 .Sp
87 The following optimizations are implemented:
88 .nf
89              all        Turn on all optimizations
90              peephole   Peephole postpass
91              branch     Branch optimizations
92              inline     Inline method calls
93              cfold      Constant folding
94              consprop   Constant propagation
95              copyprop   Copy propagation
96              deadce     Dead code elimination
97              linears    Linear scan global reg allocation
98              cmov       Conditional moves
99              shared     Emit per-domain code
100              sched      Instruction scheduling
101              intrins    Intrinsic method implementations
102              tailc      Tail recursion and tail calls
103              loop       Loop related optimizations
104              fcmov      Fast x86 FP compares
105              leaf       Leaf procedures optimizations
106              aot        Usage of Ahead Of Time compiled code
107              precomp    Precompile all methods before executing Main
108              abcrem     Array bound checks removal
109              ssapre     SSA based Partial Redundancy Elimination
110 .fi
111 .Sp
112 For example, to enable all the optimization but dead code
113 elimination and inlining, you can use:
114 .nf
115         -O=all,-deadce,-inline
116 .fi
117 .TP
118 .I "--security"
119 Activate the security manager (experimental feature in 1.1). This allows 
120 mono to support declarative security attributes (e.g. execution of, CAS 
121 or non-CAS, security demands). The security manager is OFF by default 
122 (experimental).
123 .TP
124 .I "-V", "--version"
125 Prints JIT version information.
126
127
128 .SH DEVELOPMENT OPTIONS
129 The following options are used to help when developing a JITed application.
130 .TP
131 .I "--debug"
132 Turns on the debugging mode in the runtime.  If an assembly was
133 compiled with debugging information, it will produce line number
134 information for stack traces. 
135 .TP
136 .I "--profile[=profiler[:profiler_args]]"
137 Instructs the runtime to collect profiling information about execution
138 times and memory allocation, and dump it at the end of the execution.
139 If a profiler is not specified, the default profiler is used.
140 .Sp
141 Mono has a built-in profiler called `default' (and is also the default
142 if no arguments are specified), but developers can write custom
143 profilers as shared libraries.  The shared library must be called
144 `mono-profiler-NAME.so' where `NAME' is the name of your profiler.
145 .Sp
146 For a sample of the custom profilers look in the Mono source tree for
147 in the samples/profiler.c.
148 .Sp
149 The 
150 .I profiler_args 
151 is a profiler-specific string of options for the profiler itself.
152 .Sp
153 The default profiler is called `default' and it accepts `alloc' to
154 profile memory consumption by the application; `time' to profile the
155 time spent on each routine and `stat' to perform sample statistical
156 profiling.  If no options are provided the default is `alloc,time'.
157 .Sp
158 For example:
159 .nf
160         mono --profile program.exe
161 .fi
162 .Sp
163 That will run the program with the default profiler and will do time
164 and allocation profiling.
165 .Sp
166 .nf
167         mono --profile=default:stat,alloc program.exe
168 .fi
169 Will do  sample statistical profiling and allocation profiling on
170 program.exe.
171 .TP
172 .nf
173         mono --profile=custom program.exe
174 .fi
175 .Sp
176 In the above sample Mono will load the user defined profiler from the
177 shared library `mono-profiler-custom.so'.
178 .SH JIT MAINTAINER OPTIONS
179 The maintainer options are only used by those developing the runtime
180 itself, and not typically of interest to runtime users or developers.
181 .TP
182 .I "--compile name"
183 This compiles a method (namespace.name:methodname), this is used for
184 testing the compiler performance or to examine the output of the code
185 generator. 
186 .TP
187 .I "--compileall"
188 Compiles all the methods in an assembly.  This is used to test the
189 compiler performance or to examine the output of the code generator
190 .TP 
191 .I "--graph=TYPE METHOD"
192 This generates a postscript file with a graph with the details about
193 the specified method (namespace.name:methodname).  This requires `dot'
194 and ghostview to be installed (it expects Ghostview to be called
195 "gv"). 
196 .Sp
197 The following graphs are available:
198 .nf
199           cfg        Control Flow Graph (CFG)
200           dtree      Dominator Tree
201           code       CFG showing code
202           ssa        CFG showing code after SSA translation
203           optcode    CFG showing code after IR optimizations
204 .fi
205 .Sp
206 Some graphs will only be available if certain optimizations are turned
207 on.
208 .TP
209 .I "--ncompile"
210 Instruct the runtime on the number of times that the method specified
211 by --compile (or all the methods if --compileall is used) to be
212 compiled.  This is used for testing the code generator performance. 
213 .TP
214 .I "-v", "--verbose"
215 Increases the verbosity level, each time it is listed, increases the
216 verbosity level to include more information (including, for example, 
217 a disassembly of the native code produced, code selector info etc.).
218 .TP
219 .I "--break method"
220 Inserts a breakpoint before the method whose name is `method'
221 (namespace.class:methodname).  Use `Main' as method name to insert a
222 breakpoint on the application's main method.
223 .TP
224 .I "--breakonex"
225 Inserts a breakpoint on exceptions.  This allows you to debug your
226 application with a native debugger when an exception is thrown.
227 .TP
228 .I "--trace[=expression]"
229 Shows method names as they are invoked.  By default all methods are
230 traced. 
231 .Sp
232 The trace can be customized to include or exclude methods, classes or
233 assemblies.  A trace expression is a comma separated list of targets,
234 each target can be prefixed with a minus sign to turn off a particular
235 target.  The words `program' and `all' have special meaning.
236 `program' refers to the main program being executed, and `all' means
237 all the method calls. 
238 .Sp
239 Assemblies are specified by their name, for example, to trace all
240 calls in the System assembly, use:
241 .nf
242
243         mono --trace=System app.exe
244
245 .fi
246 Classes are specified with the T: prefix.  For example, to trace all
247 calls to the System.String class, use:
248 .nf
249
250         mono --trace=T:System.String app.exe
251
252 .fi
253 And individual methods are referenced with the M: prefix, and the
254 standar method notation:
255 .nf
256
257         mono --trace=M:System.Console:WriteLine app.exe
258
259 .fi
260 As previously noted, various rules can be specified at once:
261 .nf
262
263         mono --trace=T:System.String,T:System.Random app.exe
264
265 .fi
266 You can exclude pieces, the next example traces calls to
267 System.String except for the System.String:Concat method.
268 .nf
269
270         mono --trace=T:System.String,-M:System.String:Concat
271
272 .fi
273 Finally, namespaces can be specified using the N: prefix:
274 .nf
275
276         mono --trace=N:System.Xml
277
278 .fi
279 .SH DEBUGGING
280 .PP
281 You can use the MONO_LOG_LEVEL and MONO_LOG_MASK environment variables
282 to get verbose debugging output about the execution of your
283 application within Mono.
284 .PP
285 The 
286 .I MONO_LOG_LEVEL
287 environment variable if set, the logging level is changed to the set
288 value. Possible values are "error", "critical", "warning", "message",
289 "info", "debug". The default value is "error". Messages with a logging
290 level greater then or equal to the log level will be printed to
291 stdout/stderr.
292 .PP
293 Use "info" to track the dynamic loading of assemblies.
294 .PP
295 .PP
296 Use the 
297 .I MONO_LOG_MASK
298 environment variable to limit the extent of the messages you get: 
299 If set, the log mask is changed to the set value. Possible values are
300 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
301 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
302 The default value is "all". Changing the mask value allows you to display only 
303 messages for a certain component. You can use multiple masks by comma 
304 separating them. For example to see config file messages and assembly loader
305 messages set you mask to "asm,cfg".
306 .PP
307 The following is a common use to track down problems with P/Invoke:
308 .nf
309         $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
310 .fi
311 .PP
312 .SH SERIALIZATION
313 Mono's XML serialization engine by default will use a reflection-based
314 approach to serialize which might be slow for continous processing
315 (web service applications).  The serialization engine will determine
316 when a class must use a hand-tuned serializer based on a few
317 parameters and if needed it will produce a customized C# serializer
318 for your types at runtime.  This customized serializer then gets
319 dynamically loaded into your application.
320 .PP
321 You can control this with the MONO_XMLSERIALIZER_THS environment
322 variable.
323 .PP
324 The possible values are 
325 .B `no' 
326 to disable the use of a C# customized
327 serializer, or an integer that is the minimum number of uses before
328 the runtime will produce a custom serializer (0 will produce a
329 custom serializer on the first access, 50 will produce a serializer on
330 the 50th use).
331 .SH ENVIRONMENT VARIABLES
332 .TP
333 .I "GC_DONT_GC"
334 Turns off the garbage collection in Mono.  This should be only used
335 for debugging purposes
336 .TP
337 .I "MONO_AOT_CACHE"
338 If set, this variable will instruct Mono to ahead-of-time compile new
339 assemblies on demand and store the result into a cache in
340 ~/.mono/aot-cache. 
341 .TP
342 .I "MONO_ASPNET_NODELETE"
343 If set to any value, temporary source files generated by ASP.NET support
344 classes will not be removed. They will be kept in the user's temporary
345 directory.
346 .TP
347 .I "MONO_CFG_DIR"
348 If set, this variable overrides the default system configuration directory
349 ($PREFIX/etc). It's used to locate machine.config file.
350 .TP
351 .I "MONO_CONFIG"
352 If set, this variable overrides the default runtime configuration file
353 ($PREFIX/etc/mono/config). The --config command line options overrides the
354 environment variable.
355 .TP
356 .I "MONO_DEBUG"
357 If set, enables some features of the runtime useful for debugging.
358 It makes the runtime display the stack traces for all the threads
359 running and exit when mono is interrupted (Ctrl-C) and print some
360 additional messages on error conditions. It may not exit cleanly. Use at
361 your own risk.
362 .TP
363 .I "MONO_DISABLE_AIO"
364 If set, tells mono NOT to attempt using native asynchronous I/O services. In
365 that case, the threadpool is used for asynchronous I/O on files and sockets.
366 .TP
367 .I "MONO_DISABLE_SHM"
368 If this variable is set, it disables the shared memory part of the
369 Windows I/O Emulation layer, and handles (files, events, mutexes,
370 pipes) will not be shared across processes.  Process creation is also
371 disabled.  This option is only available on Unix.
372 .TP
373 .I "MONO_EGD_SOCKET"
374 For platforms that do not otherwise have a way of obtaining random bytes
375 this can be set to the name of a file system socket on which an egd or
376 prngd daemon is listening.
377 .TP
378 .I "MONO_EXTERNAL_ENCODINGS"
379 If set, contains a colon-separated list of text encodings to try when
380 turning externally-generated text (e.g. command-line arguments or
381 filenames) into Unicode.  The encoding names come from the list
382 provided by iconv, and the special case "default_locale" which refers
383 to the current locale's default encoding.
384 .IP
385 When reading externally-generated text strings UTF-8 is tried first,
386 and then this list is tried in order with the first successful
387 conversion ending the search.  When writing external text (e.g. new
388 filenames or arguments to new processes) the first item in this list
389 is used, or UTF-8 if the environment variable is not set.
390 .TP
391 .I "MONO_GAC_PREFIX"
392 Provides a prefix the runtime uses to look for Global Assembly Caches.
393 Directories are separated by the platform path separator (colons on
394 unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
395 install. Or to the directory provided in the gacutil /gacdir command. Example:
396 .B /home/username/.mono:/usr/local/mono/
397 .TP
398 .I "MONO_LOG_LEVEL"
399 The logging level, possible values are `error', `critical', `warning',
400 `message', `info' and `debug'.  See the DEBUGGING section for more
401 details.
402 .TP
403 .I "MONO_LOG_MASK"
404 Controls the domain of the Mono runtime that logging will apply to. 
405 If set, the log mask is changed to the set value. Possible values are
406 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
407 (garbage collector), "cfg" (config file loader), "aot" (precompiler) and "all". 
408 The default value is "all". Changing the mask value allows you to display only 
409 messages for a certain component. You can use multiple masks by comma 
410 separating them. For example to see config file messages and assembly loader
411 messages set you mask to "asm,cfg".
412 .TP
413 .I "MONO_MANAGED_WATCHER"
414 If set to any value, System.IO.FileSystemWatcher will use the default
415 managed implementation (slow). If unset, mono will try to use FAM under
416 Unix systems and native API calls on Windows, falling back to the
417 managed implementation on error.
418 .TP
419 .I "MONO_PATH"
420 Provides a search path to the runtime where to look for library files.
421 Directories are separated by the platform path separator (colons on unix). Example:
422 .B /home/username/lib:/usr/local/mono/lib
423 .TP
424 .I "MONO_RTC"
425 Experimental RTC support in the statistical profiler: if the user has
426 the permission, more accurate statistics are gathered.  The MONO_RTC
427 value must be restricted to what the linux rtc allows: power of two
428 from 64 to 8192 Hz.
429 .Sp
430 For example:
431 .nf
432         MONO_RTC=4096 mono --profiler=default:stat program.exe
433 .fi
434 .TP 
435 .I "MONO_SHARED_DIR"
436 If set its the directory where the ".wapi" handle state is stored.
437 This is the directory where the Windows I/O Emulation layer stores its
438 shared state data (files, events, mutexes, pipes).  By default Mono
439 will store the ".wapi" directory in the users's home directory.
440 .TP
441 .I "MONO_THREADS_PER_CPU"
442 Sets the maximum number of threads in the threadpool per CPU. The default is
443 50 for non-windows systems and 25 for windows.
444 .TP
445 .I "MONO_TRACE"
446 If set, enables the System.Diagnostics.DefaultTraceListener, which will 
447 print the output of the System.Diagnostics Trace and Debug classes.  
448 It can be set to a filename, and to Console.Out or Console.Error to display
449 output to standard output or standard error, respectively.
450 See the System.Diagnostics.DefaultTraceListener documentation for more
451 information.
452 .TP
453 .I "MONO_XMLSERIALIZER_THS"
454 Controls the threshold for the XmlSerializer to produce a custom
455 serializer for a given class instead of using the Reflection-based
456 interpreter.  The possible values are `no' to disable the use of a
457 custom serializer or a number to indicate when the XmlSerializer
458 should start serializing.   The default value is 50, which means that
459 the a custom serializer will be produced on the 50th use.
460 .SH FILES
461 On Unix assemblies are loaded from the installation lib directory.  If you set
462 `prefix' to /usr, the assemblies will be located in /usr/lib.  On
463 Windows, the assemblies are loaded from the directory where mono and
464 mint live.
465 .PP
466 ~/.mono/aot-cache
467 .PP
468 The directory for the ahead-of-time compiler demand creation
469 assemblies are located. 
470 .PP
471 /etc/mono/config, ~/.mono/config
472 .PP
473 Mono runtime configuration file.  See the mono-config(5) manual page
474 for more information.
475 .PP
476 ~/.config/.mono/certs, /usr/share/.mono/certs
477 .PP
478 Contains Mono certificate stores for users / machine. See the certmgr(1) 
479 manual page for more information on managing certificate stores.
480 .PP
481 ~/.config/.mono/keypairs, /usr/share/.mono/keypairs
482 .PP
483 Contains Mono cryptographic keypairs for users / machine. They can be 
484 accessed by using a CspParameters object with DSACryptoServiceProvider
485 and RSACryptoServiceProvider classes.
486 .PP
487 ~/.config/.isolatedstorage, ~/.local/share/.isolatedstorage, /usr/share/.isolatedstorage
488 .PP
489 Contains Mono isolated storage for non-roaming users, roaming users and 
490 local machine. Isolated storage can be accessed using the classes from 
491 the System.IO.IsolatedStorage namespace.
492 .SH MAILING LISTS
493 Visit http://lists.ximian.com/mailman/listinfo/mono-list for details.
494 .SH WEB SITE
495 Visit: http://www.mono-project.com for details
496 .SH SEE ALSO
497 .BR mcs(1), mint(1), monodis(1), mono-config(5), certmgr(1).
498 .PP
499 For ASP.NET-related documentation, see the xsp(1) manual page