StackTrace.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, 2020 IBM Corp.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v2.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  * https://www.eclipse.org/legal/epl-2.0/
10  * and the Eclipse Distribution License is available at
11  * http://www.eclipse.org/org/documents/edl-v10.php.
12  *
13  * Contributors:
14  * Ian Craggs - initial API and implementation and/or initial documentation
15  *******************************************************************************/
16 
17 #ifndef STACKTRACE_H_
18 #define STACKTRACE_H_
19 
20 #if defined(HIGH_PERFORMANCE)
21 #define NOSTACKTRACE 1
22 #endif
23 
24 #include <stdio.h>
25 #include "Log.h"
26 #include "Thread.h"
27 
28 #if defined(NOSTACKTRACE)
29 #define FUNC_ENTRY
30 #define FUNC_ENTRY_NOLOG
31 #define FUNC_ENTRY_MED
32 #define FUNC_ENTRY_MAX
33 #define FUNC_EXIT
34 #define FUNC_EXIT_NOLOG
35 #define FUNC_EXIT_MED
36 #define FUNC_EXIT_MAX
37 #define FUNC_EXIT_RC(x)
38 #define FUNC_EXIT_MED_RC(x)
39 #define FUNC_EXIT_MAX_RC(x)
40 #else
41 #if defined(_WIN32) || defined(_WIN64)
42 #define inline __inline
43 #define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)
44 #define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)
45 #define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM)
46 #define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM)
47 #define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM)
48 #define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, NULL, -1)
49 #define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM)
50 #define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM)
51 #define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM)
52 #define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM)
53 #define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM)
54 #else
55 #define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM)
56 #define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1)
57 #define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM)
58 #define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM)
59 #define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM)
60 #define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1)
61 #define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM)
62 #define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM)
63 #define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM)
64 #define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM)
65 #define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM)
66 #endif
67 #endif
68 
69 void StackTrace_entry(const char* name, int line, enum LOG_LEVELS trace);
70 void StackTrace_exit(const char* name, int line, void* return_value, enum LOG_LEVELS trace);
71 
72 void StackTrace_printStack(FILE* dest);
73 char* StackTrace_get(thread_id_type, char* buf, int bufsize);
74 
75 #endif /* STACKTRACE_H_ */
void StackTrace_exit(const char *name, int line, void *return_value, enum LOG_LEVELS trace)
Definition: StackTrace.c:124
LOG_LEVELS
Definition: Log.h:35
char * StackTrace_get(thread_id_type, char *buf, int bufsize)
Definition: StackTrace.c:175
void StackTrace_entry(const char *name, int line, enum LOG_LEVELS trace)
Definition: StackTrace.c:106
const char * name
void StackTrace_printStack(FILE *dest)
Definition: StackTrace.c:145
#define thread_id_type
Definition: Thread.h:43


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:47