[lttng-dev] Problem using UST with PHP

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Sat Mar 31 15:11:58 EDT 2012


* Ettore Del Negro (ettore at ettoredelnegro.me) wrote:
> Hello,
> i missed that part of the README, thanks for let me know.
> Summing up, i have to link PHP with -llttng-ust and preload the fork
> library using something like:
> 
> env LD_PRELOAD="/usr/lib64/liblttng-ust-fork.so" /usr/sbin/php-fpm
> --fpm-config /etc/php5/fpm/php-fpm.conf
> 
> Is that right?

Yep.

> 
> Before your reply i ran PHP without LD_PRELOAD'ing and apparently all
> went fine. Is that a normal behavior? What should i expect to happen if
> i don't preload it? Is it possible i get misleading results (timestamps)?
> Maybe it's worth to note i run FPM with only one child, so it forks only
> once.

If you don't do the LD_PRELOAD, and the application forks before you
create your session/enable event/start tracing, there won't be any UST
thread listening for those commands on the child process, so these
events would never be traced.

If tracing was setup and started before the fork, I the child will very
likely write its data into the same shared buffers as the parent, so it
even though the events would be written in that case, the child process
data will appear to be written from the parent process.

Hoping this clarify the expected behavior,

Mathieu

> 
> Thanks,
> Ettore
> 
> On 13/3/2012 11:42 PM, Mathieu Desnoyers wrote:
> > * Ettore Del Negro (ettore at ettoredelnegro.me) wrote:
> >> Hello,
> >> thanks for reply, anyway i already found what was missing: #define
> >> TRACEPOINT_CREATE_PROBES
> >> I looked at lttng-ust-2.0.0-rc2/tests/fork/fork.c and saw it, since
> >> i'm using a fork-based SAPI (PHP-FPM) i gave it a try and worked.
> > FYI, if your application forks without issuing execs afterward, you'll
> > need to LD_PRELOAD liblttng-ust-fork.so. Quoting the README:
> >
> >   - liblttng-ust-fork
> >     A library that is LD_PRELOAD'ed, and that hijacks calls to several system
> >     calls in order to trace across these calls. It _has_ to be LD_PRELOAD'ed
> >     in order to hijack calls. In contrast, libust may be linked at build time.
> >
> >
> >> Maybe is it worth to add a a note in the README?
> >>
> >> The relevant diff applied to PHP is this: https://github.com/ettoredn/php-debug/commit/f1f6c6f23c1ea6c82b9ff9d5a1b46565f1c36b0e
> >> (note: see next commit for zend_trace_provider.h, i forgot it in this one).
> >>
> >> Now my question becomes: why TRANCEPOINT_CREATE_PROBES is needed with fork?
> > TRACEPOINT_CREATE_PROBE is needed with each instrumentation style, it
> > should appear at least once in the program (even for the hello test
> > program).
> >
> > Thanks,
> >
> > Mathieu
> >
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list