/* For interface with stabsread.c. */
#include "aout/stab_gnu.h"
-/* Define this if you want gdb to ignore typdef stabs. This was needed for
- one of Transarc, to reduce the size of the symbol table. Types won't be
- recognized, but tag names will be. */
-
-/* #define NO_TYPEDEFS 1 */
-
/* Simplified internal version of coff symbol table information */
struct coff_symbol {
static int
init_lineno PARAMS ((bfd *, file_ptr, int));
+static void
+free_linetab PARAMS ((void));
+
static void
find_linenos PARAMS ((bfd *, sec_ptr, PTR));
/* Give a line table with function entries are marked, arrange its functions
in assending order and strip off function entry markers and return it in
a newly created table. If the old one is good enough, return the old one. */
+/* FIXME: I think all this stuff can be replaced by just passing
+ sort_linevec = 1 to end_symtab. */
static struct linetable *
arrange_linetable (oldLineTb)
if (inclLength == 0) {
inclTable = (InclTable*)
xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
- bzero (inclTable, sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
+ memset (inclTable, '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
inclIndx = 0;
}
inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
inclTable = (InclTable*)
xrealloc (inclTable, sizeof (InclTable) * inclLength);
- bzero (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH,
- sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
+ memset (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH,
+ '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
}
inclTable [inclIndx].name = cs->c_name;
if (!(offset = first_fun_line_offset))
goto return_after_cleanup;
- bzero (&main_subfile, sizeof (main_subfile));
+ memset (&main_subfile, '\0', sizeof (main_subfile));
first_fun_line_offset = 0;
if (inclIndx == 0)
tmpSubfile = inclTable[ii].subfile = (struct subfile*)
xmalloc (sizeof (struct subfile));
- bzero (tmpSubfile, sizeof (struct subfile));
+ memset (tmpSubfile, '\0', sizeof (struct subfile));
firstLine = &(inclTable[ii].funStartLine);
/* enter include file's lines now. */
inclIndx = 0;
/* start with a fresh subfile structure for the next file. */
- bzero (&main_subfile, sizeof (struct subfile));
+ memset (&main_subfile, '\0', sizeof (struct subfile));
}
void
int functionstart = cs->c_value - textsec->vma;
- bzero (&tbInfo, sizeof (tbInfo));
+ memset (&tbInfo, '\0', sizeof (tbInfo));
/* keep reading blocks of data from the text section, until finding a zero
word and a traceback table. */
abfd, textsec, buffer,
(file_ptr)(functionstart +
bytesread - (buffer + bufferbytes - (char*)pinsn)),MIN_TBTABSIZ))
- { printf ("Abnormal return!..\n"); return NULL; }
+ { printf_unfiltered ("Abnormal return!..\n"); return NULL; }
ptb = (struct tbtable *)buffer;
}
abfd, textsec, buffer,
(file_ptr)(functionstart +
bytesread - (buffer + bufferbytes - pinsn)),MIN_TBTABSIZ))
- /* abort (); */ { printf ("abort!!!\n"); return NULL; }
+ /* abort (); */ { printf_unfiltered ("abort!!!\n"); return NULL; }
return (struct tbtable *)buffer;
}
/* Reading symbol table has to be fast! Keep the followings as macros, rather
than functions. */
-#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED, SECTION) \
+#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED, SECTION, OBJFILE) \
{ \
char *namestr; \
if (ALLOCED) \
(ALLOCED) = 1; \
} \
prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
- (char *)NULL, (SECTION)); \
+ (char *)NULL, (SECTION), (OBJFILE)); \
misc_func_recorded = 1; \
}
textsec = bfd_get_section_by_name (abfd, ".text");
if (!textsec) {
- printf ("Unable to locate text section!\n");
+ printf_unfiltered ("Unable to locate text section!\n");
}
while (symnum < nsyms) {
case XMC_PR : /* a `.text' csect. */
{
- /* A program csect is seen.
-
- We have to allocate one symbol table for each program csect. Normally
- gdb prefers one symtab for each compilation unit (CU). In case of AIX, one
- CU might include more than one prog csect, and they don't have to be
- adjacent in terms of the space they occupy in memory. Thus, one single
- CU might get fragmented in the memory and gdb's file start and end address
- approach does not work! */
+ /* A program csect is seen. We have to allocate one
+ symbol table for each program csect. Normally gdb
+ prefers one symtab for each source file. In case
+ of AIX, one source file might include more than one
+ [PR] csect, and they don't have to be adjacent in
+ terms of the space they occupy in memory. Thus, one
+ single source file might get fragmented in the
+ memory and gdb's file start and end address
+ approach does not work! GCC (and I think xlc) seem
+ to put all the code in the unnamed program csect. */
if (last_csect_name) {
if (!misc_func_recorded) {
int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val,
- mst_text, alloced, last_csect_sec);
+ mst_text, alloced, last_csect_sec,
+ objfile);
}
textsec->target_index);
end_stabs ();
start_stabs ();
- start_symtab ((char *)NULL, (char *)NULL, (CORE_ADDR)0);
+ /* Give all csects for this source file the same
+ name. */
+ start_symtab (filestring, (char *)NULL, (CORE_ADDR)0);
}
/* If this is the very first csect seen, basically `__start'. */
function_entry_point:
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text,
- symname_alloced, cs->c_secnum);
+ symname_alloced, cs->c_secnum, objfile);
fcn_line_offset = main_aux->x_sym.x_fcnary.x_fcn.x_lnnoptr;
fcn_start_addr = cs->c_value;
prim_record_minimal_symbol_and_info
("<trampoline>", cs->c_value, mst_unknown,
- (char *)NULL, cs->c_secnum);
+ (char *)NULL, cs->c_secnum, objfile);
#else
/* record trampoline code entries as mst_unknown symbol. When we
lookup mst symbols, we will choose mst_text over mst_unknown. */
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_unknown,
- symname_alloced);
+ symname_alloced, objfile);
#endif
continue;
}
int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val,
- mst_text, alloced, last_csect_sec);
+ mst_text, alloced, last_csect_sec, objfile);
}
/* c_value field contains symnum of next .file entry in table
case C_STRTAG :
case C_UNTAG :
case C_ENTAG :
- printf ("ERROR: Unimplemented storage class: %d.\n", cs->c_sclass);
+ printf_unfiltered ("ERROR: Unimplemented storage class: %d.\n", cs->c_sclass);
break;
case C_HIDEXT : /* ignore these.. */
if (name[0] == '.')
++name;
- bzero (sym, sizeof (struct symbol));
+ memset (sym, '\0', sizeof (struct symbol));
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
break;
#endif
- case C_DECL: /* a type decleration?? */
-
- sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
- if (sym != NULL)
- SYMBOL_SECTION (sym) = cs->c_secnum;
- return sym;
-
case C_GSYM:
add_stab_to_list (name, &global_stabs);
break;
+ case C_BCOMM:
+ common_block_start (cs->c_name, objfile);
+ break;
+
+ case C_ECOMM:
+ common_block_end (objfile);
+ break;
+
+ default:
+ complain (&storclass_complaint, cs->c_sclass);
+ /* FALLTHROUGH */
+
+ case C_DECL:
case C_PSYM:
case C_RPSYM:
+ case C_ECOML:
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL)
case C_STSYM:
- /* If we are going to use Sun dbx's define_symbol(), we need to
- massage our stab string a little. Change 'V' type to 'S' to be
- comparible with Sun. */
- /* FIXME: I believe this is to avoid a Sun-specific hack somewhere.
- Needs more investigation. */
+ /* For xlc (not GCC), the 'V' symbol descriptor is used for all
+ statics and we need to distinguish file-scope versus function-scope
+ using within_function. We do this by changing the string we pass
+ to define_symbol to use 'S' where we need to, which is not necessarily
+ super-clean, but seems workable enough. */
- if (*name == ':' || (pp = (char *) index (name, ':')) == NULL)
- return NULL;
+ if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL)
+ return NULL;
- ++pp;
- if (*pp == 'V') *pp = 'S';
- sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
- if (sym != NULL)
- {
- SYMBOL_VALUE (sym) += static_block_base;
- SYMBOL_SECTION (sym) = static_block_section;
- }
- return sym;
+ ++pp;
+ if (*pp == 'V' && !within_function)
+ *pp = 'S';
+ sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
+ if (sym != NULL)
+ {
+ SYMBOL_VALUE (sym) += static_block_base;
+ SYMBOL_SECTION (sym) = static_block_section;
+ }
+ return sym;
case C_LSYM:
sym = define_symbol (cs->c_value, cs->c_name, 0, N_LSYM, objfile);
break;
case C_REG:
- printf ("ERROR! C_REG is not fully implemented!\n");
+ printf_unfiltered ("ERROR! C_REG is not fully implemented!\n");
SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum;
complain (&rsym_complaint, name);
return NULL;
}
-
- default :
- complain (&storclass_complaint, cs->c_sclass);
- return NULL;
}
}
return sym2;
{
int val;
+ free_linetab ();
+
if (bfd_seek(abfd, offset, L_SET) < 0)
return -1;
linetab_offset = offset;
linetab_size = size;
- make_cleanup (free, linetab); /* Be sure it gets de-allocated. */
return 0;
}
+
+static void
+free_linetab ()
+{
+ if (linetab)
+ free (linetab);
+ linetab = NULL;
+}
\f
/* dbx allows the text of a symbol name to be continued into the
next symbol name! When such a continuation is encountered
#undef next_symbol_text
#define next_symbol_text() \
- printf ("Gdb Error: symbol names on multiple lines not implemented.\n")
+ printf_unfiltered ("Gdb Error: symbol names on multiple lines not implemented.\n")
static void
if (strtbl == NULL)
return -1;
- bcopy(&length, strtbl, sizeof length);
+ memcpy(strtbl, &length, sizeof length);
if (length == sizeof length)
return 0;
return -1;
if (!bfd_get_section_contents(abfd, secp, debugsec, (file_ptr) 0, length)) {
- printf ("Can't read .debug section from symbol file\n");
+ printf_unfiltered ("Can't read .debug section from symbol file\n");
return -1;
}
return 0;
bfd *abfd;
struct coff_symfile_info *info;
char *name;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
info = (struct coff_symfile_info *) objfile -> sym_private;
symfile_bfd = abfd = objfile->obfd;
&& info->max_lineno_offset > info->min_lineno_offset) {
/* only read in the line # table if one exists */
+ make_cleanup (free_linetab, 0);
val = init_lineno(abfd, info->min_lineno_offset,
(int) (info->max_lineno_offset - info->min_lineno_offset));
free_debugsection ();
/* Sort symbols alphabetically within each block. */
- sort_all_symtab_syms ();
+ {
+ struct symtab *s;
+ for (s = objfile -> symtabs; s != NULL; s = s -> next)
+ {
+ sort_symtab_syms (s);
+ }
+ }
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
install_minimal_symbols (objfile);
+
+ do_cleanups (back_to);
}
/* XCOFF-specific parsing routine for section offsets. */
return section_offsets;
}
-/* Register our ability to parse symbols for xcoff BFD files. */
+
+/* Register our ability to parse symbols for xcoff BFD files. */
static struct sym_fns xcoff_sym_fns =
{
- "aixcoff-rs6000", /* sym_name: name or name prefix of BFD target type */
- 15, /* sym_namelen: number of significant sym_name chars */
+
+ /* Because the bfd uses coff_flavour, we need to specially kludge
+ the flavour. FIXME: coff and xcoff and fundamentally similar
+ except for debug format, and we should see if we can merge this
+ file with coffread.c. For example, the extra storage classes
+ used for stabs could presumably be recognized in any COFF file. */
+
+ (enum bfd_flavour)-1,
+
xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
xcoff_symfile_read, /* sym_read: read a symbol file into symtab */