public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP
@ 2021-07-23 12:35 vries at gcc dot gnu.org
  2021-07-23 12:42 ` [Bug debug/101598] " vries at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-23 12:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

            Bug ID: 101598
           Summary: [debug, ada] .loc generated for defs__struct1IP
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I.

Consider test-case defs.adb/defs.ads from a gdb testcase (
https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/testsuite/gdb.ada/formatted_ref
).

When compiled with trunk, we have a .loc in defs__struct1IP:
...
$ ./install/bin/gcc defs.adb -c -save-temps -g
$ more defs.s
        .file   "defs.adb"
        .text
.Ltext0:
        .file 0 "/home/vries/gcc_versions/devel" "defs.adb"
        .align 2
        .globl  defs__struct1IP
        .type   defs__struct1IP, @function
defs__struct1IP:
.LFB2:
        .cfi_startproc
        .file 1 "defs.ads"
        .loc 1 18 9
        pushq   %rbp
...

According to PR 101575 comment 7, that's something that needs to be fixed.

II.

Concretely, the .loc being there means that when stepping through defs___elabs,
we'll step into defs__struct1IP:
...
$ gdb -q formatted_ref -ex "b defs___elabs" -ex run
Reading symbols from formatted_ref...
Breakpoint 1 at 0x402bfe: file defs.ads, line 25.
Starting program: formatted_ref 

Breakpoint 1, <defs___elabs> () at defs.ads:25
25         S1 : Struct1;
(gdb) s
0x0000000000402bcc in defs__struct1IP () at defs.ads:18
18         type Struct1 is limited record
(gdb) s
<defs___elabs> () at defs.ads:27
27      end Defs;
(gdb) 
...

OTOH, with gcc-11, we have no .loc:
...
$ gcc-11 defs.adb -c -save-temps -g -gdwarf-5
$ more defs.s
        .file   "defs.adb"
        .text
.Ltext0:
        .file 0 "/home/vries/gcc_versions/devel" "defs.adb"
        .align 2
        .globl  defs__struct1IP
        .type   defs__struct1IP, @function
defs__struct1IP:
.LFB2:
        .cfi_startproc
        pushq   %rbp
...
which means means we don't step into defs__struct1IP:
...
$ gdb -q formatted_ref -ex "b defs___elabs" -ex run
Reading symbols from formatted_ref...
Breakpoint 1 at 0x402d1a: file defs.ads, line 25.
Starting program: formatted_ref 

Breakpoint 1, <defs___elabs> () at defs.ads:25
25         S1 : Struct1;
(gdb) s
27      end Defs;
(gdb) 
...

III.

The difference is caused by commit e69ac020372 ("Add line debug info for
virtual thunks").

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
@ 2021-07-23 12:42 ` vries at gcc dot gnu.org
  2021-07-23 12:54 ` bernd.edlinger at hotmail dot de
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-23 12:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
FWIW, this works for me:
...
$ git diff
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 82783c4968b..0e21775041c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -28390,6 +28390,8 @@ dwarf2out_source_line (unsigned int line, unsigned int
column,

     column = 0;

   file_num = maybe_emit_file (lookup_filename (filename));
+  if (DECL_IGNORED_P (cfun->decl) && is_ada ())
+    return;

   /* ??? TODO: Elide duplicate line number entries.  Traditionally,
      the debugger has used the second (possibly duplicate) line number
...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
  2021-07-23 12:42 ` [Bug debug/101598] " vries at gcc dot gnu.org
@ 2021-07-23 12:54 ` bernd.edlinger at hotmail dot de
  2021-07-23 12:55 ` vries at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2021-07-23 12:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Yes, but it wont fix dwarf-4 and also not the case
when this is not the first function. then we'll
have the .loc from the previous function extend to this one.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
  2021-07-23 12:42 ` [Bug debug/101598] " vries at gcc dot gnu.org
  2021-07-23 12:54 ` bernd.edlinger at hotmail dot de
@ 2021-07-23 12:55 ` vries at gcc dot gnu.org
  2021-07-23 13:05 ` vries at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-23 12:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> FWIW, this works for me:

