From 18017c39f9598dcd8e3204afd624afd2ac723301 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Sat, 23 Nov 2019 20:59:25 +0100 Subject: [PATCH] Fix an issue with the gdb step-over aka. "n" command When debugging optimized code with inlined functions built with -gstatement-frontiers debug info, it may happen that an inline function has a line location exactly at the end of a block which has the is_stmt attribute set, followed by a location info which is at the call site but has the is_stmt attribute cleared and is therefore ignored. The visual effect is that "n" does sometimes not step over the inlined function but instead jumps to the last line of the inline function, but the inline function has already returned, hence the line number information is inconsistent at this point. This patch detects a is_stmt location info followed by a location info in a different file at the same address, but without is_stmt location set, and forces the second location info to replace the previous one. --- gdb/dwarf2read.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1ca801c..a7c4c8e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -20915,6 +20915,7 @@ private: example, when discriminators are present. PR 17276. */ unsigned int m_last_line = 0; bool m_line_has_non_zero_discriminator = false; + CORE_ADDR m_last_address = (CORE_ADDR) -1; }; void @@ -21097,7 +21098,10 @@ lnp_state_machine::record_line (bool end_sequence) else if (m_op_index == 0 || end_sequence) { fe->included_p = 1; - if (m_record_lines_p && (producer_is_codewarrior (m_cu) || m_is_stmt)) + if (m_record_lines_p + && (producer_is_codewarrior (m_cu) || m_is_stmt || end_sequence + || (m_last_subfile != m_cu->get_builder ()->get_current_subfile () + && m_last_address == m_address))) { if (m_last_subfile != m_cu->get_builder ()->get_current_subfile () || end_sequence) @@ -21120,6 +21124,7 @@ lnp_state_machine::record_line (bool end_sequence) } m_last_subfile = m_cu->get_builder ()->get_current_subfile (); m_last_line = m_line; + m_last_address = m_address; } } } -- 1.9.1