1 /* Copyright (c) 2014-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. */
9 #include "mc_object_info.h"
10 #include "mc_private.h"
11 #include "mc/Type.hpp"
13 /** Resolve snapshot in the process address space
15 * @param object Process address of the struct/class
16 * @param type Type of the struct/class
17 * @param member Member description
18 * @param snapshot Snapshot (or NULL)
19 * @return Process address of the given member of the 'object' struct/class
21 void *mc_member_resolve(
22 const void *base, simgrid::mc::Type* type, simgrid::mc::Member* member,
23 simgrid::mc::AddressSpace* address_space, int process_index)
25 // TODO, get rid of this?
26 if (!member->has_offset_location())
27 return ((char *) base) + member->offset();
29 s_mc_expression_state_t state;
30 memset(&state, 0, sizeof(s_mc_expression_state_t));
31 state.frame_base = NULL;
33 state.address_space = address_space;
35 state.stack[0] = (uintptr_t) base;
36 state.process_index = process_index;
38 if (simgrid::mc::execute(
39 member->location_expression, &state))
40 xbt_die("Error evaluating DWARF expression");
41 if (state.stack_size == 0)
42 xbt_die("No value on the stack");
44 return (void *) state.stack[state.stack_size - 1];