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]

More generic_load preliminaries


Hello,

Apart from minor cleanups to generic_load, this patch changes the
download summary message to:

	Transfer rate: 5139 bits/sec, 93 bytes/write.

The ``, 93 bytes/write'' is new.

	Andrew
Mon Oct 18 17:32:51 1999  Andrew Cagney  <cagney@b1.cygnus.com>

	* symfile.c (generic_load): Don't filter output. Use
 	print_transfer_performance for summary. Use paddr for addresses.
	(print_transfer_performance): New function.  Includes write count.
	(report_transfer_performance): Call
 	print_transfer_performance. Deprecate.

	* defs.h (print_transfer_performance): Add declaration.
	(generic_load): Move declaration to here.
	* symfile.h (generic_load): From here.

Index: defs.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v
retrieving revision 1.266
diff -p -r1.266 defs.h
*** defs.h	1999/10/17 04:23:07	1.266
--- defs.h	1999/10/18 09:40:52
*************** extern char *re_comp (const char *);
*** 525,530 ****
--- 525,539 ----
  
  extern void symbol_file_command (char *, int);
  
+ /* Remote targets may wish to use this as their load function.  */
+ extern void generic_load (char *name, int from_tty);
+ 
+ /* Summarise a download */
+ extern void print_transfer_performance (struct gdb_file *stream,
+ 					unsigned long data_count,
+ 					unsigned long write_count,
+ 					unsigned long time_count);
+ 
  /* From top.c */
  
  typedef void initialize_file_ftype (void);
Index: symfile.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symfile.c,v
retrieving revision 1.199
diff -p -r1.199 symfile.c
*** symfile.c	1999/10/17 04:23:08	1.199
--- symfile.c	1999/10/18 09:40:59
*************** generic_load (filename, from_tty)
*** 1219,1224 ****
--- 1219,1225 ----
    bfd *loadfile_bfd;
    time_t start_time, end_time;	/* Start and end times of download */
    unsigned long data_count = 0;	/* Number of bytes transferred to memory */
+   unsigned long write_count = 0;	/* Number of writes needed. */
    int n;
    unsigned long load_offset = 0;	/* offset to add to vma for each section */
    char buf[GENERIC_LOAD_CHUNK + 8];
