]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/common/sim-profile.c
sim: unify scache settings
[thirdparty/binutils-gdb.git] / sim / common / sim-profile.c
index 98ee804b0494292439053189e1edee99edd5db49..1459ae70ab284980b82f933575b9020d8b3b891a 100644 (file)
@@ -1,5 +1,5 @@
 /* Default profiling support.
 /* Default profiling support.
-   Copyright (C) 1996-2020 Free Software Foundation, Inc.
+   Copyright (C) 1996-2021 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.
@@ -17,22 +17,16 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include "sim-main.h"
 #include "sim-io.h"
 #include "sim-options.h"
 #include "sim-assert.h"
 
 #include "sim-main.h"
 #include "sim-io.h"
 #include "sim-options.h"
 #include "sim-assert.h"
 
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
 #include <string.h>
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #include <ctype.h>
 
 #if !WITH_PROFILE_PC_P
 #include <ctype.h>
 
 #if !WITH_PROFILE_PC_P
@@ -463,7 +457,7 @@ profile_option_handler (SIM_DESC sd,
 \f
 /* Profiling output hooks.  */
 
 \f
 /* Profiling output hooks.  */
 
-static void
+static void ATTRIBUTE_PRINTF (3, 0)
 profile_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)
 {
   FILE *fp = PROFILE_FILE (CPU_PROFILE_DATA (cpu));
 profile_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)
 {
   FILE *fp = PROFILE_FILE (CPU_PROFILE_DATA (cpu));
@@ -475,7 +469,7 @@ profile_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)
     sim_io_evprintf (sd, fmt, ap);
 }
 
     sim_io_evprintf (sd, fmt, ap);
 }
 
-__attribute__ ((format (printf, 3, 4)))
+ATTRIBUTE_PRINTF (3, 4)
 static void
 profile_printf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, ...)
 {
 static void
 profile_printf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, ...)
 {
@@ -563,7 +557,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 << sizeof (sim_cia) * (8 - 1))
+                       ((1ULL << sizeof (sim_cia) * (8 - 1))
                         / (PROFILE_PC_BUCKET_SIZE (data) / 2));
                    }
                  else
                         / (PROFILE_PC_BUCKET_SIZE (data) / 2));
                    }
                  else
@@ -582,7 +576,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 << ((sizeof (sim_cia) * 8) - 1))
+               bucket_size = ((1ULL << ((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)
@@ -1158,7 +1152,7 @@ profile_info (SIM_DESC sd, int verbose)
 #if WITH_PROFILE_MODEL_P
              || PROFILE_FLAGS (data) [PROFILE_MODEL_IDX]
 #endif
 #if WITH_PROFILE_MODEL_P
              || PROFILE_FLAGS (data) [PROFILE_MODEL_IDX]
 #endif
-#if WITH_PROFILE_SCACHE_P && WITH_SCACHE
+#if WITH_PROFILE_SCACHE_P && WITH_SCACHE && defined(CGEN_ARCH)
              || PROFILE_FLAGS (data) [PROFILE_SCACHE_IDX]
 #endif
 #if WITH_PROFILE_PC_P
              || PROFILE_FLAGS (data) [PROFILE_SCACHE_IDX]
 #endif
 #if WITH_PROFILE_PC_P
@@ -1196,7 +1190,7 @@ profile_info (SIM_DESC sd, int verbose)
        profile_print_model (cpu, verbose);
 #endif
 
        profile_print_model (cpu, verbose);
 #endif
 
-#if WITH_PROFILE_SCACHE_P && WITH_SCACHE
+#if WITH_PROFILE_SCACHE_P && WITH_SCACHE && defined(CGEN_ARCH)
       if (PROFILE_FLAGS (data) [PROFILE_SCACHE_IDX])
        scache_print_profile (cpu, verbose);
 #endif
       if (PROFILE_FLAGS (data) [PROFILE_SCACHE_IDX])
        scache_print_profile (cpu, verbose);
 #endif
@@ -1222,10 +1216,12 @@ profile_info (SIM_DESC sd, int verbose)
 
 }
 \f
 
 }
 \f
-/* Install profiling support in the simulator.  */
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+SIM_RC sim_install_profile (SIM_DESC sd);
 
 
+/* Install profiling support in the simulator.  */
 SIM_RC
 SIM_RC
-profile_install (SIM_DESC sd)
+sim_install_profile (SIM_DESC sd)
 {
   int i;
 
 {
   int i;