trace only after some point, to say function "main"

Roland McGrath roland at redhat.com
Thu Dec 10 01:05:22 UTC 2009


> Thanks for the quick reply. So if I want to add such staff to strace,
> do you think it is easy? For the first process, it is not hard, but I
> am not sure how to handle the forked processes along the way.

I would not call it easy in any case.  You would need to do real breakpoint
insertion and handle hitting it, with variants for every arch, etc.  It's
probably easier to use gdb for that and bend its "catch syscall" to what
you wanted strace for.

> To take the other way you suggested, is there any system call, when it
> happen, can indicate that function main (or other specified point),
> has been reached, or to be reached in a very short term?

Not really.  Especially not if you really want to see main and consider
shared libraries' initializers (not just dynamic linker startup stuff) as
"uninteresting".  In recent libc's on common configurations, the TLS setup
is close to the end of the dynamic linker startup phase.  On x86_64 that's
an arch_prctl call and on i386 a set_thread_area call.  But on other
machines there is no syscall associated with that, so I don't have any good
suggestion off hand.

I guess you might try hacking on ltrace instead.


Thanks,
Roland




More information about the Strace-devel mailing list