summaryrefslogtreecommitdiff
path: root/rts/Libdw.h
blob: 28c6312f7a8dd621f28cfad36323363f7466cb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2014-2015
 *
 * Producing stacktraces with DWARF unwinding using libdw..
 *
 * Do not #include this file directly: #include "Rts.h" instead.
 *
 * To understand the structure of the RTS headers, see the wiki:
 *   https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes
 *
 * -------------------------------------------------------------------------- */

#pragma once

#include "BeginPrivate.h"

#if USE_LIBDW

/* Begin a libdw session. A session is tied to a particular capability */
LibdwSession *libdwInit(void);

/* Free a session */
void libdwFree(LibdwSession *session);

// Traverse backtrace in order of outer-most to inner-most frame
#define FOREACH_FRAME_INWARDS(pc, bt)                                 \
    BacktraceChunk *_chunk;                                           \
    unsigned int _frame_idx;                                          \
    for (_chunk = &bt->frames; _chunk != NULL; _chunk = _chunk->next) \
        for (_frame_idx=0;                                            \
             pc = _chunk->frames[_frame_idx], _frame_idx < _chunk->n_frames; \
             _frame_idx++)

// Traverse a backtrace in order of inner-most to outer-most frame
int libdwForEachFrameOutwards(Backtrace *bt,
                              int (*cb)(StgPtr, void*),
                              void *user_data);

#endif /* USE_LIBDW */

#include "EndPrivate.h"