cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / rts / Libdw.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2014-2015
4 *
5 * Producing stacktraces with DWARF unwinding using libdw..
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * -------------------------------------------------------------------------- */
13
14 #pragma once
15
16 #include "BeginPrivate.h"
17
18 #if USE_LIBDW
19
20 /* Begin a libdw session. A session is tied to a particular capability */
21 LibdwSession *libdwInit(void);
22
23 /* Free a session */
24 void libdwFree(LibdwSession *session);
25
26 /* Pretty-print a backtrace to std*/
27 void libdwPrintBacktrace(LibdwSession *session, FILE *file, Backtrace *bt);
28
29 // Traverse backtrace in order of outer-most to inner-most frame
30 #define FOREACH_FRAME_INWARDS(pc, bt) \
31 BacktraceChunk *_chunk; \
32 unsigned int _frame_idx; \
33 for (_chunk = &bt->frames; _chunk != NULL; _chunk = _chunk->next) \
34 for (_frame_idx=0; \
35 pc = _chunk->frames[_frame_idx], _frame_idx < _chunk->n_frames; \
36 _frame_idx++)
37
38 // Traverse a backtrace in order of inner-most to outer-most frame
39 int libdwForEachFrameOutwards(Backtrace *bt,
40 int (*cb)(StgPtr, void*),
41 void *user_data);
42
43 #endif /* USE_LIBDW */
44
45 #include "EndPrivate.h"