X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Findex%2Fctf-index.h;h=7fc7fd83480a960a19c31fffe08678252a73a7a0;hp=0efa8887daff4435eae88fe18fee78db7373c858;hb=6f1105342bcca0c5ba8177ae134c197c19ba215f;hpb=50adc26400482c07210afcda8ef1d3322f75871d diff --git a/src/common/index/ctf-index.h b/src/common/index/ctf-index.h index 0efa8887d..7fc7fd834 100644 --- a/src/common/index/ctf-index.h +++ b/src/common/index/ctf-index.h @@ -1,35 +1,25 @@ /* - * Copyright (C) 2013 - Julien Desfossez - * Mathieu Desnoyers - * David Goulet + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 Mathieu Desnoyers + * Copyright (C) 2013 David Goulet * - * 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: + * SPDX-License-Identifier: MIT * - * 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. */ #ifndef LTTNG_INDEX_H #define LTTNG_INDEX_H +#include +#include + +#include #include +#include #define CTF_INDEX_MAGIC 0xC1F1DCC1 #define CTF_INDEX_MAJOR 1 -#define CTF_INDEX_MINOR 0 +#define CTF_INDEX_MINOR 1 /* * Header at the beginning of each index file. @@ -44,7 +34,7 @@ struct ctf_packet_index_file_hdr { } __attribute__((__packed__)); /* - * Packet index generated for each trace packet store in a trace file. + * Packet index generated for each trace packet stored in a trace file. * All integer fields are stored in big endian. */ struct ctf_packet_index { @@ -54,7 +44,63 @@ struct ctf_packet_index { uint64_t timestamp_begin; uint64_t timestamp_end; uint64_t events_discarded; - uint64_t stream_id; + uint64_t stream_id; /* ID of the channel */ + /* CTF_INDEX 1.0 limit */ + uint64_t stream_instance_id; /* ID of the channel instance */ + uint64_t packet_seq_num; /* packet sequence number */ } __attribute__((__packed__)); +static inline size_t ctf_packet_index_len(uint32_t major, uint32_t minor) +{ + if (major == 1) { + switch (minor) { + case 0: + return offsetof(struct ctf_packet_index, stream_id) + + member_sizeof(struct ctf_packet_index, + stream_id); + case 1: + return offsetof(struct ctf_packet_index, packet_seq_num) + + member_sizeof(struct ctf_packet_index, + packet_seq_num); + default: + abort(); + } + } + abort(); +} + +static inline uint32_t lttng_to_index_major(uint32_t lttng_major, + uint32_t lttng_minor __attribute__((unused))) +{ + if (lttng_major == 2) { + return 1; + } + abort(); +} + +static inline uint32_t lttng_to_index_minor(uint32_t lttng_major, + uint32_t lttng_minor) +{ + if (lttng_major == 2) { + if (lttng_minor < 8) { + return 0; + } else { + return 1; + } + } + abort(); +} + +static inline void ctf_packet_index_file_hdr_init( + struct ctf_packet_index_file_hdr *hdr, + uint32_t idx_major, uint32_t idx_minor) +{ + memset(hdr, 0, sizeof(*hdr)); + hdr->magic = htobe32(CTF_INDEX_MAGIC); + hdr->index_major = htobe32(idx_major); + hdr->index_minor = htobe32(idx_minor); + hdr->packet_index_len = htobe32( + ctf_packet_index_len(idx_major, idx_minor)); +} + #endif /* LTTNG_INDEX_H */