Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: src/trusted/validator/x86/testing/enuminsts/enuminsts.h

Issue 9861030: Modify enuminsts to be able to communicate matched instructions accross (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * enuminsts.h 8 * enuminsts.h
9 * 9 *
10 * Defines the general API for defining decoder / validation tools to be 10 * Defines the general API for defining decoder / validation tools to be
11 * tested by the enumeration structure. 11 * tested by the enumeration structure.
12 */ 12 */
13 13
14 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_ 14 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_
15 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_ 15 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_
16 16
17 #include "native_client/src/include/nacl_macros.h" 17 #include "native_client/src/include/nacl_macros.h"
18 #include "native_client/src/shared/utils/types.h" 18 #include "native_client/src/shared/utils/types.h"
19 19
20 /* Defines routine to print out non-fatal error due to unexpected
21 * internal error.
22 */
23 extern void InternalError(const char *why);
24
25 /* Records that a fatal (i.e. non-recoverable) error occurred. */
26 extern void ReportFatalError(const char* why);
27
20 /* Structure holding decoder/validation tool to test. */ 28 /* Structure holding decoder/validation tool to test. */
21 struct NaClEnumeratorDecoder; 29 struct NaClEnumeratorDecoder;
22 30
23 /* Defines the maximum length of an instruction. */ 31 /* Defines the maximum length of an instruction. */
24 #define NACL_ENUM_MAX_INSTRUCTION_BYTES 30 32 #define NACL_ENUM_MAX_INSTRUCTION_BYTES 15
25 33
26 /* Defines the maximum number of enumeration decoders one can run. */ 34 /* Defines the maximum number of enumeration decoders one can run. */
27 #define NACL_MAX_ENUM_DECODERS 2 35 #define NACL_MAX_ENUM_DECODERS 5
28 36
29 /* 37 /*
30 * Defines the data structure used by the driver to enumerate possible 38 * Defines the data structure used by the driver to enumerate possible
31 * instruction encodings. 39 * instruction encodings.
32 */ 40 */
33 typedef struct NaClEnumerator { 41 typedef struct NaClEnumerator {
34 /* Defines the buffer of bytes generated for an enumeration. 42 /* Defines the buffer of bytes generated for an enumeration.
35 */ 43 */
36 uint8_t _itext[NACL_ENUM_MAX_INSTRUCTION_BYTES]; 44 uint8_t _itext[NACL_ENUM_MAX_INSTRUCTION_BYTES];
37 45
38 /* Defines the actual number of bytes to be tried within _itext. */ 46 /* Defines the actual number of bytes to be tried within _itext. */
39 size_t _num_bytes; 47 size_t _num_bytes;
40 48
41 /* Defines the two enumerator decoders to apply. */ 49 /* Defines the two enumerator decoders to apply. */
42 struct NaClEnumeratorDecoder* _decoder[NACL_MAX_ENUM_DECODERS]; 50 struct NaClEnumeratorDecoder* _decoder[NACL_MAX_ENUM_DECODERS];
43 51
44 /* Defines the number of decoders being applied. */ 52 /* Defines the number of decoders being applied. */
45 size_t _num_decoders; 53 size_t _num_decoders;
46
47 /* Defines flag defining if only opcode bytes should be printed. */
48 Bool _print_opcode_bytes_only;
49
50 /*
51 * Returns true if the enumerated instruction should be printed out in
52 * a easily to read form. That is, the sequence of opcodes,
53 * followed by "#", followed by the instruction text.
54 */
55 Bool _print_enumerated_instruction;
56 } NaClEnumerator; 54 } NaClEnumerator;
57 55
58 /* Define the (virtual) function to parse the first instruction in the itext 56 /* Define the (virtual) function to parse the first instruction in the itext
59 * array of the enumerator. Assumes that the length of the first instruction 57 * array of the enumerator. Assumes that the length of the first instruction
60 * must be no larger than the _num_bytes field of the enumerator. 58 * must be no larger than the _num_bytes field of the enumerator.
61 */ 59 */
62 typedef void (*NaClDecoderParseInstFn)(NaClEnumerator* enmerator, 60 typedef void (*NaClDecoderParseInstFn)(NaClEnumerator* enmerator,
63 int pc_address); 61 int pc_address);
64 62
65 /* Defines the (virtual) function that returns the number of bytes in the 63 /* Defines the (virtual) function that returns the number of bytes in the
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 * _writes_to_reserved_reg_fn; 142 * _writes_to_reserved_reg_fn;
145 * _maybe_inst_validates_fn; 143 * _maybe_inst_validates_fn;
146 * _segment_validates_fn; 144 * _segment_validates_fn;
147 */ 145 */
148 typedef struct NaClEnumeratorDecoder { 146 typedef struct NaClEnumeratorDecoder {
149 /* The identifying name for the tester. */ 147 /* The identifying name for the tester. */
150 const char* _id_name; 148 const char* _id_name;
151 /* True if the legal filter should be applied to this tester. That is, 149 /* True if the legal filter should be applied to this tester. That is,
152 * only report on instructions this tester finds to be a legal instruction. 150 * only report on instructions this tester finds to be a legal instruction.
153 * When false, filter out instructions that are illegal. 151 * When false, filter out instructions that are illegal.
152 * Note: This field is initialized by NaClPreregisterEnumeratorDecoder
153 * in enuminsts.c
154 */ 154 */
155 Bool _legal_only; 155 Bool _legal_only;
156 /* True if we should should not run comparison tests, but only print. */ 156 /* True if we should should not run comparison tests, but only print.
157 Bool _print_only; 157 * Note: This field is initialized by NaClPreregisterEnumeratorDecoder
158 * in enuminsts.c
159 */
160 Bool _print;
161 /* True if we should print out the matched opcode sequence for the decoder.
162 * Note: This field is initialized by NaClPreregisterEnumeratorDecoder
163 * in enuminsts.c
164 */
165 Bool _print_opcode_sequence;
166 /* True if we should print out the matched opcode sequence, as well as the
167 * mnemonic and operands (as returned by _get_inst_mnemonic_fn and
168 * _get_inst_operands_text_fn) as a comment after the matched opcode sequence.
169 * Note: This field is initialized by NaClPreregisterEnumeratorDecoder
170 * in enuminsts.c
171 */
172 Bool _print_opcode_sequence_plus_desc;
158 /* 173 /*
159 * Parses the first instruction in the itext array of the enumerator. Assumes 174 * Parses the first instruction in the itext array of the enumerator. Assumes
160 * that the length of the first instruction must be <= the _num_bytes field 175 * that the length of the first instruction must be <= the _num_bytes field
161 * of the enumerator. 176 * of the enumerator.
162 */ 177 */
163 NaClDecoderParseInstFn _parse_inst_fn; 178 NaClDecoderParseInstFn _parse_inst_fn;
164 /* 179 /*
165 * Returns the number of bytes in the disassembled instruction. 180 * Returns the number of bytes in the disassembled instruction.
166 */ 181 */
167 NaClDecoderInstLengthFn _inst_length_fn; 182 NaClDecoderInstLengthFn _inst_length_fn;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 NaClDecoderMaybeSegmentValidatesFn _segment_validates_fn; 222 NaClDecoderMaybeSegmentValidatesFn _segment_validates_fn;
208 /* Processes the given command line flag. */ 223 /* Processes the given command line flag. */
209 NaClDecoderInstallFlagFn _install_flag_fn; 224 NaClDecoderInstallFlagFn _install_flag_fn;
210 /* Holds the usage message to printed for the decoder in the (command-line) 225 /* Holds the usage message to printed for the decoder in the (command-line)
211 * usage function. 226 * usage function.
212 */ 227 */
213 const char* _usage_message; 228 const char* _usage_message;
214 } NaClEnumeratorDecoder; 229 } NaClEnumeratorDecoder;
215 230
216 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_ */ 231 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_TESTING_ENUMINSTS_ENUMINST_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698