blob: b0de8ac7c31475ff040a721bafb04711f25a3d5a (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* ---------------------------------------------------------------------------
*
* (c) The GHC Team, 2014-2015
*
* A pool of libdw sessions
*
* --------------------------------------------------------------------------*/
#include "Rts.h"
#include "RtsUtils.h"
#include "LibdwPool.h"
#ifdef USE_LIBDW
#include <unistd.h>
#include "Pool.h"
/*
* Note [libdw session pool]
* ~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Building a libdw session requires a number of rather expensive steps,
*
* - Examine the object files mapped into the address space
* - Find them on disk
* - Open them and map their debugging information
* - Build various index structures necessary for quick lookup
*
* The time to setup a session can be several milliseconds. In order to avoid
* incurring this cost too often, we keep a pool of warm sessions around which
* can be shared between capabilities.
*
*/
static Pool *pool = NULL;
static nat pool_size = 10; // TODO
void libdwPoolInit(void) {
pool = poolInit(pool_size, pool_size,
(alloc_thing_fn) libdwInit,
(free_thing_fn) libdwFree);
}
LibdwSession *libdwPoolTake(void) {
return poolTryTake(pool);
}
void libdwPoolRelease(LibdwSession *sess) {
poolRelease(pool, sess);
}
void libdwPoolClear(void) {
poolFlush(pool);
}
#else /* !USE_LIBDW */
LibdwSession *libdwPoolTake(void) { return NULL; }
void libdwPoolRelease(LibdwSession *sess STG_UNUSED) { }
void libdwPoolClear(void) { }
#endif /* USE_LIBDW */
|