if (!v) {
fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__,
__FILE__, __LINE__);
+ goto end;
}
*v = DEBUG_INFO_UNKNOWN_STREAM;
g_hash_table_insert(di_trace->stream_states, stream, v);
+end:
return v;
}
void debug_info_close_trace(struct debug_info_iterator *debug_it,
struct debug_info_trace *di_trace)
{
- if (di_trace->static_listener_id > 0) {
+ if (di_trace->static_listener_id >= 0) {
bt_ctf_trace_remove_is_static_listener(di_trace->trace,
di_trace->static_listener_id);
}
struct debug_info_trace *di_trace)
{
struct bt_ctf_packet *writer_packet;
+ int ret;
writer_packet = bt_ctf_packet_create(writer_stream);
if (!writer_packet) {
fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__,
__FILE__, __LINE__);
- goto end;
+ goto error;
+ }
+
+ ret = ctf_packet_copy_header(debug_it->err, packet, writer_packet);
+ if (ret) {
+ fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__,
+ __FILE__, __LINE__);
+ goto error;
}
- g_hash_table_insert(di_trace->packet_map, (gpointer) packet, writer_packet);
+ g_hash_table_insert(di_trace->packet_map, (gpointer) packet,
+ writer_packet);
+ goto end;
+
+error:
+ BT_PUT(writer_packet);
end:
return writer_packet;
}
int ret_int;
const char *name = bt_ctf_stream_class_get_name(stream_class);
- if (strlen(name) == 0) {
- name = NULL;
- }
-
- writer_stream_class = bt_ctf_stream_class_create(name);
+ writer_stream_class = bt_ctf_stream_class_create_empty(name);
if (!writer_stream_class) {
fprintf(err, "[error] %s in %s:%d\n",
__func__, __FILE__, __LINE__);
}
type = bt_ctf_stream_class_get_packet_context_type(stream_class);
- if (!type) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
- }
-
- ret_int = bt_ctf_stream_class_set_packet_context_type(
- writer_stream_class, type);
- if (ret_int < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
+ if (type) {
+ ret_int = bt_ctf_stream_class_set_packet_context_type(
+ writer_stream_class, type);
+ if (ret_int < 0) {
+ fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
+ __LINE__);
+ goto error;
+ }
+ BT_PUT(type);
}
- BT_PUT(type);
type = bt_ctf_stream_class_get_event_header_type(stream_class);
- if (!type) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
- }
-
- ret_int = bt_ctf_stream_class_set_event_header_type(
- writer_stream_class, type);
- if (ret_int < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
+ if (type) {
+ ret_int = bt_ctf_stream_class_set_event_header_type(
+ writer_stream_class, type);
+ if (ret_int < 0) {
+ fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
+ __LINE__);
+ goto error;
+ }
+ BT_PUT(type);
}
- BT_PUT(type);
type = bt_ctf_stream_class_get_event_context_type(stream_class);
if (type) {
for (i = 0; i < clock_class_count; i++) {
struct bt_ctf_clock_class *clock_class =
bt_ctf_trace_get_clock_class_by_index(trace, i);
+ struct bt_ctf_clock_class *existing_clock_class = NULL;
if (!clock_class) {
fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
goto error;
}
+ existing_clock_class = bt_ctf_trace_get_clock_class_by_name(
+ writer_trace, bt_ctf_clock_class_get_name(clock_class));
+ bt_put(existing_clock_class);
+ if (existing_clock_class) {
+ bt_put(clock_class);
+ continue;
+ }
+
ret = bt_ctf_trace_add_clock_class(writer_trace, clock_class);
BT_PUT(clock_class);
if (ret != 0) {
struct bt_ctf_stream *writer_stream = NULL;
struct bt_ctf_stream_class *stream_class = NULL;
struct bt_ctf_stream_class *writer_stream_class = NULL;
+ int64_t id;
stream_class = bt_ctf_stream_get_class(stream);
if (!stream_class) {
}
bt_get(writer_stream_class);
- writer_stream = bt_ctf_stream_create(writer_stream_class,
- bt_ctf_stream_get_name(stream));
+ id = bt_ctf_stream_get_id(stream);
+ if (id < 0) {
+ writer_stream = bt_ctf_stream_create(writer_stream_class,
+ bt_ctf_stream_get_name(stream));
+ } else {
+ writer_stream = bt_ctf_stream_create_with_id(
+ writer_stream_class,
+ bt_ctf_stream_get_name(stream), id);
+ }
+
if (!writer_stream) {
fprintf(debug_it->err, "[error] %s in %s:%d\n",
__func__, __FILE__, __LINE__);
struct bt_ctf_packet *packet)
{
struct bt_ctf_stream *stream = NULL, *writer_stream = NULL;
- struct bt_ctf_field *writer_packet_context = NULL;
struct bt_ctf_packet *writer_packet = NULL;
+ struct bt_ctf_field *packet_context = NULL;
struct debug_info_trace *di_trace;
int int_ret;
goto error;
}
- writer_packet_context = ctf_copy_packet_context(debug_it->err, packet,
- writer_stream);
- if (!writer_packet_context) {
- fprintf(debug_it->err, "[error] %s in %s:%d\n",
- __func__, __FILE__, __LINE__);
- goto error;
- }
-
- int_ret = bt_ctf_packet_set_context(writer_packet, writer_packet_context);
- if (int_ret) {
- fprintf(debug_it->err, "[error] %s in %s:%d\n",
- __func__, __FILE__, __LINE__);
- goto error;
+ packet_context = bt_ctf_packet_get_context(packet);
+ if (packet_context) {
+ int_ret = ctf_packet_copy_context(debug_it->err,
+ packet, writer_stream, writer_packet);
+ if (int_ret < 0) {
+ fprintf(debug_it->err, "[error] %s in %s:%d\n",
+ __func__, __FILE__, __LINE__);
+ goto error;
+ }
+ BT_PUT(packet_context);
}
bt_get(writer_packet);
error:
end:
- bt_put(writer_packet_context);
+ bt_put(packet_context);
bt_put(writer_stream);
bt_put(stream);
return writer_packet;
}
state = insert_new_stream_state(debug_it, di_trace,
stream);
+ if (!state) {
+ fprintf(debug_it->err, "[error] Adding a new stream "
+ "on a static trace\n");
+ goto error;
+ }
}
if (*state != DEBUG_INFO_UNKNOWN_STREAM) {
fprintf(debug_it->err, "[error] Unexpected stream state %d\n",
struct bt_ctf_stream *debug_info_stream_end(struct debug_info_iterator *debug_it,
struct bt_ctf_stream *stream)
{
- struct bt_ctf_stream *writer_stream;
+ struct bt_ctf_stream *writer_stream = NULL;
struct debug_info_trace *di_trace = NULL;
enum debug_info_stream_state *state;
goto error;
}
- ret = bt_ctf_field_structure_set_field(writer_event_context,
+ ret = bt_ctf_field_structure_set_field_by_name(
+ writer_event_context,
field_name, copy_field);
if (ret) {
fprintf(err, "[error] %s in %s:%d\n", __func__,
goto end;
}
+ if (!bt_ctf_trace_get_clock_class_count(trace)) {
+ /* No clock. */
+ goto end;
+ }
+
/* FIXME multi-clock? */
clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0);
{
struct bt_ctf_clock_class *clock_class = NULL;
struct bt_ctf_clock_value *clock_value = NULL;
- int ret;
+ int ret = 0;
clock_class = event_get_clock_class(err, event);
if (!clock_class) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
+ /* No clock on input trace. */
+ goto end;
}
clock_value = bt_ctf_event_get_clock_value(event, clock_class);