This is the mail archive of the gdb-patches@sources.redhat.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]

[PATCH]: Better cycle information for 68hc11 simulator


Hi!

I've committed the following patch to improve the information printed by
the simulator. The cpu cycle information (timer, spi, sio, ...) is now
printed as a cycle number (as before) and as a time in microseconds,
milliseconds or seconds.

For example, the sim info timer command now reports:

  Next RTI interrupt in 8124 cycles (4.1 ms)
  Next OVERFLOW interrupt in 65467 cycles (32.7 ms)

	Stephane

2000-09-10  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* sim-main.h: Define cycle_to_string.
	* dv-m68hc11tim.c (cycle_to_string): New function to translate 
	the cpu cycle into some formatted time string.
	(m68hc11tim_print_timer): Use it.
	* dv-m68hc11sio.c (m68hc11sio_info): Use cycle_to_string.
	* dv-m68hc11spi.c (m68hc11spi_info): Likewise.
	* interrupts.c (interrupts_info): Likewise.
	* m68hc11_sim.c (cpu_info): Likewise.
Index: dv-m68hc11sio.c
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/dv-m68hc11sio.c,v
retrieving revision 1.2
diff -p -r1.2 dv-m68hc11sio.c
*** dv-m68hc11sio.c	2000/08/11 18:44:59	1.2
--- dv-m68hc11sio.c	2000/09/09 20:58:05
*************** m68hc11sio_info (struct hw *me)
*** 465,480 ****
        t = hw_event_remain_time (me, controller->tx_poll_event);
        n = (clock_cycle - t) / controller->baud_cycle;
        n = controller->data_length - n;
!       sim_io_printf (sd, "  Transmit finished in %ld cycles (%d bit%s)\n",
! 		     (long) t, n, (n > 1 ? "s" : ""));
      }
    if (controller->rx_poll_event)
      {
        signed64 t;
  
        t = hw_event_remain_time (me, controller->rx_poll_event);
!       sim_io_printf (sd, "  Receive finished in %ld cycles\n",
! 		     (long) t);
      }
    
  }
--- 465,480 ----
        t = hw_event_remain_time (me, controller->tx_poll_event);
        n = (clock_cycle - t) / controller->baud_cycle;
        n = controller->data_length - n;
!       sim_io_printf (sd, "  Transmit finished in %s (%d bit%s)\n",
! 		     cycle_to_string (cpu, t), n, (n > 1 ? "s" : ""));
      }
    if (controller->rx_poll_event)
      {
        signed64 t;
  
        t = hw_event_remain_time (me, controller->rx_poll_event);
!       sim_io_printf (sd, "  Receive finished in %s\n",
! 		     cycle_to_string (cpu, t));
      }
    
  }
Index: dv-m68hc11spi.c
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/dv-m68hc11spi.c,v
retrieving revision 1.3
diff -p -r1.3 dv-m68hc11spi.c
*** dv-m68hc11spi.c	2000/09/05 20:49:46	1.3
--- dv-m68hc11spi.c	2000/09/09 20:58:18
*************** m68hc11spi_info (struct hw *me)
*** 355,362 ****
        sim_io_printf (sd, "  SPI has %d bits to send\n",
                       controller->tx_bit + 1);
        t = hw_event_remain_time (me, controller->spi_event);
!       sim_io_printf (sd, "  SPI operation finished in %ld cycles\n",
! 		     (long) t);
      }
  }
  
--- 355,366 ----
        sim_io_printf (sd, "  SPI has %d bits to send\n",
                       controller->tx_bit + 1);
        t = hw_event_remain_time (me, controller->spi_event);
!       sim_io_printf (sd, "  SPI current bit-cycle finished in %s\n",
! 		     cycle_to_string (cpu, t));
! 
!       t += (controller->tx_bit + 1) * 2 * controller->clock;
!       sim_io_printf (sd, "  SPI operation finished in %s\n",
! 		     cycle_to_string (cpu, t));
      }
  }
  
