![](/img/trans.png)
[英]Get a probed function's arguments in the entry_handler of a kretprobe
[英]Get a function's return value in a kretprobe handler
我想知道是否有可能將kretprobe鈎在內核函數上,並在kretprobe的返回處理程序中捕獲其返回值。
這個問題有點老了,但是對於那些仍在尋找答案的人。
如何注冊kretprobe,您可以在kprobes的文檔中查看( https://www.kernel.org/doc/Documentation/kprobes.txt )
與體系結構無關的功能,可從syscalls中捕獲ret值:
#include <linux/ptrace.h>
...
int hook_retcode(struct kretprobe_instance *ri, struct pt_regs *regs)
{
unsigned long retval = 0;
retval = regs_return_value(regs);
if (is_syscall_success(regs))
{
printk("%pf exited with a code %#lx\n", ri->rp->kp.addr, retval);
}
else
{
printk("%pf failed with a code %#lx\n", ri->rp->kp.addr, retval);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.