+ if (subfile == NULL)
+ return;
+
+ if (dwarf_line_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "Finishing current line, file %s, address %s\n",
+ lbasename (subfile->name),
+ paddress (gdbarch, address));
+ }
+
+ dwarf_record_line_1 (gdbarch, subfile, 0, address, p_record_line);
+}
+
+/* Record the line in STATE.
+ END_SEQUENCE is non-zero if we're processing the end of a sequence. */
+
+static void
+dwarf_record_line (lnp_reader_state *reader, lnp_state_machine *state,
+ int end_sequence)
+{
+ const struct line_header *lh = reader->line_header;
+ unsigned int file, line, discriminator;
+ int is_stmt;
+
+ file = state->file;
+ line = state->line;
+ is_stmt = state->is_stmt;
+ discriminator = state->discriminator;
+
+ if (dwarf_line_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "Processing actual line %u: file %u,"
+ " address %s, is_stmt %u, discrim %u\n",
+ line, file,
+ paddress (reader->gdbarch, state->address),
+ is_stmt, discriminator);
+ }
+
+ if (file == 0 || file - 1 >= lh->num_file_names)
+ dwarf2_debug_line_missing_file_complaint ();
+ /* For now we ignore lines not starting on an instruction boundary.
+ But not when processing end_sequence for compatibility with the
+ previous version of the code. */
+ else if (state->op_index == 0 || end_sequence)
+ {
+ lh->file_names[file - 1].included_p = 1;
+ if (reader->record_lines_p && is_stmt)
+ {
+ if (state->last_subfile != current_subfile || end_sequence)
+ {
+ dwarf_finish_line (reader->gdbarch, state->last_subfile,
+ state->address, state->record_line);
+ }
+
+ if (!end_sequence)
+ {
+ if (dwarf_record_line_p (line, state->last_line,
+ state->line_has_non_zero_discriminator,
+ state->last_subfile))
+ {
+ dwarf_record_line_1 (reader->gdbarch, current_subfile,
+ line, state->address,
+ state->record_line);
+ }
+ state->last_subfile = current_subfile;
+ state->last_line = line;
+ }
+ }
+ }
+}
+
+/* Initialize STATE for the start of a line number program. */
+
+static void
+init_lnp_state_machine (lnp_state_machine *state,
+ const lnp_reader_state *reader)
+{
+ memset (state, 0, sizeof (*state));
+
+ /* Just starting, there is no "last file". */
+ state->last_file = 0;
+ state->last_subfile = NULL;
+
+ state->record_line = record_line;
+
+ state->last_line = 0;
+ state->line_has_non_zero_discriminator = 0;
+
+ /* Initialize these according to the DWARF spec. */
+ state->op_index = 0;
+ state->file = 1;
+ state->line = 1;
+ /* Call `gdbarch_adjust_dwarf2_line' on the initial 0 address as if there
+ was a line entry for it so that the backend has a chance to adjust it
+ and also record it in case it needs it. This is currently used by MIPS
+ code, cf. `mips_adjust_dwarf2_line'. */
+ state->address = gdbarch_adjust_dwarf2_line (reader->gdbarch, 0, 0);
+ state->is_stmt = reader->line_header->default_is_stmt;
+ state->discriminator = 0;
+}
+
+/* Check address and if invalid nop-out the rest of the lines in this
+ sequence. */
+
+static void
+check_line_address (struct dwarf2_cu *cu, lnp_state_machine *state,
+ const gdb_byte *line_ptr,
+ CORE_ADDR lowpc, CORE_ADDR address)
+{
+ /* If address < lowpc then it's not a usable value, it's outside the
+ pc range of the CU. However, we restrict the test to only address
+ values of zero to preserve GDB's previous behaviour which is to
+ handle the specific case of a function being GC'd by the linker. */
+
+ if (address == 0 && address < lowpc)
+ {
+ /* This line table is for a function which has been
+ GCd by the linker. Ignore it. PR gdb/12528 */
+
+ struct objfile *objfile = cu->objfile;
+ long line_offset = line_ptr - get_debug_line_section (cu)->buffer;
+
+ complaint (&symfile_complaints,
+ _(".debug_line address at offset 0x%lx is 0 [in module %s]"),
+ line_offset, objfile_name (objfile));
+ state->record_line = noop_record_line;
+ /* Note: sm.record_line is left as noop_record_line
+ until we see DW_LNE_end_sequence. */
+ }