This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [SIM] Change sim_trace() iface, add ``-o'' to run.c


Andrew Cagney wrote:
> 
> Hello,
> 
> I've encountered the situation where for the d10v simulator needs to
> exhibit both user and operating environment behaviors (1).  To allow
> this, I'd like to propose the following changes to the sim sub
> directory:
> 
>         o       run.c
> 
>                 Add the option ``-o'' for operating
>                 (system) environment.  When selected
>                 operating environment is provided.
> 
>                 Change the main loop so that it
>                 only loops when ``operating_p''.
> 
>         o       sim/*/* + include/remote-sim.h
> 
>                 Change the sim_trace() interface
>                 so that it just sets the trace
>                 option and doesn't try to run
>                 the simulator.
> 
>                 run.c being updated accordingly.
>                 This change is needed as, currently,
>                 the old simulators are confused as
>                 to what exactly sim_trace() should
>                 do.
> 
>                 Trying to introduce a ``-o'' option
>                 would result in inconsistent behavour:
>                 ``-t -o'' would be different to ``-o''

FYI,

The attatched was applied.  It only enables the ``-o'' option when the
simulator supports operating environment.  It also updates/clarifies
more of include/remote-sim.h.

	Andrew
: include/ChangeLog
Tue Feb 22 15:19:54 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* remote-sim.h (sim_trace): Document return values.
	(sim_set_trace): Declare.  Deprecate.

: sim/common/ChangeLog
Tue Feb 22 16:45:09 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* run.c (main): When SIM_HAVE_SET_TRACE enable tracing with
 	sim_set_trace and run simulator using sim_resume.
	(main): Add option ``-o'' - operating environment.  Only continue
 	after a signal when operating environment.
	(main): Always set REASON and SIGRC using sim_stop_reason.
	(sim_trace): Delete extern declaration.

: sim/d10v/ChangeLog
Tue Feb 22 18:24:56 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* Makefile.in (SIM_EXTRA_CFLAGS): Define SIM_HAVE_ENVIRONMENT.
	* interp.c (sim_set_trace): Replace sim_trace.  Enable tracing.

: sim/testsuite/d10v-elf/ChangeLog
Tue Feb 22 17:36:34 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* Makefile.in: Force d10v into operating mode.

Index: include/remote-sim.h
===================================================================
RCS file: /cvs/src/src/include/remote-sim.h,v
retrieving revision 1.2
diff -p -r1.2 remote-sim.h
*** remote-sim.h	2000/02/09 07:44:03	1.2
--- remote-sim.h	2000/02/22 08:20:34
*************** void sim_set_callbacks PARAMS ((struct h
*** 308,320 ****
  void sim_size PARAMS ((int i));
  
  
! /* Run a simulation with tracing enabled.
     THIS PROCEDURE IS DEPRECIATED.
     GDB and NRUN do not use this interface.
!    This procedure does not take a SIM_DESC argument as it is
!    used before sim_open. */
  
  int sim_trace PARAMS ((SIM_DESC sd));
  
  
  /* Configure the size of the profile buffer.
--- 308,332 ----
  void sim_size PARAMS ((int i));
  
  
! /* Single-step simulator with tracing enabled.
     THIS PROCEDURE IS DEPRECIATED.
+    THIS PROCEDURE IS EVEN MORE DEPRECATED THAN SIM_SET_TRACE
     GDB and NRUN do not use this interface.
!    This procedure returns: ``0'' indicating that the simulator should
!    be continued using sim_trace() calls; ``1'' indicating that the
!    simulation has finished. */
  
  int sim_trace PARAMS ((SIM_DESC sd));
+ 
+ 
+ /* Enable tracing.
+    THIS PROCEDURE IS DEPRECIATED.
+    GDB and NRUN do not use this interface.
+    This procedure returns: ``0'' indicating that the simulator should
+    be continued using sim_trace() calls; ``1'' indicating that the
+    simulation has finished. */
+ 
+ void sim_set_trace PARAMS ((void));
  
  
  /* Configure the size of the profile buffer.
Index: sim/common/run.c
===================================================================
RCS file: /cvs/src/src/sim/common/run.c,v
retrieving revision 1.3
diff -p -r1.3 run.c
*** run.c	2000/02/09 05:08:42	1.3
--- run.c	2000/02/22 08:20:50
*************** extern host_callback default_callback;
*** 57,65 ****
  
  static char *myname;
  
- /* NOTE: sim_size() and sim_trace() are going away */
- extern int sim_trace PARAMS ((SIM_DESC sd));
- 
  extern int getopt ();
  
  #ifdef NEED_UI_LOOP_HOOK
