Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Output cleanups for when the exception arises in a separate thread
[simgrid.git] / src / xbt / ex.c
index 3cbbbcd..c331605 100644 (file)
@@ -81,7 +81,9 @@ void xbt_backtrace_display_current(void) {
   xbt_backtrace_display(&e);
 }
 
+#ifndef WIN32
 extern char **environ; /* the environment, as specified by the opengroup */
+#endif
 
 void xbt_ex_setup_backtrace(xbt_ex_t *e)  {
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_POPEN) && defined(ADDR2LINE)
@@ -118,7 +120,7 @@ void xbt_ex_setup_backtrace(xbt_ex_t *e)  {
     for (i=0; environ[i]; i++) {
       if (!strncmp("PATH=",environ[i], 5)) {   
        xbt_dynar_t path=xbt_str_split(environ[i] + 5, ":");
-       int cpt;
+       unsigned int cpt;
        char *data;
        xbt_dynar_foreach(path, cpt, data) {
          if (binary_name)
@@ -295,18 +297,17 @@ void xbt_ex_setup_backtrace(xbt_ex_t *e)  {
     free(addrs[i]);
      
     /* Mask the bottom of the stack */    
-    if (!strncmp("main",line_func,strlen("main"))) {
-       int j;
-       for (j=i+1; j<e->used; j++)
-        free(addrs[j]);
-       e->used = i+1;
-    }
-     
-    if (!strncmp("__context_wrapper",line_func,strlen("__context_wrapper"))) {
+    if (!strncmp("main",line_func,strlen("main")) ||
+       !strncmp("xbt_thread_context_wrapper",line_func,strlen("xbt_thread_context_wrapper"))) {
        int j;
        for (j=i+1; j<e->used; j++)
         free(addrs[j]);
        e->used = i;
+
+       if (!strncmp("xbt_thread_context_wrapper",line_func,strlen("xbt_thread_context_wrapper"))) {
+         e->used++;
+         e->bt_strings[i] = bprintf("**   (in a separate thread)");
+       }       
     }