Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MonoVM] Improve thread state debugging and make it usable on Android #108401

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ JS_ENGINES = [NODE_JS]
<_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="-DANDROID_ABI=armeabi-v7a" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DANDROID_ABI=x86" />
<_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DANDROID_ABI=x86_64" />
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,logging" />
<_MonoCMakeArgs Condition="'$(Configuration)' != 'Debug'" Include="-DENABLE_MINIMAL=ssa,logging" />
<_MonoCMakeArgs Condition="'$(Configuration)' == 'Debug'" Include="-DENABLE_MINIMAL=ssa" />

<_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-march=armv7-a" />
<_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-mtune=cortex-a8" />
Expand Down
9 changes: 9 additions & 0 deletions src/mono/mono/utils/mono-threads-debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@

#include <config.h>
#include <glib.h>
#if defined (HOST_ANDROID)
#include <android/log.h>
#endif

/* Logging - enable them below if you need specific logging for the category you need */
#define MOSTLY_ASYNC_SAFE_FPRINTF(handle, ...) do { \
g_async_safe_fprintf (handle, __VA_ARGS__); \
} while (0)

#if defined (HOST_ANDROID)
#define MOSTLY_ASYNC_SAFE_PRINTF(...) do { \
__android_log_print (ANDROID_LOG_ERROR, "THREAD", __VA_ARGS__); \
} while (0)
#else
#define MOSTLY_ASYNC_SAFE_PRINTF(...) MOSTLY_ASYNC_SAFE_FPRINTF(1, __VA_ARGS__);
#endif

#if 1
#define THREADS_DEBUG(...)
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/utils/mono-threads-state-machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,15 +737,15 @@ mono_threads_transition_do_blocking (MonoThreadInfo* info, const char *func)
mono_fatal_with_history ("no_safepoints = TRUE, but should be FALSE in state RUNNING with DO_BLOCKING");
if (thread_state_cas (&info->thread_state, build_thread_state (STATE_BLOCKING, suspend_count, no_safepoints), raw_state) != raw_state)
goto retry_state_change;
trace_state_change ("DO_BLOCKING", info, raw_state, STATE_BLOCKING, no_safepoints, 0);
trace_state_change_with_func ("DO_BLOCKING", info, raw_state, STATE_BLOCKING, no_safepoints, 0, func);
return DoBlockingContinue;

case STATE_ASYNC_SUSPEND_REQUESTED:
if (!(suspend_count > 0))
mono_fatal_with_history ("suspend_count = %d, but should be > 0", suspend_count);
if (no_safepoints)
mono_fatal_with_history ("no_safepoints = TRUE, but should be FALSE in state ASYNC_SUSPEND_REQUESTED with DO_BLOCKING");
trace_state_change ("DO_BLOCKING", info, raw_state, cur_state, no_safepoints, 0);
trace_state_change_with_func ("DO_BLOCKING", info, raw_state, cur_state, no_safepoints, 0, func);
return DoBlockingPollAndRetry;
/*
STATE_ASYNC_SUSPENDED
Expand Down
Loading