Index: dv-m68hc11tim.c
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/dv-m68hc11tim.c,v
retrieving revision 1.3
diff -p -r1.3 dv-m68hc11tim.c
*** dv-m68hc11tim.c	2000/09/06 19:33:12	1.3
--- dv-m68hc11tim.c	2000/09/09 20:58:20
*************** to_realtime (sim_cpu *cpu, signed64 t)
*** 407,412 ****
--- 407,430 ----
    return (double) (t) / (double) (cpu->cpu_frequency / 4);
  }
  
+ const char*
+ cycle_to_string (sim_cpu *cpu, signed64 t)
+ {
+   double dt;
+   static char buf[64];
+   
+   dt = to_realtime (cpu, t);
+   if (dt < 0.001)
+     sprintf (buf, "%llu cycle%s (%3.1f us)", t,
+              (t > 1 ? "s" : ""), dt * 1000000.0);
+   else if (dt < 1.0)
+     sprintf (buf, "%llu cycles (%3.1f ms)", t, dt * 1000.0);
+   else
+     sprintf (buf, "%llu cycles (%3.1f s)", t, dt);
+ 
+   return buf;
+ }
+ 
  static void
  m68hc11tim_print_timer (struct hw *me, const char *name,
                          struct hw_event *event)
*************** m68hc11tim_print_timer (struct hw *me, c
*** 421,435 ****
    else
      {
        signed64 t;
-       double dt;
        sim_cpu* cpu;
  
        cpu = STATE_CPU (sd, 0);
  
        t  = hw_event_remain_time (me, event);
!       dt = to_realtime (cpu, t) * 1000.0;
!       sim_io_printf (sd, "  Next %s interrupt in %ld cycles (%3.3f ms)\n",
!                      name, (long) t, dt);
      }
  }
  
--- 439,451 ----
    else
      {
        signed64 t;
        sim_cpu* cpu;
  
        cpu = STATE_CPU (sd, 0);
  
        t  = hw_event_remain_time (me, event);
!       sim_io_printf (sd, "  Next %s interrupt in %s\n",
!                      name, cycle_to_string (cpu, t));
      }
  }
  
