Fix indentation in print_thread_info_1
[deliverable/binutils-gdb.git] / sim / common / sim-profile.c
index 997193377d28a076476e5002b9d7f4920fcb8292..98ee804b0494292439053189e1edee99edd5db49 100644 (file)
@@ -1,6 +1,5 @@
 /* Default profiling support.
 /* Default profiling support.
-   Copyright (C) 1996, 1997, 1998, 2000, 2001, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
@@ -190,7 +189,7 @@ set_profile_option_mask (SIM_DESC sd, const char *name, int mask, const char *ar
                }
            }
        }
                }
            }
        }
-    }  
+    }
 
   return SIM_RC_OK;
 }
 
   return SIM_RC_OK;
 }
@@ -414,7 +413,7 @@ profile_option_handler (SIM_DESC sd,
            {
              PROFILE_PC_START (CPU_PROFILE_DATA (STATE_CPU (sd, cpu_nr))) = base;
              PROFILE_PC_END (CPU_PROFILE_DATA (STATE_CPU (sd, cpu_nr))) = bound;
            {
              PROFILE_PC_START (CPU_PROFILE_DATA (STATE_CPU (sd, cpu_nr))) = base;
              PROFILE_PC_END (CPU_PROFILE_DATA (STATE_CPU (sd, cpu_nr))) = bound;
-           }         
+           }
          for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; ++cpu_nr)
            CPU_PROFILE_FLAGS (STATE_CPU (sd, cpu_nr))[PROFILE_PC_IDX] = 1;
        }
          for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; ++cpu_nr)
            CPU_PROFILE_FLAGS (STATE_CPU (sd, cpu_nr))[PROFILE_PC_IDX] = 1;
        }
@@ -521,21 +520,14 @@ profile_pc_event (SIM_DESC sd,
 {
   sim_cpu *cpu = (sim_cpu*) data;
   PROFILE_DATA *profile = CPU_PROFILE_DATA (cpu);
 {
   sim_cpu *cpu = (sim_cpu*) data;
   PROFILE_DATA *profile = CPU_PROFILE_DATA (cpu);
-  address_word pc;
+  address_word pc = sim_pc_get (cpu);
   unsigned i;
   unsigned i;
-  switch (STATE_WATCHPOINTS (sd)->sizeof_pc)
-    {
-    case 2: pc = *(unsigned_2*)(STATE_WATCHPOINTS (sd)->pc) ; break;
-    case 4: pc = *(unsigned_4*)(STATE_WATCHPOINTS (sd)->pc) ; break;
-    case 8: pc = *(unsigned_8*)(STATE_WATCHPOINTS (sd)->pc) ; break;
-    default: pc = 0;
-    }
   i = (pc - PROFILE_PC_START (profile)) >> PROFILE_PC_SHIFT (profile);
   if (i < PROFILE_PC_NR_BUCKETS (profile))
     PROFILE_PC_COUNT (profile) [i] += 1; /* Overflow? */
   else
     PROFILE_PC_COUNT (profile) [PROFILE_PC_NR_BUCKETS (profile)] += 1;
   i = (pc - PROFILE_PC_START (profile)) >> PROFILE_PC_SHIFT (profile);
   if (i < PROFILE_PC_NR_BUCKETS (profile))
     PROFILE_PC_COUNT (profile) [i] += 1; /* Overflow? */
   else
     PROFILE_PC_COUNT (profile) [PROFILE_PC_NR_BUCKETS (profile)] += 1;
-  PROFILE_PC_EVENT (profile) = 
+  PROFILE_PC_EVENT (profile) =
     sim_events_schedule (sd, PROFILE_PC_FREQ (profile), profile_pc_event, cpu);
 }
 
     sim_events_schedule (sd, PROFILE_PC_FREQ (profile), profile_pc_event, cpu);
 }
 
