Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / mc / mc_member.cpp
1 /* Copyright (c) 2014-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <xbt/misc.h>
8
9 #include "src/mc/mc_object_info.h"
10 #include "src/mc/mc_private.h"
11 #include "src/mc/Type.hpp"
12 #include "src/mc/mc_dwarf.hpp"
13
14
15 namespace simgrid {
16 namespace dwarf {
17
18 /** Resolve snapshot in the process address space
19  *
20  * @param object   Process address of the struct/class
21  * @param type     Type of the struct/class
22  * @param member   Member description
23  * @param snapshot Snapshot (or NULL)
24  * @return Process address of the given member of the 'object' struct/class
25  */
26 void *resolve_member(
27     const void *base, simgrid::mc::Type* type, simgrid::mc::Member* member,
28     simgrid::mc::AddressSpace* address_space, int process_index)
29 {
30   // TODO, get rid of this?
31   if (!member->has_offset_location())
32     return ((char *) base) + member->offset();
33
34   ExpressionContext state;
35   state.frame_base = NULL;
36   state.cursor = NULL;
37   state.address_space = address_space;
38   state.process_index = process_index;
39
40   ExpressionStack stack;
41   stack.push((ExpressionStack::value_type) base);
42   simgrid::dwarf::execute(member->location_expression, state, stack);
43   return (void*) stack.top();
44 }
45
46 }
47 }