Index: interrupts.c
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/interrupts.c,v
retrieving revision 1.1
diff -p -r1.1 interrupts.c
*** interrupts.c	2000/07/27 11:23:39	1.1
--- interrupts.c	2000/09/09 20:58:20
*************** interrupts_raise (struct interrupts *int
*** 262,270 ****
  void
  interrupts_info (SIM_DESC sd, struct interrupts *interrupts)
  {
    if (interrupts->start_mask_cycle >= 0)
      {
!       signed64 t = cpu_current_cycle (interrupts->cpu);
  
        t -= interrupts->start_mask_cycle;
        if (t > interrupts->max_mask_cycles)
--- 262,272 ----
  void
  interrupts_info (SIM_DESC sd, struct interrupts *interrupts)
  {
+   signed64 t;
+   
    if (interrupts->start_mask_cycle >= 0)
      {
!       t = cpu_current_cycle (interrupts->cpu);
  
        t -= interrupts->start_mask_cycle;
        if (t > interrupts->max_mask_cycles)
*************** interrupts_info (SIM_DESC sd, struct int
*** 272,278 ****
      }
    if (interrupts->xirq_start_mask_cycle >= 0)
      {
!       signed64 t = cpu_current_cycle (interrupts->cpu);
  
        t -= interrupts->xirq_start_mask_cycle;
        if (t > interrupts->xirq_max_mask_cycles)
--- 274,280 ----
      }
    if (interrupts->xirq_start_mask_cycle >= 0)
      {
!       t = cpu_current_cycle (interrupts->cpu);
  
        t -= interrupts->xirq_start_mask_cycle;
        if (t > interrupts->xirq_max_mask_cycles)
*************** interrupts_info (SIM_DESC sd, struct int
*** 282,297 ****
    sim_io_printf (sd, "Interrupts Info:\n");
    sim_io_printf (sd, "  Interrupts raised: %lu\n",
                   interrupts->nb_interrupts_raised);
!   sim_io_printf (sd, "  Min interrupts masked sequence: %llu cycles\n",
!                  interrupts->min_mask_cycles == CYCLES_MAX ?
!                  interrupts->max_mask_cycles :
!                  interrupts->min_mask_cycles);
!   sim_io_printf (sd, "  Max interrupts masked sequence: %llu cycles\n",
!                  interrupts->max_mask_cycles);
!   sim_io_printf (sd, "  XIRQ Min interrupts masked sequence: %llu cycles\n",
!                  interrupts->xirq_min_mask_cycles == CYCLES_MAX ?
!                  interrupts->xirq_max_mask_cycles :
!                  interrupts->xirq_min_mask_cycles);
!   sim_io_printf (sd, "  XIRQ Max interrupts masked sequence: %llu cycles\n",
!                  interrupts->xirq_max_mask_cycles);
  }
--- 284,307 ----
    sim_io_printf (sd, "Interrupts Info:\n");
    sim_io_printf (sd, "  Interrupts raised: %lu\n",
                   interrupts->nb_interrupts_raised);
! 
!   t = interrupts->min_mask_cycles == CYCLES_MAX ?
!     interrupts->max_mask_cycles :
!     interrupts->min_mask_cycles;
!   sim_io_printf (sd, "  Shortest interrupts masked sequence: %s\n",
!                  cycle_to_string (interrupts->cpu, t));
! 
!   t = interrupts->max_mask_cycles;
!   sim_io_printf (sd, "  Longest interrupts masked sequence: %s\n",
!                  cycle_to_string (interrupts->cpu, t));
! 
!   t = interrupts->xirq_min_mask_cycles == CYCLES_MAX ?
!     interrupts->xirq_max_mask_cycles :
!     interrupts->xirq_min_mask_cycles;
!   sim_io_printf (sd, "  XIRQ Min interrupts masked sequence: %s\n",
!                  cycle_to_string (interrupts->cpu, t));
! 
!   t = interrupts->xirq_max_mask_cycles;
!   sim_io_printf (sd, "  XIRQ Max interrupts masked sequence: %s\n",
!                  cycle_to_string (interrupts->cpu, t));
  }
Index: m68hc11_sim.c
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/m68hc11_sim.c,v
retrieving revision 1.1
diff -p -r1.1 m68hc11_sim.c
*** m68hc11_sim.c	2000/07/27 11:23:39	1.1
--- m68hc11_sim.c	2000/09/09 20:58:30
*************** void
*** 627,634 ****
  cpu_info (SIM_DESC sd, sim_cpu *cpu)
  {
    sim_io_printf (sd, "CPU info:\n");
!   sim_io_printf (sd, "  Absolute cycle: %llu\n",
!                  cpu->cpu_absolute_cycle);
    sim_io_printf (sd, "  Syscall emulation: %s\n",
                   cpu->cpu_emul_syscall ? "yes, via 0xcd <n>" : "no");
    sim_io_printf (sd, "  Memory errors detection: %s\n",
--- 627,635 ----
  cpu_info (SIM_DESC sd, sim_cpu *cpu)
  {
    sim_io_printf (sd, "CPU info:\n");
!   sim_io_printf (sd, "  Absolute cycle: %s\n",
!                  cycle_to_string (cpu, cpu->cpu_absolute_cycle));
!   
    sim_io_printf (sd, "  Syscall emulation: %s\n",
                   cpu->cpu_emul_syscall ? "yes, via 0xcd <n>" : "no");
    sim_io_printf (sd, "  Memory errors detection: %s\n",
Index: sim-main.h
===================================================================
RCS file: /cvs/src/src/sim/m68hc11/sim-main.h,v
retrieving revision 1.2
diff -p -r1.2 sim-main.h
*** sim-main.h	2000/08/11 18:44:59	1.2
--- sim-main.h	2000/09/09 20:58:30
*************** extern void sim_set_profile (int n);
*** 497,502 ****
--- 497,504 ----
  extern void sim_set_profile_size (int n);
  extern void sim_board_reset (SIM_DESC sd);
  
+ extern const char *cycle_to_string (sim_cpu *cpu, signed64 t);
+ 
  #endif
  
  

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