mbox series

[0/2] Fix bogus line info in DECL_IGNORED_P functions

Message ID AM8PR10MB4708F838423E9387CFC467D3E4E89@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM
Headers show
Series Fix bogus line info in DECL_IGNORED_P functions | expand

Message

Bernd Edlinger July 26, 2021, 4:45 p.m. UTC
This fixes a regression which was introduced accidentally with
commit e69ac020372 ("Add line debug info for virtual thunks").

That is certain Ada functions have now a .loc directive which is
probably not how the debug experience of those functions was intended.

Currently those functions stop in the debugger when stepped into, and
show the source location where the data type was declared.  It was
pointed out in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101575#c7
that the previous behaviour is what Ada really wants here.

The prevoious debug experience can be achieved by setting
DECL_SOURCE_LOCATION of such functions in the Ada front end
to UNKNOWN_LOCATION.  This is done by (2/2).

However it turns out that the test case which is from the
gdb-test suite has a special feature that the ignored function
is compiled before the first normal function, and that triggers
a misbehaviour of the dwarf-4 assembler.  That shows a corner
case where the current handling of ignored functions with
no line info at all fails to suppress the bogus line numbers.
That is fixed by (1/2), by emiting a dummy .file directive
when there was no preceeding .file directive.


This was boot-strapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?

Thanks,

Bernd Edlinger (2):
  Fix debug info for ignored decls at start of assembly
  Ada: Remove debug line number for DECL_IGNORED_P functions

 gcc/ada/gcc-interface/trans.c |  4 +++-
 gcc/dwarf2out.c               | 29 +++++++++++++++++++++++++----
 gcc/final.c                   |  5 ++---
 3 files changed, 30 insertions(+), 8 deletions(-)