Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/binary-reader-logging.h
1 /* 2 * Copyright 2017 WebAssembly Community Group participants 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 #ifndef WABT_BINARY_READER_LOGGING_H_ 18 #define WABT_BINARY_READER_LOGGING_H_ 19 20 #include "wabt/binary-reader.h" 21 22 namespace wabt { 23 24 class Stream; 25 26 class BinaryReaderLogging : public BinaryReaderDelegate { 27 public: 28 BinaryReaderLogging(Stream*, BinaryReaderDelegate* forward); 29 30 bool OnError(const Error&) override; 31 void OnSetState(const State* s) override; 32 33 Result BeginModule(uint32_t version) override; 34 Result EndModule() override; 35 36 Result BeginSection(Index section_index, 37 BinarySection section_type, 38 Offset size) override; 39 40 Result BeginCustomSection(Index section_index, 41 Offset size, 42 std::string_view section_name) override; 43 Result EndCustomSection() override; 44 45 Result BeginTypeSection(Offset size) override; 46 Result OnTypeCount(Index count) override; 47 Result OnFuncType(Index index, 48 Index param_count, 49 Type* param_types, 50 Index result_count, 51 Type* result_types) override; 52 Result OnStructType(Index index, Index field_count, TypeMut* fields) override; 53 Result OnArrayType(Index index, TypeMut field) override; 54 Result EndTypeSection() override; 55 56 Result BeginImportSection(Offset size) override; 57 Result OnImportCount(Index count) override; 58 Result OnImport(Index index, 59 ExternalKind kind, 60 std::string_view module_name, 61 std::string_view field_name) override; 62 Result OnImportFunc(Index import_index, 63 std::string_view module_name, 64 std::string_view field_name, 65 Index func_index, 66 Index sig_index) override; 67 Result OnImportTable(Index import_index, 68 std::string_view module_name, 69 std::string_view field_name, 70 Index table_index, 71 Type elem_type, 72 const Limits* elem_limits) override; 73 Result OnImportMemory(Index import_index, 74 std::string_view module_name, 75 std::string_view field_name, 76 Index memory_index, 77 const Limits* page_limits) override; 78 Result OnImportGlobal(Index import_index, 79 std::string_view module_name, 80 std::string_view field_name, 81 Index global_index, 82 Type type, 83 bool mutable_) override; 84 Result OnImportTag(Index import_index, 85 std::string_view module_name, 86 std::string_view field_name, 87 Index tag_index, 88 Index sig_index) override; 89 Result EndImportSection() override; 90 91 Result BeginFunctionSection(Offset size) override; 92 Result OnFunctionCount(Index count) override; 93 Result OnFunction(Index index, Index sig_index) override; 94 Result EndFunctionSection() override; 95 96 Result BeginTableSection(Offset size) override; 97 Result OnTableCount(Index count) override; 98 Result OnTable(Index index, 99 Type elem_type, 100 const Limits* elem_limits) override; 101 Result EndTableSection() override; 102 103 Result BeginMemorySection(Offset size) override; 104 Result OnMemoryCount(Index count) override; 105 Result OnMemory(Index index, const Limits* limits) override; 106 Result EndMemorySection() override; 107 108 Result BeginGlobalSection(Offset size) override; 109 Result OnGlobalCount(Index count) override; 110 Result BeginGlobal(Index index, Type type, bool mutable_) override; 111 Result BeginGlobalInitExpr(Index index) override; 112 Result EndGlobalInitExpr(Index index) override; 113 Result EndGlobal(Index index) override; 114 Result EndGlobalSection() override; 115 116 Result BeginExportSection(Offset size) override; 117 Result OnExportCount(Index count) override; 118 Result OnExport(Index index, 119 ExternalKind kind, 120 Index item_index, 121 std::string_view name) override; 122 Result EndExportSection() override; 123 124 Result BeginStartSection(Offset size) override; 125 Result OnStartFunction(Index func_index) override; 126 Result EndStartSection() override; 127 128 Result BeginCodeSection(Offset size) override; 129 Result OnFunctionBodyCount(Index count) override; 130 Result BeginFunctionBody(Index index, Offset size) override; 131 Result OnLocalDeclCount(Index count) override; 132 Result OnLocalDecl(Index decl_index, Index count, Type type) override; 133 134 Result OnOpcode(Opcode opcode) override; 135 Result OnOpcodeBare() override; 136 Result OnOpcodeIndex(Index value) override; 137 Result OnOpcodeIndexIndex(Index value, Index value2) override; 138 Result OnOpcodeUint32(uint32_t value) override; 139 Result OnOpcodeUint32Uint32(uint32_t value, uint32_t value2) override; 140 Result OnOpcodeUint32Uint32Uint32(uint32_t value, 141 uint32_t value2, 142 uint32_t value3) override; 143 Result OnOpcodeUint32Uint32Uint32Uint32(uint32_t value, 144 uint32_t value2, 145 uint32_t value3, 146 uint32_t value4) override; 147 Result OnOpcodeUint64(uint64_t value) override; 148 Result OnOpcodeF32(uint32_t value) override; 149 Result OnOpcodeF64(uint64_t value) override; 150 Result OnOpcodeV128(v128 value) override; 151 Result OnOpcodeBlockSig(Type sig_type) override; 152 Result OnOpcodeType(Type type) override; 153 Result OnAtomicLoadExpr(Opcode opcode, 154 Index memidx, 155 Address alignment_log2, 156 Address offset) override; 157 Result OnAtomicStoreExpr(Opcode opcode, 158 Index memidx, 159 Address alignment_log2, 160 Address offset) override; 161 Result OnAtomicRmwExpr(Opcode opcode, 162 Index memidx, 163 Address alignment_log2, 164 Address offset) override; 165 Result OnAtomicRmwCmpxchgExpr(Opcode opcode, 166 Index memidx, 167 Address alignment_log2, 168 Address offset) override; 169 Result OnBinaryExpr(Opcode opcode) override; 170 Result OnBlockExpr(Type sig_type) override; 171 Result OnBrExpr(Index depth) override; 172 Result OnBrIfExpr(Index depth) override; 173 Result OnBrTableExpr(Index num_targets, 174 Index* target_depths, 175 Index default_target_depth) override; 176 Result OnCallExpr(Index func_index) override; 177 Result OnCatchExpr(Index tag_index) override; 178 Result OnCatchAllExpr() override; 179 Result OnCallIndirectExpr(Index sig_index, Index table_index) override; 180 Result OnCallRefExpr() override; 181 Result OnCompareExpr(Opcode opcode) override; 182 Result OnConvertExpr(Opcode opcode) override; 183 Result OnDelegateExpr(Index depth) override; 184 Result OnDropExpr() override; 185 Result OnElseExpr() override; 186 Result OnEndExpr() override; 187 Result OnF32ConstExpr(uint32_t value_bits) override; 188 Result OnF64ConstExpr(uint64_t value_bits) override; 189 Result OnV128ConstExpr(v128 value_bits) override; 190 Result OnGlobalGetExpr(Index global_index) override; 191 Result OnGlobalSetExpr(Index global_index) override; 192 Result OnI32ConstExpr(uint32_t value) override; 193 Result OnI64ConstExpr(uint64_t value) override; 194 Result OnIfExpr(Type sig_type) override; 195 Result OnLoadExpr(Opcode opcode, 196 Index memidx, 197 Address alignment_log2, 198 Address offset) override; 199 Result OnLocalGetExpr(Index local_index) override; 200 Result OnLocalSetExpr(Index local_index) override; 201 Result OnLocalTeeExpr(Index local_index) override; 202 Result OnLoopExpr(Type sig_type) override; 203 Result OnMemoryCopyExpr(Index destmemidx, Index srcmemidx) override; 204 Result OnDataDropExpr(Index segment_index) override; 205 Result OnMemoryFillExpr(Index memidx) override; 206 Result OnMemoryGrowExpr(Index memidx) override; 207 Result OnMemoryInitExpr(Index segment_index, Index memidx) override; 208 Result OnMemorySizeExpr(Index memidx) override; 209 Result OnTableCopyExpr(Index dst_index, Index src_index) override; 210 Result OnElemDropExpr(Index segment_index) override; 211 Result OnTableInitExpr(Index segment_index, Index table_index) override; 212 Result OnTableGetExpr(Index table) override; 213 Result OnTableSetExpr(Index table) override; 214 Result OnTableGrowExpr(Index table) override; 215 Result OnTableSizeExpr(Index table) override; 216 Result OnTableFillExpr(Index table) override; 217 Result OnRefFuncExpr(Index index) override; 218 Result OnRefNullExpr(Type type) override; 219 Result OnRefIsNullExpr() override; 220 Result OnNopExpr() override; 221 Result OnRethrowExpr(Index depth) override; 222 Result OnReturnCallExpr(Index func_index) override; 223 Result OnReturnCallIndirectExpr(Index sig_index, Index table_index) override; 224 Result OnReturnExpr() override; 225 Result OnSelectExpr(Index result_count, Type* result_types) override; 226 Result OnStoreExpr(Opcode opcode, 227 Index memidx, 228 Address alignment_log2, 229 Address offset) override; 230 Result OnThrowExpr(Index tag_index) override; 231 Result OnTryExpr(Type sig_type) override; 232 Result OnUnaryExpr(Opcode opcode) override; 233 Result OnTernaryExpr(Opcode opcode) override; 234 Result OnUnreachableExpr() override; 235 Result OnAtomicWaitExpr(Opcode opcode, 236 Index memidx, 237 Address alignment_log2, 238 Address offset) override; 239 Result OnAtomicFenceExpr(uint32_t consistency_model) override; 240 Result OnAtomicNotifyExpr(Opcode opcode, 241 Index memidx, 242 Address alignment_log2, 243 Address offset) override; 244 Result EndFunctionBody(Index index) override; 245 Result EndCodeSection() override; 246 Result OnSimdLaneOpExpr(Opcode opcode, uint64_t value) override; 247 Result OnSimdLoadLaneExpr(Opcode opcode, 248 Index memidx, 249 Address alignment_log2, 250 Address offset, 251 uint64_t value) override; 252 Result OnSimdStoreLaneExpr(Opcode opcode, 253 Index memidx, 254 Address alignment_log2, 255 Address offset, 256 uint64_t value) override; 257 Result OnSimdShuffleOpExpr(Opcode opcode, v128 value) override; 258 Result OnLoadSplatExpr(Opcode opcode, 259 Index memidx, 260 Address alignment_log2, 261 Address offset) override; 262 Result OnLoadZeroExpr(Opcode opcode, 263 Index memidx, 264 Address alignment_log2, 265 Address offset) override; 266 267 Result BeginElemSection(Offset size) override; 268 Result OnElemSegmentCount(Index count) override; 269 Result BeginElemSegment(Index index, 270 Index table_index, 271 uint8_t flags) override; 272 Result BeginElemSegmentInitExpr(Index index) override; 273 Result EndElemSegmentInitExpr(Index index) override; 274 Result OnElemSegmentElemType(Index index, Type elem_type) override; 275 Result OnElemSegmentElemExprCount(Index index, Index count) override; 276 Result BeginElemExpr(Index elem_index, Index expr_index) override; 277 Result EndElemExpr(Index elem_index, Index expr_index) override; 278 Result EndElemSegment(Index index) override; 279 Result EndElemSection() override; 280 281 Result BeginDataSection(Offset size) override; 282 Result OnDataSegmentCount(Index count) override; 283 Result BeginDataSegment(Index index, 284 Index memory_index, 285 uint8_t flags) override; 286 Result BeginDataSegmentInitExpr(Index index) override; 287 Result EndDataSegmentInitExpr(Index index) override; 288 Result OnDataSegmentData(Index index, 289 const void* data, 290 Address size) override; 291 Result EndDataSegment(Index index) override; 292 Result EndDataSection() override; 293 294 Result BeginDataCountSection(Offset size) override; 295 Result OnDataCount(Index count) override; 296 Result EndDataCountSection() override; 297 298 Result BeginNamesSection(Offset size) override; 299 Result OnModuleNameSubsection(Index index, 300 uint32_t name_type, 301 Offset subsection_size) override; 302 Result OnModuleName(std::string_view name) override; 303 Result OnFunctionNameSubsection(Index index, 304 uint32_t name_type, 305 Offset subsection_size) override; 306 Result OnFunctionNamesCount(Index num_functions) override; 307 Result OnFunctionName(Index function_index, 308 std::string_view function_name) override; 309 Result OnLocalNameSubsection(Index index, 310 uint32_t name_type, 311 Offset subsection_size) override; 312 Result OnLocalNameFunctionCount(Index num_functions) override; 313 Result OnLocalNameLocalCount(Index function_index, Index num_locals) override; 314 Result OnLocalName(Index function_index, 315 Index local_index, 316 std::string_view local_name) override; 317 Result OnNameSubsection(Index index, 318 NameSectionSubsection subsection_type, 319 Offset subsection_size) override; 320 Result OnNameEntry(NameSectionSubsection type, 321 Index index, 322 std::string_view name) override; 323 Result OnNameCount(Index num_names) override; 324 Result EndNamesSection() override; 325 326 Result BeginRelocSection(Offset size) override; 327 Result OnRelocCount(Index count, Index section_index) override; 328 Result OnReloc(RelocType type, 329 Offset offset, 330 Index index, 331 uint32_t addend) override; 332 Result EndRelocSection() override; 333 334 Result BeginDylinkSection(Offset size) override; 335 Result OnDylinkInfo(uint32_t mem_size, 336 uint32_t mem_align, 337 uint32_t table_size, 338 uint32_t table_align) override; 339 Result OnDylinkNeededCount(Index count) override; 340 Result OnDylinkNeeded(std::string_view needed) override; 341 Result OnDylinkImportCount(Index count) override; 342 Result OnDylinkExportCount(Index count) override; 343 Result OnDylinkImport(std::string_view module, 344 std::string_view name, 345 uint32_t flags) override; 346 Result OnDylinkExport(std::string_view name, uint32_t flags) override; 347 Result EndDylinkSection() override; 348 349 Result BeginGenericCustomSection(Offset size) override; 350 Result OnGenericCustomSection(std::string_view name, 351 const void* data, 352 Offset size) override; 353 Result EndGenericCustomSection() override; 354 355 Result BeginTargetFeaturesSection(Offset size) override; 356 Result OnFeatureCount(Index count) override; 357 Result OnFeature(uint8_t prefix, std::string_view name) override; 358 Result EndTargetFeaturesSection() override; 359 360 Result BeginLinkingSection(Offset size) override; 361 Result OnSymbolCount(Index count) override; 362 Result OnDataSymbol(Index index, 363 uint32_t flags, 364 std::string_view name, 365 Index segment, 366 uint32_t offset, 367 uint32_t size) override; 368 Result OnFunctionSymbol(Index index, 369 uint32_t flags, 370 std::string_view name, 371 Index func_index) override; 372 Result OnGlobalSymbol(Index index, 373 uint32_t flags, 374 std::string_view name, 375 Index global_index) override; 376 Result OnSectionSymbol(Index index, 377 uint32_t flags, 378 Index section_index) override; 379 Result OnTagSymbol(Index index, 380 uint32_t flags, 381 std::string_view name, 382 Index tag_index) override; 383 Result OnTableSymbol(Index index, 384 uint32_t flags, 385 std::string_view name, 386 Index tag_index) override; 387 Result OnSegmentInfoCount(Index count) override; 388 Result OnSegmentInfo(Index index, 389 std::string_view name, 390 Address alignment, 391 uint32_t flags) override; 392 Result OnInitFunctionCount(Index count) override; 393 Result OnInitFunction(uint32_t priority, Index symbol_index) override; 394 Result OnComdatCount(Index count) override; 395 Result OnComdatBegin(std::string_view name, 396 uint32_t flags, 397 Index count) override; 398 Result OnComdatEntry(ComdatType kind, Index index) override; 399 Result EndLinkingSection() override; 400 401 Result BeginTagSection(Offset size) override; 402 Result OnTagCount(Index count) override; 403 Result OnTagType(Index index, Index sig_index) override; 404 Result EndTagSection() override; 405 406 /* Code Metadata sections */ 407 Result BeginCodeMetadataSection(std::string_view name, Offset size) override; 408 Result OnCodeMetadataFuncCount(Index count) override; 409 Result OnCodeMetadataCount(Index function_index, Index count) override; 410 Result OnCodeMetadata(Offset offset, const void* data, Address size) override; 411 Result EndCodeMetadataSection() override; 412 413 private: 414 void Indent(); 415 void Dedent(); 416 void WriteIndent(); 417 void LogType(Type type); 418 void LogTypes(Index type_count, Type* types); 419 void LogTypes(TypeVector& types); 420 void LogField(TypeMut field); 421 422 Stream* stream_; 423 BinaryReaderDelegate* reader_; 424 int indent_; 425 }; 426 427 } // namespace wabt 428 429 #endif // WABT_BINARY_READER_LOGGING_H_