1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* This file needs to be kept in-sync with its counterpart on Trusty side: 18 * trusty/user/base/lib/coverage/common/include/lib/coverage/common/record.h */ 19 20 #pragma once 21 22 #include <stdint.h> 23 24 /** 25 * enum coverage_record_type - Coverage region header type 26 * @COV_START: Magic header start marker 27 * @COV_8BIT_COUNTERS: 8bit counter for each instrumentation point 28 * @COV_INSTR_PCS: Pointer length offset of each instrumentation point from the 29 * start of the binary 30 * @COV_TOTAL_LENGTH: Total length of the entire coverage record, must be the 31 * last header item. 32 * 33 * Describes the type of a region of the coverage record. See &struct 34 * coverage_record_header. 35 */ 36 enum coverage_record_type { 37 COV_START = 0x434f5652, 38 COV_8BIT_COUNTERS = 1, 39 COV_INSTR_PCS = 2, 40 COV_TOTAL_LENGTH = 0, 41 }; 42 43 /** 44 * struct coverage_record_header - Header entry describing a region of the 45 * coverage record. 46 * @type: type of the region, must be one of @enum coverage_record_type 47 * @offset: offset from the beginning of the header to the start of the region 48 * 49 * Coverage records start with a header which is a list of struct 50 * coverage_record_header, beginning with an entry with type COV_START and 51 * terminated with an entry with type COV_TOTAL_LENGTH. Each of these header 52 * entries corresponds to a region of the record, with the offset indicating the 53 * offset of the start of that region from the beginning of the record (i.e. the 54 * beginning of the header). Each record type and offset is 32-bit field with 55 * native endianness. The first header item must be COV_START with a 0 offset. 56 * The COV_START entry should be initialized when the coverage header is 57 * complete and ready for consumption by the client, because coverage record 58 * initialization happens asynchronously. The final header item, 59 * COV_TOTAL_LENGTH, which must always be present, indicates the total length of 60 * the coverage record, including the header. 61 * 62 * Coverage regions should be contiguous, so the end of one region is the start 63 * of the next, and the coverage header must be in the same order as the regions 64 * in the record body. Thus we can compute the length of a region by subtracting 65 * the region's offset from the offset of the next header item. 66 */ 67 struct coverage_record_header { 68 uint32_t type; 69 uint32_t offset; 70 }; 71