/* Support routines for building symbol tables in GDB's internal format.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
set_last_source_file (name);
/* Default the source language to whatever can be deduced from
- the filename. If nothing can be deduced (such as for a C/C++
- include file with a ".h" extension), then inherit whatever
- language the previous subfile had. This kludgery is
- necessary because there is no standard way in some object
- formats to record the source language. Also, when symtabs
- are allocated we try to deduce a language then as well, but
- it is too late for us to use that information while reading
- symbols, since symtabs aren't allocated until after all the
- symbols have been processed for a given source file. */
+ the filename. If nothing can be deduced (such as for a C/C++
+ include file with a ".h" extension), then inherit whatever
+ language the previous subfile had. This kludgery is
+ necessary because there is no standard way in some object
+ formats to record the source language. Also, when symtabs
+ are allocated we try to deduce a language then as well, but
+ it is too late for us to use that information while reading
+ symbols, since symtabs aren't allocated until after all the
+ symbols have been processed for a given source file. */
subfile->language = deduce_language_from_filename (subfile->name);
if (subfile->language == language_unknown
anyway. */
if (line == 0)
{
+ struct linetable_entry *last = nullptr;
while (subfile->line_vector->nitems > 0)
{
- e = subfile->line_vector->item + subfile->line_vector->nitems - 1;
- if (e->pc != pc)
+ last = subfile->line_vector->item + subfile->line_vector->nitems - 1;
+ if (last->pc != pc)
break;
subfile->line_vector->nitems--;
}
+
+ /* Ignore an end-of-sequence marker marking an empty sequence. */
+ if (last == nullptr || last->line == 0)
+ return;
}
e = subfile->line_vector->item + subfile->line_vector->nitems++;
= [] (const linetable_entry &ln1,
const linetable_entry &ln2) -> bool
{
+ if (ln1.pc == ln2.pc
+ && ((ln1.line == 0) != (ln2.line == 0)))
+ return ln1.line == 0;
+
return (ln1.pc < ln2.pc);
};