cpp-stub
cpp-stub copied to clipboard
C++ unit test stub(not mock) and awesome.Surpported ISA x86,x86-64,arm64,arm32,arm thumb,mips64,riscv,loongarch64.
前两天在使用 stub 进行插桩时,遇到了在 arm32 上执行段错误的问题,通过对源代码的反汇编分析发现,使用 arm-linux-g++ 编译器编译出来的地址和程序中获取函数的地址有差距,后来发现需要在编译的时候添加 `-marm` 参数。这样就能得到正确的地址了。
arm platform contructor stub across segmentation fault test for windows + docker, success test for mac(arm) + docker, fails, segment fault when contructor called I guess function get_dtor_addr may have...
root@centos:/home/xxx/cpp-stub/ut_examples/gtest/ut/src# ll total 12 drwxr-xr-x. 4 root root 87 Feb 4 07:57 ./ drwxr-xr-x. 5 root root 43 Feb 3 10:12 ../ -rw-r--r--. 1 root root 588 Feb 4 07:31...
remove the line "Type Class::Name;" can fix the failure /*#define ACCESS_PRIVATE_STATIC_FIELD(Class, Type, Name) \ **Type Class::Name; */ \** #define ACCESS_PRIVATE_STATIC_FIELD(Class, Type, Name) \ PRIVATE_ACCESS_DETAIL_ACCESS_PRIVATE_STATIC_FIELD( \ PRIVATE_ACCESS_DETAIL_UNIQUE_TAG, Class, Type, Name)
In a qemu environment, when the stub::set function is executed, The permission of the internal call if (-1 == mprotect(pageof(pstub->fn), m_pagesize * 2, PROT_READ | PROT_WRITE | PROT_EXEC)) is denied....
example: namespace A { namespace B { namespace C { int func(int a, std::string b) { xxxx; return 0; } } } } int stub_func(int a, std::string b) { return...
``` cpp #include #include int main() { // 打开当前可执行文件(假设已使用-rdynamic编译) void *handle = dlopen(NULL, RTLD_LAZY); if (!handle) { fprintf(stderr, "dlopen failed: %s\n", dlerror()); return 1; } // 获取函数指针 void (*hello)() =...
报错提示成员函数指针不允许转换为普通函数指针
void func(int a) {} int main () { std::function f = [] (int a) {} ; stub.set(func, f); // 类似这样的调用? }
Demo: [StubTestDemo.zip](https://github.com/user-attachments/files/18979081/StubTestDemo.zip)  as the pic, fake method and target method distance exceeds 32 bytes, so far jump be using, but 13 byte command corrupt method `MyClass::getState`, cause crash when...