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

Make DebugInfo edges per-call rather than per-callee #56305

Closed

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Oct 23, 2024

This is useful for when you need to, e.g., trim the "common prefix" of two stacktraces that were both taken from inside an inlined function call. I'm hoping to use this property to provide a way to get only the "popped" frames inside a catch handler, but that requires us to understand when an inlined frame was popped, as in:

@inline function foo()
    try
        error("foo")
    catch err
        Base.showerror(stderr, err, Base.catch_backtrace())
    end
end
bar() = foo()

The frames would be:

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:44
 [2] foo
   @ ./REPL[1]:3 [inlined]
 [3] bar()        # <- this hasn't been "popped" yet, we want to exclude it from the debuginfo expansion
   @ Main ./REPL[2]:1

To know to trim off bar() (since it hasn't been popped yet), I want to record the ip at catch entry and then have our stacktrace expansion logic remove any frames common with the catch entry.

In order to trim that common prefix correctly, we need to distinguish this case from:

try foo() catch foo() end

which has the same line number and callee, but is a different call.

This is useful for when you need to, e.g., trim the "common prefix" of
two stacktraces that were both taken from inside an inlined function
call.

I'm hoping to use this property to provide a way to get only the
"popped" frames inside a `catch` handler, but that requires us to
understand when an inlined frame was popped, as in:
```julia
@inline function foo()
    try
        error("foo")
    catch err
        Base.showerror(stderr, err, Base.catch_backtrace())
    end
end
bar() = foo()
```

The popped frames would be:
```julia
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:44
 [2] foo
   @ ./REPL[1]:3 [inlined]
```

To know to trim off `bar()` (since it hasn't been popped yet), I want
to record the ip at catch entry and then have our stacktrace expansion
logic remove any frames common with the catch entry.

In order to trim that common prefix correctly, we need to distinguish
this case from:
```
try foo() catch foo() end
```
which has the same line number and callee, but is a different call.
@topolarity
Copy link
Member Author

On second thought, I don't think this change is needed

The catch ip should yield a strict subset of inlined frames that we got from the try (where we threw), so it should be enough to record the ip on catch entry and use that to count how many inlined frames should be left "unpopped"

@topolarity topolarity deleted the ct/inlined-call-debuginfo branch October 23, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant