1 /* Symbol table lookup for the GNU debugger, GDB.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
22 #include "initialize.h"
35 /* Allocate an obstack to hold objects that should be freed
36 when we load a new symbol table.
37 This includes the symbols made by dbxread
38 and the types that are not permanent. */
40 struct obstack obstack1
;
42 struct obstack
*symbol_obstack
= &obstack1
;
44 /* These variables point to the objects
45 representing the predefined C data types. */
47 struct type
*builtin_type_void
;
48 struct type
*builtin_type_char
;
49 struct type
*builtin_type_short
;
50 struct type
*builtin_type_int
;
51 struct type
*builtin_type_long
;
52 struct type
*builtin_type_unsigned_char
;
53 struct type
*builtin_type_unsigned_short
;
54 struct type
*builtin_type_unsigned_int
;
55 struct type
*builtin_type_unsigned_long
;
56 struct type
*builtin_type_float
;
57 struct type
*builtin_type_double
;
59 /* Lookup the symbol table of a source file named NAME. */
65 register struct symtab
*s
;
68 for (s
= symtab_list
; s
; s
= s
->next
)
69 if (!strcmp (name
, s
->filename
))
72 /* If name not found as specified, see if adding ".c" helps. */
74 copy
= (char *) alloca (strlen (name
) + 3);
77 for (s
= symtab_list
; s
; s
= s
->next
)
78 if (!strcmp (copy
, s
->filename
))
84 /* Lookup a typedef or primitive type named NAME,
85 visible in lexical block BLOCK.
86 If NOERR is nonzero, return zero if NAME is not suitably defined. */
89 lookup_typename (name
, block
, noerr
)
94 register struct symbol
*sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
);
95 if (sym
== 0 || SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
97 if (!strcmp (name
, "int"))
98 return builtin_type_int
;
99 if (!strcmp (name
, "long"))
100 return builtin_type_long
;
101 if (!strcmp (name
, "short"))
102 return builtin_type_short
;
103 if (!strcmp (name
, "char"))
104 return builtin_type_char
;
105 if (!strcmp (name
, "float"))
106 return builtin_type_float
;
107 if (!strcmp (name
, "double"))
108 return builtin_type_double
;
109 if (!strcmp (name
, "void"))
110 return builtin_type_void
;
114 error ("No type named %s.", name
);
116 return SYMBOL_TYPE (sym
);
120 lookup_unsigned_typename (name
)
123 if (!strcmp (name
, "int"))
124 return builtin_type_unsigned_int
;
125 if (!strcmp (name
, "long"))
126 return builtin_type_unsigned_long
;
127 if (!strcmp (name
, "short"))
128 return builtin_type_unsigned_short
;
129 if (!strcmp (name
, "char"))
130 return builtin_type_unsigned_char
;
131 error ("No type named unsigned %s.", name
);
134 /* Lookup a structure type named "struct NAME",
135 visible in lexical block BLOCK. */
138 lookup_struct (name
, block
)
142 register struct symbol
*sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
);
144 error ("No struct type named %s.", name
);
145 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
146 error ("This context has union or enum %s, not a struct.", name
);
147 return SYMBOL_TYPE (sym
);
150 /* Lookup a union type named "union NAME",
151 visible in lexical block BLOCK. */
154 lookup_union (name
, block
)
158 register struct symbol
*sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
);
160 error ("No union type named %s.", name
);
161 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_UNION
)
162 error ("This context has struct or enum %s, not a union.", name
);
163 return SYMBOL_TYPE (sym
);
166 /* Lookup an enum type named "enum NAME",
167 visible in lexical block BLOCK. */
170 lookup_enum (name
, block
)
174 register struct symbol
*sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
);
176 error ("No enum type named %s.", name
);
177 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
178 error ("This context has struct or union %s, not an enum.", name
);
179 return SYMBOL_TYPE (sym
);
182 /* Given a type TYPE, return a type of pointers to that type.
183 May need to construct such a type if this is the first use. */
186 lookup_pointer_type (type
)
189 register struct type
*ptype
= TYPE_POINTER_TYPE (type
);
190 if (ptype
) return ptype
;
192 /* This is the first time anyone wanted a pointer to a TYPE. */
193 if (TYPE_FLAGS (type
) & TYPE_FLAG_PERM
)
194 ptype
= (struct type
*) xmalloc (sizeof (struct type
));
196 ptype
= (struct type
*) obstack_alloc (symbol_obstack
,
197 sizeof (struct type
));
199 bzero (ptype
, sizeof (struct type
));
200 TYPE_TARGET_TYPE (ptype
) = type
;
201 TYPE_POINTER_TYPE (type
) = ptype
;
202 /* New type is permanent if type pointed to is permanent. */
203 if (TYPE_FLAGS (type
) & TYPE_FLAG_PERM
)
204 TYPE_FLAGS (ptype
) |= TYPE_FLAG_PERM
;
205 /* We assume the machine has only one representation for pointers! */
206 TYPE_LENGTH (ptype
) = sizeof (char *);
207 TYPE_CODE (ptype
) = TYPE_CODE_PTR
;
211 /* Given a type TYPE, return a type of functions that return that type.
212 May need to construct such a type if this is the first use. */
215 lookup_function_type (type
)
218 register struct type
*ptype
= TYPE_FUNCTION_TYPE (type
);
219 if (ptype
) return ptype
;
221 /* This is the first time anyone wanted a function returning a TYPE. */
222 if (TYPE_FLAGS (type
) & TYPE_FLAG_PERM
)
223 ptype
= (struct type
*) xmalloc (sizeof (struct type
));
225 ptype
= (struct type
*) obstack_alloc (symbol_obstack
,
226 sizeof (struct type
));
228 bzero (ptype
, sizeof (struct type
));
229 TYPE_TARGET_TYPE (ptype
) = type
;
230 TYPE_FUNCTION_TYPE (type
) = ptype
;
231 /* New type is permanent if type returned is permanent. */
232 if (TYPE_FLAGS (type
) & TYPE_FLAG_PERM
)
233 TYPE_FLAGS (ptype
) |= TYPE_FLAG_PERM
;
234 TYPE_LENGTH (ptype
) = 1;
235 TYPE_CODE (ptype
) = TYPE_CODE_FUNC
;
236 TYPE_NFIELDS (ptype
) = 0;
240 /* Smash TYPE to be a type of pointers to TO_TYPE.
241 If TO_TYPE is not permanent and has no pointer-type yet,
242 record TYPE as its pointer-type. */
245 smash_to_pointer_type (type
, to_type
)
246 struct type
*type
, *to_type
;
248 bzero (type
, sizeof (struct type
));
249 TYPE_TARGET_TYPE (type
) = to_type
;
250 /* We assume the machine has only one representation for pointers! */
251 TYPE_LENGTH (type
) = sizeof (char *);
252 TYPE_CODE (type
) = TYPE_CODE_PTR
;
254 if (TYPE_POINTER_TYPE (to_type
) == 0
255 && !(TYPE_FLAGS (type
) & TYPE_FLAG_PERM
))
257 TYPE_POINTER_TYPE (to_type
) = type
;
261 /* Smash TYPE to be a type of functions returning TO_TYPE.
262 If TO_TYPE is not permanent and has no function-type yet,
263 record TYPE as its function-type. */
266 smash_to_function_type (type
, to_type
)
267 struct type
*type
, *to_type
;
269 bzero (type
, sizeof (struct type
));
270 TYPE_TARGET_TYPE (type
) = to_type
;
271 TYPE_LENGTH (type
) = 1;
272 TYPE_CODE (type
) = TYPE_CODE_FUNC
;
273 TYPE_NFIELDS (type
) = 0;
275 if (TYPE_FUNCTION_TYPE (to_type
) == 0
276 && !(TYPE_FLAGS (type
) & TYPE_FLAG_PERM
))
278 TYPE_FUNCTION_TYPE (to_type
) = type
;
282 static struct symbol
*lookup_block_symbol ();
284 /* Find the definition for a specified symbol name NAME
285 in namespace NAMESPACE, visible from lexical block BLOCK.
286 Returns the struct symbol pointer, or zero if no symbol is found. */
289 lookup_symbol (name
, block
, namespace)
291 register struct block
*block
;
292 enum namespace namespace;
295 register struct symbol
*sym
;
296 register struct symtab
*s
;
297 struct blockvector
*bv
;
299 /* Search specified block and its superiors. */
303 sym
= lookup_block_symbol (block
, name
, namespace);
305 block
= BLOCK_SUPERBLOCK (block
);
308 /* Now search all symtabs' global blocks. */
310 for (s
= symtab_list
; s
; s
= s
->next
)
312 bv
= BLOCKVECTOR (s
);
313 block
= BLOCKVECTOR_BLOCK (bv
, 0);
314 sym
= lookup_block_symbol (block
, name
, namespace);
318 /* Now search all symtabs' per-file blocks.
319 Not strictly correct, but more useful than an error. */
321 for (s
= symtab_list
; s
; s
= s
->next
)
323 bv
= BLOCKVECTOR (s
);
324 block
= BLOCKVECTOR_BLOCK (bv
, 1);
325 sym
= lookup_block_symbol (block
, name
, namespace);
331 /* Look for a symbol in block BLOCK using binary search. */
333 static struct symbol
*
334 lookup_block_symbol (block
, name
, namespace)
335 register struct block
*block
;
337 enum namespace namespace;
339 register int bot
, top
, inc
;
340 register struct symbol
*sym
;
342 top
= BLOCK_NSYMS (block
);
345 /* First, advance BOT to not far before
346 the first symbol whose name is NAME. */
350 inc
= (top
- bot
+ 1);
351 /* No need to keep binary searching for the last few bits worth. */
355 sym
= BLOCK_SYM (block
, bot
+ inc
);
356 if (strcmp (SYMBOL_NAME (sym
), name
) < 0)
362 /* Now scan forward until we run out of symbols,
363 find one whose name is greater than NAME,
365 If there is more than one symbol with the right name and namespace,
366 we return the first one. dbxread.c is careful to make sure
367 that if one is a register then it comes first. */
369 top
= BLOCK_NSYMS (block
);
372 sym
= BLOCK_SYM (block
, bot
);
373 inc
= strcmp (SYMBOL_NAME (sym
), name
);
374 if (inc
== 0 && SYMBOL_NAMESPACE (sym
) == namespace)
383 /* Return the symbol for the function which contains a specified
384 lexical block, described by a struct block BL. */
390 while (BLOCK_FUNCTION (bl
) == 0 && BLOCK_SUPERBLOCK (bl
) != 0)
391 bl
= BLOCK_SUPERBLOCK (bl
);
393 return BLOCK_FUNCTION (bl
);
396 /* Subroutine of find_pc_line */
398 static struct symtab
*
400 register CORE_ADDR pc
;
402 register struct block
*b
;
403 struct blockvector
*bv
;
404 register struct symtab
*s
;
406 /* Search all symtabs for one whose file contains our pc */
408 for (s
= symtab_list
; s
; s
= s
->next
)
410 bv
= BLOCKVECTOR (s
);
411 b
= BLOCKVECTOR_BLOCK (bv
, 0);
412 if (BLOCK_START (b
) <= pc
413 && BLOCK_END (b
) > pc
)
420 /* Find the source file and line number for a given PC value.
421 Return a structure containing a symtab pointer, a line number,
422 and a pc range for the entire source line.
423 The value's .pc field is NOT the specified pc.
424 NOTCURRENT nonzero means, if specified pc is on a line boundary,
425 use the line that ends there. Otherwise, in that case, the line
426 that begins there is used. */
428 struct symtab_and_line
429 find_pc_line (pc
, notcurrent
)
434 register struct linetable
*l
;
436 register int i
, item
;
438 struct symtab_and_line value
;
439 struct blockvector
*bv
;
441 /* Info on best line seen so far, and where it starts, and its file. */
444 CORE_ADDR best_pc
= 0;
445 CORE_ADDR best_end
= 0;
446 struct symtab
*best_symtab
= 0;
448 /* Store here the first line number
449 of a file which contains the line at the smallest pc after PC.
450 If we don't find a line whose range contains PC,
451 we will use a line one less than this,
452 with a range from the start of that file to the first line's pc. */
454 CORE_ADDR alt_pc
= 0;
455 struct symtab
*alt_symtab
= 0;
457 /* Info on best line seen in this file. */
462 /* Info on first line of this file. */
467 /* If this pc is not from the current frame,
468 it is the address of the end of a call instruction.
469 Quite likely that is the start of the following statement.
470 But what we want is the statement containing the instruction.
471 Fudge the pc to make sure we get that. */
473 if (notcurrent
) pc
-= 1;
475 s
= find_pc_symtab (pc
);
484 bv
= BLOCKVECTOR (s
);
486 /* Look at all the symtabs that share this blockvector.
487 They all have the same apriori range, that we found was right;
488 but they have different line tables. */
490 for (; s
&& BLOCKVECTOR (s
) == bv
; s
= s
->next
)
492 /* Find the best line in this symtab. */
497 for (i
= 0; i
< len
; i
++)
510 /* Return the last line that did not start after PC. */
521 /* Is this file's best line closer than the best in the other files?
522 If so, record this file, and its best line, as best so far. */
523 if (prev_line
>= 0 && prev_pc
> best_pc
)
526 best_line
= prev_line
;
533 /* Is this file's first line closer than the first lines of other files?
534 If so, record this file, and its first line, as best alternate. */
535 if (first_line
>= 0 && first_pc
> pc
536 && (alt_pc
== 0 || first_pc
< alt_pc
))
539 alt_line
= first_line
;
543 if (best_symtab
== 0)
545 value
.symtab
= alt_symtab
;
546 value
.line
= alt_line
- 1;
547 value
.pc
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, 0));
552 value
.symtab
= best_symtab
;
553 value
.line
= best_line
;
555 value
.end
= (best_end
? best_end
557 : BLOCK_END (BLOCKVECTOR_BLOCK (bv
, 0))));
562 /* Find the range of pc values in a line.
563 Store the starting pc of the line into *STARTPTR
564 and the ending pc (start of next line) into *ENDPTR.
565 Returns 1 to indicate success.
566 Returns 0 if could not find the specified line. */
569 find_line_pc_range (symtab
, thisline
, startptr
, endptr
)
570 struct symtab
*symtab
;
572 CORE_ADDR
*startptr
, *endptr
;
574 register struct linetable
*l
;
575 register int i
, line
, item
;
577 register CORE_ADDR prev_pc
;
583 l
= LINETABLE (symtab
);
586 for (i
= 0; i
< len
; i
++)
594 /* As soon as we find a line following the specified one
595 we know the end pc and can return. */
598 /* If we have not seen an entry for the specified line,
599 assume that means the specified line has zero bytes. */
600 *startptr
= prev_pc
== -1 ? item
: prev_pc
;
604 /* If we see an entry for the specified line,
605 it gives the beginning. */
606 if (line
== thisline
)
613 /* If we found the specified line but no later line, it's file's last.
614 Its range is from line's pc to file's end pc. */
616 *endptr
= BLOCK_END (BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab
), 0));
623 /* Find the PC value for a given source file and line number.
624 Returns zero for invalid line number.
625 The source file is specified with a struct symtab. */
628 find_line_pc (symtab
, line
)
629 struct symtab
*symtab
;
632 register struct linetable
*l
;
636 register int nextline
= -1;
641 l
= LINETABLE (symtab
);
643 for (i
= 0; i
< len
; i
++)
647 nextline
= - item
- 1;
651 if (line
<= nextline
)
659 find_pc_line_pc_range (pc
, startptr
, endptr
)
661 CORE_ADDR
*startptr
, *endptr
;
663 struct symtab_and_line sal
;
664 sal
= find_pc_line (pc
, 0);
667 return sal
.symtab
!= 0;
670 /* Parse a string that specifies a line number.
671 Pass the address of a char * variable; that variable will be
672 advanced over the characters actually parsed.
676 LINENUM -- that line number in current file. PC returned is 0.
677 FILE:LINENUM -- that line in that file. PC returned is 0.
678 FUNCTION -- line number of openbrace of that function.
679 PC returned is the start of the function.
680 FILE:FUNCTION -- likewise, but prefer functions in that file.
681 *EXPR -- line in which address EXPR appears.
683 FUNCTION may be an undebuggable function found in misc_function_vector.
685 If the argument FUNFIRSTLINE is nonzero, we want the first line
686 of real code inside a function when a function is specified.
688 DEFAULT_SYMTAB specifies the file to use if none is specified.
689 It defaults to current_source_symtab.
690 DEFAULT_LINE specifies the line number to use for relative
691 line numbers (that start with signs). Defaults to current_source_line.
693 Note that it is possible to return zero for the symtab
694 if no file is validly specified. Callers must check that.
695 Also, the line number returned may be invalid. */
697 struct symtab_and_line
698 decode_line_1 (argptr
, funfirstline
, default_symtab
, default_line
)
701 struct symtab
*default_symtab
;
704 struct symtab_and_line value
;
705 register char *p
, *p1
;
706 register struct symtab
*s
;
707 register struct symbol
*sym
;
708 register CORE_ADDR pc
;
712 /* Defaults have defaults. */
714 if (default_symtab
== 0)
716 default_symtab
= current_source_symtab
;
717 default_line
= current_source_line
;
720 /* See if arg is *PC */
725 pc
= parse_and_eval_address_1 (argptr
);
726 value
= find_pc_line (pc
, 0);
731 /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
735 for (p
= *argptr
; *p
; p
++)
737 if (p
[0] == ':' || p
[0] == ' ' || p
[0] == '\t')
740 while (p
[0] == ' ' || p
[0] == '\t') p
++;
744 /* Extract the file name. */
746 while (p
!= *argptr
&& p
[-1] == ' ') --p
;
747 copy
= (char *) alloca (p
- *argptr
+ 1);
748 bcopy (*argptr
, copy
, p
- *argptr
);
749 copy
[p
- *argptr
] = 0;
751 /* Find that file's data. */
752 s
= lookup_symtab (copy
);
755 if (symtab_list
== 0)
756 error ("No symbol table is loaded. Use the \"symbol-file\" command.");
757 error ("No source file named %s.", copy
);
760 /* Discard the file name from the arg. */
762 while (*p
== ' ' || *p
== '\t') p
++;
766 /* S is specified file's symtab, or 0 if no file specified.
767 arg no longer contains the file name. */
769 /* Check whether arg is all digits (and sign) */
772 if (*p
== '-' || *p
== '+') p
++;
773 while (*p
>= '0' && *p
<= '9')
776 if (p
!= *argptr
&& (*p
== 0 || *p
== ' ' || *p
== '\t' || *p
== ','))
778 /* We found a token consisting of all digits -- at least one digit. */
779 enum sign
{none
, plus
, minus
} sign
= none
;
782 sign
= plus
, (*argptr
)++;
783 else if (**argptr
== '-')
784 sign
= minus
, (*argptr
)++;
785 value
.line
= atoi (*argptr
);
792 value
.line
= default_line
+ value
.line
;
798 value
.line
= default_line
- value
.line
;
804 while (*p
== ' ' || *p
== '\t') p
++;
813 /* Arg token is not digits => try it as a function name
814 Find the next token (everything up to end or next whitespace). */
816 while (*p
&& *p
!= ' ' && *p
!= '\t' && *p
!= ',') p
++;
817 copy
= (char *) alloca (p
- *argptr
+ 1);
818 bcopy (*argptr
, copy
, p
- *argptr
);
819 copy
[p
- *argptr
] = 0;
820 while (*p
== ' ' || *p
== '\t') p
++;
823 /* Look up that token as a function.
824 If file specified, use that file's per-file block to start with. */
826 sym
= lookup_symbol (copy
, s
? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), 1) : 0,
829 if (sym
&& SYMBOL_CLASS (sym
) == LOC_BLOCK
)
831 /* Arg is the name of a function */
832 pc
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)) + FUNCTION_START_OFFSET
;
835 value
= find_pc_line (pc
, 0);
836 value
.pc
= (value
.end
&& value
.pc
!= pc
) ? value
.end
: pc
;
841 error ("%s is not a function.", copy
);
843 for (i
= 0; i
< misc_function_count
; i
++)
844 if (!strcmp (misc_function_vector
[i
].name
, copy
))
848 value
.pc
= misc_function_vector
[i
].address
+ FUNCTION_START_OFFSET
;
850 SKIP_PROLOGUE (value
.pc
);
854 if (symtab_list
== 0)
855 error ("No symbol table is loaded. Use the \"symbol-file\" command.");
856 error ("Function %s not defined.", copy
);
859 struct symtab_and_line
860 decode_line_spec (string
, funfirstline
)
864 struct symtab_and_line sal
;
866 error ("Empty line specification.");
867 sal
= decode_line_1 (&string
, funfirstline
,
868 current_source_symtab
, current_source_line
);
870 error ("Junk at end of line specification: %s", string
);
877 register struct symtab
*s
;
878 register int column
= 0;
880 if (symtab_list
== 0)
882 printf ("No symbol table is loaded.\n");
885 printf ("Source files for which symbol table is known:\n");
886 for (s
= symtab_list
; s
; s
= s
->next
)
888 if (column
!= 0 && column
+ strlen (s
->filename
) >= 70)
893 else if (column
!= 0)
898 printf ("%s", s
->filename
);
899 column
+= strlen (s
->filename
);
909 /* List all symbols (if REGEXP is 0) or all symbols matching REGEXP.
910 If CLASS is zero, list all symbols except functions and type names.
911 If CLASS is 1, list only functions.
912 If CLASS is 2, list only type names. */
916 if (print_count >= 21) \
917 { printf ("--Type Return to print more--"); \
923 list_symbols (regexp
, class)
927 register struct symtab
*s
;
928 register struct blockvector
*bv
;
929 struct blockvector
*prev_bv
= 0;
930 register struct block
*b
;
932 register struct symbol
*sym
;
935 static char *classnames
[]
936 = {"variable", "function", "type"};
939 extern char *regcmp(), *regex(), *loc1
;
944 val
= regcmp(regexp
, (char *)0);
946 error ("Invalid regexp: %s", regexp
);
948 if (val
= (char *) re_comp (regexp
))
949 error ("Invalid regexp: %s", val
);
954 ? "All %ss matching regular expression \"%s\":\n"
955 : "All defined %ss:\n",
959 for (s
= symtab_list
; s
; s
= s
->next
)
962 bv
= BLOCKVECTOR (s
);
963 /* Often many files share a blockvector.
964 Scan each blockvector only once so that
965 we don't get every symbol many times.
966 It happens that the first symtab in the list
967 for any given blockvector is the main file. */
969 for (i
= 0; i
< 2; i
++)
971 b
= BLOCKVECTOR_BLOCK (bv
, i
);
972 for (j
= 0; j
< BLOCK_NSYMS (b
); j
++)
975 sym
= BLOCK_SYM (b
, j
);
978 if (!regex(val
, SYMBOL_NAME (sym
)))
981 if (!re_exec (SYMBOL_NAME (sym
)))
985 if ((class == 0 && SYMBOL_CLASS (sym
) != LOC_TYPEDEF
986 && SYMBOL_CLASS (sym
) != LOC_BLOCK
)
987 || (class == 1 && SYMBOL_CLASS (sym
) == LOC_BLOCK
)
988 || (class == 2 && SYMBOL_CLASS (sym
) == LOC_TYPEDEF
))
992 printf ("\nFile %s:\n", s
->filename
);
997 if (class != 2 && i
== 1)
1000 && SYMBOL_NAMESPACE (sym
) != STRUCT_NAMESPACE
)
1001 printf ("typedef ");
1003 type_print (SYMBOL_TYPE (sym
),
1004 (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
1005 ? "" : SYMBOL_NAME (sym
)),
1008 && SYMBOL_NAMESPACE (sym
) != STRUCT_NAMESPACE
1009 && (TYPE_NAME ((SYMBOL_TYPE (sym
))) == 0
1010 || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (sym
))),
1011 SYMBOL_NAME (sym
))))
1012 printf (" %s", SYMBOL_NAME (sym
));
1026 variables_info (regexp
)
1029 list_symbols (regexp
, 0);
1033 functions_info (regexp
)
1036 list_symbols (regexp
, 1);
1043 list_symbols (regexp
, 2);
1046 /* Initialize the standard C scalar types. */
1050 init_type (code
, length
, uns
, name
)
1051 enum type_code code
;
1055 register struct type
*type
;
1057 type
= (struct type
*) xmalloc (sizeof (struct type
));
1058 bzero (type
, sizeof *type
);
1059 TYPE_CODE (type
) = code
;
1060 TYPE_LENGTH (type
) = length
;
1061 TYPE_FLAGS (type
) = uns
? TYPE_FLAG_UNSIGNED
: 0;
1062 TYPE_FLAGS (type
) |= TYPE_FLAG_PERM
;
1063 TYPE_NFIELDS (type
) = 0;
1064 TYPE_NAME (type
) = name
;
1072 add_info ("variables", variables_info
,
1073 "All global and static variable names, or those matching REGEXP.");
1074 add_info ("functions", functions_info
,
1075 "All function names, or those matching REGEXP.");
1076 add_info ("types", types_info
,
1077 "All types names, or those matching REGEXP.");
1078 add_info ("sources", sources_info
,
1079 "Source files in the program.");
1081 obstack_init (symbol_obstack
);
1083 builtin_type_void
= init_type (TYPE_CODE_VOID
, 0, 0, "void");
1085 builtin_type_float
= init_type (TYPE_CODE_FLT
, sizeof (float), 0, "float");
1086 builtin_type_double
= init_type (TYPE_CODE_FLT
, sizeof (double), 0, "double");
1088 builtin_type_char
= init_type (TYPE_CODE_INT
, sizeof (char), 0, "char");
1089 builtin_type_short
= init_type (TYPE_CODE_INT
, sizeof (short), 0, "short");
1090 builtin_type_long
= init_type (TYPE_CODE_INT
, sizeof (long), 0, "long");
1091 builtin_type_int
= init_type (TYPE_CODE_INT
, sizeof (int), 0, "int");
1093 builtin_type_unsigned_char
= init_type (TYPE_CODE_INT
, sizeof (char), 1, "unsigned char");
1094 builtin_type_unsigned_short
= init_type (TYPE_CODE_INT
, sizeof (short), 1, "unsigned short");
1095 builtin_type_unsigned_long
= init_type (TYPE_CODE_INT
, sizeof (long), 1, "unsigned long");
1096 builtin_type_unsigned_int
= init_type (TYPE_CODE_INT
, sizeof (int), 1, "unsigned int");