1 /* Copyright (c) 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. */
9 #include "mc_object_info.h"
10 #include "mc_private.h"
12 /** Resolve snapshot in the process address space
14 * @param object Process address of the struct/class
15 * @param type Type of the struct/class
16 * @param member Member description
17 * @param snapshot Snapshot (or NULL)
18 * @return Process address of the given member of the 'object' struct/class
20 void *mc_member_resolve(const void *base, dw_type_t type, dw_type_t member,
21 mc_address_space_t address_space, int process_index)
23 if (!member->location.size) {
24 return ((char *) base) + member->offset;
27 s_mc_expression_state_t state;
28 memset(&state, 0, sizeof(s_mc_expression_state_t));
29 state.frame_base = NULL;
31 state.address_space = address_space;
33 state.stack[0] = (uintptr_t) base;
34 state.process_index = process_index;
36 if (mc_dwarf_execute_expression
37 (member->location.size, member->location.ops, &state))
38 xbt_die("Error evaluating DWARF expression");
39 if (state.stack_size == 0)
40 xbt_die("No value on the stack");
42 return (void *) state.stack[state.stack_size - 1];