ref_reg = mc_model_checker->parent_snapshot->snapshot_regions[index];
mc_mem_region_t region;
- const bool privatization_aware = object_info && MC_object_info_executable(object_info);
- if (privatization_aware && smpi_privatize_global_variables && smpi_process_count())
+ const bool privatization_aware = MC_object_info_is_privatized(object_info);
+ if (privatization_aware && smpi_process_count())
region = MC_region_new_privatized(type, start_addr, permanent_addr, size, ref_reg);
else
region = MC_region_new(type, start_addr, permanent_addr, size, ref_reg);
i++;
}
+ result->start = result->start_rw;
+ if ((const void*) result->start_ro > result->start)
+ result->start = result->start_ro;
+ if ((const void*) result->start_exec > result->start)
+ result->start = result->start_exec;
+
+ result->end = result->end_rw;
+ if (result->end_ro && (const void*) result->end_ro < result->end)
+ result->end = result->end_ro;
+ if (result->end_exec && (const void*) result->end_exec > result->end)
+ result->end = result->end_exec;
+
xbt_assert(result->file_name);
xbt_assert(result->start_rw);
xbt_assert(result->start_exec);
#include "mc_object_info.h"
#include "mc_private.h"
-dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, void *ip)
+dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
{
xbt_dynar_t dynar = info->functions_index;
mc_function_index_item_t base =
#define MC_OBJECT_INFO_H
#include <stdint.h>
+#include <stdbool.h>
#include <simgrid_config.h>
#include <xbt/dict.h>
#include "mc_forward.h"
#include "mc_location.h"
#include "mc_process.h"
+#include "../smpi/private.h"
SG_BEGIN_DECL();
struct s_mc_object_info {
enum mc_object_info_flags flags;
char* file_name;
+ const void* start, *end;
char *start_exec, *end_exec; // Executable segment
char *start_rw, *end_rw; // Read-write segment
char *start_ro, *end_ro; // read-only segment
return info->flags & MC_OBJECT_INFO_EXECUTABLE;
}
+static inline __attribute__ ((always_inline))
+bool MC_object_info_is_privatized(mc_object_info_t info)
+{
+ return info && MC_object_info_executable(info) && smpi_privatize_global_variables;
+}
+
/** Find the DWARF offset for this ELF object
*
* An offset is applied to address found in DWARF:
mc_object_info_t MC_find_object_info(memory_map_t maps, const char* name, int executable);
void MC_free_object_info(mc_object_info_t* p);
-dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, void *ip);
+dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip);
dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name);
void MC_post_process_object_info(mc_process_t process, mc_object_info_t info);
XBT_INFO("Get debug information done !");
}
-mc_object_info_t MC_process_find_object_info(mc_process_t process, void *ip)
+mc_object_info_t MC_process_find_object_info(mc_process_t process, const void *addr)
{
size_t i;
for (i = 0; i != process->object_infos_size; ++i) {
- if (ip >= (void *) process->object_infos[i]->start_exec
- && ip <= (void *) process->object_infos[i]->end_exec) {
+ if (addr >= (void *) process->object_infos[i]->start
+ && addr <= (void *) process->object_infos[i]->end) {
+ return process->object_infos[i];
+ }
+ }
+ return NULL;
+}
+
+mc_object_info_t MC_process_find_object_info_exec(mc_process_t process, const void *addr)
+{
+ size_t i;
+ for (i = 0; i != process->object_infos_size; ++i) {
+ if (addr >= (void *) process->object_infos[i]->start_exec
+ && addr <= (void *) process->object_infos[i]->end_exec) {
+ return process->object_infos[i];
+ }
+ }
+ return NULL;
+}
+
+mc_object_info_t MC_process_find_object_info_rw(mc_process_t process, const void *addr)
+{
+ size_t i;
+ for (i = 0; i != process->object_infos_size; ++i) {
+ if (addr >= (void *) process->object_infos[i]->start_rw
+ && addr <= (void *) process->object_infos[i]->end_rw) {
return process->object_infos[i];
}
}
// Functions, variables…
-dw_frame_t MC_process_find_function(mc_process_t process, void *ip)
+dw_frame_t MC_process_find_function(mc_process_t process, const void *ip)
{
- mc_object_info_t info = MC_process_find_object_info(process, ip);
+ mc_object_info_t info = MC_process_find_object_info_exec(process, ip);
if (info == NULL)
return NULL;
else
void* local, const void* remote, size_t len,
int process_index)
{
- if (process_index != MC_PROCESS_INDEX_DISABLED)
- xbt_die("Not implemented yet");
+ if (process_index != MC_PROCESS_INDEX_DISABLED) {
+ mc_object_info_t info = MC_process_find_object_info_rw(process, remote);
+ // 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;
+ }
+ }
if (MC_process_is_self(process)) {
if (flags & MC_ADDRESS_SPACE_READ_FLAGS_LAZY)
/* Functions, variables of the process: */
-mc_object_info_t MC_process_find_object_info(mc_process_t process, void* ip);
-dw_frame_t MC_process_find_function(mc_process_t process, void* ip);
+mc_object_info_t MC_process_find_object_info(mc_process_t process, const void* addr);
+mc_object_info_t MC_process_find_object_info_exec(mc_process_t process, const void* addr);
+mc_object_info_t MC_process_find_object_info_rw(mc_process_t process, const void* addr);
+
+dw_frame_t MC_process_find_function(mc_process_t process, const void* ip);
static inline xbt_mheap_t MC_process_get_heap(mc_process_t process)
{