From ca6a826d84d020d08a619a055c5769d4d55e0ea9 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Thu, 8 Apr 1993 17:37:24 +0000 Subject: * symtab.h (DESTRUCTOR_PREFIX_P): New macro to check if physname is a C++ destructor. * symtab.c (gdb_mangle_name): Use it. * symtab.c (find_methods): Do not add destructors to choice list for constructors. * symtab.c (decode_line_1): Make breakpoints on destructors work for gcc-2.x again. --- gdb/ChangeLog | 10 ++++++++++ gdb/symtab.c | 45 ++++++++++++++++++++++++++++++++++++++++----- gdb/symtab.h | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7eee3be..3c6008c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Thu Apr 8 10:34:37 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * symtab.h (DESTRUCTOR_PREFIX_P): New macro to check if physname + is a C++ destructor. + * symtab.c (gdb_mangle_name): Use it. + * symtab.c (find_methods): Do not add destructors to choice list + for constructors. + * symtab.c (decode_line_1): Make breakpoints on destructors work + for gcc-2.x again. + Wed Apr 7 18:43:09 1993 Stu Grossman (grossman@cygnus.com) * ser-go32.c: Make it use serial port name. diff --git a/gdb/symtab.c b/gdb/symtab.c index c7a2178..7f74661 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -255,8 +255,7 @@ gdb_mangle_name (type, i, j) char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); char *newname = type_name_no_tag (type); int is_constructor = STREQ (field_name, newname); - int is_destructor = is_constructor && physname[0] == '_' - && physname[1] == CPLUS_MARKER && physname[2] == '_'; + int is_destructor = is_constructor && DESTRUCTOR_PREFIX_P (physname); /* Need a new type prefix. */ char *const_prefix = method->is_const ? "C" : ""; char *volatile_prefix = method->is_volatile ? "V" : ""; @@ -920,8 +919,11 @@ find_pc_symtab (pc) register struct block *b; struct blockvector *bv; register struct symtab *s = NULL; + register struct symtab *best_s = NULL; register struct partial_symtab *ps; register struct objfile *objfile; + int distance = 0;; + /* Search all symtabs for one whose file contains our pc */ @@ -930,10 +932,18 @@ find_pc_symtab (pc) bv = BLOCKVECTOR (s); b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); if (BLOCK_START (b) <= pc - && BLOCK_END (b) > pc) - return (s); + && BLOCK_END (b) > pc + && (distance == 0 + || BLOCK_END (b) - BLOCK_START (b) < distance)) + { + distance = BLOCK_END (b) - BLOCK_START (b); + best_s = s; + } } + if (best_s != NULL) + return(best_s); + s = NULL; ps = find_pc_psymtab (pc); if (ps) @@ -1380,6 +1390,9 @@ find_methods (t, name, sym_arr) if (TYPE_FN_FIELD_STUB (f, field_counter)) check_stub_method (t, method_counter, field_counter); phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter); + /* Destructor is handled by caller, dont add it to the list */ + if (DESTRUCTOR_PREFIX_P (phys_name)) + continue; sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, @@ -1599,7 +1612,15 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) /* destructors are a special case. */ struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0); int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1; + /* gcc 1.x puts destructor in last field, + gcc 2.x puts destructor in first field. */ char *phys_name = TYPE_FN_FIELD_PHYSNAME (f, len); + if (!DESTRUCTOR_PREFIX_P (phys_name)) + { + phys_name = TYPE_FN_FIELD_PHYSNAME (f, 0); + if (!DESTRUCTOR_PREFIX_P (phys_name)) + phys_name = ""; + } sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, 0, (struct symtab **)NULL); @@ -2258,7 +2279,21 @@ list_symbols (regexp, class, bpt) { /* Set a breakpoint here, if it's a function */ if (class == 1) - break_command (SYMBOL_NAME(sym), 0); + { + /* There may be more than one function with the + same name but in different files. In order to + set breakpoints on all of them, we must give + both the file name and the function name to + break_command. */ + char *string = + (char *) alloca (strlen (s->filename) + + strlen (SYMBOL_NAME(sym)) + + 2); + strcpy (string, s->filename); + strcat (string, ":"); + strcat (string, SYMBOL_NAME(sym)); + break_command (string, 0); + } } else if (!found_in_file) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 304e8c7..a00b3b1 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -100,6 +100,13 @@ struct general_symbol_info /* end-sanitize-chill */ } lang_u; } lang_specific; + + /* Which section is this symbol in? This is an index into + section_offsets for this objfile. Negative means that the symbol + does not get relocated relative to a section. */ + /* Disclaimer: currently this is just used for xcoff, so don't expect + all symbol-reading code to set it correctly. */ + int section; }; #define SYMBOL_NAME(symbol) (symbol)->ginfo.name @@ -109,6 +116,7 @@ struct general_symbol_info #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->ginfo.value.block #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain #define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.lang_specific.language +#define SYMBOL_SECTION(symbol) (symbol)->ginfo.section #define SYMBOL_CPLUS_DEMANGLED_NAME(symbol) \ (symbol)->ginfo.lang_specific.lang_u.cplus_specific.demangled_name @@ -507,7 +515,7 @@ enum address_class LOC_BLOCK, - /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_ADDRESS, in + /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in target byte order. */ LOC_CONST_BYTES, @@ -518,8 +526,12 @@ enum address_class (FRAME_ARGS_ADDRESS). Added for i960, which passes args in regs then copies to frame. */ - LOC_LOCAL_ARG + LOC_LOCAL_ARG, + + /* The variable does not actually exist in the program. + The SYMBOL_VALUE is ignored. */ + LOC_OPTIMIZED_OUT }; struct symbol @@ -679,6 +691,17 @@ struct symtab struct linetable *linetable; + /* Section in objfile->section_offsets for the blockvector and + the linetable. */ + + int block_line_section; + + /* If several symtabs share a blockvector, exactly one of them + should be designed the primary, so that the blockvector + is relocated exactly once by objfile_relocate. */ + + int primary; + /* Name of this source file. */ char *filename; @@ -854,9 +877,18 @@ struct partial_symtab #define OPNAME_PREFIX_P(NAME) \ ((NAME)[0] == 'o' && (NAME)[1] == 'p' && (NAME)[2] == CPLUS_MARKER) +/* Macro that yields non-zero value iff NAME is the prefix for C++ vtbl + names. */ + #define VTBL_PREFIX_P(NAME) \ ((NAME)[3] == CPLUS_MARKER && !strncmp ((NAME), "_vt", 3)) +/* Macro that yields non-zero value iff NAME is the prefix for C++ destructor + names. */ + +#define DESTRUCTOR_PREFIX_P(NAME) \ + ((NAME)[0] == '_' && (NAME)[1] == CPLUS_MARKER && (NAME)[2] == '_') + /* External variables and functions for the objects described above. */ @@ -935,7 +967,7 @@ prim_record_minimal_symbol PARAMS ((const char *, CORE_ADDR, extern void prim_record_minimal_symbol_and_info PARAMS ((const char *, CORE_ADDR, enum minimal_symbol_type, - char *info)); + char *info, int section)); extern struct minimal_symbol * lookup_minimal_symbol PARAMS ((const char *, struct objfile *)); -- cgit v1.1