mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
miscellaneous dwarf.c tidies
* dwarf.c: Leading and trailing whitespace fixes. (free_abbrev_list): New function. (free_all_abbrevs): Use the above. Free cu_abbrev_map here too. (process_abbrev_set): Print actual section name on error. (get_type_abbrev_from_form): Add overflow check. (free_debug_memory): Don't free cu_abbrev_map here.. (process_debug_info): ..or here. Warn on another case of not finding a neeeded abbrev.
This commit is contained in:
@ -901,38 +901,41 @@ record_abbrev_list_for_cu (dwarf_vma start, dwarf_vma end, abbrev_list * list)
|
|||||||
next_free_abbrev_map_entry ++;
|
next_free_abbrev_map_entry ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static abbrev_list *
|
||||||
free_all_abbrevs (void)
|
free_abbrev_list (abbrev_list *list)
|
||||||
{
|
{
|
||||||
abbrev_list * list;
|
abbrev_entry *abbrv = list->first_abbrev;
|
||||||
|
|
||||||
for (list = abbrev_lists; list != NULL;)
|
while (abbrv)
|
||||||
{
|
{
|
||||||
abbrev_list * next = list->next;
|
abbrev_attr *attr = abbrv->first_attr;
|
||||||
abbrev_entry * abbrv;
|
|
||||||
|
|
||||||
for (abbrv = list->first_abbrev; abbrv != NULL;)
|
while (attr)
|
||||||
{
|
|
||||||
abbrev_entry * next_abbrev = abbrv->next;
|
|
||||||
abbrev_attr * attr;
|
|
||||||
|
|
||||||
for (attr = abbrv->first_attr; attr;)
|
|
||||||
{
|
{
|
||||||
abbrev_attr *next_attr = attr->next;
|
abbrev_attr *next_attr = attr->next;
|
||||||
|
|
||||||
free (attr);
|
free (attr);
|
||||||
attr = next_attr;
|
attr = next_attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abbrev_entry *next_abbrev = abbrv->next;
|
||||||
free (abbrv);
|
free (abbrv);
|
||||||
abbrv = next_abbrev;
|
abbrv = next_abbrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abbrev_list *next = list->next;
|
||||||
free (list);
|
free (list);
|
||||||
list = next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
abbrev_lists = NULL;
|
static void
|
||||||
|
free_all_abbrevs (void)
|
||||||
|
{
|
||||||
|
while (abbrev_lists)
|
||||||
|
abbrev_lists = free_abbrev_list (abbrev_lists);
|
||||||
|
|
||||||
|
free (cu_abbrev_map);
|
||||||
|
cu_abbrev_map = NULL;
|
||||||
|
next_free_abbrev_map_entry = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static abbrev_list *
|
static abbrev_list *
|
||||||
@ -1119,7 +1122,7 @@ process_abbrev_set (struct dwarf_section *section,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Report the missing single zero which ends the section. */
|
/* Report the missing single zero which ends the section. */
|
||||||
error (_(".debug_abbrev section not zero terminated\n"));
|
error (_("%s section not zero terminated\n"), section->name);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2124,7 +2127,8 @@ get_type_abbrev_from_form (unsigned long form,
|
|||||||
case DW_FORM_ref4:
|
case DW_FORM_ref4:
|
||||||
case DW_FORM_ref8:
|
case DW_FORM_ref8:
|
||||||
case DW_FORM_ref_udata:
|
case DW_FORM_ref_udata:
|
||||||
if (uvalue + cu_offset > (size_t) (cu_end - section->start))
|
if (uvalue + cu_offset < uvalue
|
||||||
|
|| uvalue + cu_offset > (size_t) (cu_end - section->start))
|
||||||
{
|
{
|
||||||
warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\n"),
|
warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\n"),
|
||||||
uvalue, (long) cu_offset, (long) (cu_end - section->start));
|
uvalue, (long) cu_offset, (long) (cu_end - section->start));
|
||||||
@ -3653,11 +3657,8 @@ process_debug_info (struct dwarf_section * section,
|
|||||||
introduce (section, false);
|
introduce (section, false);
|
||||||
|
|
||||||
free_all_abbrevs ();
|
free_all_abbrevs ();
|
||||||
free (cu_abbrev_map);
|
|
||||||
cu_abbrev_map = NULL;
|
|
||||||
next_free_abbrev_map_entry = 0;
|
|
||||||
|
|
||||||
/* In order to be able to resolve DW_FORM_ref_attr forms we need
|
/* In order to be able to resolve DW_FORM_ref_addr forms we need
|
||||||
to load *all* of the abbrevs for all CUs in this .debug_info
|
to load *all* of the abbrevs for all CUs in this .debug_info
|
||||||
section. This does effectively mean that we (partially) read
|
section. This does effectively mean that we (partially) read
|
||||||
every CU header twice. */
|
every CU header twice. */
|
||||||
@ -4028,9 +4029,8 @@ process_debug_info (struct dwarf_section * section,
|
|||||||
|
|
||||||
/* Scan through the abbreviation list until we reach the
|
/* Scan through the abbreviation list until we reach the
|
||||||
correct entry. */
|
correct entry. */
|
||||||
if (list == NULL)
|
entry = NULL;
|
||||||
continue;
|
if (list != NULL)
|
||||||
|
|
||||||
for (entry = list->first_abbrev; entry != NULL; entry = entry->next)
|
for (entry = list->first_abbrev; entry != NULL; entry = entry->next)
|
||||||
if (entry->number == abbrev_number)
|
if (entry->number == abbrev_number)
|
||||||
break;
|
break;
|
||||||
@ -12079,10 +12079,6 @@ free_debug_memory (void)
|
|||||||
|
|
||||||
free_all_abbrevs ();
|
free_all_abbrevs ();
|
||||||
|
|
||||||
free (cu_abbrev_map);
|
|
||||||
cu_abbrev_map = NULL;
|
|
||||||
next_free_abbrev_map_entry = 0;
|
|
||||||
|
|
||||||
free (shndx_pool);
|
free (shndx_pool);
|
||||||
shndx_pool = NULL;
|
shndx_pool = NULL;
|
||||||
shndx_pool_size = 0;
|
shndx_pool_size = 0;
|
||||||
|
Reference in New Issue
Block a user