From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jimmy Guo To: gdb-patches@sourceware.cygnus.com Subject: (patch) hpjyg21: FAT_FREE_PSYMTABS Date: Thu, 11 Nov 1999 12:53:00 -0000 Message-id: X-SW-Source: 1999-q4/msg00234.html *** Patch dependecies: hpjyg05 (config/pa/tm-hppa.h) hpjyg16 (symtab.c) hpjyg20 (symtab.c) *** This patch contains: - addition of codes ifdef'd by FAT_FREE_PSYMTABS to rely on linker symbol table entries to determine which translation unit's partial symbol table must be expanded. Here is a more complete overview of this feature: We use the partial symbol tables to identify which TU's partial symbol table must be expanded to get further information about a symbol. This decision can also be made by consulting the minimal symbol table, determining the address of the symbol therefrom and finding out which partial symbol table's address range (texthigh & textlow) envelops the symbol's address. If we are successful in using the minimal symbol table to zoom in on which psymtab to expand, then we could eliminate the "kernels" of these N partial symbol tables and build just the shell. ChangeLog: 1999-11-11 Jimmy Guo * symtab.c: FAT_FREE_PSYMTABS support. (find_pc_sect_psymtab): If find_pc_sect_psymbol failed to find a psymtab, check textlow and texthigh and return tpst if it houses pc + 4. (find_main_psymtab): Fall back to linker symbol table to find the psymtab housing psymbol. (find_functions): Iterate over linker symbol table to expand the psymtab containing psymbol. (expand_containing_psymtab): New function. * minsyms.c (foreach_text_minsym): New function. * config/pa/tm-hppa.h (FAT_FREE_PSYMTABS): Define. Index: gdb/symtab.c /opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/symtab.c gdb/symtab.c *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/symtab.c Thu Nov 11 12:45:24 1999 --- gdb/symtab.c Thu Nov 11 12:34:12 1999 *************** *** 449,454 **** --- 449,477 ---- p = find_pc_sect_psymbol (tpst, pc, section); + #ifdef FAT_FREE_PSYMTABS + + /* srikanth, in the case of the Wildebeest, the psymtabs could be empty + and hence the call to find_pc_sect_psymbol() could fail to find anything. + Due potentially to a combination of bugs in compilers, linkers, loaders, + editors and debugger engineers :-), sometimes there is an overlap of + textlow and texthigh values between and multiple psymtabs. As a result, + if we are handed an address equal to the texthigh or textlow, we could + end up identifying the wrong psymtab. + + To be absolutely sure of the identity of the psymtab, let us verify that + the one we narrow down on, also houses pc + 4. + */ + + if (p == NULL) + { + CORE_ADDR pc_plus4 = pc + 4; + if (pc_plus4 >= tpst->textlow && + pc_plus4 <= tpst->texthigh) + return tpst; + } + #endif + if (p != NULL && SYMBOL_VALUE_ADDRESS (p) == SYMBOL_VALUE_ADDRESS (msymbol)) *************** *** 1367,1372 **** --- 1390,1408 ---- } } + #ifdef FAT_FREE_PSYMTABS + + /* srikanth, under the new world order, psymtabs could be empty + for the Wildebeest. Fall back on the linker symbol table, use the + address therefrom to find out which psymtab would have housed the + psymbol were one to exist. + */ + + if ((m = lookup_minimal_symbol_text (default_main, NULL, NULL))) + return find_pc_psymtab (SYMBOL_VALUE_ADDRESS (m)); + + #endif + return (NULL); } *************** *** 2725,2730 **** --- 2761,2785 ---- return (i1); } + #ifdef FAT_FREE_PSYMTABS + + static void + expand_containing_psymtab (m) + struct minimal_symbol *m; + { + struct objfile *objfile; + struct partial_symtab *pst = NULL; + CORE_ADDR pc; + + if (m) + pst = find_pc_psymtab (SYMBOL_VALUE_ADDRESS (m)); + + if (pst && !pst->readin) + PSYMTAB_TO_SYMTAB (pst); + } + + #endif + /* Helper function for decode_line_1. Look for functions named NAME in all the symbol tables. Return number of matches. *************** *** 2812,2817 **** --- 2867,2887 ---- /* If we found match(es) in the current source file we are done */ if (i1) goto lookup_over; + + #ifdef FAT_FREE_PSYMTABS + + /* srikanth, in the case of the Wildebeest, the psymtabs are no + longer populated with psymbols. We need to rely on the linker + symbol table to lookup the symbol, use its address to decide + which psymtab would have housed the psymbol, were one to exist. + The function `foreach_text_minsym' is an iterator, which would + call its second argument for each matched minimal symbol + (mst_text and mst_file_text) and pass the match. + */ + + foreach_text_minsym (name, expand_containing_psymtab); + + #endif /* Now search all the global symbols. Do the symtab's first, then check the psymtab's. If a psymtab indicates the existence Index: gdb/minsyms.c /opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/minsyms.c gdb/minsyms.c *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/minsyms.c Wed Nov 10 12:30:56 1999 --- gdb/minsyms.c Thu Nov 11 09:25:44 1999 *************** *** 80,85 **** --- 80,108 ---- static int compact_minimal_symbols PARAMS ((struct minimal_symbol *, int)); + /* srikanth, an iterator for functions in the linker symbol table. + Looks up `name' and for each matching symbol, calls `action' and + passes the selected symbol. */ + + void + foreach_text_minsym (name, action) + char *name; + void (*action) (struct minimal_symbol *); + { + + struct objfile *objfile; + struct minimal_symbol m, *msymbol = &m; + char *mangled_prefix; + + ALL_MSYMBOLS (objfile, msymbol) + { + if (MSYMBOL_TYPE (msymbol) == mst_text || + MSYMBOL_TYPE (msymbol) == mst_file_text) + if (SYMBOL_MATCHES_NAME (msymbol, name)) + action (msymbol); + } + } + /* Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME. If OBJF is non-NULL, limit the search to that objfile. If SFILE is non-NULL, limit the search Index: gdb/config/pa/tm-hppa.h /opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/config/pa/tm-hppa.h gdb/config/pa/tm-hppa.h *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/config/pa/tm-hppa.h Tue Nov 2 16:04:12 1999 --- gdb/config/pa/tm-hppa.h Wed Nov 10 12:06:11 1999 *************** *** 146,152 **** top byte of the address for all 1's. Sigh. */ #define PC_REQUIRES_RUN_BEFORE_USE(pc) \ ! (! target_has_stack && (pc & 0xFF000000)) /* return instruction is bv r0(rp) or bv,n r0(rp) */ --- 146,152 ---- top byte of the address for all 1's. Sigh. */ #define PC_REQUIRES_RUN_BEFORE_USE(pc) \ ! (! target_has_stack && ((pc & 0xFF000000) == 0xFF000000)) /* return instruction is bv r0(rp) or bv,n r0(rp) */ *************** *** 331,337 **** else \ memcpy ((VALBUF), \ (char *)(REGBUF) + REGISTER_BYTE (28) + \ ! (TYPE_LENGTH (TYPE) > 4 ? (8 - TYPE_LENGTH (TYPE)) : (4 - TYPE_LENGTH (TYPE))), \ TYPE_LENGTH (TYPE)); \ } --- 331,337 ---- else \ memcpy ((VALBUF), \ (char *)(REGBUF) + REGISTER_BYTE (28) + \ ! (TYPE_LENGTH (TYPE) > 4 ? (8 - TYPE_LENGTH (TYPE)) : (REGISTER_SIZE - TYPE_LENGTH (TYPE))), \ TYPE_LENGTH (TYPE)); \ } *************** *** 810,815 **** --- 810,817 ---- || (strncmp ((symname), "$PIC", 4) == 0) \ || ((symname)[0] == '$' && isdigit ((symname)[1])) \ )) + + #define FAT_FREE_PSYMTABS /* Here's how to step off a permanent breakpoint. */ #define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint)