/* 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.
#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 *));
/* Global variables owned by this file */
int readnow_symbol_files; /* Read full symbols immediately */
new_symfile_objfile (objfile, mainline, from_tty);
- target_new_objfile (objfile);
+ if (target_new_objfile_hook)
+ target_new_objfile_hook (objfile);
return (objfile);
}
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. */
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)
/* 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);
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);
{
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);
}
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);
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.
/* 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 */
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",
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);
current_source_symtab = 0;
current_source_line = 0;
clear_pc_function_cache ();
- target_new_objfile (NULL);
+ if (target_new_objfile_hook)
+ target_new_objfile_hook (NULL);
}
/* clear_symtab_users_once: