diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-16 22:00:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 22:00:36 +0100 |
commit | c3ea4ea9b76d1bacde83f7b70af4638cf2ff41a2 (patch) | |
tree | 65cb654ac536181896a202f99cd4bb148399c2c2 | |
parent | 3aa46a58cd3ae5f327929d127ac5fef0733176c9 (diff) | |
parent | 7c64779516441ad5b6fe20084d10e895fefa0f01 (diff) |
Merge pull request #34382 from van800/profiler
Allow attaching any external profiler, including JetBrains dotTrace
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 69634eccf4..29274be559 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -102,6 +102,18 @@ void gd_mono_profiler_init() { bool profiler_enabled = GLOBAL_DEF("mono/profiler/enabled", false); if (profiler_enabled) { mono_profiler_load(profiler_args.utf8()); + return; + } + + const String env_var_name = "MONO_ENV_OPTIONS"; + if (OS::get_singleton()->has_environment(env_var_name)) { + const auto mono_env_ops = OS::get_singleton()->get_environment(env_var_name); + // Usually MONO_ENV_OPTIONS looks like: --profile=jb:prof=timeline,ctl=remote,host=127.0.0.1:55467 + const String prefix = "--profile="; + if (mono_env_ops.begins_with(prefix)) { + const auto ops = mono_env_ops.substr(prefix.length(), mono_env_ops.length()); + mono_profiler_load(ops.utf8()); + } } } |