37 STAT_REGISTER_GROUP_VAR(
int,globalallocateddumpsize,0,"globalallocateddumpsize","dump memory not freed",not_freed_mem_stat)
63 #if defined(ENABLE_MEMCHECK)
96 assert(
_areas.back() == dma);
131 #if defined(ENABLE_MEMCHECK)
138 for (std::vector<DumpMemoryAllocation*>::iterator it = _allocs.begin(); it != _allocs.end(); it++) {
139 DumpMemoryAllocation* dma = *it;
142 (
void)
os::memset(dma->get_mem(), MEMORY_CLEAR_BYTE, dma->get_size());
150 for (std::vector<DumpMemoryBlock*>::iterator it =
_blocks.begin(); it !=
_blocks.end(); it++) {
172 #if defined(ENABLE_STATISTICS)
187 #if defined(ENABLE_MEMCHECK)
188 void DumpMemoryArea::check_canaries()
194 for (std::vector<DumpMemoryAllocation*>::iterator it = _allocs.begin(); it != _allocs.end(); it++) {
195 DumpMemoryAllocation* dma = *it;
199 pm = ((uint8_t *) dma->get_mem()) - MEMORY_CANARY_SIZE;
201 for (
int i = 0;
i < MEMORY_CANARY_SIZE; ++
i) {
202 if (pm[
i] !=
i + MEMORY_CANARY_FIRST_BYTE) {
203 fprintf(stderr,
"canary bytes:");
205 for (
int j = 0; j < MEMORY_CANARY_SIZE; ++j)
206 fprintf(stderr,
" %02x", pm[j]);
208 fprintf(stderr,
"\n");
210 vm_abort(
"error: dump memory bottom canary killed: "
211 "%p (%d bytes allocated at %p)\n",
212 pm +
i, dma->get_size(), dma->get_mem());
216 pm = ((uint8_t *) dma->get_mem()) + dma->get_size();
218 for (
int i = 0;
i < MEMORY_CANARY_SIZE; ++
i) {
219 if (pm[
i] !=
i + MEMORY_CANARY_FIRST_BYTE) {
220 fprintf(stderr,
"canary bytes:");
222 for (
int j = 0; j < MEMORY_CANARY_SIZE; ++j)
223 fprintf(stderr,
" %02x", pm[j]);
225 fprintf(stderr,
"\n");
227 vm_abort(
"error: dump memory top canary killed: "
228 "%p (%d bytes allocated at %p)\n",
229 pm +
i, dma->get_size(), dma->get_mem());
DumpMemoryArea(size_t size=0)
Allocate a new dump memory area.
static void * memset(void *s, int c, size_t n)
std::vector< DumpMemoryBlock * > _blocks
List of memory blocks in this area.
#define STATISTICS(x)
Wrapper for statistics only code.
void remove_area(DumpMemoryArea *dma)
Remove the given dump area from the area list.
typedef void(JNICALL *jvmtiEventSingleStep)(jvmtiEnv *jvmti_env
DumpMemoryBlock(size_t size=0)
Checks canaries in this dump memory area.
JNIEnv jthread jobject jclass jlong size
void vm_abort(const char *text,...)
~DumpMemoryArea()
Release all dump memory blocks in the current dump area.
size_t _size
Size of the dump areas in this dump memory.
void * memory_checked_alloc(size_t size)
size_t _size
Size of the current memory block.
void mem_free(void *m, int32_t size)
#define STAT_REGISTER_GROUP_VAR(type, var, init, name, description, group)
Register an statistics variable and add it to a group.
static void * reallocate(void *src, size_t len1, size_t len2)
Stupid realloc implementation for dump memory.
void add_size(size_t size)
static void * memcpy(void *dest, const void *src, size_t n)
size_t _used
Used memory in this dump memory.
~DumpMemoryBlock()
Release the memory block for the dump memory block.
void * _block
List of memory blocks in this area.
#define STAT_DECLARE_GROUP(var)
Declare an external group (or subgroup).
static void * allocate(size_t size)
std::list< DumpMemoryArea * > _areas
Pointer to the current dump area.
DumpMemoryBlock * allocate_new_block(size_t size)
Allocate a dump memory block for the current dump memory area.
Thread-local dump memory structure.
static const size_t DEFAULT_SIZE
void add_area(DumpMemoryArea *dma)
Add the given dump area to the area list.
static DumpMemory * get_current()