1 /* Copyright (c) 2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMGRID_MC_UNW_H
8 #define SIMGRID_MC_UNW_H
11 * Libunwind implementation for the model-checker
13 * Libunwind provides an pluggable stack unwinding API: the way the current
14 * registers and memory is accessed, the way unwinding informations is found
17 * This component implements the libunwind API for he model-checker:
19 * * reading memory from a simgrid::mc::AddressSpace*;
21 * * reading stack registers from a saved snapshot (context).
23 * Parts of the libunwind information fetching is currently handled by the
24 * standard `libunwind` implementations (either the local one or the ptrace one)
25 * because parsing `.eh_frame` section is not fun and `libdw` does not help
29 #include "mc_process.h"
33 // ***** Libunwind namespace
35 /** Virtual table for our `libunwind-process_vm_readv` implementation.
37 * This implementation reuse most the code of `libunwind-ptrace` but
38 * does not use ptrace() to read the target process memory by
39 * `process_vm_readv()` or `/dev/${pid}/mem` if possible.
41 * Does not support any MC-specific behaviour (privatisation, snapshots)
44 * It works with `void*` contexts allocated with `_UPT_create(pid)`.
46 extern unw_accessors_t mc_unw_vmread_accessors;
48 /** Virtual table for our `libunwind` implementation
50 * Stack unwinding on a `simgrid::mc::Process*` (for memory, unwinding information)
51 * and `ucontext_t` (for processor registers).
53 * It works with the `s_mc_unw_context_t` context.
55 extern XBT_INTERNAL unw_accessors_t mc_unw_accessors;
57 // ***** Libunwind context
59 /** A `libunwind` context
61 typedef struct s_mc_unw_context {
62 simgrid::mc::AddressSpace* address_space;
63 simgrid::mc::Process* process;
64 unw_context_t context;
65 } s_mc_unw_context_t, *mc_unw_context_t;
67 /** Initialises an already allocated context */
68 XBT_INTERNAL int mc_unw_init_context(
69 mc_unw_context_t context, simgrid::mc::Process* process, unw_context_t* c);
71 // ***** Libunwind cursor
73 /** Initialises a `libunwind` cursor */
74 XBT_INTERNAL int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context);