[compiler-rt] [win/asan] Add a test skeleton for function GetInstructionSize. (PR #116948)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 02:29:20 PST 2024
================
@@ -793,6 +793,38 @@ TEST(Interception, EmptyExportTable) {
EXPECT_EQ(0U, FunPtr);
}
+const struct InstructionSizeData_t {
+ size_t size; // hold instruction size or 0 for failure, e.g. on control instructions
+ u8 instr[16];
+ size_t rel_offset;
+} data[] = {
+ /* sorted list */
+ { 1, { 0x50 }, 0 }, // 50 : push eax / rax
+};
+
+std::string dumpInstruction(unsigned int arrayIndex, const InstructionSizeData_t& data) {
+ std::stringstream ret;
+ ret << " with arrayIndex=" << arrayIndex << " ( ";
+ for (size_t byteIndex = 0; byteIndex < data.size; byteIndex++) {
+ ret << std::setfill('0') << std::setw(2) << std::right << std::hex << (int)data.instr[byteIndex] << " ";
+ }
+ ret << ")";
+ return ret.str();
+}
+
+TEST(Interception, GetInstructionSize) {
+
+ size_t size;
+ size_t rel_offset;
+
+ for (unsigned int arrayIndex = 0; arrayIndex < sizeof(data)/sizeof(*data); arrayIndex++) {
----------------
zmodem wrote:
s/unsigned int/unsigned/
and i'd suggest just `i` for the index here too
https://github.com/llvm/llvm-project/pull/116948
More information about the llvm-commits
mailing list