#include "mc_private.h"
#include "smpi/private.h"
#include "mc/mc_snapshot.h"
+#include "mc_ignore.h"
+#include "mc_protocol.h"
+#include "mc_client.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_ignore, mc,
"Logging specific to MC ignore mechanism");
/***********************************************************************/
-// FIXME, cross-process support? (or make this it is used on the app-side)
-void MC_ignore_heap(void *address, size_t size)
+void MC_heap_region_ignore_insert(mc_heap_ignore_region_t region)
{
- if(!std_heap)
- return;
-
int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
- MC_SET_MC_HEAP;
-
- mc_heap_ignore_region_t region = NULL;
- region = xbt_new0(s_mc_heap_ignore_region_t, 1);
- region->address = address;
- region->size = size;
-
- region->block =
- ((char *) address -
- (char *) std_heap->heapbase) / BLOCKSIZE + 1;
-
- if (std_heap->heapinfo[region->block].type == 0) {
- region->fragment = -1;
- std_heap->heapinfo[region->block].busy_block.ignore++;
- } else {
- region->fragment =
- ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >> std_heap->
- heapinfo[region->block].type;
- std_heap->heapinfo[region->block].busy_frag.ignore[region->fragment]++;
- }
-
if (mc_heap_comparison_ignore == NULL) {
mc_heap_comparison_ignore =
xbt_dynar_new(sizeof(mc_heap_ignore_region_t),
int start = 0;
int end = xbt_dynar_length(mc_heap_comparison_ignore) - 1;
+ // Find the position where we want to insert the mc_heap_ignore_region_t:
while (start <= end) {
cursor = (start + end) / 2;
current_region =
(mc_heap_ignore_region_t) xbt_dynar_get_as(mc_heap_comparison_ignore,
cursor,
mc_heap_ignore_region_t);
- if (current_region->address == address) {
+ if (current_region->address == region->address) {
heap_ignore_region_free(region);
if (!raw_mem_set)
MC_SET_STD_HEAP;
return;
- } else if (current_region->address < address) {
+ } else if (current_region->address < region->address) {
start = cursor + 1;
} else {
end = cursor - 1;
}
}
- if (current_region->address < address)
+ // Insert it mc_heap_ignore_region_t:
+ if (current_region->address < region->address)
xbt_dynar_insert_at(mc_heap_comparison_ignore, cursor + 1, ®ion);
else
xbt_dynar_insert_at(mc_heap_comparison_ignore, cursor, ®ion);
MC_SET_STD_HEAP;
}
+void MC_heap_region_ignore_send(mc_heap_ignore_region_t region)
+{
+ s_mc_ignore_region_message_t message;
+ message.type = MC_MESSAGE_IGNORE_REGION;
+ message.region = *region;
+ if (MC_protocol_send(mc_client->fd, &message, sizeof(message)))
+ xbt_die("Could not send ignored region to MCer");
+ XBT_DEBUG("Sent ignored region to the model-checker");
+}
+
+// FIXME, cross-process support? (or make this it is used on the app-side)
+void MC_ignore_heap(void *address, size_t size)
+{
+ if(!std_heap)
+ return;
+
+ int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
+
+ MC_SET_MC_HEAP;
+
+ mc_heap_ignore_region_t region = NULL;
+ region = xbt_new0(s_mc_heap_ignore_region_t, 1);
+ region->address = address;
+ region->size = size;
+
+ region->block =
+ ((char *) address -
+ (char *) std_heap->heapbase) / BLOCKSIZE + 1;
+
+ if (std_heap->heapinfo[region->block].type == 0) {
+ region->fragment = -1;
+ std_heap->heapinfo[region->block].busy_block.ignore++;
+ } else {
+ region->fragment =
+ ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >> std_heap->
+ heapinfo[region->block].type;
+ std_heap->heapinfo[region->block].busy_frag.ignore[region->fragment]++;
+ }
+
+ MC_heap_region_ignore_insert(region);
+
+#if 1
+ if (mc_mode == MC_MODE_CLIENT)
+ MC_heap_region_ignore_send(region);
+#endif
+
+ if (!raw_mem_set)
+ MC_SET_STD_HEAP;
+}
+
void MC_remove_ignore_heap(void *address, size_t size)
{