1 /* Copyright (c) 2015. The SimGrid Team.
3 / * All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
12 * Libunwind implementation for the model-checker
14 * Libunwind provides an pluggable stack unwinding API: the way the current
15 * registers and memory is accessed, the way unwinding informations is found
18 * This component implements the libunwind API for he model-checker:
20 * * reading memory from a mc_address_space_t;
22 * * reading stack registers from a saved snapshot (context).
24 * Parts of the libunwind information fetching is currently handled by the
25 * standard `libunwind` implementations (either the local one or the ptrace one)
26 * because parsing `.eh_frame` section is not fun and `libdw` does not help
30 #include "mc_process.h"
34 // ***** Libunwind namespace
36 /** Virtual table for our `libunwind-process_vm_readv` implementation.
38 * This implementation reuse most the code of `libunwind-ptrace` but
39 * does not use ptrace() to read the target process memory by
40 * `process_vm_readv()` or `/dev/${pid}/mem` if possible.
42 * Does not support any MC-specific behaviour (privatisation, snapshots)
45 * It works with `void*` contexts allocated with `_UPT_create(pid)`.
47 extern unw_accessors_t mc_unw_vmread_accessors;
49 /** Virtual table for our `libunwind` implementation
51 * Stack unwinding on a `mc_process_t` (for memory, unwinding information)
52 * and `ucontext_t` (for processor registers).
54 * It works with the `s_mc_unw_context_t` context.
56 extern XBT_INTERNAL unw_accessors_t mc_unw_accessors;
58 // ***** Libunwind context
60 /** A `libunwind` context
62 typedef struct s_mc_unw_context {
63 mc_address_space_t address_space;
65 unw_context_t context;
66 } s_mc_unw_context_t, *mc_unw_context_t;
68 /** Initialises an already allocated context */
69 XBT_INTERNAL int mc_unw_init_context(
70 mc_unw_context_t context, mc_process_t process, unw_context_t* c);
72 // ***** Libunwind cursor
74 /** Initialises a `libunwind` cursor */
75 XBT_INTERNAL int mc_unw_init_cursor(unw_cursor_t *cursor, mc_unw_context_t context);