@@ -548,8 +540,7 @@ profile_pc_init (SIM_DESC sd)
     {
       sim_cpu *cpu = STATE_CPU (sd, n);
       PROFILE_DATA *data = CPU_PROFILE_DATA (cpu);
     {
       sim_cpu *cpu = STATE_CPU (sd, n);
       PROFILE_DATA *data = CPU_PROFILE_DATA (cpu);
-      if (CPU_PROFILE_FLAGS (STATE_CPU (sd, n))[PROFILE_PC_IDX]
-         && STATE_WATCHPOINTS (sd)->pc != NULL)
+      if (CPU_PROFILE_FLAGS (STATE_CPU (sd, n))[PROFILE_PC_IDX])
        {
          int bucket_size;
          /* fill in the frequency if not specified */
        {
          int bucket_size;
          /* fill in the frequency if not specified */
@@ -572,7 +563,7 @@ profile_pc_init (SIM_DESC sd)
                    {
                      /* nr_buckets = (full-address-range / 2) / (bucket_size / 2) */
                      PROFILE_PC_NR_BUCKETS (data) =
                    {
                      /* nr_buckets = (full-address-range / 2) / (bucket_size / 2) */
                      PROFILE_PC_NR_BUCKETS (data) =
-                       ((1 << (STATE_WATCHPOINTS (sd)->sizeof_pc) * (8 - 1))
+                       ((1 << sizeof (sim_cia) * (8 - 1))
                         / (PROFILE_PC_BUCKET_SIZE (data) / 2));
                    }
                  else
                         / (PROFILE_PC_BUCKET_SIZE (data) / 2));
                    }
                  else
@@ -591,7 +582,7 @@ profile_pc_init (SIM_DESC sd)
            {
              if (PROFILE_PC_END (data) == 0)
                /* bucket_size = (full-address-range / 2) / (nr_buckets / 2) */
            {
              if (PROFILE_PC_END (data) == 0)
                /* bucket_size = (full-address-range / 2) / (nr_buckets / 2) */
-               bucket_size = ((1 << ((STATE_WATCHPOINTS (sd)->sizeof_pc * 8) - 1))
+               bucket_size = ((1 << ((sizeof (sim_cia) * 8) - 1))
                               / (PROFILE_PC_NR_BUCKETS (data) / 2));
              else
                bucket_size = ((PROFILE_PC_END (data)
                               / (PROFILE_PC_NR_BUCKETS (data) / 2));
              else
                bucket_size = ((PROFILE_PC_END (data)
@@ -698,7 +689,7 @@ profile_print_pc (sim_cpu *cpu, int verbose)
   /* FIXME: Is this the best place for this code? */
   {
     FILE *pf = fopen ("gmon.out", "wb");
   /* FIXME: Is this the best place for this code? */
   {
     FILE *pf = fopen ("gmon.out", "wb");
-    
+
     if (pf == NULL)
       sim_io_eprintf (sd, "Failed to open \"gmon.out\" profile file\n");
     else
     if (pf == NULL)
       sim_io_eprintf (sd, "Failed to open \"gmon.out\" profile file\n");
     else
@@ -740,7 +731,7 @@ profile_print_pc (sim_cpu *cpu, int verbose)
          }
        if (ok == 0)
          sim_io_eprintf (sd, "Failed to write to \"gmon.out\" profile file\n");
          }
        if (ok == 0)
          sim_io_eprintf (sd, "Failed to write to \"gmon.out\" profile file\n");
-       fclose(pf);
+       fclose (pf);
       }
   }
 
       }
   }
 
@@ -1132,7 +1123,7 @@ profile_info (SIM_DESC sd, int verbose)
   /* FIXME: If the number of processors can be selected on the command line,
      then MAX_NR_PROCESSORS will need to take an argument of `sd'.  */
 
   /* FIXME: If the number of processors can be selected on the command line,
      then MAX_NR_PROCESSORS will need to take an argument of `sd'.  */
 
-  for (c = 0; c < MAX_NR_PROCESSORS; ++c)
+  for (c = 0; c < MAX_NR_PROCESSORS && !print_title_p; ++c)
     {
       sim_cpu *cpu = STATE_CPU (sd, c);
       PROFILE_DATA *data = CPU_PROFILE_DATA (cpu);
     {
       sim_cpu *cpu = STATE_CPU (sd, c);
       PROFILE_DATA *data = CPU_PROFILE_DATA (cpu);
@@ -1142,6 +1133,7 @@ profile_info (SIM_DESC sd, int verbose)
          {
            profile_printf (sd, cpu, "Summary profiling results:\n\n");
            print_title_p = 1;
          {
            profile_printf (sd, cpu, "Summary profiling results:\n\n");
            print_title_p = 1;
+           break;
          }
     }
 
          }
     }
 
This page took 0.040129 seconds and 4 git commands to generate.