已关闭
[fix] h6 #28
JankinEE创建于 9月29日关闭于 17 天前
[fix] h6 #28
已关闭
共 5 个文件变更+28-30525
| @@ -5586,16 +5586,30 @@ diff -urN mockcpp-2.7/include/mockcpp/IsEqual.h mockcpp-2.7-patch/include/mockcp | |||
| 5586 | ***/ | 5586 | ***/ |
| 5587 | 5587 | ||
| 5588 | #ifndef __MOCKCPP_IS_EQUAL_H | 5588 | #ifndef __MOCKCPP_IS_EQUAL_H |
| 5589 | -@@ -21,7 +22,7 @@ | 5589 | +@@ -21,7 +22,8 @@ |
| 5590 | #include <mockcpp/types/AnyCast.h> | 5590 | #include <mockcpp/types/AnyCast.h> |
| 5591 | #include <mockcpp/Constraint.h> | 5591 | #include <mockcpp/Constraint.h> |
| 5592 | #include <mockcpp/Formatter.h> | 5592 | #include <mockcpp/Formatter.h> |
| 5593 | -#include <memory> | 5593 | -#include <memory> |
| 5594 | +#include <string.h> | 5594 | +#include <string.h> |
| 5595 | ++#include <type_traits> | ||
| 5595 | 5596 | ||
| 5596 | MOCKCPP_NS_START | 5597 | MOCKCPP_NS_START |
| 5597 | 5598 | ||
| 5598 | -@@ -52,36 +53,6 @@ | 5599 | +@@ -37,7 +39,11 @@ |
| 5600 | + bool eval(const RefAny& val) const | ||
| 5601 | + { | ||
| 5602 | + if(!any_castable<T>(val)) return false; | ||
| 5603 | +- return any_cast<T>(val) == expectedValue; | ||
| 5604 | ++ if constexpr (std::is_class<T>::value || std::is_union<T>::value) { | ||
| 5605 | ++ return !memcmp((void *)&val, (void *)&expectedValue, sizeof(T)); | ||
| 5606 | ++ } else { | ||
| 5607 | ++ return any_cast<T>(val) == expectedValue; | ||
| 5608 | ++ } | ||
| 5609 | + } | ||
| 5610 | + | ||
| 5611 | + std::string toString() const | ||
| 5612 | +@@ -52,36 +58,6 @@ | ||
| 5599 | T expectedValue; | 5613 | T expectedValue; |
| 5600 | }; | 5614 | }; |
| 5601 | 5615 | ||
| @@ -11344,7 +11358,7 @@ diff -urN mockcpp-2.7/src/JmpCodeAARCH32.h mockcpp-2.7-patch/src/JmpCodeAARCH32. | |||
| 11344 | diff -urN mockcpp-2.7/src/JmpCodeAARCH64.h mockcpp-2.7-patch/src/JmpCodeAARCH64.h | 11358 | diff -urN mockcpp-2.7/src/JmpCodeAARCH64.h mockcpp-2.7-patch/src/JmpCodeAARCH64.h |
| 11345 | --- mockcpp-2.7/src/JmpCodeAARCH64.h 1970-01-01 08:00:00.000000000 +0800 | 11359 | --- mockcpp-2.7/src/JmpCodeAARCH64.h 1970-01-01 08:00:00.000000000 +0800 |
| 11346 | +++ mockcpp-2.7-patch/src/JmpCodeAARCH64.h 2026-03-04 11:11:46.624667741 +0800 | 11360 | +++ mockcpp-2.7-patch/src/JmpCodeAARCH64.h 2026-03-04 11:11:46.624667741 +0800 |
| 11347 | -@@ -0,0 +1,85 @@ | 11361 | +@@ -0,0 +1,76 @@ |
| 11348 | + | 11362 | + |
| 11349 | +#ifndef __MOCKCPP_JMP_CODE_AARCH64_H__ | 11363 | +#ifndef __MOCKCPP_JMP_CODE_AARCH64_H__ |
| 11350 | +#define __MOCKCPP_JMP_CODE_AARCH64_H__ | 11364 | +#define __MOCKCPP_JMP_CODE_AARCH64_H__ |
| @@ -11381,25 +11395,19 @@ diff -urN mockcpp-2.7/src/JmpCodeAARCH64.h mockcpp-2.7-patch/src/JmpCodeAARCH64. | |||
| 11381 | + | 11395 | + |
| 11382 | +const unsigned char jmpCodeTemplate[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 11396 | +const unsigned char jmpCodeTemplate[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 11383 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 11397 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 11384 | -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 11398 | ++ 0x00, 0x00, 0x00, 0x00}; // 覆写20字节,需配合-falign-functions=32避免越界破坏相邻函数 |
| 11385 | -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 11399 | ++const uint32_t jump_code = 0xd61f0200; // br x16 无链接跳转:不压栈不改动x30/sp,桩内抛出的C++异常可沿正常调用帧unwind回被测代码catch分支 |
| 11386 | -+ | 11400 | ++static inline uint32_t get_mov_x16_code(uintptr_t val) |
| 11387 | -+#define ARM_BYTE_ORDER(x) ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24) | ||
| 11388 | -+const uint32_t push_reg_code = ARM_BYTE_ORDER(0xfd7bbfa9); // stp x29, x30, [sp,#-16]! 先把sp指针减去16,然后,把寄存器x29和x30这两个64位寄存器存放到sp所指的地址处 | ||
| 11389 | -+const uint32_t jump_code = ARM_BYTE_ORDER(0xc0033fd6); // blr x30 跳转到装函数,执行后返回到此处的下一条指令以回复寄存器的内容 | ||
| 11390 | -+const uint32_t pop_reg_code = ARM_BYTE_ORDER(0xfd7bc1a8); // ldp x29, x30, [sp],#16 把sp所指内存地址处的16字节内容拷贝到寄存器x29和x30中,然后把sp加上16。这样,栈空间就恢复了 | ||
| 11391 | -+const uint32_t ret_code = ARM_BYTE_ORDER(0xc0035fd6); // ret | ||
| 11392 | -+static inline uint32_t get_mov_x30_code(uintptr_t val) | ||
| 11393 | +{ | 11401 | +{ |
| 11394 | -+ uint32_t code = 0xd280001e; // mov 指令是 11010010 100 + 16bit val + 5bit reg id | 11402 | ++ uint32_t code = 0xd2800010; // movz x16, #imm16:11010010 100 + 16bit val + 5bit reg id |
| 11395 | + val = (val & 0xffff) << 5; | 11403 | + val = (val & 0xffff) << 5; |
| 11396 | + code |= (uint32_t)val; | 11404 | + code |= (uint32_t)val; |
| 11397 | + return code; | 11405 | + return code; |
| 11398 | +} | 11406 | +} |
| 11399 | + | 11407 | + |
| 11400 | -+static inline uint32_t get_movk_x30_code(uintptr_t val, uint32_t pos) | 11408 | ++static inline uint32_t get_movk_x16_code(uintptr_t val, uint32_t pos) |
| 11401 | +{ | 11409 | +{ |
| 11402 | -+ uint32_t code = 0xf280001e; // movk 指令是 11110010 1 + 2bit offset + 16bit val + 5bit reg id | 11410 | ++ uint32_t code = 0xf2800010; // movk x16, #imm16, LSL #16*pos |
| 11403 | + pos &= 0x3; | 11411 | + pos &= 0x3; |
| 11404 | + val = ((val >> (16 * pos)) & 0xffff) << 5; | 11412 | + val = ((val >> (16 * pos)) & 0xffff) << 5; |
| 11405 | + code |= (uint32_t)val; | 11413 | + code |= (uint32_t)val; |
| @@ -11410,14 +11418,11 @@ diff -urN mockcpp-2.7/src/JmpCodeAARCH64.h mockcpp-2.7-patch/src/JmpCodeAARCH64. | |||
| 11410 | + | 11418 | + |
| 11411 | +#define SET_JMP_CODE(base, from, to) do { \ | 11419 | +#define SET_JMP_CODE(base, from, to) do { \ |
| 11412 | + uint32_t *d_ptr = (uint32_t *)base; \ | 11420 | + uint32_t *d_ptr = (uint32_t *)base; \ |
| 11413 | -+ d_ptr[0] = push_reg_code; \ | 11421 | ++ d_ptr[0] = get_mov_x16_code((uintptr_t)to); \ |
| 11414 | -+ d_ptr[1] = get_mov_x30_code((uintptr_t)to); \ | 11422 | ++ d_ptr[1] = get_movk_x16_code((uintptr_t)to, 1); \ |
| 11415 | -+ d_ptr[2] = get_movk_x30_code((uintptr_t)to, 1); \ | 11423 | ++ d_ptr[2] = get_movk_x16_code((uintptr_t)to, 2); \ |
| 11416 | -+ d_ptr[3] = get_movk_x30_code((uintptr_t)to, 2); \ | 11424 | ++ d_ptr[3] = get_movk_x16_code((uintptr_t)to, 3); \ |
| 11417 | -+ d_ptr[4] = get_movk_x30_code((uintptr_t)to, 3); \ | 11425 | ++ d_ptr[4] = jump_code; \ |
| 11418 | -+ d_ptr[5] = jump_code; \ | ||
| 11419 | -+ d_ptr[6] = pop_reg_code; \ | ||
| 11420 | -+ d_ptr[7] = ret_code; \ | ||
| 11421 | +} while (0) | 11426 | +} while (0) |
| 11422 | + | 11427 | + |
| 11423 | +#define FLUSH_CACHE(from, length) do { \ | 11428 | +#define FLUSH_CACHE(from, length) do { \ |
此文件变更行数或变更字符数较多,你可以直接
Binary files do not support preview
Binary files do not support preview
此文件变更行数或变更字符数较多,你可以直接