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.
8 * ncdis_segments.h - Common routine for disassembling a block of code.
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_
14 #ifndef NACL_TRUSTED_BUT_NOT_TCB
15 #error("This file is not meant for use in the TCB")
18 #include "native_client/src/shared/utils/types.h"
19 #include "native_client/src/trusted/validator/types_memory_model.h"
21 /* Flags that can be passed to the disassembler */
22 typedef enum NaClDisassembleFlag {
23 /* Use the full decoder to disassemble the instruction. */
25 /* Use the dissassembler associated with the corresponding decoder. */
26 NaClDisassembleValidatorDecoder,
27 /* If additional internal information is available about the disassembled
28 * instruction, print it also.
30 NaClDisassembleAddInternals,
31 } NaClDisassembleFlag;
33 /* Defines an integer to represent sets of possible disassembler flags. */
34 typedef uint8_t NaClDisassembleFlags;
36 /* Converts a NaClDisssembleFlag to the corresponding bit in
37 * NaClDisassembleFlags.
39 #define NACL_DISASSEMBLE_FLAG(x) (((NaClDisassembleFlags) 1) << (x))
41 /* Returns Bool flag defining if given flag is in the set of
44 Bool NaClContainsDisassembleFlag(NaClDisassembleFlags flags,
45 NaClDisassembleFlag flag);
47 /* Disassemble the code segment, following the rules specified by
48 * the given set of flags.
51 * mbase - Memory region containing code segment.
52 * vbase - PC address associated with first byte of memory region.
53 * size - Number of bytes in memory region.
54 * flags - Flags to use when decoding.
56 void NaClDisassembleSegment(uint8_t* mbase, NaClPcAddress vbase,
57 NaClMemorySize size, NaClDisassembleFlags flags);
59 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_ */