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 "src/internal_config.h"
8 #include "src/mc/mc_object_info.h"
9 #include "src/mc/mc_private.h"
10 #include "src/smpi/private.h"
11 #include "src/mc/mc_snapshot.h"
12 #include "src/mc/mc_ignore.h"
13 #include "src/mc/mc_protocol.h"
14 #include "src/mc/mc_client.h"
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_ignore, mc,
19 "Logging specific to MC ignore mechanism");
21 // ***** Model-checked
23 void MC_ignore_heap(void *address, size_t size)
25 if (mc_mode != MC_MODE_CLIENT)
28 xbt_mheap_t heap = mmalloc_get_current_heap();
30 s_mc_ignore_heap_message_t message;
31 message.type = MC_MESSAGE_IGNORE_HEAP;
32 message.address = address;
36 (char *) heap->heapbase) / BLOCKSIZE + 1;
37 if (heap->heapinfo[message.block].type == 0) {
38 message.fragment = -1;
39 heap->heapinfo[message.block].busy_block.ignore++;
42 ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >>
43 heap->heapinfo[message.block].type;
44 heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
47 if (MC_protocol_send(mc_client->fd, &message, sizeof(message)))
48 xbt_die("Could not send ignored region to MCer");
51 void MC_remove_ignore_heap(void *address, size_t size)
53 if (mc_mode != MC_MODE_CLIENT)
56 s_mc_ignore_memory_message_t message;
57 message.type = MC_MESSAGE_UNIGNORE_HEAP;
58 message.addr = (std::uintptr_t) address;
60 MC_client_send_message(&message, sizeof(message));
63 void MC_ignore_global_variable(const char *name)
65 // TODO, send a message to the model_checker
66 xbt_die("Unimplemented");
69 /** @brief Register a stack in the model checker
71 * The stacks are allocated in the heap. The MC handle them especially
72 * when we analyse/compare the content of the heap so it must be told where
73 * they are with this function.
76 * @param process Process owning the stack
78 * @param size Size of the stack
80 void MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size)
82 if (mc_mode != MC_MODE_CLIENT)
85 xbt_mheap_t heap = mmalloc_get_current_heap();
87 s_stack_region_t region;
88 memset(®ion, 0, sizeof(region));
89 region.address = stack;
90 region.context = context;
94 (char *) heap->heapbase) / BLOCKSIZE + 1;
96 if (smpi_privatize_global_variables && process) {
97 region.process_index = smpi_process_index_of_smx_process(process);
100 region.process_index = -1;
102 s_mc_stack_region_message_t message;
103 message.type = MC_MESSAGE_STACK_REGION;
104 message.stack_region = region;
105 MC_client_send_message(&message, sizeof(message));