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

cmd/compile: debugger support for range-over-func #66468

Open
aarzilli opened this issue Mar 22, 2024 · 1 comment
Open

cmd/compile: debugger support for range-over-func #66468

aarzilli opened this issue Mar 22, 2024 · 1 comment
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@aarzilli
Copy link
Contributor

Range-over-func (#61405) statements are going to be compiled into closures passed to the iterator function. I.e. the following code:

for range f {
    body
}

becomes:

f(func() {
    body
})

Delve (and potentially other debuggers) needs a way to correlate the stack frame where the body's closure is executing with the stack frame that it logically belongs to (the "parent" frame), for two reasons:

  1. to display variables from the parent frame while the the program is stopped inside the loop's body
  2. to make stepping work seamlessly (i.e. step-over from the header line of the loop will move to the first line of the loop's body)

We have discussed during the go team/delve meetings possible solutions for this and the current plan is to keep the closure struct alive and make it accessible through a specially named variable DIE.

This issue is to track this problem (and also for cases where the binary is optimized and a lot of inlining happens to the range-over-func statement).

cc @derekparker @dr2chase

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 22, 2024
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 26, 2024
@thanm
Copy link
Contributor

thanm commented Mar 26, 2024

Thanks for filing this tracking issue.

@mknyszek mknyszek modified the milestones: Backlog, Go1.23 Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

4 participants