[SciPy-user] A useful little debugging script...

Skip Montanaro skip at pobox.com
Thu Sep 5 15:13:43 EDT 2002


While trying to track down unreferenced symbol errors on a Sun install of
SciPy I wrote the attached Python script to quickly identify the location of
such symbols.  You run it like so:

    python findlibs.py <link command>

or

    python findlibs.py -f pattern1 -f pattern2 ... <link command>

It saves any patterns you give it, then analyzes the -L, -l and .o elements
of the link command, and lists what it finds.  Here's an example:

    $ python findlibs.py -f s_stop f90 build/temp.solaris-2.8-sun4u-2.2/fortranobject.o build/temp.solaris-2.8-sun4u-2.2/_flinalgmodule.o -L/home/skip/local/SunOS/lib/atlas -Lbuild/temp.solaris-2.8-sun4u-2.2 -Lbuild/temp.solaris-2.8-sun4u-2.2 -Lbuild/temp.solaris-2.8-sun4u-2.2 -Lbuild/temp.solaris-2.8-sun4u-2.2 -Lbuild/temp.solaris-2.8-sun4u-2.2 -Lbuild/temp.solaris-2.8-sun4u-2.2 -L/opt/SUNWspro/prod/lib -L/home/skip/local/SunOS/lib -R/opt/SUNWspro/prod/lib -R/home/skip/local/SunOS/lib -l_flinalg -lfblas -llapack -lf77blas -lcblas -latlas -lfsu -lF77 -lM77 -lsunmath -lmvec -lf77compat -lm -o build/lib.solaris-2.8-sun4u-2.2/scipy/linalg/_flinalg.so -Bdynamic -G
    Dirs:
      /home/skip/local/SunOS/lib
      /opt/SUNWspro/prod/lib
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2
      /home/skip/local/SunOS/lib/atlas
      /usr/lib
      /usr/ccs/lib
    Libs:
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2/lib_flinalg.a
      /home/skip/src/scipy/build/temp.solaris-2.8-sun4u-2.2/libfblas.a
      /home/skip/local/SunOS/lib/atlas/liblapack.a
    0000000000 U s_stop
      /home/skip/local/SunOS/lib/atlas/libf77blas.a
      /home/skip/local/SunOS/lib/atlas/libcblas.a
      /home/skip/local/SunOS/lib/atlas/libatlas.a
      /opt/SUNWspro/prod/lib/libfsu.a
      /home/skip/local/SunOS/lib/libF77.so
    0000039648 T __s_stop
    0000039392 T __s_stop_nv
    0000000000 f s_stop.c
    0000000000 f s_stop_nv.c
      /home/skip/local/SunOS/lib/libM77.so
      /opt/SUNWspro/prod/lib/libsunmath.a
      /opt/SUNWspro/prod/lib/libmvec.a
      /opt/SUNWspro/prod/lib/libf77compat.a
    /opt/SUNWspro/prod/lib/libf77compat.a[s_stop.o]:
    0000000016 T __s_stop
    0000000088 T __s_stop_p
    0000000000 f s_stop.c
    /opt/SUNWspro/prod/lib/libf77compat.a[s_stop_nv.o]:
    0000000016 T __s_stop_nv
    0000000096 T __s_stop_p_nv
    0000000000 f s_stop_nv.c
      /usr/lib/libm.a
    Objects:
      build/temp.solaris-2.8-sun4u-2.2/fortranobject.o
      build/temp.solaris-2.8-sun4u-2.2/_flinalgmodule.o

This identified the source of the unresolved symbol - s_stop in this case -
much more quickly than I could have done so by hand.  In fact, writing and
debugging the script was probably faster than manually performing the search
once.

I made no stab at portability, but it should be easy to adapt to other
varieties of Unix (different nm flags and possibly different shared library
extensions).  It is, as they say, a 90% solution. ;-)

Cheers,

-- 
Skip Montanaro
skip at pobox.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 1525 bytes
Desc: symbol finder
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20020905/0c5f0b6c/attachment.obj>


More information about the SciPy-User mailing list