From: Jim Kingdon Date: Thu, 29 Sep 1994 15:09:51 +0000 (+0000) Subject: * coffread.c (complete_symtab): If last_source_file is set upon X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab93997d683a4631687a1e50f28bc10a49cabd2e;p=binutils-gdb.git * coffread.c (complete_symtab): If last_source_file is set upon entry, free it. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d81e98dc083..94eaa7352b9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 28 17:48:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * coffread.c (complete_symtab): If last_source_file is set upon + entry, free it. + Wed Sep 28 08:59:14 1994 Jim Kingdon (kingdon@cygnus.com) * xcoffread.c (read_xcoff_symtab, case C_FILE): diff --git a/gdb/coffread.c b/gdb/coffread.c index 9350d45cec0..d04cbb7f0fb 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -366,10 +366,10 @@ static void coff_start_symtab () { start_symtab ( - /* We fill in the filename later. start_symtab - puts this pointer into last_source file and in - coff_end_symtab we assume we can free() it. - FIXME: leaks memory. */ + /* We fill in the filename later. start_symtab puts + this pointer into last_source_file and we put it in + subfiles->name, which end_symtab frees; that's why + it must be malloc'd. */ savestring ("", 0), /* We never know the directory name for COFF. */ NULL, @@ -400,6 +400,8 @@ complete_symtab (name, start_addr, size) CORE_ADDR start_addr; unsigned int size; { + if (last_source_file != NULL) + free (last_source_file); last_source_file = savestring (name, strlen (name)); current_source_start_addr = start_addr; current_source_end_addr = start_addr + size; @@ -461,8 +463,10 @@ record_minimal_symbol (name, address, type, objfile) /* We don't want TDESC entry points in the minimal symbol table */ if (name[0] == '@') return; - prim_record_minimal_symbol (savestring (name, strlen (name)), address, type, - objfile); + prim_record_minimal_symbol + (obsavestring (name, strlen (name), &objfile->symbol_obstack), + address, type, + objfile); } /* coff_symfile_init () @@ -1148,6 +1152,10 @@ coff_getfilename (aux_entry) buffer[FILNMLEN] = '\0'; } result = buffer; + + /* FIXME: We should not be throwing away the information about what + directory. It should go into dirname of the symtab, or some such + place. */ if ((temp = strrchr (result, '/')) != NULL) result = temp + 1; return (result); @@ -1850,7 +1858,10 @@ coff_read_struct_type (index, length, lastsym) list = new; /* Save the data. */ - list->field.name = savestring (name, strlen (name)); + list->field.name = + obsavestring (name, + strlen (name), + ¤t_objfile->symbol_obstack); list->field.type = decode_type (ms, ms->c_type, &sub_aux); list->field.bitpos = 8 * ms->c_value; list->field.bitsize = 0; @@ -1865,7 +1876,10 @@ coff_read_struct_type (index, length, lastsym) list = new; /* Save the data. */ - list->field.name = savestring (name, strlen (name)); + list->field.name = + obsavestring (name, + strlen (name), + ¤t_objfile->symbol_obstack); list->field.type = decode_type (ms, ms->c_type, &sub_aux); list->field.bitpos = ms->c_value; list->field.bitsize = sub_aux.x_sym.x_misc.x_lnsz.x_size; @@ -1933,10 +1947,14 @@ coff_read_enum_type (index, length, lastsym) switch (ms->c_sclass) { case C_MOE: - sym = (struct symbol *) xmalloc (sizeof (struct symbol)); + sym = (struct symbol *) obstack_alloc + (¤t_objfile->symbol_obstack, + sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = savestring (name, strlen (name)); + SYMBOL_NAME (sym) = + obsavestring (name, strlen (name), + ¤t_objfile->symbol_obstack); SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_VALUE (sym) = ms->c_value;