1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright Ericsson AB 2004-2016. All Rights Reserved. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * %CopyrightEnd% 19 */ 20 21 22 /* 23 * Description: 24 * 25 * Author: Rickard Green 26 */ 27 28 #ifndef ERL_MEMORY_TRACE_PROTOCOL_H__ 29 #define ERL_MEMORY_TRACE_PROTOCOL_H__ 30 31 /* 32 * Increase ERTS_MT_MAJOR_VSN and set ERTS_MT_MINOR_VSN to 0 33 * when backward incompatible changes are made in the protocol. 34 * 35 * Increase ERTS_MT_MINOR_VSN when backward compatible changes are 36 * made in the protocol. 37 */ 38 #define ERTS_MT_MAJOR_VSN (2) 39 #define ERTS_MT_MINOR_VSN (0) 40 41 /* Trace flags */ 42 43 #define ERTS_MT_64_BIT_FLAG (1 << 0) 44 #define ERTS_MT_CRR_INFO (1 << 1) 45 #define ERTS_MT_SEG_CRR_INFO (1 << 2) 46 47 /* Header flags */ 48 /* Allocator flags */ 49 50 #define ERTS_MT_ALLCTR_USD_CRR_INFO (1 << 0) 51 52 /* Block type flags */ 53 54 55 56 /* Entry tags */ 57 58 #define ERTS_MT_V1_ALLOCATOR_TAG (1) 59 #define ERTS_MT_V1_BLOCK_TYPE_TAG (2) 60 #define ERTS_MT_V1_ALLOC_TAG (3) 61 #define ERTS_MT_V1_REALLOC_NPB_TAG (4) 62 #define ERTS_MT_V1_REALLOC_MV_TAG (5) 63 #define ERTS_MT_V1_REALLOC_NMV_TAG (6) 64 #define ERTS_MT_V1_FREE_TAG (7) 65 #define ERTS_MT_V1_TIME_INC_TAG (8) 66 #define ERTS_MT_V1_STOP_TAG (9) 67 #define ERTS_MT_V1_EXIT_TAG (10) 68 69 #define ERTS_MT_END_OF_HDR_TAG (0) 70 #define ERTS_MT_ALLOCATOR_HDR_TAG (1) 71 #define ERTS_MT_BLOCK_TYPE_HDR_TAG (2) 72 73 #define ERTS_MT_EXIT_BDY_TAG (0) 74 #define ERTS_MT_STOP_BDY_TAG (1) 75 #define ERTS_MT_ALLOC_BDY_TAG (2) 76 #define ERTS_MT_REALLOC_BDY_TAG (3) 77 #define ERTS_MT_FREE_BDY_TAG (4) 78 #define ERTS_MT_CRR_ALLOC_BDY_TAG (5) 79 #define ERTS_MT_CRR_REALLOC_BDY_TAG (6) 80 #define ERTS_MT_CRR_FREE_BDY_TAG (7) 81 #define ERTS_MT_TIME_INC_BDY_TAG (8) 82 #define ERTS_MT_X_BDY_TAG (9) 83 84 /* X subtags */ 85 #if 0 86 #define ERTS_MT_X_ _BDY_TAG (0) 87 #endif 88 89 #define ERTS_MT_START_WORD (0xfff04711) 90 /* Entry header fields */ 91 92 #define ERTS_MT_UI8_MSB_EHDR_FLD_SZ (0) 93 #define ERTS_MT_UI16_MSB_EHDR_FLD_SZ (1) 94 #define ERTS_MT_UI32_MSB_EHDR_FLD_SZ (2) 95 #define ERTS_MT_UI64_MSB_EHDR_FLD_SZ (3) 96 #define ERTS_MT_UI_MSB_EHDR_FLD_SZ ERTS_MT_UI64_MSB_EHDR_FLD_SZ 97 #define ERTS_MT_TAG_EHDR_FLD_SZ (4) 98 99 #define ERTS_MT_UI8_MSB_EHDR_FLD_MSK ((1 << ERTS_MT_UI8_MSB_EHDR_FLD_SZ)-1) 100 #define ERTS_MT_UI16_MSB_EHDR_FLD_MSK ((1 << ERTS_MT_UI16_MSB_EHDR_FLD_SZ)-1) 101 #define ERTS_MT_UI32_MSB_EHDR_FLD_MSK ((1 << ERTS_MT_UI32_MSB_EHDR_FLD_SZ)-1) 102 #define ERTS_MT_UI64_MSB_EHDR_FLD_MSK ((1 << ERTS_MT_UI64_MSB_EHDR_FLD_SZ)-1) 103 #define ERTS_MT_UI_MSB_EHDR_FLD_MSK ERTS_MT_UI64_MSB_EHDR_FLD_MSK 104 #define ERTS_MT_TAG_EHDR_FLD_MSK ((1 << ERTS_MT_TAG_EHDR_FLD_SZ)-1) 105 106 /* Time increment word */ 107 #define ERTS_MT_TIME_INC_SECS_SHIFT 20 108 #define ERTS_MT_TIME_INC_USECS_SHIFT 0 109 110 #define ERTS_MT_TIME_INC_SECS_MASK ((1 << 12) - 1) 111 #define ERTS_MT_TIME_INC_USECS_MASK ((1 << 20) - 1) 112 113 114 #define ERTS_MT_MAX_V1_HEADER_ENTRY_SIZE (2 + 2 + 1 + 255 + 2) 115 /* Largest v1 header entry is block type entry (ERTS_MT_V1_BLOCK_TYPE_TAG) */ 116 #define ERTS_MT_MAX_V1_BODY_ENTRY_SIZE (2 + 8 + 8 + 8 + 4) 117 /* Largest body entry is realloc moved entry (ERTS_MT_V1_REALLOC_MV_TAG) */ 118 119 120 #define ERTS_MT_MAX_HEADER_ENTRY_SIZE (1 + 2 + 2 + 1 + 255 + 2) 121 /* Largest header entry is block type entry (ERTS_MT_BLOCK_TYPE_TAG) */ 122 #define ERTS_MT_MAX_BODY_ENTRY_SIZE ERTS_MT_MAX_CRR_REALLOC_SIZE 123 /* Largest body entry is carrier realloc entry (ERTS_MT_CRR_REALLOC_BDY_TAG) */ 124 125 /* 126 * 127 * Entry header: 128 * 129 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 130 * | ... |MSB2|MSB1| 131 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 132 * 133 * Time inc entry field: 134 * 135 * 31 23 0 136 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 137 * | Seconds | Micro Seconds | 138 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 139 */ 140 141 #define ERTS_MT_MAX_CRR_ALLOC_SIZE (1 + 2 + 2 + 2 + 8 + 8 + 4) 142 143 /* 144 * ERTS_MT_CRR_ALLOC_BDY_TAG: 145 * N 1 2 3 4 5 146 * MSB 1-0 1-0 7|3-0 7|3-0 3-0 147 * SZ 1 2 2-1 2-1 8|4-1 8|4-1 4-1 148 * UIT UI8 UI16 UI16 UI16 UI64|UI32 UI64|UI32 UI32 149 * +---+----+...--+...--+...-------+...-------+...-------+ 150 * |Tag| Hdr|CType| Type| Out ptr | In size | Time inc | 151 * +---+----+...--+...--+...-------+...-------+...-------+ 152 * 153 */ 154 155 #define ERTS_MT_MAX_ALLOC_SIZE (1 + 2 + 2 + 8 + 8 + 4) 156 /* 157 * ERTS_MT_ALLOC_BDY_TAG: 158 * N 1 2 3 4 159 * MSB 1-0 7|3-0 7|3-0 3-0 160 * SZ 1 2 2-1 8|4-1 8|4-1 4-1 161 * UIT UI8 UI16 UI16 UI64|UI32 UI64|UI32 UI32 162 * +---+----+...--+...-------+...-------+...-------+ 163 * |Tag| Hdr| Type| Out ptr | In size | Time inc | 164 * +---+----+...--+...-------+...-------+...-------+ 165 * 166 */ 167 168 #define ERTS_MT_MAX_CRR_REALLOC_SIZE (1 + 2 + 2 + 2 + 8 + 8 + 8 + 4) 169 /* 170 * ERTS_MT_CRR_REALLOC_BDY_TAG: 171 * N 1 2 3 4 5 6 172 * MSB 1-0 1-0 7|3-0 7|3-0 7|3-0 3-0 173 * SZ 1 2 2-1 2-1 8|4-1 8|4-1 8|4-1 4-1 174 * UIT UI8 UI16 UI16 UI16 UI64|UI32 UI64|UI32 UI64|UI32 UI32 175 * +---+----+...--+...--+...-------+...-------+...-------+...-------+ 176 * |Tag| Hdr|CType| Type| Out ptr | In ptr | In size | Time inc | 177 * +---+----+...--+...--+...-------+...-------+...-------+...-------+ 178 * 179 */ 180 181 #define ERTS_MT_MAX_REALLOC_SIZE (1 + 2 + 2 + 8 + 8 + 8 + 4) 182 /* 183 * ERTS_MT_REALLOC_BDY_TAG: 184 * N 1 2 3 4 5 185 * MSB 1-0 7|3-0 7|3-0 7|3-0 3-0 186 * SZ 1 2 2-1 8|4-1 8|4-1 8|4-1 4-1 187 * UIT UI8 UI16 UI16 UI64|UI32 UI64|UI32 UI64|UI32 UI32 188 * +---+----+...--+...-------+...-------+...-------+...-------+ 189 * |Tag| Hdr| Type| Out ptr | In ptr | In size | Time inc | 190 * +---+----+...--+...-------+...-------+...-------+...-------+ 191 * 192 */ 193 194 #define ERTS_MT_MAX_CRR_FREE_SIZE (1 + 2 + 2 + 2 + 8 + 4) 195 /* 196 * ERTS_MT_CRR_FREE_BDY_TAG: 197 * N 1 2 3 4 198 * MSB 1-0 1-0 7|3-0 3-0 199 * SZ 1 2 2-1 2-1 8|4-1 4-1 200 * UIT UI8 UI16 UI16 UI16 UI64|UI32 UI32 201 * +---+----+...--+...--+...-------+...-------+ 202 * |Tag| Hdr|CType| Type| In ptr | Time inc | 203 * +---+----+...--+...--+...-------+...-------+ 204 * 205 */ 206 207 #define ERTS_MT_MAX_FREE_SIZE (1 + 2 + 2 + 8 + 4) 208 /* 209 * ERTS_MT_FREE_BDY_TAG: 210 * N 1 2 3 211 * MSB 1-0 7|3-0 3-0 212 * SZ 1 2 2-1 8|4-1 4-1 213 * UIT UI8 UI16 UI16 UI64|UI32 UI32 214 * +---+----+...--+...-------+...-------+ 215 * |Tag| Hdr| Type| In ptr | Time inc | 216 * +---+----+...--+...-------+...-------+ 217 * 218 */ 219 220 /* 221 * ERTS_MT_X_BDY_TAG: 222 * N 223 * MSB 224 * SZ 1 2 1 225 * UIT UI8 UI16 UI8 226 * +---+-----+------+... ...+ 227 * |Tag|TotSz|SubTag| | 228 * +---+-----+------+... ...+ 229 * 230 * ^ ^ 231 * | | 232 * +------ TotSz bytes -----+ 233 * 234 * X for extension 235 * 236 * * Tag equals ERTS_MT_X_BDY_TAG. 237 * * TotSz contains the total size of the entry. 238 * * SubTag is used to distinguish between different sub entries 239 * passed in X entries. 240 * 241 */ 242 243 244 245 #endif /* #ifndef ERL_MEMORY_TRACE_PROTOCOL_H__ */ 246 247