Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5b01e582b29cb14d3310eb352538a82ec7c72dd3
[simgrid.git] / src / mc / inspect / mc_member.cpp
1 /* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/mc/inspect/Type.hpp"
7 #include "src/mc/inspect/mc_dwarf.hpp"
8 #include "src/mc/mc_private.hpp"
9
10 namespace simgrid {
11 namespace dwarf {
12
13 /** Resolve snapshot in the process address space
14  *
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 nullptr)
19  * @return Process address of the given member of the 'object' struct/class
20  */
21 void* resolve_member(const void* base, simgrid::mc::Type* /*type*/, simgrid::mc::Member* member,
22                      simgrid::mc::AddressSpace* address_space, int process_index)
23 {
24   ExpressionContext state;
25   state.frame_base    = nullptr;
26   state.cursor        = nullptr;
27   state.address_space = address_space;
28   state.process_index = process_index;
29
30   ExpressionStack stack;
31   stack.push((ExpressionStack::value_type)base);
32   simgrid::dwarf::execute(member->location_expression, state, stack);
33   return (void*)stack.top();
34 }
35
36 } // namespace dwarf
37 } // namespace simgrid