This is the mail archive of the systemtap@sources.redhat.com mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Function tracing


Vara Prasad wrote:

> int max(int a, int b)
> {
>    if (a < b)
>       return b;
>    else
>       return a;
> }
> 
> What we cannot find out with return probes is, which of the the two
> possible return statements was executed.
> I would think this feature will be very useful for tracing the code
> path.

It is unrealistic to expect this to work.  The compile might not even
generate separate exit paths.  In fact, gcc in most cases will generate
just one ret opcode.  The above function, on x86-64, might be compiled as

  cmp    %esi,%edi
  cmovge %edi,%esi
  mov    %esi,%eax
  retq

If you would want instrumentation, you would have to explicitly replace
the return statement with something you can set a breakpoint on.  This
will never be accepted into the general kernel since it's a major
performance regression.

Simply finding all ret instructions in a function does not achieve
anything since different C return statements might use the same ret
instruction.

-- 
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]