Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9e9af73d5937ea694123617bd891c7ef650d924f
[simgrid.git] / src / mc / inspect / mc_member.cpp
1 /* Copyright (c) 2014-2023. 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::dwarf {
11
12 /** Resolve snapshot in the process address space
13  *
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 nullptr)
18  * @return Process address of the given member of the 'object' struct/class
19  */
20 void* resolve_member(const void* base, const simgrid::mc::Type* /*type*/, const simgrid::mc::Member* member,
21                      const simgrid::mc::AddressSpace* address_space)
22 {
23   ExpressionContext state;
24   state.address_space = address_space;
25
26   ExpressionStack stack;
27   stack.push((ExpressionStack::value_type)base);
28   simgrid::dwarf::execute(member->location_expression, state, stack);
29   return (void*)stack.top();
30 }
31
32 } // namespace simgrid::dwarf