*************** generic_load (filename, from_tty)
*** 1256,1269 ****
      {
        if (s->flags & SEC_LOAD)
  	{
! 	  bfd_size_type size;
! 
! 	  size = bfd_get_section_size_before_reloc (s);
  	  if (size > 0)
  	    {
  	      char *buffer;
  	      struct cleanup *old_chain;
! 	      bfd_vma lma;
  	      unsigned long l = size;
  	      int err;
  	      const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
--- 1257,1268 ----
      {
        if (s->flags & SEC_LOAD)
  	{
! 	  CORE_ADDR size = bfd_get_section_size_before_reloc (s);
  	  if (size > 0)
  	    {
  	      char *buffer;
  	      struct cleanup *old_chain;
! 	      CORE_ADDR lma = s->lma + load_offset;
  	      unsigned long l = size;
  	      int err;
  	      const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
*************** generic_load (filename, from_tty)
*** 1275,1289 ****
  	      buffer = xmalloc (size);
  	      old_chain = make_cleanup (free, buffer);
  
- 	      lma = s->lma;
- 	      lma += load_offset;
- 
  	      /* Is this really necessary?  I guess it gives the user something
  	         to look at during a long download.  */
! 	      printf_filtered ("Loading section %s, size 0x%lx lma ",
! 			       sect_name, (unsigned long) size);
! 	      print_address_numeric (lma, 1, gdb_stdout);
! 	      printf_filtered ("\n");
  
  	      bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
  
--- 1274,1284 ----
  	      buffer = xmalloc (size);
  	      old_chain = make_cleanup (free, buffer);
  
  	      /* Is this really necessary?  I guess it gives the user something
  	         to look at during a long download.  */
! 	      fprintf_unfiltered (gdb_stdout,
! 				  "Loading section %s, size 0x%s lma 0x%s\n",
! 				  sect_name, paddr_nz (size), paddr_nz (lma));
  
  	      bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
  
*************** generic_load (filename, from_tty)
*** 1314,1319 ****
--- 1309,1315 ----
  		  data_count += len;
  		  lma += len;
  		  buffer += len;
+ 		  write_count += 1;
  		}		/* od */
  	      while (err == 0 && sent < size);
  
*************** generic_load (filename, from_tty)
*** 1327,1335 ****
  
    end_time = time (NULL);
    {
!     unsigned long entry;
      entry = bfd_get_start_address (loadfile_bfd);
!     printf_filtered ("Start address 0x%lx , load size %ld\n", entry, data_count);
      /* We were doing this in remote-mips.c, I suspect it is right
         for other targets too.  */
      write_pc (entry);
--- 1323,1333 ----
  
    end_time = time (NULL);
    {
!     CORE_ADDR entry;
      entry = bfd_get_start_address (loadfile_bfd);
!     fprintf_unfiltered (gdb_stdout,
! 			"Start address 0x%s , load size %ld\n",
! 			paddr_nz (entry), data_count);
      /* We were doing this in remote-mips.c, I suspect it is right
         for other targets too.  */
      write_pc (entry);
*************** generic_load (filename, from_tty)
*** 1341,1365 ****
       loaded in.  remote-nindy.c had no call to symbol_file_add, but remote-vx.c
       does.  */
  
!   report_transfer_performance (data_count, start_time, end_time);
  
    do_cleanups (old_cleanups);
  }
  
  /* Report how fast the transfer went. */
  
  void
  report_transfer_performance (data_count, start_time, end_time)
       unsigned long data_count;
       time_t start_time, end_time;
  {
!   printf_filtered ("Transfer rate: ");
!   if (end_time != start_time)
!     printf_filtered ("%ld bits/sec",
! 		     (data_count * 8) / (end_time - start_time));
    else
!     printf_filtered ("%ld bits in <1 sec", (data_count * 8));
!   printf_filtered (".\n");
  }
  
  /* This function allows the addition of incrementally linked object files.
--- 1339,1378 ----
       loaded in.  remote-nindy.c had no call to symbol_file_add, but remote-vx.c
       does.  */
  
!   print_transfer_performance (gdb_stdout, data_count, write_count,
! 			      end_time - start_time);
  
    do_cleanups (old_cleanups);
  }
  
  /* Report how fast the transfer went. */
  
+ /* DEPRECATED: cagney/1999-10-18: report_transfer_performance is being
+    replaced by print_transfer_performance (with a very different
+    function signature). */
+ 
  void
  report_transfer_performance (data_count, start_time, end_time)
       unsigned long data_count;
       time_t start_time, end_time;
+ {
+   print_transfer_performance (gdb_stdout, data_count, end_time - start_time, 0);
+ }
+ 
+ void
+ print_transfer_performance (struct gdb_file *stream,
+ 			    unsigned long data_count,
+ 			    unsigned long write_count,
+ 			    unsigned long time_count)
  {
!   fprintf_unfiltered (stream, "Transfer rate: ");
!   if (time_count > 0)
!     fprintf_unfiltered (stream, "%ld bits/sec", (data_count * 8) / time_count);
    else
!     fprintf_unfiltered (stream, "%ld bits in <1 sec", (data_count * 8));
!   if (write_count > 0)
!     fprintf_unfiltered (stream, ", %ld bytes/write", data_count / write_count);
!   fprintf_unfiltered (stream, ".\n");
  }
  
  /* This function allows the addition of incrementally linked object files.
Index: symfile.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symfile.h,v
retrieving revision 1.67
diff -p -r1.67 symfile.h
*** symfile.h	1999/10/01 00:21:17	1.67
--- symfile.h	1999/10/18 09:41:01
*************** extern void find_lowest_section PARAMS (
*** 221,229 ****
  
  extern bfd *symfile_bfd_open PARAMS ((char *));
  
- /* Remote targets may wish to use this as their load function.  */
- extern void generic_load PARAMS ((char *name, int from_tty));
- 
  /* Utility functions for overlay sections: */
  extern int overlay_debugging;
  extern int overlay_cache_invalid;
--- 221,226 ----


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