Skip to content

Commit

Permalink
[browser][wasm] Default Debug Write to StdErr (#37886)
Browse files Browse the repository at this point in the history
* [browser][wasm] Default Debug Write to StdErr

- COMPlus_DebugWriteToStdErr environment variable when set to `1` will write to `stderr` so it show up in the browser console log.

* Address review comment about adding a comment

* Address review comments

Add conditional compile for DEBUG build to only set debug environment variables when /p:Configuration=Debug is specified
  • Loading branch information
kjpou1 committed Jun 17, 2020
1 parent 3222741 commit fa7c99d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MONO_LIBS = \
${SYS_NATIVE_DIR}/libSystem.Native.a

EMCC_FLAGS=--profiling-funcs -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s ALIASING_FUNCTION_POINTERS=0 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'addFunction']" -s "EXPORTED_FUNCTIONS=['_putchar']" --source-map-base http://example.com -s WASM_OBJECT_FILES=0 -s FORCE_FILESYSTEM=1 -s USE_ZLIB=1
EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DENABLE_NETCORE=1
EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DENABLE_NETCORE=1 -DDEBUG=1
EMCC_RELEASE_FLAGS=-Oz --llvm-opts 2 --llvm-lto 1 -DENABLE_NETCORE=1

#
Expand Down
10 changes: 8 additions & 2 deletions src/mono/wasm/runtime/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ mono_wasm_load_runtime (const char *managed_path, int enable_debugging)
{
const char *interp_opts = "";

//monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0);
//monoeg_g_setenv ("MONO_LOG_MASK", "gc", 0);
#ifdef DEBUG
monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0);
monoeg_g_setenv ("MONO_LOG_MASK", "gc", 0);
// Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this
// output will be sent to the console. Right now this is the only way to emit debug logging from
// corlib assemblies.
monoeg_g_setenv ("COMPlus_DebugWriteToStdErr", "1", 0);
#endif
#ifdef ENABLE_NETCORE
monoeg_g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", 0);
#endif
Expand Down

0 comments on commit fa7c99d

Please sign in to comment.