And, doesn't reintroduce PR101575 on trunk.

AFAIU, the solution suggested in PR101575 comment 8 of setting the
DECL_SOURCE_LOCATION for defs__struct1IP to UNKNOWN_LOCATION would reintroduce
PR101575 on trunk.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-23 12:55 ` vries at gcc dot gnu.org
@ 2021-07-23 13:05 ` vries at gcc dot gnu.org
  2021-07-23 13:08 ` bernd.edlinger at hotmail dot de
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-23 13:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Bernd Edlinger from comment #2)
> Yes, but it wont fix dwarf-4 and also not the case
> when this is not the first function. then we'll
> have the .loc from the previous function extend to this one.

I just tried out:
- dwarf-4
- manually changing order of defs__f1 and defs__struct1IP in .s file

The result look fine to me.  So please show a concrete example where this
produces wrong results.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-23 13:05 ` vries at gcc dot gnu.org
@ 2021-07-23 13:08 ` bernd.edlinger at hotmail dot de
  2021-07-24  6:11 ` bernd.edlinger at hotmail dot de
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2021-07-23 13:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #5 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
I will have a look.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-23 13:08 ` bernd.edlinger at hotmail dot de
@ 2021-07-24  6:11 ` bernd.edlinger at hotmail dot de
  2021-07-24 19:26 ` bernd.edlinger at hotmail dot de
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2021-07-24  6:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Tom de Vries from comment #4)
> (In reply to Bernd Edlinger from comment #2)
> > Yes, but it wont fix dwarf-4 and also not the case
> > when this is not the first function. then we'll
> > have the .loc from the previous function extend to this one.
> 
> I just tried out:
> - dwarf-4
> - manually changing order of defs__f1 and defs__struct1IP in .s file
> 
> The result look fine to me.  So please show a concrete example where this
> produces wrong results.


I did the same.
The effect I meant is the following which is basically PR97937
The line number from the previous function defs__f1 extends to
defs__structIP.

So when I debug this I see the following:
Reading symbols from ./formatted_ref...
(gdb) b defs__struct1IP 
Breakpoint 1 at 0x402faa: file defs.adb, line 21.
(gdb) r
Starting program:
/home/ed/gnu/binutils-gdb/gdb/testsuite/gdb.ada/formatted_ref/formatted_ref 

Breakpoint 1, 0x0000000000402faa in defs__struct1IP () at defs.adb:21
21         end F1;


This here the line number is totally misleading.
So to me it appears, that PR101575 is just the evil
twin brother of PR97937.

And indeed the fix for PR97937 - excluding the really
not debuggable funtions from the debug ranges -
is not sufficient to get rid of the bogus line table
entries from PR101575.

So I start to think that emitting a dummy .file table entry
as you suggest is the way to go, but I would like not to
break the fix for PR97937 at the same time.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-24  6:11 ` bernd.edlinger at hotmail dot de
@ 2021-07-24 19:26 ` bernd.edlinger at hotmail dot de
  2021-08-04 14:26 ` bernd.edlinger at hotmail dot de
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2021-07-24 19:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #7 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 51202
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51202&action=edit
Proposed patch

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-07-24 19:26 ` bernd.edlinger at hotmail dot de
@ 2021-08-04 14:26 ` bernd.edlinger at hotmail dot de
  2021-08-11  5:30 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2021-08-04 14:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #8 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
patch was posted here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/576027.html
review here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-August/576520.html
and here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-August/576538.html

conclusion: I'm not sure that we want it.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-08-04 14:26 ` bernd.edlinger at hotmail dot de
@ 2021-08-11  5:30 ` cvs-commit at gcc dot gnu.org
  2021-08-11  7:20 ` edlinger at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11  5:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bernd Edlinger <edlinger@gcc.gnu.org>:

https://gcc.gnu.org/g:a45918f8a7444a40eb397a037683ba5900a2db74

