time. */
bfd *orig_bfd;
- /* Pointer to the bfd, section and address of the beginning of the
- section. The bfd might be different than expected because of
- gnu_debuglink sections. */
+ /* Pointer to the bfd. The bfd might be different than expected
+ because of gnu_debuglink sections. */
bfd *bfd_ptr;
- asection *sec;
- bfd_byte *sec_info_ptr;
/* Support for alternate debug info sections created by the DWZ utility:
This includes a pointer to an alternate bfd which contains *extra*,
bfd_byte * alt_dwarf_info_buffer;
bfd_size_type alt_dwarf_info_size;
- /* A pointer to the memory block allocated for info_ptr. Neither
- info_ptr nor sec_info_ptr are guaranteed to stay pointing to the
- beginning of the malloc block. */
+ /* A pointer to the memory block allocated for .debug_info sections. */
bfd_byte *info_ptr_memory;
/* Pointer to the symbol table. */
&stash->dwarf_str_buffer, &stash->dwarf_str_size))
return NULL;
- if (offset >= stash->dwarf_str_size)
- return NULL;
str = (char *) stash->dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
&stash->dwarf_line_str_size))
return NULL;
- if (offset >= stash->dwarf_line_str_size)
- return NULL;
str = (char *) stash->dwarf_line_str_buffer + offset;
if (*str == '\0')
return NULL;
&stash->alt_dwarf_str_size))
return NULL;
- if (offset >= stash->alt_dwarf_str_size)
- return NULL;
str = (char *) stash->alt_dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
char *debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
if (debug_filename == NULL)
- return FALSE;
+ return NULL;
debug_bfd = bfd_openr (debug_filename, NULL);
free (debug_filename);
&stash->alt_dwarf_info_size))
return NULL;
- if (offset >= stash->alt_dwarf_info_size)
- return NULL;
return stash->alt_dwarf_info_buffer + offset;
}
&stash->dwarf_abbrev_buffer, &stash->dwarf_abbrev_size))
return NULL;
- if (offset >= stash->dwarf_abbrev_size)
- return NULL;
-
amt = sizeof (struct abbrev_info*) * ABBREV_HASH_SIZE;
abbrevs = (struct abbrev_info **) bfd_zalloc (abfd, amt);
if (abbrevs == NULL)
amt = sizeof (struct abbrev_info);
cur_abbrev = (struct abbrev_info *) bfd_zalloc (abfd, amt);
if (cur_abbrev == NULL)
- return NULL;
+ goto fail;
/* Read in abbrev header. */
cur_abbrev->number = abbrev_number;
amt *= sizeof (struct attr_abbrev);
tmp = (struct attr_abbrev *) bfd_realloc (cur_abbrev->attrs, amt);
if (tmp == NULL)
- {
- size_t i;
-
- for (i = 0; i < ABBREV_HASH_SIZE; i++)
- {
- struct abbrev_info *abbrev = abbrevs[i];
-
- while (abbrev)
- {
- free (abbrev->attrs);
- abbrev = abbrev->next;
- }
- }
- return NULL;
- }
+ goto fail;
cur_abbrev->attrs = tmp;
}
already read (which means we are about to read the abbreviations
for the next compile unit) or if the end of the abbreviation
table is reached. */
- if ((unsigned int) (abbrev_ptr - stash->dwarf_abbrev_buffer)
+ if ((size_t) (abbrev_ptr - stash->dwarf_abbrev_buffer)
>= stash->dwarf_abbrev_size)
break;
abbrev_number = _bfd_safe_read_leb128 (abfd, abbrev_ptr,
if (lookup_abbrev (abbrev_number, abbrevs) != NULL)
break;
}
-
return abbrevs;
+
+ fail:
+ if (abbrevs != NULL)
+ {
+ size_t i;
+
+ for (i = 0; i < ABBREV_HASH_SIZE; i++)
+ {
+ struct abbrev_info *abbrev = abbrevs[i];
+
+ while (abbrev)
+ {
+ free (abbrev->attrs);
+ abbrev = abbrev->next;
+ }
+ }
+ free (abbrevs);
+ }
+ return NULL;
}
/* Returns true if the form is one which has a string value. */
{
*sec = d;
*syms = stash->syms;
+ break;
}
}
}
stash->info_ptr = stash->info_ptr_memory;
stash->info_ptr_end = stash->info_ptr + total_size;
- stash->sec = find_debug_info (debug_bfd, debug_sections, NULL);
- stash->sec_info_ptr = stash->info_ptr;
return TRUE;
}
stash->all_comp_units = each;
stash->info_ptr += length;
-
- if ((bfd_size_type) (stash->info_ptr - stash->sec_info_ptr)
- == stash->sec->size)
- {
- stash->sec = find_debug_info (stash->bfd_ptr,
- stash->debug_sections,
- stash->sec);
- stash->sec_info_ptr = stash->info_ptr;
- }
return each;
}
}
/* Find the source code location of SYMBOL. If SYMBOL is NULL
then find the nearest source code location corresponding to
the address SECTION + OFFSET.
- Returns TRUE if the line is found without error and fills in
+ Returns 1 if the line is found without error and fills in
FILENAME_PTR and LINENUMBER_PTR. In the case where SYMBOL was
NULL the FUNCTIONNAME_PTR is also filled in.
+ Returns 2 if partial information from _bfd_elf_find_function is
+ returned (function and maybe file) by looking at symbols. DWARF2
+ info is present but not regarding the requested code location.
+ Returns 0 otherwise.
SYMBOLS contains the symbol table for ABFD.
- DEBUG_SECTIONS contains the name of the dwarf debug sections.
- field and in the abbreviation offset, or zero to indicate that the
- default value should be used. */
+ DEBUG_SECTIONS contains the name of the dwarf debug sections. */
-bfd_boolean
+int
_bfd_dwarf2_find_nearest_line (bfd *abfd,
asymbol **symbols,
asymbol *symbol,
bfd_vma addr;
struct comp_unit* each;
struct funcinfo *function = NULL;
- bfd_boolean found = FALSE;
+ int found = FALSE;
bfd_boolean do_line;
*filename_ptr = NULL;
if (functionname_ptr && function && function->is_linkage)
*functionname_ptr = function->name;
else if (functionname_ptr
- && ((found && !*functionname_ptr)
+ && (!*functionname_ptr
|| (function && !function->is_linkage)))
{
asymbol *fun;
asymbol **syms = symbols;
asection *sec = section;
- if (symbols == NULL || *symbols == NULL)
- _bfd_dwarf2_stash_syms (stash, abfd, &sec, &syms);
+ _bfd_dwarf2_stash_syms (stash, abfd, &sec, &syms);
fun = _bfd_elf_find_function (abfd, syms, sec, offset,
*filename_ptr ? NULL : filename_ptr,
functionname_ptr);
+ if (!found && fun != NULL)
+ found = 2;
+
if (function && !function->is_linkage)
{
bfd_vma sec_vma;