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

Create proper debug info for functions and function pointers #27025

Merged
merged 4 commits into from
Jul 20, 2015

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Jul 13, 2015

See the commits for details

r? @arielb1

@dotdash
Copy link
Contributor Author

dotdash commented Jul 14, 2015

This needs more work, closure DI is still wrong

@dotdash dotdash force-pushed the issue-26484 branch 2 times, most recently from b2b3827 to 3629f00 Compare July 14, 2015 18:09
@@ -796,12 +796,31 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
ty::TyBareFn(_, ref barefnty) => {
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
let fn_metadata = subroutine_type_metadata(cx,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason that fn_metadata is defined up here but is only used after the match below? (I note this largely because of that first match arm that returns, so I would have expected this let to come below the match)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The match checks whether subroutine_type_metadata happened to already create the metadata that we're trying to create, i.e. whether it recursively called type_metadata for this type again.

Thinking about it, I feel like this isn't actually possible for function types, so the match could be dropped. Is that correct?

@pnkfelix
Copy link
Member

This seems fine to me, though I am pretty unfamiliar with the debuginfo code.

It would be nice if it included a regression test for #26484 (i.e. something that narrowed down the original problem to something small), since I do not know if #27010 is going to be addressed any time soon.

@dotdash
Copy link
Contributor Author

dotdash commented Jul 15, 2015

I don't know how to come up with a smaller test case, but I could add a check that checks for the debugger type output for function pointers.

We had: z = {void (void)} 0x7fffffffe1a8

And now we have: z = 0x555555558760 <dbg::foo>

Would that be enough?

@dotdash
Copy link
Contributor Author

dotdash commented Jul 15, 2015

Removed that match and added a basic test for function pointer debug info.

@dotdash
Copy link
Contributor Author

dotdash commented Jul 15, 2015

r? @michaelwoerister

@dotdash
Copy link
Contributor Author

dotdash commented Jul 15, 2015

Hm, this currently triggers an assertion in LLVM when running the debuginfo tests. Will investigate...

@pnkfelix
Copy link
Member

@dotdash here is my reduction of the original librustc input from #26484 down to a managable regression test:

https://gist.github.com/pnkfelix/268609f5a2e88cddac63

It is a very strange twisty test. I tried to remove parts that seemed unnecessary, but that tended to cause the bug to disappear.

@michaelwoerister
Copy link
Member

In general this looks very good to me. Thanks a lot for looking into this @dotdash!
I didn't have time yet to do a careful review for possible smaller bugs somewhere. That it causes an LLVM assertion seems to indicate that something isn't quite right yet.

@bors
Copy link
Contributor

bors commented Jul 17, 2015

☔ The latest upstream changes (presumably #27076) made this pull request unmergeable. Please resolve the merge conflicts.

dotdash added 3 commits July 18, 2015 12:43
We're currently using the actual function type as the return type when
creating the debug info for a function, so we're actually creating
debug info for a function that takes the same parameters, and returns
the actual function type, which is completely wrong.
Internally, the arguments passed to the closure are represented by a
tuple, but the actual function takes them as individual arguments, so we
have to untuple the arguments before creating the debuginfo.
Instead of generating pointer debug info, we're currently generating
subroutine debug info.
@dotdash
Copy link
Contributor Author

dotdash commented Jul 18, 2015

OK, so I restored the match statement, because I think that it might actually be useful for cases like this:

struct S {
    f: fn(&S)
}

I also created a minimal testcase from the reduced one that @pnkfelix has provided.

The assertion I have been hitting is the same as in #26447 and the testsuite only triggers it with debug info and optimizations enabled. So since this is an existing bug and we don't have build bots for that setup yet, I think this should land even with that bug still left in.

@pnkfelix
Copy link
Member

Yeah okay, at least this will get us to the point where we can bootstrap rustc atop --enable-debug --enable-optimize again.

@pnkfelix
Copy link
Member

Based on @michaelwoerister positive feedback above and @dotdash's note that the assertion is likely a preexisting bug, I'm r+'ing this.

@pnkfelix
Copy link
Member

@bors r+ 9a14f80

@bors
Copy link
Contributor

bors commented Jul 20, 2015

⌛ Testing commit 9a14f80 with merge 9a31543...

@bors
Copy link
Contributor

bors commented Jul 20, 2015

💔 Test failed - auto-mac-64-opt

@dotdash
Copy link
Contributor Author

dotdash commented Jul 20, 2015

gah, I forgot that a _run_pass test is actually executed by the testsuite :-/

@dotdash
Copy link
Contributor Author

dotdash commented Jul 20, 2015

@bors r=pnkfelix 955690f

@bors
Copy link
Contributor

bors commented Jul 20, 2015

⌛ Testing commit 955690f with merge bbd42a0...

@bors
Copy link
Contributor

bors commented Jul 20, 2015

💔 Test failed - auto-linux-64-x-android-t

Variables for closures hold a tuple of captured variables, and not the
function itself.

Fixes rust-lang#26484
@dotdash
Copy link
Contributor Author

dotdash commented Jul 20, 2015

@bors r=pnkfelix 3d65c7f

bors added a commit that referenced this pull request Jul 20, 2015
@bors
Copy link
Contributor

bors commented Jul 20, 2015

⌛ Testing commit 3d65c7f with merge 39d4faf...

@bors bors merged commit 3d65c7f into rust-lang:master Jul 20, 2015
@dotdash dotdash deleted the issue-26484 branch July 27, 2015 08:49
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.

5 participants