/* Read a symbol table in ECOFF format (Third-Eye).
- Copyright (C) 1986-2018 Free Software Foundation, Inc.
+ Copyright (C) 1986-2019 Free Software Foundation, Inc.
Original version contributed by Alessandro Forin (af@cs.cmu.edu) at
CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor
{
int regno = gdbarch_ecoff_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
- if (regno < 0
- || regno >= (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch)))
+ if (regno < 0 || regno >= gdbarch_num_cooked_regs (gdbarch))
{
- reg_value_complaint (regno,
- gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch),
+ reg_value_complaint (regno, gdbarch_num_cooked_regs (gdbarch),
SYMBOL_PRINT_NAME (sym));
regno = gdbarch_sp_regnum (gdbarch); /* Known safe, though useless. */
struct block *b;
struct mdebug_pending *pend;
struct type *t;
- struct field *f;
int count = 1;
TIR tir;
long svalue = sh->value;
const struct blockvector *bv
= SYMTAB_BLOCKVECTOR (top_stack->cur_st);
struct mdebug_extra_func_info *e;
- struct block *b = top_stack->cur_block;
+ struct block *cblock = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
int i;
{
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
- if (BLOCK_SUPERBLOCK (b_bad) == b
+ if (BLOCK_SUPERBLOCK (b_bad) == cblock
&& BLOCK_START (b_bad) == top_stack->procadr
&& BLOCK_END (b_bad) == top_stack->procadr)
{
- BLOCK_START (b_bad) = BLOCK_START (b);
- BLOCK_END (b_bad) = BLOCK_END (b);
+ BLOCK_START (b_bad) = BLOCK_START (cblock);
+ BLOCK_END (b_bad) = BLOCK_END (cblock);
}
}
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
iparams = 0;
- ALL_BLOCK_SYMBOLS (b, iter, sym)
+ ALL_BLOCK_SYMBOLS (cblock, iter, sym)
{
if (iparams == nparams)
break;
break;
case stMember: /* member of struct or union */
- f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
- FIELD_NAME (*f) = name;
- SET_FIELD_BITPOS (*f, sh->value);
- bitsize = 0;
- FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index,
- &bitsize, bigend, name);
- FIELD_BITSIZE (*f) = bitsize;
+ {
+ struct field *f
+ = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
+ FIELD_NAME (*f) = name;
+ SET_FIELD_BITPOS (*f, sh->value);
+ bitsize = 0;
+ FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index,
+ &bitsize, bigend, name);
+ FIELD_BITSIZE (*f) = bitsize;
+ }
break;
case stIndirect: /* forward declaration on Irix5 */
fdr_to_pst = fdr_to_pst_holder.data ();
fdr_to_pst++;
{
- struct partial_symtab *pst = new_psymtab ("", objfile);
+ struct partial_symtab *new_pst = new_psymtab ("", objfile);
- fdr_to_pst[-1].pst = pst;
- FDR_IDX (pst) = -1;
+ fdr_to_pst[-1].pst = new_pst;
+ FDR_IDX (new_pst) = -1;
}
/* Allocate the global pending list. */
textlow = 0;
pst = start_psymtab_common (objfile,
fdr_name (fh),
- textlow,
- objfile->global_psymbols,
- objfile->static_psymbols);
+ textlow);
pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
memset (pst->read_symtab_private, 0, sizeof (struct symloc));
/* Handle stabs continuation. */
{
char *stabstring = debug_info->ss + fh->issBase + sh.iss;
+ /* If we need to heap-allocate STABSTRING, this owns
+ it. */
+ gdb::unique_xmalloc_ptr<char> stabstring_storage;
int len = strlen (stabstring);
while (stabstring[len - 1] == '\\')
stabstring2 = debug_info->ss + fh->issBase + sh2.iss;
len2 = strlen (stabstring2);
- /* Concatinate stabstring2 with stabstring1. */
- if (stabstring
- && stabstring != debug_info->ss + fh->issBase + sh.iss)
- stabstring
- = (char *) xrealloc (stabstring, len + len2 + 1);
+ /* Concatenate stabstring2 with stabstring1. */
+ if (stabstring_storage != nullptr)
+ {
+ stabstring_storage.reset
+ ((char *) xrealloc (stabstring_storage.release (),
+ len + len2 + 1));
+ stabstring = stabstring_storage.get ();
+ }
else
{
- stabstring = (char *) xmalloc (len + len2 + 1);
+ stabstring_storage.reset
+ ((char *) xmalloc (len + len2 + 1));
+ stabstring = stabstring_storage.get ();
strcpy (stabstring, stabstring1);
}
strcpy (stabstring + len, stabstring2);
case N_SO:
{
static int prev_so_symnum = -10;
- const char *p;
+ const char *basename;
/* A zero value is probably an indication for the
SunPRO 3.0 compiler. dbx_end_psymtab explicitly tests
the second the file name. If pst exists, is
empty, and has a filename ending in '/', we assume
the previous N_SO was a directory name. */
- p = lbasename (namestring);
- if (p != namestring && *p == '\000')
+ basename = lbasename (namestring);
+ if (basename != namestring && *basename == '\000')
continue; /* Simply ignore directory
name SOs. */
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
sh.value,
psymtab_language, objfile);
continue;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
sh.value,
psymtab_language, objfile);
continue;
add_psymbol_to_list (namestring, p - namestring, 1,
STRUCT_DOMAIN, LOC_TYPEDEF,
-1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
if (p[2] == 't')
{
p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
-1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language,
objfile);
p += 1;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
-1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
}
check_enum:
add_psymbol_to_list (p, q - p, 1,
VAR_DOMAIN, LOC_CONST,
-1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language,
objfile);
/* Point past the name. */
/* Constant, e.g. from "const" in Pascal. */
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_CONST, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
continue;
case 'f':
if (! pst)
{
- int name_len = p - namestring;
- char *name = (char *) xmalloc (name_len + 1);
-
- memcpy (name, namestring, name_len);
- name[name_len] = '\0';
- function_outside_compilation_unit_complaint (name);
- xfree (name);
+ std::string copy (namestring, p);
+ function_outside_compilation_unit_complaint
+ (copy.c_str ());
}
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
sh.value,
psymtab_language, objfile);
continue;
case 'F':
if (! pst)
{
- int name_len = p - namestring;
- char *name = (char *) xmalloc (name_len + 1);
-
- memcpy (name, namestring, name_len);
- name[name_len] = '\0';
- function_outside_compilation_unit_complaint (name);
- xfree (name);
+ std::string copy (namestring, p);
+ function_outside_compilation_unit_complaint
+ (copy.c_str ());
}
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
sh.value,
psymtab_language, objfile);
continue;
hex_string (type_code)); /* CUR_SYMBOL_TYPE */
continue;
}
- if (stabstring
- && stabstring != debug_info->ss + fh->issBase + sh.iss)
- xfree (stabstring);
}
/* end - Handle continuation */
}
{
for (cur_sdx = 0; cur_sdx < fh->csym;)
{
- char *name;
+ char *sym_name;
enum address_class theclass;
CORE_ADDR minsym_value;
short section = -1;
continue;
}
- name = debug_info->ss + fh->issBase + sh.iss;
+ sym_name = debug_info->ss + fh->issBase + sh.iss;
minsym_value = sh.value;
int new_sdx;
case stStaticProc:
- reader.record_with_info (name, minsym_value,
+ reader.record_with_info (sym_name, minsym_value,
mst_file_text,
SECT_OFF_TEXT (objfile));
{
/* Should not happen, but does when cross-compiling
with the MIPS compiler. FIXME -- pull later. */
- index_complaint (name);
+ index_complaint (sym_name);
new_sdx = cur_sdx + 1; /* Don't skip at all. */
}
else
{
/* This should not happen either... FIXME. */
complaint (_("bad proc end in aux found from symbol %s"),
- name);
+ sym_name);
new_sdx = cur_sdx + 1; /* Don't skip backward. */
}
symbol table, and the MAIN__ symbol via the minimal
symbol table. */
if (sh.st == stProc)
- add_psymbol_to_list (name, strlen (name), 1,
+ add_psymbol_to_list (sym_name, strlen (sym_name), 1,
VAR_DOMAIN, LOC_BLOCK,
section,
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
sh.value, psymtab_language, objfile);
else
- add_psymbol_to_list (name, strlen (name), 1,
+ add_psymbol_to_list (sym_name, strlen (sym_name), 1,
VAR_DOMAIN, LOC_BLOCK,
section,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
sh.value, psymtab_language, objfile);
procaddr = sh.value;
case stStatic: /* Variable */
if (SC_IS_DATA (sh.sc))
- reader.record_with_info (name, minsym_value,
+ reader.record_with_info (sym_name, minsym_value,
mst_file_data,
SECT_OFF_DATA (objfile));
else
- reader.record_with_info (name, minsym_value,
+ reader.record_with_info (sym_name, minsym_value,
mst_file_bss,
SECT_OFF_BSS (objfile));
theclass = LOC_STATIC;
&& sh.iss != 0
&& sh.index != cur_sdx + 2)
{
- add_psymbol_to_list (name, strlen (name), 1,
+ add_psymbol_to_list (sym_name, strlen (sym_name), 1,
STRUCT_DOMAIN, LOC_TYPEDEF, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
}
handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
if (new_sdx <= cur_sdx)
{
/* This happens with the Ultrix kernel. */
- complaint (_("bad aux index at block symbol %s"), name);
+ complaint (_("bad aux index at block symbol %s"),
+ sym_name);
new_sdx = cur_sdx + 1; /* Don't skip backward. */
}
cur_sdx = new_sdx;
goto skip;
default:
- /* Both complaints are valid: one gives symbol name,
+ /* Both complaints are valid: one gives symbol sym_name,
the other the offending symbol type. */
complaint (_("unknown local symbol %s"),
- name);
+ sym_name);
complaint (_("with type %d"), sh.st);
cur_sdx++;
continue;
}
/* Use this gdb symbol. */
- add_psymbol_to_list (name, strlen (name), 1,
+ add_psymbol_to_list (sym_name, strlen (sym_name), 1,
VAR_DOMAIN, theclass, section,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
sh.value, psymtab_language, objfile);
skip:
cur_sdx++; /* Go to next file symbol. */
{
enum address_class theclass;
SYMR *psh;
- char *name;
CORE_ADDR svalue;
short section;
theclass = LOC_STATIC;
break;
}
- name = debug_info->ssext + psh->iss;
- add_psymbol_to_list (name, strlen (name), 1,
+ char *sym_name = debug_info->ssext + psh->iss;
+ add_psymbol_to_list (sym_name, strlen (sym_name), 1,
VAR_DOMAIN, theclass,
section,
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
svalue, psymtab_language, objfile);
}
}
&& save_pst->text_low_valid
&& !(objfile->flags & OBJF_REORDERED))
{
- ALL_OBJFILE_PSYMTABS (objfile, pst)
- {
- if (save_pst != pst
- && save_pst->raw_text_low () >= pst->raw_text_low ()
- && save_pst->raw_text_low () < pst->raw_text_high ()
- && save_pst->raw_text_high () > pst->raw_text_high ())
- {
- objfile->flags |= OBJF_REORDERED;
- break;
- }
- }
+ for (partial_symtab *iter : objfile_psymtabs (objfile))
+ {
+ if (save_pst != iter
+ && save_pst->raw_text_low () >= iter->raw_text_low ()
+ && save_pst->raw_text_low () < iter->raw_text_high ()
+ && save_pst->raw_text_high () > iter->raw_text_high ())
+ {
+ objfile->flags |= OBJF_REORDERED;
+ break;
+ }
+ }
}
}
/* Skip the first file indirect entry as it is a self dependency for
source files or a reverse .h -> .c dependency for header files. */
pst->number_of_dependencies = 0;
- pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
- partial_symtab *, (fh->crfd - 1));
+ pst->dependencies
+ = objfile->partial_symtabs->allocate_dependencies (fh->crfd - 1);
for (s_idx = 1; s_idx < fh->crfd; s_idx++)
{
RFDT rh;
/* Remove the dummy psymtab created for -O3 images above, if it is
still empty, to enable the detection of stripped executables. */
- if (objfile->psymtabs->next == NULL
- && objfile->psymtabs->number_of_dependencies == 0
- && objfile->psymtabs->n_global_syms == 0
- && objfile->psymtabs->n_static_syms == 0)
- objfile->psymtabs = NULL;
+ pst = objfile->partial_symtabs->psymtabs;
+ if (pst->next == NULL
+ && pst->number_of_dependencies == 0
+ && pst->n_global_syms == 0
+ && pst->n_static_syms == 0)
+ objfile->partial_symtabs->psymtabs = NULL;
}
/* If the current psymbol has an enumerated type, we need to add
in psymtabs, just in symtabs. */
add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, LOC_CONST, -1,
- &objfile->static_psymbols, 0,
+ psymbol_placement::STATIC, 0,
psymtab_language, objfile);
ext_sym += external_sym_size;
}