#ifndef MC_DATATYPE_H
#define MC_DATATYPE_H
+#include <ucontext.h>
+
#include "xbt/misc.h"
#include "xbt/swag.h"
#include "xbt/fifo.h"
typedef struct s_stack_region{
void *address;
- void *context;
+ ucontext_t* context;
size_t size;
int block;
int process_index;
#ifndef _MC_MC_H
#define _MC_MC_H
+#include <ucontext.h>
+
#include "xbt/base.h"
#include "xbt/misc.h"
#include "xbt/fifo.h"
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 */
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;
}
const malloc_info* heapinfos2 = snapshot2->read<malloc_info*>(
(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));
}
- while (i2 < state->heaplimit && !equal) {
+ while (i2 <= state->heaplimit && !equal) {
addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE +
(char *) state->std_heap_copy.heapbase;
}
- 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],
/* 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) {
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) {
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)
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);
* @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;
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 {
UContext(std::function<void()> code,
void_pfn_smxprocess_t cleanup_func, smx_process_t process);
~UContext();
-protected:
- static void wrapper(int first, ...);
};
class SerialUContext : public UContext {
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;
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;
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();
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;