Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename smx_process to ActorImpl
[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 "src/mc/mc_private.h"
8 #include "src/mc/Type.hpp"
9 #include "src/mc/mc_dwarf.hpp"
10
11 namespace simgrid {
12 namespace dwarf {
13
14 /** Resolve snapshot in the process address space
15  *
16  * @param object   Process address of the struct/class
17  * @param type     Type of the struct/class
18  * @param member   Member description
19  * @param snapshot Snapshot (or nullptr)
20  * @return Process address of the given member of the 'object' struct/class
21  */
22 void *resolve_member(
23     const void *base, simgrid::mc::Type* type, simgrid::mc::Member* member,
24     simgrid::mc::AddressSpace* address_space, int process_index)
25 {
26   // TODO, get rid of this?
27   if (!member->has_offset_location())
28     return ((char *) base) + member->offset();
29
30   ExpressionContext state;
31   state.frame_base = nullptr;
32   state.cursor = nullptr;
33   state.address_space = address_space;
34   state.process_index = process_index;
35
36   ExpressionStack stack;
37   stack.push((ExpressionStack::value_type) base);
38   simgrid::dwarf::execute(member->location_expression, state, stack);
39   return (void*) stack.top();
40 }
41
42 }
43 }