{"record":{"id":"c76d650607995865","repo":"mono/mono","slug":"s-c76d65","errorCode":null,"errorMessage":"%s\n","messagePattern":"%s\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mono/mini/trace.c","lineNumber":59,"sourceCode":"static MonoCallSpec trace_spec;\n\nstatic volatile gint32 output_lock = 0;\n\ngboolean mono_trace_eval_exception (MonoClass *klass)\n{\n\treturn mono_callspec_eval_exception (klass, &trace_spec);\n}\n\ngboolean mono_trace_eval (MonoMethod *method)\n{\n\treturn mono_callspec_eval (method, &trace_spec);\n}\n\nMonoCallSpec *mono_trace_set_options (const char *options)\n{\n\tchar *errstr;\n\tif (!mono_callspec_parse (options, &trace_spec, &errstr)) {\n\t\tfprintf (stderr, \"%s\\n\", errstr);\n\t\tg_free (errstr);\n\t\treturn NULL;\n\t}\n\n\treturn &trace_spec;\n}\n\nstatic\n#ifdef MONO_KEYWORD_THREAD\nMONO_KEYWORD_THREAD\n#endif\nint indent_level = 0;\nstatic guint64 start_time = 0;\n\nstatic double seconds_since_start (void)\n{\n\tguint64 diff = mono_100ns_ticks () - start_time;\n\treturn diff/10000000.0;","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/mini/trace.c#L41-L77","documentation":"mono_trace_set_options() (trace.c:55) parses a call specification string for method tracing via mono_callspec_parse() (callspec.c:312). If parsing fails, it prints the error string returned by the parser and returns NULL — it does NOT call exit(1). The callspec grammar accepts tokens: 'M:' (method descriptor), 'N:' (namespace), 'T:' (class), 'E:' (exception type), bare assembly names, and keywords 'all', 'program', 'wrapper', 'disabled', joined by commas; a leading '-' excludes. Parser error messages include 'Syntax error at or around ...', 'Invalid method name: ...', 'Expecting an expression', and 'Syntax error in method specification'. This variable is typically set via the --trace= command-line option or the MONO_TRACE environment variable.","triggerScenarios":"Passing a malformed callspec to mono --trace (e.g. `mono --trace=M:Foo.Bar(` with unbalanced parens, or `--trace=X:BadPrefix` using an unrecognized prefix); forgetting the 'M:'/'T:'/'N:'/'E:' prefix and supplying a raw method signature that the parser interprets as an assembly name; using characters outside the allowed filename-char set (A-Z, a-z, 0-9, '.', ':', '_', '-', '`').","commonSituations":"Trying to trace a specific method for debugging and getting the callspec syntax wrong; following incomplete documentation about the --trace flag format; passing a C# fully-qualified name without the required prefix token.","solutions":["Prefix method specs with 'M:' and use valid method-descriptor syntax, e.g. `--trace=M:MyNamespace.MyClass.MyMethod`.","Use 'T:Namespace.ClassName' to trace all methods of a class, 'N:Namespace' for a namespace, or 'all' to trace everything.","Separate multiple specs with commas and prefix a spec with '-' to exclude it, e.g. `--trace=all,-M:System.*`."],"exampleFix":"# before\nmono --trace=\"MyClass.MyMethod\" app.exe\n\n# after\nmono --trace=\"M:MyNamespace.MyClass.MyMethod\" app.exe","handlingStrategy":"validation","validationCode":"# Validate the callspec format before passing to --trace\n# Valid prefixes: M: T: N: E: ; keywords: all program wrapper disabled ; '-' to exclude\nvalidate_callspec() {\n  local spec=\"$1\"\n  IFS=',' read -ra parts <<< \"$spec\"\n  for part in \"${parts[@]}\"; do\n    local stripped=${part#+}  # remove leading +\n    stripped=${stripped#-}    # remove leading -\n    case \"$stripped\" in\n      M:*|T:*|N:*|E:*) continue ;;\n      all|program|wrapper|disabled) continue ;;\n      *) echo \"Invalid callspec token: '$part'\" >&2; return 1 ;;\n    esac\n  done\n}\nvalidate_callspec \"$TRACE_SPEC\" && mono --trace=\"$TRACE_SPEC\" app.exe","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always prefix method/class/namespace/exception specs with M:/T:/N:/E: respectively — bare names are interpreted as assembly names, not method patterns.","Test callspecs in a throwaway process before embedding them in scripts or CI, since mono_trace_set_options returns NULL on failure rather than crashing.","Remember that method descriptors (after M:) must be parseable by mono_method_desc_new — use the fully qualified 'Namespace.Class.Method(args)' form for precision."],"tags":["mono","tracing","env-var","configuration","callspec"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}