1 /* Copyright (c) 2008-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "internal_config.h"
8 #include "mc_object_info.h"
9 #include "mc/mc_private.h"
10 #include "smpi/private.h"
11 #include "mc/mc_snapshot.h"
12 #include "mc/mc_ignore.h"
13 #include "mc/mc_protocol.h"
14 #include "mc/mc_client.h"
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mcer_ignore, mc,
19 "Logging specific to MC ignore mechanism");
21 extern xbt_dynar_t mc_heap_comparison_ignore;
23 void MC_heap_region_ignore_insert(mc_heap_ignore_region_t region)
25 if (mc_heap_comparison_ignore == NULL) {
26 mc_heap_comparison_ignore =
27 xbt_dynar_new(sizeof(mc_heap_ignore_region_t),
28 heap_ignore_region_free_voidp);
29 xbt_dynar_push(mc_heap_comparison_ignore, ®ion);
33 unsigned int cursor = 0;
34 mc_heap_ignore_region_t current_region = NULL;
36 int end = xbt_dynar_length(mc_heap_comparison_ignore) - 1;
38 // Find the position where we want to insert the mc_heap_ignore_region_t:
39 while (start <= end) {
40 cursor = (start + end) / 2;
42 (mc_heap_ignore_region_t) xbt_dynar_get_as(mc_heap_comparison_ignore,
44 mc_heap_ignore_region_t);
45 if (current_region->address == region->address) {
46 heap_ignore_region_free(region);
48 } else if (current_region->address < region->address) {
55 // Insert it mc_heap_ignore_region_t:
56 if (current_region->address < region->address)
57 xbt_dynar_insert_at(mc_heap_comparison_ignore, cursor + 1, ®ion);
59 xbt_dynar_insert_at(mc_heap_comparison_ignore, cursor, ®ion);
62 void MC_heap_region_ignore_remove(void *address, size_t size)
64 unsigned int cursor = 0;
66 int end = xbt_dynar_length(mc_heap_comparison_ignore) - 1;
67 mc_heap_ignore_region_t region;
70 while (start <= end) {
71 cursor = (start + end) / 2;
73 (mc_heap_ignore_region_t) xbt_dynar_get_as(mc_heap_comparison_ignore,
75 mc_heap_ignore_region_t);
76 if (region->address == address) {
79 } else if (region->address < address) {
82 if ((char *) region->address <= ((char *) address + size)) {
91 if (ignore_found == 1) {
92 xbt_dynar_remove_at(mc_heap_comparison_ignore, cursor, NULL);
93 MC_remove_ignore_heap(address, size);