Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #8
Go 会为泛型函数生成中间函数。但实际需要 mock 的是中间函数所
调用的公共函数。为此,我们需要遍历中间函数机器码,通过 CALL
指令确定公共函数的地址。
如果函数使用了 struct 值传递,Go 在一些场景下会插入若干额外
的 CALL 指令。这样 monkey 就会拿到错误的公共函数地址。
为此,我们需要跳过因为 struct 传值而需要执行的 CALL 指令。
通过观察生成的汇编代码,我发现这些 CALL 指令用 BP 寄存器,而
调用公共函数用的是 AX 寄存器。所以可以根据寄存器参数来过滤。