#define O_BINARY 0
#endif
+int (*ui_load_progress_hook) PARAMS ((char *, unsigned long));
+void (*pre_add_symbol_hook) PARAMS ((char *));
+void (*post_add_symbol_hook) PARAMS ((void));
+
/* Global variables owned by this file */
int readnow_symbol_files; /* Read full symbols immediately */
performed, or need to read an unmapped symbol table. */
if (from_tty || info_verbose)
{
- printf_filtered ("Reading symbols from %s...", name);
- wrap_here ("");
- gdb_flush (gdb_stdout);
+ if (pre_add_symbol_hook)
+ pre_add_symbol_hook (name);
+ else
+ {
+ printf_filtered ("Reading symbols from %s...", name);
+ wrap_here ("");
+ gdb_flush (gdb_stdout);
+ }
}
syms_from_objfile (objfile, addr, mainline, from_tty);
}
if (from_tty || info_verbose)
{
- printf_filtered ("done.\n");
- gdb_flush (gdb_stdout);
+ if (post_add_symbol_hook)
+ post_add_symbol_hook ();
+ else
+ {
+ printf_filtered ("done.\n");
+ gdb_flush (gdb_stdout);
+ }
}
new_symfile_objfile (objfile, mainline, from_tty);
to worry about finding it, and (b) On VMS, fork() is very slow and so
we don't want to run a subprocess. On the other hand, I'm not sure how
performance compares. */
+#define GENERIC_LOAD_CHUNK 256
+#define VALIDATE_DOWNLOAD 0
void
generic_load (filename, from_tty)
char *filename;
unsigned long data_count = 0; /* Number of bytes transferred to memory */
int n;
unsigned long load_offset = 0; /* offset to add to vma for each section */
- char buf[128];
+ char buf[GENERIC_LOAD_CHUNK+8];
+#if VALIDATE_DOWNLOAD
+ char verify_buffer[GENERIC_LOAD_CHUNK+8] ;
+#endif
/* enable user to specify address for downloading as 2nd arg to load */
n = sscanf(filename, "%s 0x%lx", buf, &load_offset);
for (s = loadfile_bfd->sections; s; s = s->next)
{
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;
-
- data_count += size;
-
- buffer = xmalloc (size);
- old_chain = make_cleanup (free, buffer);
+ {
+ 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;
+ char *sect;
+ unsigned long sent;
+ unsigned long len;
+
+ l = l > GENERIC_LOAD_CHUNK ? GENERIC_LOAD_CHUNK : l ;
+
+ 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 ",
+ bfd_get_section_name (loadfile_bfd, s),
+ (unsigned long) size);
+ print_address_numeric (lma, 1, gdb_stdout);
+ printf_filtered ("\n");
+
+ bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
+
+ sect = (char *) bfd_get_section_name (loadfile_bfd, s);
+ sent = 0;
+ do
+ {
+ len = (size - sent) < l ? (size - sent) : l;
+ sent += len;
+ err = target_write_memory (lma, buffer, len);
+ if (ui_load_progress_hook)
+ if (ui_load_progress_hook (sect, sent))
+ error ("Canceled the download");
+#if VALIDATE_DOWNLOAD
+ /* Broken memories and broken monitors manifest themselves
+ here when bring new computers to life.
+ This doubles already slow downloads.
+ */
+ if (err) break ;
+ {
+ target_read_memory(lma,verify_buffer,len) ;
+ if (0 != bcmp(buffer,verify_buffer,len))
+ error("Download verify failed at %08x",
+ (unsigned long)lma) ;
+ }
- 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 ",
- bfd_get_section_name (loadfile_bfd, s),
- (unsigned long) size);
- print_address_numeric (lma, 1, gdb_stdout);
- printf_filtered ("\n");
-
- bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
-
- target_write_memory (lma, buffer, size);
-
- do_cleanups (old_chain);
- }
- }
+#endif
+ data_count += len ;
+ lma += len;
+ buffer += len;
+ } /* od */
+ while (err == 0 && sent < size);
+
+ if (err != 0)
+ error ("Memory access error while loading section %s.",
+ bfd_get_section_name (loadfile_bfd, s));
+
+ do_cleanups (old_chain);
+ }
+ }
}
end_time = time (NULL);
-
- printf_filtered ("Start address 0x%lx\n", loadfile_bfd->start_address);
-
- /* We were doing this in remote-mips.c, I suspect it is right
- for other targets too. */
- write_pc (loadfile_bfd->start_address);
+ {
+ unsigned long entry ;
+ entry = bfd_get_start_address(loadfile_bfd) ;
+ printf_filtered ("Start address 0x%lx , load size %d\n", entry,data_count);
+ /* We were doing this in remote-mips.c, I suspect it is right
+ for other targets too. */
+ write_pc (entry);
+ }
/* FIXME: are we supposed to call symbol_file_add or not? According to
a comment from remote-mips.c (where a call to symbol_file_add was
}
/* FIXME-32x64: Assumes text_addr fits in a long. */
- if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
- name, local_hex_string ((unsigned long)text_addr)))
+ if ((from_tty)
+ && (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
+ name, local_hex_string ((unsigned long)text_addr))))
error ("Not confirmed.");
- symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
+ symbol_file_add (name, from_tty, text_addr, 0, mapped, readnow);
/* Getting new symbols may change our opinion about what is
frameless. */
else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
|| STREQ (c, ".cpp") || STREQ (c, ".cp") || STREQ (c, ".c++"))
return language_cplus;
- else if (STREQ (c, ".java"))
+ /* start-sanitize-java */
+ else if (STREQ (c, ".java") || STREQ (c, ".class"))
return language_java;
+ /* end-sanitize-java */
else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
return language_chill;
else if (STREQ (c, ".f") || STREQ (c, ".F"))
symtab->dirname
symtab->free_code
symtab->free_ptr
- initialize any EXTRA_SYMTAB_INFO
possibly free_named_symtabs (symtab->filename);
*/
&objfile -> symbol_obstack);
symtab -> fullname = NULL;
symtab -> language = deduce_language_from_filename (filename);
+ symtab -> debugformat = obsavestring ("unknown", 7,
+ &objfile -> symbol_obstack);
/* Hook it to the objfile it comes from */
symtab -> next = objfile -> symtabs;
objfile -> symtabs = symtab;
+ /* FIXME: This should go away. It is only defined for the Z8000,
+ and the Z8000 definition of this macro doesn't have anything to
+ do with the now-nonexistent EXTRA_SYMTAB_INFO macro, it's just
+ here for convenience. */
#ifdef INIT_EXTRA_SYMTAB_INFO
INIT_EXTRA_SYMTAB_INFO (symtab);
#endif
&objfile -> psymbol_obstack);
psymtab -> symtab = NULL;
- /* Hook it to the objfile it comes from */
+ /* Prepend it to the psymtab list for the objfile it belongs to.
+ Psymtabs are searched in most recent inserted -> least recent
+ inserted order. */
psymtab -> objfile = objfile;
psymtab -> next = objfile -> psymtabs;
objfile -> psymtabs = psymtab;
+#if 0
+ {
+ struct partial_symtab **prev_pst;
+ psymtab -> objfile = objfile;
+ psymtab -> next = NULL;
+ prev_pst = &(objfile -> psymtabs);
+ while ((*prev_pst) != NULL)
+ prev_pst = &((*prev_pst) -> next);
+ (*prev_pst) = psymtab;
+ }
+#endif
return (psymtab);
}
+void
+discard_psymtab (pst)
+ struct partial_symtab *pst;
+{
+ struct partial_symtab **prev_pst;
+
+ /* From dbxread.c:
+ Empty psymtabs happen as a result of header files which don't
+ have any symbols in them. There can be a lot of them. But this
+ check is wrong, in that a psymtab with N_SLINE entries but
+ nothing else is not empty, but we don't realize that. Fixing
+ that without slowing things down might be tricky. */
+
+ /* First, snip it out of the psymtab chain */
+
+ prev_pst = &(pst->objfile->psymtabs);
+ while ((*prev_pst) != pst)
+ prev_pst = &((*prev_pst)->next);
+ (*prev_pst) = pst->next;
+
+ /* Next, put it on a free list for recycling */
+
+ pst->next = pst->objfile->free_psymtabs;
+ pst->objfile->free_psymtabs = pst;
+}
+
\f
/* Reset all data structures in gdb which may contain references to symbol
table data. */
objfile -> global_psymbols.size = total_symbols / 10;
objfile -> static_psymbols.size = total_symbols / 10;
- objfile -> global_psymbols.next =
- objfile -> global_psymbols.list = (struct partial_symbol **)
- xmmalloc (objfile -> md, objfile -> global_psymbols.size
- * sizeof (struct partial_symbol *));
- objfile -> static_psymbols.next =
- objfile -> static_psymbols.list = (struct partial_symbol **)
- xmmalloc (objfile -> md, objfile -> static_psymbols.size
- * sizeof (struct partial_symbol *));
+
+ if (objfile -> global_psymbols.size > 0)
+ {
+ objfile -> global_psymbols.next =
+ objfile -> global_psymbols.list = (struct partial_symbol **)
+ xmmalloc (objfile -> md, (objfile -> global_psymbols.size
+ * sizeof (struct partial_symbol *)));
+ }
+ if (objfile -> static_psymbols.size > 0)
+ {
+ objfile -> static_psymbols.next =
+ objfile -> static_psymbols.list = (struct partial_symbol **)
+ xmmalloc (objfile -> md, (objfile -> static_psymbols.size
+ * sizeof (struct partial_symbol *)));
+ }
}
/* OVERLAYS:
static void
overlay_auto_command (args, from_tty)
+ char *args;
+ int from_tty;
{
overlay_debugging = -1;
if (info_verbose)
static void
overlay_manual_command (args, from_tty)
+ char *args;
+ int from_tty;
{
overlay_debugging = 1;
if (info_verbose)
static void
overlay_off_command (args, from_tty)
+ char *args;
+ int from_tty;
{
overlay_debugging = 0;
if (info_verbose)
static void
overlay_load_command (args, from_tty)
+ char *args;
+ int from_tty;
{
if (target_overlay_update)
(*target_overlay_update) (NULL);
static CORE_ADDR cache_ovly_region_table_base = 0;
#endif
enum ovly_index { VMA, SIZE, LMA, MAPPED};
-#define TARGET_INT_BYTES (TARGET_INT_BIT / TARGET_CHAR_BIT)
+#define TARGET_LONG_BYTES (TARGET_LONG_BIT / TARGET_CHAR_BIT)
/* Throw away the cached copy of _ovly_table */
static void
/* Read an array of ints from the target into a local buffer.
Convert to host order. int LEN is number of ints */
static void
-read_target_int_array (memaddr, myaddr, len)
+read_target_long_array (memaddr, myaddr, len)
CORE_ADDR memaddr;
unsigned int *myaddr;
int len;
{
- char *buf = alloca (len * TARGET_INT_BYTES);
+ char *buf = alloca (len * TARGET_LONG_BYTES);
int i;
- read_memory (memaddr, buf, len * TARGET_INT_BYTES);
+ read_memory (memaddr, buf, len * TARGET_LONG_BYTES);
for (i = 0; i < len; i++)
- myaddr[i] = extract_unsigned_integer (TARGET_INT_BYTES * i + buf,
- TARGET_INT_BYTES);
+ myaddr[i] = extract_unsigned_integer (TARGET_LONG_BYTES * i + buf,
+ TARGET_LONG_BYTES);
}
/* Find and grab a copy of the target _ovly_table
if (msym != NULL)
{
cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (msym);
- read_target_int_array (cache_ovly_table_base,
- (int *) cache_ovly_table,
- cache_novlys * 4);
+ read_target_long_array (cache_ovly_table_base,
+ (int *) cache_ovly_table,
+ cache_novlys * 4);
}
else
return 0; /* failure */
if (msym != NULL)
{
cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
- read_target_int_array (cache_ovly_region_table_base,
- (int *) cache_ovly_region_table,
- cache_novly_regions * 3);
+ read_target_long_array (cache_ovly_region_table_base,
+ (int *) cache_ovly_region_table,
+ cache_novly_regions * 3);
}
else
return 0; /* failure */
size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
for (i = 0; i < cache_novlys; i++)
if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
- cache_ovly_table[i][SIZE] == size)
+ cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
+ cache_ovly_table[i][SIZE] == size */)
{
- read_target_int_array (cache_ovly_table_base + i * TARGET_INT_BYTES,
- (int *) &cache_ovly_table[i], 4);
+ read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES,
+ (int *) cache_ovly_table[i], 4);
if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
- cache_ovly_table[i][SIZE] == size)
+ cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
+ cache_ovly_table[i][SIZE] == size */)
{
osect->ovly_mapped = cache_ovly_table[i][MAPPED];
return 1;
size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
for (i = 0; i < cache_novlys; i++)
if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
- cache_ovly_table[i][SIZE] == size)
+ cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
+ cache_ovly_table[i][SIZE] == size */)
{ /* obj_section matches i'th entry in ovly_table */
osect->ovly_mapped = cache_ovly_table[i][MAPPED];
break; /* finished with inner for loop: break out */