Hi,

Just developing upon Mulyadi's idea:

> A quick idea would be to implement something like /proc/tracethispid
> which read integer. Then you do i.e "echo 1111 > /proc/tracethispid"
> and store this integer in a kernel variable.

A simpler technique could simply be storing the "current" pid in the
target_pid in the proc read handler for /proc/tracethispid. The user
space can then stop worrying about finding its own pid. The rest is same
as below.

Thanks,

Rajat

> 
> Use this variable inside a condition checking: (not sure if "current"
> is still called like 2.6.x used to be)
> if unlikely(current->pid = target_pid)
> {
>      printk("tracing function xyz"); /* FIXME: I forgot the gcc
> function to print current functio name, maybe it's __function__ }
> 
> here, "unlikely" is used to accelerate the whole function call,
> because IMHO not all the time your we hit the function when the
> backing process's pid is our target pid, right?
> 
> just 2 cents idea...
> --
> regards,
> 
> Mulyadi Santosa
> Freelance Linux trainer and consultant
> 
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to