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

Side by Side Diff: src/trusted/validator_x86/nc_inst_state_internal.h

Issue 6883091: Start unit testing for functions in nc_inst_state.c (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 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) 2011 The Native Client Authors. All rights reserved. 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 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 * Internal implementation of the state associated with matching instructions. 8 * Internal implementation of the state associated with matching instructions.
9 */ 9 */
10 10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_ 11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_ 12 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_
13 13
14 #include "native_client/src/shared/utils/types.h" 14 #include "native_client/src/shared/utils/types.h"
15 #include "native_client/src/trusted/validator_x86/ncop_exps.h" 15 #include "native_client/src/trusted/validator_x86/ncop_exps.h"
16 16
17 EXTERN_C_BEGIN
18
17 /* The meta model of an x86 opcode instruction. */ 19 /* The meta model of an x86 opcode instruction. */
18 struct NaClInst; 20 struct NaClInst;
19 21
20 /* Model of a code segment. */ 22 /* Model of a code segment. */
21 struct NaClSegment; 23 struct NaClSegment;
22 24
23 /* Defines the type used to align OpExprNodes when memory allocating. */ 25 /* Defines the type used to align OpExprNodes when memory allocating. */
24 typedef uint64_t NaClOpExpElement; 26 typedef uint64_t NaClOpExpElement;
25 27
26 /* Model data needed to decode an x86 instruction. */ 28 /* Model data needed to decode an x86 instruction. */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 NaClMemorySize inst_count; 102 NaClMemorySize inst_count;
101 /* The following fields define a ring buffer, where buffer_index 103 /* The following fields define a ring buffer, where buffer_index
102 * is the index of the current instruction in the buffer, and 104 * is the index of the current instruction in the buffer, and
103 * buffer_size is the number of iterator states in the buffer. 105 * buffer_size is the number of iterator states in the buffer.
104 */ 106 */
105 size_t buffer_size; 107 size_t buffer_size;
106 size_t buffer_index; 108 size_t buffer_index;
107 struct NaClInstState* buffer; 109 struct NaClInstState* buffer;
108 }; 110 };
109 111
112 /* Structure holding the results of consuming the opcode bytes of the
113 * instruction.
114 */
115 typedef struct {
116 /* The (last) byte of the matched opcode. */
117 uint8_t opcode_byte;
118 /* The most specific prefix that the opcode bytes can match
119 * (or OpcodePrefixEnumSize if no such patterns exist).
120 */
121 NaClInstPrefix matched_prefix;
122 /* The number of bytes to subtract from the instruction length,
123 * the next time GetNextNaClInstCandidates is called.
124 */
125 uint8_t next_length_adjustment;
126 } NaClInstPrefixDescriptor;
127
110 /* Given the current location of the (relative) pc of the given instruction 128 /* Given the current location of the (relative) pc of the given instruction
111 * iterator, update the given state to hold the matched opcode 129 * iterator, update the given state to hold the matched opcode
112 * (instruction) pattern. If no matching pattern exists, set the state 130 * (instruction) pattern. If no matching pattern exists, set the state
113 * to a matched undefined opcode (instruction) pattern. In all cases, 131 * to a matched undefined opcode (instruction) pattern. In all cases,
114 * update the state to hold all information on the matched bytes of the 132 * update the state to hold all information on the matched bytes of the
115 * instruction. 133 * instruction.
116 */ 134 */
117 void NaClDecodeInst(struct NaClInstIter* iter, struct NaClInstState* state); 135 void NaClDecodeInst(struct NaClInstIter* iter, struct NaClInstState* state);
118 136
137 /* Returns the (undecoded) instruction state of the iterator. Should only
138 * be used for testing.
139 */
140
141 struct NaClInstState* NaClInstIterGetUndecodedState(struct NaClInstIter* iter);
142
143 EXTERN_C_END
144
119 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_ */ 145 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_INST_STATE_INTERNAL_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698