Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 struct 传值导致泛型打桩卡住的问题 #10

Merged
merged 1 commit into from
Aug 20, 2022
Merged

Commits on Aug 19, 2022

  1. 修复 struct 传值导致泛型打桩卡住的问题

    Fix #8
    
    Go 会为泛型函数生成中间函数。但实际需要 mock 的是中间函数所
    调用的公共函数。为此,我们需要遍历中间函数机器码,通过 CALL
    指令确定公共函数的地址。
    
    如果函数使用了 struct 值传递,Go 在一些场景下会插入若干额外
    的 CALL 指令。这样 monkey 就会拿到错误的公共函数地址。
    
    为此,我们需要跳过因为 struct 传值而需要执行的 CALL 指令。
    
    通过观察生成的汇编代码,我发现这些 CALL 指令用 BP 寄存器,而
    调用公共函数用的是 AX 寄存器。所以可以根据寄存器参数来过滤。
    taoso committed Aug 19, 2022
    Configuration menu
    Copy the full SHA
    1f9d72d View commit details
    Browse the repository at this point in the history