- /* Only expand sals that represent file.c:line. */
- if (sal.symtab == NULL || sal.line == 0 || sal.pc != 0)
- {
- ret.sals = xmalloc (sizeof (struct symtab_and_line));
- ret.sals[0] = sal;
- ret.nelts = 1;
- return ret;
- }
- else
- {
- struct program_space *pspace;
- struct linetable_entry *best_item = 0;
- struct symtab *best_symtab = 0;
- int exact = 0;
- char *match_filename;
-
- lineno = sal.line;
- match_filename = sal.symtab->filename;
-
- /* We need to find all symtabs for a file which name
- is described by sal. We cannot just directly
- iterate over symtabs, since a symtab might not be
- yet created. We also cannot iterate over psymtabs,
- calling PSYMTAB_TO_SYMTAB and working on that symtab,
- since PSYMTAB_TO_SYMTAB will return NULL for psymtab
- corresponding to an included file. Therefore, we do
- first pass over psymtabs, reading in those with
- the right name. Then, we iterate over symtabs, knowing
- that all symtabs we're interested in are loaded. */
-
- old_chain = save_current_program_space ();
- ALL_PSPACES (pspace)
- {
- set_current_program_space (pspace);
- ALL_PSPACE_OBJFILES (pspace, objfile)
- {
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_with_filename (objfile,
- sal.symtab->filename);
- }
- }
- do_cleanups (old_chain);
-
- /* Now search the symtab for exact matches and append them. If
- none is found, append the best_item and all its exact
- matches. */
- symtab_to_fullname (sal.symtab);
- exact = append_exact_match_to_sals (sal.symtab->filename,
- sal.symtab->fullname, lineno,
- &ret, &best_item, &best_symtab);
- if (!exact && best_item)
- append_exact_match_to_sals (best_symtab->filename,
- best_symtab->fullname, best_item->line,
- &ret, &best_item, &best_symtab);
- }