Commits

Anonymous committed 668dfbf

use eu-addr2line, if present on the system

Comments (0)

Files changed (3)

+2011-04-20  Rolf Seuster < seuster AT cern.ch>
+	* use eu-addr2line, if present on the system
+	* eu-addr2line follows .gnu_debuglink (debug symbols in a separate library)
+	* tagging CxxUtils-00-00-73
+
 2011-03-26  scott snyder  <snyder@bnl.gov>
 
 	* CxxUtils/unused.h: (new)

CxxUtils/SealDebug.h

 
 private:
     static IOFD			s_stackTraceFd;
+    static unsigned int         s_have_eu_addr2line;
 };
 
 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>

src/SealDebug.cxx

 
 /** The default output file descriptor for #stacktrace().  */
 IOFD			DebugAids::s_stackTraceFd = IOFD_INVALID;
+unsigned int            DebugAids::s_have_eu_addr2line=0;
 
 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
 
     {
       if (getenv ("LD_PRELOAD"))
         unsetenv ("LD_PRELOAD");
-      snprintf (line, LINE_MAX, "addr2line -f -C -e %s %p", info.dli_fname,
-               (void*)relative_address);
+      
+      // check, if we have eu-addr2line (from elfutils)
+      // just check, if it's in /usr/bin/eu-addr2line, because if the user installs elfutils by hand
+      // the eu- prefix is probably missing, checking for F_OK (existence) should be enough
+      if ( DebugAids::s_have_eu_addr2line == 0 )
+	{
+	  if ( access("/usr/bin/eu-addr2line",F_OK) == 0 )
+	    {
+	      DebugAids::s_have_eu_addr2line=1;
+	    }
+	  else
+	    {
+	      DebugAids::s_have_eu_addr2line=2;
+	    }
+	}
+      
+      if ( DebugAids::s_have_eu_addr2line == 1 )
+	{
+	  snprintf (line, LINE_MAX, "/usr/bin/eu-addr2line -f -C -e %s %p", info.dli_fname,
+		    (void*)relative_address);
+	}
+      else
+	{
+	  snprintf (line, LINE_MAX, "addr2line -f -C -e %s %p", info.dli_fname,
+		    (void*)relative_address);
+	}
 
       pfd = stacktracePopenFD( line, child_pid );