--- 57,62 ----
*************** main (ac, av)
*** 89,94 ****
--- 86,94 ----
    int i;
    int verbose = 0;
    int trace = 0;
+ #ifdef SIM_HAVE_ENVIRONMENT
+   int operating_p = 0;
+ #endif
    char *name;
    static char *no_args[4];
    char **sim_argv = &no_args[0];
*************** main (ac, av)
*** 117,125 ****
       do all argv processing.  */
  
  #ifdef SIM_H8300 /* FIXME: quick hack */
!   while ((i = getopt (ac, av, "a:c:m:p:s:htv")) != EOF) 
  #else
!   while ((i = getopt (ac, av, "a:c:m:p:s:tv")) != EOF) 
  #endif
      switch (i)
        {
--- 117,125 ----
       do all argv processing.  */
  
  #ifdef SIM_H8300 /* FIXME: quick hack */
!   while ((i = getopt (ac, av, "a:c:m:op:s:htv")) != EOF) 
  #else
!   while ((i = getopt (ac, av, "a:c:m:op:s:tv")) != EOF) 
  #endif
      switch (i)
        {
*************** main (ac, av)
*** 147,152 ****
--- 147,159 ----
  	/* FIXME: Rename to sim_set_mem_size.  */
  	sim_size (atoi (optarg));
  	break;
+ #ifdef SIM_HAVE_ENVIRONMENT
+       case 'o':
+ 	/* Operating enironment where any signals are delivered to the
+            target. */
+ 	operating_p = 1;
+ 	break;
+ #endif SIM_HAVE_ENVIRONMENT
  #ifdef SIM_HAVE_PROFILE
        case 'p':
  	sim_set_profile (atoi (optarg));
*************** main (ac, av)
*** 157,164 ****
  #endif
        case 't':
  	trace = 1;
- 	/* FIXME: need to allow specification of what to trace.  */
- 	/* sim_set_trace (1); */
  	break;
        case 'v':
  	/* Things that are printed with -v are the kinds of things that
--- 164,169 ----
*************** main (ac, av)
*** 231,238 ****
--- 236,258 ----
    if (sim_create_inferior (sd, abfd, prog_args, NULL) == SIM_RC_FAIL)
      exit (1);
  
+ #ifdef SIM_HAVE_ENVIRONMENT
+   /* NOTE: An old simulator supporting the operating environment MUST
+      provide sim_set_trace() and not sim_trace(). That way
+      sim_stop_reason() can be used to determine any stop reason. */
    if (trace)
+     sim_set_trace ();
+   do
      {
+       prev_sigint = signal (SIGINT, cntrl_c);
+       sim_resume (sd, 0, sigrc);
+       signal (SIGINT, prev_sigint);
+       sim_stop_reason (sd, &reason, &sigrc);
+     }
+   while (operating_p && reason == sim_stopped && sigrc != SIGINT);
+ #else
+   if (trace)
+     {
        int done = 0;
        prev_sigint = signal (SIGINT, cntrl_c);
        while (!done)
*************** main (ac, av)
*** 240,257 ****
  	  done = sim_trace (sd);
  	}
        signal (SIGINT, prev_sigint);
      }
    else
      {
!       do
! 	{
! 	  prev_sigint = signal (SIGINT, cntrl_c);
! 	  sim_resume (sd, 0, sigrc);
! 	  signal (SIGINT, prev_sigint);
! 	  sim_stop_reason (sd, &reason, &sigrc);
! 	}
!       while (reason == sim_stopped && sigrc != SIGINT);
      }
  
    if (verbose)
      sim_info (sd, 0);
--- 260,275 ----
  	  done = sim_trace (sd);
  	}
        signal (SIGINT, prev_sigint);
