1 /* Generic symbol file reading for the GNU debugger, GDB.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Support, using pieces from other GDB modules.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32 #include "breakpoint.h"
34 #include "complaints.h"
36 #include "inferior.h" /* for write_pc */
37 #include "gdb-stabs.h"
41 #include <sys/types.h>
43 #include "gdb_string.h"
55 /* Global variables owned by this file */
56 int readnow_symbol_files; /* Read full symbols immediately */
58 struct complaint oldsyms_complaint = {
59 "Replacing old symbols for `%s'", 0, 0
62 struct complaint empty_symtab_complaint = {
63 "Empty symbol table found for `%s'", 0, 0
66 /* External variables and functions referenced. */
68 extern int info_verbose;
70 extern void report_transfer_performance PARAMS ((unsigned long,
73 /* Functions this file defines */
76 static int simple_read_overlay_region_table PARAMS ((void));
77 static void simple_free_overlay_region_table PARAMS ((void));
80 static void set_initial_language PARAMS ((void));
82 static void load_command PARAMS ((char *, int));
84 static void add_symbol_file_command PARAMS ((char *, int));
86 static void add_shared_symbol_files_command PARAMS ((char *, int));
88 static void cashier_psymtab PARAMS ((struct partial_symtab *));
90 static int compare_psymbols PARAMS ((const void *, const void *));
92 static int compare_symbols PARAMS ((const void *, const void *));
94 static bfd *symfile_bfd_open PARAMS ((char *));
96 static void find_sym_fns PARAMS ((struct objfile *));
98 static void decrement_reading_symtab PARAMS ((void *));
100 /* List of all available sym_fns. On gdb startup, each object file reader
101 calls add_symtab_fns() to register information on each format it is
104 static struct sym_fns *symtab_fns = NULL;
106 /* Flag for whether user will be reloading symbols multiple times.
107 Defaults to ON for VxWorks, otherwise OFF. */
109 #ifdef SYMBOL_RELOADING_DEFAULT
110 int symbol_reloading = SYMBOL_RELOADING_DEFAULT;
112 int symbol_reloading = 0;
115 /* If true, then shared library symbols will be added automatically
116 when the inferior is created, new libraries are loaded, or when
117 attaching to the inferior. This is almost always what users
118 will want to have happen; but for very large programs, the startup
119 time will be excessive, and so if this is a problem, the user can
120 clear this flag and then add the shared library symbols as needed.
121 Note that there is a potential for confusion, since if the shared
122 library symbols are not loaded, commands like "info fun" will *not*
123 report all the functions that are actually present. */
125 int auto_solib_add = 1;
128 /* Since this function is called from within qsort, in an ANSI environment
129 it must conform to the prototype for qsort, which specifies that the
130 comparison function takes two "void *" pointers. */
133 compare_symbols (s1p, s2p)
137 register struct symbol **s1, **s2;
139 s1 = (struct symbol **) s1p;
140 s2 = (struct symbol **) s2p;
142 return (STRCMP (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)));
149 compare_psymbols -- compare two partial symbols by name
153 Given pointers to pointers to two partial symbol table entries,
154 compare them by name and return -N, 0, or +N (ala strcmp).
155 Typically used by sorting routines like qsort().
159 Does direct compare of first two characters before punting
160 and passing to strcmp for longer compares. Note that the
161 original version had a bug whereby two null strings or two
162 identically named one character strings would return the
163 comparison of memory following the null byte.
168 compare_psymbols (s1p, s2p)
172 register char *st1 = SYMBOL_NAME (*(struct partial_symbol **) s1p);
173 register char *st2 = SYMBOL_NAME (*(struct partial_symbol **) s2p);
175 if ((st1[0] - st2[0]) || !st1[0])
177 return (st1[0] - st2[0]);
179 else if ((st1[1] - st2[1]) || !st1[1])
181 return (st1[1] - st2[1]);
185 return (STRCMP (st1 + 2, st2 + 2));
190 sort_pst_symbols (pst)
191 struct partial_symtab *pst;
193 /* Sort the global list; don't sort the static list */
195 qsort (pst -> objfile -> global_psymbols.list + pst -> globals_offset,
196 pst -> n_global_syms, sizeof (struct partial_symbol *),
200 /* Call sort_block_syms to sort alphabetically the symbols of one block. */
204 register struct block *b;
206 qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
207 sizeof (struct symbol *), compare_symbols);
210 /* Call sort_symtab_syms to sort alphabetically
211 the symbols of each block of one symtab. */
215 register struct symtab *s;
217 register struct blockvector *bv;
220 register struct block *b;
224 bv = BLOCKVECTOR (s);
225 nbl = BLOCKVECTOR_NBLOCKS (bv);
226 for (i = 0; i < nbl; i++)
228 b = BLOCKVECTOR_BLOCK (bv, i);
229 if (BLOCK_SHOULD_SORT (b))
234 /* Make a null terminated copy of the string at PTR with SIZE characters in
235 the obstack pointed to by OBSTACKP . Returns the address of the copy.
236 Note that the string at PTR does not have to be null terminated, I.E. it
237 may be part of a larger string and we are only saving a substring. */
240 obsavestring (ptr, size, obstackp)
243 struct obstack *obstackp;
245 register char *p = (char *) obstack_alloc (obstackp, size + 1);
246 /* Open-coded memcpy--saves function call time. These strings are usually
247 short. FIXME: Is this really still true with a compiler that can
250 register char *p1 = ptr;
251 register char *p2 = p;
252 char *end = ptr + size;
260 /* Concatenate strings S1, S2 and S3; return the new string. Space is found
261 in the obstack pointed to by OBSTACKP. */
264 obconcat (obstackp, s1, s2, s3)
265 struct obstack *obstackp;
266 const char *s1, *s2, *s3;
268 register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
269 register char *val = (char *) obstack_alloc (obstackp, len);
276 /* True if we are nested inside psymtab_to_symtab. */
278 int currently_reading_symtab = 0;
281 decrement_reading_symtab (dummy)
284 currently_reading_symtab--;
287 /* Get the symbol table that corresponds to a partial_symtab.
288 This is fast after the first time you do it. In fact, there
289 is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
293 psymtab_to_symtab (pst)
294 register struct partial_symtab *pst;
296 /* If it's been looked up before, return it. */
300 /* If it has not yet been read in, read it. */
303 struct cleanup *back_to = make_cleanup (decrement_reading_symtab, NULL);
304 currently_reading_symtab++;
305 (*pst->read_symtab) (pst);
306 do_cleanups (back_to);
312 /* Initialize entry point information for this objfile. */
315 init_entry_point_info (objfile)
316 struct objfile *objfile;
318 /* Save startup file's range of PC addresses to help blockframe.c
319 decide where the bottom of the stack is. */
321 if (bfd_get_file_flags (objfile -> obfd) & EXEC_P)
323 /* Executable file -- record its entry point so we'll recognize
324 the startup file because it contains the entry point. */
325 objfile -> ei.entry_point = bfd_get_start_address (objfile -> obfd);
329 /* Examination of non-executable.o files. Short-circuit this stuff. */
330 objfile -> ei.entry_point = INVALID_ENTRY_POINT;
332 objfile -> ei.entry_file_lowpc = INVALID_ENTRY_LOWPC;
333 objfile -> ei.entry_file_highpc = INVALID_ENTRY_HIGHPC;
334 objfile -> ei.entry_func_lowpc = INVALID_ENTRY_LOWPC;
335 objfile -> ei.entry_func_highpc = INVALID_ENTRY_HIGHPC;
336 objfile -> ei.main_func_lowpc = INVALID_ENTRY_LOWPC;
337 objfile -> ei.main_func_highpc = INVALID_ENTRY_HIGHPC;
340 /* Get current entry point address. */
343 entry_point_address()
345 return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
348 /* Remember the lowest-addressed loadable section we've seen.
349 This function is called via bfd_map_over_sections.
351 In case of equal vmas, the section with the largest size becomes the
352 lowest-addressed loadable section.
354 If the vmas and sizes are equal, the last section is considered the
355 lowest-addressed loadable section. */
358 find_lowest_section (abfd, sect, obj)
363 asection **lowest = (asection **)obj;
365 if (0 == (bfd_get_section_flags (abfd, sect) & SEC_LOAD))
368 *lowest = sect; /* First loadable section */
369 else if (bfd_section_vma (abfd, *lowest) > bfd_section_vma (abfd, sect))
370 *lowest = sect; /* A lower loadable section */
371 else if (bfd_section_vma (abfd, *lowest) == bfd_section_vma (abfd, sect)
372 && (bfd_section_size (abfd, (*lowest))
373 <= bfd_section_size (abfd, sect)))
377 /* Parse the user's idea of an offset for dynamic linking, into our idea
378 of how to represent it for fast symbol reading. This is the default
379 version of the sym_fns.sym_offsets function for symbol readers that
380 don't need to do anything special. It allocates a section_offsets table
381 for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */
383 struct section_offsets *
384 default_symfile_offsets (objfile, addr)
385 struct objfile *objfile;
388 struct section_offsets *section_offsets;
391 objfile->num_sections = SECT_OFF_MAX;
392 section_offsets = (struct section_offsets *)
393 obstack_alloc (&objfile -> psymbol_obstack, SIZEOF_SECTION_OFFSETS);
395 for (i = 0; i < SECT_OFF_MAX; i++)
396 ANOFFSET (section_offsets, i) = addr;
398 return section_offsets;
402 /* Process a symbol file, as either the main file or as a dynamically
405 NAME is the file name (which will be tilde-expanded and made
406 absolute herein) (but we don't free or modify NAME itself).
407 FROM_TTY says how verbose to be. MAINLINE specifies whether this
408 is the main symbol file, or whether it's an extra symbol file such
409 as dynamically loaded code. If !mainline, ADDR is the address
410 where the text segment was loaded. If VERBO, the caller has printed
411 a verbose message about the symbol reading (and complaints can be
412 more terse about it). */
415 syms_from_objfile (objfile, addr, mainline, verbo)
416 struct objfile *objfile;
421 struct section_offsets *section_offsets;
422 asection *lowest_sect;
423 struct cleanup *old_chain;
425 init_entry_point_info (objfile);
426 find_sym_fns (objfile);
428 /* Make sure that partially constructed symbol tables will be cleaned up
429 if an error occurs during symbol reading. */
430 old_chain = make_cleanup (free_objfile, objfile);
434 /* We will modify the main symbol table, make sure that all its users
435 will be cleaned up if an error occurs during symbol reading. */
436 make_cleanup (clear_symtab_users, 0);
438 /* Since no error yet, throw away the old symbol table. */
440 if (symfile_objfile != NULL)
442 free_objfile (symfile_objfile);
443 symfile_objfile = NULL;
446 /* Currently we keep symbols from the add-symbol-file command.
447 If the user wants to get rid of them, they should do "symbol-file"
448 without arguments first. Not sure this is the best behavior
451 (*objfile -> sf -> sym_new_init) (objfile);
454 /* Convert addr into an offset rather than an absolute address.
455 We find the lowest address of a loaded segment in the objfile,
456 and assume that <addr> is where that got loaded. Due to historical
457 precedent, we warn if that doesn't happen to be a text segment. */
461 addr = 0; /* No offset from objfile addresses. */
465 lowest_sect = bfd_get_section_by_name (objfile->obfd, ".text");
466 if (lowest_sect == NULL)
467 bfd_map_over_sections (objfile->obfd, find_lowest_section,
470 if (lowest_sect == NULL)
471 warning ("no loadable sections found in added symbol-file %s",
473 else if ((bfd_get_section_flags (objfile->obfd, lowest_sect) & SEC_CODE)
475 /* FIXME-32x64--assumes bfd_vma fits in long. */
476 warning ("Lowest section in %s is %s at 0x%lx",
478 bfd_section_name (objfile->obfd, lowest_sect),
479 (unsigned long) bfd_section_vma (objfile->obfd, lowest_sect));
482 addr -= bfd_section_vma (objfile->obfd, lowest_sect);
485 /* Initialize symbol reading routines for this objfile, allow complaints to
486 appear for this new file, and record how verbose to be, then do the
487 initial symbol reading for this file. */
489 (*objfile -> sf -> sym_init) (objfile);
490 clear_complaints (1, verbo);
492 section_offsets = (*objfile -> sf -> sym_offsets) (objfile, addr);
493 objfile->section_offsets = section_offsets;
495 #ifndef IBM6000_TARGET
496 /* This is a SVR4/SunOS specific hack, I think. In any event, it
497 screws RS/6000. sym_offsets should be doing this sort of thing,
498 because it knows the mapping between bfd sections and
500 /* This is a hack. As far as I can tell, section offsets are not
501 target dependent. They are all set to addr with a couple of
502 exceptions. The exceptions are sysvr4 shared libraries, whose
503 offsets are kept in solib structures anyway and rs6000 xcoff
504 which handles shared libraries in a completely unique way.
506 Section offsets are built similarly, except that they are built
507 by adding addr in all cases because there is no clear mapping
508 from section_offsets into actual sections. Note that solib.c
509 has a different algorythm for finding section offsets.
511 These should probably all be collapsed into some target
512 independent form of shared library support. FIXME. */
516 struct obj_section *s;
518 for (s = objfile->sections; s < objfile->sections_end; ++s)
520 s->addr -= s->offset;
522 s->endaddr -= s->offset;
527 #endif /* not IBM6000_TARGET */
529 (*objfile -> sf -> sym_read) (objfile, section_offsets, mainline);
531 if (!have_partial_symbols () && !have_full_symbols ())
534 printf_filtered ("(no debugging symbols found)...");
538 /* Don't allow char * to have a typename (else would get caddr_t).
539 Ditto void *. FIXME: Check whether this is now done by all the
540 symbol readers themselves (many of them now do), and if so remove
543 TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
544 TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0;
546 /* Mark the objfile has having had initial symbol read attempted. Note
547 that this does not mean we found any symbols... */
549 objfile -> flags |= OBJF_SYMS;
551 /* Discard cleanups as symbol reading was successful. */
553 discard_cleanups (old_chain);
555 /* Call this after reading in a new symbol table to give target dependant code
556 a crack at the new symbols. For instance, this could be used to update the
557 values of target-specific symbols GDB needs to keep track of (such as
558 _sigtramp, or whatever). */
560 TARGET_SYMFILE_POSTREAD (objfile);
563 /* Perform required actions after either reading in the initial
564 symbols for a new objfile, or mapping in the symbols from a reusable
568 new_symfile_objfile (objfile, mainline, verbo)
569 struct objfile *objfile;
574 /* If this is the main symbol file we have to clean up all users of the
575 old main symbol file. Otherwise it is sufficient to fixup all the
576 breakpoints that may have been redefined by this symbol file. */
579 /* OK, make it the "real" symbol file. */
580 symfile_objfile = objfile;
582 clear_symtab_users ();
586 breakpoint_re_set ();
589 /* We're done reading the symbol file; finish off complaints. */
590 clear_complaints (0, verbo);
593 /* Process a symbol file, as either the main file or as a dynamically
596 NAME is the file name (which will be tilde-expanded and made
597 absolute herein) (but we don't free or modify NAME itself).
598 FROM_TTY says how verbose to be. MAINLINE specifies whether this
599 is the main symbol file, or whether it's an extra symbol file such
600 as dynamically loaded code. If !mainline, ADDR is the address
601 where the text segment was loaded.
603 Upon success, returns a pointer to the objfile that was added.
604 Upon failure, jumps back to command level (never returns). */
607 symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
615 struct objfile *objfile;
616 struct partial_symtab *psymtab;
619 /* Open a bfd for the file, and give user a chance to burp if we'd be
620 interactively wiping out any existing symbols. */
622 abfd = symfile_bfd_open (name);
624 if ((have_full_symbols () || have_partial_symbols ())
627 && !query ("Load new symbol table from \"%s\"? ", name))
628 error ("Not confirmed.");
630 objfile = allocate_objfile (abfd, mapped);
632 /* If the objfile uses a mapped symbol file, and we have a psymtab for
633 it, then skip reading any symbols at this time. */
635 if ((objfile -> flags & OBJF_MAPPED) && (objfile -> flags & OBJF_SYMS))
637 /* We mapped in an existing symbol table file that already has had
638 initial symbol reading performed, so we can skip that part. Notify
639 the user that instead of reading the symbols, they have been mapped.
641 if (from_tty || info_verbose)
643 printf_filtered ("Mapped symbols for %s...", name);
645 gdb_flush (gdb_stdout);
647 init_entry_point_info (objfile);
648 find_sym_fns (objfile);
652 /* We either created a new mapped symbol table, mapped an existing
653 symbol table file which has not had initial symbol reading
654 performed, or need to read an unmapped symbol table. */
655 if (from_tty || info_verbose)
657 printf_filtered ("Reading symbols from %s...", name);
659 gdb_flush (gdb_stdout);
661 syms_from_objfile (objfile, addr, mainline, from_tty);
664 /* We now have at least a partial symbol table. Check to see if the
665 user requested that all symbols be read on initial access via either
666 the gdb startup command line or on a per symbol file basis. Expand
667 all partial symbol tables for this objfile if so. */
669 if (readnow || readnow_symbol_files)
671 if (from_tty || info_verbose)
673 printf_filtered ("expanding to full symbols...");
675 gdb_flush (gdb_stdout);
678 for (psymtab = objfile -> psymtabs;
680 psymtab = psymtab -> next)
682 psymtab_to_symtab (psymtab);
686 if (from_tty || info_verbose)
688 printf_filtered ("done.\n");
689 gdb_flush (gdb_stdout);
692 new_symfile_objfile (objfile, mainline, from_tty);
694 target_new_objfile (objfile);
699 /* This is the symbol-file command. Read the file, analyze its
700 symbols, and add a struct symtab to a symtab list. The syntax of
701 the command is rather bizarre--(1) buildargv implements various
702 quoting conventions which are undocumented and have little or
703 nothing in common with the way things are quoted (or not quoted)
704 elsewhere in GDB, (2) options are used, which are not generally
705 used in GDB (perhaps "set mapped on", "set readnow on" would be
706 better), (3) the order of options matters, which is contrary to GNU
707 conventions (because it is confusing and inconvenient). */
710 symbol_file_command (args, from_tty)
716 CORE_ADDR text_relocation = 0; /* text_relocation */
717 struct cleanup *cleanups;
725 if ((have_full_symbols () || have_partial_symbols ())
727 && !query ("Discard symbol table from `%s'? ",
728 symfile_objfile -> name))
729 error ("Not confirmed.");
730 free_all_objfiles ();
731 symfile_objfile = NULL;
734 printf_unfiltered ("No symbol file now.\n");
739 if ((argv = buildargv (args)) == NULL)
743 cleanups = make_cleanup (freeargv, (char *) argv);
744 while (*argv != NULL)
746 if (STREQ (*argv, "-mapped"))
750 else if (STREQ (*argv, "-readnow"))
754 else if (**argv == '-')
756 error ("unknown option `%s'", *argv);
764 /* this is for rombug remote only, to get the text relocation by
765 using link command */
766 p = strrchr(name, '/');
770 target_link(p, &text_relocation);
772 if (text_relocation == (CORE_ADDR)0)
774 else if (text_relocation == (CORE_ADDR)-1)
775 symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped,
778 symbol_file_add (name, from_tty, (CORE_ADDR)text_relocation,
781 /* Getting new symbols may change our opinion about what is
783 reinit_frame_cache ();
785 set_initial_language ();
792 error ("no symbol file name was specified");
794 do_cleanups (cleanups);
798 /* Set the initial language.
800 A better solution would be to record the language in the psymtab when reading
801 partial symbols, and then use it (if known) to set the language. This would
802 be a win for formats that encode the language in an easily discoverable place,
803 such as DWARF. For stabs, we can jump through hoops looking for specially
804 named symbols or try to intuit the language from the specific type of stabs
805 we find, but we can't do that until later when we read in full symbols.
809 set_initial_language ()
811 struct partial_symtab *pst;
812 enum language lang = language_unknown;
814 pst = find_main_psymtab ();
817 if (pst -> filename != NULL)
819 lang = deduce_language_from_filename (pst -> filename);
821 if (lang == language_unknown)
823 /* Make C the default language */
827 expected_language = current_language; /* Don't warn the user */
831 /* Open file specified by NAME and hand it off to BFD for preliminary
832 analysis. Result is a newly initialized bfd *, which includes a newly
833 malloc'd` copy of NAME (tilde-expanded and made absolute).
834 In case of trouble, error() is called. */
837 symfile_bfd_open (name)
844 name = tilde_expand (name); /* Returns 1st new malloc'd copy */
846 /* Look down path for it, allocate 2nd new malloc'd copy. */
847 desc = openp (getenv ("PATH"), 1, name, O_RDONLY | O_BINARY, 0, &absolute_name);
848 #if defined(__GO32__) || defined(_WIN32)
851 char *exename = alloca (strlen (name) + 5);
852 strcat (strcpy (exename, name), ".exe");
853 desc = openp (getenv ("PATH"), 1, exename, O_RDONLY | O_BINARY,
859 make_cleanup (free, name);
860 perror_with_name (name);
862 free (name); /* Free 1st new malloc'd copy */
863 name = absolute_name; /* Keep 2nd malloc'd copy in bfd */
864 /* It'll be freed in free_objfile(). */
866 sym_bfd = bfd_fdopenr (name, gnutarget, desc);
870 make_cleanup (free, name);
871 error ("\"%s\": can't open to read symbols: %s.", name,
872 bfd_errmsg (bfd_get_error ()));
874 sym_bfd->cacheable = true;
876 if (!bfd_check_format (sym_bfd, bfd_object))
878 /* FIXME: should be checking for errors from bfd_close (for one thing,
879 on error it does not free all the storage associated with the
881 bfd_close (sym_bfd); /* This also closes desc */
882 make_cleanup (free, name);
883 error ("\"%s\": can't read symbols: %s.", name,
884 bfd_errmsg (bfd_get_error ()));
890 /* Link a new symtab_fns into the global symtab_fns list. Called on gdb
891 startup by the _initialize routine in each object file format reader,
892 to register information about each format the the reader is prepared
899 sf->next = symtab_fns;
904 /* Initialize to read symbols from the symbol file sym_bfd. It either
905 returns or calls error(). The result is an initialized struct sym_fns
906 in the objfile structure, that contains cached information about the
910 find_sym_fns (objfile)
911 struct objfile *objfile;
914 enum bfd_flavour our_flavour = bfd_get_flavour (objfile -> obfd);
915 char *our_target = bfd_get_target (objfile -> obfd);
917 /* Special kludge for RS/6000 and PowerMac. See xcoffread.c. */
918 if (STREQ (our_target, "aixcoff-rs6000") ||
919 STREQ (our_target, "xcoff-powermac"))
920 our_flavour = (enum bfd_flavour)-1;
922 /* Special kludge for apollo. See dstread.c. */
923 if (STREQN (our_target, "apollo", 6))
924 our_flavour = (enum bfd_flavour)-2;
926 for (sf = symtab_fns; sf != NULL; sf = sf -> next)
928 if (our_flavour == sf -> sym_flavour)
934 error ("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown.",
935 bfd_get_target (objfile -> obfd));
938 /* This function runs the load command of our current target. */
941 load_command (arg, from_tty)
946 arg = get_exec_file (1);
947 target_load (arg, from_tty);
950 /* This version of "load" should be usable for any target. Currently
951 it is just used for remote targets, not inftarg.c or core files,
952 on the theory that only in that case is it useful.
954 Avoiding xmodem and the like seems like a win (a) because we don't have
955 to worry about finding it, and (b) On VMS, fork() is very slow and so
956 we don't want to run a subprocess. On the other hand, I'm not sure how
957 performance compares. */
959 generic_load (filename, from_tty)
963 struct cleanup *old_cleanups;
966 time_t start_time, end_time; /* Start and end times of download */
967 unsigned long data_count = 0; /* Number of bytes transferred to memory */
969 unsigned long load_offset = 0; /* offset to add to vma for each section */
972 /* enable user to specify address for downloading as 2nd arg to load */
973 n = sscanf(filename, "%s 0x%lx", buf, &load_offset);
979 loadfile_bfd = bfd_openr (filename, gnutarget);
980 if (loadfile_bfd == NULL)
982 perror_with_name (filename);
985 /* FIXME: should be checking for errors from bfd_close (for one thing,
986 on error it does not free all the storage associated with the
988 old_cleanups = make_cleanup (bfd_close, loadfile_bfd);
990 if (!bfd_check_format (loadfile_bfd, bfd_object))
992 error ("\"%s\" is not an object file: %s", filename,
993 bfd_errmsg (bfd_get_error ()));
996 start_time = time (NULL);
998 for (s = loadfile_bfd->sections; s; s = s->next)
1000 if (s->flags & SEC_LOAD)
1004 size = bfd_get_section_size_before_reloc (s);
1008 struct cleanup *old_chain;
1013 buffer = xmalloc (size);
1014 old_chain = make_cleanup (free, buffer);
1019 /* Is this really necessary? I guess it gives the user something
1020 to look at during a long download. */
1021 printf_filtered ("Loading section %s, size 0x%lx lma ",
1022 bfd_get_section_name (loadfile_bfd, s),
1023 (unsigned long) size);
1024 print_address_numeric (lma, 1, gdb_stdout);
1025 printf_filtered ("\n");
1027 bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
1029 target_write_memory (lma, buffer, size);
1031 do_cleanups (old_chain);
1036 end_time = time (NULL);
1038 printf_filtered ("Start address 0x%lx\n", loadfile_bfd->start_address);
1040 /* We were doing this in remote-mips.c, I suspect it is right
1041 for other targets too. */
1042 write_pc (loadfile_bfd->start_address);
1044 /* FIXME: are we supposed to call symbol_file_add or not? According to
1045 a comment from remote-mips.c (where a call to symbol_file_add was
1046 commented out), making the call confuses GDB if more than one file is
1047 loaded in. remote-nindy.c had no call to symbol_file_add, but remote-vx.c
1050 report_transfer_performance (data_count, start_time, end_time);
1052 do_cleanups (old_cleanups);
1055 /* Report how fast the transfer went. */
1058 report_transfer_performance (data_count, start_time, end_time)
1059 unsigned long data_count;
1060 time_t start_time, end_time;
1062 printf_filtered ("Transfer rate: ");
1063 if (end_time != start_time)
1064 printf_filtered ("%d bits/sec",
1065 (data_count * 8) / (end_time - start_time));
1067 printf_filtered ("%d bits in <1 sec", (data_count * 8));
1068 printf_filtered (".\n");
1071 /* This function allows the addition of incrementally linked object files.
1072 It does not modify any state in the target, only in the debugger. */
1076 add_symbol_file_command (args, from_tty)
1081 CORE_ADDR text_addr;
1090 error ("add-symbol-file takes a file name and an address");
1093 /* Make a copy of the string that we can safely write into. */
1095 args = strdup (args);
1096 make_cleanup (free, args);
1098 /* Pick off any -option args and the file name. */
1100 while ((*args != '\000') && (name == NULL))
1102 while (isspace (*args)) {args++;}
1104 while ((*args != '\000') && !isspace (*args)) {args++;}
1105 if (*args != '\000')
1113 else if (STREQ (arg, "-mapped"))
1117 else if (STREQ (arg, "-readnow"))
1123 error ("unknown option `%s'", arg);
1127 /* After picking off any options and the file name, args should be
1128 left pointing at the remainder of the command line, which should
1129 be the address expression to evaluate. */
1133 error ("add-symbol-file takes a file name");
1135 name = tilde_expand (name);
1136 make_cleanup (free, name);
1138 if (*args != '\000')
1140 text_addr = parse_and_eval_address (args);
1144 target_link(name, &text_addr);
1145 if (text_addr == (CORE_ADDR)-1)
1146 error("Don't know how to get text start location for this file");
1149 /* FIXME-32x64: Assumes text_addr fits in a long. */
1150 if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
1151 name, local_hex_string ((unsigned long)text_addr)))
1152 error ("Not confirmed.");
1154 symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
1156 /* Getting new symbols may change our opinion about what is
1158 reinit_frame_cache ();
1162 add_shared_symbol_files_command (args, from_tty)
1166 #ifdef ADD_SHARED_SYMBOL_FILES
1167 ADD_SHARED_SYMBOL_FILES (args, from_tty);
1169 error ("This command is not available in this configuration of GDB.");
1173 /* Re-read symbols if a symbol-file has changed. */
1177 struct objfile *objfile;
1180 struct stat new_statbuf;
1183 /* With the addition of shared libraries, this should be modified,
1184 the load time should be saved in the partial symbol tables, since
1185 different tables may come from different source files. FIXME.
1186 This routine should then walk down each partial symbol table
1187 and see if the symbol table that it originates from has been changed */
1189 for (objfile = object_files; objfile; objfile = objfile->next) {
1190 if (objfile->obfd) {
1191 #ifdef IBM6000_TARGET
1192 /* If this object is from a shared library, then you should
1193 stat on the library name, not member name. */
1195 if (objfile->obfd->my_archive)
1196 res = stat (objfile->obfd->my_archive->filename, &new_statbuf);
1199 res = stat (objfile->name, &new_statbuf);
1201 /* FIXME, should use print_sys_errmsg but it's not filtered. */
1202 printf_filtered ("`%s' has disappeared; keeping its symbols.\n",
1206 new_modtime = new_statbuf.st_mtime;
1207 if (new_modtime != objfile->mtime)
1209 struct cleanup *old_cleanups;
1210 struct section_offsets *offsets;
1212 int section_offsets_size;
1213 char *obfd_filename;
1215 printf_filtered ("`%s' has changed; re-reading symbols.\n",
1218 /* There are various functions like symbol_file_add,
1219 symfile_bfd_open, syms_from_objfile, etc., which might
1220 appear to do what we want. But they have various other
1221 effects which we *don't* want. So we just do stuff
1222 ourselves. We don't worry about mapped files (for one thing,
1223 any mapped file will be out of date). */
1225 /* If we get an error, blow away this objfile (not sure if
1226 that is the correct response for things like shared
1228 old_cleanups = make_cleanup (free_objfile, objfile);
1229 /* We need to do this whenever any symbols go away. */
1230 make_cleanup (clear_symtab_users, 0);
1232 /* Clean up any state BFD has sitting around. We don't need
1233 to close the descriptor but BFD lacks a way of closing the
1234 BFD without closing the descriptor. */
1235 obfd_filename = bfd_get_filename (objfile->obfd);
1236 if (!bfd_close (objfile->obfd))
1237 error ("Can't close BFD for %s: %s", objfile->name,
1238 bfd_errmsg (bfd_get_error ()));
1239 objfile->obfd = bfd_openr (obfd_filename, gnutarget);
1240 if (objfile->obfd == NULL)
1241 error ("Can't open %s to read symbols.", objfile->name);
1242 /* bfd_openr sets cacheable to true, which is what we want. */
1243 if (!bfd_check_format (objfile->obfd, bfd_object))
1244 error ("Can't read symbols from %s: %s.", objfile->name,
1245 bfd_errmsg (bfd_get_error ()));
1247 /* Save the offsets, we will nuke them with the rest of the
1249 num_offsets = objfile->num_sections;
1250 section_offsets_size =
1251 sizeof (struct section_offsets)
1252 + sizeof (objfile->section_offsets->offsets) * num_offsets;
1253 offsets = (struct section_offsets *) alloca (section_offsets_size);
1254 memcpy (offsets, objfile->section_offsets, section_offsets_size);
1256 /* Nuke all the state that we will re-read. Much of the following
1257 code which sets things to NULL really is necessary to tell
1258 other parts of GDB that there is nothing currently there. */
1260 /* FIXME: Do we have to free a whole linked list, or is this
1262 if (objfile->global_psymbols.list)
1263 mfree (objfile->md, objfile->global_psymbols.list);
1264 memset (&objfile -> global_psymbols, 0,
1265 sizeof (objfile -> global_psymbols));
1266 if (objfile->static_psymbols.list)
1267 mfree (objfile->md, objfile->static_psymbols.list);
1268 memset (&objfile -> static_psymbols, 0,
1269 sizeof (objfile -> static_psymbols));
1271 /* Free the obstacks for non-reusable objfiles */
1272 obstack_free (&objfile -> psymbol_cache.cache, 0);
1273 memset (&objfile -> psymbol_cache, 0,
1274 sizeof (objfile -> psymbol_cache));
1275 obstack_free (&objfile -> psymbol_obstack, 0);
1276 obstack_free (&objfile -> symbol_obstack, 0);
1277 obstack_free (&objfile -> type_obstack, 0);
1278 objfile->sections = NULL;
1279 objfile->symtabs = NULL;
1280 objfile->psymtabs = NULL;
1281 objfile->free_psymtabs = NULL;
1282 objfile->msymbols = NULL;
1283 objfile->minimal_symbol_count= 0;
1284 objfile->fundamental_types = NULL;
1285 if (objfile -> sf != NULL)
1287 (*objfile -> sf -> sym_finish) (objfile);
1290 /* We never make this a mapped file. */
1291 objfile -> md = NULL;
1292 /* obstack_specify_allocation also initializes the obstack so
1294 obstack_specify_allocation (&objfile -> psymbol_cache.cache, 0, 0,
1296 obstack_specify_allocation (&objfile -> psymbol_obstack, 0, 0,
1298 obstack_specify_allocation (&objfile -> symbol_obstack, 0, 0,
1300 obstack_specify_allocation (&objfile -> type_obstack, 0, 0,
1302 if (build_objfile_section_table (objfile))
1304 error ("Can't find the file sections in `%s': %s",
1305 objfile -> name, bfd_errmsg (bfd_get_error ()));
1308 /* We use the same section offsets as from last time. I'm not
1309 sure whether that is always correct for shared libraries. */
1310 objfile->section_offsets = (struct section_offsets *)
1311 obstack_alloc (&objfile -> psymbol_obstack, section_offsets_size);
1312 memcpy (objfile->section_offsets, offsets, section_offsets_size);
1313 objfile->num_sections = num_offsets;
1315 /* What the hell is sym_new_init for, anyway? The concept of
1316 distinguishing between the main file and additional files
1317 in this way seems rather dubious. */
1318 if (objfile == symfile_objfile)
1319 (*objfile->sf->sym_new_init) (objfile);
1321 (*objfile->sf->sym_init) (objfile);
1322 clear_complaints (1, 1);
1323 /* The "mainline" parameter is a hideous hack; I think leaving it
1324 zero is OK since dbxread.c also does what it needs to do if
1325 objfile->global_psymbols.size is 0. */
1326 (*objfile->sf->sym_read) (objfile, objfile->section_offsets, 0);
1327 if (!have_partial_symbols () && !have_full_symbols ())
1330 printf_filtered ("(no debugging symbols found)\n");
1333 objfile -> flags |= OBJF_SYMS;
1335 /* We're done reading the symbol file; finish off complaints. */
1336 clear_complaints (0, 1);
1338 /* Getting new symbols may change our opinion about what is
1341 reinit_frame_cache ();
1343 /* Discard cleanups as symbol reading was successful. */
1344 discard_cleanups (old_cleanups);
1346 /* If the mtime has changed between the time we set new_modtime
1347 and now, we *want* this to be out of date, so don't call stat
1349 objfile->mtime = new_modtime;
1352 /* Call this after reading in a new symbol table to give target
1353 dependant code a crack at the new symbols. For instance, this
1354 could be used to update the values of target-specific symbols GDB
1355 needs to keep track of (such as _sigtramp, or whatever). */
1357 TARGET_SYMFILE_POSTREAD (objfile);
1363 clear_symtab_users ();
1368 deduce_language_from_filename (filename)
1375 else if (0 == (c = strrchr (filename, '.')))
1376 ; /* Get default. */
1377 else if (STREQ (c, ".c"))
1379 else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
1380 || STREQ (c, ".cpp") || STREQ (c, ".cp") || STREQ (c, ".c++"))
1381 return language_cplus;
1382 else if (STREQ (c, ".java"))
1383 return language_java;
1384 else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
1385 return language_chill;
1386 else if (STREQ (c, ".f") || STREQ (c, ".F"))
1387 return language_fortran;
1388 else if (STREQ (c, ".mod"))
1390 else if (STREQ (c, ".s") || STREQ (c, ".S"))
1391 return language_asm;
1393 return language_unknown; /* default */
1398 Allocate and partly initialize a new symbol table. Return a pointer
1399 to it. error() if no space.
1401 Caller must set these fields:
1407 initialize any EXTRA_SYMTAB_INFO
1408 possibly free_named_symtabs (symtab->filename);
1412 allocate_symtab (filename, objfile)
1414 struct objfile *objfile;
1416 register struct symtab *symtab;
1418 symtab = (struct symtab *)
1419 obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symtab));
1420 memset (symtab, 0, sizeof (*symtab));
1421 symtab -> filename = obsavestring (filename, strlen (filename),
1422 &objfile -> symbol_obstack);
1423 symtab -> fullname = NULL;
1424 symtab -> language = deduce_language_from_filename (filename);
1426 /* Hook it to the objfile it comes from */
1428 symtab -> objfile = objfile;
1429 symtab -> next = objfile -> symtabs;
1430 objfile -> symtabs = symtab;
1432 #ifdef INIT_EXTRA_SYMTAB_INFO
1433 INIT_EXTRA_SYMTAB_INFO (symtab);
1439 struct partial_symtab *
1440 allocate_psymtab (filename, objfile)
1442 struct objfile *objfile;
1444 struct partial_symtab *psymtab;
1446 if (objfile -> free_psymtabs)
1448 psymtab = objfile -> free_psymtabs;
1449 objfile -> free_psymtabs = psymtab -> next;
1452 psymtab = (struct partial_symtab *)
1453 obstack_alloc (&objfile -> psymbol_obstack,
1454 sizeof (struct partial_symtab));
1456 memset (psymtab, 0, sizeof (struct partial_symtab));
1457 psymtab -> filename = obsavestring (filename, strlen (filename),
1458 &objfile -> psymbol_obstack);
1459 psymtab -> symtab = NULL;
1461 /* Hook it to the objfile it comes from */
1463 psymtab -> objfile = objfile;
1464 psymtab -> next = objfile -> psymtabs;
1465 objfile -> psymtabs = psymtab;
1471 /* Reset all data structures in gdb which may contain references to symbol
1475 clear_symtab_users ()
1477 /* Someday, we should do better than this, by only blowing away
1478 the things that really need to be blown. */
1479 clear_value_history ();
1481 clear_internalvars ();
1482 breakpoint_re_set ();
1483 set_default_breakpoint (0, 0, 0, 0);
1484 current_source_symtab = 0;
1485 current_source_line = 0;
1486 clear_pc_function_cache ();
1487 target_new_objfile (NULL);
1490 /* clear_symtab_users_once:
1492 This function is run after symbol reading, or from a cleanup.
1493 If an old symbol table was obsoleted, the old symbol table
1494 has been blown away, but the other GDB data structures that may
1495 reference it have not yet been cleared or re-directed. (The old
1496 symtab was zapped, and the cleanup queued, in free_named_symtab()
1499 This function can be queued N times as a cleanup, or called
1500 directly; it will do all the work the first time, and then will be a
1501 no-op until the next time it is queued. This works by bumping a
1502 counter at queueing time. Much later when the cleanup is run, or at
1503 the end of symbol processing (in case the cleanup is discarded), if
1504 the queued count is greater than the "done-count", we do the work
1505 and set the done-count to the queued count. If the queued count is
1506 less than or equal to the done-count, we just ignore the call. This
1507 is needed because reading a single .o file will often replace many
1508 symtabs (one per .h file, for example), and we don't want to reset
1509 the breakpoints N times in the user's face.
1511 The reason we both queue a cleanup, and call it directly after symbol
1512 reading, is because the cleanup protects us in case of errors, but is
1513 discarded if symbol reading is successful. */
1516 /* FIXME: As free_named_symtabs is currently a big noop this function
1517 is no longer needed. */
1519 clear_symtab_users_once PARAMS ((void));
1521 static int clear_symtab_users_queued;
1522 static int clear_symtab_users_done;
1525 clear_symtab_users_once ()
1527 /* Enforce once-per-`do_cleanups'-semantics */
1528 if (clear_symtab_users_queued <= clear_symtab_users_done)
1530 clear_symtab_users_done = clear_symtab_users_queued;
1532 clear_symtab_users ();
1536 /* Delete the specified psymtab, and any others that reference it. */
1539 cashier_psymtab (pst)
1540 struct partial_symtab *pst;
1542 struct partial_symtab *ps, *pprev = NULL;
1545 /* Find its previous psymtab in the chain */
1546 for (ps = pst->objfile->psymtabs; ps; ps = ps->next) {
1553 /* Unhook it from the chain. */
1554 if (ps == pst->objfile->psymtabs)
1555 pst->objfile->psymtabs = ps->next;
1557 pprev->next = ps->next;
1559 /* FIXME, we can't conveniently deallocate the entries in the
1560 partial_symbol lists (global_psymbols/static_psymbols) that
1561 this psymtab points to. These just take up space until all
1562 the psymtabs are reclaimed. Ditto the dependencies list and
1563 filename, which are all in the psymbol_obstack. */
1565 /* We need to cashier any psymtab that has this one as a dependency... */
1567 for (ps = pst->objfile->psymtabs; ps; ps = ps->next) {
1568 for (i = 0; i < ps->number_of_dependencies; i++) {
1569 if (ps->dependencies[i] == pst) {
1570 cashier_psymtab (ps);
1571 goto again; /* Must restart, chain has been munged. */
1578 /* If a symtab or psymtab for filename NAME is found, free it along
1579 with any dependent breakpoints, displays, etc.
1580 Used when loading new versions of object modules with the "add-file"
1581 command. This is only called on the top-level symtab or psymtab's name;
1582 it is not called for subsidiary files such as .h files.
1584 Return value is 1 if we blew away the environment, 0 if not.
1585 FIXME. The return valu appears to never be used.
1587 FIXME. I think this is not the best way to do this. We should
1588 work on being gentler to the environment while still cleaning up
1589 all stray pointers into the freed symtab. */
1592 free_named_symtabs (name)
1596 /* FIXME: With the new method of each objfile having it's own
1597 psymtab list, this function needs serious rethinking. In particular,
1598 why was it ever necessary to toss psymtabs with specific compilation
1599 unit filenames, as opposed to all psymtabs from a particular symbol
1601 Well, the answer is that some systems permit reloading of particular
1602 compilation units. We want to blow away any old info about these
1603 compilation units, regardless of which objfiles they arrived in. --gnu. */
1605 register struct symtab *s;
1606 register struct symtab *prev;
1607 register struct partial_symtab *ps;
1608 struct blockvector *bv;
1611 /* We only wack things if the symbol-reload switch is set. */
1612 if (!symbol_reloading)
1615 /* Some symbol formats have trouble providing file names... */
1616 if (name == 0 || *name == '\0')
1619 /* Look for a psymtab with the specified name. */
1622 for (ps = partial_symtab_list; ps; ps = ps->next) {
1623 if (STREQ (name, ps->filename)) {
1624 cashier_psymtab (ps); /* Blow it away...and its little dog, too. */
1625 goto again2; /* Must restart, chain has been munged */
1629 /* Look for a symtab with the specified name. */
1631 for (s = symtab_list; s; s = s->next)
1633 if (STREQ (name, s->filename))
1640 if (s == symtab_list)
1641 symtab_list = s->next;
1643 prev->next = s->next;
1645 /* For now, queue a delete for all breakpoints, displays, etc., whether
1646 or not they depend on the symtab being freed. This should be
1647 changed so that only those data structures affected are deleted. */
1649 /* But don't delete anything if the symtab is empty.
1650 This test is necessary due to a bug in "dbxread.c" that
1651 causes empty symtabs to be created for N_SO symbols that
1652 contain the pathname of the object file. (This problem
1653 has been fixed in GDB 3.9x). */
1655 bv = BLOCKVECTOR (s);
1656 if (BLOCKVECTOR_NBLOCKS (bv) > 2
1657 || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
1658 || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)))
1660 complain (&oldsyms_complaint, name);
1662 clear_symtab_users_queued++;
1663 make_cleanup (clear_symtab_users_once, 0);
1666 complain (&empty_symtab_complaint, name);
1673 /* It is still possible that some breakpoints will be affected
1674 even though no symtab was found, since the file might have
1675 been compiled without debugging, and hence not be associated
1676 with a symtab. In order to handle this correctly, we would need
1677 to keep a list of text address ranges for undebuggable files.
1678 For now, we do nothing, since this is a fairly obscure case. */
1682 /* FIXME, what about the minimal symbol table? */
1689 /* Allocate and partially fill a partial symtab. It will be
1690 completely filled at the end of the symbol list.
1692 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
1693 is the address relative to which its symbols are (incremental) or 0
1697 struct partial_symtab *
1698 start_psymtab_common (objfile, section_offsets,
1699 filename, textlow, global_syms, static_syms)
1700 struct objfile *objfile;
1701 struct section_offsets *section_offsets;
1704 struct partial_symbol **global_syms;
1705 struct partial_symbol **static_syms;
1707 struct partial_symtab *psymtab;
1709 psymtab = allocate_psymtab (filename, objfile);
1710 psymtab -> section_offsets = section_offsets;
1711 psymtab -> textlow = textlow;
1712 psymtab -> texthigh = psymtab -> textlow; /* default */
1713 psymtab -> globals_offset = global_syms - objfile -> global_psymbols.list;
1714 psymtab -> statics_offset = static_syms - objfile -> static_psymbols.list;
1718 /* Add a symbol with a long value to a psymtab.
1719 Since one arg is a struct, we pass in a ptr and deref it (sigh). */
1722 add_psymbol_to_list (name, namelength, namespace, class, list, val, coreaddr,
1726 namespace_enum namespace;
1727 enum address_class class;
1728 struct psymbol_allocation_list *list;
1729 long val; /* Value as a long */
1730 CORE_ADDR coreaddr; /* Value as a CORE_ADDR */
1731 enum language language;
1732 struct objfile *objfile;
1734 register struct partial_symbol *psym;
1735 char *buf = alloca (namelength + 1);
1736 /* psymbol is static so that there will be no uninitialized gaps in the
1737 structure which might contain random data, causing cache misses in
1739 static struct partial_symbol psymbol;
1741 /* Create local copy of the partial symbol */
1742 memcpy (buf, name, namelength);
1743 buf[namelength] = '\0';
1744 SYMBOL_NAME (&psymbol) = bcache (buf, namelength + 1, &objfile->psymbol_cache);
1745 /* val and coreaddr are mutually exclusive, one of them *will* be zero */
1748 SYMBOL_VALUE (&psymbol) = val;
1752 SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
1754 SYMBOL_SECTION (&psymbol) = 0;
1755 SYMBOL_LANGUAGE (&psymbol) = language;
1756 PSYMBOL_NAMESPACE (&psymbol) = namespace;
1757 PSYMBOL_CLASS (&psymbol) = class;
1758 SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol, language);
1760 /* Stash the partial symbol away in the cache */
1761 psym = bcache (&psymbol, sizeof (struct partial_symbol), &objfile->psymbol_cache);
1763 /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
1764 if (list->next >= list->list + list->size)
1766 extend_psymbol_list (list, objfile);
1768 *list->next++ = psym;
1769 OBJSTAT (objfile, n_psyms++);
1772 /* Initialize storage for partial symbols. */
1775 init_psymbol_list (objfile, total_symbols)
1776 struct objfile *objfile;
1779 /* Free any previously allocated psymbol lists. */
1781 if (objfile -> global_psymbols.list)
1783 mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
1785 if (objfile -> static_psymbols.list)
1787 mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
1790 /* Current best guess is that approximately a twentieth
1791 of the total symbols (in a debugging file) are global or static
1794 objfile -> global_psymbols.size = total_symbols / 10;
1795 objfile -> static_psymbols.size = total_symbols / 10;
1796 objfile -> global_psymbols.next =
1797 objfile -> global_psymbols.list = (struct partial_symbol **)
1798 xmmalloc (objfile -> md, objfile -> global_psymbols.size
1799 * sizeof (struct partial_symbol *));
1800 objfile -> static_psymbols.next =
1801 objfile -> static_psymbols.list = (struct partial_symbol **)
1802 xmmalloc (objfile -> md, objfile -> static_psymbols.size
1803 * sizeof (struct partial_symbol *));
1807 The following code implements an abstraction for debugging overlay sections.
1809 The target model is as follows:
1810 1) The gnu linker will permit multiple sections to be mapped into the
1811 same VMA, each with its own unique LMA (or load address).
1812 2) It is assumed that some runtime mechanism exists for mapping the
1813 sections, one by one, from the load address into the VMA address.
1814 3) This code provides a mechanism for gdb to keep track of which
1815 sections should be considered to be mapped from the VMA to the LMA.
1816 This information is used for symbol lookup, and memory read/write.
1817 For instance, if a section has been mapped then its contents
1818 should be read from the VMA, otherwise from the LMA.
1820 Two levels of debugger support for overlays are available. One is
1821 "manual", in which the debugger relies on the user to tell it which
1822 overlays are currently mapped. This level of support is
1823 implemented entirely in the core debugger, and the information about
1824 whether a section is mapped is kept in the objfile->obj_section table.
1826 The second level of support is "automatic", and is only available if
1827 the target-specific code provides functionality to read the target's
1828 overlay mapping table, and translate its contents for the debugger
1829 (by updating the mapped state information in the obj_section tables).
1831 The interface is as follows:
1833 overlay map <name> -- tell gdb to consider this section mapped
1834 overlay unmap <name> -- tell gdb to consider this section unmapped
1835 overlay list -- list the sections that GDB thinks are mapped
1836 overlay read-target -- get the target's state of what's mapped
1837 overlay off/manual/auto -- set overlay debugging state
1838 Functional interface:
1839 find_pc_mapped_section(pc): if the pc is in the range of a mapped
1840 section, return that section.
1841 find_pc_overlay(pc): find any overlay section that contains
1842 the pc, either in its VMA or its LMA
1843 overlay_is_mapped(sect): true if overlay is marked as mapped
1844 section_is_overlay(sect): true if section's VMA != LMA
1845 pc_in_mapped_range(pc,sec): true if pc belongs to section's VMA
1846 pc_in_unmapped_range(...): true if pc belongs to section's LMA
1847 overlay_mapped_address(...): map an address from section's LMA to VMA
1848 overlay_unmapped_address(...): map an address from section's VMA to LMA
1849 symbol_overlayed_address(...): Return a "current" address for symbol:
1850 either in VMA or LMA depending on whether
1851 the symbol's section is currently mapped
1854 /* Overlay debugging state: */
1856 int overlay_debugging = 0; /* 0 == off, 1 == manual, -1 == auto */
1857 int overlay_cache_invalid = 0; /* True if need to refresh mapped state */
1859 /* Target vector for refreshing overlay mapped state */
1860 static void simple_overlay_update PARAMS ((struct obj_section *));
1861 void (*target_overlay_update) PARAMS ((struct obj_section *))
1862 = simple_overlay_update;
1864 /* Function: section_is_overlay (SECTION)
1865 Returns true if SECTION has VMA not equal to LMA, ie.
1866 SECTION is loaded at an address different from where it will "run". */
1869 section_is_overlay (section)
1872 if (overlay_debugging)
1873 if (section && section->lma != 0 &&
1874 section->vma != section->lma)
1880 /* Function: overlay_invalidate_all (void)
1881 Invalidate the mapped state of all overlay sections (mark it as stale). */
1884 overlay_invalidate_all ()
1886 struct objfile *objfile;
1887 struct obj_section *sect;
1889 ALL_OBJSECTIONS (objfile, sect)
1890 if (section_is_overlay (sect->the_bfd_section))
1891 sect->ovly_mapped = -1;
1894 /* Function: overlay_is_mapped (SECTION)
1895 Returns true if section is an overlay, and is currently mapped.
1896 Private: public access is thru function section_is_mapped.
1898 Access to the ovly_mapped flag is restricted to this function, so
1899 that we can do automatic update. If the global flag
1900 OVERLAY_CACHE_INVALID is set (by wait_for_inferior), then call
1901 overlay_invalidate_all. If the mapped state of the particular
1902 section is stale, then call TARGET_OVERLAY_UPDATE to refresh it. */
1905 overlay_is_mapped (osect)
1906 struct obj_section *osect;
1908 if (osect == 0 || !section_is_overlay (osect->the_bfd_section))
1911 switch (overlay_debugging)
1914 case 0: return 0; /* overlay debugging off */
1915 case -1: /* overlay debugging automatic */
1916 /* Unles there is a target_overlay_update function,
1917 there's really nothing useful to do here (can't really go auto) */
1918 if (target_overlay_update)
1920 if (overlay_cache_invalid)
1922 overlay_invalidate_all ();
1923 overlay_cache_invalid = 0;
1925 if (osect->ovly_mapped == -1)
1926 (*target_overlay_update) (osect);
1928 /* fall thru to manual case */
1929 case 1: /* overlay debugging manual */
1930 return osect->ovly_mapped == 1;
1934 /* Function: section_is_mapped
1935 Returns true if section is an overlay, and is currently mapped. */
1938 section_is_mapped (section)
1941 struct objfile *objfile;
1942 struct obj_section *osect;
1944 if (overlay_debugging)
1945 if (section && section_is_overlay (section))
1946 ALL_OBJSECTIONS (objfile, osect)
1947 if (osect->the_bfd_section == section)
1948 return overlay_is_mapped (osect);
1953 /* Function: pc_in_unmapped_range
1954 If PC falls into the lma range of SECTION, return true, else false. */
1957 pc_in_unmapped_range (pc, section)
1963 if (overlay_debugging)
1964 if (section && section_is_overlay (section))
1966 size = bfd_get_section_size_before_reloc (section);
1967 if (section->lma <= pc && pc < section->lma + size)
1973 /* Function: pc_in_mapped_range
1974 If PC falls into the vma range of SECTION, return true, else false. */
1977 pc_in_mapped_range (pc, section)
1983 if (overlay_debugging)
1984 if (section && section_is_overlay (section))
1986 size = bfd_get_section_size_before_reloc (section);
1987 if (section->vma <= pc && pc < section->vma + size)
1993 /* Function: overlay_unmapped_address (PC, SECTION)
1994 Returns the address corresponding to PC in the unmapped (load) range.
1995 May be the same as PC. */
1998 overlay_unmapped_address (pc, section)
2002 if (overlay_debugging)
2003 if (section && section_is_overlay (section) &&
2004 pc_in_mapped_range (pc, section))
2005 return pc + section->lma - section->vma;
2010 /* Function: overlay_mapped_address (PC, SECTION)
2011 Returns the address corresponding to PC in the mapped (runtime) range.
2012 May be the same as PC. */
2015 overlay_mapped_address (pc, section)
2019 if (overlay_debugging)
2020 if (section && section_is_overlay (section) &&
2021 pc_in_unmapped_range (pc, section))
2022 return pc + section->vma - section->lma;
2028 /* Function: symbol_overlayed_address
2029 Return one of two addresses (relative to the VMA or to the LMA),
2030 depending on whether the section is mapped or not. */
2033 symbol_overlayed_address (address, section)
2037 if (overlay_debugging)
2039 /* If the symbol has no section, just return its regular address. */
2042 /* If the symbol's section is not an overlay, just return its address */
2043 if (!section_is_overlay (section))
2045 /* If the symbol's section is mapped, just return its address */
2046 if (section_is_mapped (section))
2049 * HOWEVER: if the symbol is in an overlay section which is NOT mapped,
2050 * then return its LOADED address rather than its vma address!!
2052 return overlay_unmapped_address (address, section);
2057 /* Function: find_pc_overlay (PC)
2058 Return the best-match overlay section for PC:
2059 If PC matches a mapped overlay section's VMA, return that section.
2060 Else if PC matches an unmapped section's VMA, return that section.
2061 Else if PC matches an unmapped section's LMA, return that section. */
2064 find_pc_overlay (pc)
2067 struct objfile *objfile;
2068 struct obj_section *osect, *best_match = NULL;
2070 if (overlay_debugging)
2071 ALL_OBJSECTIONS (objfile, osect)
2072 if (section_is_overlay (osect->the_bfd_section))
2074 if (pc_in_mapped_range (pc, osect->the_bfd_section))
2076 if (overlay_is_mapped (osect))
2077 return osect->the_bfd_section;
2081 else if (pc_in_unmapped_range (pc, osect->the_bfd_section))
2084 return best_match ? best_match->the_bfd_section : NULL;
2087 /* Function: find_pc_mapped_section (PC)
2088 If PC falls into the VMA address range of an overlay section that is
2089 currently marked as MAPPED, return that section. Else return NULL. */
2092 find_pc_mapped_section (pc)
2095 struct objfile *objfile;
2096 struct obj_section *osect;
2098 if (overlay_debugging)
2099 ALL_OBJSECTIONS (objfile, osect)
2100 if (pc_in_mapped_range (pc, osect->the_bfd_section) &&
2101 overlay_is_mapped (osect))
2102 return osect->the_bfd_section;
2107 /* Function: list_overlays_command
2108 Print a list of mapped sections and their PC ranges */
2111 list_overlays_command (args, from_tty)
2116 struct objfile *objfile;
2117 struct obj_section *osect;
2119 if (overlay_debugging)
2120 ALL_OBJSECTIONS (objfile, osect)
2121 if (overlay_is_mapped (osect))
2127 vma = bfd_section_vma (objfile->obfd, osect->the_bfd_section);
2128 lma = bfd_section_lma (objfile->obfd, osect->the_bfd_section);
2129 size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
2130 name = bfd_section_name (objfile->obfd, osect->the_bfd_section);
2131 printf_filtered ("Section %s, loaded at %08x - %08x, ",
2132 name, lma, lma + size);
2133 printf_filtered ("mapped at %08x - %08x\n",
2138 printf_filtered ("No sections are mapped.\n");
2141 /* Function: map_overlay_command
2142 Mark the named section as mapped (ie. residing at its VMA address). */
2145 map_overlay_command (args, from_tty)
2149 struct objfile *objfile, *objfile2;
2150 struct obj_section *sec, *sec2;
2153 if (!overlay_debugging)
2154 error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
2156 if (args == 0 || *args == 0)
2157 error ("Argument required: name of an overlay section");
2159 /* First, find a section matching the user supplied argument */
2160 ALL_OBJSECTIONS (objfile, sec)
2161 if (!strcmp (bfd_section_name (objfile->obfd, sec->the_bfd_section), args))
2163 /* Now, check to see if the section is an overlay. */
2164 bfdsec = sec->the_bfd_section;
2165 if (!section_is_overlay (bfdsec))
2166 continue; /* not an overlay section */
2168 /* Mark the overlay as "mapped" */
2169 sec->ovly_mapped = 1;
2171 /* Next, make a pass and unmap any sections that are
2172 overlapped by this new section: */
2173 ALL_OBJSECTIONS (objfile2, sec2)
2174 if (sec2->ovly_mapped &&
2176 sec->the_bfd_section != sec2->the_bfd_section &&
2177 (pc_in_mapped_range (sec2->addr, sec->the_bfd_section) ||
2178 pc_in_mapped_range (sec2->endaddr, sec->the_bfd_section)))
2181 printf_filtered ("Note: section %s unmapped by overlap\n",
2182 bfd_section_name (objfile->obfd,
2183 sec2->the_bfd_section));
2184 sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2 */
2188 error ("No overlay section called %s", args);
2191 /* Function: unmap_overlay_command
2192 Mark the overlay section as unmapped
2193 (ie. resident in its LMA address range, rather than the VMA range). */
2196 unmap_overlay_command (args, from_tty)
2200 struct objfile *objfile;
2201 struct obj_section *sec;
2203 if (!overlay_debugging)
2204 error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
2206 if (args == 0 || *args == 0)
2207 error ("Argument required: name of an overlay section");
2209 /* First, find a section matching the user supplied argument */
2210 ALL_OBJSECTIONS (objfile, sec)
2211 if (!strcmp (bfd_section_name (objfile->obfd, sec->the_bfd_section), args))
2213 if (!sec->ovly_mapped)
2214 error ("Section %s is not mapped", args);
2215 sec->ovly_mapped = 0;
2218 error ("No overlay section called %s", args);
2221 /* Function: overlay_auto_command
2222 A utility command to turn on overlay debugging.
2223 Possibly this should be done via a set/show command. */
2226 overlay_auto_command (args, from_tty)
2228 overlay_debugging = -1;
2230 printf_filtered ("Automatic overlay debugging enabled.");
2233 /* Function: overlay_manual_command
2234 A utility command to turn on overlay debugging.
2235 Possibly this should be done via a set/show command. */
2238 overlay_manual_command (args, from_tty)
2240 overlay_debugging = 1;
2242 printf_filtered ("Overlay debugging enabled.");
2245 /* Function: overlay_off_command
2246 A utility command to turn on overlay debugging.
2247 Possibly this should be done via a set/show command. */
2250 overlay_off_command (args, from_tty)
2252 overlay_debugging = 0;
2254 printf_filtered ("Overlay debugging disabled.");
2258 overlay_load_command (args, from_tty)
2260 if (target_overlay_update)
2261 (*target_overlay_update) (NULL);
2263 error ("This target does not know how to read its overlay state.");
2266 /* Function: overlay_command
2267 A place-holder for a mis-typed command */
2269 /* Command list chain containing all defined "overlay" subcommands. */
2270 struct cmd_list_element *overlaylist;
2273 overlay_command (args, from_tty)
2278 ("\"overlay\" must be followed by the name of an overlay command.\n");
2279 help_list (overlaylist, "overlay ", -1, gdb_stdout);
2283 /* Target Overlays for the "Simplest" overlay manager:
2285 This is GDB's default target overlay layer. It works with the
2286 minimal overlay manager supplied as an example by Cygnus. The
2287 entry point is via a function pointer "target_overlay_update",
2288 so targets that use a different runtime overlay manager can
2289 substitute their own overlay_update function and take over the
2292 The overlay_update function pokes around in the target's data structures
2293 to see what overlays are mapped, and updates GDB's overlay mapping with
2296 In this simple implementation, the target data structures are as follows:
2297 unsigned _novlys; /# number of overlay sections #/
2298 unsigned _ovly_table[_novlys][4] = {
2299 {VMA, SIZE, LMA, MAPPED}, /# one entry per overlay section #/
2300 {..., ..., ..., ...},
2302 unsigned _novly_regions; /# number of overlay regions #/
2303 unsigned _ovly_region_table[_novly_regions][3] = {
2304 {VMA, SIZE, MAPPED_TO_LMA}, /# one entry per overlay region #/
2307 These functions will attempt to update GDB's mappedness state in the
2308 symbol section table, based on the target's mappedness state.
2310 To do this, we keep a cached copy of the target's _ovly_table, and
2311 attempt to detect when the cached copy is invalidated. The main
2312 entry point is "simple_overlay_update(SECT), which looks up SECT in
2313 the cached table and re-reads only the entry for that section from
2314 the target (whenever possible).
2317 /* Cached, dynamically allocated copies of the target data structures: */
2318 static unsigned (*cache_ovly_table)[4] = 0;
2320 static unsigned (*cache_ovly_region_table)[3] = 0;
2322 static unsigned cache_novlys = 0;
2324 static unsigned cache_novly_regions = 0;
2326 static CORE_ADDR cache_ovly_table_base = 0;
2328 static CORE_ADDR cache_ovly_region_table_base = 0;
2330 enum ovly_index { VMA, SIZE, LMA, MAPPED};
2331 #define TARGET_INT_BYTES (TARGET_INT_BIT / TARGET_CHAR_BIT)
2333 /* Throw away the cached copy of _ovly_table */
2335 simple_free_overlay_table ()
2337 if (cache_ovly_table)
2338 free(cache_ovly_table);
2340 cache_ovly_table = NULL;
2341 cache_ovly_table_base = 0;
2345 /* Throw away the cached copy of _ovly_region_table */
2347 simple_free_overlay_region_table ()
2349 if (cache_ovly_region_table)
2350 free(cache_ovly_region_table);
2351 cache_novly_regions = 0;
2352 cache_ovly_region_table = NULL;
2353 cache_ovly_region_table_base = 0;
2357 /* Read an array of ints from the target into a local buffer.
2358 Convert to host order. int LEN is number of ints */
2360 read_target_int_array (memaddr, myaddr, len)
2362 unsigned int *myaddr;
2365 char *buf = alloca (len * TARGET_INT_BYTES);
2368 read_memory (memaddr, buf, len * TARGET_INT_BYTES);
2369 for (i = 0; i < len; i++)
2370 myaddr[i] = extract_unsigned_integer (TARGET_INT_BYTES * i + buf,
2374 /* Find and grab a copy of the target _ovly_table
2375 (and _novlys, which is needed for the table's size) */
2377 simple_read_overlay_table ()
2379 struct minimal_symbol *msym;
2381 simple_free_overlay_table ();
2382 msym = lookup_minimal_symbol ("_novlys", 0, 0);
2384 cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
2386 return 0; /* failure */
2387 cache_ovly_table = (void *) xmalloc (cache_novlys * sizeof(*cache_ovly_table));
2388 if (cache_ovly_table != NULL)
2390 msym = lookup_minimal_symbol ("_ovly_table", 0, 0);
2393 cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (msym);
2394 read_target_int_array (cache_ovly_table_base,
2395 (int *) cache_ovly_table,
2399 return 0; /* failure */
2402 return 0; /* failure */
2403 return 1; /* SUCCESS */
2407 /* Find and grab a copy of the target _ovly_region_table
2408 (and _novly_regions, which is needed for the table's size) */
2410 simple_read_overlay_region_table ()
2412 struct minimal_symbol *msym;
2414 simple_free_overlay_region_table ();
2415 msym = lookup_minimal_symbol ("_novly_regions", 0, 0);
2417 cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
2419 return 0; /* failure */
2420 cache_ovly_region_table = (void *) xmalloc (cache_novly_regions * 12);
2421 if (cache_ovly_region_table != NULL)
2423 msym = lookup_minimal_symbol ("_ovly_region_table", 0, 0);
2426 cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
2427 read_target_int_array (cache_ovly_region_table_base,
2428 (int *) cache_ovly_region_table,
2429 cache_novly_regions * 3);
2432 return 0; /* failure */
2435 return 0; /* failure */
2436 return 1; /* SUCCESS */
2440 /* Function: simple_overlay_update_1
2441 A helper function for simple_overlay_update. Assuming a cached copy
2442 of _ovly_table exists, look through it to find an entry whose vma,
2443 lma and size match those of OSECT. Re-read the entry and make sure
2444 it still matches OSECT (else the table may no longer be valid).
2445 Set OSECT's mapped state to match the entry. Return: 1 for
2446 success, 0 for failure. */
2449 simple_overlay_update_1 (osect)
2450 struct obj_section *osect;
2454 size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
2455 for (i = 0; i < cache_novlys; i++)
2456 if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
2457 cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
2458 cache_ovly_table[i][SIZE] == size)
2460 read_target_int_array (cache_ovly_table_base + i * TARGET_INT_BYTES,
2461 (int *) &cache_ovly_table[i], 4);
2462 if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
2463 cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
2464 cache_ovly_table[i][SIZE] == size)
2466 osect->ovly_mapped = cache_ovly_table[i][MAPPED];
2469 else /* Warning! Warning! Target's ovly table has changed! */
2475 /* Function: simple_overlay_update
2476 If OSECT is NULL, then update all sections' mapped state
2477 (after re-reading the entire target _ovly_table).
2478 If OSECT is non-NULL, then try to find a matching entry in the
2479 cached ovly_table and update only OSECT's mapped state.
2480 If a cached entry can't be found or the cache isn't valid, then
2481 re-read the entire cache, and go ahead and update all sections. */
2484 simple_overlay_update (osect)
2485 struct obj_section *osect;
2487 struct objfile *objfile;
2489 /* Were we given an osect to look up? NULL means do all of them. */
2491 /* Have we got a cached copy of the target's overlay table? */
2492 if (cache_ovly_table != NULL)
2493 /* Does its cached location match what's currently in the symtab? */
2494 if (cache_ovly_table_base ==
2495 SYMBOL_VALUE_ADDRESS (lookup_minimal_symbol ("_ovly_table", 0, 0)))
2496 /* Then go ahead and try to look up this single section in the cache */
2497 if (simple_overlay_update_1 (osect))
2498 /* Found it! We're done. */
2501 /* Cached table no good: need to read the entire table anew.
2502 Or else we want all the sections, in which case it's actually
2503 more efficient to read the whole table in one block anyway. */
2505 if (simple_read_overlay_table () == 0) /* read failed? No table? */
2507 warning ("Failed to read the target overlay mapping table.");
2510 /* Now may as well update all sections, even if only one was requested. */
2511 ALL_OBJSECTIONS (objfile, osect)
2512 if (section_is_overlay (osect->the_bfd_section))
2516 size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
2517 for (i = 0; i < cache_novlys; i++)
2518 if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
2519 cache_ovly_table[i][LMA] == osect->the_bfd_section->lma &&
2520 cache_ovly_table[i][SIZE] == size)
2521 { /* obj_section matches i'th entry in ovly_table */
2522 osect->ovly_mapped = cache_ovly_table[i][MAPPED];
2523 break; /* finished with inner for loop: break out */
2530 _initialize_symfile ()
2532 struct cmd_list_element *c;
2534 c = add_cmd ("symbol-file", class_files, symbol_file_command,
2535 "Load symbol table from executable file FILE.\n\
2536 The `file' command can also load symbol tables, as well as setting the file\n\
2537 to execute.", &cmdlist);
2538 c->completer = filename_completer;
2540 c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command,
2541 "Usage: add-symbol-file FILE ADDR\n\
2542 Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
2543 ADDR is the starting address of the file's text.",
2545 c->completer = filename_completer;
2547 c = add_cmd ("add-shared-symbol-files", class_files,
2548 add_shared_symbol_files_command,
2549 "Load the symbols from shared objects in the dynamic linker's link map.",
2551 c = add_alias_cmd ("assf", "add-shared-symbol-files", class_files, 1,
2554 c = add_cmd ("load", class_files, load_command,
2555 "Dynamically load FILE into the running program, and record its symbols\n\
2556 for access from GDB.", &cmdlist);
2557 c->completer = filename_completer;
2560 (add_set_cmd ("symbol-reloading", class_support, var_boolean,
2561 (char *)&symbol_reloading,
2562 "Set dynamic symbol table reloading multiple times in one run.",
2566 add_prefix_cmd ("overlay", class_support, overlay_command,
2567 "Commands for debugging overlays.", &overlaylist,
2568 "overlay ", 0, &cmdlist);
2570 add_com_alias ("ovly", "overlay", class_alias, 1);
2571 add_com_alias ("ov", "overlay", class_alias, 1);
2573 add_cmd ("map-overlay", class_support, map_overlay_command,
2574 "Assert that an overlay section is mapped.", &overlaylist);
2576 add_cmd ("unmap-overlay", class_support, unmap_overlay_command,
2577 "Assert that an overlay section is unmapped.", &overlaylist);
2579 add_cmd ("list-overlays", class_support, list_overlays_command,
2580 "List mappings of overlay sections.", &overlaylist);
2582 add_cmd ("manual", class_support, overlay_manual_command,
2583 "Enable overlay debugging.", &overlaylist);
2584 add_cmd ("off", class_support, overlay_off_command,
2585 "Disable overlay debugging.", &overlaylist);
2586 add_cmd ("auto", class_support, overlay_auto_command,
2587 "Enable automatic overlay debugging.", &overlaylist);
2588 add_cmd ("load-target", class_support, overlay_load_command,
2589 "Read the overlay mapping state from the target.", &overlaylist);