Get return address of a function using kretprobe or bpf

253 Views Asked by At

Is it possible to identify where the kernel function returned using kretprobe or BPF code? For example;

void func()
{
.........some line......
.........some line......
  if (condition1)
    return;
.........some line......
.........some line......
  if(condition2)
     return;
.........some line......
  if(condition3)
     return;
.........some line......
.........some line......
.........some line......
  return;
}

If I have a kernel function like this, how would I know which return was hit?

1

There are 1 best solutions below

0
On

I guess you can create a kprobe on each return line.

If you are the author of the function you try to trace, I'd just set a global variable to certain value for each branch taken.