)
set(MC_SRC
- src/mc/mc_address_space.h
- src/mc/mc_address_space.cpp
+ src/mc/AddressSpace.hpp
+ src/mc/AddressSpace.cpp
src/mc/mc_forward.h
src/mc/mc_process.h
src/mc/mc_process.cpp
#include "xbt/dynar.h"
#include "xbt/dict.h"
+#include "mc/mc_forward.h"
SG_BEGIN_DECL()
xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap);
xbt_mheap_t mmalloc_get_current_heap(void);
-struct s_mc_snapshot;
struct s_dw_type;
-int mmalloc_compare_heap(struct s_mc_snapshot* snapshot1, struct s_mc_snapshot* snapshot2);
+int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2);
int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2);
int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t to_ignore1, xbt_dynar_t to_ignore2);
-int compare_heap_area(int process_index, const void *area1, const void* area2, struct s_mc_snapshot* snapshot1, struct s_mc_snapshot* snapshot2, xbt_dynar_t previous, struct s_dw_type *type, int pointer_level);
+int compare_heap_area(int process_index, const void *area1, const void* area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, struct s_dw_type *type, int pointer_level);
void reset_heap_information(void);
size_t mmalloc_get_bytes_used(xbt_mheap_t);
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "mc_address_space.h"
+#include "AddressSpace.hpp"
+
+namespace simgrid {
+namespace mc {
+
+AddressSpace::~AddressSpace()
+{
+}
+
+}
+}
--- /dev/null
+/* Copyright (c) 2008-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef MC_ADDRESS_SPACE_H
+#define MC_ADDRESS_SPACE_H
+
+#include <cstdint>
+#include <type_traits>
+
+#include <xbt/misc.h>
+
+#include <stdint.h>
+
+#include "mc_forward.h"
+
+// Compatibility stuff, will be removed:
+#define MC_ADDRESS_SPACE_READ_FLAGS_NONE ::simgrid::mc::AddressSpace::Normal
+#define MC_ADDRESS_SPACE_READ_FLAGS_LAZY ::simgrid::mc::AddressSpace::Lazy
+
+// Compatibility stuff, will be removed:
+#define MC_PROCESS_INDEX_MISSING ::simgrid::mc::ProcessIndexMissing
+#define MC_PROCESS_INDEX_DISABLED ::simgrid::mc::ProcessIndexDisabled
+#define MC_PROCESS_INDEX_ANY ::simgrid::mc::ProcessIndexAny
+
+namespace simgrid {
+namespace mc {
+
+/** Process index used when no process is available
+ *
+ * The expected behaviour is that if a process index is needed it will fail.
+ * */
+const int ProcessIndexMissing = -1;
+
+/** Process index used when we don't care about the process index
+ * */
+const int ProcessIndexDisabled = -2;
+
+/** Constant used when any process will do.
+ *
+ * This is is index of the first process.
+ */
+const int ProcessIndexAny = 0;
+
+class AddressSpace {
+public:
+ enum ReadMode {
+ Normal,
+ /** Allows the `read_bytes` to return a pointer to another buffer
+ * where the data ins available instead of copying the data into the buffer
+ */
+ Lazy
+ };
+ virtual ~AddressSpace();
+ virtual const void* read_bytes(void* buffer, std::size_t size,
+ std::uint64_t address, int process_index = ProcessIndexAny,
+ ReadMode mode = Normal) = 0;
+ template<class T>
+ T read(uint64_t address, int process_index = ProcessIndexMissing)
+ {
+ static_assert(std::is_trivial<T>::value, "Cannot read a non-trivial type");
+ T res;
+ this->read_bytes(&res, sizeof(T), address, process_index);
+ return res;
+ }
+};
+
+}
+}
+
+// Deprecated compatibility wrapper:
+static inline
+const void* MC_address_space_read(
+ mc_address_space_t address_space, simgrid::mc::AddressSpace::ReadMode mode,
+ void* target, const void* addr, size_t size,
+ int process_index)
+{
+ return address_space->read_bytes(target, size, (std::uint64_t) addr,
+ process_index, mode);
+}
+
+#endif
namespace simgrid {
namespace mc {
-ModelChecker::ModelChecker(pid_t pid, int socket)
- : page_store_(500)
+ModelChecker::ModelChecker(pid_t pid, int socket) :
+ hostnames_(xbt_dict_new()),
+ page_store_(500),
+ process_(pid, socket)
{
- this->hostnames_ = xbt_dict_new();
- MC_process_init(&this->process(), pid, socket);
}
ModelChecker::~ModelChecker()
{
- MC_process_clear(&this->process_);
xbt_dict_free(&this->hostnames_);
}
* on the model-checker heap, we avoid those issues.
*/
class ModelChecker {
- // This is the parent snapshot of the current state:
- s_mc_pages_store_t page_store_;
- s_mc_process_t process_;
/** String pool for host names */
// TODO, use std::unordered_set with heterogeneous comparison lookup (C++14)
xbt_dict_t /* <hostname, NULL> */ hostnames_;
+ // This is the parent snapshot of the current state:
+ s_mc_pages_store_t page_store_;
+ s_mc_process_t process_;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
+++ /dev/null
-/* Copyright (c) 2008-2014. The SimGrid Team.
- * All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef MC_ADDRESS_SPACE_H
-#define MC_ADDRESS_SPACE_H
-
-#include <xbt/misc.h>
-
-#include <stdint.h>
-
-#include "mc_forward.h"
-
-SG_BEGIN_DECL()
-
-// ***** Data types
-
-/** Options for the read() operation
- *
- * - MC_ADDRESS_SPACE_READ_FLAGS_LAZY, avoid a copy when the data is
- * available in the current process. In this case, the return value
- * of MC_address_space_read might be different from the provided one.
- */
-typedef int adress_space_read_flags_t;
-#define MC_ADDRESS_SPACE_READ_FLAGS_NONE 0
-#define MC_ADDRESS_SPACE_READ_FLAGS_LAZY 1
-
-/** Process index used when no process is available
- *
- * The expected behaviour is that if a process index is needed it will fail.
- * */
-#define MC_PROCESS_INDEX_MISSING -1
-
-#define MC_PROCESS_INDEX_DISABLED -2
-
-/** Process index when any process is suitable
- *
- * We could use a special negative value in the future.
- */
-#define MC_PROCESS_INDEX_ANY 0
-
-// ***** Class definition
-
-typedef struct s_mc_address_space s_mc_address_space_t, *mc_address_space_t;
-typedef struct s_mc_address_space_class s_mc_address_space_class_t, *mc_address_space_class_t;
-
-/** Abstract base class for an address space
- *
- * This is the base class for all virtual address spaces (process, snapshot).
- * It uses dynamic dispatch based on a vtable (`address_space_class`).
- */
-struct s_mc_address_space {
- const s_mc_address_space_class_t* address_space_class;
-};
-
-/** Class object (vtable) for the virtual address spaces
- */
-struct s_mc_address_space_class {
- const void* (*read)(
- mc_address_space_t address_space, adress_space_read_flags_t flags,
- void* target, const void* addr, size_t size,
- int process_index);
- mc_process_t (*get_process)(mc_address_space_t address_space);
-};
-
-typedef const void* (*mc_address_space_class_read_callback_t)(
- mc_address_space_t address_space, adress_space_read_flags_t flags,
- void* target, const void* addr, size_t size,
- int process_index);
-typedef mc_process_t (*mc_address_space_class_get_process_callback_t)(mc_address_space_t address_space);
-
-// ***** Virtual/non-final methods
-
-/** Read data from the given address space
- *
- * Dysnamic dispatch.
- */
-static inline __attribute__((always_inline))
-const void* MC_address_space_read(
- mc_address_space_t address_space, adress_space_read_flags_t flags,
- void* target, const void* addr, size_t size,
- int process_index)
-{
- return address_space->address_space_class->read(
- address_space, flags, target, addr, size,
- process_index);
-}
-
-static inline __attribute__((always_inline))
-const void* MC_address_space_get_process(mc_address_space_t address_space)
-{
- if (address_space->address_space_class->get_process)
- return address_space->address_space_class->get_process(address_space);
- else
- return NULL;
-}
-
-SG_END_DECL()
-
-#endif
xbt_free(region);
}
-void MC_free_snapshot(mc_snapshot_t snapshot)
-{
- for (size_t i = 0; i < snapshot->snapshot_regions_count; i++) {
- MC_region_destroy(snapshot->snapshot_regions[i]);
- }
- xbt_free(snapshot->snapshot_regions);
- xbt_free(snapshot->stack_sizes);
- xbt_dynar_free(&(snapshot->stacks));
- xbt_dynar_free(&(snapshot->to_ignore));
- xbt_dynar_free(&snapshot->ignored_data);
- xbt_free(snapshot);
-}
-
/******************************* Snapshot regions ********************************/
/*********************************************************************************/
current_variable->object_info,
&(stack_frame->unw_cursor),
(void *) stack_frame->frame_base,
- (mc_address_space_t) &mc_model_checker->process(), process_index);
+ &mc_model_checker->process(), process_index);
switch(mc_get_location_type(&location)) {
case MC_LOCATION_TYPE_ADDRESS:
closedir (fd_dir);
}
-static s_mc_address_space_class_t mc_snapshot_class = {
- (mc_address_space_class_read_callback_t) &MC_snapshot_read,
- NULL
-};
-
mc_snapshot_t MC_take_snapshot(int num_state)
{
XBT_DEBUG("Taking snapshot %i", num_state);
mc_process_t mc_process = &mc_model_checker->process();
- mc_snapshot_t snapshot = xbt_new0(s_mc_snapshot_t, 1);
+
+ mc_snapshot_t snapshot = new simgrid::mc::Snapshot();
+
snapshot->process = mc_process;
snapshot->num_state = num_state;
- snapshot->address_space.address_space_class = &mc_snapshot_class;
snapshot->enabled_processes = xbt_dynar_new(sizeof(int), NULL);
case DW_TAG_class_type:
xbt_dynar_foreach(type->members, cursor, member) {
void *member1 =
- mc_member_resolve(real_area1, type, member, (mc_address_space_t) snapshot1, process_index);
+ mc_member_resolve(real_area1, type, member, snapshot1, process_index);
void *member2 =
- mc_member_resolve(real_area2, type, member, (mc_address_space_t) snapshot2, process_index);
+ mc_member_resolve(real_area2, type, member, snapshot2, process_index);
mc_mem_region_t subregion1 = mc_get_region_hinted(member1, snapshot1, process_index, region1);
mc_mem_region_t subregion2 = mc_get_region_hinted(member2, snapshot2, process_index, region2);
res =
} else {
void *real_member =
mc_member_resolve(real_base_address, type, member,
- (mc_address_space_t) snapshot, process_index);
+ snapshot, process_index);
if ((char*) real_member - (char *) real_base_address == offset)
return member->subtype;
}
namespace simgrid {
namespace mc {
- class PageStore;
- class ModelChecker;
+
+class PageStore;
+class ModelChecker;
+class AddressSpace;
+class Process;
+class Snapshot;
+
}
}
typedef ::simgrid::mc::ModelChecker s_mc_model_checker_t;
typedef ::simgrid::mc::PageStore s_mc_pages_store_t;
+typedef ::simgrid::mc::AddressSpace s_mc_address_space_t;
+typedef ::simgrid::mc::Process s_mc_process_t;
+typedef ::simgrid::mc::Snapshot s_mc_snapshot_t;
#else
typedef struct _s_mc_model_checker s_mc_model_checker_t;
typedef struct _s_mc_pages_store s_mc_pages_store_t;
+typedef struct _s_mc_address_space_t s_mc_address_space_t;
+typedef struct _s_mc_process_t s_mc_process_t;
+typedef struct _s_mc_snapshot_t s_mc_snapshot_t;
#endif
typedef struct s_memory_map s_memory_map_t, *memory_map_t;
typedef struct s_dw_variable s_dw_variable_t, *dw_variable_t;
typedef struct s_dw_frame s_dw_frame_t, *dw_frame_t;
+
+
typedef s_mc_pages_store_t *mc_pages_store_t;
-typedef struct s_mc_snapshot s_mc_snapshot_t, *mc_snapshot_t;
-typedef struct s_mc_process s_mc_process_t, * mc_process_t;
typedef s_mc_model_checker_t *mc_model_checker_t;
+typedef s_mc_address_space_t *mc_address_space_t;
+typedef s_mc_process_t *mc_process_t;
+typedef s_mc_snapshot_t *mc_snapshot_t;
SG_BEGIN_DECL()
extern mc_model_checker_t mc_model_checker;
#include "mc_forward.h"
#include "mc_object_info.h"
#include "mc_forward.h"
-#include "mc_address_space.h"
+#include "AddressSpace.hpp"
SG_BEGIN_DECL()
#include "mc_process.h"
#include "mc_object_info.h"
-#include "mc_address_space.h"
+#include "AddressSpace.hpp"
#include "mc_unw.h"
#include "mc_snapshot.h"
#include "mc_ignore.h"
return p;
}
-static const s_mc_address_space_class_t mc_process_class = {
- (mc_address_space_class_read_callback_t) &MC_process_read,
- (mc_address_space_class_get_process_callback_t) MC_process_get_process
-};
-
-bool MC_is_process(mc_address_space_t p)
-{
- return p->address_space_class == &mc_process_class;
}
// ***** mc_process
-void MC_process_init(mc_process_t process, pid_t pid, int sockfd)
+namespace simgrid {
+namespace mc {
+
+Process::Process(pid_t pid, int sockfd)
{
- process->address_space.address_space_class = &mc_process_class;
+ Process* process = this;
+
process->process_flags = MC_PROCESS_NO_FLAG;
process->socket = sockfd;
process->pid = pid;
}
}
-void MC_process_clear(mc_process_t process)
+Process::~Process()
{
- process->address_space.address_space_class = NULL;
+ Process* process = this;
+
process->process_flags = MC_PROCESS_NO_FLAG;
process->pid = 0;
process->heap_info = NULL;
}
+}
+}
+
+extern "C" {
+
void MC_process_refresh_heap(mc_process_t process)
{
xbt_assert(mc_mode == MC_MODE_SERVER);
return real_count;
}
-const void* MC_process_read(mc_process_t process, adress_space_read_flags_t flags,
- void* local, const void* remote, size_t len,
- int process_index)
+}
+
+namespace simgrid {
+namespace mc {
+
+const void *Process::read_bytes(void* buffer, std::size_t size,
+ std::uint64_t address, int process_index,
+ AddressSpace::ReadMode mode)
{
if (process_index != MC_PROCESS_INDEX_DISABLED) {
- mc_object_info_t info = MC_process_find_object_info_rw(process, remote);
+ mc_object_info_t info = MC_process_find_object_info_rw(this, (void*)address);
// Segment overlap is not handled.
if (MC_object_info_is_privatized(info)) {
if (process_index < 0)
xbt_die("Missing process index");
// Address translation in the privaization segment:
- size_t offset = (const char*) remote - info->start_rw;
- remote = (const char*) remote - offset;
+ // TODO, fix me (broken)
+ size_t offset = address - (std::uint64_t)info->start_rw;
+ address = address - offset;
}
}
- if (MC_process_is_self(process)) {
- if (flags & MC_ADDRESS_SPACE_READ_FLAGS_LAZY)
- return remote;
+ if (MC_process_is_self(this)) {
+ if (mode == MC_ADDRESS_SPACE_READ_FLAGS_LAZY)
+ return (void*)address;
else {
- memcpy(local, remote, len);
- return local;
+ memcpy(buffer, (void*)address, size);
+ return buffer;
}
} else {
- if (pread_whole(process->memory_file, local, len, (off_t) remote) < 0)
- xbt_die("Read from process %lli failed", (long long) process->pid);
- return local;
+ if (pread_whole(this->memory_file, buffer, size, (off_t) address) < 0)
+ xbt_die("Read from process %lli failed", (long long) this->pid);
+ return buffer;
}
}
+}
+}
+
+extern "C" {
+
const void* MC_process_read_simple(mc_process_t process,
void* local, const void* remote, size_t len)
{
- adress_space_read_flags_t flags = MC_ADDRESS_SPACE_READ_FLAGS_NONE;
+ simgrid::mc::AddressSpace::ReadMode mode = MC_ADDRESS_SPACE_READ_FLAGS_NONE;
int index = MC_PROCESS_INDEX_ANY;
- MC_process_read(process, flags, local, remote, len, index);
+ MC_process_read(process, mode, local, remote, len, index);
return local;
}
#include "mc_base.h"
#include "mc_mmalloc.h" // std_heap
#include "mc_memory_map.h"
-#include "mc_address_space.h"
+#include "AddressSpace.hpp"
#include "mc_protocol.h"
-SG_BEGIN_DECL()
-
-int MC_process_vm_open(pid_t pid, int flags);
-
typedef int mc_process_flags_t;
#define MC_PROCESS_NO_FLAG 0
#define MC_PROCESS_SELF_FLAG 1
typedef struct s_mc_smx_process_info s_mc_smx_process_info_t, *mc_smx_process_info_t;
+namespace simgrid {
+namespace mc {
+
/** Representation of a process
*/
-struct s_mc_process {
- s_mc_address_space_t address_space;
+class Process : public AddressSpace {
+public:
+ Process(pid_t pid, int sockfd);
+ ~Process();
+ const void* read_bytes(void* buffer, std::size_t size,
+ std::uint64_t address, int process_index = ProcessIndexAny,
+ ReadMode mode = Normal) override;
+public: // to be private
mc_process_flags_t process_flags;
pid_t pid;
int socket;
xbt_dynar_t checkpoint_ignore;
};
-XBT_INTERNAL bool MC_is_process(mc_address_space_t p);
+}
+}
-MC_SHOULD_BE_INTERNAL void MC_process_init(mc_process_t process, pid_t pid, int sockfd);
-XBT_INTERNAL void MC_process_clear(mc_process_t process);
+SG_BEGIN_DECL()
+
+int MC_process_vm_open(pid_t pid, int flags);
/** Refresh the information about the process
*
/* Process memory access: */
-/** Read data from a process memory
- *
- * @param process the process
- * @param local local memory address (destination)
- * @param remote target process memory address (source)
- * @param len data size
- */
-XBT_INTERNAL const void* MC_process_read(mc_process_t process,
- adress_space_read_flags_t flags,
+static inline
+const void* MC_process_read(mc_process_t process,
+ simgrid::mc::AddressSpace::ReadMode mode,
void* local, const void* remote, size_t len,
- int process_index);
+ int process_index)
+{
+ return process->read_bytes(local, len, (std::uint64_t)remote, process_index, mode);
+}
// Simplified versions/wrappers (whould be moved in mc_address_space):
XBT_INTERNAL const void* MC_process_read_simple(mc_process_t process,
{
// swag = REMOTE(*simix_global->process_list)
s_xbt_swag_t swag;
- MC_process_read(process, MC_PROCESS_NO_FLAG, &swag, remote_swag, sizeof(swag),
+ MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE, &swag, remote_swag, sizeof(swag),
MC_PROCESS_INDEX_ANY);
smx_process_t p;
info.address = p;
info.name = NULL;
info.hostname = NULL;
- MC_process_read(process, MC_PROCESS_NO_FLAG,
+ MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
&info.copy, p, sizeof(info.copy), MC_PROCESS_INDEX_ANY);
xbt_dynar_push(target, &info);
// simix_global = REMOTE(*simix_global)
s_smx_global_t simix_global;
- MC_process_read(process, MC_PROCESS_NO_FLAG, &simix_global, simix_global_p, sizeof(simix_global),
+ MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE, &simix_global,
+ simix_global_p, sizeof(simix_global),
MC_PROCESS_INDEX_ANY);
MC_process_refresh_simix_process_list(
return target;
}
-/** @brief Read memory from a snapshot
- *
- * @param addr Process (non-snapshot) address of the data
- * @param snapshot Snapshot (or NULL is no snapshot)
- * @param target Buffer to store the value
- * @param size Size of the data to read in bytes
- * @return Pointer where the data is located (target buffer or original location)
- */
-const void* MC_snapshot_read(
- mc_snapshot_t snapshot, adress_space_read_flags_t flags,
- void* target, const void* addr, size_t size, int process_index)
-{
- mc_mem_region_t region = mc_get_snapshot_region(addr, snapshot, process_index);
- if (region)
- return MC_region_read(region, target, addr, size);
- else
- return MC_process_read(snapshot->process, flags, target, addr, size, process_index);
-}
-
/** Compare memory between snapshots (with known regions)
*
* @param addr1 Address in the first snapshot
return MC_snapshot_region_memcmp(addr1, region1, addr2, region2, size);
}
+namespace simgrid {
+namespace mc {
+
+Snapshot::Snapshot() :
+ process(nullptr),
+ num_state(0),
+ heap_bytes_used(0),
+ snapshot_regions(nullptr),
+ snapshot_regions_count(0),
+ enabled_processes(0),
+ privatization_index(0),
+ stack_sizes(nullptr),
+ stacks(nullptr),
+ to_ignore(nullptr),
+ hash(0),
+ ignored_data(nullptr),
+ total_fd(0),
+ current_fd(nullptr)
+{
+
+}
+Snapshot::~Snapshot()
+{
+ for (size_t i = 0; i < this->snapshot_regions_count; i++) {
+ MC_region_destroy(this->snapshot_regions[i]);
+ }
+ xbt_free(this->snapshot_regions);
+ xbt_free(this->stack_sizes);
+ xbt_dynar_free(&(this->stacks));
+ xbt_dynar_free(&(this->to_ignore));
+ xbt_dynar_free(&this->ignored_data);
+}
+
+const void* Snapshot::read_bytes(void* buffer, std::size_t size,
+ std::uint64_t address, int process_index,
+ AddressSpace::ReadMode mode)
+{
+ mc_mem_region_t region = mc_get_snapshot_region((void*)address, this, process_index);
+ if (region)
+ return MC_region_read(region, buffer, (void*)address, size);
+ else
+ return MC_process_read(this->process, mode, buffer, (void*)address, size, process_index);
+}
+
+}
+}
+
#ifdef SIMGRID_TEST
#include <string.h>
#include "ModelChecker.hpp"
#include "PageStore.hpp"
#include "mc_mmalloc.h"
-#include "mc_address_space.h"
+#include "mc/AddressSpace.hpp"
#include "mc_unw.h"
SG_BEGIN_DECL()
int flags;
}s_fd_infos_t, *fd_infos_t;
-struct s_mc_snapshot {
+}
+
+namespace simgrid {
+namespace mc {
+
+class Snapshot : public AddressSpace {
+public:
+ Snapshot();
+ ~Snapshot();
+ const void* read_bytes(void* buffer, std::size_t size,
+ std::uint64_t address, int process_index = ProcessIndexAny,
+ ReadMode mode = Normal) override;
+public: // To be private
mc_process_t process;
int num_state;
- s_mc_address_space_t address_space;
size_t heap_bytes_used;
mc_mem_region_t* snapshot_regions;
size_t snapshot_regions_count;
fd_infos_t *current_fd;
};
+}
+}
+
+extern "C" {
+
static inline __attribute__ ((always_inline))
mc_mem_region_t mc_get_region_hinted(void* addr, mc_snapshot_t snapshot, int process_index, mc_mem_region_t region)
{
XBT_INTERNAL mc_snapshot_t MC_take_snapshot(int num_state);
XBT_INTERNAL void MC_restore_snapshot(mc_snapshot_t);
-XBT_INTERNAL void MC_free_snapshot(mc_snapshot_t);
XBT_INTERNAL size_t* mc_take_page_snapshot_region(mc_process_t process,
void* data, size_t page_count);
MC_SHOULD_BE_INTERNAL const void* MC_region_read_fragmented(
mc_mem_region_t region, void* target, const void* addr, size_t size);
-XBT_INTERNAL const void* MC_snapshot_read(mc_snapshot_t snapshot,
- adress_space_read_flags_t flags,
- void* target, const void* addr, size_t size, int process_index);
+// Deprecated compatibility wrapper
+static inline
+const void* MC_snapshot_read(mc_snapshot_t snapshot,
+ simgrid::mc::AddressSpace::ReadMode mode,
+ void* target, const void* addr, size_t size, int process_index)
+{
+ return snapshot->read_bytes(target, size, (uint64_t)addr, process_index, mode);
+}
MC_SHOULD_BE_INTERNAL int MC_snapshot_region_memcmp(
const void* addr1, mc_mem_region_t region1,
const void* addr2, mc_mem_region_t region2, size_t size);
*/
void MC_state_delete(mc_state_t state, int free_snapshot){
if (state->system_state && free_snapshot){
- MC_free_snapshot(state->system_state);
+ delete state->system_state;
}
if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
xbt_free(state->index_comm);
int mc_unw_init_context(
mc_unw_context_t context, mc_process_t process, unw_context_t* c)
{
- context->address_space = (mc_address_space_t) process;
+ context->address_space = process;
context->process = process;
// Take a copy of the context for our own purpose:
return -UNW_EUNSPEC;
mc_address_space_t as = context->address_space;
- // Use local unwinding for current process:
- if (MC_is_process(as) && MC_process_is_self((mc_process_t) as))
+ mc_process_t process = dynamic_cast<mc_process_t>(as);
+ if (process && MC_process_is_self(process))
return unw_init_local(cursor, &context->context);
return unw_init_remote(cursor, context->process->unw_addr_space, context);
void visited_state_free(mc_visited_state_t state)
{
if (state) {
- if(!is_exploration_stack_state(state)){
- MC_free_snapshot(state->system_state);
- }
+ if(!is_exploration_stack_state(state))
+ delete state->system_state;
xbt_free(state);
}
}
#include "smx_private.h"
#ifdef HAVE_MC
-#include "mc/mc_process.h"
+#include "mc/mc_forward.h"
#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);
fd.write('#include "smx_private.h"\n');
fd.write('#ifdef HAVE_MC\n');
- fd.write('#include "mc/mc_process.h"\n');
+ fd.write('#include "mc/mc_forward.h"\n');
fd.write('#endif\n');
fd.write('\n');
fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n');
dw_variable_t var;
dw_type_t type;
- s_mc_process_t p;
+ s_mc_process_t p(getpid(), -1);
mc_process_t process = &p;
- MC_process_init(&p, getpid(), -1);
test_global_variable(process, process->binary_info, "some_local_variable", &some_local_variable, sizeof(int));
if(HAVE_MC)
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
- add_executable(dwarf-expression dwarf_expression.c)
+ add_executable(dwarf-expression dwarf_expression.cpp)
target_link_libraries(dwarf-expression simgrid)
endif()
)
set(testsuite_src
${testsuite_src}
- ${CMAKE_CURRENT_SOURCE_DIR}/dwarf_expression.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/dwarf_expression.cpp
PARENT_SCOPE
)
#include "../src/mc/mc_private.h"
#include "../src/mc/mc_object_info.h"
-static s_mc_process_t process;
+static mc_process_t process;
static
uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a, uintptr_t b) {
}
int main(int argc, char** argv) {
- MC_process_init(&process, getpid(), -1);
+ process = new simgrid::mc::Process(getpid(), -1);
s_mc_expression_state_t state;
memset(&state, 0, sizeof(s_mc_expression_state_t));
- state.address_space = (mc_address_space_t) &process;
+ state.address_space = (mc_address_space_t) process;
basic_test(&state);