Home | History | Annotate | Download | only in memcheck

Lines Matching refs:MC_

66 SizeT MC_(Malloc_Redzone_SzB) = -10000000; // If used before set, should BOMB
69 VgHashTable MC_(malloc_list) = NULL;
73 VgHashTable MC_(mempool_list) = NULL;
76 PoolAlloc *MC_(chunk_poolalloc) = NULL;
88 The blocks with a size >= MC_(clo_freelist_big_blocks)
102 const int l = (mc->szB >= MC_(clo_freelist_big_blocks) ? 0 : 1);
113 if (mc->szB >= MC_(clo_freelist_vol)) {
132 On entry, VG_(free_queue_volume) must be > MC_(clo_freelist_vol).
133 On exit, VG_(free_queue_volume) will be <= MC_(clo_freelist_vol). */
138 tl_assert (VG_(free_queue_volume) > MC_(clo_freelist_vol));
142 while (VG_(free_queue_volume) > MC_(clo_freelist_vol)
171 MC_Chunk* MC_(get_freed_block_bracketting) (Addr a)
179 MC_(Malloc_Redzone_SzB) ))
193 MC_Chunk* mc = VG_(allocEltPA)(MC_(chunk_poolalloc));
197 switch ( MC_(n_where_pointers)() ) {
203 MC_(set_allocated_at) (tid, mc);
207 if (VG_(free_queue_volume) > MC_(clo_freelist_vol))
214 if (!MC_(check_mem_is_noaccess)( (Addr)mc, sizeof(MC_Chunk), NULL )) {
223 VG_(freeEltPA) (MC_(chunk_poolalloc), mc);
238 twice in MC_(malloc_list) is a recipe for bugs.
255 VG_(HT_ResetIter)(MC_(mempool_list));
256 while ( (mp = VG_(HT_Next)(MC_(mempool_list))) ) {
262 as such a block can be inserted in MC_(malloc_list)
264 return in_block_list ( MC_(malloc_list), mc );
267 ExeContext* MC_(allocated_at) (MC_Chunk* mc)
269 switch (MC_(clo_keep_stacktraces)) {
280 ExeContext* MC_(freed_at) (MC_Chunk* mc)
282 switch (MC_(clo_keep_stacktraces)) {
295 void MC_(set_allocated_at) (ThreadId tid, MC_Chunk* mc)
297 switch (MC_(clo_keep_stacktraces)) {
308 void MC_(set_freed_at) (ThreadId tid, MC_Chunk* mc)
311 switch (MC_(clo_keep_stacktraces)) {
322 UInt MC_(n_where_pointers) (void)
324 switch (MC_(clo_keep_stacktraces)) {
366 void* MC_(new_block) ( ThreadId tid,
384 if (MC_(clo_malloc_fill) != -1) {
385 tl_assert(MC_(clo_malloc_fill) >= 0x00 && MC_(clo_malloc_fill) <= 0xFF);
386 VG_(memset)((void*)p, MC_(clo_malloc_fill), szB);
397 MC_(make_mem_defined)( p, szB );
399 UInt ecu = VG_(get_ECU_from_ExeContext)(MC_(allocated_at)(mc));
401 MC_(make_mem_undefined_w_otag)( p, szB, ecu | MC_OKIND_HEAP );
407 void* MC_(malloc) ( ThreadId tid, SizeT n )
412 return MC_(new_block) ( tid, 0, n, VG_(clo_alignment),
413 /*is_zeroed*/False, MC_AllocMalloc, MC_(malloc_list));
417 void* MC_(__builtin_new) ( ThreadId tid, SizeT n )
422 return MC_(new_block) ( tid, 0, n, VG_(clo_alignment),
423 /*is_zeroed*/False, MC_AllocNew, MC_(malloc_list));
427 void* MC_(__builtin_vec_new) ( ThreadId tid, SizeT n )
432 return MC_(new_block) ( tid, 0, n, VG_(clo_alignment),
433 /*is_zeroed*/False, MC_AllocNewVec, MC_(malloc_list));
437 void* MC_(memalign) ( ThreadId tid, SizeT alignB, SizeT n )
442 return MC_(new_block) ( tid, 0, n, alignB,
443 /*is_zeroed*/False, MC_AllocMalloc, MC_(malloc_list));
447 void* MC_(calloc) ( ThreadId tid, SizeT nmemb, SizeT size1 )
452 return MC_(new_block) ( tid, 0, nmemb*size1, VG_(clo_alignment),
453 /*is_zeroed*/True, MC_AllocMalloc, MC_(malloc_list));
462 if (MC_(clo_free_fill) != -1 && MC_AllocCustom != mc->allockind ) {
463 tl_assert(MC_(clo_free_fill) >= 0x00 && MC_(clo_free_fill) <= 0xFF);
464 VG_(memset)((void*)mc->data, MC_(clo_free_fill), mc->szB);
469 MC_(make_mem_noaccess)( mc->data-rzB, mc->szB + 2*rzB );
472 MC_(set_freed_at) (tid, mc);
475 /* If the free list volume is bigger than MC_(clo_freelist_vol),
485 /* MC_(record_freemismatch_error) reports errors for still
491 VG_(HT_add_node)( MC_(malloc_list), mc );
492 MC_(record_freemismatch_error) ( tid, mc );
493 if ((mc != VG_(HT_remove) ( MC_(malloc_list), (UWord)mc->data )))
497 void MC_(handle_free) ( ThreadId tid, Addr p, UInt rzB, MC_AllocKind kind )
503 mc = VG_(HT_remove) ( MC_(malloc_list), (UWord)p );
505 MC_(record_free_error) ( tid, p );
516 void MC_(free) ( ThreadId tid, void* p )
518 MC_(handle_free)(
519 tid, (Addr)p, MC_(Malloc_Redzone_SzB), MC_AllocMalloc );
522 void MC_(__builtin_delete) ( ThreadId tid, void* p )
524 MC_(handle_free)(
525 tid, (Addr)p, MC_(Malloc_Redzone_SzB), MC_AllocNew);
528 void MC_(__builtin_vec_delete) ( ThreadId tid, void* p )
530 MC_(handle_free)(
531 tid, (Addr)p, MC_(Malloc_Redzone_SzB), MC_AllocNewVec);
534 void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_szB )
549 old_mc = VG_(HT_remove) ( MC_(malloc_list), (UWord)p_old );
551 MC_(record_free_error) ( tid, (Addr)p_old );
582 VG_(HT_add_node)( MC_(malloc_list), new_mc );
587 MC_(make_mem_noaccess)( a_new-MC_(Malloc_Redzone_SzB),
588 MC_(Malloc_Redzone_SzB) );
595 MC_(copy_address_range_state) ( (Addr)p_old, a_new, new_szB );
602 MC_(copy_address_range_state) ( (Addr)p_old, a_new, old_szB );
608 ecu = VG_(get_ECU_from_ExeContext)(MC_(allocated_at)(new_mc));
610 MC_(make_mem_undefined_w_otag)( a_new+old_szB,
615 if (MC_(clo_malloc_fill) != -1) {
616 tl_assert(MC_(clo_malloc_fill) >= 0x00
617 && MC_(clo_malloc_fill) <= 0xFF);
618 VG_(memset)((void*)(a_new+old_szB), MC_(clo_malloc_fill),
624 MC_(make_mem_noaccess) ( a_new+new_szB, MC_(Malloc_Redzone_SzB));
627 if (MC_(clo_free_fill) != -1) {
628 tl_assert(MC_(clo_free_fill) >= 0x00 && MC_(clo_free_fill) <= 0xFF);
629 VG_(memset)((void*)p_old, MC_(clo_free_fill), old_szB);
636 die_and_free_mem ( tid, old_mc, MC_(Malloc_Redzone_SzB) );
642 VG_(HT_add_node)( MC_(malloc_list), old_mc );
648 SizeT MC_(malloc_usable_size) ( ThreadId tid, void* p )
650 MC_Chunk* mc = VG_(HT_lookup) ( MC_(malloc_list), (UWord)p );
661 void MC_(handle_resizeInPlace)(ThreadId tid, Addr p,
664 MC_Chunk* mc = VG_(HT_lookup) ( MC_(malloc_list), (UWord)p );
668 MC_(record_free_error) ( tid, p );
677 MC_(make_mem_noaccess)( p + newSizeB, oldSizeB - newSizeB + rzB );
681 MC_(make_mem_undefined_w_otag)( p + oldSizeB, newSizeB - oldSizeB,
684 MC_(make_mem_noaccess)( p + newSizeB, rzB );
700 void MC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed)
711 mp = VG_(HT_lookup)(MC_(mempool_list), (UWord)pool);
713 VG_(tool_panic)("MC_(create_mempool): duplicate pool creation");
720 mp->chunks = VG_(HT_construct)( "MC_(create_mempool)" );
728 if (!MC_(check_mem_is_noaccess)( (Addr)mp, sizeof(MC_Mempool), NULL )) {
729 VG_(tool_panic)("MC_(create_mempool): shadow area is accessible");
732 VG_(HT_add_node)( MC_(mempool_list), mp );
735 void MC_(destroy_mempool)(Addr pool)
746 mp = VG_(HT_remove) ( MC_(mempool_list), (UWord)pool );
750 MC_(record_illegal_mempool_error) ( tid, pool );
760 MC_(make_mem_noaccess)(mc->data-mp->rzB, mc->szB + 2*mp->rzB );
794 VG_(HT_ResetIter)(MC_(mempool_list));
795 while ( (mp2 = VG_(HT_Next)(MC_(mempool_list))) ) {
848 VG_(pp_ExeContext)(MC_(allocated_at)(chunks[i]));
854 void MC_(mempool_alloc)(ThreadId tid, Addr pool, Addr addr, SizeT szB)
864 mp = VG_(HT_lookup) ( MC_(mempool_list), (UWord)pool );
866 MC_(record_illegal_mempool_error) ( tid, pool );
869 MC_(new_block)(tid, addr, szB, /*ignored*/0, mp->is_zeroed,
876 MC_(make_mem_noaccess) ( addr - mp->rzB, mp->rzB);
877 MC_(make_mem_noaccess) ( addr + szB, mp->rzB);
883 void MC_(mempool_free)(Addr pool, Addr addr)
889 mp = VG_(HT_lookup)(MC_(mempool_list), (UWord)pool);
891 MC_(record_illegal_mempool_error)(tid, pool);
903 MC_(record_free_error)(tid, (Addr)addr);
918 void MC_(mempool_trim)(Addr pool, Addr addr, SizeT szB)
932 mp = VG_(HT_lookup)(MC_(mempool_list), (UWord)pool);
934 MC_(record_illegal_mempool_error)(tid, pool);
971 MC_(record_free_error)(tid, (Addr)mc->data);
986 MC_(record_free_error)(tid, (Addr)mc->data);
1013 MC_(make_mem_noaccess)( min, lo - min);
1017 MC_(make_mem_noaccess)( hi, max - hi );
1032 void MC_(move_mempool)(Addr poolA, Addr poolB)
1042 mp = VG_(HT_remove) ( MC_(mempool_list), (UWord)poolA );
1046 MC_(record_illegal_mempool_error) ( tid, poolA );
1051 VG_(HT_add_node)( MC_(mempool_list), mp );
1054 void MC_(mempool_change)(Addr pool, Addr addrA, Addr addrB, SizeT szB)
1066 mp = VG_(HT_lookup)(MC_(mempool_list), (UWord)pool);
1068 MC_(record_illegal_mempool_error)(tid, pool);
1076 MC_(record_free_error)(tid, (Addr)addrA);
1087 Bool MC_(mempool_exists)(Addr pool)
1091 mp = VG_(HT_lookup)(MC_(mempool_list), (UWord)pool);
1103 void MC_(print_malloc_stats) ( void )
1115 VG_(HT_ResetIter)(MC_(malloc_list));
1116 while ( (mc = VG_(HT_Next)(MC_(malloc_list))) ) {
1132 SizeT MC_(get_cmalloc_n_frees) ( void )