diff --git a/runtime/src/debug/cpp/KDebug.cpp b/runtime/src/debug/cpp/KDebug.cpp index a9b669f377b..b6f47cf1460 100644 --- a/runtime/src/debug/cpp/KDebug.cpp +++ b/runtime/src/debug/cpp/KDebug.cpp @@ -19,6 +19,7 @@ #include #include "KAssert.h" +#include "KString.h" #include "Memory.h" #include "Natives.h" #include "Porting.h" @@ -176,6 +177,17 @@ RUNTIME_USED const char* Konan_DebugGetFieldName(KRef obj, int index) { return extendedTypeInfo->fieldNames_[index]; } +RUNTIME_USED const char* Konan_DebugGetTypeName(KRef obj) { + if (obj == nullptr) + return nullptr; + + auto type_info = obj->type_info(); + if (type_info == nullptr) + return ""; + + return CreateCStringFromString(type_info->relativeName_); +} + } // extern "C" #endif // !KONAN_NO_DEBUG_API diff --git a/runtime/src/main/cpp/KDebug.h b/runtime/src/main/cpp/KDebug.h index ba60740662b..30a80025208 100644 --- a/runtime/src/main/cpp/KDebug.h +++ b/runtime/src/main/cpp/KDebug.h @@ -60,6 +60,9 @@ RUNTIME_USED void* Konan_DebugGetFieldAddress(KRef obj, int index); // Compute address of field or an array element at the index, or null, if incorrect. RUNTIME_USED const char* Konan_DebugGetFieldName(KRef obj, int index); +// Returns name of type. +RUNTIME_USED const char* Konan_DebugGetTypeName(KRef obj); + #ifdef __cplusplus } #endif