Home | History | Annotate | Download | only in scripts
      1 #!/bin/sh
      2 #
      3 # Test to see if backtrace requires a library in /usr/lib
      4 # Returns true if the backtrace command works and requires a library in /usr/lib
      5 # This is a nasty workaround for Debian bug #708307, which is really a glibc bug
      6 #
      7 
      8 cat > /tmp/backtrace$$.c << EOF
      9 
     10 #include <execinfo.h>
     11 
     12 int main(int argc, char **argv)
     13 {
     14        void *stack_syms[32];
     15        int frames;
     16 
     17        frames = backtrace(stack_syms, 32);
     18        backtrace_symbols_fd(stack_syms, frames, 0);
     19 }
     20 EOF
     21 
     22 if ! cc -o /tmp/backtrace$$ /tmp/backtrace$$.c; then
     23    exit 1
     24 fi
     25 
     26 if ! ldd /tmp/backtrace$$ > /tmp/backtrace$$.ldd 2>&1 ; then
     27    exit 1
     28 fi
     29 
     30 grep -q /usr/lib /tmp/backtrace$$.ldd
     31 ret=$?
     32 
     33 /bin/rm -f /tmp/backtrace$$*
     34 exit $ret
     35