From: Martin Quinson Date: Thu, 11 Feb 2016 21:42:53 +0000 (+0100) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_13~872 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6a20b94eaec32fb5224c18d21e141bef70da15d8?hp=6010e94a450a23778f1691ac4e4d30340b3ba1ea Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/src/include/mc/datatypes.h b/src/include/mc/datatypes.h index 763b60dee6..0b45c09f97 100644 --- a/src/include/mc/datatypes.h +++ b/src/include/mc/datatypes.h @@ -7,6 +7,8 @@ #ifndef MC_DATATYPE_H #define MC_DATATYPE_H +#include + #include "xbt/misc.h" #include "xbt/swag.h" #include "xbt/fifo.h" @@ -26,7 +28,7 @@ typedef struct s_mc_transition *mc_transition_t; typedef struct s_stack_region{ void *address; - void *context; + ucontext_t* context; size_t size; int block; int process_index; diff --git a/src/include/mc/mc.h b/src/include/mc/mc.h index eaeb396691..d3eadeabe2 100644 --- a/src/include/mc/mc.h +++ b/src/include/mc/mc.h @@ -7,6 +7,8 @@ #ifndef _MC_MC_H #define _MC_MC_H +#include + #include "xbt/base.h" #include "xbt/misc.h" #include "xbt/fifo.h" @@ -87,7 +89,7 @@ XBT_PUBLIC(void) MC_ignore_heap(void *address, size_t size); XBT_PUBLIC(void) MC_remove_ignore_heap(void *address, size_t size); XBT_PUBLIC(void) MC_ignore_local_variable(const char *var_name, const char *frame); XBT_PUBLIC(void) MC_ignore_global_variable(const char *var_name); -XBT_PUBLIC(void) MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size); +XBT_PUBLIC(void) MC_register_stack_area(void *stack, smx_process_t process, ucontext_t* context, size_t size); /********************************* Memory *************************************/ XBT_PUBLIC(void) MC_memory_init(void); /* Initialize the memory subsystem */ diff --git a/src/mc/ObjectInformation.cpp b/src/mc/ObjectInformation.cpp index 9d66b0ebb4..08a75fa583 100644 --- a/src/mc/ObjectInformation.cpp +++ b/src/mc/ObjectInformation.cpp @@ -108,32 +108,35 @@ void ObjectInformation::remove_global_variable(const char* name) return; // Binary search: - size_type start = 0; - size_type end = this->global_variables.size() - 1; + size_type first = 0; + size_type last = this->global_variables.size() - 1; - while (start <= end) { - size_type cursor = start + (end - start) / 2; + while (first <= last) { + size_type cursor = first + (last - first) / 2; simgrid::mc::Variable& current_var = this->global_variables[cursor]; int cmp = current_var.name.compare(name); if (cmp == 0) { + // Find the whole range: - start = cursor; - while (start != 0 && this->global_variables[start - 1].name == name) - start--; + size_type first = cursor; + while (first != 0 && this->global_variables[first - 1].name == name) + first--; size_type size = this->global_variables.size(); - end = cursor; - while (end != size - 1 && this->global_variables[end + 1].name == name) - end++; + size_type last = cursor; + while (last != size - 1 && this->global_variables[last + 1].name == name) + last++; + // Remove the whole range: this->global_variables.erase( - this->global_variables.begin() + cursor, - this->global_variables.begin() + end + 1); + this->global_variables.begin() + first, + this->global_variables.begin() + last + 1); + return; } else if (cmp < 0) - start = cursor + 1; + first = cursor + 1; else if (cursor != 0) - end = cursor - 1; + last = cursor - 1; else break; } diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index 93fd25433e..f8bbd845b1 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -337,7 +337,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) const malloc_info* heapinfos2 = snapshot2->read( (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing); - while (i1 < state->heaplimit) { + while (i1 <= state->heaplimit) { const malloc_info* heapinfo1 = (const malloc_info*) MC_region_read(heap_region1, &heapinfo_temp1, &heapinfos1[i1], sizeof(malloc_info)); const malloc_info* heapinfo2 = (const malloc_info*) MC_region_read(heap_region2, &heapinfo_temp2, &heapinfos2[i1], sizeof(malloc_info)); @@ -401,7 +401,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) } - while (i2 < state->heaplimit && !equal) { + while (i2 <= state->heaplimit && !equal) { addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char *) state->std_heap_copy.heapbase; @@ -486,7 +486,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) } - while (i2 < state->heaplimit && !equal) { + while (i2 <= state->heaplimit && !equal) { const malloc_info* heapinfo2b = (const malloc_info*) MC_region_read( heap_region2, &heapinfo_temp2b, &heapinfos2[i2], @@ -560,7 +560,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) /* All blocks/fragments are equal to another block/fragment ? */ size_t i = 1, j = 0; - for(i = 1; i < state->heaplimit; i++) { + for(i = 1; i <= state->heaplimit; i++) { const malloc_info* heapinfo1 = (const malloc_info*) MC_region_read( heap_region1, &heapinfo_temp1, &heapinfos1[i], sizeof(malloc_info)); if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { @@ -602,7 +602,7 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) if (i1 == state->heaplimit) XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1); - for (i=1; i < state->heaplimit; i++) { + for (i=1; i <= state->heaplimit; i++) { const malloc_info* heapinfo2 = (const malloc_info*) MC_region_read( heap_region2, &heapinfo_temp2, &heapinfos2[i], sizeof(malloc_info)); if (heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) { @@ -758,9 +758,13 @@ static int compare_heap_area_with_type(struct s_mc_diff *state, int process_inde int pointer_level) { top: - if (is_stack(real_area1) && is_stack(real_area2)) + // HACK: This should not happen but in pratice, there is some + // DW_TAG_typedef without DW_AT_type. We should fix this somehow. + if (type == nullptr) return 0; + if (is_stack(real_area1) && is_stack(real_area2)) + return 0; ssize_t ignore1, ignore2; if ((check_ignore > 0) @@ -925,7 +929,7 @@ top: void *real_member2 = simgrid::dwarf::resolve_member( real_area2, type, &member, (simgrid::mc::AddressSpace*) snapshot2, process_index); res = - compare_heap_area_with_type(state, process_index, real_member1, real_member2, + compare_heap_area_with_type(state, process_index, real_member1, real_member2, snapshot1, snapshot2, previous, member.type, -1, check_ignore, 0); diff --git a/src/mc/mc_ignore.cpp b/src/mc/mc_ignore.cpp index ccac7338fb..6017779fa2 100644 --- a/src/mc/mc_ignore.cpp +++ b/src/mc/mc_ignore.cpp @@ -77,7 +77,7 @@ void MC_ignore_global_variable(const char *name) * @param context * @param size Size of the stack */ -void MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size) +void MC_register_stack_area(void *stack, smx_process_t process, ucontext_t* context, size_t size) { if (mc_mode != MC_MODE_CLIENT) return; diff --git a/src/simix/UContext.cpp b/src/simix/UContext.cpp index 33532bb647..45b50be5d9 100644 --- a/src/simix/UContext.cpp +++ b/src/simix/UContext.cpp @@ -76,6 +76,10 @@ static unsigned long sysv_process_index = 0; /* index of the next process to r static simgrid::simix::UContext* sysv_maestro_context; static bool sysv_parallel; +// The name of this function is currently hardcoded in the code (as string). +// Do not change it without fixing those references as well. +static void smx_ctx_sysv_wrapper(int first, ...); + namespace simgrid { namespace simix { @@ -88,8 +92,6 @@ public: UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_process_t process); ~UContext(); -protected: - static void wrapper(int first, ...); }; class SerialUContext : public UContext { @@ -224,7 +226,7 @@ UContext::UContext(std::function code, this->stack_, smx_context_usable_stack_size); this->uc_.uc_stack.ss_size = pth_sksize_makecontext( this->stack_, smx_context_usable_stack_size); - simgrid_makecontext(&this->uc_, UContext::wrapper, this); + simgrid_makecontext(&this->uc_, smx_ctx_sysv_wrapper, this); } else { if (process != NULL && sysv_maestro_context == NULL) sysv_maestro_context = this; @@ -243,11 +245,14 @@ UContext::~UContext() SIMIX_context_stack_delete(this->stack_); } -void UContext::wrapper(int first, ...) +} +} + +static void smx_ctx_sysv_wrapper(int first, ...) { // Rebuild the Context* pointer from the integers: int ctx_addr[CTX_ADDR_LEN]; - UContext* context; + simgrid::simix::UContext* context; ctx_addr[0] = first; if (CTX_ADDR_LEN > 1) { va_list ap; @@ -256,12 +261,15 @@ void UContext::wrapper(int first, ...) ctx_addr[i] = va_arg(ap, int); va_end(ap); } - memcpy(&context, ctx_addr, sizeof(UContext*)); + memcpy(&context, ctx_addr, sizeof(simgrid::simix::UContext*)); (*context)(); context->stop(); } +namespace simgrid { +namespace simix { + void SerialUContext::stop() { Context::stop(); diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 8b9ebaa6c5..344023658c 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -359,7 +359,7 @@ void mmalloc_postexit(void) size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapinfo) { int bytes = 0; - for (size_t i=0; i < heaplimit; ++i){ + for (size_t i=0; i<=heaplimit; ++i){ if (heapinfo[i].type == MMALLOC_TYPE_UNFRAGMENTED){ if (heapinfo[i].busy_block.busy_size > 0) bytes += heapinfo[i].busy_block.busy_size;