1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  *                         University Research and Technology
5  *                         Corporation.  All rights reserved.
6  * Copyright (c) 2004-2005 The University of Tennessee and The University
7  *                         of Tennessee Research Foundation.  All rights
8  *                         reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  *                         University of Stuttgart.  All rights reserved.
11  * Copyright (c) 2004-2006 The Regents of the University of California.
12  *                         All rights reserved.
13  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
14  *                         reserved.
15  * Copyright (c) 2017      IBM Corporation.  All rights reserved.
16  * $COPYRIGHT$
17  *
18  * Additional copyrights may follow
19  *
20  * $HEADER$
21  */
22 
23 #ifndef OPAL_MCA_BACKTRACE_BACKTRACE_H
24 #define OPAL_MCA_BACKTRACE_BACKTRACE_H
25 
26 #include "opal_config.h"
27 
28 #include "opal/mca/mca.h"
29 #include "opal/mca/base/base.h"
30 #include "opal/util/stacktrace.h"
31 
32 BEGIN_C_DECLS
33 
34 /*
35  * Most of this file is just for ompi_info.  There are two interface
36  * functions, both of which are called directly.  The joy of link-time
37  * components.
38  */
39 
40 
41 /*
42  * Print back trace to FILE file with a prefix for each line.
43  * First strip lines are not printed.
44  * If 'file' is NULL then the component should try to use the file descriptor
45  * saved in opal_stacktrace_output_fileno
46  *
47  * \note some attempts made to be signal safe.
48  */
49 OPAL_DECLSPEC int opal_backtrace_print(FILE *file, char *prefix, int strip);
50 
51 /*
52  * Return back trace in buffer.  buffer will be allocated by the
53  * backtrace component, but should be free'ed by the caller.
54  *
55  * \note Probably bad to call this from a signal handler.
56  *
57  */
58 OPAL_DECLSPEC int opal_backtrace_buffer(char*** messages, int *len);
59 
60 
61 /**
62  * Structure for backtrace components.
63  */
64 struct opal_backtrace_base_component_2_0_0_t {
65     /** MCA base component */
66     mca_base_component_t backtracec_version;
67     /** MCA base data */
68     mca_base_component_data_t backtracec_data;
69 };
70 /**
71  * Convenience typedef
72  */
73 typedef struct opal_backtrace_base_component_2_0_0_t opal_backtrace_base_component_2_0_0_t;
74 
75 /*
76  * Macro for use in components that are of type backtrace
77  */
78 #define OPAL_BACKTRACE_BASE_VERSION_2_0_0 \
79     OPAL_MCA_BASE_VERSION_2_1_0("backtrace", 2, 0, 0)
80 
81 END_C_DECLS
82 
83 #endif /* OPAL_MCA_BACKTRACE_BACKTRACE_H */
84