Replace ../include/wait.h with gdb_wait.h.
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 80f990295036092f4ce103dfb56216a4379c0a55..5b2a2ff56579a8123e0b70f6ea22ece686c1d3b0 100644 (file)
@@ -1,6 +1,5 @@
 /* Generic symbol file reading for the GNU debugger, GDB.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998
-   Free Software Foundation, Inc.
+   Copyright 1990-1996, 1998, 2000 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
    This file is part of GDB.
@@ -64,6 +63,11 @@ extern int hp_cxx_exception_support_initialized;
 #endif
 
 int (*ui_load_progress_hook) (const char *section, unsigned long num);
+void (*show_load_progress) (const char *section,
+                           unsigned long section_sent, 
+                           unsigned long section_size, 
+                           unsigned long total_sent, 
+                           unsigned long total_size);
 void (*pre_add_symbol_hook) PARAMS ((char *));
 void (*post_add_symbol_hook) PARAMS ((void));
 void (*target_new_objfile_hook) PARAMS ((struct objfile *));
@@ -1225,6 +1229,8 @@ generic_load (char *args, int from_tty)
   char *filename;
   struct cleanup *old_cleanups;
   char *offptr;
+  CORE_ADDR total_size = 0;
+  CORE_ADDR total_sent = 0;
 
   /* Parse the input argument - the user can specify a load offset as
      a second argument. */
@@ -1262,6 +1268,10 @@ generic_load (char *args, int from_tty)
             bfd_errmsg (bfd_get_error ()));
     }
 
+  for (s = loadfile_bfd->sections; s; s = s->next)
+    if (s->flags & SEC_LOAD)
+      total_size += bfd_get_section_size_before_reloc (s);
+
   start_time = time (NULL);
 
   for (s = loadfile_bfd->sections; s; s = s->next)
@@ -1289,9 +1299,14 @@ generic_load (char *args, int from_tty)
 
              /* Is this really necessary?  I guess it gives the user something
                 to look at during a long download.  */
+#ifdef UI_OUT
+             ui_out_message (uiout, 0, "Loading section %s, size 0x%s lma 0x%s\n",
+                          sect_name, paddr_nz (size), paddr_nz (lma));
+#else
              fprintf_unfiltered (gdb_stdout,
                                  "Loading section %s, size 0x%s lma 0x%s\n",
                                  sect_name, paddr_nz (size), paddr_nz (lma));
+#endif
 
              bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
 
@@ -1331,10 +1346,14 @@ generic_load (char *args, int from_tty)
                  buffer += len;
                  write_count += 1;
                  sent += len;
+                 total_sent += len;
                  if (quit_flag
                      || (ui_load_progress_hook != NULL
                          && ui_load_progress_hook (sect_name, sent)))
                    error ("Canceled the download");
+
+                 if (show_load_progress != NULL)
+                   show_load_progress (sect_name, sent, size, total_sent, total_size);
                }
              while (sent < size);
 
@@ -1350,9 +1369,18 @@ generic_load (char *args, int from_tty)
   {
     CORE_ADDR entry;
     entry = bfd_get_start_address (loadfile_bfd);
+#ifdef UI_OUT
+   ui_out_text (uiout, "Start address ");
+   ui_out_field_fmt (uiout, "address", "0x%s" , paddr_nz (entry));
+   ui_out_text (uiout, ", load size ");
+   ui_out_field_fmt (uiout, "load-size", "%ld" , data_count);
+   ui_out_text (uiout, "\n");
+
+#else
     fprintf_unfiltered (gdb_stdout,
                        "Start address 0x%s , load size %ld\n",
                        paddr_nz (entry), data_count);
+#endif
     /* We were doing this in remote-mips.c, I suspect it is right
        for other targets too.  */
     write_pc (entry);
@@ -1385,11 +1413,32 @@ report_transfer_performance (data_count, start_time, end_time)
 }
 
 void
-print_transfer_performance (struct gdb_file *stream,
+print_transfer_performance (struct ui_file *stream,
                            unsigned long data_count,
                            unsigned long write_count,
                            unsigned long time_count)
 {
+#ifdef UI_OUT
+  ui_out_text (uiout, "Transfer rate: ");
+  if (time_count > 0)
+    {
+      ui_out_field_fmt (uiout, "transfer-rate", "%ld", 
+                       (data_count * 8) / time_count);
+      ui_out_text (uiout, " bits/sec");
+    }
+  else
+    {
+      ui_out_field_fmt (uiout, "transferred-bits", "%ld", (data_count * 8));
+      ui_out_text (uiout, " bits in <1 sec");    
+    }
+  if (write_count > 0)
+    {
+      ui_out_text (uiout, ", ");
+      ui_out_field_fmt (uiout, "write-rate", "%ld", data_count / write_count);
+      ui_out_text (uiout, " bytes/write");
+    }
+  ui_out_text (uiout, ".\n");
+#else
   fprintf_unfiltered (stream, "Transfer rate: ");
   if (time_count > 0)
     fprintf_unfiltered (stream, "%ld bits/sec", (data_count * 8) / time_count);
@@ -1398,6 +1447,7 @@ print_transfer_performance (struct gdb_file *stream,
   if (write_count > 0)
     fprintf_unfiltered (stream, ", %ld bytes/write", data_count / write_count);
   fprintf_unfiltered (stream, ".\n");
+#endif
 }
 
 /* This function allows the addition of incrementally linked object files.
@@ -1435,7 +1485,7 @@ add_symbol_file_command (args, from_tty)
 
   /* Make a copy of the string that we can safely write into. */
 
-  args = strdup (args);
+  args = xstrdup (args);
   make_cleanup (free, args);
 
   /* Ensure section_addrs is initialized */
@@ -1560,7 +1610,7 @@ add_symbol_file_command (args, from_tty)
                    text data or bss section. This is redundent but
                    eventually, none will be given special treatment */
                {
-                 section_addrs.other[sec_num].name = strdup (sec);
+                 section_addrs.other[sec_num].name = xstrdup (sec);
                  make_cleanup (free, section_addrs.other[sec_num].name);
                  section_addrs.other[sec_num++].addr = addr;
                  printf_filtered ("\t%s_addr = %s\n",
@@ -1715,9 +1765,7 @@ reread_symbols ()
                      sizeof (objfile->static_psymbols));
 
              /* Free the obstacks for non-reusable objfiles */
-             obstack_free (&objfile->psymbol_cache.cache, 0);
-             memset (&objfile->psymbol_cache, 0,
-                     sizeof (objfile->psymbol_cache));
+             free_bcache (&objfile->psymbol_cache);
              obstack_free (&objfile->psymbol_obstack, 0);
              obstack_free (&objfile->symbol_obstack, 0);
              obstack_free (&objfile->type_obstack, 0);
This page took 0.027944 seconds and 4 git commands to generate.