c++clinuxltrace

How to use ltrace with wildcards


I'm new to ltrace.

E.g. this works:

ltrace -c -e "XDrawLine" -p 10876 ^C
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
100.00    4.925592         501      9829 XDrawLine
------ ----------- ----------- --------- --------------------
100.00    4.925592                  9829 total

But this matches nothing:

trace -c -e "XDrawLin*" -p 10876
^C
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
------ ----------- ----------- --------- --------------------
100.00    0.000000                     0 total

Also, no luck with -e "/XDrawLin.*/" or -e "XDrawLin.*" either. Any working example is appreciated.


Solution

  • The functionality of the -e switch evolved over ltrace releases. Even fairly recent Linux releases frequently shipped an older ltrace, and that’s most likely is the issue for you. (For example, RHEL6 if I remember correctly, ships with version 0.5.) Run ltrace --v and make sure you have version 0.7 and above.

    * Version 0.7.0 [2012-11-09 Fri]
    
    ** Tracing
    ...
    
    *** Limited support for tracing returns from tail call functions
    
    *** -e, -x and -l selectors now allow using globs and regular expressions
    

    http://anonscm.debian.org/gitweb/?p=collab-maint/ltrace.git;a=blob_plain;f=NEWS;hb=0.7.3

    If you have an older ltrace - update it with your package manager or download it from http://freecode.com/projects/ltrace