[PATCH v2 2/4] Fix range end handling of inlined subroutines

Bernd Edlinger bernd.edlinger@hotmail.de
Sun May 30 13:58:58 GMT 2021


Currently there is a problem when debugging
optimized code when the inferior stops at an inline
sub-range end PC.  It is unclear if that location
is from the inline function or from the calling
function.  Therefore the call stack is often
wrong.

This patch detects the "weak" line table entries
which are likely part of the previous inline block,
and if we have such a location, it assumes the
location belongs to the previous block.

Additionally it may happen that the infrun machinery
steps from one inline range to another inline range
of the same inline function.  That can look like
jumping back and forth from the calling program
to the inline function, while really the inline
function just jumps from a hot to a cold section
of the code, i.e. error handling.

Additionally it may happen that one inline sub-range
is empty or the inline is completely empty.  But
filtering that information away is not the right
solution, since although there is no actual code
from the inline, it is still possible that variables
from an inline function can be inspected here.

Conceptually this patch uses a heuristic to work around
a deficiency in the dwarf-4 and dwarf-5 rnglists structure.
There should be a location view number for each inline
sub-range begin PC and end PC, similar to the DW_AT_GNU_entry_view
which is the location view for the inline entry point.

gdb:
2021-01-01  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* block.c (blockvector_for_pc_sect): For weak line table values,
	use the inline frame at PC - 1 if it is deeper.
	* dwarf2/read.c (dwarf2_rnglists_process,
	dwarf2_ranges_process): Don't ignore empty ranges here.
	(dwarf2_ranges_read): Ignore empty ranges here.
	(dwarf2_get_pc_bounds): Allow empty inlined subroutines.
	(partial_die_info::read): Likewise.
	(dwarf_finish_line): Add new parameter end_sequence.
	(lnp_state_machine::m_last_file, lnp_state_machine::m_last_address,
	lnp_state_machine::m_stmt_at_address): Remove data items.
	(lnp_state_machine::record_line): Do not filter line entries here,
	except for line == 0.  Pass end_sequence to dwarf_finish_line.
	* infcmd.c (prepare_one_step): Ignore empty inline ranges.
	* infrun.c (process_event_stop_test): Don't stop in !is_stmt lines
	when stepping into inlines.  Don't stop at the call site again, when
	stepping within inlined subroutines with multiple ranges.
	Don't refresh the step info the when executing !is_stmt lines of
	of a different inlined subroutine.
	* symtab.c (find_pc_sect_line): Handle is_weak.

gdb/testsuite:
2021-01-01  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gdb.base/empty-inline.exp: New test.
	* gdb.base/empty-inline.c: New test.
	* gdb.cp/empty-inline.exp: New test.
	* gdb.cp/empty-inline.cc: New test.
	* gdb.cp/step-and-next-inline.exp: Remove KFAILs, enhance test.
	* gdb.cp/step-and-next-inline.cc: Work around failure with
	gcc-9.3.0 from ubuntu 20.04.

Thanks,
Bernd.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-range-end-handling-of-inlined-subroutines.patch
Type: text/x-patch
Size: 28791 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20210530/c4f6a9bf/attachment-0001.bin>


More information about the Gdb-patches mailing list