X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Ftrace-debuginfo.h;fp=include%2Fbabeltrace%2Ftrace-debuginfo.h;h=adbad09d6c6533082aaafb0374f750706c464cee;hb=c40a57e579977be9eb7682480428a89af5ca529c;hp=0000000000000000000000000000000000000000;hpb=220e0cbec97669ccfe4ed8a7e69c73c9ac72062d;p=babeltrace.git diff --git a/include/babeltrace/trace-debuginfo.h b/include/babeltrace/trace-debuginfo.h new file mode 100644 index 00000000..adbad09d --- /dev/null +++ b/include/babeltrace/trace-debuginfo.h @@ -0,0 +1,142 @@ +#ifndef _BABELTRACE_TRACE_DEBUGINFO_H +#define _BABELTRACE_TRACE_DEBUGINFO_H + +/* + * Babeltrace - Debug information state tracker wrapper + * + * Copyright (c) 2015 EfficiOS Inc. + * Copyright (c) 2015 Antoine Busque + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#ifdef ENABLE_DEBUGINFO + +#include +#include +#include + +static inline +void ctf_text_integer_write_debug_info(struct bt_stream_pos *ppos, + struct bt_definition *definition) +{ + struct definition_integer *integer_definition = + container_of(definition, struct definition_integer, p); + struct ctf_text_stream_pos *pos = ctf_text_pos(ppos); + struct debug_info_source *debug_info_src = + integer_definition->debug_info_src; + + /* Print debug info if available */ + if (debug_info_src) { + if (debug_info_src->func || debug_info_src->filename) { + bool add_comma = false; + + fprintf(pos->fp, ", debug_info = { "); + + if (debug_info_src->func) { + fprintf(pos->fp, "func = \"%s\"", + debug_info_src->func); + add_comma = true; + } + + if (debug_info_src->filename) { + if (add_comma) { + fprintf(pos->fp, ", "); + } + + fprintf(pos->fp, "source_loc = \"%s:%" PRIu64 + "\"", + debug_info_src->filename, + debug_info_src->line_no); + } + + fprintf(pos->fp, " }"); + } + } +} + +static inline +int trace_debug_info_create(struct ctf_trace *trace) +{ + int ret = 0; + + if (strcmp(trace->env.domain, "ust") != 0) { + goto end; + } + + if (strcmp(trace->env.tracer_name, "lttng-ust") != 0) { + goto end; + } + + trace->debug_info = debug_info_create(); + if (!trace->debug_info) { + ret = -1; + goto end; + } + +end: + return ret; +} + +static inline +void trace_debug_info_destroy(struct ctf_trace *trace) +{ + debug_info_destroy(trace->debug_info); +} + +static inline +void handle_debug_info_event(struct ctf_stream_declaration *stream_class, + struct ctf_event_definition *event) +{ + debug_info_handle_event(stream_class->trace->debug_info, event); +} + +#else /* #ifdef ENABLE_DEBUGINFO */ + +static inline +void ctf_text_integer_write_debug_info(struct bt_stream_pos *ppos, + struct bt_definition *definition) +{ + /* Do nothing. */ +} + +static inline +int trace_debug_info_create(struct ctf_trace *trace) +{ + return 0; +} + +static inline +void trace_debug_info_destroy(struct ctf_trace *trace) +{ + /* Do nothing. */ +} + +static inline +void handle_debug_info_event(struct ctf_stream_declaration *stream_class, + struct ctf_event_definition *event) +{ + /* Do nothing. */ +} + +#endif /* #else #ifdef ENABLE_DEBUGINFO */ + +#endif /* _BABELTRACE_TRACE_DEBUGINFO_H */