X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Flib-logging.c;h=8b16a011e2b2286e60e9c509e518313ae4a14698;hb=68b66a256a54d32992dfefeaad11eea88b7df234;hp=11ba9e71ce443a622b3f23f32a69d2d103f8e5ca;hpb=c9fe7f23d9609caf13253debd50f10a820d8de8f;p=babeltrace.git diff --git a/lib/lib-logging.c b/lib/lib-logging.c index 11ba9e71..8b16a011 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -30,48 +30,48 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define LIB_LOGGING_BUF_SIZE (4096 * 4) @@ -100,10 +100,12 @@ static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE]; #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL) +#define TMP_PREFIX_LEN 64 #define SET_TMP_PREFIX(_prefix2) \ do { \ - strcpy(tmp_prefix, prefix); \ - strcat(tmp_prefix, (_prefix2)); \ + snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s", \ + prefix, (_prefix2)); \ + tmp_prefix[TMP_PREFIX_LEN - 1] = '\0'; \ } while (0) static inline void format_component(char **buf_ch, bool extended, @@ -185,7 +187,7 @@ static inline void format_array_field_class(char **buf_ch, static inline void format_field_class(char **buf_ch, bool extended, const char *prefix, const struct bt_field_class *field_class) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %stype=%s", PRFIELD(bt_common_field_class_type_string(field_class->type))); @@ -472,7 +474,7 @@ static inline void format_trace_class(char **buf_ch, bool extended, static inline void format_trace(char **buf_ch, bool extended, const char *prefix, const struct bt_trace *trace) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (trace->name.value) { BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value)); @@ -503,7 +505,7 @@ static inline void format_stream_class(char **buf_ch, bool extended, const struct bt_stream_class *stream_class) { const struct bt_trace_class *trace_class; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id)); @@ -532,9 +534,21 @@ static inline void format_stream_class(char **buf_ch, bool extended, return; } - BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d", + BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, " + "%spackets-have-default-beginning-cs=%d, " + "%spackets-have-default-end-cs=%d, " + "%ssupports-discarded-events=%d, " + "%sdiscarded-events-have-default-cs=%d, " + "%ssupports-discarded-packets=%d, " + "%sdiscarded-packets-have-default-cs=%d", PRFIELD(stream_class->assigns_automatic_event_class_id), - PRFIELD(stream_class->assigns_automatic_stream_id)); + PRFIELD(stream_class->assigns_automatic_stream_id), + PRFIELD(stream_class->packets_have_beginning_default_clock_snapshot), + PRFIELD(stream_class->packets_have_end_default_clock_snapshot), + PRFIELD(stream_class->supports_discarded_events), + PRFIELD(stream_class->discarded_events_have_default_clock_snapshots), + PRFIELD(stream_class->supports_discarded_packets), + PRFIELD(stream_class->discarded_packets_have_default_clock_snapshots)); BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); SET_TMP_PREFIX("trace-class-"); format_trace_class(buf_ch, false, tmp_prefix, trace_class); @@ -548,7 +562,7 @@ static inline void format_event_class(char **buf_ch, bool extended, { const struct bt_stream_class *stream_class; const struct bt_trace_class *trace_class; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id)); @@ -605,7 +619,7 @@ static inline void format_stream(char **buf_ch, bool extended, const struct bt_stream_class *stream_class; const struct bt_trace_class *trace_class = NULL; const struct bt_trace *trace = NULL; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id)); @@ -647,7 +661,7 @@ static inline void format_packet(char **buf_ch, bool extended, { const struct bt_stream *stream; const struct bt_trace_class *trace_class; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (!extended) { return; @@ -681,7 +695,7 @@ static inline void format_event(char **buf_ch, bool extended, const struct bt_stream *stream; const struct bt_trace_class *trace_class; const struct bt_stream_class *stream_class; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (!extended) { return; @@ -742,7 +756,7 @@ static inline void format_event(char **buf_ch, bool extended, static inline void format_clock_class(char **buf_ch, bool extended, const char *prefix, const struct bt_clock_class *clock_class) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (clock_class->name.value) { BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value)); @@ -781,7 +795,7 @@ static inline void format_clock_class(char **buf_ch, bool extended, static inline void format_clock_snapshot(char **buf_ch, bool extended, const char *prefix, const struct bt_clock_snapshot *clock_snapshot) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, PRFIELD(clock_snapshot->value_cycles), PRFIELD(clock_snapshot->ns_from_origin)); @@ -869,7 +883,7 @@ static inline void format_value(char **buf_ch, bool extended, static inline void format_message(char **buf_ch, bool extended, const char *prefix, const struct bt_message *msg) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %stype=%s", PRFIELD(bt_message_type_string(msg->type))); @@ -1008,7 +1022,7 @@ static inline void format_component_class(char **buf_ch, bool extended, const char *prefix, const struct bt_component_class *comp_class) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %stype=%s, %sname=\"%s\"", PRFIELD(bt_component_class_type_string(comp_class->type)), @@ -1035,7 +1049,7 @@ static inline void format_component_class(char **buf_ch, bool extended, static inline void format_component(char **buf_ch, bool extended, const char *prefix, const struct bt_component *component) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %sname=\"%s\"", PRFIELD_GSTRING(component->name)); @@ -1064,7 +1078,7 @@ static inline void format_component(char **buf_ch, bool extended, static inline void format_port(char **buf_ch, bool extended, const char *prefix, const struct bt_port *port) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %stype=%s, %sname=\"%s\"", PRFIELD(bt_port_type_string(port->type)), @@ -1083,7 +1097,7 @@ static inline void format_port(char **buf_ch, bool extended, static inline void format_connection(char **buf_ch, bool extended, const char *prefix, const struct bt_connection *connection) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (!extended) { return; @@ -1105,7 +1119,7 @@ static inline void format_connection(char **buf_ch, bool extended, static inline void format_graph(char **buf_ch, bool extended, const char *prefix, const struct bt_graph *graph) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, " "%sconfig-state=%s", @@ -1143,7 +1157,7 @@ static inline void format_message_iterator(char **buf_ch, const struct bt_message_iterator *iterator) { const char *type; - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) { type = "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT"; @@ -1207,7 +1221,7 @@ static inline void format_message_iterator(char **buf_ch, static inline void format_plugin(char **buf_ch, bool extended, const char *prefix, const struct bt_plugin *plugin) { - char tmp_prefix[64]; + char tmp_prefix[TMP_PREFIX_LEN]; BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin->type)));