Native: make debug interface handle uninitialized threads
Generally, debug interface is not called from uninitialized threads, but let's be on the safe side here.
This commit is contained in:
committed by
Space
parent
41b531db7c
commit
3f6b386681
@@ -112,7 +112,9 @@ int Konan_DebugBufferSizeWithObjectImpl(KRef obj) {
|
|||||||
int32_t Konan_DebugObjectToUtf8ArrayImpl(KRef obj, char* buffer, int32_t bufferSize) {
|
int32_t Konan_DebugObjectToUtf8ArrayImpl(KRef obj, char* buffer, int32_t bufferSize) {
|
||||||
// We need the runnable thread state to call the Kotlin function 'KonanObjectToUtf8Array' and operate with it's result.
|
// We need the runnable thread state to call the Kotlin function 'KonanObjectToUtf8Array' and operate with it's result.
|
||||||
// But the current thread can be in any state when this function is called by the debugger. So we use the reentrant state switch.
|
// But the current thread can be in any state when this function is called by the debugger. So we use the reentrant state switch.
|
||||||
kotlin::ThreadStateGuard guard(kotlin::ThreadState::kRunnable, /* reentrant */ true);
|
// Finally, let's be on the safe side and assume that current thread might be uninitialized,
|
||||||
|
// so use CalledFromNativeGuard instead of ThreadStateGuard.
|
||||||
|
kotlin::CalledFromNativeGuard guard(/* reentrant */ true);
|
||||||
ObjHolder stringHolder;
|
ObjHolder stringHolder;
|
||||||
// Kotlin call.
|
// Kotlin call.
|
||||||
ArrayHeader* data = KonanObjectToUtf8Array(obj, stringHolder.slot())->array();
|
ArrayHeader* data = KonanObjectToUtf8Array(obj, stringHolder.slot())->array();
|
||||||
|
|||||||
Reference in New Issue
Block a user