Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Breakpoints with For Loops & Branches (Generated Debug Information) #4777

Open
itsdanott opened this issue Jan 30, 2025 · 0 comments
Labels
llvm-backend llvm-bug LLVM related bug

Comments

@itsdanott
Copy link
Contributor

itsdanott commented Jan 30, 2025

Context

This is quite a specific one so there's also a video attached that should help understanding it.

Screen.Recording.2025-01-30.115109.mp4

When hitting an if branch with a false conditional expression while stepping through a for loop the breakpoint is shown inside last line of the if-scope.
This makes it hard to understand wether the code is actually executed or not.
Especially in single-line scopes it gets difficult as you won't notice a visual difference.

As suggested by laytan this is most likely related to Odin's generated debug information.

Details

The problem occurs on Windows with MSVC - I have also tested it on a Mac with LLDB where it works as expected.
It seems to only happen inside a foor loop and only for a conditional expression - for a boolean literal it works fine.

Operating System & Odin Version:
Odin: dev-2025-01:2aae4cfd4
OS: Windows 11 Professional (version: 24H2), build 26100.2894
CPU: AMD Ryzen 9 5950X 16-Core Processor
RAM: 65448 MiB
Backend: LLVM 18.1.8

Steps to Reproduce

  1. Add a breakpoint to line 5
  2. Start a debug session with MSVC (cppvsdbg)
  3. Step through the for loop and notice how the breakpoint enters the last line of the if-branch - even though the print is obviously not actually executed.
  4. Change line 6 to a bool literal: if false { and notice how the problem does not occur any more
package main
import "core:fmt"

main :: proc() {
    for i in 0..<32 {
        if i > 64 { // <- conditional expression seems to trigger the issue. Compare to false bool literal.
            fmt.printf("This won't be printed!")
            fmt.printf("Neither will this.")
            // ^ Somehow the breakpoint exists the loop here
        }
    }
}
@gingerBill gingerBill added llvm-bug LLVM related bug llvm-backend labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm-backend llvm-bug LLVM related bug
Projects
None yet
Development

No branches or pull requests

2 participants