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

Side by Side Diff: x86_decode.cc

Issue 7326013: GCC 4.6 warnings cleanup (Closed) Base URL: http://seccompsandbox.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 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
« no previous file with comments | « tests/test_syscalls.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "x86_decode.h" 5 #include "x86_decode.h"
6 6
7 namespace playground { 7 namespace playground {
8 8
9 #if defined(__x86_64__) || defined(__i386__) 9 #if defined(__x86_64__) || defined(__i386__)
10 unsigned short next_inst(const char **ip, bool is64bit, bool *has_prefix, 10 unsigned short next_inst(const char **ip, bool is64bit, bool *has_prefix,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 unsigned char type; 164 unsigned char type;
165 unsigned short insn = byte; 165 unsigned short insn = byte;
166 unsigned int idx = 0; 166 unsigned int idx = 0;
167 if (byte == 0x0F) { 167 if (byte == 0x0F) {
168 byte = *insn_ptr++; 168 byte = *insn_ptr++;
169 insn = (insn << 8) | byte; 169 insn = (insn << 8) | byte;
170 idx = 256; 170 idx = 256;
171 } 171 }
172 type = opcode_types[idx + byte]; 172 type = opcode_types[idx + byte];
173 bool found_mod_rm = false;
Markus (顧孟勤) 2011/09/16 16:07:32 While currently unused, these statements actually
174 bool found_group = false; 173 bool found_group = false;
175 bool found_sib = false;
176 unsigned char mod_rm = 0; 174 unsigned char mod_rm = 0;
177 unsigned char sib = 0; 175 unsigned char sib = 0;
178 if (type & GROUP) { 176 if (type & GROUP) {
179 found_mod_rm = true;
180 found_group = true; 177 found_group = true;
181 mod_rm = *insn_ptr; 178 mod_rm = *insn_ptr;
182 if (mod_rm_ptr) { 179 if (mod_rm_ptr) {
183 *mod_rm_ptr = (char *)insn_ptr; 180 *mod_rm_ptr = (char *)insn_ptr;
184 } 181 }
185 unsigned char group = (type & GROUP_MASK) + ((mod_rm >> 3) & 0x7); 182 unsigned char group = (type & GROUP_MASK) + ((mod_rm >> 3) & 0x7);
186 if ((type & GROUP_MASK) == 40 && (mod_rm >> 6) == 3) { 183 if ((type & GROUP_MASK) == 40 && (mod_rm >> 6) == 3) {
187 group += 8; 184 group += 8;
188 } 185 }
189 type = group_table[group]; 186 type = group_table[group];
(...skipping 12 matching lines...) Expand all
202 // ptr < insn_ptr; ) { 199 // ptr < insn_ptr; ) {
203 // std::cerr << std::hex << std::uppercase << std::setw(2) << 200 // std::cerr << std::hex << std::uppercase << std::setw(2) <<
204 // std::setfill('0') << (unsigned int)*ptr++ << ' '; 201 // std::setfill('0') << (unsigned int)*ptr++ << ' ';
205 // } 202 // }
206 // std::cerr << "]" << std::endl; 203 // std::cerr << "]" << std::endl;
207 } else { 204 } else {
208 if (is64bit && (type & STACK)) { 205 if (is64bit && (type & STACK)) {
209 operand_width = 8; 206 operand_width = 8;
210 } 207 }
211 if (type & MOD_RM) { 208 if (type & MOD_RM) {
212 found_mod_rm = true;
213 if (mod_rm_ptr) { 209 if (mod_rm_ptr) {
214 *mod_rm_ptr = (char *)insn_ptr; 210 *mod_rm_ptr = (char *)insn_ptr;
215 } 211 }
216 mod_rm = *insn_ptr++; 212 mod_rm = *insn_ptr++;
217 int mod = (mod_rm >> 6) & 0x3; 213 int mod = (mod_rm >> 6) & 0x3;
218 int rm = 8*(rex & REX_B) + (mod_rm & 0x7); 214 int rm = 8*(rex & REX_B) + (mod_rm & 0x7);
219 if (mod != 3) { 215 if (mod != 3) {
220 if (address_width == 2) { 216 if (address_width == 2) {
221 switch (mod) { 217 switch (mod) {
222 case 0: 218 case 0:
223 if (rm != 6 /* SI */) { 219 if (rm != 6 /* SI */) {
224 break; 220 break;
225 } 221 }
226 // fall through 222 // fall through
227 case 2: 223 case 2:
228 insn_ptr++; 224 insn_ptr++;
229 // fall through 225 // fall through
230 case 1: 226 case 1:
231 insn_ptr++; 227 insn_ptr++;
232 break; 228 break;
233 } 229 }
234 } else { 230 } else {
235 if ((rm & 0x7) == 4) { 231 if ((rm & 0x7) == 4) {
236 found_sib = true;
237 if (sib_ptr) { 232 if (sib_ptr) {
238 *sib_ptr = (char *)insn_ptr; 233 *sib_ptr = (char *)insn_ptr;
239 } 234 }
240 sib = *insn_ptr++; 235 sib = *insn_ptr++;
241 if (!mod && (sib & 0x7) == 5 /* BP */) { 236 if (!mod && (sib & 0x7) == 5 /* BP */) {
242 insn_ptr += 4; 237 insn_ptr += 4;
243 } 238 }
244 } 239 }
245 switch (mod) { 240 switch (mod) {
246 case 0: 241 case 0:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 296 }
302 if (is_group) { 297 if (is_group) {
303 *is_group = found_group; 298 *is_group = found_group;
304 } 299 }
305 *ip = reinterpret_cast<const char *>(insn_ptr); 300 *ip = reinterpret_cast<const char *>(insn_ptr);
306 return insn; 301 return insn;
307 } 302 }
308 #endif 303 #endif
309 304
310 } // namespace 305 } // namespace
OLDNEW
« no previous file with comments | « tests/test_syscalls.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698