1 /* Generic symbol file reading for the GNU debugger, GDB.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998
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,
21 Boston, MA 02111-1307, USA. */
33 #include "breakpoint.h"
35 #include "complaints.h"
37 #include "inferior.h" /* for write_pc */
38 #include "gdb-stabs.h"
42 #include <sys/types.h>
44 #include "gdb_string.h"
55 /* Some HP-UX related globals to clear when a new "main"
56 symbol file is loaded. HP-specific. */
58 extern int hp_som_som_object_present
;
59 extern int hp_cxx_exception_support_initialized
;
60 #define RESET_HP_UX_GLOBALS() do {\
61 hp_som_som_object_present = 0; /* indicates HP-compiled code */ \
62 hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \
66 int (*ui_load_progress_hook
) (const char *section
, unsigned long num
);
67 void (*pre_add_symbol_hook
) PARAMS ((char *));
68 void (*post_add_symbol_hook
) PARAMS ((void));
69 void (*target_new_objfile_hook
) PARAMS ((struct objfile
*));
71 /* Global variables owned by this file */
72 int readnow_symbol_files
; /* Read full symbols immediately */
74 struct complaint oldsyms_complaint
=
76 "Replacing old symbols for `%s'", 0, 0
79 struct complaint empty_symtab_complaint
=
81 "Empty symbol table found for `%s'", 0, 0
84 struct complaint unknown_option_complaint
=
86 "Unknown option `%s' ignored", 0, 0
89 /* External variables and functions referenced. */
91 extern int info_verbose
;
93 extern void report_transfer_performance
PARAMS ((unsigned long,
96 /* Functions this file defines */
99 static int simple_read_overlay_region_table
PARAMS ((void));
100 static void simple_free_overlay_region_table
PARAMS ((void));
103 static void set_initial_language
PARAMS ((void));
105 static void load_command
PARAMS ((char *, int));
107 static void add_symbol_file_command
PARAMS ((char *, int));
109 static void add_shared_symbol_files_command
PARAMS ((char *, int));
111 static void cashier_psymtab
PARAMS ((struct partial_symtab
*));
113 static int compare_psymbols
PARAMS ((const void *, const void *));
115 static int compare_symbols
PARAMS ((const void *, const void *));
117 bfd
*symfile_bfd_open
PARAMS ((char *));
119 static void find_sym_fns
PARAMS ((struct objfile
*));
121 static void decrement_reading_symtab
PARAMS ((void *));
123 static void overlay_invalidate_all
PARAMS ((void));
125 static int overlay_is_mapped
PARAMS ((struct obj_section
*));
127 void list_overlays_command
PARAMS ((char *, int));
129 void map_overlay_command
PARAMS ((char *, int));
131 void unmap_overlay_command
PARAMS ((char *, int));
133 static void overlay_auto_command
PARAMS ((char *, int));
135 static void overlay_manual_command
PARAMS ((char *, int));
137 static void overlay_off_command
PARAMS ((char *, int));
139 static void overlay_load_command
PARAMS ((char *, int));
141 static void overlay_command
PARAMS ((char *, int));
143 static void simple_free_overlay_table
PARAMS ((void));
145 static void read_target_long_array
PARAMS ((CORE_ADDR
, unsigned int *, int));
147 static int simple_read_overlay_table
PARAMS ((void));
149 static int simple_overlay_update_1
PARAMS ((struct obj_section
*));
151 static void add_filename_language
PARAMS ((char *ext
, enum language lang
));
153 static void set_ext_lang_command
PARAMS ((char *args
, int from_tty
));
155 static void info_ext_lang_command
PARAMS ((char *args
, int from_tty
));
157 static void init_filename_language_table
PARAMS ((void));
159 void _initialize_symfile
PARAMS ((void));
161 /* List of all available sym_fns. On gdb startup, each object file reader
162 calls add_symtab_fns() to register information on each format it is
165 static struct sym_fns
*symtab_fns
= NULL
;
167 /* Flag for whether user will be reloading symbols multiple times.
168 Defaults to ON for VxWorks, otherwise OFF. */
170 #ifdef SYMBOL_RELOADING_DEFAULT
171 int symbol_reloading
= SYMBOL_RELOADING_DEFAULT
;
173 int symbol_reloading
= 0;
176 /* If non-zero, then on HP-UX (i.e., platforms that use somsolib.c),
177 this variable is interpreted as a threshhold. If adding a new
178 library's symbol table to those already known to the debugger would
179 exceed this threshhold, then the shlib's symbols are not added.
181 If non-zero on other platforms, shared library symbols will be added
182 automatically when the inferior is created, new libraries are loaded,
183 or when attaching to the inferior. This is almost always what users
184 will want to have happen; but for very large programs, the startup
185 time will be excessive, and so if this is a problem, the user can
186 clear this flag and then add the shared library symbols as needed.
187 Note that there is a potential for confusion, since if the shared
188 library symbols are not loaded, commands like "info fun" will *not*
189 report all the functions that are actually present.
191 Note that HP-UX interprets this variable to mean, "threshhold size
192 in megabytes, where zero means never add". Other platforms interpret
193 this variable to mean, "always add if non-zero, never add if zero."
196 int auto_solib_add
= 1;
199 /* Since this function is called from within qsort, in an ANSI environment
200 it must conform to the prototype for qsort, which specifies that the
201 comparison function takes two "void *" pointers. */
204 compare_symbols (s1p
, s2p
)
208 register struct symbol
**s1
, **s2
;
210 s1
= (struct symbol
**) s1p
;
211 s2
= (struct symbol
**) s2p
;
213 return (STRCMP (SYMBOL_NAME (*s1
), SYMBOL_NAME (*s2
)));
220 compare_psymbols -- compare two partial symbols by name
224 Given pointers to pointers to two partial symbol table entries,
225 compare them by name and return -N, 0, or +N (ala strcmp).
226 Typically used by sorting routines like qsort().
230 Does direct compare of first two characters before punting
231 and passing to strcmp for longer compares. Note that the
232 original version had a bug whereby two null strings or two
233 identically named one character strings would return the
234 comparison of memory following the null byte.
239 compare_psymbols (s1p
, s2p
)
243 register char *st1
= SYMBOL_NAME (*(struct partial_symbol
**) s1p
);
244 register char *st2
= SYMBOL_NAME (*(struct partial_symbol
**) s2p
);
246 if ((st1
[0] - st2
[0]) || !st1
[0])
248 return (st1
[0] - st2
[0]);
250 else if ((st1
[1] - st2
[1]) || !st1
[1])
252 return (st1
[1] - st2
[1]);
256 /* Note: I replaced the STRCMP line (commented out below)
257 * with a simpler "strcmp()" which compares the 2 strings
258 * from the beginning. (STRCMP is a macro which first compares
259 * the initial characters, then falls back on strcmp).
260 * The reason is that the STRCMP line was tickling a C compiler
261 * bug on HP-UX 10.30, which is avoided with the simpler
262 * code. The performance gain from the more complicated code
263 * is negligible, given that we have already checked the
264 * initial 2 characters above. I reported the compiler bug,
265 * and once it is fixed the original line can be put back. RT
267 /* return ( STRCMP (st1 + 2, st2 + 2)); */
268 return (strcmp (st1
, st2
));
273 sort_pst_symbols (pst
)
274 struct partial_symtab
*pst
;
276 /* Sort the global list; don't sort the static list */
278 qsort (pst
->objfile
->global_psymbols
.list
+ pst
->globals_offset
,
279 pst
->n_global_syms
, sizeof (struct partial_symbol
*),
283 /* Call sort_block_syms to sort alphabetically the symbols of one block. */
287 register struct block
*b
;
289 qsort (&BLOCK_SYM (b
, 0), BLOCK_NSYMS (b
),
290 sizeof (struct symbol
*), compare_symbols
);
293 /* Call sort_symtab_syms to sort alphabetically
294 the symbols of each block of one symtab. */
298 register struct symtab
*s
;
300 register struct blockvector
*bv
;
303 register struct block
*b
;
307 bv
= BLOCKVECTOR (s
);
308 nbl
= BLOCKVECTOR_NBLOCKS (bv
);
309 for (i
= 0; i
< nbl
; i
++)
311 b
= BLOCKVECTOR_BLOCK (bv
, i
);
312 if (BLOCK_SHOULD_SORT (b
))
317 /* Make a null terminated copy of the string at PTR with SIZE characters in
318 the obstack pointed to by OBSTACKP . Returns the address of the copy.
319 Note that the string at PTR does not have to be null terminated, I.E. it
320 may be part of a larger string and we are only saving a substring. */
323 obsavestring (ptr
, size
, obstackp
)
326 struct obstack
*obstackp
;
328 register char *p
= (char *) obstack_alloc (obstackp
, size
+ 1);
329 /* Open-coded memcpy--saves function call time. These strings are usually
330 short. FIXME: Is this really still true with a compiler that can
333 register char *p1
= ptr
;
334 register char *p2
= p
;
335 char *end
= ptr
+ size
;
343 /* Concatenate strings S1, S2 and S3; return the new string. Space is found
344 in the obstack pointed to by OBSTACKP. */
347 obconcat (obstackp
, s1
, s2
, s3
)
348 struct obstack
*obstackp
;
349 const char *s1
, *s2
, *s3
;
351 register int len
= strlen (s1
) + strlen (s2
) + strlen (s3
) + 1;
352 register char *val
= (char *) obstack_alloc (obstackp
, len
);
359 /* True if we are nested inside psymtab_to_symtab. */
361 int currently_reading_symtab
= 0;
364 decrement_reading_symtab (dummy
)
367 currently_reading_symtab
--;
370 /* Get the symbol table that corresponds to a partial_symtab.
371 This is fast after the first time you do it. In fact, there
372 is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
376 psymtab_to_symtab (pst
)
377 register struct partial_symtab
*pst
;
379 /* If it's been looked up before, return it. */
383 /* If it has not yet been read in, read it. */
386 struct cleanup
*back_to
= make_cleanup (decrement_reading_symtab
, NULL
);
387 currently_reading_symtab
++;
388 (*pst
->read_symtab
) (pst
);
389 do_cleanups (back_to
);
395 /* Initialize entry point information for this objfile. */
398 init_entry_point_info (objfile
)
399 struct objfile
*objfile
;
401 /* Save startup file's range of PC addresses to help blockframe.c
402 decide where the bottom of the stack is. */
404 if (bfd_get_file_flags (objfile
->obfd
) & EXEC_P
)
406 /* Executable file -- record its entry point so we'll recognize
407 the startup file because it contains the entry point. */
408 objfile
->ei
.entry_point
= bfd_get_start_address (objfile
->obfd
);
412 /* Examination of non-executable.o files. Short-circuit this stuff. */
413 objfile
->ei
.entry_point
= INVALID_ENTRY_POINT
;
415 objfile
->ei
.entry_file_lowpc
= INVALID_ENTRY_LOWPC
;
416 objfile
->ei
.entry_file_highpc
= INVALID_ENTRY_HIGHPC
;
417 objfile
->ei
.entry_func_lowpc
= INVALID_ENTRY_LOWPC
;
418 objfile
->ei
.entry_func_highpc
= INVALID_ENTRY_HIGHPC
;
419 objfile
->ei
.main_func_lowpc
= INVALID_ENTRY_LOWPC
;
420 objfile
->ei
.main_func_highpc
= INVALID_ENTRY_HIGHPC
;
423 /* Get current entry point address. */
426 entry_point_address ()
428 return symfile_objfile
? symfile_objfile
->ei
.entry_point
: 0;
431 /* Remember the lowest-addressed loadable section we've seen.
432 This function is called via bfd_map_over_sections.
434 In case of equal vmas, the section with the largest size becomes the
435 lowest-addressed loadable section.
437 If the vmas and sizes are equal, the last section is considered the
438 lowest-addressed loadable section. */
441 find_lowest_section (abfd
, sect
, obj
)
446 asection
**lowest
= (asection
**) obj
;
448 if (0 == (bfd_get_section_flags (abfd
, sect
) & SEC_LOAD
))
451 *lowest
= sect
; /* First loadable section */
452 else if (bfd_section_vma (abfd
, *lowest
) > bfd_section_vma (abfd
, sect
))
453 *lowest
= sect
; /* A lower loadable section */
454 else if (bfd_section_vma (abfd
, *lowest
) == bfd_section_vma (abfd
, sect
)
455 && (bfd_section_size (abfd
, (*lowest
))
456 <= bfd_section_size (abfd
, sect
)))
460 /* Parse the user's idea of an offset for dynamic linking, into our idea
461 of how to represent it for fast symbol reading. This is the default
462 version of the sym_fns.sym_offsets function for symbol readers that
463 don't need to do anything special. It allocates a section_offsets table
464 for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */
467 default_symfile_offsets (objfile
, addrs
)
468 struct objfile
*objfile
;
469 struct section_addr_info
*addrs
;
473 objfile
->num_sections
= SECT_OFF_MAX
;
474 objfile
->section_offsets
= (struct section_offsets
*)
475 obstack_alloc (&objfile
->psymbol_obstack
, SIZEOF_SECTION_OFFSETS
);
476 memset (objfile
->section_offsets
, 0, SIZEOF_SECTION_OFFSETS
);
478 /* If user explicitly specified values for data and bss, set them here. */
480 if (addrs
->text_addr
)
481 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
) = addrs
->text_addr
;
482 if (addrs
->data_addr
)
483 ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA
) = addrs
->data_addr
;
485 ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS
) = addrs
->bss_addr
;
487 /* Now calculate offsets for other sections. */
488 for (i
= 0; i
< MAX_SECTIONS
&& addrs
->other
[i
].name
; i
++)
490 struct other_sections
*osp
;
492 osp
= &addrs
->other
[i
] ;
493 if (addrs
->other
[i
].addr
== 0)
496 if (strcmp (".text", osp
->name
) == 0)
497 SECT_OFF_TEXT
= osp
->sectindex
;
498 else if (strcmp (".data", osp
->name
) == 0)
499 SECT_OFF_DATA
= osp
->sectindex
;
500 else if (strcmp (".bss", osp
->name
) == 0)
501 SECT_OFF_BSS
= osp
->sectindex
;
503 /* Record all sections in offsets */
504 ANOFFSET (objfile
->section_offsets
, osp
->sectindex
) = osp
->addr
;
509 /* Process a symbol file, as either the main file or as a dynamically
512 OBJFILE is where the symbols are to be read from.
514 ADDR is the address where the text segment was loaded, unless the
515 objfile is the main symbol file, in which case it is zero.
517 MAINLINE is nonzero if this is the main symbol file, or zero if
518 it's an extra symbol file such as dynamically loaded code.
520 VERBO is nonzero if the caller has printed a verbose message about
521 the symbol reading (and complaints can be more terse about it). */
524 syms_from_objfile (objfile
, addrs
, mainline
, verbo
)
525 struct objfile
*objfile
;
526 struct section_addr_info
*addrs
;
530 struct section_offsets
*section_offsets
;
531 asection
*lower_sect
;
533 CORE_ADDR lower_offset
;
534 struct section_addr_info local_addr
;
535 struct cleanup
*old_chain
;
538 /* If ADDRS is NULL, initialize the local section_addr_info struct and
539 point ADDRS to it. We now establish the convention that an addr of
540 zero means no load address was specified. */
544 memset (&local_addr
, 0, sizeof (local_addr
));
548 init_entry_point_info (objfile
);
549 find_sym_fns (objfile
);
551 /* Make sure that partially constructed symbol tables will be cleaned up
552 if an error occurs during symbol reading. */
553 old_chain
= make_cleanup ((make_cleanup_func
) free_objfile
, objfile
);
557 /* We will modify the main symbol table, make sure that all its users
558 will be cleaned up if an error occurs during symbol reading. */
559 make_cleanup ((make_cleanup_func
) clear_symtab_users
, 0);
561 /* Since no error yet, throw away the old symbol table. */
563 if (symfile_objfile
!= NULL
)
565 free_objfile (symfile_objfile
);
566 symfile_objfile
= NULL
;
569 /* Currently we keep symbols from the add-symbol-file command.
570 If the user wants to get rid of them, they should do "symbol-file"
571 without arguments first. Not sure this is the best behavior
574 (*objfile
->sf
->sym_new_init
) (objfile
);
577 /* Convert addr into an offset rather than an absolute address.
578 We find the lowest address of a loaded segment in the objfile,
579 and assume that <addr> is where that got loaded.
581 We no longer warn if the lowest section is not a text segment (as
582 happens for the PA64 port. */
585 /* No offset from objfile addresses. */
586 addrs
-> text_addr
= 0;
587 addrs
-> data_addr
= 0;
588 addrs
-> bss_addr
= 0;
592 /* Find lowest loadable section to be used as starting point for
593 continguous sections. FIXME!! won't work without call to find
594 .text first, but this assumes text is lowest section. */
595 lower_sect
= bfd_get_section_by_name (objfile
->obfd
, ".text");
596 if (lower_sect
== NULL
)
597 bfd_map_over_sections (objfile
->obfd
, find_lowest_section
,
599 if (lower_sect
== NULL
)
600 warning ("no loadable sections found in added symbol-file %s",
602 else if ((bfd_get_section_flags (objfile
->obfd
, lower_sect
) & SEC_CODE
)
604 warning ("Lowest section in %s is %s at %s",
606 bfd_section_name (objfile
->obfd
, lower_sect
),
607 paddr (bfd_section_vma (objfile
->obfd
, lower_sect
)));
608 if (lower_sect
!= NULL
)
609 lower_offset
= bfd_section_vma (objfile
->obfd
, lower_sect
);
613 /* Calculate offsets for the loadable sections.
614 FIXME! Sections must be in order of increasing loadable section
615 so that contiguous sections can use the lower-offset!!!
617 Adjust offsets if the segments are not contiguous.
618 If the section is contiguous, its offset should be set to
619 the offset of the highest loadable section lower than it
620 (the loadable section directly below it in memory).
621 this_offset = lower_offset = lower_addr - lower_orig_addr */
623 /* FIXME: These sections will not need special treatment because ALL
624 sections are in the other sections table */
626 if (addrs
->text_addr
!= 0)
628 sect
= bfd_get_section_by_name (objfile
->obfd
, ".text");
631 addrs
->text_addr
-= bfd_section_vma (objfile
->obfd
, sect
);
632 lower_offset
= addrs
->text_addr
;
636 /* ??? who's below me? */
637 addrs
->text_addr
= lower_offset
;
639 if (addrs
->data_addr
!= 0)
641 sect
= bfd_get_section_by_name (objfile
->obfd
, ".data");
644 addrs
->data_addr
-= bfd_section_vma (objfile
->obfd
, sect
);
645 lower_offset
= addrs
->data_addr
;
649 addrs
->data_addr
= lower_offset
;
651 if (addrs
->bss_addr
!= 0)
653 sect
= bfd_get_section_by_name (objfile
->obfd
, ".bss");
656 addrs
->bss_addr
-= bfd_section_vma (objfile
->obfd
, sect
);
657 lower_offset
= addrs
->bss_addr
;
661 addrs
->bss_addr
= lower_offset
;
663 /* Now calculate offsets for other sections. */
664 for (i
=0 ; i
< MAX_SECTIONS
&& addrs
->other
[i
].name
; i
++)
667 if (addrs
->other
[i
].addr
!= 0)
669 sect
=bfd_get_section_by_name(objfile
->obfd
, addrs
->other
[i
].name
);
672 addrs
->other
[i
].addr
-= bfd_section_vma (objfile
->obfd
, sect
);
673 lower_offset
= addrs
->other
[i
].addr
;
674 addrs
->other
[i
].sectindex
= sect
->index
;
678 warning ("section %s not found in %s", addrs
->other
[i
].name
,
680 addrs
->other
[i
].addr
= 0;
684 addrs
->other
[i
].addr
= lower_offset
;
688 /* Initialize symbol reading routines for this objfile, allow complaints to
689 appear for this new file, and record how verbose to be, then do the
690 initial symbol reading for this file. */
692 (*objfile
->sf
->sym_init
) (objfile
);
693 clear_complaints (1, verbo
);
695 (*objfile
->sf
->sym_offsets
) (objfile
, addrs
);
697 #ifndef IBM6000_TARGET
698 /* This is a SVR4/SunOS specific hack, I think. In any event, it
699 screws RS/6000. sym_offsets should be doing this sort of thing,
700 because it knows the mapping between bfd sections and
702 /* This is a hack. As far as I can tell, section offsets are not
703 target dependent. They are all set to addr with a couple of
704 exceptions. The exceptions are sysvr4 shared libraries, whose
705 offsets are kept in solib structures anyway and rs6000 xcoff
706 which handles shared libraries in a completely unique way.
708 Section offsets are built similarly, except that they are built
709 by adding addr in all cases because there is no clear mapping
710 from section_offsets into actual sections. Note that solib.c
711 has a different algorithm for finding section offsets.
713 These should probably all be collapsed into some target
714 independent form of shared library support. FIXME. */
718 struct obj_section
*s
;
720 /* Map section offsets in "addr" back to the object's
721 sections by comparing the section names with bfd's
722 section names. Then adjust the section address by
723 the offset. */ /* for gdb/13815 */
725 ALL_OBJFILE_OSECTIONS (objfile
, s
)
727 CORE_ADDR s_addr
= 0;
730 if (strcmp (s
->the_bfd_section
->name
, ".text") == 0)
731 s_addr
= addrs
->text_addr
;
732 else if (strcmp (s
->the_bfd_section
->name
, ".data") == 0)
733 s_addr
= addrs
->data_addr
;
734 else if (strcmp (s
->the_bfd_section
->name
, ".bss") == 0)
735 s_addr
= addrs
->bss_addr
;
737 for (i
= 0; !s_addr
&& addrs
->other
[i
].name
; i
++)
738 if (strcmp (s
->the_bfd_section
->name
, addrs
->other
[i
].name
) == 0)
739 s_addr
= addrs
->other
[i
].addr
; /* end added for gdb/13815 */
741 s
->addr
-= s
->offset
;
743 s
->endaddr
-= s
->offset
;
744 s
->endaddr
+= s_addr
;
748 #endif /* not IBM6000_TARGET */
750 (*objfile
->sf
->sym_read
) (objfile
, mainline
);
752 if (!have_partial_symbols () && !have_full_symbols ())
755 printf_filtered ("(no debugging symbols found)...");
759 /* Don't allow char * to have a typename (else would get caddr_t).
760 Ditto void *. FIXME: Check whether this is now done by all the
761 symbol readers themselves (many of them now do), and if so remove
764 TYPE_NAME (lookup_pointer_type (builtin_type_char
)) = 0;
765 TYPE_NAME (lookup_pointer_type (builtin_type_void
)) = 0;
767 /* Mark the objfile has having had initial symbol read attempted. Note
768 that this does not mean we found any symbols... */
770 objfile
->flags
|= OBJF_SYMS
;
772 /* Discard cleanups as symbol reading was successful. */
774 discard_cleanups (old_chain
);
776 /* Call this after reading in a new symbol table to give target
777 dependant code a crack at the new symbols. For instance, this
778 could be used to update the values of target-specific symbols GDB
779 needs to keep track of (such as _sigtramp, or whatever). */
781 TARGET_SYMFILE_POSTREAD (objfile
);
784 /* Perform required actions after either reading in the initial
785 symbols for a new objfile, or mapping in the symbols from a reusable
789 new_symfile_objfile (objfile
, mainline
, verbo
)
790 struct objfile
*objfile
;
795 /* If this is the main symbol file we have to clean up all users of the
796 old main symbol file. Otherwise it is sufficient to fixup all the
797 breakpoints that may have been redefined by this symbol file. */
800 /* OK, make it the "real" symbol file. */
801 symfile_objfile
= objfile
;
803 clear_symtab_users ();
807 breakpoint_re_set ();
810 /* We're done reading the symbol file; finish off complaints. */
811 clear_complaints (0, verbo
);
814 /* Process a symbol file, as either the main file or as a dynamically
817 NAME is the file name (which will be tilde-expanded and made
818 absolute herein) (but we don't free or modify NAME itself).
819 FROM_TTY says how verbose to be. MAINLINE specifies whether this
820 is the main symbol file, or whether it's an extra symbol file such
821 as dynamically loaded code. If !mainline, ADDR is the address
822 where the text segment was loaded.
824 Upon success, returns a pointer to the objfile that was added.
825 Upon failure, jumps back to command level (never returns). */
828 symbol_file_add (name
, from_tty
, addrs
, mainline
, flags
)
831 struct section_addr_info
*addrs
;
835 struct objfile
*objfile
;
836 struct partial_symtab
*psymtab
;
839 /* Open a bfd for the file, and give user a chance to burp if we'd be
840 interactively wiping out any existing symbols. */
842 abfd
= symfile_bfd_open (name
);
844 if ((have_full_symbols () || have_partial_symbols ())
847 && !query ("Load new symbol table from \"%s\"? ", name
))
848 error ("Not confirmed.");
850 objfile
= allocate_objfile (abfd
, flags
);
852 /* If the objfile uses a mapped symbol file, and we have a psymtab for
853 it, then skip reading any symbols at this time. */
855 if ((objfile
->flags
& OBJF_MAPPED
) && (objfile
->flags
& OBJF_SYMS
))
857 /* We mapped in an existing symbol table file that already has had
858 initial symbol reading performed, so we can skip that part. Notify
859 the user that instead of reading the symbols, they have been mapped.
861 if (from_tty
|| info_verbose
)
863 printf_filtered ("Mapped symbols for %s...", name
);
865 gdb_flush (gdb_stdout
);
867 init_entry_point_info (objfile
);
868 find_sym_fns (objfile
);
872 /* We either created a new mapped symbol table, mapped an existing
873 symbol table file which has not had initial symbol reading
874 performed, or need to read an unmapped symbol table. */
875 if (from_tty
|| info_verbose
)
877 if (pre_add_symbol_hook
)
878 pre_add_symbol_hook (name
);
881 printf_filtered ("Reading symbols from %s...", name
);
883 gdb_flush (gdb_stdout
);
886 syms_from_objfile (objfile
, addrs
, mainline
, from_tty
);
889 /* We now have at least a partial symbol table. Check to see if the
890 user requested that all symbols be read on initial access via either
891 the gdb startup command line or on a per symbol file basis. Expand
892 all partial symbol tables for this objfile if so. */
894 if ((flags
& OBJF_READNOW
) || readnow_symbol_files
)
896 if (from_tty
|| info_verbose
)
898 printf_filtered ("expanding to full symbols...");
900 gdb_flush (gdb_stdout
);
903 for (psymtab
= objfile
->psymtabs
;
905 psymtab
= psymtab
->next
)
907 psymtab_to_symtab (psymtab
);
911 if (from_tty
|| info_verbose
)
913 if (post_add_symbol_hook
)
914 post_add_symbol_hook ();
917 printf_filtered ("done.\n");
918 gdb_flush (gdb_stdout
);
922 new_symfile_objfile (objfile
, mainline
, from_tty
);
924 if (target_new_objfile_hook
)
925 target_new_objfile_hook (objfile
);
930 /* This is the symbol-file command. Read the file, analyze its
931 symbols, and add a struct symtab to a symtab list. The syntax of
932 the command is rather bizarre--(1) buildargv implements various
933 quoting conventions which are undocumented and have little or
934 nothing in common with the way things are quoted (or not quoted)
935 elsewhere in GDB, (2) options are used, which are not generally
936 used in GDB (perhaps "set mapped on", "set readnow on" would be
937 better), (3) the order of options matters, which is contrary to GNU
938 conventions (because it is confusing and inconvenient). */
941 symbol_file_command (args
, from_tty
)
947 CORE_ADDR text_relocation
= 0; /* text_relocation */
948 struct cleanup
*cleanups
;
949 int flags
= OBJF_USERLOADED
;
955 if ((have_full_symbols () || have_partial_symbols ())
957 && !query ("Discard symbol table from `%s'? ",
958 symfile_objfile
->name
))
959 error ("Not confirmed.");
960 free_all_objfiles ();
962 /* solib descriptors may have handles to objfiles. Since their
963 storage has just been released, we'd better wipe the solib
966 #if defined(SOLIB_RESTART)
970 symfile_objfile
= NULL
;
973 printf_unfiltered ("No symbol file now.\n");
976 RESET_HP_UX_GLOBALS ();
981 if ((argv
= buildargv (args
)) == NULL
)
985 cleanups
= make_cleanup_freeargv (argv
);
986 while (*argv
!= NULL
)
988 if (STREQ (*argv
, "-mapped"))
990 flags
|= OBJF_MAPPED
;
992 else if (STREQ (*argv
, "-readnow"))
994 flags
|= OBJF_READNOW
;
996 else if (**argv
== '-')
998 error ("unknown option `%s'", *argv
);
1006 /* this is for rombug remote only, to get the text relocation by
1007 using link command */
1008 p
= strrchr (name
, '/');
1014 target_link (p
, &text_relocation
);
1016 if (text_relocation
== (CORE_ADDR
) 0)
1018 else if (text_relocation
== (CORE_ADDR
) -1)
1020 symbol_file_add (name
, from_tty
, NULL
, 1, flags
);
1022 RESET_HP_UX_GLOBALS ();
1027 struct section_addr_info section_addrs
;
1028 memset (§ion_addrs
, 0, sizeof (section_addrs
));
1029 section_addrs
.text_addr
= (CORE_ADDR
) text_relocation
;
1030 symbol_file_add (name
, from_tty
, §ion_addrs
, 0, flags
);
1033 /* Getting new symbols may change our opinion about what is
1035 reinit_frame_cache ();
1037 set_initial_language ();
1044 error ("no symbol file name was specified");
1046 TUIDO (((TuiOpaqueFuncPtr
) tuiDisplayMainFunction
));
1047 do_cleanups (cleanups
);
1051 /* Set the initial language.
1053 A better solution would be to record the language in the psymtab when reading
1054 partial symbols, and then use it (if known) to set the language. This would
1055 be a win for formats that encode the language in an easily discoverable place,
1056 such as DWARF. For stabs, we can jump through hoops looking for specially
1057 named symbols or try to intuit the language from the specific type of stabs
1058 we find, but we can't do that until later when we read in full symbols.
1062 set_initial_language ()
1064 struct partial_symtab
*pst
;
1065 enum language lang
= language_unknown
;
1067 pst
= find_main_psymtab ();
1070 if (pst
->filename
!= NULL
)
1072 lang
= deduce_language_from_filename (pst
->filename
);
1074 if (lang
== language_unknown
)
1076 /* Make C the default language */
1079 set_language (lang
);
1080 expected_language
= current_language
; /* Don't warn the user */
1084 /* Open file specified by NAME and hand it off to BFD for preliminary
1085 analysis. Result is a newly initialized bfd *, which includes a newly
1086 malloc'd` copy of NAME (tilde-expanded and made absolute).
1087 In case of trouble, error() is called. */
1090 symfile_bfd_open (name
)
1095 char *absolute_name
;
1099 name
= tilde_expand (name
); /* Returns 1st new malloc'd copy */
1101 /* Look down path for it, allocate 2nd new malloc'd copy. */
1102 desc
= openp (getenv ("PATH"), 1, name
, O_RDONLY
| O_BINARY
, 0, &absolute_name
);
1103 #if defined(__GO32__) || defined(_WIN32)
1106 char *exename
= alloca (strlen (name
) + 5);
1107 strcat (strcpy (exename
, name
), ".exe");
1108 desc
= openp (getenv ("PATH"), 1, exename
, O_RDONLY
| O_BINARY
,
1114 make_cleanup (free
, name
);
1115 perror_with_name (name
);
1117 free (name
); /* Free 1st new malloc'd copy */
1118 name
= absolute_name
; /* Keep 2nd malloc'd copy in bfd */
1119 /* It'll be freed in free_objfile(). */
1121 sym_bfd
= bfd_fdopenr (name
, gnutarget
, desc
);
1125 make_cleanup (free
, name
);
1126 error ("\"%s\": can't open to read symbols: %s.", name
,
1127 bfd_errmsg (bfd_get_error ()));
1129 sym_bfd
->cacheable
= true;
1131 if (!bfd_check_format (sym_bfd
, bfd_object
))
1133 /* FIXME: should be checking for errors from bfd_close (for one thing,
1134 on error it does not free all the storage associated with the
1136 bfd_close (sym_bfd
); /* This also closes desc */
1137 make_cleanup (free
, name
);
1138 error ("\"%s\": can't read symbols: %s.", name
,
1139 bfd_errmsg (bfd_get_error ()));
1144 /* Link a new symtab_fns into the global symtab_fns list. Called on gdb
1145 startup by the _initialize routine in each object file format reader,
1146 to register information about each format the the reader is prepared
1153 sf
->next
= symtab_fns
;
1158 /* Initialize to read symbols from the symbol file sym_bfd. It either
1159 returns or calls error(). The result is an initialized struct sym_fns
1160 in the objfile structure, that contains cached information about the
1164 find_sym_fns (objfile
)
1165 struct objfile
*objfile
;
1168 enum bfd_flavour our_flavour
= bfd_get_flavour (objfile
->obfd
);
1169 char *our_target
= bfd_get_target (objfile
->obfd
);
1171 /* Special kludge for RS/6000 and PowerMac. See xcoffread.c. */
1172 if (STREQ (our_target
, "aixcoff-rs6000") ||
1173 STREQ (our_target
, "xcoff-powermac"))
1174 our_flavour
= (enum bfd_flavour
) -1;
1176 /* Special kludge for apollo. See dstread.c. */
1177 if (STREQN (our_target
, "apollo", 6))
1178 our_flavour
= (enum bfd_flavour
) -2;
1180 for (sf
= symtab_fns
; sf
!= NULL
; sf
= sf
->next
)
1182 if (our_flavour
== sf
->sym_flavour
)
1188 error ("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown.",
1189 bfd_get_target (objfile
->obfd
));
1192 /* This function runs the load command of our current target. */
1195 load_command (arg
, from_tty
)
1200 arg
= get_exec_file (1);
1201 target_load (arg
, from_tty
);
1204 /* This version of "load" should be usable for any target. Currently
1205 it is just used for remote targets, not inftarg.c or core files,
1206 on the theory that only in that case is it useful.
1208 Avoiding xmodem and the like seems like a win (a) because we don't have
1209 to worry about finding it, and (b) On VMS, fork() is very slow and so
1210 we don't want to run a subprocess. On the other hand, I'm not sure how
1211 performance compares. */
1213 static int download_write_size
= 512;
1214 static int validate_download
= 0;
1217 generic_load (char *args
, int from_tty
)
1221 time_t start_time
, end_time
; /* Start and end times of download */
1222 unsigned long data_count
= 0; /* Number of bytes transferred to memory */
1223 unsigned long write_count
= 0; /* Number of writes needed. */
1224 unsigned long load_offset
; /* offset to add to vma for each section */
1226 struct cleanup
*old_cleanups
;
1229 /* Parse the input argument - the user can specify a load offset as
1230 a second argument. */
1231 filename
= xmalloc (strlen (args
) + 1);
1232 old_cleanups
= make_cleanup (free
, filename
);
1233 strcpy (filename
, args
);
1234 offptr
= strchr (filename
, ' ');
1238 load_offset
= strtoul (offptr
, &endptr
, 0);
1239 if (offptr
== endptr
)
1240 error ("Invalid download offset:%s\n", offptr
);
1246 /* Open the file for loading. */
1247 loadfile_bfd
= bfd_openr (filename
, gnutarget
);
1248 if (loadfile_bfd
== NULL
)
1250 perror_with_name (filename
);
1254 /* FIXME: should be checking for errors from bfd_close (for one thing,
1255 on error it does not free all the storage associated with the
1257 make_cleanup ((make_cleanup_func
) bfd_close
, loadfile_bfd
);
1259 if (!bfd_check_format (loadfile_bfd
, bfd_object
))
1261 error ("\"%s\" is not an object file: %s", filename
,
1262 bfd_errmsg (bfd_get_error ()));
1265 start_time
= time (NULL
);
1267 for (s
= loadfile_bfd
->sections
; s
; s
= s
->next
)
1269 if (s
->flags
& SEC_LOAD
)
1271 CORE_ADDR size
= bfd_get_section_size_before_reloc (s
);
1275 struct cleanup
*old_chain
;
1276 CORE_ADDR lma
= s
->lma
+ load_offset
;
1277 CORE_ADDR block_size
;
1279 const char *sect_name
= bfd_get_section_name (loadfile_bfd
, s
);
1282 if (download_write_size
> 0 && size
> download_write_size
)
1283 block_size
= download_write_size
;
1287 buffer
= xmalloc (size
);
1288 old_chain
= make_cleanup (free
, buffer
);
1290 /* Is this really necessary? I guess it gives the user something
1291 to look at during a long download. */
1292 fprintf_unfiltered (gdb_stdout
,
1293 "Loading section %s, size 0x%s lma 0x%s\n",
1294 sect_name
, paddr_nz (size
), paddr_nz (lma
));
1296 bfd_get_section_contents (loadfile_bfd
, s
, buffer
, 0, size
);
1302 CORE_ADDR this_transfer
= size
- sent
;
1303 if (this_transfer
>= block_size
)
1304 this_transfer
= block_size
;
1305 len
= target_write_memory_partial (lma
, buffer
,
1306 this_transfer
, &err
);
1309 if (validate_download
)
1311 /* Broken memories and broken monitors manifest
1312 themselves here when bring new computers to
1313 life. This doubles already slow downloads. */
1314 /* NOTE: cagney/1999-10-18: A more efficient
1315 implementation might add a verify_memory()
1316 method to the target vector and then use
1317 that. remote.c could implement that method
1318 using the ``qCRC'' packet. */
1319 char *check
= xmalloc (len
);
1320 struct cleanup
*verify_cleanups
= make_cleanup (free
, check
);
1321 if (target_read_memory (lma
, check
, len
) != 0)
1322 error ("Download verify read failed at 0x%s",
1324 if (memcmp (buffer
, check
, len
) != 0)
1325 error ("Download verify compare failed at 0x%s",
1327 do_cleanups (verify_cleanups
);
1335 || (ui_load_progress_hook
!= NULL
1336 && ui_load_progress_hook (sect_name
, sent
)))
1337 error ("Canceled the download");
1339 while (sent
< size
);
1342 error ("Memory access error while loading section %s.", sect_name
);
1344 do_cleanups (old_chain
);
1349 end_time
= time (NULL
);
1352 entry
= bfd_get_start_address (loadfile_bfd
);
1353 fprintf_unfiltered (gdb_stdout
,
1354 "Start address 0x%s , load size %ld\n",
1355 paddr_nz (entry
), data_count
);
1356 /* We were doing this in remote-mips.c, I suspect it is right
1357 for other targets too. */
1361 /* FIXME: are we supposed to call symbol_file_add or not? According to
1362 a comment from remote-mips.c (where a call to symbol_file_add was
1363 commented out), making the call confuses GDB if more than one file is
1364 loaded in. remote-nindy.c had no call to symbol_file_add, but remote-vx.c
1367 print_transfer_performance (gdb_stdout
, data_count
, write_count
,
1368 end_time
- start_time
);
1370 do_cleanups (old_cleanups
);
1373 /* Report how fast the transfer went. */
1375 /* DEPRECATED: cagney/1999-10-18: report_transfer_performance is being
1376 replaced by print_transfer_performance (with a very different
1377 function signature). */
1380 report_transfer_performance (data_count
, start_time
, end_time
)
1381 unsigned long data_count
;
1382 time_t start_time
, end_time
;
1384 print_transfer_performance (gdb_stdout
, data_count
, end_time
- start_time
, 0);
1388 print_transfer_performance (struct gdb_file
*stream
,
1389 unsigned long data_count
,
1390 unsigned long write_count
,
1391 unsigned long time_count
)
1393 fprintf_unfiltered (stream
, "Transfer rate: ");
1395 fprintf_unfiltered (stream
, "%ld bits/sec", (data_count
* 8) / time_count
);
1397 fprintf_unfiltered (stream
, "%ld bits in <1 sec", (data_count
* 8));
1398 if (write_count
> 0)
1399 fprintf_unfiltered (stream
, ", %ld bytes/write", data_count
/ write_count
);
1400 fprintf_unfiltered (stream
, ".\n");
1403 /* This function allows the addition of incrementally linked object files.
1404 It does not modify any state in the target, only in the debugger. */
1408 add_symbol_file_command (args
, from_tty
)
1413 CORE_ADDR text_addr
;
1414 int flags
= OBJF_USERLOADED
;
1416 int expecting_option
= 0;
1417 int option_index
= 0;
1423 enum { OPT_SECTION
} type
;
1426 } opt
[SECT_OFF_MAX
];
1427 struct section_addr_info section_addrs
;
1433 error ("add-symbol-file takes a file name and an address");
1436 /* Make a copy of the string that we can safely write into. */
1438 args
= strdup (args
);
1439 make_cleanup (free
, args
);
1441 /* Ensure section_addrs is initialized */
1442 memset (§ion_addrs
, 0, sizeof (section_addrs
));
1444 /* Pick off any -option args and the file name. */
1446 while (*args
!= '\000')
1448 while (isspace (*args
))
1453 while ((*args
!= '\000') && !isspace (*args
))
1457 if (*args
!= '\000')
1463 if (expecting_option
)
1465 opt
[option_index
++].value
= arg
;
1466 expecting_option
= 0;
1476 opt
[option_index
].type
= OPT_SECTION
;
1477 opt
[option_index
].name
= ".text";
1478 opt
[option_index
++].value
= arg
;
1481 opt
[option_index
].type
= OPT_SECTION
;
1482 opt
[option_index
].name
= ".data";
1483 opt
[option_index
++].value
= arg
;
1486 opt
[option_index
].type
= OPT_SECTION
;
1487 opt
[option_index
].name
= ".bss";
1488 opt
[option_index
++].value
= arg
;
1491 warning ("Too many arguments entered; see \"help add-symbol-file\" for command syntax.");
1496 else if (STREQ (arg
, "-mapped"))
1498 flags
|= OBJF_MAPPED
;
1500 else if (STREQ (arg
, "-readnow"))
1502 flags
|= OBJF_READNOW
;
1504 else if (STREQN (arg
, "-T", 2))
1506 if (option_index
>= SECT_OFF_MAX
)
1508 warning ("Number of options exceeds maximum allowed.");
1512 expecting_option
= 1;
1513 opt
[option_index
].type
= OPT_SECTION
;
1514 opt
[option_index
].name
= arg
+ 2;
1519 error ("Unknown option `%s'", arg
);
1525 error ("add-symbol-file takes a file name");
1527 name
= tilde_expand (name
);
1528 make_cleanup (free
, name
);
1530 if (option_index
> 0)
1532 /* Print the prompt for the query below.
1533 We have to split this up into 3 print statements because
1534 local_hex_string returns a local static string. */
1536 printf_filtered ("add symbol table from file \"%s\" at\n", name
);
1537 for (i
= 0; i
< option_index
; i
++)
1539 switch (opt
[i
].type
)
1544 char *val
= opt
[i
].value
;
1545 char *sec
= opt
[i
].name
;
1548 if (val
[0] == '0' && val
[1] == 'x')
1549 addr
= strtoul (val
+2, NULL
, 16);
1551 addr
= strtoul (val
, NULL
, 10);
1553 if (strcmp (sec
, ".text") == 0)
1554 section_addrs
.text_addr
= addr
;
1555 else if (strcmp (sec
, ".data") == 0)
1556 section_addrs
.data_addr
= addr
;
1557 else if (strcmp (sec
, ".bss") == 0)
1558 section_addrs
.bss_addr
= addr
;
1559 /* Add the section to the others even if it is a
1560 text data or bss section. This is redundent but
1561 eventually, none will be given special treatment */
1563 section_addrs
.other
[sec_num
].name
= strdup (sec
);
1564 make_cleanup (free
, section_addrs
.other
[sec_num
].name
);
1565 section_addrs
.other
[sec_num
++].addr
= addr
;
1566 printf_filtered ("\t%s_addr = %s\n",
1568 local_hex_string ((unsigned long)addr
));
1571 /* The object's sections are initialized when a
1572 call is made to build_objfile_section_table (objfile).
1573 This happens in reread_symbols.
1574 At this point, we don't know what file type this is,
1575 so we can't determine what section names are valid. */
1579 complain (&unknown_option_complaint
, opt
[i
].name
);
1582 /* Eventually, these hard coded names will be obsolete */
1583 /* All the addresses will be on the others section */
1587 CORE_ADDR text_addr
;
1588 target_link (name
, &text_addr
);
1589 if (text_addr
== (CORE_ADDR
) -1)
1590 error("Don't know how to get text start location for this file");
1591 section_addrs
.text_addr
= text_addr
;
1592 section_addrs
.data_addr
= 0;
1593 section_addrs
.bss_addr
= 0;
1594 printf_filtered("add symbol table from file \"%s\" at text_addr = %s?\n",
1595 name
, local_hex_string ((unsigned long)text_addr
));
1597 if (from_tty
&& (!query ("%s", "")))
1598 error ("Not confirmed.");
1600 symbol_file_add (name
, from_tty
, §ion_addrs
, 0, flags
);
1602 /* Getting new symbols may change our opinion about what is
1604 reinit_frame_cache ();
1608 add_shared_symbol_files_command (args
, from_tty
)
1612 #ifdef ADD_SHARED_SYMBOL_FILES
1613 ADD_SHARED_SYMBOL_FILES (args
, from_tty
);
1615 error ("This command is not available in this configuration of GDB.");
1619 /* Re-read symbols if a symbol-file has changed. */
1623 struct objfile
*objfile
;
1626 struct stat new_statbuf
;
1629 /* With the addition of shared libraries, this should be modified,
1630 the load time should be saved in the partial symbol tables, since
1631 different tables may come from different source files. FIXME.
1632 This routine should then walk down each partial symbol table
1633 and see if the symbol table that it originates from has been changed */
1635 for (objfile
= object_files
; objfile
; objfile
= objfile
->next
)
1639 #ifdef IBM6000_TARGET
1640 /* If this object is from a shared library, then you should
1641 stat on the library name, not member name. */
1643 if (objfile
->obfd
->my_archive
)
1644 res
= stat (objfile
->obfd
->my_archive
->filename
, &new_statbuf
);
1647 res
= stat (objfile
->name
, &new_statbuf
);
1650 /* FIXME, should use print_sys_errmsg but it's not filtered. */
1651 printf_filtered ("`%s' has disappeared; keeping its symbols.\n",
1655 new_modtime
= new_statbuf
.st_mtime
;
1656 if (new_modtime
!= objfile
->mtime
)
1658 struct cleanup
*old_cleanups
;
1659 struct section_offsets
*offsets
;
1661 char *obfd_filename
;
1663 printf_filtered ("`%s' has changed; re-reading symbols.\n",
1666 /* There are various functions like symbol_file_add,
1667 symfile_bfd_open, syms_from_objfile, etc., which might
1668 appear to do what we want. But they have various other
1669 effects which we *don't* want. So we just do stuff
1670 ourselves. We don't worry about mapped files (for one thing,
1671 any mapped file will be out of date). */
1673 /* If we get an error, blow away this objfile (not sure if
1674 that is the correct response for things like shared
1676 old_cleanups
= make_cleanup ((make_cleanup_func
) free_objfile
,
1678 /* We need to do this whenever any symbols go away. */
1679 make_cleanup ((make_cleanup_func
) clear_symtab_users
, 0);
1681 /* Clean up any state BFD has sitting around. We don't need
1682 to close the descriptor but BFD lacks a way of closing the
1683 BFD without closing the descriptor. */
1684 obfd_filename
= bfd_get_filename (objfile
->obfd
);
1685 if (!bfd_close (objfile
->obfd
))
1686 error ("Can't close BFD for %s: %s", objfile
->name
,
1687 bfd_errmsg (bfd_get_error ()));
1688 objfile
->obfd
= bfd_openr (obfd_filename
, gnutarget
);
1689 if (objfile
->obfd
== NULL
)
1690 error ("Can't open %s to read symbols.", objfile
->name
);
1691 /* bfd_openr sets cacheable to true, which is what we want. */
1692 if (!bfd_check_format (objfile
->obfd
, bfd_object
))
1693 error ("Can't read symbols from %s: %s.", objfile
->name
,
1694 bfd_errmsg (bfd_get_error ()));
1696 /* Save the offsets, we will nuke them with the rest of the
1698 num_offsets
= objfile
->num_sections
;
1699 offsets
= (struct section_offsets
*) alloca (SIZEOF_SECTION_OFFSETS
);
1700 memcpy (offsets
, objfile
->section_offsets
, SIZEOF_SECTION_OFFSETS
);
1702 /* Nuke all the state that we will re-read. Much of the following
1703 code which sets things to NULL really is necessary to tell
1704 other parts of GDB that there is nothing currently there. */
1706 /* FIXME: Do we have to free a whole linked list, or is this
1708 if (objfile
->global_psymbols
.list
)
1709 mfree (objfile
->md
, objfile
->global_psymbols
.list
);
1710 memset (&objfile
->global_psymbols
, 0,
1711 sizeof (objfile
->global_psymbols
));
1712 if (objfile
->static_psymbols
.list
)
1713 mfree (objfile
->md
, objfile
->static_psymbols
.list
);
1714 memset (&objfile
->static_psymbols
, 0,
1715 sizeof (objfile
->static_psymbols
));
1717 /* Free the obstacks for non-reusable objfiles */
1718 obstack_free (&objfile
->psymbol_cache
.cache
, 0);
1719 memset (&objfile
->psymbol_cache
, 0,
1720 sizeof (objfile
->psymbol_cache
));
1721 obstack_free (&objfile
->psymbol_obstack
, 0);
1722 obstack_free (&objfile
->symbol_obstack
, 0);
1723 obstack_free (&objfile
->type_obstack
, 0);
1724 objfile
->sections
= NULL
;
1725 objfile
->symtabs
= NULL
;
1726 objfile
->psymtabs
= NULL
;
1727 objfile
->free_psymtabs
= NULL
;
1728 objfile
->msymbols
= NULL
;
1729 objfile
->minimal_symbol_count
= 0;
1730 objfile
->fundamental_types
= NULL
;
1731 if (objfile
->sf
!= NULL
)
1733 (*objfile
->sf
->sym_finish
) (objfile
);
1736 /* We never make this a mapped file. */
1738 /* obstack_specify_allocation also initializes the obstack so
1740 obstack_specify_allocation (&objfile
->psymbol_cache
.cache
, 0, 0,
1742 obstack_specify_allocation (&objfile
->psymbol_obstack
, 0, 0,
1744 obstack_specify_allocation (&objfile
->symbol_obstack
, 0, 0,
1746 obstack_specify_allocation (&objfile
->type_obstack
, 0, 0,
1748 if (build_objfile_section_table (objfile
))
1750 error ("Can't find the file sections in `%s': %s",
1751 objfile
->name
, bfd_errmsg (bfd_get_error ()));
1754 /* We use the same section offsets as from last time. I'm not
1755 sure whether that is always correct for shared libraries. */
1756 objfile
->section_offsets
= (struct section_offsets
*)
1757 obstack_alloc (&objfile
->psymbol_obstack
, SIZEOF_SECTION_OFFSETS
);
1758 memcpy (objfile
->section_offsets
, offsets
, SIZEOF_SECTION_OFFSETS
);
1759 objfile
->num_sections
= num_offsets
;
1761 /* What the hell is sym_new_init for, anyway? The concept of
1762 distinguishing between the main file and additional files
1763 in this way seems rather dubious. */
1764 if (objfile
== symfile_objfile
)
1766 (*objfile
->sf
->sym_new_init
) (objfile
);
1768 RESET_HP_UX_GLOBALS ();
1772 (*objfile
->sf
->sym_init
) (objfile
);
1773 clear_complaints (1, 1);
1774 /* The "mainline" parameter is a hideous hack; I think leaving it
1775 zero is OK since dbxread.c also does what it needs to do if
1776 objfile->global_psymbols.size is 0. */
1777 (*objfile
->sf
->sym_read
) (objfile
, 0);
1778 if (!have_partial_symbols () && !have_full_symbols ())
1781 printf_filtered ("(no debugging symbols found)\n");
1784 objfile
->flags
|= OBJF_SYMS
;
1786 /* We're done reading the symbol file; finish off complaints. */
1787 clear_complaints (0, 1);
1789 /* Getting new symbols may change our opinion about what is
1792 reinit_frame_cache ();
1794 /* Discard cleanups as symbol reading was successful. */
1795 discard_cleanups (old_cleanups
);
1797 /* If the mtime has changed between the time we set new_modtime
1798 and now, we *want* this to be out of date, so don't call stat
1800 objfile
->mtime
= new_modtime
;
1803 /* Call this after reading in a new symbol table to give target
1804 dependant code a crack at the new symbols. For instance, this
1805 could be used to update the values of target-specific symbols GDB
1806 needs to keep track of (such as _sigtramp, or whatever). */
1808 TARGET_SYMFILE_POSTREAD (objfile
);
1814 clear_symtab_users ();
1826 static filename_language
*filename_language_table
;
1827 static int fl_table_size
, fl_table_next
;
1830 add_filename_language (ext
, lang
)
1834 if (fl_table_next
>= fl_table_size
)
1836 fl_table_size
+= 10;
1837 filename_language_table
= realloc (filename_language_table
,
1841 filename_language_table
[fl_table_next
].ext
= strsave (ext
);
1842 filename_language_table
[fl_table_next
].lang
= lang
;
1846 static char *ext_args
;
1849 set_ext_lang_command (args
, from_tty
)
1854 char *cp
= ext_args
;
1857 /* First arg is filename extension, starting with '.' */
1859 error ("'%s': Filename extension must begin with '.'", ext_args
);
1861 /* Find end of first arg. */
1862 while (*cp
&& !isspace (*cp
))
1866 error ("'%s': two arguments required -- filename extension and language",
1869 /* Null-terminate first arg */
1872 /* Find beginning of second arg, which should be a source language. */
1873 while (*cp
&& isspace (*cp
))
1877 error ("'%s': two arguments required -- filename extension and language",
1880 /* Lookup the language from among those we know. */
1881 lang
= language_enum (cp
);
1883 /* Now lookup the filename extension: do we already know it? */
1884 for (i
= 0; i
< fl_table_next
; i
++)
1885 if (0 == strcmp (ext_args
, filename_language_table
[i
].ext
))
1888 if (i
>= fl_table_next
)
1890 /* new file extension */
1891 add_filename_language (ext_args
, lang
);
1895 /* redefining a previously known filename extension */
1898 /* query ("Really make files of type %s '%s'?", */
1899 /* ext_args, language_str (lang)); */
1901 free (filename_language_table
[i
].ext
);
1902 filename_language_table
[i
].ext
= strsave (ext_args
);
1903 filename_language_table
[i
].lang
= lang
;
1908 info_ext_lang_command (args
, from_tty
)
1914 printf_filtered ("Filename extensions and the languages they represent:");
1915 printf_filtered ("\n\n");
1916 for (i
= 0; i
< fl_table_next
; i
++)
1917 printf_filtered ("\t%s\t- %s\n",
1918 filename_language_table
[i
].ext
,
1919 language_str (filename_language_table
[i
].lang
));
1923 init_filename_language_table ()
1925 if (fl_table_size
== 0) /* protect against repetition */
1929 filename_language_table
=
1930 xmalloc (fl_table_size
* sizeof (*filename_language_table
));
1931 add_filename_language (".c", language_c
);
1932 add_filename_language (".C", language_cplus
);
1933 add_filename_language (".cc", language_cplus
);
1934 add_filename_language (".cp", language_cplus
);
1935 add_filename_language (".cpp", language_cplus
);
1936 add_filename_language (".cxx", language_cplus
);
1937 add_filename_language (".c++", language_cplus
);
1938 add_filename_language (".java", language_java
);
1939 add_filename_language (".class", language_java
);
1940 add_filename_language (".ch", language_chill
);
1941 add_filename_language (".c186", language_chill
);
1942 add_filename_language (".c286", language_chill
);
1943 add_filename_language (".f", language_fortran
);
1944 add_filename_language (".F", language_fortran
);
1945 add_filename_language (".s", language_asm
);
1946 add_filename_language (".S", language_asm
);
1951 deduce_language_from_filename (filename
)
1957 if (filename
!= NULL
)
1958 if ((cp
= strrchr (filename
, '.')) != NULL
)
1959 for (i
= 0; i
< fl_table_next
; i
++)
1960 if (strcmp (cp
, filename_language_table
[i
].ext
) == 0)
1961 return filename_language_table
[i
].lang
;
1963 return language_unknown
;
1968 Allocate and partly initialize a new symbol table. Return a pointer
1969 to it. error() if no space.
1971 Caller must set these fields:
1977 possibly free_named_symtabs (symtab->filename);
1981 allocate_symtab (filename
, objfile
)
1983 struct objfile
*objfile
;
1985 register struct symtab
*symtab
;
1987 symtab
= (struct symtab
*)
1988 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symtab
));
1989 memset (symtab
, 0, sizeof (*symtab
));
1990 symtab
->filename
= obsavestring (filename
, strlen (filename
),
1991 &objfile
->symbol_obstack
);
1992 symtab
->fullname
= NULL
;
1993 symtab
->language
= deduce_language_from_filename (filename
);
1994 symtab
->debugformat
= obsavestring ("unknown", 7,
1995 &objfile
->symbol_obstack
);
1997 /* Hook it to the objfile it comes from */
1999 symtab
->objfile
= objfile
;
2000 symtab
->next
= objfile
->symtabs
;
2001 objfile
->symtabs
= symtab
;
2003 /* FIXME: This should go away. It is only defined for the Z8000,
2004 and the Z8000 definition of this macro doesn't have anything to
2005 do with the now-nonexistent EXTRA_SYMTAB_INFO macro, it's just
2006 here for convenience. */
2007 #ifdef INIT_EXTRA_SYMTAB_INFO
2008 INIT_EXTRA_SYMTAB_INFO (symtab
);
2014 struct partial_symtab
*
2015 allocate_psymtab (filename
, objfile
)
2017 struct objfile
*objfile
;
2019 struct partial_symtab
*psymtab
;
2021 if (objfile
->free_psymtabs
)
2023 psymtab
= objfile
->free_psymtabs
;
2024 objfile
->free_psymtabs
= psymtab
->next
;
2027 psymtab
= (struct partial_symtab
*)
2028 obstack_alloc (&objfile
->psymbol_obstack
,
2029 sizeof (struct partial_symtab
));
2031 memset (psymtab
, 0, sizeof (struct partial_symtab
));
2032 psymtab
->filename
= obsavestring (filename
, strlen (filename
),
2033 &objfile
->psymbol_obstack
);
2034 psymtab
->symtab
= NULL
;
2036 /* Prepend it to the psymtab list for the objfile it belongs to.
2037 Psymtabs are searched in most recent inserted -> least recent
2040 psymtab
->objfile
= objfile
;
2041 psymtab
->next
= objfile
->psymtabs
;
2042 objfile
->psymtabs
= psymtab
;
2045 struct partial_symtab
**prev_pst
;
2046 psymtab
->objfile
= objfile
;
2047 psymtab
->next
= NULL
;
2048 prev_pst
= &(objfile
->psymtabs
);
2049 while ((*prev_pst
) != NULL
)
2050 prev_pst
= &((*prev_pst
)->next
);
2051 (*prev_pst
) = psymtab
;
2059 discard_psymtab (pst
)
2060 struct partial_symtab
*pst
;
2062 struct partial_symtab
**prev_pst
;
2065 Empty psymtabs happen as a result of header files which don't
2066 have any symbols in them. There can be a lot of them. But this
2067 check is wrong, in that a psymtab with N_SLINE entries but
2068 nothing else is not empty, but we don't realize that. Fixing
2069 that without slowing things down might be tricky. */
2071 /* First, snip it out of the psymtab chain */
2073 prev_pst
= &(pst
->objfile
->psymtabs
);
2074 while ((*prev_pst
) != pst
)
2075 prev_pst
= &((*prev_pst
)->next
);
2076 (*prev_pst
) = pst
->next
;
2078 /* Next, put it on a free list for recycling */
2080 pst
->next
= pst
->objfile
->free_psymtabs
;
2081 pst
->objfile
->free_psymtabs
= pst
;
2085 /* Reset all data structures in gdb which may contain references to symbol
2089 clear_symtab_users ()
2091 /* Someday, we should do better than this, by only blowing away
2092 the things that really need to be blown. */
2093 clear_value_history ();
2095 clear_internalvars ();
2096 breakpoint_re_set ();
2097 set_default_breakpoint (0, 0, 0, 0);
2098 current_source_symtab
= 0;
2099 current_source_line
= 0;
2100 clear_pc_function_cache ();
2101 if (target_new_objfile_hook
)
2102 target_new_objfile_hook (NULL
);
2105 /* clear_symtab_users_once:
2107 This function is run after symbol reading, or from a cleanup.
2108 If an old symbol table was obsoleted, the old symbol table
2109 has been blown away, but the other GDB data structures that may
2110 reference it have not yet been cleared or re-directed. (The old
2111 symtab was zapped, and the cleanup queued, in free_named_symtab()
2114 This function can be queued N times as a cleanup, or called
2115 directly; it will do all the work the first time, and then will be a
2116 no-op until the next time it is queued. This works by bumping a
2117 counter at queueing time. Much later when the cleanup is run, or at
2118 the end of symbol processing (in case the cleanup is discarded), if
2119 the queued count is greater than the "done-count", we do the work
2120 and set the done-count to the queued count. If the queued count is
2121 less than or equal to the done-count, we just ignore the call. This
2122 is needed because reading a single .o file will often replace many
2123 symtabs (one per .h file, for example), and we don't want to reset
2124 the breakpoints N times in the user's face.
2126 The reason we both queue a cleanup, and call it directly after symbol
2127 reading, is because the cleanup protects us in case of errors, but is
2128 discarded if symbol reading is successful. */
2131 /* FIXME: As free_named_symtabs is currently a big noop this function
2132 is no longer needed. */
2134 clear_symtab_users_once
PARAMS ((void));
2136 static int clear_symtab_users_queued
;
2137 static int clear_symtab_users_done
;
2140 clear_symtab_users_once ()
2142 /* Enforce once-per-`do_cleanups'-semantics */
2143 if (clear_symtab_users_queued
<= clear_symtab_users_done
)
2145 clear_symtab_users_done
= clear_symtab_users_queued
;
2147 clear_symtab_users ();
2151 /* Delete the specified psymtab, and any others that reference it. */
2154 cashier_psymtab (pst
)
2155 struct partial_symtab
*pst
;
2157 struct partial_symtab
*ps
, *pprev
= NULL
;
2160 /* Find its previous psymtab in the chain */
2161 for (ps
= pst
->objfile
->psymtabs
; ps
; ps
= ps
->next
)
2170 /* Unhook it from the chain. */
2171 if (ps
== pst
->objfile
->psymtabs
)
2172 pst
->objfile
->psymtabs
= ps
->next
;
2174 pprev
->next
= ps
->next
;
2176 /* FIXME, we can't conveniently deallocate the entries in the
2177 partial_symbol lists (global_psymbols/static_psymbols) that
2178 this psymtab points to. These just take up space until all
2179 the psymtabs are reclaimed. Ditto the dependencies list and
2180 filename, which are all in the psymbol_obstack. */
2182 /* We need to cashier any psymtab that has this one as a dependency... */
2184 for (ps
= pst
->objfile
->psymtabs
; ps
; ps
= ps
->next
)
2186 for (i
= 0; i
< ps
->number_of_dependencies
; i
++)
2188 if (ps
->dependencies
[i
] == pst
)
2190 cashier_psymtab (ps
);
2191 goto again
; /* Must restart, chain has been munged. */
2198 /* If a symtab or psymtab for filename NAME is found, free it along
2199 with any dependent breakpoints, displays, etc.
2200 Used when loading new versions of object modules with the "add-file"
2201 command. This is only called on the top-level symtab or psymtab's name;
2202 it is not called for subsidiary files such as .h files.
2204 Return value is 1 if we blew away the environment, 0 if not.
2205 FIXME. The return valu appears to never be used.
2207 FIXME. I think this is not the best way to do this. We should
2208 work on being gentler to the environment while still cleaning up
2209 all stray pointers into the freed symtab. */
2212 free_named_symtabs (name
)
2216 /* FIXME: With the new method of each objfile having it's own
2217 psymtab list, this function needs serious rethinking. In particular,
2218 why was it ever necessary to toss psymtabs with specific compilation
2219 unit filenames, as opposed to all psymtabs from a particular symbol
2221 Well, the answer is that some systems permit reloading of particular
2222 compilation units. We want to blow away any old info about these
2223 compilation units, regardless of which objfiles they arrived in. --gnu. */
2225 register struct symtab
*s
;
2226 register struct symtab
*prev
;
2227 register struct partial_symtab
*ps
;
2228 struct blockvector
*bv
;
2231 /* We only wack things if the symbol-reload switch is set. */
2232 if (!symbol_reloading
)
2235 /* Some symbol formats have trouble providing file names... */
2236 if (name
== 0 || *name
== '\0')
2239 /* Look for a psymtab with the specified name. */
2242 for (ps
= partial_symtab_list
; ps
; ps
= ps
->next
)
2244 if (STREQ (name
, ps
->filename
))
2246 cashier_psymtab (ps
); /* Blow it away...and its little dog, too. */
2247 goto again2
; /* Must restart, chain has been munged */
2251 /* Look for a symtab with the specified name. */
2253 for (s
= symtab_list
; s
; s
= s
->next
)
2255 if (STREQ (name
, s
->filename
))
2262 if (s
== symtab_list
)
2263 symtab_list
= s
->next
;
2265 prev
->next
= s
->next
;
2267 /* For now, queue a delete for all breakpoints, displays, etc., whether
2268 or not they depend on the symtab being freed. This should be
2269 changed so that only those data structures affected are deleted. */
2271 /* But don't delete anything if the symtab is empty.
2272 This test is necessary due to a bug in "dbxread.c" that
2273 causes empty symtabs to be created for N_SO symbols that
2274 contain the pathname of the object file. (This problem
2275 has been fixed in GDB 3.9x). */
2277 bv
= BLOCKVECTOR (s
);
2278 if (BLOCKVECTOR_NBLOCKS (bv
) > 2
2279 || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
))
2280 || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)))
2282 complain (&oldsyms_complaint
, name
);
2284 clear_symtab_users_queued
++;
2285 make_cleanup (clear_symtab_users_once
, 0);
2290 complain (&empty_symtab_complaint
, name
);
2297 /* It is still possible that some breakpoints will be affected
2298 even though no symtab was found, since the file might have
2299 been compiled without debugging, and hence not be associated
2300 with a symtab. In order to handle this correctly, we would need
2301 to keep a list of text address ranges for undebuggable files.
2302 For now, we do nothing, since this is a fairly obscure case. */
2306 /* FIXME, what about the minimal symbol table? */
2313 /* Allocate and partially fill a partial symtab. It will be
2314 completely filled at the end of the symbol list.
2316 FILENAME is the name of the symbol-file we are reading from. */
2318 struct partial_symtab
*
2319 start_psymtab_common (objfile
, section_offsets
,
2320 filename
, textlow
, global_syms
, static_syms
)
2321 struct objfile
*objfile
;
2322 struct section_offsets
*section_offsets
;
2325 struct partial_symbol
**global_syms
;
2326 struct partial_symbol
**static_syms
;
2328 struct partial_symtab
*psymtab
;
2330 psymtab
= allocate_psymtab (filename
, objfile
);
2331 psymtab
->section_offsets
= section_offsets
;
2332 psymtab
->textlow
= textlow
;
2333 psymtab
->texthigh
= psymtab
->textlow
; /* default */
2334 psymtab
->globals_offset
= global_syms
- objfile
->global_psymbols
.list
;
2335 psymtab
->statics_offset
= static_syms
- objfile
->static_psymbols
.list
;
2339 /* Add a symbol with a long value to a psymtab.
2340 Since one arg is a struct, we pass in a ptr and deref it (sigh). */
2343 add_psymbol_to_list (name
, namelength
, namespace, class, list
, val
, coreaddr
,
2347 namespace_enum
namespace;
2348 enum address_class
class;
2349 struct psymbol_allocation_list
*list
;
2350 long val
; /* Value as a long */
2351 CORE_ADDR coreaddr
; /* Value as a CORE_ADDR */
2352 enum language language
;
2353 struct objfile
*objfile
;
2355 register struct partial_symbol
*psym
;
2356 char *buf
= alloca (namelength
+ 1);
2357 /* psymbol is static so that there will be no uninitialized gaps in the
2358 structure which might contain random data, causing cache misses in
2360 static struct partial_symbol psymbol
;
2362 /* Create local copy of the partial symbol */
2363 memcpy (buf
, name
, namelength
);
2364 buf
[namelength
] = '\0';
2365 SYMBOL_NAME (&psymbol
) = bcache (buf
, namelength
+ 1, &objfile
->psymbol_cache
);
2366 /* val and coreaddr are mutually exclusive, one of them *will* be zero */
2369 SYMBOL_VALUE (&psymbol
) = val
;
2373 SYMBOL_VALUE_ADDRESS (&psymbol
) = coreaddr
;
2375 SYMBOL_SECTION (&psymbol
) = 0;
2376 SYMBOL_LANGUAGE (&psymbol
) = language
;
2377 PSYMBOL_NAMESPACE (&psymbol
) = namespace;
2378 PSYMBOL_CLASS (&psymbol
) = class;
2379 SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol
, language
);
2381 /* Stash the partial symbol away in the cache */
2382 psym
= bcache (&psymbol
, sizeof (struct partial_symbol
), &objfile
->psymbol_cache
);
2384 /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
2385 if (list
->next
>= list
->list
+ list
->size
)
2387 extend_psymbol_list (list
, objfile
);
2389 *list
->next
++ = psym
;
2390 OBJSTAT (objfile
, n_psyms
++);
2393 /* Add a symbol with a long value to a psymtab. This differs from
2394 * add_psymbol_to_list above in taking both a mangled and a demangled
2398 add_psymbol_with_dem_name_to_list (name
, namelength
, dem_name
, dem_namelength
,
2399 namespace, class, list
, val
, coreaddr
, language
, objfile
)
2404 namespace_enum
namespace;
2405 enum address_class
class;
2406 struct psymbol_allocation_list
*list
;
2407 long val
; /* Value as a long */
2408 CORE_ADDR coreaddr
; /* Value as a CORE_ADDR */
2409 enum language language
;
2410 struct objfile
*objfile
;
2412 register struct partial_symbol
*psym
;
2413 char *buf
= alloca (namelength
+ 1);
2414 /* psymbol is static so that there will be no uninitialized gaps in the
2415 structure which might contain random data, causing cache misses in
2417 static struct partial_symbol psymbol
;
2419 /* Create local copy of the partial symbol */
2421 memcpy (buf
, name
, namelength
);
2422 buf
[namelength
] = '\0';
2423 SYMBOL_NAME (&psymbol
) = bcache (buf
, namelength
+ 1, &objfile
->psymbol_cache
);
2425 buf
= alloca (dem_namelength
+ 1);
2426 memcpy (buf
, dem_name
, dem_namelength
);
2427 buf
[dem_namelength
] = '\0';
2432 case language_cplus
:
2433 SYMBOL_CPLUS_DEMANGLED_NAME (&psymbol
) =
2434 bcache (buf
, dem_namelength
+ 1, &objfile
->psymbol_cache
);
2436 case language_chill
:
2437 SYMBOL_CHILL_DEMANGLED_NAME (&psymbol
) =
2438 bcache (buf
, dem_namelength
+ 1, &objfile
->psymbol_cache
);
2440 /* FIXME What should be done for the default case? Ignoring for now. */
2443 /* val and coreaddr are mutually exclusive, one of them *will* be zero */
2446 SYMBOL_VALUE (&psymbol
) = val
;
2450 SYMBOL_VALUE_ADDRESS (&psymbol
) = coreaddr
;
2452 SYMBOL_SECTION (&psymbol
) = 0;
2453 SYMBOL_LANGUAGE (&psymbol
) = language
;
2454 PSYMBOL_NAMESPACE (&psymbol
) = namespace;
2455 PSYMBOL_CLASS (&psymbol
) = class;
2456 SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol
, language
);
2458 /* Stash the partial symbol away in the cache */
2459 psym
= bcache (&psymbol
, sizeof (struct partial_symbol
), &objfile
->psymbol_cache
);
2461 /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
2462 if (list
->next
>= list
->list
+ list
->size
)
2464 extend_psymbol_list (list
, objfile
);
2466 *list
->next
++ = psym
;
2467 OBJSTAT (objfile
, n_psyms
++);
2470 /* Initialize storage for partial symbols. */
2473 init_psymbol_list (objfile
, total_symbols
)
2474 struct objfile
*objfile
;
2477 /* Free any previously allocated psymbol lists. */
2479 if (objfile
->global_psymbols
.list
)
2481 mfree (objfile
->md
, (PTR
) objfile
->global_psymbols
.list
);
2483 if (objfile
->static_psymbols
.list
)
2485 mfree (objfile
->md
, (PTR
) objfile
->static_psymbols
.list
);
2488 /* Current best guess is that approximately a twentieth
2489 of the total symbols (in a debugging file) are global or static
2492 objfile
->global_psymbols
.size
= total_symbols
/ 10;
2493 objfile
->static_psymbols
.size
= total_symbols
/ 10;
2495 if (objfile
->global_psymbols
.size
> 0)
2497 objfile
->global_psymbols
.next
=
2498 objfile
->global_psymbols
.list
= (struct partial_symbol
**)
2499 xmmalloc (objfile
->md
, (objfile
->global_psymbols
.size
2500 * sizeof (struct partial_symbol
*)));
2502 if (objfile
->static_psymbols
.size
> 0)
2504 objfile
->static_psymbols
.next
=
2505 objfile
->static_psymbols
.list
= (struct partial_symbol
**)
2506 xmmalloc (objfile
->md
, (objfile
->static_psymbols
.size
2507 * sizeof (struct partial_symbol
*)));
2512 The following code implements an abstraction for debugging overlay sections.
2514 The target model is as follows:
2515 1) The gnu linker will permit multiple sections to be mapped into the
2516 same VMA, each with its own unique LMA (or load address).
2517 2) It is assumed that some runtime mechanism exists for mapping the
2518 sections, one by one, from the load address into the VMA address.
2519 3) This code provides a mechanism for gdb to keep track of which
2520 sections should be considered to be mapped from the VMA to the LMA.
2521 This information is used for symbol lookup, and memory read/write.
2522 For instance, if a section has been mapped then its contents
2523 should be read from the VMA, otherwise from the LMA.
2525 Two levels of debugger support for overlays are available. One is
2526 "manual", in which the debugger relies on the user to tell it which
2527 overlays are currently mapped. This level of support is
2528 implemented entirely in the core debugger, and the information about
2529 whether a section is mapped is kept in the objfile->obj_section table.
2531 The second level of support is "automatic", and is only available if
2532 the target-specific code provides functionality to read the target's
2533 overlay mapping table, and translate its contents for the debugger
2534 (by updating the mapped state information in the obj_section tables).
2536 The interface is as follows:
2538 overlay map <name> -- tell gdb to consider this section mapped
2539 overlay unmap <name> -- tell gdb to consider this section unmapped
2540 overlay list -- list the sections that GDB thinks are mapped
2541 overlay read-target -- get the target's state of what's mapped
2542 overlay off/manual/auto -- set overlay debugging state
2543 Functional interface:
2544 find_pc_mapped_section(pc): if the pc is in the range of a mapped
2545 section, return that section.
2546 find_pc_overlay(pc): find any overlay section that contains
2547 the pc, either in its VMA or its LMA
2548 overlay_is_mapped(sect): true if overlay is marked as mapped
2549 section_is_overlay(sect): true if section's VMA != LMA
2550 pc_in_mapped_range(pc,sec): true if pc belongs to section's VMA
2551 pc_in_unmapped_range(...): true if pc belongs to section's LMA
2552 overlay_mapped_address(...): map an address from section's LMA to VMA
2553 overlay_unmapped_address(...): map an address from section's VMA to LMA
2554 symbol_overlayed_address(...): Return a "current" address for symbol:
2555 either in VMA or LMA depending on whether
2556 the symbol's section is currently mapped
2559 /* Overlay debugging state: */
2561 int overlay_debugging
= 0; /* 0 == off, 1 == manual, -1 == auto */
2562 int overlay_cache_invalid
= 0; /* True if need to refresh mapped state */
2564 /* Target vector for refreshing overlay mapped state */
2565 static void simple_overlay_update
PARAMS ((struct obj_section
*));
2566 void (*target_overlay_update
) PARAMS ((struct obj_section
*))
2567 = simple_overlay_update
;
2569 /* Function: section_is_overlay (SECTION)
2570 Returns true if SECTION has VMA not equal to LMA, ie.
2571 SECTION is loaded at an address different from where it will "run". */
2574 section_is_overlay (section
)
2577 if (overlay_debugging
)
2578 if (section
&& section
->lma
!= 0 &&
2579 section
->vma
!= section
->lma
)
2585 /* Function: overlay_invalidate_all (void)
2586 Invalidate the mapped state of all overlay sections (mark it as stale). */
2589 overlay_invalidate_all ()
2591 struct objfile
*objfile
;
2592 struct obj_section
*sect
;
2594 ALL_OBJSECTIONS (objfile
, sect
)
2595 if (section_is_overlay (sect
->the_bfd_section
))
2596 sect
->ovly_mapped
= -1;
2599 /* Function: overlay_is_mapped (SECTION)
2600 Returns true if section is an overlay, and is currently mapped.
2601 Private: public access is thru function section_is_mapped.
2603 Access to the ovly_mapped flag is restricted to this function, so
2604 that we can do automatic update. If the global flag
2605 OVERLAY_CACHE_INVALID is set (by wait_for_inferior), then call
2606 overlay_invalidate_all. If the mapped state of the particular
2607 section is stale, then call TARGET_OVERLAY_UPDATE to refresh it. */
2610 overlay_is_mapped (osect
)
2611 struct obj_section
*osect
;
2613 if (osect
== 0 || !section_is_overlay (osect
->the_bfd_section
))
2616 switch (overlay_debugging
)
2620 return 0; /* overlay debugging off */
2621 case -1: /* overlay debugging automatic */
2622 /* Unles there is a target_overlay_update function,
2623 there's really nothing useful to do here (can't really go auto) */
2624 if (target_overlay_update
)
2626 if (overlay_cache_invalid
)
2628 overlay_invalidate_all ();
2629 overlay_cache_invalid
= 0;
2631 if (osect
->ovly_mapped
== -1)
2632 (*target_overlay_update
) (osect
);
2634 /* fall thru to manual case */
2635 case 1: /* overlay debugging manual */
2636 return osect
->ovly_mapped
== 1;
2640 /* Function: section_is_mapped
2641 Returns true if section is an overlay, and is currently mapped. */
2644 section_is_mapped (section
)
2647 struct objfile
*objfile
;
2648 struct obj_section
*osect
;
2650 if (overlay_debugging
)
2651 if (section
&& section_is_overlay (section
))
2652 ALL_OBJSECTIONS (objfile
, osect
)
2653 if (osect
->the_bfd_section
== section
)
2654 return overlay_is_mapped (osect
);
2659 /* Function: pc_in_unmapped_range
2660 If PC falls into the lma range of SECTION, return true, else false. */
2663 pc_in_unmapped_range (pc
, section
)
2669 if (overlay_debugging
)
2670 if (section
&& section_is_overlay (section
))
2672 size
= bfd_get_section_size_before_reloc (section
);
2673 if (section
->lma
<= pc
&& pc
< section
->lma
+ size
)
2679 /* Function: pc_in_mapped_range
2680 If PC falls into the vma range of SECTION, return true, else false. */
2683 pc_in_mapped_range (pc
, section
)
2689 if (overlay_debugging
)
2690 if (section
&& section_is_overlay (section
))
2692 size
= bfd_get_section_size_before_reloc (section
);
2693 if (section
->vma
<= pc
&& pc
< section
->vma
+ size
)
2699 /* Function: overlay_unmapped_address (PC, SECTION)
2700 Returns the address corresponding to PC in the unmapped (load) range.
2701 May be the same as PC. */
2704 overlay_unmapped_address (pc
, section
)
2708 if (overlay_debugging
)
2709 if (section
&& section_is_overlay (section
) &&
2710 pc_in_mapped_range (pc
, section
))
2711 return pc
+ section
->lma
- section
->vma
;
2716 /* Function: overlay_mapped_address (PC, SECTION)
2717 Returns the address corresponding to PC in the mapped (runtime) range.
2718 May be the same as PC. */
2721 overlay_mapped_address (pc
, section
)
2725 if (overlay_debugging
)
2726 if (section
&& section_is_overlay (section
) &&
2727 pc_in_unmapped_range (pc
, section
))
2728 return pc
+ section
->vma
- section
->lma
;
2734 /* Function: symbol_overlayed_address
2735 Return one of two addresses (relative to the VMA or to the LMA),
2736 depending on whether the section is mapped or not. */
2739 symbol_overlayed_address (address
, section
)
2743 if (overlay_debugging
)
2745 /* If the symbol has no section, just return its regular address. */
2748 /* If the symbol's section is not an overlay, just return its address */
2749 if (!section_is_overlay (section
))
2751 /* If the symbol's section is mapped, just return its address */
2752 if (section_is_mapped (section
))
2755 * HOWEVER: if the symbol is in an overlay section which is NOT mapped,
2756 * then return its LOADED address rather than its vma address!!
2758 return overlay_unmapped_address (address
, section
);
2763 /* Function: find_pc_overlay (PC)
2764 Return the best-match overlay section for PC:
2765 If PC matches a mapped overlay section's VMA, return that section.
2766 Else if PC matches an unmapped section's VMA, return that section.
2767 Else if PC matches an unmapped section's LMA, return that section. */
2770 find_pc_overlay (pc
)
2773 struct objfile
*objfile
;
2774 struct obj_section
*osect
, *best_match
= NULL
;
2776 if (overlay_debugging
)
2777 ALL_OBJSECTIONS (objfile
, osect
)
2778 if (section_is_overlay (osect
->the_bfd_section
))
2780 if (pc_in_mapped_range (pc
, osect
->the_bfd_section
))
2782 if (overlay_is_mapped (osect
))
2783 return osect
->the_bfd_section
;
2787 else if (pc_in_unmapped_range (pc
, osect
->the_bfd_section
))
2790 return best_match
? best_match
->the_bfd_section
: NULL
;
2793 /* Function: find_pc_mapped_section (PC)
2794 If PC falls into the VMA address range of an overlay section that is
2795 currently marked as MAPPED, return that section. Else return NULL. */
2798 find_pc_mapped_section (pc
)
2801 struct objfile
*objfile
;
2802 struct obj_section
*osect
;
2804 if (overlay_debugging
)
2805 ALL_OBJSECTIONS (objfile
, osect
)
2806 if (pc_in_mapped_range (pc
, osect
->the_bfd_section
) &&
2807 overlay_is_mapped (osect
))
2808 return osect
->the_bfd_section
;
2813 /* Function: list_overlays_command
2814 Print a list of mapped sections and their PC ranges */
2817 list_overlays_command (args
, from_tty
)
2822 struct objfile
*objfile
;
2823 struct obj_section
*osect
;
2825 if (overlay_debugging
)
2826 ALL_OBJSECTIONS (objfile
, osect
)
2827 if (overlay_is_mapped (osect
))
2833 vma
= bfd_section_vma (objfile
->obfd
, osect
->the_bfd_section
);
2834 lma
= bfd_section_lma (objfile
->obfd
, osect
->the_bfd_section
);
2835 size
= bfd_get_section_size_before_reloc (osect
->the_bfd_section
);
2836 name
= bfd_section_name (objfile
->obfd
, osect
->the_bfd_section
);
2838 printf_filtered ("Section %s, loaded at ", name
);
2839 print_address_numeric (lma
, 1, gdb_stdout
);
2840 puts_filtered (" - ");
2841 print_address_numeric (lma
+ size
, 1, gdb_stdout
);
2842 printf_filtered (", mapped at ");
2843 print_address_numeric (vma
, 1, gdb_stdout
);
2844 puts_filtered (" - ");
2845 print_address_numeric (vma
+ size
, 1, gdb_stdout
);
2846 puts_filtered ("\n");
2851 printf_filtered ("No sections are mapped.\n");
2854 /* Function: map_overlay_command
2855 Mark the named section as mapped (ie. residing at its VMA address). */
2858 map_overlay_command (args
, from_tty
)
2862 struct objfile
*objfile
, *objfile2
;
2863 struct obj_section
*sec
, *sec2
;
2866 if (!overlay_debugging
)
2867 error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
2869 if (args
== 0 || *args
== 0)
2870 error ("Argument required: name of an overlay section");
2872 /* First, find a section matching the user supplied argument */
2873 ALL_OBJSECTIONS (objfile
, sec
)
2874 if (!strcmp (bfd_section_name (objfile
->obfd
, sec
->the_bfd_section
), args
))
2876 /* Now, check to see if the section is an overlay. */
2877 bfdsec
= sec
->the_bfd_section
;
2878 if (!section_is_overlay (bfdsec
))
2879 continue; /* not an overlay section */
2881 /* Mark the overlay as "mapped" */
2882 sec
->ovly_mapped
= 1;
2884 /* Next, make a pass and unmap any sections that are
2885 overlapped by this new section: */
2886 ALL_OBJSECTIONS (objfile2
, sec2
)
2887 if (sec2
->ovly_mapped
&&
2889 sec
->the_bfd_section
!= sec2
->the_bfd_section
&&
2890 (pc_in_mapped_range (sec2
->addr
, sec
->the_bfd_section
) ||
2891 pc_in_mapped_range (sec2
->endaddr
, sec
->the_bfd_section
)))
2894 printf_filtered ("Note: section %s unmapped by overlap\n",
2895 bfd_section_name (objfile
->obfd
,
2896 sec2
->the_bfd_section
));
2897 sec2
->ovly_mapped
= 0; /* sec2 overlaps sec: unmap sec2 */
2901 error ("No overlay section called %s", args
);
2904 /* Function: unmap_overlay_command
2905 Mark the overlay section as unmapped
2906 (ie. resident in its LMA address range, rather than the VMA range). */
2909 unmap_overlay_command (args
, from_tty
)
2913 struct objfile
*objfile
;
2914 struct obj_section
*sec
;
2916 if (!overlay_debugging
)
2917 error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
2919 if (args
== 0 || *args
== 0)
2920 error ("Argument required: name of an overlay section");
2922 /* First, find a section matching the user supplied argument */
2923 ALL_OBJSECTIONS (objfile
, sec
)
2924 if (!strcmp (bfd_section_name (objfile
->obfd
, sec
->the_bfd_section
), args
))
2926 if (!sec
->ovly_mapped
)
2927 error ("Section %s is not mapped", args
);
2928 sec
->ovly_mapped
= 0;
2931 error ("No overlay section called %s", args
);
2934 /* Function: overlay_auto_command
2935 A utility command to turn on overlay debugging.
2936 Possibly this should be done via a set/show command. */
2939 overlay_auto_command (args
, from_tty
)
2943 overlay_debugging
= -1;
2945 printf_filtered ("Automatic overlay debugging enabled.");
2948 /* Function: overlay_manual_command
2949 A utility command to turn on overlay debugging.
2950 Possibly this should be done via a set/show command. */
2953 overlay_manual_command (args
, from_tty
)
2957 overlay_debugging
= 1;
2959 printf_filtered ("Overlay debugging enabled.");
2962 /* Function: overlay_off_command
2963 A utility command to turn on overlay debugging.
2964 Possibly this should be done via a set/show command. */
2967 overlay_off_command (args
, from_tty
)
2971 overlay_debugging
= 0;
2973 printf_filtered ("Overlay debugging disabled.");
2977 overlay_load_command (args
, from_tty
)
2981 if (target_overlay_update
)
2982 (*target_overlay_update
) (NULL
);
2984 error ("This target does not know how to read its overlay state.");
2987 /* Function: overlay_command
2988 A place-holder for a mis-typed command */
2990 /* Command list chain containing all defined "overlay" subcommands. */
2991 struct cmd_list_element
*overlaylist
;
2994 overlay_command (args
, from_tty
)
2999 ("\"overlay\" must be followed by the name of an overlay command.\n");
3000 help_list (overlaylist
, "overlay ", -1, gdb_stdout
);
3004 /* Target Overlays for the "Simplest" overlay manager:
3006 This is GDB's default target overlay layer. It works with the
3007 minimal overlay manager supplied as an example by Cygnus. The
3008 entry point is via a function pointer "target_overlay_update",
3009 so targets that use a different runtime overlay manager can
3010 substitute their own overlay_update function and take over the
3013 The overlay_update function pokes around in the target's data structures
3014 to see what overlays are mapped, and updates GDB's overlay mapping with
3017 In this simple implementation, the target data structures are as follows:
3018 unsigned _novlys; /# number of overlay sections #/
3019 unsigned _ovly_table[_novlys][4] = {
3020 {VMA, SIZE, LMA, MAPPED}, /# one entry per overlay section #/
3021 {..., ..., ..., ...},
3023 unsigned _novly_regions; /# number of overlay regions #/
3024 unsigned _ovly_region_table[_novly_regions][3] = {
3025 {VMA, SIZE, MAPPED_TO_LMA}, /# one entry per overlay region #/
3028 These functions will attempt to update GDB's mappedness state in the
3029 symbol section table, based on the target's mappedness state.
3031 To do this, we keep a cached copy of the target's _ovly_table, and
3032 attempt to detect when the cached copy is invalidated. The main
3033 entry point is "simple_overlay_update(SECT), which looks up SECT in
3034 the cached table and re-reads only the entry for that section from
3035 the target (whenever possible).
3038 /* Cached, dynamically allocated copies of the target data structures: */
3039 static unsigned (*cache_ovly_table
)[4] = 0;
3041 static unsigned (*cache_ovly_region_table
)[3] = 0;
3043 static unsigned cache_novlys
= 0;
3045 static unsigned cache_novly_regions
= 0;
3047 static CORE_ADDR cache_ovly_table_base
= 0;
3049 static CORE_ADDR cache_ovly_region_table_base
= 0;
3053 VMA
, SIZE
, LMA
, MAPPED
3055 #define TARGET_LONG_BYTES (TARGET_LONG_BIT / TARGET_CHAR_BIT)
3057 /* Throw away the cached copy of _ovly_table */
3059 simple_free_overlay_table ()
3061 if (cache_ovly_table
)
3062 free (cache_ovly_table
);
3064 cache_ovly_table
= NULL
;
3065 cache_ovly_table_base
= 0;
3069 /* Throw away the cached copy of _ovly_region_table */
3071 simple_free_overlay_region_table ()
3073 if (cache_ovly_region_table
)
3074 free (cache_ovly_region_table
);
3075 cache_novly_regions
= 0;
3076 cache_ovly_region_table
= NULL
;
3077 cache_ovly_region_table_base
= 0;
3081 /* Read an array of ints from the target into a local buffer.
3082 Convert to host order. int LEN is number of ints */
3084 read_target_long_array (memaddr
, myaddr
, len
)
3086 unsigned int *myaddr
;
3089 char *buf
= alloca (len
* TARGET_LONG_BYTES
);
3092 read_memory (memaddr
, buf
, len
* TARGET_LONG_BYTES
);
3093 for (i
= 0; i
< len
; i
++)
3094 myaddr
[i
] = extract_unsigned_integer (TARGET_LONG_BYTES
* i
+ buf
,
3098 /* Find and grab a copy of the target _ovly_table
3099 (and _novlys, which is needed for the table's size) */
3101 simple_read_overlay_table ()
3103 struct minimal_symbol
*msym
;
3105 simple_free_overlay_table ();
3106 msym
= lookup_minimal_symbol ("_novlys", 0, 0);
3108 cache_novlys
= read_memory_integer (SYMBOL_VALUE_ADDRESS (msym
), 4);
3110 return 0; /* failure */
3111 cache_ovly_table
= (void *) xmalloc (cache_novlys
* sizeof (*cache_ovly_table
));
3112 if (cache_ovly_table
!= NULL
)
3114 msym
= lookup_minimal_symbol ("_ovly_table", 0, 0);
3117 cache_ovly_table_base
= SYMBOL_VALUE_ADDRESS (msym
);
3118 read_target_long_array (cache_ovly_table_base
,
3119 (int *) cache_ovly_table
,
3123 return 0; /* failure */
3126 return 0; /* failure */
3127 return 1; /* SUCCESS */
3131 /* Find and grab a copy of the target _ovly_region_table
3132 (and _novly_regions, which is needed for the table's size) */
3134 simple_read_overlay_region_table ()
3136 struct minimal_symbol
*msym
;
3138 simple_free_overlay_region_table ();
3139 msym
= lookup_minimal_symbol ("_novly_regions", 0, 0);
3141 cache_novly_regions
= read_memory_integer (SYMBOL_VALUE_ADDRESS (msym
), 4);
3143 return 0; /* failure */
3144 cache_ovly_region_table
= (void *) xmalloc (cache_novly_regions
* 12);
3145 if (cache_ovly_region_table
!= NULL
)
3147 msym
= lookup_minimal_symbol ("_ovly_region_table", 0, 0);
3150 cache_ovly_region_table_base
= SYMBOL_VALUE_ADDRESS (msym
);
3151 read_target_long_array (cache_ovly_region_table_base
,
3152 (int *) cache_ovly_region_table
,
3153 cache_novly_regions
* 3);
3156 return 0; /* failure */
3159 return 0; /* failure */
3160 return 1; /* SUCCESS */
3164 /* Function: simple_overlay_update_1
3165 A helper function for simple_overlay_update. Assuming a cached copy
3166 of _ovly_table exists, look through it to find an entry whose vma,
3167 lma and size match those of OSECT. Re-read the entry and make sure
3168 it still matches OSECT (else the table may no longer be valid).
3169 Set OSECT's mapped state to match the entry. Return: 1 for
3170 success, 0 for failure. */
3173 simple_overlay_update_1 (osect
)
3174 struct obj_section
*osect
;
3178 size
= bfd_get_section_size_before_reloc (osect
->the_bfd_section
);
3179 for (i
= 0; i
< cache_novlys
; i
++)
3180 if (cache_ovly_table
[i
][VMA
] == osect
->the_bfd_section
->vma
&&
3181 cache_ovly_table
[i
][LMA
] == osect
->the_bfd_section
->lma
/* &&
3182 cache_ovly_table[i][SIZE] == size */ )
3184 read_target_long_array (cache_ovly_table_base
+ i
* TARGET_LONG_BYTES
,
3185 (int *) cache_ovly_table
[i
], 4);
3186 if (cache_ovly_table
[i
][VMA
] == osect
->the_bfd_section
->vma
&&
3187 cache_ovly_table
[i
][LMA
] == osect
->the_bfd_section
->lma
/* &&
3188 cache_ovly_table[i][SIZE] == size */ )
3190 osect
->ovly_mapped
= cache_ovly_table
[i
][MAPPED
];
3193 else /* Warning! Warning! Target's ovly table has changed! */
3199 /* Function: simple_overlay_update
3200 If OSECT is NULL, then update all sections' mapped state
3201 (after re-reading the entire target _ovly_table).
3202 If OSECT is non-NULL, then try to find a matching entry in the
3203 cached ovly_table and update only OSECT's mapped state.
3204 If a cached entry can't be found or the cache isn't valid, then
3205 re-read the entire cache, and go ahead and update all sections. */
3208 simple_overlay_update (osect
)
3209 struct obj_section
*osect
;
3211 struct objfile
*objfile
;
3213 /* Were we given an osect to look up? NULL means do all of them. */
3215 /* Have we got a cached copy of the target's overlay table? */
3216 if (cache_ovly_table
!= NULL
)
3217 /* Does its cached location match what's currently in the symtab? */
3218 if (cache_ovly_table_base
==
3219 SYMBOL_VALUE_ADDRESS (lookup_minimal_symbol ("_ovly_table", 0, 0)))
3220 /* Then go ahead and try to look up this single section in the cache */
3221 if (simple_overlay_update_1 (osect
))
3222 /* Found it! We're done. */
3225 /* Cached table no good: need to read the entire table anew.
3226 Or else we want all the sections, in which case it's actually
3227 more efficient to read the whole table in one block anyway. */
3229 if (simple_read_overlay_table () == 0) /* read failed? No table? */
3231 warning ("Failed to read the target overlay mapping table.");
3234 /* Now may as well update all sections, even if only one was requested. */
3235 ALL_OBJSECTIONS (objfile
, osect
)
3236 if (section_is_overlay (osect
->the_bfd_section
))
3240 size
= bfd_get_section_size_before_reloc (osect
->the_bfd_section
);
3241 for (i
= 0; i
< cache_novlys
; i
++)
3242 if (cache_ovly_table
[i
][VMA
] == osect
->the_bfd_section
->vma
&&
3243 cache_ovly_table
[i
][LMA
] == osect
->the_bfd_section
->lma
/* &&
3244 cache_ovly_table[i][SIZE] == size */ )
3245 { /* obj_section matches i'th entry in ovly_table */
3246 osect
->ovly_mapped
= cache_ovly_table
[i
][MAPPED
];
3247 break; /* finished with inner for loop: break out */
3254 _initialize_symfile ()
3256 struct cmd_list_element
*c
;
3258 c
= add_cmd ("symbol-file", class_files
, symbol_file_command
,
3259 "Load symbol table from executable file FILE.\n\
3260 The `file' command can also load symbol tables, as well as setting the file\n\
3261 to execute.", &cmdlist
);
3262 c
->completer
= filename_completer
;
3264 c
= add_cmd ("add-symbol-file", class_files
, add_symbol_file_command
,
3265 "Usage: add-symbol-file FILE ADDR [DATA_ADDR [BSS_ADDR]]\n\
3266 or: add-symbol-file FILE -T<SECT> <SECT_ADDR> -T<SECT> <SECT_ADDR> ...\n\
3267 Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
3268 ADDR is the starting address of the file's text.\n\
3269 The optional arguments, DATA_ADDR and BSS_ADDR, should be specified\n\
3270 if the data and bss segments are not contiguous with the text.\n\
3271 For complicated cases, SECT is a section name to be loaded at SECT_ADDR.",
3273 c
->completer
= filename_completer
;
3275 c
= add_cmd ("add-shared-symbol-files", class_files
,
3276 add_shared_symbol_files_command
,
3277 "Load the symbols from shared objects in the dynamic linker's link map.",
3279 c
= add_alias_cmd ("assf", "add-shared-symbol-files", class_files
, 1,
3282 c
= add_cmd ("load", class_files
, load_command
,
3283 "Dynamically load FILE into the running program, and record its symbols\n\
3284 for access from GDB.", &cmdlist
);
3285 c
->completer
= filename_completer
;
3288 (add_set_cmd ("symbol-reloading", class_support
, var_boolean
,
3289 (char *) &symbol_reloading
,
3290 "Set dynamic symbol table reloading multiple times in one run.",
3294 add_prefix_cmd ("overlay", class_support
, overlay_command
,
3295 "Commands for debugging overlays.", &overlaylist
,
3296 "overlay ", 0, &cmdlist
);
3298 add_com_alias ("ovly", "overlay", class_alias
, 1);
3299 add_com_alias ("ov", "overlay", class_alias
, 1);
3301 add_cmd ("map-overlay", class_support
, map_overlay_command
,
3302 "Assert that an overlay section is mapped.", &overlaylist
);
3304 add_cmd ("unmap-overlay", class_support
, unmap_overlay_command
,
3305 "Assert that an overlay section is unmapped.", &overlaylist
);
3307 add_cmd ("list-overlays", class_support
, list_overlays_command
,
3308 "List mappings of overlay sections.", &overlaylist
);
3310 add_cmd ("manual", class_support
, overlay_manual_command
,
3311 "Enable overlay debugging.", &overlaylist
);
3312 add_cmd ("off", class_support
, overlay_off_command
,
3313 "Disable overlay debugging.", &overlaylist
);
3314 add_cmd ("auto", class_support
, overlay_auto_command
,
3315 "Enable automatic overlay debugging.", &overlaylist
);
3316 add_cmd ("load-target", class_support
, overlay_load_command
,
3317 "Read the overlay mapping state from the target.", &overlaylist
);
3319 /* Filename extension to source language lookup table: */
3320 init_filename_language_table ();
3321 c
= add_set_cmd ("extension-language", class_files
, var_string_noescape
,
3323 "Set mapping between filename extension and source language.\n\
3324 Usage: set extension-language .foo bar",
3326 c
->function
.cfunc
= set_ext_lang_command
;
3328 add_info ("extensions", info_ext_lang_command
,
3329 "All filename extensions associated with a source language.");
3332 (add_set_cmd ("download-write-size", class_obscure
,
3333 var_integer
, (char *) &download_write_size
,
3334 "Set the write size used when downloading a program.\n"
3335 "Only used when downloading a program onto a remote\n"
3336 "target. Specify zero, or a negative value, to disable\n"
3337 "blocked writes. The actual size of each transfer is also\n"
3338 "limited by the size of the target packet and the memory\n"