1 /* Copyright (c) 2008-2014. 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_private.h"
10 #include "smpi/private.h"
11 #include "mc/mc_snapshot.h"
12 #include "mc_ignore.h"
13 #include "mc_protocol.h"
14 #include "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 s_mc_heap_ignore_region_t region;
29 memset(®ion, 0, sizeof(region));
30 region.address = address;
34 (char *) std_heap->heapbase) / BLOCKSIZE + 1;
35 if (std_heap->heapinfo[region.block].type == 0) {
37 std_heap->heapinfo[region.block].busy_block.ignore++;
40 ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >> std_heap->
41 heapinfo[region.block].type;
42 std_heap->heapinfo[region.block].busy_frag.ignore[region.fragment]++;
45 s_mc_ignore_heap_message_t message;
46 message.type = MC_MESSAGE_IGNORE_HEAP;
47 message.region = region;
48 if (MC_protocol_send(mc_client->fd, &message, sizeof(message)))
49 xbt_die("Could not send ignored region to MCer");
52 void MC_remove_ignore_heap(void *address, size_t size)
54 if (mc_mode != MC_MODE_CLIENT)
57 s_mc_ignore_memory_message_t message;
58 message.type = MC_MESSAGE_UNIGNORE_HEAP;
59 message.addr = address;
61 MC_client_send_message(&message, sizeof(message));
64 void MC_ignore_global_variable(const char *name)
66 // TODO, send a message to the model_checker
67 xbt_die("Unimplemented");
70 /** @brief Register a stack in the model checker
72 * The stacks are allocated in the heap. The MC handle them especially
73 * when we analyse/compare the content of the heap so it must be told where
74 * they are with this function.
77 * @param process Process owning the stack
79 * @param size Size of the stack
81 void MC_register_stack_area(void *stack, smx_process_t process, void *context, size_t size)
83 if (mc_mode != MC_MODE_CLIENT)
86 s_stack_region_t region;
87 memset(®ion, 0, sizeof(region));
88 region.address = stack;
89 region.context = context;
93 (char *) std_heap->heapbase) / BLOCKSIZE + 1;
95 if (smpi_privatize_global_variables && process) {
96 region.process_index = smpi_process_index_of_smx_process(process);
99 region.process_index = -1;
101 s_mc_stack_region_message_t message;
102 message.type = MC_MESSAGE_STACK_REGION;
103 message.stack_region = region;
104 MC_client_send_message(&message, sizeof(message));