| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 /* | |
| 8 * Collects histogram information as a validator function. | |
| 9 * | |
| 10 * Note: The following functions are used to define a validator function | |
| 11 * for collecting this information. See header file ncvalidator_iter.h | |
| 12 * for more information on how to register these functions as a validator | |
| 13 * function. | |
| 14 */ | |
| 15 | |
| 16 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NC_OPCODE_HISTOGRA
PH_H__ | |
| 17 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NC_OPCODE_HISTOGRA
PH_H__ | |
| 18 | |
| 19 #include "native_client/src/include/portability.h" | |
| 20 #include "native_client/src/shared/utils/types.h" | |
| 21 | |
| 22 /* Defines a validator state. */ | |
| 23 struct NaClValidatorState; | |
| 24 | |
| 25 /* Defines an instruction iterator that processes a code segment. */ | |
| 26 struct NaClInstIter; | |
| 27 | |
| 28 /* Defines a data structure that holds data defining the opcode histogram | |
| 29 * being collected. Holds a histogram of the (first) byte of the found | |
| 30 * opcodes for each instruction. | |
| 31 */ | |
| 32 typedef struct NaClOpcodeHistogram { | |
| 33 uint32_t opcode_histogram[256]; | |
| 34 } NaClOpcodeHistogram; | |
| 35 | |
| 36 /* Command line flag controlling whether an opcode histogram is | |
| 37 * collected while validating. | |
| 38 */ | |
| 39 extern Bool NACL_FLAGS_opcode_histogram; | |
| 40 | |
| 41 /* Initializes opcode histogram data in the validator state. */ | |
| 42 void NaClOpcodeHistogramInitialize(struct NaClValidatorState* state); | |
| 43 | |
| 44 /* Validator function to record histgram value for current instruction. */ | |
| 45 void NaClOpcodeHistogramRecord(struct NaClValidatorState* state); | |
| 46 | |
| 47 /* Validator print function to print out collected histogram. */ | |
| 48 void NaClOpcodeHistogramPrintStats(struct NaClValidatorState* state); | |
| 49 | |
| 50 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NC_OPCODE_HISTO
GRAPH_H__ */ | |
| OLD | NEW |