From e751ea1b0da3db914e466405009eff0bc317e698 Mon Sep 17 00:00:00 2001 From: Andrei Pangin Date: Tue, 6 Feb 2024 02:37:28 +0000 Subject: [PATCH] #886: Support cstack=vm for slowdebug JVM --- src/vmStructs.cpp | 7 ++++++- src/vmStructs.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vmStructs.cpp b/src/vmStructs.cpp index 7da31eeb..55e36098 100644 --- a/src/vmStructs.cpp +++ b/src/vmStructs.cpp @@ -61,6 +61,7 @@ int VMStructs::_constmethod_constants_offset = -1; int VMStructs::_constmethod_idnum_offset = -1; int VMStructs::_constmethod_size = -1; int VMStructs::_pool_holder_offset = -1; +int VMStructs::_array_len_offset = 0; int VMStructs::_array_data_offset = -1; int VMStructs::_code_heap_memory_offset = -1; int VMStructs::_code_heap_segmap_offset = -1; @@ -321,6 +322,10 @@ void VMStructs::initOffsets() { if (strcmp(field, "_call_stub_return_address") == 0) { _call_stub_return_addr = *(const void***)(entry + address_offset); } + } else if (strcmp(type, "GrowableArrayBase") == 0 || strcmp(type, "GenericGrowableArray") == 0) { + if (strcmp(field, "_len") == 0) { + _array_len_offset = *(int*)(entry + offset_offset); + } } else if (strcmp(type, "GrowableArray") == 0) { if (strcmp(field, "_data") == 0) { _array_data_offset = *(int*)(entry + offset_offset); @@ -458,7 +463,7 @@ void VMStructs::resolveOffsets() { if (_code_heap_addr != NULL && _code_heap_low_addr != NULL && _code_heap_high_addr != NULL) { char* code_heaps = *_code_heap_addr; - unsigned int code_heap_count = *(unsigned int*)code_heaps; + unsigned int code_heap_count = *(unsigned int*)(code_heaps + _array_len_offset); if (code_heap_count <= 3 && _array_data_offset >= 0) { char* code_heap_array = *(char**)(code_heaps + _array_data_offset); memcpy(_code_heap, code_heap_array, code_heap_count * sizeof(_code_heap[0])); diff --git a/src/vmStructs.h b/src/vmStructs.h index c051283b..38131780 100644 --- a/src/vmStructs.h +++ b/src/vmStructs.h @@ -66,6 +66,7 @@ class VMStructs { static int _constmethod_idnum_offset; static int _constmethod_size; static int _pool_holder_offset; + static int _array_len_offset; static int _array_data_offset; static int _code_heap_memory_offset; static int _code_heap_segmap_offset;