public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "andreemalcher at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug fortran/29937] New: Stepping Fortran(77) code always jumps back to subroutine header
Date: Fri, 23 Dec 2022 12:36:18 +0000	[thread overview]
Message-ID: <bug-29937-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29937

            Bug ID: 29937
           Summary: Stepping Fortran(77) code always jumps back to
                    subroutine header
           Product: gdb
           Version: 8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: fortran
          Assignee: unassigned at sourceware dot org
          Reporter: andreemalcher at gmail dot com
  Target Milestone: ---

I have a rather large code base (proprietary) including F77, C and C++ code.
The F77 parts are compiled with gfortran 11.2.0.

Compiling with debugging symbols and running the application with gdb works
fine so far, but for the Fortran part there is the following annoyance:

For every `next` step in gdb, the debugger jumps to the corresponding
subroutine header and I need to enter `next` again to go the the actual next
line/statement. Consider the following snippet from a gdb session:

```
843           DELTA = TIME - TOLD
(gdb) n
97            SUBROUTINE THE_SUBROUTINE_HEADER
(gdb) n
844           DELOLD(1) = DELTA
(gdb) n
845           CALL COMCOF
(gdb) n
97            SUBROUTINE THE_SUBROUTINE_HEADER
(gdb) n
854           IF (ITL5 .NE. 0 .AND.
(gdb) n
97            SUBROUTINE THE_SUBROUTINE_HEADER
(gdb) n
854           IF (ITL5 .NE. 0 .AND.
```

I hope the point is clear. While I just want to step line by line through the
code, I always have a superfluous step to `SUBROUTINE THE_SUBROUTINE_HEADER`,
as also evident when looking at the line numbers. 

A few remarks:

* Interestingly, for logical operators, it looks like for every operand I have
these additional calls (i.e. if I have something like `IF (A .AND. B .AND. C)`,
gdb will jump to the subroutine header three times).

* The problem doesn't show up with the `advance` command, i.e. if I type
`advance 900` to advance to line 900 in the example above, gdb will happily
fast forward to the given location.

* FWIW, this also happens when I run the debugger from an IDE (that is, using
GDB/MI)

* The C and C++ code is not affected, there gdb works like expected (in the
same session).

* A related question was posted on StackOverflow, but no replies have been
posted so far:
https://stackoverflow.com/questions/23744141/ddd-execution-line-jumps-to-subroutine-top-continuation-line-fortran-77

Unfortunately I am not able to reproduce this bug in a small test program. 

Last but not least, things I have tried in the original program:
* Try with gdb 10.1 and 11.1 (the latter has its own set of problems, e.g.
stepping takes ages to complete)
* Delete/remove everything from my ~/.gdbinit
* remove all flags except for `-g -O0`
* try with `-g3`
but to no avail.

Let me know in case you need further information or want me to test something,
I'll be happy to help.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2022-12-23 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-23 12:36 andreemalcher at gmail dot com [this message]
2022-12-23 16:01 ` [Bug fortran/29937] " tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29937-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).