CmmLayoutStack: Add unwind information on stack fixups
[ghc.git] / rts / LibdwPool.c
1 /* ---------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2014-2015
4 *
5 * A pool of libdw sessions
6 *
7 * --------------------------------------------------------------------------*/
8
9 #include "Rts.h"
10 #include "RtsUtils.h"
11 #include "LibdwPool.h"
12
13 #if USE_LIBDW
14
15 #include <unistd.h>
16
17 #include "Pool.h"
18
19 /*
20 * Note [libdw session pool]
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~
22 *
23 * Building a libdw session requires a number of rather expensive steps,
24 *
25 * - Examine the object files mapped into the address space
26 * - Find them on disk
27 * - Open them and map their debugging information
28 * - Build various index structures necessary for quick lookup
29 *
30 * The time to setup a session can be several milliseconds. In order to avoid
31 * incurring this cost too often, we keep a pool of warm sessions around which
32 * can be shared between capabilities.
33 *
34 */
35
36 static Pool *pool = NULL;
37 static uint32_t pool_size = 10; // TODO
38
39 void libdwPoolInit(void) {
40 pool = poolInit(pool_size, pool_size,
41 (alloc_thing_fn) libdwInit,
42 (free_thing_fn) libdwFree);
43 }
44
45 LibdwSession *libdwPoolTake(void) {
46 return poolTryTake(pool);
47 }
48
49 void libdwPoolRelease(LibdwSession *sess) {
50 poolRelease(pool, sess);
51 }
52
53 void libdwPoolClear(void) {
54 poolFlush(pool);
55 }
56
57 #else /* !USE_LIBDW */
58
59 LibdwSession *libdwPoolTake(void) { return NULL; }
60
61 void libdwPoolRelease(LibdwSession *sess STG_UNUSED) { }
62
63 void libdwPoolClear(void) { }
64
65 #endif /* USE_LIBDW */