Operating System - HP-UX
1834015 Members
2759 Online
110063 Solutions
New Discussion

Re: tracing gethostbyname() calls

 
rvent
Frequent Advisor

tracing gethostbyname() calls

Hello,

I've been looking for a way to find which process is called gethostbyname() and have have no luck on finding a solution.

I know that tusc can attach itself to an specific process and see the calls it makes, but i have so many processes for IBM UniData that i cant really do it to all of them.

So my question is: Is there any way to know which process is calling gethostbyname()...?

If i could attach tusc to gethostbyname() and then just wait to see who calls it, it would be terrific...

Any ideas..?

Thanks
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: tracing gethostbyname() calls

You can have tusc only log specific system calls. Unfortunately I don't think gethostbyname is a system call but composed of parts.
Trying a small example, I only see opens:
open("/etc/nsswitch.conf"
open("/usr/lib/hpux32/libnss_files.so.1"
open("/etc/hosts"
And possibly:
open("/etc/resolv.conf"
socket(AF_INET, SOCK_DGRAM, 0)
connect(6, 0x76fe1050, 16)
send(6,
poll(0x7fffd318, 1, 5000)
recvfrom(6,

You might also be able to create a gethostbyname stub that prints out a message and then calls the real one, after using dlsym to find the real one.
Then you could just export LD_PRELOAD with the shlib that has the stub.