Python bindings: add has_intersection property to TraceCollection
[babeltrace.git] / include / babeltrace / trace-debuginfo.h
1 #ifndef _BABELTRACE_TRACE_DEBUGINFO_H
2 #define _BABELTRACE_TRACE_DEBUGINFO_H
3
4 /*
5 * Babeltrace - Debug information state tracker wrapper
6 *
7 * Copyright (c) 2015 EfficiOS Inc.
8 * Copyright (c) 2015 Antoine Busque <abusque@efficios.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29 #include <babeltrace/ctf-ir/metadata.h>
30
31 #ifdef ENABLE_DEBUGINFO
32
33 #include <babeltrace/debuginfo.h>
34 #include <babeltrace/ctf-text/types.h>
35 #include <stdbool.h>
36
37 static inline
38 void ctf_text_integer_write_debug_info(struct bt_stream_pos *ppos,
39 struct bt_definition *definition)
40 {
41 struct definition_integer *integer_definition =
42 container_of(definition, struct definition_integer, p);
43 struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
44 struct debug_info_source *debug_info_src =
45 integer_definition->debug_info_src;
46
47 /* Print debug info if available */
48 if (debug_info_src) {
49 if (debug_info_src->func || debug_info_src->src_path ||
50 debug_info_src->bin_path) {
51 bool add_comma = false;
52
53 fprintf(pos->fp, ", debug_info = { ");
54
55 if (debug_info_src->bin_path) {
56 fprintf(pos->fp, "bin = \"%s%s\"",
57 opt_debug_info_full_path ?
58 debug_info_src->bin_path :
59 debug_info_src->short_bin_path,
60 debug_info_src->bin_loc);
61 add_comma = true;
62 }
63
64 if (debug_info_src->func) {
65 if (add_comma) {
66 fprintf(pos->fp, ", ");
67 }
68
69 fprintf(pos->fp, "func = \"%s\"",
70 debug_info_src->func);
71 }
72
73 if (debug_info_src->src_path) {
74 if (add_comma) {
75 fprintf(pos->fp, ", ");
76 }
77
78 fprintf(pos->fp, "src = \"%s:%" PRIu64
79 "\"",
80 opt_debug_info_full_path ?
81 debug_info_src->src_path :
82 debug_info_src->short_src_path,
83 debug_info_src->line_no);
84 }
85
86 fprintf(pos->fp, " }");
87 }
88 }
89 }
90
91 static inline
92 int trace_debug_info_create(struct ctf_trace *trace)
93 {
94 int ret = 0;
95
96 if (strcmp(trace->env.domain, "ust") != 0) {
97 goto end;
98 }
99
100 if (strcmp(trace->env.tracer_name, "lttng-ust") != 0) {
101 goto end;
102 }
103
104 trace->debug_info = debug_info_create();
105 if (!trace->debug_info) {
106 ret = -1;
107 goto end;
108 }
109
110 end:
111 return ret;
112 }
113
114 static inline
115 void trace_debug_info_destroy(struct ctf_trace *trace)
116 {
117 debug_info_destroy(trace->debug_info);
118 }
119
120 static inline
121 void handle_debug_info_event(struct ctf_stream_declaration *stream_class,
122 struct ctf_event_definition *event)
123 {
124 debug_info_handle_event(stream_class->trace->debug_info, event);
125 }
126
127 #else /* #ifdef ENABLE_DEBUGINFO */
128
129 static inline
130 void ctf_text_integer_write_debug_info(struct bt_stream_pos *ppos,
131 struct bt_definition *definition)
132 {
133 /* Do nothing. */
134 }
135
136 static inline
137 int trace_debug_info_create(struct ctf_trace *trace)
138 {
139 return 0;
140 }
141
142 static inline
143 void trace_debug_info_destroy(struct ctf_trace *trace)
144 {
145 /* Do nothing. */
146 }
147
148 static inline
149 void handle_debug_info_event(struct ctf_stream_declaration *stream_class,
150 struct ctf_event_definition *event)
151 {
152 /* Do nothing. */
153 }
154
155 #endif /* #else #ifdef ENABLE_DEBUGINFO */
156
157 #endif /* _BABELTRACE_TRACE_DEBUGINFO_H */
This page took 0.031698 seconds and 4 git commands to generate.