$(MARKDOWN) $< > $@
malloc.o: malloc.c
- $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
+ $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=1 $(CPPFLAGS) -Wno-unused-variable
futex.o: futex.cc
$(CXX) -fPIC -c futex.cc -std=c++11 $(CPPFLAGS)
HashTable<uint32_t, action_mlist_t *, uintptr_t, 4> * getFuncHistory() { return &func_history; }
void print();
-
+ MEMALLOC
private:
uint32_t func_id;
*/
int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg)
{
- struct thread_params params = { start_routine, arg };
+ struct thread_params params = { start_routine, arg };
/* seq_cst is just a 'don't care' parameter */
model->switch_to_master(new ModelAction(THREAD_CREATE, std::memory_order_seq_cst, t, (uint64_t)¶ms));
return 0;
inspect_plugin(NULL)
{
memset(&stats,0,sizeof(struct execution_stats));
- init_thread = new Thread(execution->get_next_id(), (thrd_t *) malloc(sizeof(thrd_t)), &user_main_wrapper, NULL, NULL); // L: user_main_wrapper passes the user program
+ init_thread = new Thread(execution->get_next_id(), (thrd_t *) model_malloc(sizeof(thrd_t)), &user_main_wrapper, NULL, NULL); // L: user_main_wrapper passes the user program
execution->add_thread(init_thread);
scheduler->set_current_thread(init_thread);
execution->setParams(¶ms);
+
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
/** @brief Snapshotting malloc, for use by model-checker (not user progs) */
void * snapshot_malloc(size_t size)
{
- void *tmp = malloc(size);
+ void *tmp = mspace_malloc(model_snapshot_space, size);
ASSERT(tmp);
return tmp;
}
/** @brief Snapshotting calloc, for use by model-checker (not user progs) */
void * snapshot_calloc(size_t count, size_t size)
{
- void *tmp = calloc(count, size);
+ void *tmp = mspace_calloc(model_snapshot_space, count, size);
ASSERT(tmp);
return tmp;
}
/** @brief Snapshotting realloc, for use by model-checker (not user progs) */
void *snapshot_realloc(void *ptr, size_t size)
{
- void *tmp = realloc(ptr, size);
+ void *tmp = mspace_realloc(model_snapshot_space, ptr, size);
ASSERT(tmp);
return tmp;
}
/** @brief Snapshotting free, for use by model-checker (not user progs) */
void snapshot_free(void *ptr)
{
- free(ptr);
+ mspace_free(model_snapshot_space, ptr);
}
/** Non-snapshotting free for our use. */
/** @brief Snapshotting allocation function for use by the Thread class only */
void * Thread_malloc(size_t size)
{
- return malloc(size);
+ return snapshot_malloc(size);
}
/** @brief Snapshotting free function for use by the Thread class only */
void Thread_free(void *ptr)
{
- free(ptr);
+ snapshot_free(ptr);
}
#endif /* !USE_MPROTECT_SNAPSHOT */
int pthread_create(pthread_t *t, const pthread_attr_t * attr,
pthread_start_t start_routine, void * arg) {
+ if (!model) {
+ snapshot_system_init(10000, 1024, 1024, 40000);
+ model = new ModelChecker();
+ model->startChecker();
+ }
+
struct pthread_params params = { start_routine, arg };
ModelAction *act = new ModelAction(PTHREAD_CREATE, std::memory_order_seq_cst, t, (uint64_t)¶ms);
}
int pthread_mutex_lock(pthread_mutex_t *p_mutex) {
+ if (!model) {
+ snapshot_system_init(10000, 1024, 1024, 40000);
+ model = new ModelChecker();
+ model->startChecker();
+ }
+
+
ModelExecution *execution = model->get_execution();
/* to protect the case where PTHREAD_MUTEX_INITIALIZER is used
if (!fork_snap)
createSharedMemory();
- void *base_model_snapshot_space = malloc((numheappages + 1) * PAGESIZE);
- void *pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space);
- model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
+ model_snapshot_space = create_mspace(numheappages * PAGESIZE, 1);
}
static void fork_loop() {