+ /* FIXME: Do we need to scan the aranges looking for the lowest pc value ? */
+
+ for (psym = symbols; * psym != NULL; psym++)
+ {
+ asymbol * sym = * psym;
+
+ if (sym->flags & BSF_FUNCTION
+ && sym->section != NULL
+ && strcmp (sym->name, func->name) == 0)
+ return ((bfd_signed_vma) func->arange.low) -
+ ((bfd_signed_vma) (sym->value + sym->section->vma));
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* 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
+ FILENAME_PTR and LINENUMBER_PTR. In the case where SYMBOL was
+ NULL the FUNCTIONNAME_PTR is also filled in.
+ SYMBOLS contains the symbol table for ABFD.
+ DEBUG_SECTIONS contains the name of the dwarf debug sections.
+ ADDR_SIZE is the number of bytes in the initial .debug_info length
+ field and in the abbreviation offset, or zero to indicate that the
+ default value should be used. */
+
+bfd_boolean
+_bfd_dwarf2_find_nearest_line (bfd *abfd,
+ asymbol **symbols,
+ asymbol *symbol,
+ asection *section,
+ bfd_vma offset,
+ const char **filename_ptr,
+ const char **functionname_ptr,
+ unsigned int *linenumber_ptr,
+ unsigned int *discriminator_ptr,
+ const struct dwarf_debug_section *debug_sections,
+ unsigned int addr_size,
+ void **pinfo)
+{
+ /* Read each compilation unit from the section .debug_info, and check
+ to see if it contains the address we are searching for. If yes,
+ lookup the address, and return the line number info. If no, go
+ on to the next compilation unit.
+
+ We keep a list of all the previously read compilation units, and
+ a pointer to the next un-read compilation unit. Check the
+ previously read units before reading more. */
+ struct dwarf2_debug *stash;
+ /* What address are we looking for? */
+ bfd_vma addr;
+ struct comp_unit* each;
+ struct funcinfo *function = NULL;
+ bfd_boolean found = FALSE;
+ bfd_boolean do_line;
+
+ *filename_ptr = NULL;
+ if (functionname_ptr != NULL)
+ *functionname_ptr = NULL;
+ *linenumber_ptr = 0;
+ if (discriminator_ptr)
+ *discriminator_ptr = 0;
+
+ if (! _bfd_dwarf2_slurp_debug_info (abfd, NULL, debug_sections,
+ symbols, pinfo,
+ (abfd->flags & (EXEC_P | DYNAMIC)) == 0))
+ return FALSE;
+
+ stash = (struct dwarf2_debug *) *pinfo;
+
+ do_line = symbol != NULL;
+ if (do_line)
+ {
+ BFD_ASSERT (section == NULL && offset == 0 && functionname_ptr == NULL);
+ section = bfd_get_section (symbol);
+ addr = symbol->value;
+ }
+ else
+ {
+ BFD_ASSERT (section != NULL && functionname_ptr != NULL);
+ addr = offset;