• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 the Android
18  * side. */
19 
20 #pragma once
21 
22 #include <lk/compiler.h>
23 #include <stdint.h>
24 
25 __BEGIN_CDECLS
26 
27 /**
28  * enum coverage_record_type - Coverage region header type
29  * @COV_START: Magic header start marker
30  * @COV_8BIT_COUNTERS: 8bit counter for each instrumentation point
31  * @COV_INSTR_PCS: Pointer length offset of each instrumentation point from the
32  *                 start of the binary
33  * @COV_TOTAL_LENGTH: Total length of the entire coverage record, must be the
34  *                    last header item.
35  *
36  * Describes the type of a region of the coverage record. See &struct
37  * coverage_record_header.
38  */
39 enum coverage_record_type {
40     COV_START = 0x434f5652,
41     COV_8BIT_COUNTERS = 1,
42     COV_INSTR_PCS = 2,
43     COV_TOTAL_LENGTH = 0,
44 };
45 
46 /**
47  * struct coverage_record_header - Header entry describing a region of the
48  * coverage record.
49  * @type: type of the region, must be one of @enum coverage_record_type
50  * @offset: offset from the beginning of the header to the start of the region
51  *
52  * Coverage records start with a header which is a list of struct
53  * coverage_record_header, beginning with an entry with type COV_START and
54  * terminated with an entry with type COV_TOTAL_LENGTH. Each of these header
55  * entries corresponds to a region of the record, with the offset indicating the
56  * offset of the start of that region from the beginning of the record (i.e. the
57  * beginning of the header). Each record type and offset is 32-bit field with
58  * native endianness. The first header item must be COV_START with a 0 offset.
59  * The COV_START entry should be initialized when the coverage header is
60  * complete and ready for consumption by the client, because coverage record
61  * initialization happens asynchronously. The final header item,
62  * COV_TOTAL_LENGTH, which must always be present, indicates the total length of
63  * the coverage record, including the header.
64  *
65  * Coverage regions should be contiguous, so the end of one region is the start
66  * of the next, and the coverage header must be in the same order as the regions
67  * in the record body. Thus we can compute the length of a region by subtracting
68  * the region's offset from the offset of the next header item.
69  */
70 struct coverage_record_header {
71     uint32_t type;
72     uint32_t offset;
73 };
74