Author: julianalbo
Date: Mon Jan 26 15:27:49 2009
New Revision: 36040

Added:
   trunk/config/auto/backtrace/test_dlinfo_c.in
Modified:
   trunk/config/auto/backtrace.pm
   trunk/src/exceptions.c

Log:
check Dl_info availability

Modified: trunk/config/auto/backtrace.pm
==============================================================================
--- trunk/config/auto/backtrace.pm      (original)
+++ trunk/config/auto/backtrace.pm      Mon Jan 26 15:27:49 2009
@@ -56,12 +56,26 @@
     return $anyerror;
 }
 
+sub _probe_for_dlinfo {
+    my $conf = shift;
+    $conf->cc_gen("config/auto/backtrace/test_dlinfo_c.in");
+
+    # If the program compiles, the Dl_info struct is available
+
+    eval { $conf->cc_compile(); };
+    my $anyerror = $@;
+    $conf->cc_clean();
+    return $anyerror;
+}
+
 sub _evaluate_backtrace {
     my ($self, $conf, $anyerror) = @_;
     if ( $anyerror ) {
         $self->set_result("no");
     }
     else {
+        my $dlinfoerror = _probe_for_dlinfo($conf);
+        $conf->data->set ( PARROT_HAS_DLINFO => 1 ) unless $anyerror;
         $conf->data->set( backtrace => 1 );
         $self->set_result("yes");
     }

Added: trunk/config/auto/backtrace/test_dlinfo_c.in
==============================================================================
--- (empty file)
+++ trunk/config/auto/backtrace/test_dlinfo_c.in        Mon Jan 26 15:27:49 2009
@@ -0,0 +1,24 @@
+/*
+ * test_dlinfo_c.c - check that Dl_info is avaible
+ */
+
+#include <execinfo.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+
+int
+main(int argc, char **argv)
+{
+    Dl_info frameInfo;
+    return EXIT_SUCCESS;
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */

Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c      (original)
+++ trunk/src/exceptions.c      Mon Jan 26 15:27:49 2009
@@ -24,7 +24,9 @@
 
 #ifdef PARROT_HAS_BACKTRACE
 #  include <execinfo.h>
-#  include <dlfcn.h>
+#  ifdef PARROT_HAS_DLINFO
+#    include <dlfcn.h>
+#  endif
 #endif
 
 /* HEADERIZER HFILE: include/parrot/exceptions.h */
@@ -565,6 +567,9 @@
 #ifdef PARROT_HAS_BACKTRACE
 #  define BACKTRACE_DEPTH 32
 /*#  define BACKTRACE_VERBOSE */
+#  ifndef PARROT_HAS_DLINFO
+#    define BACKTRACE_VERBOSE
+#  endif
     /* stolen from http://www.delorie.com/gnu/docs/glibc/libc_665.html */
     void *array[BACKTRACE_DEPTH];
     int i;

Reply via email to