develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33525 - in trunk: config/gen/config_h src

From:
chromatic
Date:
December 5, 2008 11:52
Subject:
[svn:parrot] r33525 - in trunk: config/gen/config_h src
Message ID:
20081205195211.3DA5DCB9AF@x12.develooper.com
Author: chromatic
Date: Fri Dec  5 11:52:10 2008
New Revision: 33525

Modified:
   trunk/config/gen/config_h/feature_h.in
   trunk/src/exceptions.c

Log:
[src] Added configuration code to include the header which defines Dl_info
(used to find backtrace information in Parrot_print_backtrace()).  If this
doesn't break the build on non-GNU systems, this fixes RT #58668, reported by
Christoph Otto, we can use make cover again.  If it does break the build, we'll
have to be smarter and probe for glibc.  Either way, this is closer to correct.

It also includes some minor code tidying in src/exceptions.c.

Modified: trunk/config/gen/config_h/feature_h.in
==============================================================================
--- trunk/config/gen/config_h/feature_h.in	(original)
+++ trunk/config/gen/config_h/feature_h.in	Fri Dec  5 11:52:10 2008
@@ -145,7 +145,10 @@
 if (defined @backtrace@) {
     print OUT <<"END_PRINT";
 #define PARROT_HAS_BACKTRACE
-#define __USE_GNU
+#ifndef __USE_GNU
+#  define __USE_GNU
+#endif
+#include <dlfcn.h>
 END_PRINT
 }
 

Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c	(original)
+++ trunk/src/exceptions.c	Fri Dec  5 11:52:10 2008
@@ -291,8 +291,9 @@
     }
 
     if (Interp_debug_TEST(interp, PARROT_BACKTRACE_DEBUG_FLAG)) {
-        int exitcode = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "exit_code"));
-        STRING *msg = VTABLE_get_string(interp, exception);
+        STRING *msg      = VTABLE_get_string(interp, exception);
+        int     exitcode = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "exit_code"));
+
         PIO_eprintf(interp,
             "Parrot_ex_throw_from_c (severity:%d error:%d): %Ss\n",
             EXCEPT_error, exitcode, msg);
@@ -542,21 +543,20 @@
             size, BACKTRACE_DEPTH);
 #  ifndef BACKTRACE_VERBOSE
     for (i = 0; i < size; i++) {
-        Dl_info frameInfo;
-        int found;
+        Dl_info   frameInfo;
+        const int found  = dladdr(array[i], &frameInfo);
 
         /* always indent */
-        const int indent = 2 + (2*i);
+        const int indent = 2 + ( 2 * i);
 
         fprintf(stderr, "%*s", indent, "");
-        found = dladdr(array[i], &frameInfo);
-        if (0 == found || NULL == frameInfo.dli_sname) {
-            fprintf(stderr, "(unknown)\n");
-        }
-        else {
+
+        if (found && frameInfo.dli_sname)
             fprintf(stderr, "%s\n", frameInfo.dli_sname);
-        }
+        else
+            fprintf(stderr, "(unknown)\n");
     }
+
 #  else
     { /* Scope for strings */
         char ** strings = backtrace_symbols(array, size);



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About