1 /* Read dbx symbol tables and convert to internal format, for GDB.
2 Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@mcc.com)
5 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
6 WARRANTY. No author or distributor accepts responsibility to anyone
7 for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing.
9 Refer to the GDB General Public License for full details.
11 Everyone is granted permission to copy, modify and redistribute GDB,
12 but only under the conditions described in the GDB General Public
13 License. A copy of this license is supposed to have been given to you
14 along with GDB so you can know your rights and responsibilities. It
15 should be in a file named COPYING. Among other things, the copyright
16 notice and this notice must be preserved on all copies.
18 In other words, go ahead and share GDB, but don't try to stop
19 anyone else from sharing it farther. Help stamp out software hoarding!
24 #ifdef READ_DBX_FORMAT
30 #include <sys/param.h>
33 #include "initialize.h"
36 static void add_symbol_to_list ();
37 static void read_dbx_symtab ();
38 static void process_one_symbol ();
39 static struct type *read_type ();
40 static struct type *read_range_type ();
41 static struct type *read_enum_type ();
42 static struct type *read_struct_type ();
43 static long read_number ();
44 static void finish_block ();
45 static struct blockvector *make_blockvector ();
46 static struct symbol *define_symbol ();
47 static void start_subfile ();
48 static int hashname ();
49 static void hash_symsegs ();
51 extern struct symtab *read_symsegs ();
52 extern void free_all_symtabs ();
55 static struct type **read_args ();
59 /* Chain of symtabs made from reading the file's symsegs.
60 These symtabs do not go into symtab_list themselves,
61 but the information is copied from them when appropriate
62 to make the symtabs that will exist permanently. */
64 static struct symtab *symseg_chain;
66 /* Symseg symbol table for the file whose data we are now processing.
67 It is one of those in symseg_chain. Or 0, for a compilation that
70 static struct symtab *current_symseg;
72 /* Name of source file whose symbol data we are now processing.
73 This comes from a symbol of type N_SO. */
75 static char *last_source_file;
77 /* Core address of start of text of current source file.
78 This too comes from the N_SO symbol. */
80 static CORE_ADDR last_source_start_addr;
82 /* End of the text segment of the executable file,
83 as found in the symbol _etext. */
85 static CORE_ADDR end_of_text_addr;
87 /* The list of sub-source-files within the current individual compilation.
88 Each file gets its own symtab with its own linetable and associated info,
89 but they all share one blockvector. */
95 struct linetable *line_vector;
96 int line_vector_length;
97 int line_vector_index;
101 static struct subfile *subfiles;
103 static struct subfile *current_subfile;
105 /* The addresses of the symbol table stream and the string table
106 of the object file we are reading (as copied into core). */
108 static FILE *nlist_stream_global;
109 static int nlist_size_global;
110 static char *stringtab_global;
112 /* The index in nlist_global of the last dbx symbol to be processed. */
116 /* Vector of types defined so far, indexed by their dbx type numbers.
117 (In newer sun systems, dbx uses a pair of numbers in parens,
118 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
119 translated through the type_translations hash table to get
120 the index into the type vector.) */
122 static struct typevector *type_vector;
124 /* Number of elements allocated for type_vector currently. */
126 static int type_vector_length;
128 /* Vector of line number information. */
130 static struct linetable *line_vector;
132 /* Index of next entry to go in line_vector_index. */
134 static int line_vector_index;
136 /* Last line number recorded in the line vector. */
138 static int prev_line_number;
140 /* Number of elements allocated for line_vector currently. */
142 static int line_vector_length;
144 /* Chain of global symbols whose values are not known yet.
145 They are chained thru the SYMBOL_VALUE, since we don't
146 have the correct data for that slot yet. */
149 static struct symbol *global_sym_chain[HASHSIZE];
151 /* Record the symbols defined for each context in a list.
152 We don't create a struct block for the context until we
153 know how long to make it. */
157 struct pending *next;
158 struct symbol *symbol;
161 /* Here are the three lists that symbols are put on. */
163 struct pending *file_symbols; /* static at top level, and types */
165 struct pending *global_symbols; /* global functions and variables */
167 struct pending *local_symbols; /* everything local to lexical context */
169 /* List of unclosed lexical contexts
170 (that will become blocks, eventually). */
174 struct context_stack *next;
175 struct pending *locals;
176 struct pending_block *old_blocks;
178 CORE_ADDR start_addr;
182 struct context_stack *context_stack;
184 /* Nonzero if within a function (so symbols should be local,
185 if nothing says specifically). */
189 /* List of blocks already made (lexical contexts already closed).
190 This is used at the end to make the blockvector. */
194 struct pending_block *next;
198 struct pending_block *pending_blocks;
200 extern CORE_ADDR first_object_file_end; /* From blockframe.c */
202 /* File name symbols were loaded from. */
204 static char *symfile;
206 /* Support for Sun changes to dbx symbol format */
208 /* For each identified header file, we have a table of types defined
211 header_files maps header file names to their type tables.
212 It is a vector of n_header_files elements.
213 Each element describes one header file.
214 It contains a vector of types.
216 Sometimes it can happen that the same header file produces
217 different results when included in different places.
218 This can result from conditionals or from different
219 things done before including the file.
220 When this happens, there are multiple entries for the file in this table,
221 one entry for each distinct set of results.
222 The entries are distinguished by the INSTANCE field.
223 The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is
224 used to match header-file references to their corresponding data. */
228 char *name; /* Name of header file */
229 int instance; /* Numeric code distinguishing instances
230 of one header file that produced
231 different results when included.
232 It comes from the N_BINCL or N_EXCL. */
233 struct type **vector; /* Pointer to vector of types */
234 int length; /* Allocated length (# elts) of that vector */
237 static struct header_file *header_files;
239 static int n_header_files;
241 static int n_allocated_header_files;
243 /* Within each object file, various header files are assigned numbers.
244 A type is defined or referred to with a pair of numbers
245 (FILENUM,TYPENUM) where FILENUM is the number of the header file
246 and TYPENUM is the number within that header file.
247 TYPENUM is the index within the vector of types for that header file.
249 FILENUM == 1 is special; it refers to the main source of the object file,
250 and not to any header file. FILENUM != 1 is interpreted by looking it up
251 in the following table, which contains indices in header_files. */
253 static int *this_object_header_files;
255 static int n_this_object_header_files;
257 static int n_allocated_this_object_header_files;
259 /* When a header file is getting special overriding definitions
260 for one source file, record here the header_files index
261 of its normal definition vector.
262 At other times, this is -1. */
264 static int header_file_prev_index;
266 /* At the start of reading dbx symbols, allocate our tables. */
271 n_allocated_header_files = 10;
272 header_files = (struct header_file *) xmalloc (10 * sizeof (struct header_file));
275 n_allocated_this_object_header_files = 10;
276 this_object_header_files = (int *) xmalloc (10 * sizeof (int));
279 /* At the end of reading dbx symbols, free our tables. */
285 for (i = 0; i < n_header_files; i++)
286 free (header_files[i].name);
288 free (this_object_header_files);
291 /* Called at the start of each object file's symbols.
292 Clear out the mapping of header file numbers to header files. */
295 new_object_header_files ()
297 /* Leave FILENUM of 0 free for builtin types and this file's types. */
298 n_this_object_header_files = 1;
299 header_file_prev_index = -1;
302 /* Add header file number I for this object file
303 at the next successive FILENUM. */
306 add_this_object_header_file (i)
309 if (n_this_object_header_files == n_allocated_this_object_header_files)
311 n_allocated_this_object_header_files *= 2;
312 this_object_header_files
313 = (int *) xrealloc (this_object_header_files,
314 n_allocated_this_object_header_files * sizeof (int));
317 this_object_header_files[n_this_object_header_files++] = i;
320 /* Add to this file an "old" header file, one already seen in
321 a previous object file. NAME is the header file's name.
322 INSTANCE is its instance code, to select among multiple
323 symbol tables for the same header file. */
326 add_old_header_file (name, instance)
330 register struct header_file *p = header_files;
333 for (i = 0; i < n_header_files; i++)
334 if (!strcmp (p[i].name, name) && instance == p[i].instance)
336 add_this_object_header_file (i);
339 error ("Invalid symbol data: \"repeated\" header file that hasn't been seen before, at symtab pos %d.",
343 /* Add to this file a "new" header file: definitions for its types follow.
344 NAME is the header file's name.
345 Most often this happens only once for each distinct header file,
346 but not necessarily. If it happens more than once, INSTANCE has
347 a different value each time, and references to the header file
348 use INSTANCE values to select among them.
350 dbx output contains "begin" and "end" markers for each new header file,
351 but at this level we just need to know which files there have been;
352 so we record the file when its "begin" is seen and ignore the "end". */
355 add_new_header_file (name, instance)
360 register struct header_file *p = header_files;
361 header_file_prev_index = -1;
364 /* This code was used before I knew about the instance codes.
365 My first hypothesis is that it is not necessary now
366 that instance codes are handled. */
368 /* Has this header file a previous definition?
369 If so, make a new entry anyway so that this use in this source file
370 gets a separate entry. Later source files get the old entry.
371 Record here the index of the old entry, so that any type indices
372 not previously defined can get defined in the old entry as
373 well as in the new one. */
375 for (i = 0; i < n_header_files; i++)
376 if (!strcmp (p[i].name, name))
378 header_file_prev_index = i;
383 /* Make sure there is room for one more header file. */
385 if (n_header_files == n_allocated_header_files)
387 n_allocated_header_files *= 2;
389 = (struct header_file *) xrealloc (header_files, n_allocated_header_files * sizeof (struct header_file));
392 /* Create an entry for this header file. */
394 i = n_header_files++;
395 header_files[i].name = name;
396 header_files[i].instance = instance;
397 header_files[i].length = 10;
398 header_files[i].vector
399 = (struct type **) xmalloc (10 * sizeof (struct type *));
400 bzero (header_files[i].vector, 10 * sizeof (struct type *));
402 add_this_object_header_file (i);
405 /* Look up a dbx type-number pair. Return the address of the slot
406 where the type for that number-pair is stored.
407 The number-pair is in TYPENUMS.
409 This can be used for finding the type associated with that pair
410 or for associating a new type with the pair. */
412 static struct type **
413 dbx_lookup_type (typenums)
416 register int filenum = typenums[0], index = typenums[1];
418 if (filenum < 0 || filenum >= n_this_object_header_files)
419 error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
420 filenum, index, symnum);
424 /* Type is defined outside of header files.
425 Find it in this object file's type vector. */
426 if (index >= type_vector_length)
428 type_vector_length *= 2;
429 type_vector = (struct typevector *)
430 xrealloc (type_vector, sizeof (struct typevector) + type_vector_length * sizeof (struct type *));
431 bzero (&type_vector->type[type_vector_length / 2],
432 type_vector_length * sizeof (struct type *) / 2);
434 return &type_vector->type[index];
438 register int real_filenum = this_object_header_files[filenum];
439 register struct header_file *f;
441 if (real_filenum >= n_header_files)
444 f = &header_files[real_filenum];
446 if (index >= f->length)
449 f->vector = (struct type **)
450 xrealloc (f->vector, f->length * sizeof (struct type *));
451 bzero (&f->vector[f->length / 2],
452 f->length * sizeof (struct type *) / 2);
454 return &f->vector[index];
458 /* Make sure there is a type allocated for type numbers TYPENUMS
459 and return the type object.
460 This can create an empty (zeroed) type object. */
463 dbx_alloc_type (typenums)
466 register struct type **type_addr = dbx_lookup_type (typenums);
467 register struct type *type = *type_addr;
469 /* If we are referring to a type not known at all yet,
470 allocate an empty type for it.
471 We will fill it in later if we find out how. */
474 type = (struct type *) obstack_alloc (symbol_obstack,
475 sizeof (struct type));
476 bzero (type, sizeof (struct type));
477 TYPE_VPTR_FIELDNO (type) = -1;
484 static struct type **
485 explicit_lookup_type (real_filenum, index)
486 int real_filenum, index;
488 register struct header_file *f = &header_files[real_filenum];
490 if (index >= f->length)
493 f->vector = (struct type **)
494 xrealloc (f->vector, f->length * sizeof (struct type *));
495 bzero (&f->vector[f->length / 2],
496 f->length * sizeof (struct type *) / 2);
498 return &f->vector[index];
502 /* maintain the lists of symbols and blocks */
504 /* Add a symbol to one of the lists of symbols. */
506 add_symbol_to_list (symbol, listhead)
507 struct symbol *symbol;
508 struct pending **listhead;
510 register struct pending *link
511 = (struct pending *) xmalloc (sizeof (struct pending));
513 link->next = *listhead;
514 link->symbol = symbol;
518 /* Take one of the lists of symbols and make a block from it.
519 Put the block on the list of pending blocks. */
522 finish_block (symbol, listhead, old_blocks, start, end)
523 struct symbol *symbol;
524 struct pending **listhead;
525 struct pending_block *old_blocks;
526 CORE_ADDR start, end;
528 register struct pending *next, *next1;
529 register struct block *block;
530 register struct pending_block *pblock;
531 struct pending_block *opblock;
534 /* Count the length of the list of symbols. */
536 for (next = *listhead, i = 0; next; next = next->next, i++);
538 block = (struct block *) obstack_alloc (symbol_obstack,
539 sizeof (struct block) + (i - 1) * sizeof (struct symbol *));
541 /* Copy the symbols into the block. */
543 BLOCK_NSYMS (block) = i;
544 for (next = *listhead; next; next = next->next)
545 BLOCK_SYM (block, --i) = next->symbol;
547 BLOCK_START (block) = start;
548 BLOCK_END (block) = end;
549 BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */
551 /* Put the block in as the value of the symbol that names it. */
555 SYMBOL_BLOCK_VALUE (symbol) = block;
556 BLOCK_FUNCTION (block) = symbol;
559 BLOCK_FUNCTION (block) = 0;
561 /* Now free the links of the list, and empty the list. */
563 for (next = *listhead; next; next = next1)
570 /* Install this block as the superblock
571 of all blocks made since the start of this scope
572 that don't have superblocks yet. */
575 for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next)
577 if (BLOCK_SUPERBLOCK (pblock->block) == 0)
578 BLOCK_SUPERBLOCK (pblock->block) = block;
582 /* Record this block on the list of all blocks in the file.
583 Put it after opblock, or at the beginning if opblock is 0.
584 This puts the block in the list after all its subblocks. */
586 pblock = (struct pending_block *) xmalloc (sizeof (struct pending_block));
587 pblock->block = block;
590 pblock->next = opblock->next;
591 opblock->next = pblock;
595 pblock->next = pending_blocks;
596 pending_blocks = pblock;
600 static struct blockvector *
603 register struct pending_block *next, *next1;
604 register struct blockvector *blockvector;
607 /* Count the length of the list of blocks. */
609 for (next = pending_blocks, i = 0; next; next = next->next, i++);
611 blockvector = (struct blockvector *) obstack_alloc (symbol_obstack, sizeof (struct blockvector) + (i - 1) * sizeof (struct block *));
613 /* Copy the blocks into the blockvector.
614 This is done in reverse order, which happens to put
615 the blocks into the proper order (ascending starting address).
616 finish_block has hair to insert each block into the list
617 after its subblocks in order to make sure this is true. */
619 BLOCKVECTOR_NBLOCKS (blockvector) = i;
620 for (next = pending_blocks; next; next = next->next)
621 BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
623 /* Now free the links of the list, and empty the list. */
625 for (next = pending_blocks; next; next = next1)
635 /* Manage the vector of line numbers. */
638 record_line (line, pc)
642 /* Ignore the dummy line number in libg.o */
647 /* Make sure line vector is big enough. */
649 if (line_vector_index + 1 >= line_vector_length)
651 line_vector_length *= 2;
652 line_vector = (struct linetable *)
653 xrealloc (line_vector,
654 sizeof (struct linetable) + line_vector_length * sizeof (int));
655 current_subfile->line_vector = line_vector;
658 /* If this line is not continguous with previous one recorded,
659 record a line-number entry for it. */
660 if (line != prev_line_number + 1)
661 line_vector->item[line_vector_index++] = - line;
662 prev_line_number = line;
664 /* Record the core address of the line. */
665 line_vector->item[line_vector_index++] = pc;
668 /* Start a new symtab for a new source file.
669 This is called when a dbx symbol of type N_SO is seen;
670 it indicates the start of data for one original source file. */
673 start_symtab (name, start_addr)
675 CORE_ADDR start_addr;
677 register struct symtab *s;
679 last_source_file = name;
680 last_source_start_addr = start_addr;
686 new_object_header_files ();
688 for (s = symseg_chain; s; s = s->next)
689 if (s->ldsymoff == symnum * sizeof (struct nlist))
695 type_vector_length = 160;
696 type_vector = (struct typevector *) xmalloc (sizeof (struct typevector) + type_vector_length * sizeof (struct type *));
697 bzero (type_vector->type, type_vector_length * sizeof (struct type *));
699 /* Initialize the list of sub source files with one entry
700 for this file (the top-level source file). */
704 start_subfile (name);
707 /* Handle an N_SOL symbol, which indicates the start of
708 code that came from an included (or otherwise merged-in)
709 source file with a different name. */
715 register struct subfile *subfile;
717 /* Save the current subfile's line vector data. */
721 current_subfile->line_vector_index = line_vector_index;
722 current_subfile->line_vector_length = line_vector_length;
723 current_subfile->prev_line_number = prev_line_number;
726 /* See if this subfile is already known as a subfile of the
727 current main source file. */
729 for (subfile = subfiles; subfile; subfile = subfile->next)
731 if (!strcmp (subfile->name, name))
733 line_vector = subfile->line_vector;
734 line_vector_index = subfile->line_vector_index;
735 line_vector_length = subfile->line_vector_length;
736 prev_line_number = subfile->prev_line_number;
737 current_subfile = subfile;
742 /* This subfile is not known. Add an entry for it. */
744 line_vector_index = 0;
745 line_vector_length = 1000;
746 prev_line_number = -2; /* Force first line number to be explicit */
747 line_vector = (struct linetable *)
748 xmalloc (sizeof (struct linetable) + line_vector_length * sizeof (int));
750 /* Make an entry for this subfile in the list of all subfiles
751 of the current main source file. */
753 subfile = (struct subfile *) xmalloc (sizeof (struct subfile));
754 subfile->next = subfiles;
755 subfile->name = savestring (name, strlen (name));
756 subfile->line_vector = line_vector;
758 current_subfile = subfile;
761 /* Finish the symbol definitions for one main source file,
762 close off all the lexical contexts for that file
763 (creating struct block's for them), then make the struct symtab
764 for that file and put it in the list of all such.
766 END_ADDR is the address of the end of the file's text. */
769 end_symtab (end_addr)
772 register struct symtab *symtab;
773 register struct context_stack *cstk;
774 register struct blockvector *blockvector;
775 register struct subfile *subfile;
776 register struct linetable *lv;
777 struct subfile *nextsub;
779 if (current_symseg != 0)
781 last_source_file = 0;
786 /* Finish the lexical context of the last function in the file. */
790 cstk = context_stack;
791 /* Make a block for the local symbols within. */
792 finish_block (cstk->name, &local_symbols, cstk->old_blocks,
793 cstk->start_addr, end_addr);
797 /* Finish defining all the blocks of this symtab. */
798 finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr);
799 finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr);
800 blockvector = make_blockvector ();
802 current_subfile->line_vector_index = line_vector_index;
804 /* Now create the symtab objects proper, one for each subfile. */
805 /* (The main file is one of them.) */
807 for (subfile = subfiles; subfile; subfile = nextsub)
809 symtab = (struct symtab *) xmalloc (sizeof (struct symtab));
810 symtab->free_ptr = 0;
812 /* Fill in its components. */
813 symtab->blockvector = blockvector;
814 type_vector->length = type_vector_length;
815 symtab->typevector = type_vector;
816 symtab->free_code = free_linetable;
817 if (subfile->next == 0)
818 symtab->free_ptr = (char *) type_vector;
820 symtab->filename = subfile->name;
821 lv = subfile->line_vector;
822 lv->nitems = subfile->line_vector_index;
823 symtab->linetable = (struct linetable *)
824 xrealloc (lv, sizeof (struct linetable) + lv->nitems * sizeof (int));
826 symtab->line_charpos = 0;
828 /* Link the new symtab into the list of such. */
829 symtab->next = symtab_list;
830 symtab_list = symtab;
832 nextsub = subfile->next;
837 type_vector_length = -1;
839 line_vector_length = -1;
840 last_source_file = 0;
845 /* Handle the N_BINCL and N_EINCL symbol types
846 that act like N_SOL for switching source files
847 (different subfiles, as we call them) within one object file,
848 but using a stack rather than in an arbitrary order. */
852 struct subfile_stack *next;
857 struct subfile_stack *subfile_stack;
862 register struct subfile_stack *tem
863 = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
865 tem->next = subfile_stack;
867 if (current_subfile == 0 || current_subfile->name == 0)
869 tem->name = current_subfile->name;
870 tem->prev_index = header_file_prev_index;
877 register struct subfile_stack *link = subfile_stack;
883 subfile_stack = link->next;
884 header_file_prev_index = link->prev_index;
889 #endif /* Have N_BINCL */
891 /* Accumulate the misc functions in bunches of 127.
892 At the end, copy them all into one newly allocated structure. */
894 #define MISC_BUNCH_SIZE 127
898 struct misc_bunch *next;
899 struct misc_function contents[MISC_BUNCH_SIZE];
902 /* Bunch currently being filled up.
903 The next field points to chain of filled bunches. */
905 static struct misc_bunch *misc_bunch;
907 /* Number of slots filled in current bunch. */
909 static int misc_bunch_index;
911 /* Total number of misc functions recorded so far. */
913 static int misc_count;
916 init_misc_functions ()
920 misc_bunch_index = MISC_BUNCH_SIZE;
924 record_misc_function (name, address)
928 register struct misc_bunch *new;
930 if (misc_bunch_index == MISC_BUNCH_SIZE)
932 new = (struct misc_bunch *) xmalloc (sizeof (struct misc_bunch));
933 misc_bunch_index = 0;
934 new->next = misc_bunch;
937 misc_bunch->contents[misc_bunch_index].name = name;
938 misc_bunch->contents[misc_bunch_index].address = address;
944 compare_misc_functions (fn1, fn2)
945 struct misc_function *fn1, *fn2;
947 /* Return a signed result based on unsigned comparisons
948 so that we sort into unsigned numeric order. */
949 if (fn1->address < fn2->address)
951 if (fn1->address > fn2->address)
957 discard_misc_bunches ()
959 register struct misc_bunch *next;
963 next = misc_bunch->next;
970 condense_misc_bunches ()
973 register struct misc_bunch *bunch;
974 #ifdef NAMES_HAVE_UNDERSCORE
981 = (struct misc_function *)
982 xmalloc (misc_count * sizeof (struct misc_function));
988 for (i = 0; i < misc_bunch_index; i++)
990 misc_function_vector[j] = bunch->contents[i];
991 misc_function_vector[j].name
992 = concat (misc_function_vector[j].name
993 + (misc_function_vector[j].name[0] == '_' ? offset : 0),
998 misc_bunch_index = MISC_BUNCH_SIZE;
1001 misc_function_count = j;
1003 /* Sort the misc functions by address. */
1005 qsort (misc_function_vector, j, sizeof (struct misc_function),
1006 compare_misc_functions);
1009 /* Call sort_syms to sort alphabetically
1010 the symbols of each block of each symtab. */
1013 compare_symbols (s1, s2)
1014 struct symbol **s1, **s2;
1016 /* Names that are less should come first. */
1017 register int namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
1018 if (namediff != 0) return namediff;
1019 /* For symbols of the same name, registers should come first. */
1020 return ((SYMBOL_CLASS (*s2) == LOC_REGISTER)
1021 - (SYMBOL_CLASS (*s1) == LOC_REGISTER));
1027 register struct symtab *s;
1028 register int i, nbl;
1029 register struct blockvector *bv;
1030 register struct block *b;
1032 for (s = symtab_list; s; s = s->next)
1034 bv = BLOCKVECTOR (s);
1035 nbl = BLOCKVECTOR_NBLOCKS (bv);
1036 for (i = 0; i < nbl; i++)
1038 b = BLOCKVECTOR_BLOCK (bv, i);
1039 qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
1040 sizeof (struct symbol *), compare_symbols);
1045 /* This is the symbol-file command. Read the file, analyze its symbols,
1046 and add a struct symtab to symtab_list. */
1049 symbol_file_command (name)
1054 struct nlist *nlist;
1058 extern void close ();
1059 struct cleanup *old_chain;
1060 struct symtab *symseg;
1066 if (symtab_list && !query ("Discard symbol table? ", 0))
1067 error ("Not confirmed.");
1068 free_all_symtabs ();
1072 if (symtab_list && !query ("Load new symbol table from \"%s\"? ", name))
1073 error ("Not confirmed.");
1080 char *absolute_name;
1081 desc = openp (getenv ("PATH"), 1, name, O_RDONLY, 0, &absolute_name);
1083 perror_with_name (name);
1085 name = absolute_name;
1088 old_chain = make_cleanup (close, desc);
1089 make_cleanup (free_current_contents, &name);
1091 val = myread (desc, &hdr, sizeof hdr);
1093 perror_with_name (name);
1096 error ("File \"%s\" not in executable format.", name);
1098 if (hdr.a_syms == 0)
1100 free_all_symtabs ();
1101 printf ("%s does not have a symbol-table.\n", name);
1106 printf ("Reading symbol data from %s...", name);
1109 /* Now read the string table, all at once. */
1110 val = lseek (desc, N_SYMOFF (hdr) + hdr.a_syms, 0);
1112 perror_with_name (name);
1113 val = myread (desc, &buffer, sizeof buffer);
1115 perror_with_name (name);
1116 stringtab = (char *) alloca (buffer);
1117 if (stringtab == NULL)
1119 free_all_symtabs ();
1120 printf("%s: symbol table too large for alloca: %d bytes.\n", name,
1125 bcopy (&buffer, stringtab, sizeof buffer);
1126 val = myread (desc, stringtab + sizeof buffer, buffer - sizeof buffer);
1128 perror_with_name (name);
1130 /* Throw away the old symbol table. */
1132 free_all_symtabs ();
1134 #ifdef READ_GDB_SYMSEGS
1135 /* That puts us at the symsegs. Read them. */
1136 symseg_chain = read_symsegs (desc, name);
1139 /* Free the symtabs made by read_symsegs, but not their contents,
1140 which have been copied into symtabs on symtab_list. */
1141 for (symseg = symseg_chain; symseg; symseg = symseg->next)
1144 struct sourcevector *sv = (struct sourcevector *) symseg->linetable;
1146 for (i = 0; i < sv->length; i++)
1149 struct source *source = sv->source[i];
1151 = (struct symtab *) xmalloc (sizeof (struct symtab));
1153 bcopy (symseg, sp1, sizeof (struct symtab));
1154 sp1->filename = savestring (source->name, strlen (source->name));
1155 sp1->linetable = &source->contents;
1156 sp1->free_code = free_nothing;
1157 sp1->free_ptr = (i == 0) ? (char *) symseg : 0;
1159 sp1->next = symtab_list;
1164 /* Where people are using the 4.2 ld program, must not check for
1165 symsegs, because that ld puts randonm garbage at the end of
1166 the output file and that would trigger an error message. */
1170 /* Position to read the symbol table. Do not read it all at once. */
1171 val = lseek (desc, N_SYMOFF (hdr), 0);
1173 perror_with_name (name);
1175 init_misc_functions ();
1176 make_cleanup (discard_misc_bunches, 0);
1177 init_header_files ();
1178 make_cleanup (free_header_files, 0);
1180 /* Now that the symbol table data of the executable file are all in core,
1181 process them and define symbols accordingly. Closes desc. */
1183 read_dbx_symtab (desc, stringtab, hdr.a_syms / sizeof (struct nlist));
1185 /* Sort symbols alphabetically within each block. */
1189 /* Go over the misc functions and install them in vector. */
1191 condense_misc_bunches ();
1193 /* Don't allow char * to have a typename (else would get caddr_t.) */
1195 TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
1197 /* Make a default for file to list. */
1199 select_source_symtab (symtab_list);
1201 symfile = savestring (name, strlen (name));
1203 do_cleanups (old_chain);
1205 /* Free the symtabs made by read_symsegs, but not their contents,
1206 which have been copied into symtabs on symtab_list. */
1207 while (symseg_chain)
1209 register struct symtab *s = symseg_chain->next;
1210 free (symseg_chain);
1218 /* Return name of file symbols were loaded from, or 0 if none.. */
1226 /* Given pointers to a a.out symbol table in core containing dbx style data,
1227 analyze them and create struct symtab's describing the symbols.
1228 NLISTLEN is the number of symbols in the symbol table.
1229 We read them one at a time using stdio.
1230 All symbol names are given as offsets relative to STRINGTAB. */
1233 read_dbx_symtab (desc, stringtab, nlistlen)
1235 register char *stringtab;
1236 register int nlistlen;
1238 FILE *stream = fdopen (desc, "r");
1240 register char *namestring;
1241 register struct symbol *sym, *prev;
1243 int num_object_files = 0;
1244 struct cleanup *old_chain;
1250 old_chain = make_cleanup (free_all_symtabs, 0);
1251 nlist_stream_global = stream;
1252 nlist_size_global = nlistlen;
1253 stringtab_global = stringtab;
1254 last_source_file = 0;
1255 bzero (global_sym_chain, sizeof global_sym_chain);
1257 for (symnum = 0; symnum < nlistlen; symnum++)
1259 QUIT; /* allow this to be interruptable */
1260 fread (&buf, sizeof buf, 1, stream);
1261 namestring = buf.n_un.n_strx ? buf.n_un.n_strx + stringtab : "";
1262 if (buf.n_type & N_STAB)
1263 process_one_symbol (buf.n_type, buf.n_desc,
1264 buf.n_value, namestring);
1265 /* A static text symbol whose name ends in ".o"
1266 can only mean the start of another object file.
1267 So end the symtab of the source file we have been processing.
1268 This is how we avoid counting the libraries as part
1269 or the last source file.
1270 Also this way we find end of first object file (crt0). */
1271 else if (buf.n_type == N_TEXT
1272 && !strcmp (namestring + strlen (namestring) - 2, ".o"))
1274 if (num_object_files++ == 1)
1275 first_object_file_end = buf.n_value;
1276 if (last_source_file)
1277 end_symtab (buf.n_value);
1279 else if (buf.n_type & N_EXT || buf.n_type == N_TEXT)
1283 /* Record the location of _etext. */
1284 if (buf.n_type == (N_TEXT | N_EXT)
1285 && !strcmp (namestring, "_etext"))
1286 end_of_text_addr = buf.n_value;
1288 /* Global symbol: see if we came across a dbx definition
1289 for a corresponding symbol. If so, store the value.
1290 Remove syms from the chain when their values are stored,
1291 but search the whole chain, as there may be several syms
1292 from different files with the same name. */
1293 if (buf.n_type & N_EXT)
1296 #ifdef NAMES_HAVE_UNDERSCORE
1297 hash = hashname (namestring + 1);
1298 #else /* not NAMES_HAVE_UNDERSCORE */
1299 hash = hashname (namestring);
1300 #endif /* not NAMES_HAVE_UNDERSCORE */
1301 for (sym = global_sym_chain[hash];
1305 #ifdef NAMES_HAVE_UNDERSCORE
1307 && namestring[1] == SYMBOL_NAME (sym)[0]
1309 !strcmp (namestring + 2, SYMBOL_NAME (sym) + 1)
1310 #else /* NAMES_HAVE_UNDERSCORE */
1311 namestring[0] == SYMBOL_NAME (sym)[0]
1313 !strcmp (namestring + 1, SYMBOL_NAME (sym) + 1)
1314 #endif /* NAMES_HAVE_UNDERSCORE */
1318 SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym);
1320 global_sym_chain[hash]
1321 = (struct symbol *) SYMBOL_VALUE (sym);
1322 SYMBOL_VALUE (sym) = buf.n_value;
1324 sym = (struct symbol *) SYMBOL_VALUE (prev);
1326 sym = global_sym_chain[hash];
1333 sym = (struct symbol *) SYMBOL_VALUE (sym);
1338 /* Defined global or text symbol: record as a misc function
1339 if it didn't give its address to a debugger symbol above. */
1340 if (buf.n_type <= (N_TYPE | N_EXT)
1341 && buf.n_type != N_EXT
1343 record_misc_function (namestring, buf.n_value);
1347 if (last_source_file)
1348 end_symtab (end_of_text_addr);
1351 discard_cleanups (old_chain);
1354 /* dbx allows the text of a symbol name to be continued into the
1355 next symbol name! When such a continuation is encountered
1356 (a \ at the end of the text of a name)
1357 call this function to get the continuation. */
1363 fread (&buf, sizeof buf, 1, nlist_stream_global);
1365 return buf.n_un.n_strx + stringtab_global;
1372 register char *p = name;
1373 register int total = p[0];
1386 return total % HASHSIZE;
1389 /* Put all appropriate global symbols in the symseg data
1390 onto the hash chains so that their addresses will be stored
1391 when seen later in loader global symbols. */
1396 /* Look at each symbol in each block in each symseg symtab. */
1398 for (s = symseg_chain; s; s = s->next)
1401 for (n = BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)) - 1; n >= 0; n--)
1403 register struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), n);
1405 for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--)
1407 register struct symbol *sym = BLOCK_SYM (b, i);
1409 /* Put the symbol on a chain if its value is an address
1410 that is figured out by the loader. */
1412 if (SYMBOL_CLASS (sym) == LOC_EXTERNAL)
1414 register int hash = hashname (SYMBOL_NAME (sym));
1415 SYMBOL_VALUE (sym) = (int) global_sym_chain[hash];
1416 global_sym_chain[hash] = sym;
1417 SYMBOL_CLASS (sym) = LOC_STATIC;
1425 process_one_symbol (type, desc, value, name)
1430 register struct context_stack *new;
1432 /* Something is wrong if we see real data before
1433 seeing a source file name. */
1436 if (type == N_NSYMS) return;
1439 if (type != N_SO && last_source_file == 0)
1440 error ("Invalid symbol data: does not start by identifying a source file.");
1446 /* Either of these types of symbols indicates the start of
1447 a new function. We must process its "name" normally for dbx,
1448 but also record the start of a new lexical context, and possibly
1449 also the end of the lexical context for the previous function. */
1450 new = context_stack;
1451 within_function = 1;
1454 /* Make a block for the local symbols within. */
1455 finish_block (new->name, &local_symbols, new->old_blocks,
1456 new->start_addr, value);
1460 new = (struct context_stack *) xmalloc (sizeof (struct context_stack));
1463 context_stack = new;
1466 new->old_blocks = pending_blocks;
1467 new->start_addr = value;
1468 new->name = define_symbol (value, name, desc);
1473 /* This "symbol" just indicates the start of an inner lexical
1474 context within a function. */
1475 new = (struct context_stack *) xmalloc (sizeof (struct context_stack));
1477 new->next = context_stack;
1478 context_stack = new;
1479 new->locals = local_symbols;
1480 new->old_blocks = pending_blocks;
1481 new->start_addr = value;
1487 /* This "symbol" just indicates the end of an inner lexical
1488 context that was started with N_RBRAC. */
1489 new = context_stack;
1490 if (new == 0 || desc != new->depth)
1491 error ("Invalid symbol data: N_LBRAC/N_RBRAC symbol mismatch, symtab pos %d.", symnum);
1492 local_symbols = new->locals;
1493 context_stack = new->next;
1494 /* If this is not the outermost LBRAC...RBRAC pair in the
1495 function, its local symbols preceded it, and are the ones
1496 just recovered from the context stack. Defined the block for them.
1498 If this is the outermost LBRAC...RBRAC pair, there is no
1499 need to do anything; leave the symbols that preceded it
1500 to be attached to the function's own block. */
1501 if (local_symbols && context_stack->next)
1503 /* Muzzle a compiler bug that makes end > start. */
1504 if (new->start_addr > value)
1505 new->start_addr = value;
1506 /* Make a block for the local symbols within. */
1507 finish_block (0, &local_symbols, new->old_blocks,
1508 new->start_addr + last_source_start_addr,
1509 value + last_source_start_addr);
1515 /* This kind of symbol supposedly indicates the start
1516 of an object file. In fact this type does not appear. */
1520 /* This type of symbol indicates the start of data
1521 for one source file.
1522 Finish the symbol table of the previous source file
1523 (if any) and start accumulating a new symbol table. */
1524 if (last_source_file)
1526 start_symtab (name, value);
1530 /* This type of symbol indicates the start of data for
1531 a sub-source-file, one whose contents were copied or
1532 included in the compilation of the main source file
1533 (whose name was given in the N_SO symbol.) */
1534 start_subfile (name);
1540 add_new_header_file (name, value);
1541 start_subfile (name);
1545 start_subfile (pop_subfile ());
1549 add_old_header_file (name, value);
1551 #endif /* have N_BINCL */
1554 /* This type of "symbol" really just records
1555 one line-number -- core-address correspondence.
1556 Enter it in the line list for this symbol table. */
1557 record_line (desc, value);
1562 define_symbol (value, name, desc);
1566 /************************ READ_ADDL_SYM() ***********************************/
1569 read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size)
1571 register char *stringtab;
1572 register int nlistlen;
1576 FILE *stream = fdopen (desc, "r");
1578 register char *namestring;
1579 register struct symbol *sym, *prev;
1581 int num_object_files = 0;
1587 nlist_stream_global = stream;
1588 nlist_size_global = nlistlen;
1589 stringtab_global = stringtab;
1590 last_source_file = 0;
1591 bzero (global_sym_chain, sizeof global_sym_chain);
1593 for (symnum = 0; symnum < nlistlen; symnum++)
1597 fread (&buf, sizeof buf, 1, stream);
1599 type = buf.n_type & N_TYPE;
1600 if( (type == N_TEXT) || (type == N_DATA) || (type == N_BSS) )
1602 buf.n_value += text_addr;
1603 } /* Right?? ###### */
1606 namestring = buf.n_un.n_strx ? buf.n_un.n_strx + stringtab : "";
1607 if (buf.n_type & N_STAB)
1608 process_one_symbol (buf.n_type, buf.n_desc,
1609 buf.n_value, namestring);
1610 /* A static text symbol whose name ends in ".o"
1611 can only mean the start of another object file.
1612 So end the symtab of the source file we have been processing.
1613 This is how we avoid counting the libraries as part
1614 or the last source file.
1615 Also this way we find end of first object file (crt0). */
1616 else if (buf.n_type == N_TEXT
1617 && !strcmp (namestring + strlen (namestring) - 2, ".o"))
1619 if (num_object_files++ == 1)
1620 first_object_file_end = buf.n_value;
1621 if (last_source_file)
1623 end_symtab (buf.n_value); /* All this not used##### */
1626 else if (buf.n_type & N_EXT || buf.n_type == N_TEXT)
1630 /* Record the location of _etext. */
1631 if (buf.n_type == (N_TEXT | N_EXT)
1632 && !strcmp (namestring, "_etext"))
1634 end_of_text_addr = buf.n_value;
1637 /* Global symbol: see if we came across a dbx definition
1638 for a corresponding symbol. If so, store the value.
1639 Remove syms from the chain when their values are stored,
1640 but search the whole chain, as there may be several syms
1641 from different files with the same name. */
1642 if (buf.n_type & N_EXT)
1645 #ifdef NAMES_HAVE_UNDERSCORE
1646 hash = hashname (namestring + 1);
1647 #else /* not NAMES_HAVE_UNDERSCORE */
1648 hash = hashname (namestring);
1649 #endif /* not NAMES_HAVE_UNDERSCORE */
1650 for (sym = global_sym_chain[hash];
1654 #ifdef NAMES_HAVE_UNDERSCORE
1656 && namestring[1] == SYMBOL_NAME (sym)[0]
1658 !strcmp (namestring + 2, SYMBOL_NAME (sym) + 1)
1659 #else /* NAMES_HAVE_UNDERSCORE */
1660 namestring[0] == SYMBOL_NAME (sym)[0]
1662 !strcmp (namestring + 1, SYMBOL_NAME (sym) + 1)
1663 #endif /* NAMES_HAVE_UNDERSCORE */
1667 SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym);
1669 global_sym_chain[hash]
1670 = (struct symbol *) SYMBOL_VALUE (sym);
1671 SYMBOL_VALUE (sym) = buf.n_value;
1673 sym = (struct symbol *) SYMBOL_VALUE (prev);
1675 sym = global_sym_chain[hash];
1682 sym = (struct symbol *) SYMBOL_VALUE (sym);
1687 /* Defined global or text symbol: record as a misc function
1688 if it didn't give its address to a debugger symbol above. */
1689 if (buf.n_type <= (N_TYPE | N_EXT)
1690 && buf.n_type != N_EXT
1692 record_misc_function (namestring, buf.n_value);
1696 if (last_source_file)
1698 end_symtab (text_addr + text_size);
1704 /***************************** CONDENSE_ADDL_MISC_BUNCHES *******************/
1707 condense_addl_misc_bunches ()
1710 register struct misc_bunch *bunch;
1711 #ifdef NAMES_HAVE_UNDERSCORE
1717 misc_function_vector
1718 = (struct misc_function *) xrealloc (misc_function_vector,
1719 (misc_count + misc_function_count) * sizeof (struct misc_function));
1721 j = misc_function_count;
1725 for (i = 0; i < misc_bunch_index; i++)
1727 misc_function_vector[j] = bunch->contents[i];
1728 misc_function_vector[j].name
1729 = concat (misc_function_vector[j].name
1730 + (misc_function_vector[j].name[0] == '_' ? offset : 0),
1734 bunch = bunch->next;
1735 misc_bunch_index = MISC_BUNCH_SIZE;
1738 misc_function_count += misc_count;
1740 /* Sort the misc functions by address. */
1742 qsort (misc_function_vector, misc_function_count,
1743 sizeof (struct misc_function), compare_misc_functions);
1746 /**************************** ADD_FILE_COMMAND() ****************************/
1747 /* This function allows the addition of incrementally linked object files. */
1750 add_file_command (arg_string)
1755 struct nlist *nlist;
1759 extern void close ();
1760 struct cleanup *old_chain;
1764 if (arg_string == 0)
1765 error ("add-file takes a file name and an address");
1767 for( ; *arg_string == ' '; arg_string++ );
1769 for( ; *arg_string && *arg_string != ' ' ; arg_string++ );
1770 *arg_string++ = (char) 0;
1773 error ("add-file takes a file name and an address");
1775 text_addr = parse_and_eval_address (arg_string);
1779 if (query ("add symbol table from filename \"%s\" at text_addr = 0x%x\n", name, text_addr))
1781 desc = open (name, O_RDONLY);
1783 perror_with_name (name);
1785 old_chain = make_cleanup (close, desc);
1786 make_cleanup (free_current_contents, &name);
1788 val = myread (desc, &hdr, sizeof hdr);
1790 perror_with_name (name);
1793 error ("File \"%s\" has a bad header.", name);
1795 if (hdr.a_syms == 0)
1797 printf ("%s does not have a symbol-table.\n", name);
1802 /* Now read the string table, all at once. */
1803 val = lseek (desc, N_SYMOFF (hdr) + hdr.a_syms, 0);
1805 perror_with_name (name);
1806 val = myread (desc, &buffer, sizeof buffer);
1808 perror_with_name (name);
1809 stringtab = (char *) alloca (buffer);
1810 bcopy (&buffer, stringtab, sizeof buffer);
1811 val = myread (desc, stringtab + sizeof buffer, buffer - sizeof buffer);
1813 perror_with_name (name);
1815 /* That puts us at the symsegs. Read them. ########## Also need other
1816 changes if they exist. */
1818 /* Position to read the symbol table. Do not read it all at once. */
1819 val = lseek (desc, N_SYMOFF (hdr), 0);
1821 perror_with_name (name);
1823 printf ("Reading symbol data from %s...", name);
1826 init_misc_functions ();
1827 make_cleanup (discard_misc_bunches, 0);
1828 init_header_files ();
1829 make_cleanup (free_header_files, 0);
1831 read_addl_syms (desc, stringtab, hdr.a_syms / sizeof(struct nlist),
1832 text_addr, hdr.a_text) ;
1834 /* Sort symbols alphabetically within each block. */
1838 /* Go over the all misc functions and install them in vector. */
1840 condense_addl_misc_bunches ();
1842 /* Don't allow char * to have a typename (else would get caddr_t.) */
1844 TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
1846 /* Make a default for file to list. */
1848 select_source_symtab (symtab_list);
1850 do_cleanups (old_chain);
1852 /* Free the symtabs made by read_symsegs, but not their contents,
1853 which have been copied into symtabs on symtab_list. */
1854 while (symseg_chain)
1856 register struct symtab *s = symseg_chain->next;
1857 free (symseg_chain);
1864 else error ("Not confirmed.");
1867 static struct symbol *
1868 define_symbol (value, string, desc)
1873 register struct symbol *sym
1874 = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol));
1875 char *p = (char *) index (string, ':');
1879 bzero (sym, sizeof (struct symbol));
1880 SYMBOL_NAME (sym) = obstack_copy0 (symbol_obstack, string, p - string);
1882 /* Determine the type of name being defined. */
1883 if ((*p >= '0' && *p <= '9') || *p == '(')
1888 /* c is a special case, not followed by a type-number.
1889 SYMBOL:c=iVALUE for an integer constant symbol.
1890 SYMBOL:c=rVALUE for a floating constant symbol. */
1894 error ("Invalid symbol data at symtab pos %d.", symnum);
1899 double d = atof (p);
1902 SYMBOL_TYPE (sym) = builtin_type_double;
1903 value = (char *) obstack_alloc (symbol_obstack, sizeof (double));
1904 bcopy (&d, value, sizeof (double));
1905 SYMBOL_VALUE_BYTES (sym) = value;
1906 SYMBOL_CLASS (sym) = LOC_CONST;
1911 SYMBOL_TYPE (sym) = builtin_type_int;
1912 SYMBOL_VALUE (sym) = atoi (p);
1913 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1917 error ("Invalid symbol data at symtab pos %d.", symnum);
1919 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1920 add_symbol_to_list (sym, &file_symbols);
1924 /* Now usually comes a number that says which data type,
1925 and possibly more stuff to define the type
1926 (all of which is handled by read_type) */
1928 if (deftype == 'p' && *p == 'F')
1929 /* pF is a two-letter code that means a function parameter in Fortran.
1930 The type-number specifies the type of the return value.
1931 Translate it into a pointer-to-function type. */
1935 = lookup_pointer_type (lookup_function_type (read_type (&p)));
1938 SYMBOL_TYPE (sym) = read_type (&p);
1943 SYMBOL_CLASS (sym) = LOC_BLOCK;
1944 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1945 add_symbol_to_list (sym, &file_symbols);
1949 SYMBOL_CLASS (sym) = LOC_BLOCK;
1950 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1951 add_symbol_to_list (sym, &global_symbols);
1955 /* For a class G (global) symbol, it appears that the
1956 value is not correct. It is necessary to search for the
1957 corresponding linker definition to find the value.
1958 These definitions appear at the end of the namelist. */
1959 i = hashname (SYMBOL_NAME (sym));
1960 SYMBOL_VALUE (sym) = (int) global_sym_chain[i];
1961 global_sym_chain[i] = sym;
1962 SYMBOL_CLASS (sym) = LOC_STATIC;
1963 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1964 add_symbol_to_list (sym, &global_symbols);
1967 /* This case is faked by a conditional above,
1968 when there is no code letter in the dbx data.
1969 Dbx data never actually contains 'l'. */
1971 SYMBOL_CLASS (sym) = LOC_LOCAL;
1972 SYMBOL_VALUE (sym) = value;
1973 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1974 add_symbol_to_list (sym, &local_symbols);
1978 SYMBOL_CLASS (sym) = LOC_ARG;
1979 SYMBOL_VALUE (sym) = value;
1980 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1981 add_symbol_to_list (sym, &local_symbols);
1982 /* DESC == 0 implies compiled with GCC.
1983 In this case, if it says `short', believe it. */
1986 /* If PCC says a parameter is a short or a char,
1987 it is really an int. */
1988 if (SYMBOL_TYPE (sym) == builtin_type_char
1989 || SYMBOL_TYPE (sym) == builtin_type_short)
1990 SYMBOL_TYPE (sym) = builtin_type_int;
1991 else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char
1992 || SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
1993 SYMBOL_TYPE (sym) = builtin_type_unsigned_int;
1997 SYMBOL_CLASS (sym) = LOC_REGISTER;
1998 SYMBOL_VALUE (sym) = value;
1999 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2000 add_symbol_to_list (sym, &local_symbols);
2004 /* Static symbol at top level of file */
2005 SYMBOL_CLASS (sym) = LOC_STATIC;
2006 SYMBOL_VALUE (sym) = value;
2007 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2008 add_symbol_to_list (sym, &file_symbols);
2012 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2013 SYMBOL_VALUE (sym) = value;
2014 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2015 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
2016 && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
2017 TYPE_NAME (SYMBOL_TYPE (sym)) = concat (SYMBOL_NAME (sym), "", "");
2018 /* C++ vagaries: we may have a type which is derived from
2019 a base type which did not have its name defined when the
2020 derived class was output. We fill in the derived class's
2021 base part member's name here in that case. */
2022 else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
2023 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
2024 && TYPE_BASECLASS (SYMBOL_TYPE (sym))
2025 && TYPE_FIELD_NAME (SYMBOL_TYPE (sym), 0) == 0)
2026 TYPE_FIELD_NAME (SYMBOL_TYPE (sym), 0) = TYPE_NAME (TYPE_BASECLASS (SYMBOL_TYPE (sym)));
2028 add_symbol_to_list (sym, &file_symbols);
2032 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2033 SYMBOL_VALUE (sym) = value;
2034 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
2035 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
2036 && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
2037 TYPE_NAME (SYMBOL_TYPE (sym))
2039 (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM
2041 : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
2042 ? "struct " : "union ")),
2044 add_symbol_to_list (sym, &file_symbols);
2049 /* Static symbol of local scope */
2050 SYMBOL_CLASS (sym) = LOC_STATIC;
2051 SYMBOL_VALUE (sym) = value;
2052 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2053 add_symbol_to_list (sym, &local_symbols);
2057 error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
2062 /* Read a number by which a type is referred to in dbx data,
2063 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
2064 Just a single number N is equivalent to (0,N).
2065 Return the two numbers by storing them in the vector TYPENUMS.
2066 TYPENUMS will then be used as an argument to dbx_lookup_type. */
2069 read_type_number (pp, typenums)
2071 register int *typenums;
2076 typenums[0] = read_number (pp, ',');
2077 typenums[1] = read_number (pp, ')');
2082 typenums[1] = read_number (pp, 0);
2086 /* Read a dbx type reference or definition;
2087 return the type that is meant.
2088 This can be just a number, in which case it references
2089 a type already defined and placed in type_vector.
2090 Or the number can be followed by an =, in which case
2091 it means to define a new type according to the text that
2099 register struct type *type = 0;
2105 read_type_number (pp, typenums);
2107 /* Detect random reference to type not yet defined.
2108 Allocate a type object but leave it zeroed. */
2110 return dbx_alloc_type (typenums);
2116 type = dbx_alloc_type (typenums);
2117 /* Set the type code according to the following letter. */
2121 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2124 TYPE_CODE (type) = TYPE_CODE_UNION;
2127 TYPE_CODE (type) = TYPE_CODE_ENUM;
2130 /* Skip the name the cross-ref points to. */
2131 /* Note: for C++, the cross reference may be to a base type which
2132 has not yet been seen. In this case, we skip to the comma,
2133 which will mark the end of the base class name. (The ':'
2134 at the end of the base class name will be skipped as well.) */
2135 *pp = (char *) index (*pp, ',');
2136 /* Just allocate the type and leave it zero if nothing known */
2137 return dbx_alloc_type (typenums);
2151 read_type_number (pp, xtypenums);
2152 type = *dbx_lookup_type (xtypenums);
2154 type = builtin_type_void;
2155 *dbx_lookup_type (typenums) = type;
2159 type = dbx_alloc_type (typenums);
2160 smash_to_pointer_type (type, read_type (pp));
2165 struct type *domain = read_type (pp);
2167 struct type *memtype;
2169 if (*(*pp)++ != ',')
2170 error ("invalid member type data format, at symtab pos %d.",
2173 memtype = read_type (pp);
2174 type = dbx_alloc_type (typenums);
2175 smash_to_member_type (type, domain, memtype);
2180 type = dbx_alloc_type (typenums);
2181 smash_to_reference_type (type, read_type (pp));
2185 type = dbx_alloc_type (typenums);
2186 smash_to_function_type (type, read_type (pp));
2190 type = read_range_type (pp, typenums);
2191 *dbx_lookup_type (typenums) = type;
2195 type = dbx_alloc_type (typenums);
2196 type = read_enum_type (pp, type);
2197 *dbx_lookup_type (typenums) = type;
2201 type = dbx_alloc_type (typenums);
2202 type = read_struct_type (pp, type);
2206 type = dbx_alloc_type (typenums);
2207 type = read_struct_type (pp, type);
2208 TYPE_CODE (type) = TYPE_CODE_UNION;
2212 /* Define an array type. */
2213 type = dbx_alloc_type (typenums);
2215 /* dbx expresses array types in terms of a range type for the index,
2216 and that range type is specified right inside the array type spec
2217 making ar1;MIN;MAX;VALTYPE */
2218 if (!strncmp (*pp, "r1;0;", 5))
2220 else if (!strncmp (*pp, "r(0,1);0;", 9))
2224 TYPE_CODE (type) = TYPE_CODE_ARRAY;
2225 /* In Fortran, an upper bound may be T... meaning a parameter specifies
2226 the length of the data. In this case, just pretend the bound is 1.
2227 This happens only for array parameters, which are really passed
2228 as pointers anyway, and we will translate them into such. */
2236 n = read_number (pp, ';') + 1;
2237 TYPE_TARGET_TYPE (type) = read_type (pp);
2238 TYPE_LENGTH (type) = TYPE_LENGTH (TYPE_TARGET_TYPE (type)) * n;
2242 error ("Invalid symbol data: unrecognized type-code `%c' at symtab pos %d.",
2250 /* If this is an overriding temporary alteration for a header file's
2251 contents, and this type number is unknown in the global definition,
2252 put this type into the global definition at this type number. */
2253 if (header_file_prev_index >= 0)
2255 register struct type **tp
2256 = explicit_lookup_type (header_file_prev_index, typenums[1]);
2264 /* This page contains subroutines of read_type. */
2266 /* Read the description of a structure (or union type)
2267 and return an object describing the type. */
2269 static struct type *
2270 read_struct_type (pp, type)
2272 register struct type *type;
2276 struct nextfield *next;
2283 struct next_fnfield *next;
2285 struct fn_field fn_field;
2288 struct next_fnfieldlist
2290 struct next_fnfieldlist *next;
2291 struct fn_fieldlist fn_fieldlist;
2294 register struct nextfield *list = 0;
2295 struct nextfield *new;
2302 register struct next_fnfieldlist *mainlist = 0;
2304 struct type *baseclass = NULL;
2305 int read_possible_virtual_info = 0;
2307 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2309 /* First comes the total size in bytes. */
2311 TYPE_LENGTH (type) = read_number (pp, 0);
2313 /* C++: Now, if the class is a derived class, then the next character
2314 will be a '!', followed by the type of the base class. Allocate
2315 pretend that that base class is a sub-structure of this one,
2316 with its field name being the type name of the derived class. This
2317 cannot cause a naming conflict, since field names cannot be
2318 type names. This will magically recurse itself to gound terms
2319 when all is read and done. */
2329 TYPE_VIA_PROTECTED (type) = 1;
2332 TYPE_VIA_PUBLIC (type) = 1;
2335 error ("Invalid symbol data: bad visibility format at symtab pos %d.",
2339 if (**pp == '\\') *pp = next_symbol_text ();
2340 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2344 baseclass = read_type (pp);
2345 list->field.type = baseclass;
2346 list->field.name = TYPE_NAME (baseclass);
2347 *pp += 1; /* skip ',' */
2348 list->field.bitpos = 0;
2349 list->field.bitsize = 0; /* this should be an unpacked field! */
2353 /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one.
2354 At the end, we see a semicolon instead of a field.
2356 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
2359 The `?' is a placeholder for one of '+' (public visibility),
2360 '0' (protected visibility), and '-' (private visibility). */
2366 /* Check for and handle cretinous dbx symbol name continuation! */
2367 if (**pp == '\\') *pp = next_symbol_text ();
2369 /* Get space to record the next field's data. */
2370 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2374 /* Read the data. */
2376 while (*p != ':') p++;
2377 list->field.name = savestring (*pp, p - *pp);
2379 /* Check to see if we have hit the methods yet. */
2385 /* This means we have a visibility for a field coming. */
2406 /* else normal dbx-style format. */
2408 list->field.type = read_type (pp);
2411 list->field.bitpos = (long)-1;
2413 while (*p != ';') p++;
2414 list->field.bitsize = (long) savestring (*pp, p - *pp);
2419 else if (**pp != ',')
2420 error ("Invalid symbol data: bad structure-type format at symtab pos %d.",
2422 (*pp)++; /* Skip the comma. */
2423 list->field.bitpos = read_number (pp, ',');
2424 list->field.bitsize = read_number (pp, ';');
2425 /* Detect an unpacked field and mark it as such.
2426 dbx gives a bit size for all fields.
2427 Also detect forward refs to structures and unions,
2428 and treat enums as if they had the width of ints. */
2429 if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type)
2430 || TYPE_CODE (list->field.type) == TYPE_CODE_STRUCT
2431 || TYPE_CODE (list->field.type) == TYPE_CODE_UNION
2432 || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM
2433 && list->field.bitsize == 8 * TYPE_LENGTH (builtin_type_int)))
2435 list->field.bitpos % 8 == 0)
2436 list->field.bitsize = 0;
2440 /* Now come the method fields, as NAME::methods
2441 where each method is of the form TYPENUM,ARGS,...:PHYSNAME;
2442 At the end, we see a semicolon instead of a field.
2444 For the case of overloaded operators, the format is
2445 OPERATOR::*.methods, where OPERATOR is the string "operator",
2446 `*' holds the place for an operator name (such as `+=')
2447 and `.' marks the end of the operator name. */
2450 /* Now, read in the methods. To simplify matters, we
2451 "unread" the name that has been read, so that we can
2452 start from the top. */
2456 /* chill the list of fields: the last entry (at the head)
2457 is a partially constructed entry which we now scrub. */
2460 /* For each list of method lists... */
2464 struct next_fnfield *sublist = 0;
2465 struct fn_field *fn_fields = 0;
2467 struct next_fnfieldlist *new_mainlist =
2468 (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist));
2470 /* read in the name. */
2471 while (*p != ':') p++;
2472 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == '$')
2474 static char opname[32] = "operator ";
2475 char *o = opname + 9;
2477 /* Skip past '::'. */
2481 new_mainlist->fn_fieldlist.name = savestring (opname, o - opname);
2488 new_mainlist->fn_fieldlist.name = savestring (*pp, p - *pp);
2489 /* Skip past '::'. */
2495 struct next_fnfield *new_sublist =
2496 (struct next_fnfield *)alloca (sizeof (struct next_fnfield));
2498 /* Check for and handle cretinous dbx symbol name continuation! */
2499 if (**pp == '\\') *pp = next_symbol_text ();
2501 new_sublist->fn_field.type = read_type (pp);
2502 new_sublist->fn_field.args = read_args (pp, ':');
2504 while (*p != ';') p++;
2505 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
2507 new_sublist->visibility = *(*pp)++ - '0';
2508 if (**pp == '\\') *pp = next_symbol_text ();
2510 if (*(*pp)++ == '*')
2511 new_sublist->fn_field.voffset = read_number (pp, ';') + 1;
2513 new_sublist->fn_field.voffset = 0;
2515 new_sublist->next = sublist;
2516 sublist = new_sublist;
2519 while (**pp != ';');
2523 new_mainlist->fn_fieldlist.fn_fields =
2524 (struct fn_field *) obstack_alloc (symbol_obstack,
2525 sizeof (struct fn_field) * length);
2526 TYPE_FN_PRIVATE_BITS (new_mainlist->fn_fieldlist) =
2527 (int *) obstack_alloc (symbol_obstack,
2528 sizeof (int) * (1 + (length >> 5)));
2530 TYPE_FN_PROTECTED_BITS (new_mainlist->fn_fieldlist) =
2531 (int *) obstack_alloc (symbol_obstack,
2532 sizeof (int) * (1 + (length >> 5)));
2534 for (i = length; sublist; sublist = sublist->next)
2536 new_mainlist->fn_fieldlist.fn_fields[--i] = sublist->fn_field;
2537 if (sublist->visibility == 0)
2538 B_SET (new_mainlist->fn_fieldlist.private_fn_field_bits, i);
2539 else if (sublist->visibility == 1)
2540 B_SET (new_mainlist->fn_fieldlist.protected_fn_field_bits, i);
2543 new_mainlist->fn_fieldlist.length = length;
2544 new_mainlist->next = mainlist;
2545 mainlist = new_mainlist;
2548 while (**pp != ';');
2554 read_possible_virtual_info = 1;
2559 TYPE_HAS_DESTRUCTOR (type) = 1;
2560 TYPE_HAS_CONSTRUCTOR (type) = 1;
2563 else if (**pp == '+')
2565 TYPE_HAS_CONSTRUCTOR (type) = 1;
2571 /* Now create the vector of fields, and record how big it is. */
2573 TYPE_NFIELDS (type) = nfields;
2574 TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack,
2575 sizeof (struct field) * nfields);
2576 TYPE_FIELD_PRIVATE_BITS (type) =
2577 (int *) obstack_alloc (symbol_obstack,
2578 sizeof (int) * (1 + (nfields >> 5)));
2579 TYPE_FIELD_PROTECTED_BITS (type) =
2580 (int *) obstack_alloc (symbol_obstack,
2581 sizeof (int) * (1 + (nfields >> 5)));
2583 TYPE_NFN_FIELDS (type) = nfn_fields;
2584 TYPE_NFN_FIELDS_TOTAL (type) = nfn_fields;
2586 TYPE_NFN_FIELDS_TOTAL (type) += TYPE_NFN_FIELDS_TOTAL (baseclass);
2588 TYPE_FN_FIELDLISTS (type) =
2589 (struct fn_fieldlist *) obstack_alloc (symbol_obstack,
2590 sizeof (struct fn_fieldlist) * nfn_fields);
2592 /* Copy the saved-up fields into the field vector. */
2594 for (n = nfields; list; list = list->next)
2596 TYPE_FIELD (type, --n) = list->field;
2597 if (list->visibility == 0)
2598 SET_TYPE_FIELD_PRIVATE (type, n);
2599 else if (list->visibility == 1)
2600 SET_TYPE_FIELD_PROTECTED (type, n);
2603 for (n = nfn_fields; mainlist; mainlist = mainlist->next)
2604 TYPE_FN_FIELDLISTS (type)[--n] = mainlist->fn_fieldlist;
2606 TYPE_BASECLASS (type) = baseclass;
2608 if (read_possible_virtual_info)
2610 /* Read either a '%' or the final ';'. */
2611 if (*(*pp)++ == '%')
2613 /* Now we must record the virtual function table pointer's
2614 field information. */
2621 while (*p != ';') p++;
2622 TYPE_VPTR_BASETYPE (type) = t;
2625 if (TYPE_FIELD_NAME (t, 0) == 0)
2626 TYPE_VPTR_FIELDNO (type) = i = 0;
2627 else for (i = TYPE_NFIELDS (t) - 1; i >= 0; --i)
2628 if (! strncmp (TYPE_FIELD_NAME (t, i), *pp,
2629 strlen (TYPE_FIELD_NAME (t, i))))
2631 TYPE_VPTR_FIELDNO (type) = i;
2635 error ("virtual function table field not found");
2638 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type));
2643 TYPE_VPTR_BASETYPE (type) = 0;
2644 TYPE_VPTR_FIELDNO (type) = -1;
2649 TYPE_VPTR_BASETYPE (type) = 0;
2650 TYPE_VPTR_FIELDNO (type) = -1;
2656 /* Read a definition of an enumeration type,
2657 and create and return a suitable type object.
2658 Also defines the symbols that represent the values of the type. */
2660 static struct type *
2661 read_enum_type (pp, type)
2663 register struct type *type;
2668 register struct symbol *sym;
2670 struct pending **symlist;
2671 struct pending *osyms, *syms;
2673 if (within_function)
2674 symlist = &local_symbols;
2676 symlist = &file_symbols;
2679 /* Read the value-names and their values.
2680 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
2681 A semicolon instead of a NAME means the end. */
2682 while (**pp && **pp != ';')
2684 /* Check for and handle cretinous dbx symbol name continuation! */
2685 if (**pp == '\\') *pp = next_symbol_text ();
2688 while (*p != ':') p++;
2689 name = savestring (*pp, p - *pp);
2691 n = read_number (pp, ',');
2693 sym = (struct symbol *) xmalloc (sizeof (struct symbol));
2694 bzero (sym, sizeof (struct symbol));
2695 SYMBOL_NAME (sym) = name;
2696 SYMBOL_CLASS (sym) = LOC_CONST;
2697 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2698 SYMBOL_VALUE (sym) = n;
2699 add_symbol_to_list (sym, symlist);
2703 (*pp)++; /* Skip the semicolon. */
2705 /* Now fill in the fields of the type-structure. */
2707 TYPE_LENGTH (type) = sizeof (int);
2708 TYPE_CODE (type) = TYPE_CODE_ENUM;
2709 TYPE_NFIELDS (type) = nsyms;
2710 TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms);
2712 /* Find the symbols for the values and put them into the type.
2713 The symbols can be found in the symlist that we put them on
2714 to cause them to be defined. osyms contains the old value
2715 of that symlist; everything up to there was defined by us. */
2717 for (syms = *symlist, n = nsyms; syms != osyms; syms = syms->next)
2719 SYMBOL_TYPE (syms->symbol) = type;
2720 TYPE_FIELD_NAME (type, --n) = SYMBOL_NAME (syms->symbol);
2721 TYPE_FIELD_VALUE (type, n) = SYMBOL_VALUE (syms->symbol);
2722 TYPE_FIELD_BITPOS (type, n) = 0;
2723 TYPE_FIELD_BITSIZE (type, n) = 0;
2729 static struct type *
2730 read_range_type (pp, typenums)
2738 /* First comes a type we are a subrange of.
2739 In practice it is usually 0, 1 or the type being defined. */
2740 read_type_number (pp, rangenums);
2743 /* A semicolon should now follow; skip it. */
2747 /* The remaining two operands are usually lower and upper bounds
2748 of the range. But in some special cases they mean something else. */
2749 n2 = read_number (pp, ';');
2750 n3 = read_number (pp, ';');
2752 /* A type defined as a subrange of itself, with bounds both 0, is void. */
2753 if (rangenums[0] == typenums[0] && rangenums[1] == typenums[1]
2754 && n2 == 0 && n3 == 0)
2755 return builtin_type_void;
2757 /* If n3 is zero and n2 is not, we want a floating type,
2758 and n2 is the width in bytes.
2760 Fortran programs appear to use this for complex types also,
2761 and they give no way to distinguish between double and single-complex!
2762 We don't have complex types, so we would lose on all fortran files!
2763 So return type `double' for all of those. It won't work right
2764 for the complex values, but at least it makes the file loadable. */
2766 if (n3 == 0 && n2 > 0)
2768 if (n2 == sizeof (float))
2769 return builtin_type_float;
2770 return builtin_type_double;
2773 /* If the upper bound is -1, it must really be an unsigned int. */
2775 else if (n2 == 0 && n3 == -1)
2777 if (sizeof (int) == sizeof (long))
2778 return builtin_type_unsigned_int;
2780 return builtin_type_unsigned_long;
2783 /* Detect unsigned subranges of int. Int is normally 1.
2784 Note that `char' is usually given bounds of 0 to 127,
2785 and would therefore appear unsigned; but it is described
2786 as a subrange of itself, so we reject it here. */
2788 else if (n2 == 0 && n1 == 1)
2790 /* an unsigned type */
2791 if (n3 == (1 << (8 * sizeof (int))) - 1)
2792 return builtin_type_unsigned_int;
2793 if (n3 == (1 << (8 * sizeof (short))) - 1)
2794 return builtin_type_unsigned_short;
2795 if (n3 == (1 << (8 * sizeof (char))) - 1)
2796 return builtin_type_unsigned_char;
2801 if (n3 == (1 << (8 * sizeof (int) - 1)) - 1)
2802 return builtin_type_int;
2803 if (n3 == (1 << (8 * sizeof (long) - 1)) - 1)
2804 return builtin_type_long;
2805 if (n3 == (1 << (8 * sizeof (short) - 1)) - 1)
2806 return builtin_type_short;
2807 if (n3 == (1 << (8 * sizeof (char) - 1)) - 1)
2808 return builtin_type_char;
2810 error ("Invalid symbol data: range type spec %s at symtab pos %d.",
2814 /* Read a number from the string pointed to by *PP.
2815 The value of *PP is advanced over the number.
2816 If END is nonzero, the character that ends the
2817 number must match END, or an error happens;
2818 and that character is skipped if it does match.
2819 If END is zero, *PP is left pointing to that character. */
2822 read_number (pp, end)
2826 register char *p = *pp;
2827 register long n = 0;
2831 /* Handle an optional leading minus sign. */
2839 /* Read the digits, as far as they go. */
2841 while ((c = *p++) >= '0' && c <= '9')
2849 error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum);
2858 /* Read in an argument list. This is a list of types. It is terminated with
2859 a ':', FYI. Return the list of types read in. */
2860 static struct type **
2865 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
2871 error ("Invalid argument list: no ',', at symtab pos %d", symnum);
2873 types[n++] = read_type (pp);
2875 *pp += 1; /* get past `end' (the ':' character) */
2879 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
2883 rval = (struct type **) xmalloc (n * sizeof (struct type *));
2885 bcopy (types, rval, n * sizeof (struct type *));
2889 /* This function is really horrible, but to avoid it, there would need
2890 to be more filling in of forward references. */
2892 fill_in_vptr_fieldno (type)
2895 if (TYPE_VPTR_FIELDNO (type) < 0)
2896 TYPE_VPTR_FIELDNO (type) = fill_in_vptr_fieldno (TYPE_BASECLASS (type));
2897 return TYPE_VPTR_FIELDNO (type);
2905 add_com ("symbol-file", class_files, symbol_file_command,
2906 "Load symbol table (in dbx format) from executable file FILE.");
2908 add_com ("add-file", class_files, add_file_command,
2909 "Load the symbols from FILE, assuming its codes is at TEXT_START.") ;
2914 #endif /* READ_DBX_FORMAT */