From 93e7a1b5b74ce4e5a030378b5f39077aed9d0912 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 12 Sep 1997 02:44:03 +0000 Subject: Add profiling support to v850*. --- sim/common/ChangeLog | 45 +++++++++++++++++++++++++++++++++++++++++++++ sim/common/sim-events.c | 13 ++++++++++--- sim/v850/ChangeLog | 11 +++++++++++ sim/v850/Makefile.in | 10 +++++----- sim/v850/interp.c | 12 ++++-------- sim/v850/sim-main.h | 8 ++++++++ 6 files changed, 83 insertions(+), 16 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 5598ee2..6359cca 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,48 @@ +Thu Sep 11 10:08:48 1997 Andrew Cagney + + * sim-profile.c (profile_print_speed): Call + sim_events_elapsed_time instead of PROFILE_EXEC_TIME for moment. + + * sim-events.c (sim_events_elapsed_time): New function return nr + host MS consumed by the simulator. + (sim_watch_valid): Use. + + * sim-module.c (modules): Install sim_events very very early. + + * sim-profile.c (profile_print): Call profile_print_pc. + (print_bar): + (profile_pc_init): New function, set up processor for PC + profiling. + (profile_print_pc): New function, print a PC profile. + (profile_pc_event): New function, sample PC. + + * sim-profile.h (PROFILE_PC_COUNT, PROFILE_PC_START, + PROFILE_PC_END, PROFILE_PC_SHIFT, PROFILE_PC_SAMPLE_SIZE): Add to + profile struct. + + * sim-options.c (sim_print_help): Pacify GCC. + + * sim-n-core.h (sim_core_read_aligned_N, + sim_core_write_aligned_N): Add un-conditional profile call. + (sim_core_read_unaligned_N, sim_core_write_unaligned_N): Add + profile call when aligned read/write isn't used. + + * sim-base.h: Include sim-profile, sim-model after sim-core & + sim-events allow sim-core to define useful values. + + * sim-profile.c (OPTION_PROFILE_CORE): Define. + (profile_option_handler, profile_options): Add support for + --profile-core option. + (print_bar): Include when core profiling. + (profile_print_core): New function, print core profile. + + * sim-config.c (print_sim_config): Print profile status. + + * sim-profile.h (PROFILE_NEXT_IDX, PROFILE_core, + WITH_PROFILE_PC_P): Define. + (PROFILE_CORE_COUNT): Count each core-map/size separatly. + (PROFILE_COUNT_CORE): Define. + Thu Sep 11 08:44:52 1997 Andrew Cagney * sim-watch.c (handle_watchpoint): Pass a char** index into the diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c index 7139662..564a99d 100644 --- a/sim/common/sim-events.c +++ b/sim/common/sim-events.c @@ -343,6 +343,15 @@ sim_events_time (SIM_DESC sd) } +INLINE_SIM_EVENTS\ +(unsigned long) +sim_events_elapsed_time (SIM_DESC sd) +{ + return (sim_elapsed_time_since (STATE_EVENTS (sd)->resume_wallclock) + + STATE_EVENTS (sd)->elapsed_wallclock); +} + + STATIC_INLINE_SIM_EVENTS\ (void) update_time_from_event (SIM_DESC sd) @@ -865,9 +874,7 @@ sim_watch_valid (SIM_DESC sd, case watch_clock: /* wallclock */ { - unsigned long elapsed_time = - (sim_elapsed_time_since (STATE_EVENTS (sd)->resume_wallclock) - + STATE_EVENTS (sd)->elapsed_wallclock); + unsigned long elapsed_time = sim_events_elapsed_time (sd); return (elapsed_time >= to_do->wallclock); } diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog index b330611..feab6ef 100644 --- a/sim/v850/ChangeLog +++ b/sim/v850/ChangeLog @@ -1,5 +1,16 @@ Thu Sep 11 08:40:03 1997 Andrew Cagney + * interp.c (sim_open): Use sim_do_commandf instead of asprintf. + + * sim-main.h (INSN_NAME): + + * Makefile.in (INCLUDE): Add SIM_EXTRA_DEPS. + (SIM_EXTRA_DEPS): Add itable.h + (tmp-gencode): Does not depend on simops.h + + * sim-main.h (itable.h): Include. + (MAX_INSNS, INSN_NAME): Define. + * interp.c: Compute inttype from the interrupt_names index that was passed in. diff --git a/sim/v850/Makefile.in b/sim/v850/Makefile.in index f0c5521..cadd913 100644 --- a/sim/v850/Makefile.in +++ b/sim/v850/Makefile.in @@ -45,7 +45,7 @@ SIM_RUN_OBJS = nrun.o # List of extra dependencies. # Generally this consists of simulator specific files included by sim-main.h. -SIM_EXTRA_DEPS = v850_sim.h sim-main.h simops.h +SIM_EXTRA_DEPS = v850_sim.h sim-main.h simops.h itable.h # List of flags to always pass to $(CC) SIM_WARNINGS=@sim_warnings@ @@ -59,18 +59,18 @@ SIM_EXTRA_CFLAGS = \ $(SIM_HOSTENDIAN) SIM_EXTRA_CLEAN = clean-extra -INCLUDE = simops.h v850_sim.h sim-main.h $(srcdir)/../../include/callback.h +INCLUDE = $(sim_main_headers) $(SIM_EXTRA_DEPS) ## COMMON_POST_CONFIG_FRAG simops.h table.c: tmp-gencode -tmp-gencode: gencode simops.h +tmp-gencode: gencode ./gencode >tmp-table.c mv tmp-table.c table.c ./gencode -h >tmp-simops.h mv tmp-simops.h simops.h touch tmp-gencode -gencode.o: gencode.c $(INCLUDE) +gencode.o: gencode.c $(CC_FOR_BUILD) $(BUILD_CFLAGS) -c $(srcdir)/gencode.c v850-opc.o: $(srcdir)/../../opcodes/v850-opc.c $(CC_FOR_BUILD) $(BUILD_CFLAGS) -c $< @@ -151,5 +151,5 @@ clean-extra: clean-igen rm -f table.c simops.h gencode #interp.o: interp.c table.c $(INCLUDE) -simops.o: simops.c simops.h +simops.o: simops.c $(INCLUDE) #table.o: table.c diff --git a/sim/v850/interp.c b/sim/v850/interp.c index 753996f..485a15f 100644 --- a/sim/v850/interp.c +++ b/sim/v850/interp.c @@ -219,7 +219,6 @@ sim_open (kind, cb, abfd, argv) struct _bfd *abfd; char **argv; { - char *buf; SIM_DESC sd = sim_state_alloc (kind, cb); #if 0 struct simops *s; @@ -239,14 +238,11 @@ sim_open (kind, cb, abfd, argv) return 0; /* Allocate core managed memory */ + /* "Mirror" the ROM addresses below 1MB. */ - asprintf (&buf, "memory region 0,0x100000,0x%lx", V850_ROM_SIZE); - sim_do_command (sd, buf); - free (buf); + sim_do_commandf (sd, "memory region 0,0x100000,0x%lx", V850_ROM_SIZE); /* Chunk of ram adjacent to rom */ - asprintf (&buf, "memory region 0x100000,0x%lx", V850_LOW_END - 0x100000); - sim_do_command (sd, buf); - free (buf); + sim_do_commandf (sd, "memory region 0x100000,0x%lx", V850_LOW_END-0x100000); /* peripheral I/O region - mirror 1K across 4k (0x1000) */ sim_do_command (sd, "memory region 0xfff000,0x1000,1024"); /* similarly if in the internal RAM region */ @@ -394,7 +390,7 @@ sim_info (sd, verbose) SIM_DESC sd; int verbose; { - /* do nothing */ + profile_print (sd, STATE_VERBOSE_P (sd), NULL, NULL); } SIM_RC diff --git a/sim/v850/sim-main.h b/sim/v850/sim-main.h index 52f3086..66e8995 100644 --- a/sim/v850/sim-main.h +++ b/sim/v850/sim-main.h @@ -1,3 +1,4 @@ +#define WITH_CORE #define WITH_MODULO_MEMORY 1 #define WITH_WATCHPOINTS 1 #define WITH_TARGET_WORD_MSB 31 @@ -6,10 +7,17 @@ typedef address_word sim_cia; + /* This simulator doesn't cache state */ #define SIM_ENGINE_HALT_HOOK(sd,last_cpu,cia) while (0) #define SIM_ENGINE_RESTART_HOOK(sd,last_cpu,cia) while (0) +/* Get the number of instructions. FIXME: must be a more elegant way + of doing this. */ +#include "itable.h" +#define MAX_INSNS (nr_itable_entries) +#define INSN_NAME(i) itable[(i)].name + #include "sim-base.h" typedef signed8 int8; -- cgit v1.1