Fix: prevent uninitialized use of elf_file
[babeltrace.git] / include / babeltrace / trace-debuginfo.h
CommitLineData
b5a8598f
AB
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
37static inline
38void 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) {
ad2b5b38
JG
49 if (debug_info_src->func || debug_info_src->src_path ||
50 debug_info_src->bin_path) {
b5a8598f
AB
51 bool add_comma = false;
52
53 fprintf(pos->fp, ", debug_info = { ");
54
55 if (debug_info_src->func) {
56 fprintf(pos->fp, "func = \"%s\"",
57 debug_info_src->func);
58 add_comma = true;
59 }
60
ad2b5b38 61 if (debug_info_src->src_path) {
b5a8598f
AB
62 if (add_comma) {
63 fprintf(pos->fp, ", ");
64 }
65
458af89d 66 fprintf(pos->fp, "src = \"%s:%" PRIu64
b5a8598f 67 "\"",
458af89d 68 opt_debug_info_full_path ?
ad2b5b38
JG
69 debug_info_src->src_path :
70 debug_info_src->short_src_path,
b5a8598f
AB
71 debug_info_src->line_no);
72 }
73
ad2b5b38
JG
74 if (debug_info_src->bin_path) {
75 if (add_comma) {
76 fprintf(pos->fp, ", ");
77 }
78
79 fprintf(pos->fp, "bin = \"%s\"",
80 opt_debug_info_full_path ?
81 debug_info_src->bin_path :
82 debug_info_src->short_bin_path);
83 }
84
b5a8598f
AB
85 fprintf(pos->fp, " }");
86 }
87 }
88}
89
90static inline
91int trace_debug_info_create(struct ctf_trace *trace)
92{
93 int ret = 0;
94
95 if (strcmp(trace->env.domain, "ust") != 0) {
96 goto end;
97 }
98
99 if (strcmp(trace->env.tracer_name, "lttng-ust") != 0) {
100 goto end;
101 }
102
103 trace->debug_info = debug_info_create();
104 if (!trace->debug_info) {
105 ret = -1;
106 goto end;
107 }
108
109end:
110 return ret;
111}
112
113static inline
114void trace_debug_info_destroy(struct ctf_trace *trace)
115{
116 debug_info_destroy(trace->debug_info);
117}
118
119static inline
120void handle_debug_info_event(struct ctf_stream_declaration *stream_class,
121 struct ctf_event_definition *event)
122{
123 debug_info_handle_event(stream_class->trace->debug_info, event);
124}
125
126#else /* #ifdef ENABLE_DEBUGINFO */
127
128static inline
129void ctf_text_integer_write_debug_info(struct bt_stream_pos *ppos,
130 struct bt_definition *definition)
131{
132 /* Do nothing. */
133}
134
135static inline
136int trace_debug_info_create(struct ctf_trace *trace)
137{
138 return 0;
139}
140
141static inline
142void trace_debug_info_destroy(struct ctf_trace *trace)
143{
144 /* Do nothing. */
145}
146
147static inline
148void handle_debug_info_event(struct ctf_stream_declaration *stream_class,
149 struct ctf_event_definition *event)
150{
151 /* Do nothing. */
152}
153
154#endif /* #else #ifdef ENABLE_DEBUGINFO */
155
156#endif /* _BABELTRACE_TRACE_DEBUGINFO_H */
This page took 0.028197 seconds and 4 git commands to generate.