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

Side by Side Diff: syzygy/core/disassembler_util_unittest.cc

Issue 2507113002: Add support for the vbroadcastss instruction. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « syzygy/core/disassembler_util.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 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Interrupts. 117 // Interrupts.
118 const uint8_t kInt2[] = {0xCD, 0x02}; 118 const uint8_t kInt2[] = {0xCD, 0x02};
119 const uint8_t kInt3[] = {0xCC}; 119 const uint8_t kInt3[] = {0xCC};
120 120
121 // Improperly handled VEX encoded instructions. 121 // Improperly handled VEX encoded instructions.
122 const uint8_t kVpermq[] = {0xC4, 0xE3, 0xFD, 0x00, 0xED, 0x44}; 122 const uint8_t kVpermq[] = {0xC4, 0xE3, 0xFD, 0x00, 0xED, 0x44};
123 const uint8_t kVpermd[] = {0xC4, 0xE2, 0x4D, 0x36, 0xC0}; 123 const uint8_t kVpermd[] = {0xC4, 0xE2, 0x4D, 0x36, 0xC0};
124 const uint8_t kVbroadcasti128[] = {0xC4, 0xE2, 0x7D, 0x5A, 0x45, 0xD0}; 124 const uint8_t kVbroadcasti128[] = {0xC4, 0xE2, 0x7D, 0x5A, 0x45, 0xD0};
125 const uint8_t kVinserti128[] = {0xC4, 0xE3, 0x7D, 0x38, 0x2C, 0x0F, 0x01}; 125 const uint8_t kVinserti128[] = {0xC4, 0xE3, 0x7D, 0x38, 0x2C, 0x0F, 0x01};
126 const uint8_t kVpbroadcastb[] = {0xC4, 0xE2, 0x79, 0x78, 0xC0}; 126 const uint8_t kVpbroadcastb[] = {0xC4, 0xE2, 0x79, 0x78, 0xC0};
127 const uint8_t kVbroadcastss[] = {0xC4, 0xE2, 0x7d, 0x18, 0xC0};
127 const uint8_t kVextracti128[] = {0xC4, 0xE3, 0x7D, 0x39, 0xC8, 0x01}; 128 const uint8_t kVextracti128[] = {0xC4, 0xE3, 0x7D, 0x39, 0xC8, 0x01};
128 const uint8_t kVcvtps2ph[] = {0xC4, 0xE3, 0x79, 0x1D, 0xC8, 0x00}; 129 const uint8_t kVcvtps2ph[] = {0xC4, 0xE3, 0x79, 0x1D, 0xC8, 0x00};
129 const uint8_t kVcvtps2ps[] = {0xC4, 0xE2, 0x79, 0x13, 0xE0}; 130 const uint8_t kVcvtps2ps[] = {0xC4, 0xE2, 0x79, 0x13, 0xE0};
130 131
131 void TestBadlyDecodedInstruction(const uint8_t* code, size_t code_length) { 132 void TestBadlyDecodedInstruction(const uint8_t* code, size_t code_length) {
132 _DInst inst[1] = {}; 133 _DInst inst[1] = {};
133 unsigned int inst_count = 0; 134 unsigned int inst_count = 0;
134 _DecodeResult result = RawDecomposeCode( 135 _DecodeResult result = RawDecomposeCode(
135 code, code_length, inst, arraysize(inst), &inst_count); 136 code, code_length, inst, arraysize(inst), &inst_count);
136 EXPECT_EQ(DECRES_MEMORYERR, result); 137 EXPECT_EQ(DECRES_MEMORYERR, result);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 TEST(DisassemblerUtilTest, TestBadlyDecodedVinserti128) { 380 TEST(DisassemblerUtilTest, TestBadlyDecodedVinserti128) {
380 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction( 381 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
381 kVinserti128, sizeof(kVinserti128))); 382 kVinserti128, sizeof(kVinserti128)));
382 } 383 }
383 384
384 TEST(DisassemblerUtilTest, TestBadlyDecodedVpbroadcastb) { 385 TEST(DisassemblerUtilTest, TestBadlyDecodedVpbroadcastb) {
385 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction( 386 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
386 kVpbroadcastb, sizeof(kVpbroadcastb))); 387 kVpbroadcastb, sizeof(kVpbroadcastb)));
387 } 388 }
388 389
390 TEST(DisassemblerUtilTest, TestBadlyDecodedVbroadcastss) {
391 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
392 kVpbroadcastb, sizeof(kVbroadcastss)));
393 }
394
389 TEST(DisassemblerUtilTest, TestBadlyDecodedVextracti128) { 395 TEST(DisassemblerUtilTest, TestBadlyDecodedVextracti128) {
390 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction( 396 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
391 kVextracti128, sizeof(kVextracti128))); 397 kVextracti128, sizeof(kVextracti128)));
392 } 398 }
393 399
394 TEST(DisassemblerUtilTest, TestBadlyDecodedVcvtps2ph) { 400 TEST(DisassemblerUtilTest, TestBadlyDecodedVcvtps2ph) {
395 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction( 401 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
396 kVcvtps2ph, sizeof(kVcvtps2ph))); 402 kVcvtps2ph, sizeof(kVcvtps2ph)));
397 } 403 }
398 404
399 TEST(DisassemblerUtilTest, TestBadlyDecodedVcvtps2ps) { 405 TEST(DisassemblerUtilTest, TestBadlyDecodedVcvtps2ps) {
400 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction( 406 EXPECT_NO_FATAL_FAILURE(TestBadlyDecodedInstruction(
401 kVcvtps2ps, sizeof(kVcvtps2ps))); 407 kVcvtps2ps, sizeof(kVcvtps2ps)));
402 } 408 }
403 409
404 TEST(DisassemblerUtilTest, TestBadlyDecodedCRC32) { 410 TEST(DisassemblerUtilTest, TestBadlyDecodedCRC32) {
405 // CRC32 with a 16 bit operand size prefix is not handled correctly by 411 // CRC32 with a 16 bit operand size prefix is not handled correctly by
406 // distorm. 412 // distorm.
407 EXPECT_NO_FATAL_FAILURE( 413 EXPECT_NO_FATAL_FAILURE(
408 TestBadlyDecodedInstruction(kCrc32CX, sizeof(kCrc32CX))); 414 TestBadlyDecodedInstruction(kCrc32CX, sizeof(kCrc32CX)));
409 } 415 }
410 416
411 } // namespace core 417 } // namespace core
OLDNEW
« no previous file with comments | « syzygy/core/disassembler_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698