1 /* Symbol table lookup for the GNU debugger, GDB.
2 Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
31 #include "call-cmds.h"
32 #include "gnu-regex.h"
33 #include "expression.h"
40 #include <sys/types.h>
42 #include "gdb_string.h"
46 /* Prototypes for local functions */
49 find_methods
PARAMS ((struct type
*, char *, struct symbol
**));
52 completion_list_add_name
PARAMS ((char *, char *, int, char *, char *));
55 build_canonical_line_spec
PARAMS ((struct symtab_and_line
*, char *, char ***));
57 static struct symtabs_and_lines
58 decode_line_2
PARAMS ((struct symbol
*[], int, int, char ***));
61 rbreak_command
PARAMS ((char *, int));
64 types_info
PARAMS ((char *, int));
67 functions_info
PARAMS ((char *, int));
70 variables_info
PARAMS ((char *, int));
73 sources_info
PARAMS ((char *, int));
76 list_symbols
PARAMS ((char *, int, int, int));
79 output_source_filename
PARAMS ((char *, int *));
82 operator_chars
PARAMS ((char *, char **));
84 static int find_line_common
PARAMS ((struct linetable
*, int, int *));
86 static struct partial_symbol
*
87 lookup_partial_symbol
PARAMS ((struct partial_symtab
*, const char *,
88 int, namespace_enum
));
90 static struct symtab
*
91 lookup_symtab_1
PARAMS ((char *));
94 cplusplus_hint
PARAMS ((char *));
96 static struct symbol
*
97 find_active_alias
PARAMS ((struct symbol
*sym
, CORE_ADDR addr
));
101 /* The single non-language-specific builtin type */
102 struct type
*builtin_type_error
;
104 /* Block in which the most recently searched-for symbol was found.
105 Might be better to make this a parameter to lookup_symbol and
108 const struct block
*block_found
;
110 char no_symtab_msg
[] = "No symbol table is loaded. Use the \"file\" command.";
112 /* While the C++ support is still in flux, issue a possibly helpful hint on
113 using the new command completion feature on single quoted demangled C++
114 symbols. Remove when loose ends are cleaned up. FIXME -fnf */
117 cplusplus_hint (name
)
120 while (*name
== '\'')
122 printf_filtered ("Hint: try '%s<TAB> or '%s<ESC-?>\n", name
, name
);
123 printf_filtered ("(Note leading single quote.)\n");
126 /* Check for a symtab of a specific name; first in symtabs, then in
127 psymtabs. *If* there is no '/' in the name, a match after a '/'
128 in the symtab filename will also work. */
130 static struct symtab
*
131 lookup_symtab_1 (name
)
134 register struct symtab
*s
;
135 register struct partial_symtab
*ps
;
136 register char *slash
;
137 register struct objfile
*objfile
;
141 /* First, search for an exact match */
143 ALL_SYMTABS (objfile
, s
)
144 if (STREQ (name
, s
->filename
))
147 slash
= strchr (name
, '/');
149 /* Now, search for a matching tail (only if name doesn't have any dirs) */
152 ALL_SYMTABS (objfile
, s
)
154 char *p
= s
-> filename
;
155 char *tail
= strrchr (p
, '/');
164 /* Same search rules as above apply here, but now we look thru the
167 ps
= lookup_partial_symtab (name
);
172 error ("Internal: readin %s pst for `%s' found when no symtab found.",
173 ps
-> filename
, name
);
175 s
= PSYMTAB_TO_SYMTAB (ps
);
180 /* At this point, we have located the psymtab for this file, but
181 the conversion to a symtab has failed. This usually happens
182 when we are looking up an include file. In this case,
183 PSYMTAB_TO_SYMTAB doesn't return a symtab, even though one has
184 been created. So, we need to run through the symtabs again in
185 order to find the file.
186 XXX - This is a crock, and should be fixed inside of the the
187 symbol parsing routines. */
191 /* Lookup the symbol table of a source file named NAME. Try a couple
192 of variations if the first lookup doesn't work. */
198 register struct symtab
*s
;
203 s
= lookup_symtab_1 (name
);
207 /* This screws c-exp.y:yylex if there is both a type "tree" and a symtab
210 /* If name not found as specified, see if adding ".c" helps. */
211 /* Why is this? Is it just a user convenience? (If so, it's pretty
212 questionable in the presence of C++, FORTRAN, etc.). It's not in
215 copy
= (char *) alloca (strlen (name
) + 3);
218 s
= lookup_symtab_1 (copy
);
222 /* We didn't find anything; die. */
226 /* Lookup the partial symbol table of a source file named NAME.
227 *If* there is no '/' in the name, a match after a '/'
228 in the psymtab filename will also work. */
230 struct partial_symtab
*
231 lookup_partial_symtab (name
)
234 register struct partial_symtab
*pst
;
235 register struct objfile
*objfile
;
237 ALL_PSYMTABS (objfile
, pst
)
239 if (STREQ (name
, pst
-> filename
))
245 /* Now, search for a matching tail (only if name doesn't have any dirs) */
247 if (!strchr (name
, '/'))
248 ALL_PSYMTABS (objfile
, pst
)
250 char *p
= pst
-> filename
;
251 char *tail
= strrchr (p
, '/');
263 /* Demangle a GDB method stub type.
264 Note that this function is g++ specific. */
267 gdb_mangle_name (type
, i
, j
)
271 int mangled_name_len
;
273 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (type
, i
);
274 struct fn_field
*method
= &f
[j
];
275 char *field_name
= TYPE_FN_FIELDLIST_NAME (type
, i
);
276 char *physname
= TYPE_FN_FIELD_PHYSNAME (f
, j
);
277 char *newname
= type_name_no_tag (type
);
279 /* Does the form of physname indicate that it is the full mangled name
280 of a constructor (not just the args)? */
281 int is_full_physname_constructor
;
284 int is_destructor
= DESTRUCTOR_PREFIX_P (physname
);
285 /* Need a new type prefix. */
286 char *const_prefix
= method
->is_const
? "C" : "";
287 char *volatile_prefix
= method
->is_volatile
? "V" : "";
289 int len
= (newname
== NULL
? 0 : strlen (newname
));
291 is_full_physname_constructor
=
292 ((physname
[0]=='_' && physname
[1]=='_' &&
293 (isdigit(physname
[2]) || physname
[2]=='Q' || physname
[2]=='t'))
294 || (strncmp(physname
, "__ct", 4) == 0));
297 is_full_physname_constructor
|| (newname
&& STREQ(field_name
, newname
));
300 is_destructor
= (strncmp(physname
, "__dt", 4) == 0);
302 if (is_destructor
|| is_full_physname_constructor
)
304 mangled_name
= (char*) xmalloc(strlen(physname
)+1);
305 strcpy(mangled_name
, physname
);
311 sprintf (buf
, "__%s%s", const_prefix
, volatile_prefix
);
313 else if (physname
[0] == 't' || physname
[0] == 'Q')
315 /* The physname for template and qualified methods already includes
317 sprintf (buf
, "__%s%s", const_prefix
, volatile_prefix
);
323 sprintf (buf
, "__%s%s%d", const_prefix
, volatile_prefix
, len
);
325 mangled_name_len
= ((is_constructor
? 0 : strlen (field_name
))
330 /* Only needed for GNU-mangled names. ANSI-mangled names
331 work with the normal mechanisms. */
332 if (OPNAME_PREFIX_P (field_name
))
334 const char *opname
= cplus_mangle_opname (field_name
+ 3, 0);
336 error ("No mangling for \"%s\"", field_name
);
337 mangled_name_len
+= strlen (opname
);
338 mangled_name
= (char *)xmalloc (mangled_name_len
);
340 strncpy (mangled_name
, field_name
, 3);
341 mangled_name
[3] = '\0';
342 strcat (mangled_name
, opname
);
346 mangled_name
= (char *)xmalloc (mangled_name_len
);
348 mangled_name
[0] = '\0';
350 strcpy (mangled_name
, field_name
);
352 strcat (mangled_name
, buf
);
353 /* If the class doesn't have a name, i.e. newname NULL, then we just
354 mangle it using 0 for the length of the class. Thus it gets mangled
355 as something starting with `::' rather than `classname::'. */
357 strcat (mangled_name
, newname
);
359 strcat (mangled_name
, physname
);
360 return (mangled_name
);
365 struct partial_symbol
* fixup_psymbol_section
PARAMS ((struct partial_symbol
*,
369 /* Find which partial symtab on contains PC and SECTION. Return 0 if none. */
371 struct partial_symtab
*
372 find_pc_sect_psymtab (pc
, section
)
376 register struct partial_symtab
*pst
;
377 register struct objfile
*objfile
;
379 ALL_PSYMTABS (objfile
, pst
)
381 if (pc
>= pst
->textlow
&& pc
< pst
->texthigh
)
383 struct minimal_symbol
*msymbol
;
384 struct partial_symtab
*tpst
;
386 /* An objfile that has its functions reordered might have
387 many partial symbol tables containing the PC, but
388 we want the partial symbol table that contains the
389 function containing the PC. */
390 if (!(objfile
->flags
& OBJF_REORDERED
) &&
391 section
== 0) /* can't validate section this way */
394 msymbol
= lookup_minimal_symbol_by_pc_section (pc
, section
);
398 for (tpst
= pst
; tpst
!= NULL
; tpst
= tpst
->next
)
400 if (pc
>= tpst
->textlow
&& pc
< tpst
->texthigh
)
402 struct partial_symbol
*p
;
404 p
= find_pc_sect_psymbol (tpst
, pc
, section
);
406 && SYMBOL_VALUE_ADDRESS(p
)
407 == SYMBOL_VALUE_ADDRESS (msymbol
))
417 /* Find which partial symtab contains PC. Return 0 if none.
418 Backward compatibility, no section */
420 struct partial_symtab
*
424 return find_pc_sect_psymtab (pc
, find_pc_mapped_section (pc
));
427 /* Find which partial symbol within a psymtab matches PC and SECTION.
428 Return 0 if none. Check all psymtabs if PSYMTAB is 0. */
430 struct partial_symbol
*
431 find_pc_sect_psymbol (psymtab
, pc
, section
)
432 struct partial_symtab
*psymtab
;
436 struct partial_symbol
*best
= NULL
, *p
, **pp
;
440 psymtab
= find_pc_sect_psymtab (pc
, section
);
444 best_pc
= psymtab
->textlow
- 1;
446 /* Search the global symbols as well as the static symbols, so that
447 find_pc_partial_function doesn't use a minimal symbol and thus
448 cache a bad endaddr. */
449 for (pp
= psymtab
->objfile
->global_psymbols
.list
+ psymtab
->globals_offset
;
450 (pp
- (psymtab
->objfile
->global_psymbols
.list
+ psymtab
->globals_offset
)
451 < psymtab
->n_global_syms
);
455 if (SYMBOL_NAMESPACE (p
) == VAR_NAMESPACE
456 && SYMBOL_CLASS (p
) == LOC_BLOCK
457 && pc
>= SYMBOL_VALUE_ADDRESS (p
)
458 && SYMBOL_VALUE_ADDRESS (p
) > best_pc
)
460 if (section
) /* match on a specific section */
462 fixup_psymbol_section (p
, psymtab
->objfile
);
463 if (SYMBOL_BFD_SECTION (p
) != section
)
466 best_pc
= SYMBOL_VALUE_ADDRESS (p
);
470 for (pp
= psymtab
->objfile
->static_psymbols
.list
+ psymtab
->statics_offset
;
471 (pp
- (psymtab
->objfile
->static_psymbols
.list
+ psymtab
->statics_offset
)
472 < psymtab
->n_static_syms
);
476 if (SYMBOL_NAMESPACE (p
) == VAR_NAMESPACE
477 && SYMBOL_CLASS (p
) == LOC_BLOCK
478 && pc
>= SYMBOL_VALUE_ADDRESS (p
)
479 && SYMBOL_VALUE_ADDRESS (p
) > best_pc
)
481 if (section
) /* match on a specific section */
483 fixup_psymbol_section (p
, psymtab
->objfile
);
484 if (SYMBOL_BFD_SECTION (p
) != section
)
487 best_pc
= SYMBOL_VALUE_ADDRESS (p
);
491 if (best_pc
== psymtab
->textlow
- 1)
496 /* Find which partial symbol within a psymtab matches PC. Return 0 if none.
497 Check all psymtabs if PSYMTAB is 0. Backwards compatibility, no section. */
499 struct partial_symbol
*
500 find_pc_psymbol (psymtab
, pc
)
501 struct partial_symtab
*psymtab
;
504 return find_pc_sect_psymbol (psymtab
, pc
, find_pc_mapped_section (pc
));
507 /* Debug symbols usually don't have section information. We need to dig that
508 out of the minimal symbols and stash that in the debug symbol. */
511 fixup_section (ginfo
, objfile
)
512 struct general_symbol_info
*ginfo
;
513 struct objfile
*objfile
;
515 struct minimal_symbol
*msym
;
516 msym
= lookup_minimal_symbol (ginfo
->name
, NULL
, objfile
);
519 ginfo
->bfd_section
= SYMBOL_BFD_SECTION (msym
);
523 fixup_symbol_section (sym
, objfile
)
525 struct objfile
*objfile
;
530 if (SYMBOL_BFD_SECTION (sym
))
533 fixup_section (&sym
->ginfo
, objfile
);
538 struct partial_symbol
*
539 fixup_psymbol_section (psym
, objfile
)
540 struct partial_symbol
*psym
;
541 struct objfile
*objfile
;
546 if (SYMBOL_BFD_SECTION (psym
))
549 fixup_section (&psym
->ginfo
, objfile
);
554 /* Find the definition for a specified symbol name NAME
555 in namespace NAMESPACE, visible from lexical block BLOCK.
556 Returns the struct symbol pointer, or zero if no symbol is found.
557 If SYMTAB is non-NULL, store the symbol table in which the
558 symbol was found there, or NULL if not found.
559 C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if
560 NAME is a field of the current implied argument `this'. If so set
561 *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero.
562 BLOCK_FOUND is set to the block in which NAME is found (in the case of
563 a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */
565 /* This function has a bunch of loops in it and it would seem to be
566 attractive to put in some QUIT's (though I'm not really sure
567 whether it can run long enough to be really important). But there
568 are a few calls for which it would appear to be bad news to quit
569 out of here: find_proc_desc in alpha-tdep.c and mips-tdep.c, and
570 nindy_frame_chain_valid in nindy-tdep.c. (Note that there is C++
571 code below which can error(), but that probably doesn't affect
572 these calls since they are looking for a known variable and thus
573 can probably assume it will never hit the C++ code). */
576 lookup_symbol (name
, block
, namespace, is_a_field_of_this
, symtab
)
578 register const struct block
*block
;
579 const namespace_enum
namespace;
580 int *is_a_field_of_this
;
581 struct symtab
**symtab
;
583 register struct symbol
*sym
;
584 register struct symtab
*s
= NULL
;
585 register struct partial_symtab
*ps
;
586 struct blockvector
*bv
;
587 register struct objfile
*objfile
= NULL
;
588 register struct block
*b
;
589 register struct minimal_symbol
*msymbol
;
591 /* Search specified block and its superiors. */
595 sym
= lookup_block_symbol (block
, name
, namespace);
601 /* Search the list of symtabs for one which contains the
602 address of the start of this block. */
603 ALL_SYMTABS (objfile
, s
)
605 bv
= BLOCKVECTOR (s
);
606 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
607 if (BLOCK_START (b
) <= BLOCK_START (block
)
608 && BLOCK_END (b
) > BLOCK_START (block
))
615 return fixup_symbol_section (sym
, objfile
);
617 block
= BLOCK_SUPERBLOCK (block
);
620 /* FIXME: this code is never executed--block is always NULL at this
621 point. What is it trying to do, anyway? We already should have
622 checked the STATIC_BLOCK above (it is the superblock of top-level
623 blocks). Why is VAR_NAMESPACE special-cased? */
624 /* Don't need to mess with the psymtabs; if we have a block,
625 that file is read in. If we don't, then we deal later with
626 all the psymtab stuff that needs checking. */
627 if (namespace == VAR_NAMESPACE
&& block
!= NULL
)
630 /* Find the right symtab. */
631 ALL_SYMTABS (objfile
, s
)
633 bv
= BLOCKVECTOR (s
);
634 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
635 if (BLOCK_START (b
) <= BLOCK_START (block
)
636 && BLOCK_END (b
) > BLOCK_START (block
))
638 sym
= lookup_block_symbol (b
, name
, VAR_NAMESPACE
);
644 return fixup_symbol_section (sym
, objfile
);
651 /* C++: If requested to do so by the caller,
652 check to see if NAME is a field of `this'. */
653 if (is_a_field_of_this
)
655 struct value
*v
= value_of_this (0);
657 *is_a_field_of_this
= 0;
658 if (v
&& check_field (v
, name
))
660 *is_a_field_of_this
= 1;
667 /* Now search all global blocks. Do the symtab's first, then
668 check the psymtab's */
670 ALL_SYMTABS (objfile
, s
)
672 bv
= BLOCKVECTOR (s
);
673 block
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
674 sym
= lookup_block_symbol (block
, name
, namespace);
680 return fixup_symbol_section (sym
, objfile
);
684 /* Check for the possibility of the symbol being a function or
685 a mangled variable that is stored in one of the minimal symbol tables.
686 Eventually, all global symbols might be resolved in this way. */
688 if (namespace == VAR_NAMESPACE
)
690 msymbol
= lookup_minimal_symbol (name
, NULL
, NULL
);
693 s
= find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol
),
694 SYMBOL_BFD_SECTION (msymbol
));
697 /* This is a function which has a symtab for its address. */
698 bv
= BLOCKVECTOR (s
);
699 block
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
700 sym
= lookup_block_symbol (block
, SYMBOL_NAME (msymbol
),
702 /* We kept static functions in minimal symbol table as well as
703 in static scope. We want to find them in the symbol table. */
705 block
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
706 sym
= lookup_block_symbol (block
, SYMBOL_NAME (msymbol
),
710 /* sym == 0 if symbol was found in the minimal symbol table
711 but not in the symtab.
712 Return 0 to use the msymbol definition of "foo_".
714 This happens for Fortran "foo_" symbols,
715 which are "foo" in the symtab.
717 This can also happen if "asm" is used to make a
718 regular symbol but not a debugging symbol, e.g.
725 return fixup_symbol_section (sym
, objfile
);
727 else if (MSYMBOL_TYPE (msymbol
) != mst_text
728 && MSYMBOL_TYPE (msymbol
) != mst_file_text
729 && !STREQ (name
, SYMBOL_NAME (msymbol
)))
731 /* This is a mangled variable, look it up by its
733 return lookup_symbol (SYMBOL_NAME (msymbol
), block
,
734 namespace, is_a_field_of_this
, symtab
);
736 /* There are no debug symbols for this file, or we are looking
737 for an unmangled variable.
738 Try to find a matching static symbol below. */
742 ALL_PSYMTABS (objfile
, ps
)
744 if (!ps
->readin
&& lookup_partial_symbol (ps
, name
, 1, namespace))
746 s
= PSYMTAB_TO_SYMTAB(ps
);
747 bv
= BLOCKVECTOR (s
);
748 block
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
749 sym
= lookup_block_symbol (block
, name
, namespace);
751 error ("Internal: global symbol `%s' found in %s psymtab but not in symtab", name
, ps
->filename
);
754 return fixup_symbol_section (sym
, objfile
);
758 /* Now search all per-file blocks.
759 Not strictly correct, but more useful than an error.
760 Do the symtabs first, then check the psymtabs */
762 ALL_SYMTABS (objfile
, s
)
764 bv
= BLOCKVECTOR (s
);
765 block
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
766 sym
= lookup_block_symbol (block
, name
, namespace);
772 return fixup_symbol_section (sym
, objfile
);
776 ALL_PSYMTABS (objfile
, ps
)
778 if (!ps
->readin
&& lookup_partial_symbol (ps
, name
, 0, namespace))
780 s
= PSYMTAB_TO_SYMTAB(ps
);
781 bv
= BLOCKVECTOR (s
);
782 block
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
783 sym
= lookup_block_symbol (block
, name
, namespace);
785 error ("Internal: static symbol `%s' found in %s psymtab but not in symtab", name
, ps
->filename
);
788 return fixup_symbol_section (sym
, objfile
);
797 /* Look, in partial_symtab PST, for symbol NAME. Check the global
798 symbols if GLOBAL, the static symbols if not */
800 static struct partial_symbol
*
801 lookup_partial_symbol (pst
, name
, global
, namespace)
802 struct partial_symtab
*pst
;
805 namespace_enum
namespace;
807 struct partial_symbol
**start
, **psym
;
808 struct partial_symbol
**top
, **bottom
, **center
;
809 int length
= (global
? pst
->n_global_syms
: pst
->n_static_syms
);
810 int do_linear_search
= 1;
818 pst
->objfile
->global_psymbols
.list
+ pst
->globals_offset
:
819 pst
->objfile
->static_psymbols
.list
+ pst
->statics_offset
);
821 if (global
) /* This means we can use a binary search. */
823 do_linear_search
= 0;
825 /* Binary search. This search is guaranteed to end with center
826 pointing at the earliest partial symbol with the correct
827 name. At that point *all* partial symbols with that name
828 will be checked against the correct namespace. */
831 top
= start
+ length
- 1;
834 center
= bottom
+ (top
- bottom
) / 2;
837 if (!do_linear_search
&& SYMBOL_LANGUAGE (*center
) == language_cplus
)
839 do_linear_search
= 1;
841 if (STRCMP (SYMBOL_NAME (*center
), name
) >= 0)
850 if (!(top
== bottom
))
852 while (STREQ (SYMBOL_NAME (*top
), name
))
854 if (SYMBOL_NAMESPACE (*top
) == namespace)
862 /* Can't use a binary search or else we found during the binary search that
863 we should also do a linear search. */
865 if (do_linear_search
)
867 for (psym
= start
; psym
< start
+ length
; psym
++)
869 if (namespace == SYMBOL_NAMESPACE (*psym
))
871 if (SYMBOL_MATCHES_NAME (*psym
, name
))
882 /* Find the psymtab containing main(). */
883 /* FIXME: What about languages without main() or specially linked
884 executables that have no main() ? */
886 struct partial_symtab
*
889 register struct partial_symtab
*pst
;
890 register struct objfile
*objfile
;
892 ALL_PSYMTABS (objfile
, pst
)
894 if (lookup_partial_symbol (pst
, "main", 1, VAR_NAMESPACE
))
902 /* Search BLOCK for symbol NAME in NAMESPACE.
904 Note that if NAME is the demangled form of a C++ symbol, we will fail
905 to find a match during the binary search of the non-encoded names, but
906 for now we don't worry about the slight inefficiency of looking for
907 a match we'll never find, since it will go pretty quick. Once the
908 binary search terminates, we drop through and do a straight linear
909 search on the symbols. Each symbol which is marked as being a C++
910 symbol (language_cplus set) has both the encoded and non-encoded names
911 tested for a match. */
914 lookup_block_symbol (block
, name
, namespace)
915 register const struct block
*block
;
917 const namespace_enum
namespace;
919 register int bot
, top
, inc
;
920 register struct symbol
*sym
;
921 register struct symbol
*sym_found
= NULL
;
922 register int do_linear_search
= 1;
924 /* If the blocks's symbols were sorted, start with a binary search. */
926 if (BLOCK_SHOULD_SORT (block
))
928 /* Reset the linear search flag so if the binary search fails, we
929 won't do the linear search once unless we find some reason to
930 do so, such as finding a C++ symbol during the binary search.
931 Note that for C++ modules, ALL the symbols in a block should
932 end up marked as C++ symbols. */
934 do_linear_search
= 0;
935 top
= BLOCK_NSYMS (block
);
938 /* Advance BOT to not far before the first symbol whose name is NAME. */
942 inc
= (top
- bot
+ 1);
943 /* No need to keep binary searching for the last few bits worth. */
948 inc
= (inc
>> 1) + bot
;
949 sym
= BLOCK_SYM (block
, inc
);
950 if (!do_linear_search
&& SYMBOL_LANGUAGE (sym
) == language_cplus
)
952 do_linear_search
= 1;
954 if (SYMBOL_NAME (sym
)[0] < name
[0])
958 else if (SYMBOL_NAME (sym
)[0] > name
[0])
962 else if (STRCMP (SYMBOL_NAME (sym
), name
) < 0)
972 /* Now scan forward until we run out of symbols, find one whose
973 name is greater than NAME, or find one we want. If there is
974 more than one symbol with the right name and namespace, we
975 return the first one; I believe it is now impossible for us
976 to encounter two symbols with the same name and namespace
977 here, because blocks containing argument symbols are no
980 top
= BLOCK_NSYMS (block
);
983 sym
= BLOCK_SYM (block
, bot
);
984 inc
= SYMBOL_NAME (sym
)[0] - name
[0];
987 inc
= STRCMP (SYMBOL_NAME (sym
), name
);
989 if (inc
== 0 && SYMBOL_NAMESPACE (sym
) == namespace)
1001 /* Here if block isn't sorted, or we fail to find a match during the
1002 binary search above. If during the binary search above, we find a
1003 symbol which is a C++ symbol, then we have re-enabled the linear
1004 search flag which was reset when starting the binary search.
1006 This loop is equivalent to the loop above, but hacked greatly for speed.
1008 Note that parameter symbols do not always show up last in the
1009 list; this loop makes sure to take anything else other than
1010 parameter symbols first; it only uses parameter symbols as a
1011 last resort. Note that this only takes up extra computation
1014 if (do_linear_search
)
1016 top
= BLOCK_NSYMS (block
);
1020 sym
= BLOCK_SYM (block
, bot
);
1021 if (SYMBOL_NAMESPACE (sym
) == namespace &&
1022 SYMBOL_MATCHES_NAME (sym
, name
))
1024 /* If SYM has aliases, then use any alias that is active
1025 at the current PC. If no alias is active at the current
1026 PC, then use the main symbol.
1028 ?!? Is checking the current pc correct? Is this routine
1029 ever called to look up a symbol from another context? */
1030 if (SYMBOL_ALIASES (sym
))
1031 sym
= find_active_alias (sym
, read_pc ());
1034 if (SYMBOL_CLASS (sym
) != LOC_ARG
&&
1035 SYMBOL_CLASS (sym
) != LOC_LOCAL_ARG
&&
1036 SYMBOL_CLASS (sym
) != LOC_REF_ARG
&&
1037 SYMBOL_CLASS (sym
) != LOC_REGPARM
&&
1038 SYMBOL_CLASS (sym
) != LOC_REGPARM_ADDR
&&
1039 SYMBOL_CLASS (sym
) != LOC_BASEREG_ARG
)
1047 return (sym_found
); /* Will be NULL if not found. */
1050 /* Given a main symbol SYM and ADDR, search through the alias
1051 list to determine if an alias is active at ADDR and return
1054 If no alias is active, then return SYM. */
1056 static struct symbol
*
1057 find_active_alias (sym
, addr
)
1061 struct range_list
*r
;
1062 struct alias_list
*aliases
;
1064 /* If we have aliases, check them first. */
1065 aliases
= SYMBOL_ALIASES (sym
);
1069 if (!SYMBOL_RANGES (aliases
->sym
))
1070 return aliases
->sym
;
1071 for (r
= SYMBOL_RANGES (aliases
->sym
); r
; r
= r
->next
)
1073 if (r
->start
<= addr
&& r
->end
> addr
)
1074 return aliases
->sym
;
1076 aliases
= aliases
->next
;
1079 /* Nothing found, return the main symbol. */
1084 /* Return the symbol for the function which contains a specified
1085 lexical block, described by a struct block BL. */
1091 while (BLOCK_FUNCTION (bl
) == 0 && BLOCK_SUPERBLOCK (bl
) != 0)
1092 bl
= BLOCK_SUPERBLOCK (bl
);
1094 return BLOCK_FUNCTION (bl
);
1097 /* Find the symtab associated with PC and SECTION. Look through the
1098 psymtabs and read in another symtab if necessary. */
1101 find_pc_sect_symtab (pc
, section
)
1105 register struct block
*b
;
1106 struct blockvector
*bv
;
1107 register struct symtab
*s
= NULL
;
1108 register struct symtab
*best_s
= NULL
;
1109 register struct partial_symtab
*ps
;
1110 register struct objfile
*objfile
;
1111 CORE_ADDR distance
= 0;
1113 /* Search all symtabs for the one whose file contains our address, and which
1114 is the smallest of all the ones containing the address. This is designed
1115 to deal with a case like symtab a is at 0x1000-0x2000 and 0x3000-0x4000
1116 and symtab b is at 0x2000-0x3000. So the GLOBAL_BLOCK for a is from
1117 0x1000-0x4000, but for address 0x2345 we want to return symtab b.
1119 This happens for native ecoff format, where code from included files
1120 gets its own symtab. The symtab for the included file should have
1121 been read in already via the dependency mechanism.
1122 It might be swifter to create several symtabs with the same name
1123 like xcoff does (I'm not sure).
1125 It also happens for objfiles that have their functions reordered.
1126 For these, the symtab we are looking for is not necessarily read in. */
1128 ALL_SYMTABS (objfile
, s
)
1130 bv
= BLOCKVECTOR (s
);
1131 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
1132 if (BLOCK_START (b
) <= pc
1133 && BLOCK_END (b
) > pc
1135 || BLOCK_END (b
) - BLOCK_START (b
) < distance
))
1137 /* For an objfile that has its functions reordered,
1138 find_pc_psymtab will find the proper partial symbol table
1139 and we simply return its corresponding symtab. */
1140 /* In order to better support objfiles that contain both
1141 stabs and coff debugging info, we continue on if a psymtab
1143 if ((objfile
->flags
& OBJF_REORDERED
) && objfile
->psymtabs
)
1145 ps
= find_pc_sect_psymtab (pc
, section
);
1147 return PSYMTAB_TO_SYMTAB (ps
);
1153 for (i
= 0; i
< b
->nsyms
; i
++)
1155 fixup_symbol_section (b
->sym
[i
], objfile
);
1156 if (section
== SYMBOL_BFD_SECTION (b
->sym
[i
]))
1160 continue; /* no symbol in this symtab matches section */
1162 distance
= BLOCK_END (b
) - BLOCK_START (b
);
1171 ps
= find_pc_sect_psymtab (pc
, section
);
1175 /* Might want to error() here (in case symtab is corrupt and
1176 will cause a core dump), but maybe we can successfully
1177 continue, so let's not. */
1178 /* FIXME-32x64: assumes pc fits in a long */
1180 (Internal error: pc 0x%lx in read in psymtab, but not in symtab.)\n",
1181 (unsigned long) pc
);
1182 s
= PSYMTAB_TO_SYMTAB (ps
);
1187 /* Find the symtab associated with PC. Look through the psymtabs and
1188 read in another symtab if necessary. Backward compatibility, no section */
1194 return find_pc_sect_symtab (pc
, find_pc_mapped_section (pc
));
1200 /* Find the closest symbol value (of any sort -- function or variable)
1201 for a given address value. Slow but complete. (currently unused,
1202 mainly because it is too slow. We could fix it if each symtab and
1203 psymtab had contained in it the addresses ranges of each of its
1204 sections, which also would be required to make things like "info
1205 line *0x2345" cause psymtabs to be converted to symtabs). */
1208 find_addr_symbol (addr
, symtabp
, symaddrp
)
1210 struct symtab
**symtabp
;
1211 CORE_ADDR
*symaddrp
;
1213 struct symtab
*symtab
, *best_symtab
;
1214 struct objfile
*objfile
;
1215 register int bot
, top
;
1216 register struct symbol
*sym
;
1217 register CORE_ADDR sym_addr
;
1218 struct block
*block
;
1221 /* Info on best symbol seen so far */
1223 register CORE_ADDR best_sym_addr
= 0;
1224 struct symbol
*best_sym
= 0;
1226 /* FIXME -- we should pull in all the psymtabs, too! */
1227 ALL_SYMTABS (objfile
, symtab
)
1229 /* Search the global and static blocks in this symtab for
1230 the closest symbol-address to the desired address. */
1232 for (blocknum
= GLOBAL_BLOCK
; blocknum
<= STATIC_BLOCK
; blocknum
++)
1235 block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab
), blocknum
);
1236 top
= BLOCK_NSYMS (block
);
1237 for (bot
= 0; bot
< top
; bot
++)
1239 sym
= BLOCK_SYM (block
, bot
);
1240 switch (SYMBOL_CLASS (sym
))
1244 sym_addr
= SYMBOL_VALUE_ADDRESS (sym
);
1248 sym_addr
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
));
1255 if (sym_addr
<= addr
)
1256 if (sym_addr
> best_sym_addr
)
1258 /* Quit if we found an exact match. */
1260 best_sym_addr
= sym_addr
;
1261 best_symtab
= symtab
;
1262 if (sym_addr
== addr
)
1271 *symtabp
= best_symtab
;
1273 *symaddrp
= best_sym_addr
;
1278 /* Find the source file and line number for a given PC value and section.
1279 Return a structure containing a symtab pointer, a line number,
1280 and a pc range for the entire source line.
1281 The value's .pc field is NOT the specified pc.
1282 NOTCURRENT nonzero means, if specified pc is on a line boundary,
1283 use the line that ends there. Otherwise, in that case, the line
1284 that begins there is used. */
1286 /* The big complication here is that a line may start in one file, and end just
1287 before the start of another file. This usually occurs when you #include
1288 code in the middle of a subroutine. To properly find the end of a line's PC
1289 range, we must search all symtabs associated with this compilation unit, and
1290 find the one whose first PC is closer than that of the next line in this
1293 /* If it's worth the effort, we could be using a binary search. */
1295 struct symtab_and_line
1296 find_pc_sect_line (pc
, section
, notcurrent
)
1298 struct sec
*section
;
1302 register struct linetable
*l
;
1305 register struct linetable_entry
*item
;
1306 struct symtab_and_line val
;
1307 struct blockvector
*bv
;
1309 /* Info on best line seen so far, and where it starts, and its file. */
1311 struct linetable_entry
*best
= NULL
;
1312 CORE_ADDR best_end
= 0;
1313 struct symtab
*best_symtab
= 0;
1315 /* Store here the first line number
1316 of a file which contains the line at the smallest pc after PC.
1317 If we don't find a line whose range contains PC,
1318 we will use a line one less than this,
1319 with a range from the start of that file to the first line's pc. */
1320 struct linetable_entry
*alt
= NULL
;
1321 struct symtab
*alt_symtab
= 0;
1323 /* Info on best line seen in this file. */
1325 struct linetable_entry
*prev
;
1327 /* If this pc is not from the current frame,
1328 it is the address of the end of a call instruction.
1329 Quite likely that is the start of the following statement.
1330 But what we want is the statement containing the instruction.
1331 Fudge the pc to make sure we get that. */
1333 INIT_SAL (&val
); /* initialize to zeroes */
1338 s
= find_pc_sect_symtab (pc
, section
);
1345 bv
= BLOCKVECTOR (s
);
1347 /* Look at all the symtabs that share this blockvector.
1348 They all have the same apriori range, that we found was right;
1349 but they have different line tables. */
1351 for (; s
&& BLOCKVECTOR (s
) == bv
; s
= s
->next
)
1353 /* Find the best line in this symtab. */
1360 /* I think len can be zero if the symtab lacks line numbers
1361 (e.g. gcc -g1). (Either that or the LINETABLE is NULL;
1362 I'm not sure which, and maybe it depends on the symbol
1368 item
= l
->item
; /* Get first line info */
1370 /* Is this file's first line closer than the first lines of other files?
1371 If so, record this file, and its first line, as best alternate. */
1372 if (item
->pc
> pc
&& (!alt
|| item
->pc
< alt
->pc
))
1378 for (i
= 0; i
< len
; i
++, item
++)
1380 /* Leave prev pointing to the linetable entry for the last line
1381 that started at or before PC. */
1388 /* At this point, prev points at the line whose start addr is <= pc, and
1389 item points at the next line. If we ran off the end of the linetable
1390 (pc >= start of the last line), then prev == item. If pc < start of
1391 the first line, prev will not be set. */
1393 /* Is this file's best line closer than the best in the other files?
1394 If so, record this file, and its best line, as best so far. */
1396 if (prev
&& (!best
|| prev
->pc
> best
->pc
))
1400 /* If another line is in the linetable, and its PC is closer
1401 than the best_end we currently have, take it as best_end. */
1402 if (i
< len
&& (best_end
== 0 || best_end
> item
->pc
))
1403 best_end
= item
->pc
;
1410 { /* If we didn't find any line # info, just
1416 val
.symtab
= alt_symtab
;
1417 val
.line
= alt
->line
- 1;
1419 /* Don't return line 0, that means that we didn't find the line. */
1420 if (val
.line
== 0) ++val
.line
;
1422 val
.pc
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
1428 val
.symtab
= best_symtab
;
1429 val
.line
= best
->line
;
1431 if (best_end
&& (!alt
|| best_end
< alt
->pc
))
1436 val
.end
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
1438 val
.section
= section
;
1442 /* Backward compatibility (no section) */
1444 struct symtab_and_line
1445 find_pc_line (pc
, notcurrent
)
1451 section
= find_pc_overlay (pc
);
1452 if (pc_in_unmapped_range (pc
, section
))
1453 pc
= overlay_mapped_address (pc
, section
);
1454 return find_pc_sect_line (pc
, section
, notcurrent
);
1458 static int find_line_symtab
PARAMS ((struct symtab
*, int, struct linetable
**,
1461 /* Find line number LINE in any symtab whose name is the same as
1464 If found, return 1, set *LINETABLE to the linetable in which it was
1465 found, set *INDEX to the index in the linetable of the best entry
1466 found, and set *EXACT_MATCH nonzero if the value returned is an
1469 If not found, return 0. */
1472 find_line_symtab (symtab
, line
, linetable
, index
, exact_match
)
1473 struct symtab
*symtab
;
1475 struct linetable
**linetable
;
1481 /* BEST_INDEX and BEST_LINETABLE identify the smallest linenumber > LINE
1485 struct linetable
*best_linetable
;
1487 /* First try looking it up in the given symtab. */
1488 best_linetable
= LINETABLE (symtab
);
1489 best_index
= find_line_common (best_linetable
, line
, &exact
);
1490 if (best_index
< 0 || !exact
)
1492 /* Didn't find an exact match. So we better keep looking for
1493 another symtab with the same name. In the case of xcoff,
1494 multiple csects for one source file (produced by IBM's FORTRAN
1495 compiler) produce multiple symtabs (this is unavoidable
1496 assuming csects can be at arbitrary places in memory and that
1497 the GLOBAL_BLOCK of a symtab has a begin and end address). */
1499 /* BEST is the smallest linenumber > LINE so far seen,
1500 or 0 if none has been seen so far.
1501 BEST_INDEX and BEST_LINETABLE identify the item for it. */
1504 struct objfile
*objfile
;
1507 if (best_index
>= 0)
1508 best
= best_linetable
->item
[best_index
].line
;
1512 ALL_SYMTABS (objfile
, s
)
1514 struct linetable
*l
;
1517 if (!STREQ (symtab
->filename
, s
->filename
))
1520 ind
= find_line_common (l
, line
, &exact
);
1529 if (best
== 0 || l
->item
[ind
].line
< best
)
1531 best
= l
->item
[ind
].line
;
1543 *index
= best_index
;
1545 *linetable
= best_linetable
;
1547 *exact_match
= exact
;
1551 /* Find the PC value for a given source file and line number.
1552 Returns zero for invalid line number.
1553 The source file is specified with a struct symtab. */
1556 find_line_pc (symtab
, line
)
1557 struct symtab
*symtab
;
1560 struct linetable
*l
;
1565 if (find_line_symtab (symtab
, line
, &l
, &ind
, NULL
))
1566 return l
->item
[ind
].pc
;
1571 /* Find the range of pc values in a line.
1572 Store the starting pc of the line into *STARTPTR
1573 and the ending pc (start of next line) into *ENDPTR.
1574 Returns 1 to indicate success.
1575 Returns 0 if could not find the specified line. */
1578 find_line_pc_range (sal
, startptr
, endptr
)
1579 struct symtab_and_line sal
;
1580 CORE_ADDR
*startptr
, *endptr
;
1582 CORE_ADDR startaddr
;
1583 struct symtab_and_line found_sal
;
1588 startaddr
= find_line_pc (sal
.symtab
, sal
.line
);
1593 /* This whole function is based on address. For example, if line 10 has
1594 two parts, one from 0x100 to 0x200 and one from 0x300 to 0x400, then
1595 "info line *0x123" should say the line goes from 0x100 to 0x200
1596 and "info line *0x355" should say the line goes from 0x300 to 0x400.
1597 This also insures that we never give a range like "starts at 0x134
1598 and ends at 0x12c". */
1600 found_sal
= find_pc_sect_line (startaddr
, sal
.section
, 0);
1601 if (found_sal
.line
!= sal
.line
)
1603 /* The specified line (sal) has zero bytes. */
1604 *startptr
= found_sal
.pc
;
1605 *endptr
= found_sal
.pc
;
1609 *startptr
= found_sal
.pc
;
1610 *endptr
= found_sal
.end
;
1615 /* Given a line table and a line number, return the index into the line
1616 table for the pc of the nearest line whose number is >= the specified one.
1617 Return -1 if none is found. The value is >= 0 if it is an index.
1619 Set *EXACT_MATCH nonzero if the value returned is an exact match. */
1622 find_line_common (l
, lineno
, exact_match
)
1623 register struct linetable
*l
;
1624 register int lineno
;
1630 /* BEST is the smallest linenumber > LINENO so far seen,
1631 or 0 if none has been seen so far.
1632 BEST_INDEX identifies the item for it. */
1634 int best_index
= -1;
1643 for (i
= 0; i
< len
; i
++)
1645 register struct linetable_entry
*item
= &(l
->item
[i
]);
1647 if (item
->line
== lineno
)
1649 /* Return the first (lowest address) entry which matches. */
1654 if (item
->line
> lineno
&& (best
== 0 || item
->line
< best
))
1661 /* If we got here, we didn't get an exact match. */
1668 find_pc_line_pc_range (pc
, startptr
, endptr
)
1670 CORE_ADDR
*startptr
, *endptr
;
1672 struct symtab_and_line sal
;
1673 sal
= find_pc_line (pc
, 0);
1676 return sal
.symtab
!= 0;
1679 /* Given a function symbol SYM, find the symtab and line for the start
1681 If the argument FUNFIRSTLINE is nonzero, we want the first line
1682 of real code inside the function. */
1684 static struct symtab_and_line
1685 find_function_start_sal
PARAMS ((struct symbol
*sym
, int));
1687 static struct symtab_and_line
1688 find_function_start_sal (sym
, funfirstline
)
1693 struct symtab_and_line sal
;
1695 pc
= BLOCK_START (SYMBOL_BLOCK_VALUE (sym
));
1696 fixup_symbol_section (sym
, NULL
);
1698 { /* skip "first line" of function (which is actually its prologue) */
1699 asection
*section
= SYMBOL_BFD_SECTION (sym
);
1700 /* If function is in an unmapped overlay, use its unmapped LMA
1701 address, so that SKIP_PROLOGUE has something unique to work on */
1702 if (section_is_overlay (section
) &&
1703 !section_is_mapped (section
))
1704 pc
= overlay_unmapped_address (pc
, section
);
1706 pc
+= FUNCTION_START_OFFSET
;
1709 /* For overlays, map pc back into its mapped VMA range */
1710 pc
= overlay_mapped_address (pc
, section
);
1712 sal
= find_pc_sect_line (pc
, SYMBOL_BFD_SECTION (sym
), 0);
1714 #ifdef PROLOGUE_FIRSTLINE_OVERLAP
1715 /* Convex: no need to suppress code on first line, if any */
1718 /* Check if SKIP_PROLOGUE left us in mid-line, and the next
1719 line is still part of the same function. */
1721 && BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)) <= sal
.end
1722 && sal
.end
< BLOCK_END (SYMBOL_BLOCK_VALUE (sym
)))
1724 /* First pc of next line */
1726 /* Recalculate the line number (might not be N+1). */
1727 sal
= find_pc_sect_line (pc
, SYMBOL_BFD_SECTION (sym
), 0);
1735 /* If P is of the form "operator[ \t]+..." where `...' is
1736 some legitimate operator text, return a pointer to the
1737 beginning of the substring of the operator text.
1738 Otherwise, return "". */
1740 operator_chars (p
, end
)
1745 if (strncmp (p
, "operator", 8))
1749 /* Don't get faked out by `operator' being part of a longer
1751 if (isalpha(*p
) || *p
== '_' || *p
== '$' || *p
== '\0')
1754 /* Allow some whitespace between `operator' and the operator symbol. */
1755 while (*p
== ' ' || *p
== '\t')
1758 /* Recognize 'operator TYPENAME'. */
1760 if (isalpha(*p
) || *p
== '_' || *p
== '$')
1762 register char *q
= p
+1;
1763 while (isalnum(*q
) || *q
== '_' || *q
== '$')
1788 if (p
[1] == '=' || p
[1] == p
[0])
1799 error ("`operator ()' must be specified without whitespace in `()'");
1804 error ("`operator ?:' must be specified without whitespace in `?:'");
1809 error ("`operator []' must be specified without whitespace in `[]'");
1813 error ("`operator %s' not supported", p
);
1820 /* Return the number of methods described for TYPE, including the
1821 methods from types it derives from. This can't be done in the symbol
1822 reader because the type of the baseclass might still be stubbed
1823 when the definition of the derived class is parsed. */
1825 static int total_number_of_methods
PARAMS ((struct type
*type
));
1828 total_number_of_methods (type
)
1834 CHECK_TYPEDEF (type
);
1835 if (TYPE_CPLUS_SPECIFIC (type
) == NULL
)
1837 count
= TYPE_NFN_FIELDS_TOTAL (type
);
1839 for (n
= 0; n
< TYPE_N_BASECLASSES (type
); n
++)
1840 count
+= total_number_of_methods (TYPE_BASECLASS (type
, n
));
1845 /* Recursive helper function for decode_line_1.
1846 Look for methods named NAME in type T.
1847 Return number of matches.
1848 Put matches in SYM_ARR, which should have been allocated with
1849 a size of total_number_of_methods (T) * sizeof (struct symbol *).
1850 Note that this function is g++ specific. */
1853 find_methods (t
, name
, sym_arr
)
1856 struct symbol
**sym_arr
;
1860 struct symbol
*sym_class
;
1861 char *class_name
= type_name_no_tag (t
);
1862 /* Ignore this class if it doesn't have a name. This is ugly, but
1863 unless we figure out how to get the physname without the name of
1864 the class, then the loop can't do any good. */
1866 && (sym_class
= lookup_symbol (class_name
,
1867 (struct block
*)NULL
,
1870 (struct symtab
**)NULL
)))
1873 /* FIXME: Shouldn't this just be CHECK_TYPEDEF (t)? */
1874 t
= SYMBOL_TYPE (sym_class
);
1875 for (method_counter
= TYPE_NFN_FIELDS (t
) - 1;
1876 method_counter
>= 0;
1880 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, method_counter
);
1881 char *method_name
= TYPE_FN_FIELDLIST_NAME (t
, method_counter
);
1882 char dem_opname
[64];
1884 if (strncmp(method_name
, "__", 2)==0 ||
1885 strncmp(method_name
, "op", 2)==0 ||
1886 strncmp(method_name
, "type", 4)==0 )
1888 if (cplus_demangle_opname(method_name
, dem_opname
, DMGL_ANSI
))
1889 method_name
= dem_opname
;
1890 else if (cplus_demangle_opname(method_name
, dem_opname
, 0))
1891 method_name
= dem_opname
;
1893 if (STREQ (name
, method_name
))
1894 /* Find all the fields with that name. */
1895 for (field_counter
= TYPE_FN_FIELDLIST_LENGTH (t
, method_counter
) - 1;
1900 if (TYPE_FN_FIELD_STUB (f
, field_counter
))
1901 check_stub_method (t
, method_counter
, field_counter
);
1902 phys_name
= TYPE_FN_FIELD_PHYSNAME (f
, field_counter
);
1903 /* Destructor is handled by caller, dont add it to the list */
1904 if (DESTRUCTOR_PREFIX_P (phys_name
))
1907 sym_arr
[i1
] = lookup_symbol (phys_name
,
1908 NULL
, VAR_NAMESPACE
,
1910 (struct symtab
**) NULL
);
1915 fputs_filtered("(Cannot find method ", gdb_stdout
);
1916 fprintf_symbol_filtered (gdb_stdout
, phys_name
,
1918 DMGL_PARAMS
| DMGL_ANSI
);
1919 fputs_filtered(" - possibly inlined.)\n", gdb_stdout
);
1925 /* Only search baseclasses if there is no match yet, since names in
1926 derived classes override those in baseclasses.
1928 FIXME: The above is not true; it is only true of member functions
1929 if they have the same number of arguments (??? - section 13.1 of the
1930 ARM says the function members are not in the same scope but doesn't
1931 really spell out the rules in a way I understand. In any case, if
1932 the number of arguments differ this is a case in which we can overload
1933 rather than hiding without any problem, and gcc 2.4.5 does overload
1934 rather than hiding in this case). */
1938 for (ibase
= 0; ibase
< TYPE_N_BASECLASSES (t
); ibase
++)
1939 i1
+= find_methods(TYPE_BASECLASS(t
, ibase
), name
,
1944 /* Helper function for decode_line_1.
1945 Build a canonical line spec in CANONICAL if it is non-NULL and if
1946 the SAL has a symtab.
1947 If SYMNAME is non-NULL the canonical line spec is `filename:symname'.
1948 If SYMNAME is NULL the line number from SAL is used and the canonical
1949 line spec is `filename:linenum'. */
1952 build_canonical_line_spec (sal
, symname
, canonical
)
1953 struct symtab_and_line
*sal
;
1957 char **canonical_arr
;
1958 char *canonical_name
;
1960 struct symtab
*s
= sal
->symtab
;
1962 if (s
== (struct symtab
*)NULL
1963 || s
->filename
== (char *)NULL
1964 || canonical
== (char ***)NULL
)
1967 canonical_arr
= (char **) xmalloc (sizeof (char *));
1968 *canonical
= canonical_arr
;
1970 filename
= s
->filename
;
1971 if (symname
!= NULL
)
1973 canonical_name
= xmalloc (strlen (filename
) + strlen (symname
) + 2);
1974 sprintf (canonical_name
, "%s:%s", filename
, symname
);
1978 canonical_name
= xmalloc (strlen (filename
) + 30);
1979 sprintf (canonical_name
, "%s:%d", filename
, sal
->line
);
1981 canonical_arr
[0] = canonical_name
;
1984 /* Parse a string that specifies a line number.
1985 Pass the address of a char * variable; that variable will be
1986 advanced over the characters actually parsed.
1990 LINENUM -- that line number in current file. PC returned is 0.
1991 FILE:LINENUM -- that line in that file. PC returned is 0.
1992 FUNCTION -- line number of openbrace of that function.
1993 PC returned is the start of the function.
1994 VARIABLE -- line number of definition of that variable.
1996 FILE:FUNCTION -- likewise, but prefer functions in that file.
1997 *EXPR -- line in which address EXPR appears.
1999 FUNCTION may be an undebuggable function found in minimal symbol table.
2001 If the argument FUNFIRSTLINE is nonzero, we want the first line
2002 of real code inside a function when a function is specified, and it is
2003 not OK to specify a variable or type to get its line number.
2005 DEFAULT_SYMTAB specifies the file to use if none is specified.
2006 It defaults to current_source_symtab.
2007 DEFAULT_LINE specifies the line number to use for relative
2008 line numbers (that start with signs). Defaults to current_source_line.
2009 If CANONICAL is non-NULL, store an array of strings containing the canonical
2010 line specs there if necessary. Currently overloaded member functions and
2011 line numbers or static functions without a filename yield a canonical
2012 line spec. The array and the line spec strings are allocated on the heap,
2013 it is the callers responsibility to free them.
2015 Note that it is possible to return zero for the symtab
2016 if no file is validly specified. Callers must check that.
2017 Also, the line number returned may be invalid. */
2019 /* We allow single quotes in various places. This is a hideous
2020 kludge, which exists because the completer can't yet deal with the
2021 lack of single quotes. FIXME: write a linespec_completer which we
2022 can use as appropriate instead of make_symbol_completion_list. */
2024 struct symtabs_and_lines
2025 decode_line_1 (argptr
, funfirstline
, default_symtab
, default_line
, canonical
)
2028 struct symtab
*default_symtab
;
2032 struct symtabs_and_lines values
;
2033 #ifdef HPPA_COMPILER_BUG
2034 /* FIXME: The native HP 9000/700 compiler has a bug which appears
2035 when optimizing this file with target i960-vxworks. I haven't
2036 been able to construct a simple test case. The problem is that
2037 in the second call to SKIP_PROLOGUE below, the compiler somehow
2038 does not realize that the statement val = find_pc_line (...) will
2039 change the values of the fields of val. It extracts the elements
2040 into registers at the top of the block, and does not update the
2041 registers after the call to find_pc_line. You can check this by
2042 inserting a printf at the end of find_pc_line to show what values
2043 it is returning for val.pc and val.end and another printf after
2044 the call to see what values the function actually got (remember,
2045 this is compiling with cc -O, with this patch removed). You can
2046 also examine the assembly listing: search for the second call to
2047 skip_prologue; the LDO statement before the next call to
2048 find_pc_line loads the address of the structure which
2049 find_pc_line will return; if there is a LDW just before the LDO,
2050 which fetches an element of the structure, then the compiler
2053 Setting val to volatile avoids the problem. We must undef
2054 volatile, because the HPPA native compiler does not define
2055 __STDC__, although it does understand volatile, and so volatile
2056 will have been defined away in defs.h. */
2058 volatile struct symtab_and_line val
;
2059 #define volatile /*nothing*/
2061 struct symtab_and_line val
;
2063 register char *p
, *p1
;
2068 register struct symtab
*s
;
2070 register struct symbol
*sym
;
2071 /* The symtab that SYM was found in. */
2072 struct symtab
*sym_symtab
;
2074 register CORE_ADDR pc
;
2075 register struct minimal_symbol
*msymbol
;
2077 struct symbol
*sym_class
;
2079 int is_quoted
, has_parens
;
2080 struct symbol
**sym_arr
;
2082 char *saved_arg
= *argptr
;
2083 extern char *gdb_completer_quote_characters
;
2085 INIT_SAL (&val
); /* initialize to zeroes */
2087 /* Defaults have defaults. */
2089 if (default_symtab
== 0)
2091 default_symtab
= current_source_symtab
;
2092 default_line
= current_source_line
;
2095 /* See if arg is *PC */
2097 if (**argptr
== '*')
2100 pc
= parse_and_eval_address_1 (argptr
);
2101 values
.sals
= (struct symtab_and_line
*)
2102 xmalloc (sizeof (struct symtab_and_line
));
2104 values
.sals
[0] = find_pc_line (pc
, 0);
2108 /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
2111 is_quoted
= (**argptr
2112 && strchr (gdb_completer_quote_characters
, **argptr
) != NULL
);
2113 has_parens
= ((pp
= strchr (*argptr
, '(')) != NULL
2114 && (pp
= strchr (pp
, ')')) != NULL
);
2116 for (p
= *argptr
; *p
; p
++)
2120 while(++p
&& *p
!= '>');
2123 error ("non-matching '<' and '>' in command");
2126 if (p
[0] == ':' || p
[0] == ' ' || p
[0] == '\t')
2128 if (p
[0] == '.' && strchr (p
, ':') == NULL
) /* Java qualified method. */
2130 /* Find the *last* '.', since the others are package qualifiers. */
2131 for (p1
= p
; *p1
; p1
++)
2139 while (p
[0] == ' ' || p
[0] == '\t') p
++;
2141 if ((p
[0] == ':' || p
[0] == '.') && !has_parens
)
2145 if (is_quoted
) *argptr
= *argptr
+1;
2146 if (p
[0] == '.' || p
[1] ==':')
2148 /* Extract the class name. */
2150 while (p
!= *argptr
&& p
[-1] == ' ') --p
;
2151 copy
= (char *) alloca (p
- *argptr
+ 1);
2152 memcpy (copy
, *argptr
, p
- *argptr
);
2153 copy
[p
- *argptr
] = 0;
2155 /* Discard the class name from the arg. */
2156 p
= p1
+ (p1
[0] == ':' ? 2 : 1);
2157 while (*p
== ' ' || *p
== '\t') p
++;
2160 sym_class
= lookup_symbol (copy
, 0, STRUCT_NAMESPACE
, 0,
2161 (struct symtab
**)NULL
);
2164 (t
= check_typedef (SYMBOL_TYPE (sym_class
)),
2165 (TYPE_CODE (t
) == TYPE_CODE_STRUCT
2166 || TYPE_CODE (t
) == TYPE_CODE_UNION
)))
2168 /* Arg token is not digits => try it as a function name
2169 Find the next token(everything up to end or next blank). */
2171 && strchr (gdb_completer_quote_characters
, **argptr
) != NULL
)
2173 p
= skip_quoted(*argptr
);
2174 *argptr
= *argptr
+ 1;
2179 while (*p
&& *p
!=' ' && *p
!='\t' && *p
!=',' && *p
!=':') p
++;
2182 q = operator_chars (*argptr, &q1);
2186 char *tmp = alloca (q1 - q + 1);
2187 memcpy (tmp, q, q1 - q);
2189 opname = cplus_mangle_opname (tmp, DMGL_ANSI);
2193 printf_filtered ("no mangling for \"%s\"\n", tmp);
2194 cplusplus_hint (saved_arg);
2195 return_to_top_level (RETURN_ERROR);
2197 copy = (char*) alloca (3 + strlen(opname));
2198 sprintf (copy, "__%s", opname);
2204 copy
= (char *) alloca (p
- *argptr
+ 1 );
2205 memcpy (copy
, *argptr
, p
- *argptr
);
2206 copy
[p
- *argptr
] = '\0';
2208 && copy
[p
- *argptr
- 1]
2209 && strchr (gdb_completer_quote_characters
,
2210 copy
[p
- *argptr
- 1]) != NULL
)
2211 copy
[p
- *argptr
- 1] = '\0';
2214 /* no line number may be specified */
2215 while (*p
== ' ' || *p
== '\t') p
++;
2219 i1
= 0; /* counter for the symbol array */
2220 sym_arr
= (struct symbol
**) alloca(total_number_of_methods (t
)
2221 * sizeof(struct symbol
*));
2223 if (destructor_name_p (copy
, t
))
2225 /* Destructors are a special case. */
2226 int m_index
, f_index
;
2228 if (get_destructor_fn_field (t
, &m_index
, &f_index
))
2230 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, m_index
);
2233 lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f
, f_index
),
2234 NULL
, VAR_NAMESPACE
, (int *) NULL
,
2235 (struct symtab
**)NULL
);
2241 i1
= find_methods (t
, copy
, sym_arr
);
2244 /* There is exactly one field with that name. */
2247 if (sym
&& SYMBOL_CLASS (sym
) == LOC_BLOCK
)
2249 values
.sals
= (struct symtab_and_line
*)
2250 xmalloc (sizeof (struct symtab_and_line
));
2252 values
.sals
[0] = find_function_start_sal (sym
,
2263 /* There is more than one field with that name
2264 (overloaded). Ask the user which one to use. */
2265 return decode_line_2 (sym_arr
, i1
, funfirstline
, canonical
);
2271 if (OPNAME_PREFIX_P (copy
))
2273 tmp
= (char *)alloca (strlen (copy
+3) + 9);
2274 strcpy (tmp
, "operator ");
2275 strcat (tmp
, copy
+3);
2282 ("the class `%s' does not have destructor defined\n",
2283 SYMBOL_SOURCE_NAME(sym_class
));
2286 ("the class %s does not have any method named %s\n",
2287 SYMBOL_SOURCE_NAME(sym_class
), tmp
);
2288 cplusplus_hint (saved_arg
);
2289 return_to_top_level (RETURN_ERROR
);
2295 /* The quotes are important if copy is empty. */
2297 ("can't find class, struct, or union named \"%s\"\n", copy
);
2298 cplusplus_hint (saved_arg
);
2299 return_to_top_level (RETURN_ERROR
);
2305 /* Extract the file name. */
2307 while (p
!= *argptr
&& p
[-1] == ' ') --p
;
2308 copy
= (char *) alloca (p
- *argptr
+ 1);
2309 memcpy (copy
, *argptr
, p
- *argptr
);
2310 copy
[p
- *argptr
] = 0;
2312 /* Find that file's data. */
2313 s
= lookup_symtab (copy
);
2316 if (!have_full_symbols () && !have_partial_symbols ())
2317 error (no_symtab_msg
);
2318 error ("No source file named %s.", copy
);
2321 /* Discard the file name from the arg. */
2323 while (*p
== ' ' || *p
== '\t') p
++;
2327 /* S is specified file's symtab, or 0 if no file specified.
2328 arg no longer contains the file name. */
2330 /* Check whether arg is all digits (and sign) */
2333 if (*q
== '-' || *q
== '+') q
++;
2334 while (*q
>= '0' && *q
<= '9')
2337 if (q
!= *argptr
&& (*q
== 0 || *q
== ' ' || *q
== '\t' || *q
== ','))
2339 /* We found a token consisting of all digits -- at least one digit. */
2340 enum sign
{none
, plus
, minus
} sign
= none
;
2342 /* We might need a canonical line spec if no file was specified. */
2343 int need_canonical
= (s
== 0) ? 1 : 0;
2345 /* This is where we need to make sure that we have good defaults.
2346 We must guarantee that this section of code is never executed
2347 when we are called with just a function name, since
2348 select_source_symtab calls us with such an argument */
2350 if (s
== 0 && default_symtab
== 0)
2352 select_source_symtab (0);
2353 default_symtab
= current_source_symtab
;
2354 default_line
= current_source_line
;
2357 if (**argptr
== '+')
2358 sign
= plus
, (*argptr
)++;
2359 else if (**argptr
== '-')
2360 sign
= minus
, (*argptr
)++;
2361 val
.line
= atoi (*argptr
);
2368 val
.line
= default_line
+ val
.line
;
2374 val
.line
= default_line
- val
.line
;
2379 break; /* No need to adjust val.line. */
2382 while (*q
== ' ' || *q
== '\t') q
++;
2388 values
.sals
= (struct symtab_and_line
*)
2389 xmalloc (sizeof (struct symtab_and_line
));
2390 values
.sals
[0] = val
;
2393 build_canonical_line_spec (values
.sals
, NULL
, canonical
);
2397 /* Arg token is not digits => try it as a variable name
2398 Find the next token (everything up to end or next whitespace). */
2400 if (**argptr
== '$') /* Convenience variable */
2401 p
= skip_quoted (*argptr
+ 1);
2404 p
= skip_quoted (*argptr
);
2406 error ("Unmatched single quote.");
2408 else if (has_parens
)
2414 p
= skip_quoted(*argptr
);
2417 copy
= (char *) alloca (p
- *argptr
+ 1);
2418 memcpy (copy
, *argptr
, p
- *argptr
);
2419 copy
[p
- *argptr
] = '\0';
2422 && copy
[0] == copy
[p
- *argptr
- 1]
2423 && strchr (gdb_completer_quote_characters
, copy
[0]) != NULL
)
2425 copy
[p
- *argptr
- 1] = '\0';
2428 while (*p
== ' ' || *p
== '\t') p
++;
2431 /* See if it's a convenience variable */
2436 int need_canonical
= (s
== 0) ? 1 : 0;
2438 valx
= value_of_internalvar (lookup_internalvar (copy
+ 1));
2439 if (TYPE_CODE (VALUE_TYPE (valx
)) != TYPE_CODE_INT
)
2440 error ("Convenience variables used in line specs must have integer values.");
2442 val
.symtab
= s
? s
: default_symtab
;
2443 val
.line
= value_as_long (valx
);
2446 values
.sals
= (struct symtab_and_line
*)xmalloc (sizeof val
);
2447 values
.sals
[0] = val
;
2451 build_canonical_line_spec (values
.sals
, NULL
, canonical
);
2457 /* Look up that token as a variable.
2458 If file specified, use that file's per-file block to start with. */
2460 sym
= lookup_symbol (copy
,
2461 (s
? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
)
2462 : get_selected_block ()),
2463 VAR_NAMESPACE
, 0, &sym_symtab
);
2467 if (SYMBOL_CLASS (sym
) == LOC_BLOCK
)
2469 /* Arg is the name of a function */
2470 values
.sals
= (struct symtab_and_line
*)
2471 xmalloc (sizeof (struct symtab_and_line
));
2472 values
.sals
[0] = find_function_start_sal (sym
, funfirstline
);
2475 /* Don't use the SYMBOL_LINE; if used at all it points to
2476 the line containing the parameters or thereabouts, not
2477 the first line of code. */
2479 /* We might need a canonical line spec if it is a static
2483 struct blockvector
*bv
= BLOCKVECTOR (sym_symtab
);
2484 struct block
*b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
2485 if (lookup_block_symbol (b
, copy
, VAR_NAMESPACE
) != NULL
)
2486 build_canonical_line_spec (values
.sals
, copy
, canonical
);
2493 error ("\"%s\" is not a function", copy
);
2494 else if (SYMBOL_LINE (sym
) != 0)
2496 /* We know its line number. */
2497 values
.sals
= (struct symtab_and_line
*)
2498 xmalloc (sizeof (struct symtab_and_line
));
2500 memset (&values
.sals
[0], 0, sizeof (values
.sals
[0]));
2501 values
.sals
[0].symtab
= sym_symtab
;
2502 values
.sals
[0].line
= SYMBOL_LINE (sym
);
2506 /* This can happen if it is compiled with a compiler which doesn't
2507 put out line numbers for variables. */
2508 /* FIXME: Shouldn't we just set .line and .symtab to zero
2509 and return? For example, "info line foo" could print
2511 error ("Line number not known for symbol \"%s\"", copy
);
2515 msymbol
= lookup_minimal_symbol (copy
, NULL
, NULL
);
2516 if (msymbol
!= NULL
)
2518 val
.pc
= SYMBOL_VALUE_ADDRESS (msymbol
);
2519 val
.section
= SYMBOL_BFD_SECTION (msymbol
);
2522 val
.pc
+= FUNCTION_START_OFFSET
;
2523 SKIP_PROLOGUE (val
.pc
);
2525 values
.sals
= (struct symtab_and_line
*)
2526 xmalloc (sizeof (struct symtab_and_line
));
2527 values
.sals
[0] = val
;
2532 if (!have_full_symbols () &&
2533 !have_partial_symbols () && !have_minimal_symbols ())
2534 error (no_symtab_msg
);
2536 error ("Function \"%s\" not defined.", copy
);
2537 return values
; /* for lint */
2540 struct symtabs_and_lines
2541 decode_line_spec (string
, funfirstline
)
2545 struct symtabs_and_lines sals
;
2547 error ("Empty line specification.");
2548 sals
= decode_line_1 (&string
, funfirstline
,
2549 current_source_symtab
, current_source_line
,
2552 error ("Junk at end of line specification: %s", string
);
2556 /* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
2557 operate on (ask user if necessary).
2558 If CANONICAL is non-NULL return a corresponding array of mangled names
2559 as canonical line specs there. */
2561 static struct symtabs_and_lines
2562 decode_line_2 (sym_arr
, nelts
, funfirstline
, canonical
)
2563 struct symbol
*sym_arr
[];
2568 struct symtabs_and_lines values
, return_values
;
2573 struct cleanup
*old_chain
;
2574 char **canonical_arr
= (char **)NULL
;
2576 values
.sals
= (struct symtab_and_line
*)
2577 alloca (nelts
* sizeof(struct symtab_and_line
));
2578 return_values
.sals
= (struct symtab_and_line
*)
2579 xmalloc (nelts
* sizeof(struct symtab_and_line
));
2580 old_chain
= make_cleanup (free
, return_values
.sals
);
2584 canonical_arr
= (char **) xmalloc (nelts
* sizeof (char *));
2585 make_cleanup (free
, canonical_arr
);
2586 memset (canonical_arr
, 0, nelts
* sizeof (char *));
2587 *canonical
= canonical_arr
;
2591 printf_unfiltered("[0] cancel\n[1] all\n");
2594 INIT_SAL (&return_values
.sals
[i
]); /* initialize to zeroes */
2595 INIT_SAL (&values
.sals
[i
]);
2596 if (sym_arr
[i
] && SYMBOL_CLASS (sym_arr
[i
]) == LOC_BLOCK
)
2598 values
.sals
[i
] = find_function_start_sal (sym_arr
[i
], funfirstline
);
2599 printf_unfiltered ("[%d] %s at %s:%d\n",
2601 SYMBOL_SOURCE_NAME (sym_arr
[i
]),
2602 values
.sals
[i
].symtab
->filename
,
2603 values
.sals
[i
].line
);
2606 printf_unfiltered ("?HERE\n");
2610 if ((prompt
= getenv ("PS2")) == NULL
)
2614 printf_unfiltered("%s ",prompt
);
2615 gdb_flush(gdb_stdout
);
2617 args
= command_line_input ((char *) NULL
, 0, "overload-choice");
2619 if (args
== 0 || *args
== 0)
2620 error_no_arg ("one or more choice numbers");
2628 while (*arg1
>= '0' && *arg1
<= '9') arg1
++;
2629 if (*arg1
&& *arg1
!= ' ' && *arg1
!= '\t')
2630 error ("Arguments must be choice numbers.");
2635 error ("cancelled");
2640 for (i
= 0; i
< nelts
; i
++)
2642 if (canonical_arr
[i
] == NULL
)
2644 symname
= SYMBOL_NAME (sym_arr
[i
]);
2645 canonical_arr
[i
] = savestring (symname
, strlen (symname
));
2649 memcpy (return_values
.sals
, values
.sals
,
2650 (nelts
* sizeof(struct symtab_and_line
)));
2651 return_values
.nelts
= nelts
;
2652 discard_cleanups (old_chain
);
2653 return return_values
;
2656 if (num
>= nelts
+ 2)
2658 printf_unfiltered ("No choice number %d.\n", num
);
2663 if (values
.sals
[num
].pc
)
2667 symname
= SYMBOL_NAME (sym_arr
[num
]);
2668 make_cleanup (free
, symname
);
2669 canonical_arr
[i
] = savestring (symname
, strlen (symname
));
2671 return_values
.sals
[i
++] = values
.sals
[num
];
2672 values
.sals
[num
].pc
= 0;
2676 printf_unfiltered ("duplicate request for %d ignored.\n", num
);
2681 while (*args
== ' ' || *args
== '\t') args
++;
2683 return_values
.nelts
= i
;
2684 discard_cleanups (old_chain
);
2685 return return_values
;
2689 /* Slave routine for sources_info. Force line breaks at ,'s.
2690 NAME is the name to print and *FIRST is nonzero if this is the first
2691 name printed. Set *FIRST to zero. */
2693 output_source_filename (name
, first
)
2697 /* Table of files printed so far. Since a single source file can
2698 result in several partial symbol tables, we need to avoid printing
2699 it more than once. Note: if some of the psymtabs are read in and
2700 some are not, it gets printed both under "Source files for which
2701 symbols have been read" and "Source files for which symbols will
2702 be read in on demand". I consider this a reasonable way to deal
2703 with the situation. I'm not sure whether this can also happen for
2704 symtabs; it doesn't hurt to check. */
2705 static char **tab
= NULL
;
2706 /* Allocated size of tab in elements.
2707 Start with one 256-byte block (when using GNU malloc.c).
2708 24 is the malloc overhead when range checking is in effect. */
2709 static int tab_alloc_size
= (256 - 24) / sizeof (char *);
2710 /* Current size of tab in elements. */
2711 static int tab_cur_size
;
2718 tab
= (char **) xmalloc (tab_alloc_size
* sizeof (*tab
));
2722 /* Is NAME in tab? */
2723 for (p
= tab
; p
< tab
+ tab_cur_size
; p
++)
2724 if (STREQ (*p
, name
))
2725 /* Yes; don't print it again. */
2727 /* No; add it to tab. */
2728 if (tab_cur_size
== tab_alloc_size
)
2730 tab_alloc_size
*= 2;
2731 tab
= (char **) xrealloc ((char *) tab
, tab_alloc_size
* sizeof (*tab
));
2733 tab
[tab_cur_size
++] = name
;
2741 printf_filtered (", ");
2745 fputs_filtered (name
, gdb_stdout
);
2749 sources_info (ignore
, from_tty
)
2753 register struct symtab
*s
;
2754 register struct partial_symtab
*ps
;
2755 register struct objfile
*objfile
;
2758 if (!have_full_symbols () && !have_partial_symbols ())
2760 error (no_symtab_msg
);
2763 printf_filtered ("Source files for which symbols have been read in:\n\n");
2766 ALL_SYMTABS (objfile
, s
)
2768 output_source_filename (s
-> filename
, &first
);
2770 printf_filtered ("\n\n");
2772 printf_filtered ("Source files for which symbols will be read in on demand:\n\n");
2775 ALL_PSYMTABS (objfile
, ps
)
2779 output_source_filename (ps
-> filename
, &first
);
2782 printf_filtered ("\n");
2785 /* List all symbols (if REGEXP is NULL) or all symbols matching REGEXP.
2786 If CLASS is zero, list all symbols except functions, type names, and
2788 If CLASS is 1, list only functions.
2789 If CLASS is 2, list only type names.
2790 If CLASS is 3, list only method names.
2792 BPT is non-zero if we should set a breakpoint at the functions
2796 list_symbols (regexp
, class, bpt
, from_tty
)
2802 register struct symtab
*s
;
2803 register struct partial_symtab
*ps
;
2804 register struct blockvector
*bv
;
2805 struct blockvector
*prev_bv
= 0;
2806 register struct block
*b
;
2808 register struct symbol
*sym
;
2809 struct partial_symbol
**psym
;
2810 struct objfile
*objfile
;
2811 struct minimal_symbol
*msymbol
;
2813 static char *classnames
[]
2814 = {"variable", "function", "type", "method"};
2815 int found_in_file
= 0;
2817 static enum minimal_symbol_type types
[]
2818 = {mst_data
, mst_text
, mst_abs
, mst_unknown
};
2819 static enum minimal_symbol_type types2
[]
2820 = {mst_bss
, mst_file_text
, mst_abs
, mst_unknown
};
2821 static enum minimal_symbol_type types3
[]
2822 = {mst_file_data
, mst_solib_trampoline
, mst_abs
, mst_unknown
};
2823 static enum minimal_symbol_type types4
[]
2824 = {mst_file_bss
, mst_text
, mst_abs
, mst_unknown
};
2825 enum minimal_symbol_type ourtype
= types
[class];
2826 enum minimal_symbol_type ourtype2
= types2
[class];
2827 enum minimal_symbol_type ourtype3
= types3
[class];
2828 enum minimal_symbol_type ourtype4
= types4
[class];
2832 /* Make sure spacing is right for C++ operators.
2833 This is just a courtesy to make the matching less sensitive
2834 to how many spaces the user leaves between 'operator'
2835 and <TYPENAME> or <OPERATOR>. */
2837 char *opname
= operator_chars (regexp
, &opend
);
2840 int fix
= -1; /* -1 means ok; otherwise number of spaces needed. */
2841 if (isalpha(*opname
) || *opname
== '_' || *opname
== '$')
2843 /* There should 1 space between 'operator' and 'TYPENAME'. */
2844 if (opname
[-1] != ' ' || opname
[-2] == ' ')
2849 /* There should 0 spaces between 'operator' and 'OPERATOR'. */
2850 if (opname
[-1] == ' ')
2853 /* If wrong number of spaces, fix it. */
2856 char *tmp
= (char*) alloca(opend
-opname
+10);
2857 sprintf(tmp
, "operator%.*s%s", fix
, " ", opname
);
2862 if (0 != (val
= re_comp (regexp
)))
2863 error ("Invalid regexp (%s): %s", val
, regexp
);
2866 /* Search through the partial symtabs *first* for all symbols
2867 matching the regexp. That way we don't have to reproduce all of
2868 the machinery below. */
2870 ALL_PSYMTABS (objfile
, ps
)
2872 struct partial_symbol
**bound
, **gbound
, **sbound
;
2875 if (ps
->readin
) continue;
2877 gbound
= objfile
->global_psymbols
.list
+ ps
->globals_offset
+ ps
->n_global_syms
;
2878 sbound
= objfile
->static_psymbols
.list
+ ps
->statics_offset
+ ps
->n_static_syms
;
2881 /* Go through all of the symbols stored in a partial
2882 symtab in one loop. */
2883 psym
= objfile
->global_psymbols
.list
+ ps
->globals_offset
;
2888 if (bound
== gbound
&& ps
->n_static_syms
!= 0)
2890 psym
= objfile
->static_psymbols
.list
+ ps
->statics_offset
;
2901 /* If it would match (logic taken from loop below)
2902 load the file and go on to the next one */
2903 if ((regexp
== NULL
|| SYMBOL_MATCHES_REGEXP (*psym
))
2904 && ((class == 0 && SYMBOL_CLASS (*psym
) != LOC_TYPEDEF
2905 && SYMBOL_CLASS (*psym
) != LOC_BLOCK
)
2906 || (class == 1 && SYMBOL_CLASS (*psym
) == LOC_BLOCK
)
2907 || (class == 2 && SYMBOL_CLASS (*psym
) == LOC_TYPEDEF
)
2908 || (class == 3 && SYMBOL_CLASS (*psym
) == LOC_BLOCK
)))
2910 PSYMTAB_TO_SYMTAB(ps
);
2918 /* Here, we search through the minimal symbol tables for functions
2919 and variables that match, and force their symbols to be read.
2920 This is in particular necessary for demangled variable names,
2921 which are no longer put into the partial symbol tables.
2922 The symbol will then be found during the scan of symtabs below.
2924 For functions, find_pc_symtab should succeed if we have debug info
2925 for the function, for variables we have to call lookup_symbol
2926 to determine if the variable has debug info.
2927 If the lookup fails, set found_misc so that we will rescan to print
2928 any matching symbols without debug info.
2931 if (class == 0 || class == 1)
2933 ALL_MSYMBOLS (objfile
, msymbol
)
2935 if (MSYMBOL_TYPE (msymbol
) == ourtype
||
2936 MSYMBOL_TYPE (msymbol
) == ourtype2
||
2937 MSYMBOL_TYPE (msymbol
) == ourtype3
||
2938 MSYMBOL_TYPE (msymbol
) == ourtype4
)
2940 if (regexp
== NULL
|| SYMBOL_MATCHES_REGEXP (msymbol
))
2942 if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol
)))
2945 || lookup_symbol (SYMBOL_NAME (msymbol
),
2946 (struct block
*) NULL
,
2948 0, (struct symtab
**) NULL
) == NULL
)
2956 /* Printout here so as to get after the "Reading in symbols"
2957 messages which will be generated above. */
2959 printf_filtered (regexp
2960 ? "All %ss matching regular expression \"%s\":\n"
2961 : "All defined %ss:\n",
2965 ALL_SYMTABS (objfile
, s
)
2968 bv
= BLOCKVECTOR (s
);
2969 /* Often many files share a blockvector.
2970 Scan each blockvector only once so that
2971 we don't get every symbol many times.
2972 It happens that the first symtab in the list
2973 for any given blockvector is the main file. */
2975 for (i
= GLOBAL_BLOCK
; i
<= STATIC_BLOCK
; i
++)
2977 b
= BLOCKVECTOR_BLOCK (bv
, i
);
2978 /* Skip the sort if this block is always sorted. */
2979 if (!BLOCK_SHOULD_SORT (b
))
2980 sort_block_syms (b
);
2981 for (j
= 0; j
< BLOCK_NSYMS (b
); j
++)
2984 sym
= BLOCK_SYM (b
, j
);
2985 if ((regexp
== NULL
|| SYMBOL_MATCHES_REGEXP (sym
))
2986 && ((class == 0 && SYMBOL_CLASS (sym
) != LOC_TYPEDEF
2987 && SYMBOL_CLASS (sym
) != LOC_BLOCK
2988 && SYMBOL_CLASS (sym
) != LOC_CONST
)
2989 || (class == 1 && SYMBOL_CLASS (sym
) == LOC_BLOCK
)
2990 || (class == 2 && SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
2991 || (class == 3 && SYMBOL_CLASS (sym
) == LOC_BLOCK
)))
2995 /* Set a breakpoint here, if it's a function */
2998 /* There may be more than one function with the
2999 same name but in different files. In order to
3000 set breakpoints on all of them, we must give
3001 both the file name and the function name to
3003 Quoting the symbol name gets rid of problems
3004 with mangled symbol names that contain
3005 CPLUS_MARKER characters. */
3007 (char *) alloca (strlen (s
->filename
)
3008 + strlen (SYMBOL_NAME(sym
))
3010 strcpy (string
, s
->filename
);
3011 strcat (string
, ":'");
3012 strcat (string
, SYMBOL_NAME(sym
));
3013 strcat (string
, "'");
3014 break_command (string
, from_tty
);
3017 else if (!found_in_file
)
3019 fputs_filtered ("\nFile ", gdb_stdout
);
3020 fputs_filtered (s
->filename
, gdb_stdout
);
3021 fputs_filtered (":\n", gdb_stdout
);
3025 if (class != 2 && i
== STATIC_BLOCK
)
3026 printf_filtered ("static ");
3028 /* Typedef that is not a C++ class */
3030 && SYMBOL_NAMESPACE (sym
) != STRUCT_NAMESPACE
)
3031 c_typedef_print (SYMBOL_TYPE(sym
), sym
, gdb_stdout
);
3032 /* variable, func, or typedef-that-is-c++-class */
3033 else if (class < 2 ||
3035 SYMBOL_NAMESPACE(sym
) == STRUCT_NAMESPACE
))
3037 type_print (SYMBOL_TYPE (sym
),
3038 (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
3039 ? "" : SYMBOL_SOURCE_NAME (sym
)),
3042 printf_filtered (";\n");
3047 /* Tiemann says: "info methods was never implemented." */
3048 char *demangled_name
;
3049 c_type_print_base (TYPE_FN_FIELD_TYPE(t
, i
),
3051 c_type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t
, i
),
3053 if (TYPE_FN_FIELD_STUB (t
, i
))
3054 check_stub_method (TYPE_DOMAIN_TYPE (type
), j
, i
);
3056 cplus_demangle (TYPE_FN_FIELD_PHYSNAME (t
, i
),
3057 DMGL_ANSI
| DMGL_PARAMS
);
3058 if (demangled_name
== NULL
)
3059 fprintf_filtered (stream
, "<badly mangled name %s>",
3060 TYPE_FN_FIELD_PHYSNAME (t
, i
));
3063 fputs_filtered (demangled_name
, stream
);
3064 free (demangled_name
);
3074 /* If there are no eyes, avoid all contact. I mean, if there are
3075 no debug symbols, then print directly from the msymbol_vector. */
3077 if (found_misc
|| class != 1)
3080 ALL_MSYMBOLS (objfile
, msymbol
)
3082 if (MSYMBOL_TYPE (msymbol
) == ourtype
||
3083 MSYMBOL_TYPE (msymbol
) == ourtype2
||
3084 MSYMBOL_TYPE (msymbol
) == ourtype3
||
3085 MSYMBOL_TYPE (msymbol
) == ourtype4
)
3087 if (regexp
== NULL
|| SYMBOL_MATCHES_REGEXP (msymbol
))
3089 /* Functions: Look up by address. */
3091 (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol
))))
3093 /* Variables/Absolutes: Look up by name */
3094 if (lookup_symbol (SYMBOL_NAME (msymbol
),
3095 (struct block
*) NULL
, VAR_NAMESPACE
,
3096 0, (struct symtab
**) NULL
) == NULL
)
3100 break_command (SYMBOL_NAME (msymbol
), from_tty
);
3101 printf_filtered ("<function, no debug info> %s;\n",
3102 SYMBOL_SOURCE_NAME (msymbol
));
3107 printf_filtered ("\nNon-debugging symbols:\n");
3110 printf_filtered (" %08lx %s\n",
3111 (unsigned long) SYMBOL_VALUE_ADDRESS (msymbol
),
3112 SYMBOL_SOURCE_NAME (msymbol
));
3122 variables_info (regexp
, from_tty
)
3126 list_symbols (regexp
, 0, 0, from_tty
);
3130 functions_info (regexp
, from_tty
)
3134 list_symbols (regexp
, 1, 0, from_tty
);
3138 types_info (regexp
, from_tty
)
3142 list_symbols (regexp
, 2, 0, from_tty
);
3146 /* Tiemann says: "info methods was never implemented." */
3148 methods_info (regexp
)
3151 list_symbols (regexp
, 3, 0, from_tty
);
3155 /* Breakpoint all functions matching regular expression. */
3157 rbreak_command (regexp
, from_tty
)
3161 list_symbols (regexp
, 1, 1, from_tty
);
3165 /* Return Nonzero if block a is lexically nested within block b,
3166 or if a and b have the same pc range.
3167 Return zero otherwise. */
3170 struct block
*a
, *b
;
3174 return BLOCK_START (a
) >= BLOCK_START (b
)
3175 && BLOCK_END (a
) <= BLOCK_END (b
);
3179 /* Helper routine for make_symbol_completion_list. */
3181 static int return_val_size
;
3182 static int return_val_index
;
3183 static char **return_val
;
3185 #define COMPLETION_LIST_ADD_SYMBOL(symbol, sym_text, len, text, word) \
3187 if (SYMBOL_DEMANGLED_NAME (symbol) != NULL) \
3188 /* Put only the mangled name on the list. */ \
3189 /* Advantage: "b foo<TAB>" completes to "b foo(int, int)" */ \
3190 /* Disadvantage: "b foo__i<TAB>" doesn't complete. */ \
3191 completion_list_add_name \
3192 (SYMBOL_DEMANGLED_NAME (symbol), (sym_text), (len), (text), (word)); \
3194 completion_list_add_name \
3195 (SYMBOL_NAME (symbol), (sym_text), (len), (text), (word)); \
3198 /* Test to see if the symbol specified by SYMNAME (which is already
3199 demangled for C++ symbols) matches SYM_TEXT in the first SYM_TEXT_LEN
3200 characters. If so, add it to the current completion list. */
3203 completion_list_add_name (symname
, sym_text
, sym_text_len
, text
, word
)
3213 /* clip symbols that cannot match */
3215 if (strncmp (symname
, sym_text
, sym_text_len
) != 0)
3220 /* Clip any symbol names that we've already considered. (This is a
3221 time optimization) */
3223 for (i
= 0; i
< return_val_index
; ++i
)
3225 if (STREQ (symname
, return_val
[i
]))
3231 /* We have a match for a completion, so add SYMNAME to the current list
3232 of matches. Note that the name is moved to freshly malloc'd space. */
3236 if (word
== sym_text
)
3238 new = xmalloc (strlen (symname
) + 5);
3239 strcpy (new, symname
);
3241 else if (word
> sym_text
)
3243 /* Return some portion of symname. */
3244 new = xmalloc (strlen (symname
) + 5);
3245 strcpy (new, symname
+ (word
- sym_text
));
3249 /* Return some of SYM_TEXT plus symname. */
3250 new = xmalloc (strlen (symname
) + (sym_text
- word
) + 5);
3251 strncpy (new, word
, sym_text
- word
);
3252 new[sym_text
- word
] = '\0';
3253 strcat (new, symname
);
3256 /* Recheck for duplicates if we intend to add a modified symbol. */
3257 if (word
!= sym_text
)
3259 for (i
= 0; i
< return_val_index
; ++i
)
3261 if (STREQ (new, return_val
[i
]))
3269 if (return_val_index
+ 3 > return_val_size
)
3271 newsize
= (return_val_size
*= 2) * sizeof (char *);
3272 return_val
= (char **) xrealloc ((char *) return_val
, newsize
);
3274 return_val
[return_val_index
++] = new;
3275 return_val
[return_val_index
] = NULL
;
3279 /* Return a NULL terminated array of all symbols (regardless of class) which
3280 begin by matching TEXT. If the answer is no symbols, then the return value
3281 is an array which contains only a NULL pointer.
3283 Problem: All of the symbols have to be copied because readline frees them.
3284 I'm not going to worry about this; hopefully there won't be that many. */
3287 make_symbol_completion_list (text
, word
)
3291 register struct symbol
*sym
;
3292 register struct symtab
*s
;
3293 register struct partial_symtab
*ps
;
3294 register struct minimal_symbol
*msymbol
;
3295 register struct objfile
*objfile
;
3296 register struct block
*b
, *surrounding_static_block
= 0;
3298 struct partial_symbol
**psym
;
3299 /* The symbol we are completing on. Points in same buffer as text. */
3301 /* Length of sym_text. */
3304 /* Now look for the symbol we are supposed to complete on.
3305 FIXME: This should be language-specific. */
3309 char *quote_pos
= NULL
;
3311 /* First see if this is a quoted string. */
3313 for (p
= text
; *p
!= '\0'; ++p
)
3315 if (quote_found
!= '\0')
3317 if (*p
== quote_found
)
3318 /* Found close quote. */
3320 else if (*p
== '\\' && p
[1] == quote_found
)
3321 /* A backslash followed by the quote character
3322 doesn't end the string. */
3325 else if (*p
== '\'' || *p
== '"')
3331 if (quote_found
== '\'')
3332 /* A string within single quotes can be a symbol, so complete on it. */
3333 sym_text
= quote_pos
+ 1;
3334 else if (quote_found
== '"')
3335 /* A double-quoted string is never a symbol, nor does it make sense
3336 to complete it any other way. */
3340 /* It is not a quoted string. Break it based on the characters
3341 which are in symbols. */
3344 if (isalnum (p
[-1]) || p
[-1] == '_' || p
[-1] == '\0')
3353 sym_text_len
= strlen (sym_text
);
3355 return_val_size
= 100;
3356 return_val_index
= 0;
3357 return_val
= (char **) xmalloc ((return_val_size
+ 1) * sizeof (char *));
3358 return_val
[0] = NULL
;
3360 /* Look through the partial symtabs for all symbols which begin
3361 by matching SYM_TEXT. Add each one that you find to the list. */
3363 ALL_PSYMTABS (objfile
, ps
)
3365 /* If the psymtab's been read in we'll get it when we search
3366 through the blockvector. */
3367 if (ps
->readin
) continue;
3369 for (psym
= objfile
->global_psymbols
.list
+ ps
->globals_offset
;
3370 psym
< (objfile
->global_psymbols
.list
+ ps
->globals_offset
3371 + ps
->n_global_syms
);
3374 /* If interrupted, then quit. */
3376 COMPLETION_LIST_ADD_SYMBOL (*psym
, sym_text
, sym_text_len
, text
, word
);
3379 for (psym
= objfile
->static_psymbols
.list
+ ps
->statics_offset
;
3380 psym
< (objfile
->static_psymbols
.list
+ ps
->statics_offset
3381 + ps
->n_static_syms
);
3385 COMPLETION_LIST_ADD_SYMBOL (*psym
, sym_text
, sym_text_len
, text
, word
);
3389 /* At this point scan through the misc symbol vectors and add each
3390 symbol you find to the list. Eventually we want to ignore
3391 anything that isn't a text symbol (everything else will be
3392 handled by the psymtab code above). */
3394 ALL_MSYMBOLS (objfile
, msymbol
)
3397 COMPLETION_LIST_ADD_SYMBOL (msymbol
, sym_text
, sym_text_len
, text
, word
);
3400 /* Search upwards from currently selected frame (so that we can
3401 complete on local vars. */
3403 for (b
= get_selected_block (); b
!= NULL
; b
= BLOCK_SUPERBLOCK (b
))
3405 if (!BLOCK_SUPERBLOCK (b
))
3407 surrounding_static_block
= b
; /* For elmin of dups */
3410 /* Also catch fields of types defined in this places which match our
3411 text string. Only complete on types visible from current context. */
3413 for (i
= 0; i
< BLOCK_NSYMS (b
); i
++)
3415 sym
= BLOCK_SYM (b
, i
);
3416 COMPLETION_LIST_ADD_SYMBOL (sym
, sym_text
, sym_text_len
, text
, word
);
3417 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
3419 struct type
*t
= SYMBOL_TYPE (sym
);
3420 enum type_code c
= TYPE_CODE (t
);
3422 if (c
== TYPE_CODE_UNION
|| c
== TYPE_CODE_STRUCT
)
3424 for (j
= TYPE_N_BASECLASSES (t
); j
< TYPE_NFIELDS (t
); j
++)
3426 if (TYPE_FIELD_NAME (t
, j
))
3428 completion_list_add_name (TYPE_FIELD_NAME (t
, j
),
3429 sym_text
, sym_text_len
, text
, word
);
3437 /* Go through the symtabs and check the externs and statics for
3438 symbols which match. */
3440 ALL_SYMTABS (objfile
, s
)
3443 b
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
);
3444 for (i
= 0; i
< BLOCK_NSYMS (b
); i
++)
3446 sym
= BLOCK_SYM (b
, i
);
3447 COMPLETION_LIST_ADD_SYMBOL (sym
, sym_text
, sym_text_len
, text
, word
);
3451 ALL_SYMTABS (objfile
, s
)
3454 b
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
);
3455 /* Don't do this block twice. */
3456 if (b
== surrounding_static_block
) continue;
3457 for (i
= 0; i
< BLOCK_NSYMS (b
); i
++)
3459 sym
= BLOCK_SYM (b
, i
);
3460 COMPLETION_LIST_ADD_SYMBOL (sym
, sym_text
, sym_text_len
, text
, word
);
3464 return (return_val
);
3467 /* Determine if PC is in the prologue of a function. The prologue is the area
3468 between the first instruction of a function, and the first executable line.
3469 Returns 1 if PC *might* be in prologue, 0 if definately *not* in prologue.
3471 If non-zero, func_start is where we think the prologue starts, possibly
3472 by previous examination of symbol table information.
3476 in_prologue (pc
, func_start
)
3478 CORE_ADDR func_start
;
3480 struct symtab_and_line sal
;
3481 CORE_ADDR func_addr
, func_end
;
3483 if (!find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
3484 goto nosyms
; /* Might be in prologue */
3486 sal
= find_pc_line (func_addr
, 0);
3491 if (sal
.end
> func_addr
3492 && sal
.end
<= func_end
) /* Is prologue in function? */
3493 return pc
< sal
.end
; /* Yes, is pc in prologue? */
3495 /* The line after the prologue seems to be outside the function. In this
3496 case, tell the caller to find the prologue the hard way. */
3500 /* Come here when symtabs don't contain line # info. In this case, it is
3501 likely that the user has stepped into a library function w/o symbols, or
3502 is doing a stepi/nexti through code without symbols. */
3506 /* If func_start is zero (meaning unknown) then we don't know whether pc is
3507 in the prologue or not. I.E. it might be. */
3509 if (!func_start
) return 1;
3511 /* We need to call the target-specific prologue skipping functions with the
3512 function's start address because PC may be pointing at an instruction that
3513 could be mistakenly considered part of the prologue. */
3515 SKIP_PROLOGUE (func_start
);
3517 return pc
< func_start
;
3522 _initialize_symtab ()
3524 add_info ("variables", variables_info
,
3525 "All global and static variable names, or those matching REGEXP.");
3526 add_info ("functions", functions_info
,
3527 "All function names, or those matching REGEXP.");
3529 /* FIXME: This command has at least the following problems:
3530 1. It prints builtin types (in a very strange and confusing fashion).
3531 2. It doesn't print right, e.g. with
3532 typedef struct foo *FOO
3533 type_print prints "FOO" when we want to make it (in this situation)
3534 print "struct foo *".
3535 I also think "ptype" or "whatis" is more likely to be useful (but if
3536 there is much disagreement "info types" can be fixed). */
3537 add_info ("types", types_info
,
3538 "All type names, or those matching REGEXP.");
3541 add_info ("methods", methods_info
,
3542 "All method names, or those matching REGEXP::REGEXP.\n\
3543 If the class qualifier is omitted, it is assumed to be the current scope.\n\
3544 If the first REGEXP is omitted, then all methods matching the second REGEXP\n\
3547 add_info ("sources", sources_info
,
3548 "Source files in the program.");
3550 add_com ("rbreak", class_breakpoint
, rbreak_command
,
3551 "Set a breakpoint for all functions matching REGEXP.");
3553 /* Initialize the one built-in type that isn't language dependent... */
3554 builtin_type_error
= init_type (TYPE_CODE_ERROR
, 0, 0,
3555 "<unknown type>", (struct objfile
*) NULL
);