commit r12-2846-ga45918f8a7444a40eb397a037683ba5900a2db74
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date:   Sat Jul 24 12:53:39 2021 +0200

    Ada: Remove debug line number for DECL_IGNORED_P functions

    It was pointed out in PR101598 to be inappropriate, that
    ignored Ada decls receive the source line number which was
    recorded in the function decl's DECL_SOURCE_LOCATION.
    Therefore set all front-end-generated Ada decls with
    DECL_IGNORED_P to UNKNOWN_LOCATION.

    2021-08-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

            PR debug/101598
            * gcc-interface/trans.c (Subprogram_Body_to_gnu): Set the
            DECL_SOURCE_LOCATION of DECL_IGNORED_P gnu_subprog_decl to
            UNKNOWN_LOCATION.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-08-11  5:30 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11  7:20 ` edlinger at gcc dot gnu.org
  2022-10-25 10:24 ` cvs-commit at gcc dot gnu.org
  2022-10-25 10:25 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: edlinger at gcc dot gnu.org @ 2021-08-11  7:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

Bernd Edlinger <edlinger at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #10 from Bernd Edlinger <edlinger at gcc dot gnu.org> ---
fixed

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-08-11  7:20 ` edlinger at gcc dot gnu.org
@ 2022-10-25 10:24 ` cvs-commit at gcc dot gnu.org
  2022-10-25 10:25 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-25 10:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:cb21297f9259ceedd5f5dd7c3973535f14124d6d

commit r13-3485-gcb21297f9259ceedd5f5dd7c3973535f14124d6d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Oct 25 12:20:33 2022 +0200

    Relax assertion in profiler

    This assertion in branch_prob:

      if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
        {
          location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
          gcc_checking_assert (!RESERVED_LOCATION_P (loc));

    had been correct until the fix for PR debug/101598 was installed.

    gcc/
            * profile.cc (branch_prob): Be prepared for ignored functions with
            DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.

    gcc/testsuite:
            * gnat.dg/specs/coverage1.ads: New test.
            * gnat.dg/specs/variant_part.ads: Minor tweak.
            * gnat.dg/specs/weak1.ads: Add dg directive.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug debug/101598] [debug, ada] .loc generated for defs__struct1IP
  2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2022-10-25 10:24 ` cvs-commit at gcc dot gnu.org
@ 2022-10-25 10:25 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-25 10:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101598

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:da1f6e5260dbcce59372cb522e1af763f25eed6b

commit r12-8866-gda1f6e5260dbcce59372cb522e1af763f25eed6b
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Oct 25 12:20:33 2022 +0200

    Relax assertion in profiler

    This assertion in branch_prob:

      if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
        {
          location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
          gcc_checking_assert (!RESERVED_LOCATION_P (loc));

    had been correct until the fix for PR debug/101598 was installed.

    gcc/
            * profile.cc (branch_prob): Be prepared for ignored functions with
            DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.

    gcc/testsuite:
            * gnat.dg/specs/coverage1.ads: New test.
            * gnat.dg/specs/variant_part.ads: Minor tweak.
            * gnat.dg/specs/weak1.ads: Add dg directive.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-10-25 10:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 12:35 [Bug debug/101598] New: [debug, ada] .loc generated for defs__struct1IP vries at gcc dot gnu.org
2021-07-23 12:42 ` [Bug debug/101598] " vries at gcc dot gnu.org
2021-07-23 12:54 ` bernd.edlinger at hotmail dot de
2021-07-23 12:55 ` vries at gcc dot gnu.org
2021-07-23 13:05 ` vries at gcc dot gnu.org
2021-07-23 13:08 ` bernd.edlinger at hotmail dot de
2021-07-24  6:11 ` bernd.edlinger at hotmail dot de
2021-07-24 19:26 ` bernd.edlinger at hotmail dot de
2021-08-04 14:26 ` bernd.edlinger at hotmail dot de
2021-08-11  5:30 ` cvs-commit at gcc dot gnu.org
2021-08-11  7:20 ` edlinger at gcc dot gnu.org
2022-10-25 10:24 ` cvs-commit at gcc dot gnu.org
2022-10-25 10:25 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).