* sim-trace.c (trace_uninstall): Don't close a file twice.
authorDavid Edelsohn <dje.gcc@gmail.com>
Tue, 6 May 1997 23:38:31 +0000 (23:38 +0000)
committerDavid Edelsohn <dje.gcc@gmail.com>
Tue, 6 May 1997 23:38:31 +0000 (23:38 +0000)
sim/common/ChangeLog
sim/common/sim-trace.c

index 76dfbb4cc32687ef72029938750a9beaffbe3638..b9332d8121c261b3aaa5f4d90012bd4ace37b5c2 100644 (file)
@@ -1,3 +1,7 @@
+Tue May  6 16:38:16 1997  Doug Evans  <dje@canuck.cygnus.com>
+
+       * sim-trace.c (trace_uninstall): Don't close a file twice.
+
 Tue May  6 06:14:01 1997  Mike Meissner  <meissner@cygnus.com>
 
        * sim-trace.c (toplevel): Include bfd.h.
index a10be4a1f59ed83f37cfea07e4e0efc373f9990a..a2eec25a9c6d66e8d91d73410d6bbc3c7ccdc906 100644 (file)
@@ -286,13 +286,22 @@ trace_install (SIM_DESC sd)
 static void
 trace_uninstall (SIM_DESC sd)
 {
-  int i;
+  int i,j;
 
   for (i = 0; i < MAX_NR_PROCESSORS; ++i)
     {
       TRACE_DATA *data = CPU_TRACE_DATA (STATE_CPU (sd, i));
       if (TRACE_FILE (data) != NULL)
-       fclose (TRACE_FILE (data));
+       {
+         /* If output from different cpus is going to the same file,
+            avoid closing the file twice.  */
+         for (j = 0; j < i; ++j)
+           if (TRACE_FILE (CPU_TRACE_DATA (STATE_CPU (sd, j)))
+               == TRACE_FILE (data))
+             break;
+         if (i == j)
+           fclose (TRACE_FILE (data));
+       }
     }
 }
 \f