+       sim_stop_reason (sd, &reason, &sigrc);
      }
    else
      {
!       prev_sigint = signal (SIGINT, cntrl_c);
!       sim_resume (sd, 0, sigrc);
!       signal (SIGINT, prev_sigint);
!       sim_stop_reason (sd, &reason, &sigrc);
      }
+ #endif
  
    if (verbose)
      sim_info (sd, 0);
*************** usage ()
*** 303,308 ****
--- 321,329 ----
    fprintf (stderr, "-h              Executable is for h8/300h or h8/300s.\n");
  #endif
    fprintf (stderr, "-m size         Set memory size of simulator, in bytes.\n");
+ #ifdef SIM_HAVE_ENVIRONMENT
+   fprintf (stderr, "-o              Select operating (kernel) environment.\n");
+ #endif
  #ifdef SIM_HAVE_PROFILE
    fprintf (stderr, "-p freq         Set profiling frequency.\n");
    fprintf (stderr, "-s size         Set profiling size.\n");
Index: sim/d10v/Makefile.in
===================================================================
RCS file: /cvs/src/src/sim/d10v/Makefile.in,v
retrieving revision 1.1.1.2
diff -p -r1.1.1.2 Makefile.in
*** Makefile.in	1999/04/26 18:31:47	1.1.1.2
--- Makefile.in	2000/02/22 08:20:52
***************
*** 20,26 ****
  
  SIM_OBJS = interp.o table.o simops.o endian.o sim-load.o
  SIM_EXTRA_CLEAN = clean-extra
! SIM_EXTRA_CFLAGS = -DNEED_UI_LOOP_HOOK
  
  INCLUDE = d10v_sim.h $(srcroot)/include/callback.h targ-vals.h endian.c
  
--- 20,26 ----
  
  SIM_OBJS = interp.o table.o simops.o endian.o sim-load.o
  SIM_EXTRA_CLEAN = clean-extra
! SIM_EXTRA_CFLAGS = -DNEED_UI_LOOP_HOOK -DSIM_HAVE_ENVIRONMENT
  
  INCLUDE = d10v_sim.h $(srcroot)/include/callback.h targ-vals.h endian.c
  
Index: sim/d10v/interp.c
===================================================================
RCS file: /cvs/src/src/sim/d10v/interp.c,v
retrieving revision 1.2
diff -p -r1.2 interp.c
*** interp.c	2000/02/09 05:08:42	1.2
--- interp.c	2000/02/22 08:20:54
*************** sim_resume (sd, step, siggnal)
*** 1072,1091 ****
      State.exception = SIGTRAP;
  }
  
! int
! sim_trace (sd)
!      SIM_DESC sd;
  {
-   enum sim_stop reason;
-   static int sigrc = 0;
  #ifdef DEBUG
    d10v_debug = DEBUG;
  #endif
-   /* NOTE: SIGRC starts with zero and is then, always the value
-      returned by the last sim_stop_reason() call. */
-   sim_resume (sd, 0, sigrc);
-   sim_stop_reason (sd, &reason, &sigrc);
-   return (reason != sim_stopped || sigrc != SIGINT);
  }
  
  void
--- 1072,1083 ----
      State.exception = SIGTRAP;
  }
  
! void
! sim_set_trace (void)
  {
  #ifdef DEBUG
    d10v_debug = DEBUG;
  #endif
  }
  
  void
Index: sim/testsuite/d10v-elf/Makefile.in
===================================================================
RCS file: /cvs/src/src/sim/testsuite/d10v-elf/Makefile.in,v
retrieving revision 1.1.1.3
diff -p -r1.1.1.3 Makefile.in
*** Makefile.in	2000/01/06 03:07:20	1.1.1.3
--- Makefile.in	2000/02/22 08:20:57
*************** RUN_FOR_TARGET = `\
*** 106,111 ****
--- 106,114 ----
      echo $(target_alias)-run ; \
    fi`
  
+ # Force d10v into operating mode.
+ RUNFLAGS_FOR_TARGET=-o
+ 
  
  check: sanity $(TESTS)
  sanity:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]