backtrace->contains_function takes multiple names, speeding up whitelist check drasti...
[strongswan.git] / src / libstrongswan / utils / backtrace.h
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup backtrace backtrace
18 * @{ @ingroup utils
19 */
20
21 #ifndef BACKTRACE_H_
22 #define BACKTRACE_H_
23
24 #include <stdio.h>
25
26 #include <library.h>
27
28 typedef struct backtrace_t backtrace_t;
29
30 /**
31 * A backtrace registers the frames on the stack during creation.
32 */
33 struct backtrace_t {
34
35 /**
36 * Log the backtrace to a FILE stream.
37 *
38 * @param file FILE to log backtrace to
39 * @param detailed TRUE to resolve line/file using addr2line (slow)
40 */
41 void (*log)(backtrace_t *this, FILE *file, bool detailed);
42
43 /**
44 * Check if the backtrace contains a frame having a function in a list.
45 *
46 * @param function name array
47 * @param number of elements in function array
48 * @return TRUE if one of the functions is in the stack
49 */
50 bool (*contains_function)(backtrace_t *this, char *function[], int count);
51
52 /**
53 * Destroy a backtrace instance.
54 */
55 void (*destroy)(backtrace_t *this);
56 };
57
58 /**
59 * Create a backtrace of the current stack.
60 *
61 * @param skip how many of the innerst frames to skip
62 * @return backtrace
63 */
64 backtrace_t *backtrace_create(int skip);
65
66 #endif /** BACKTRACE_H_ @}*/