Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9d804543dc85b8c2ec459dfd1c545aabff164520
[simgrid.git] / src / mc / inspect / Frame.cpp
1 /* Copyright (c) 2007-2023. 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 <libunwind.h>
8
9 #include "xbt/sysdep.h"
10
11 #include "src/mc/inspect/Frame.hpp"
12
13 namespace simgrid::mc {
14
15 void* Frame::frame_base(unw_cursor_t& unw_cursor) const
16 {
17   simgrid::dwarf::Location location =
18       simgrid::dwarf::resolve(frame_base_location, object_info, &unw_cursor, nullptr, nullptr);
19   if (location.in_memory())
20     return location.address();
21   else if (location.in_register()) {
22     // This is a special case.
23     // The register is not the location of the frame base
24     // (a frame base cannot be located in a register).
25     // Instead, DWARF defines this to mean that the register
26     // contains the address of the frame base.
27     unw_word_t word;
28     unw_get_reg(&unw_cursor, location.register_id(), &word);
29     return (void*)word;
30   } else
31     xbt_die("Unexpected location type");
32 }
33
34 } // namespace simgrid::mc