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

Get all (but one) of debuginfo tests to pass with MIR codegen. #32952

Merged
merged 3 commits into from
Apr 17, 2016

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Apr 14, 2016

I didn't get much feedback in #31005 so I went ahead and implemented something simple.
Closes #31005, as MIR debuginfo should work now for most usecases.
#32949 tracks remaining shadowing problems that break function-prologue-stepping-no-stack-check.

The no-debug-attribute test no longer assumes variables are in scope of return.
We might also want to revisit that in #32949, but the test is more reliable now either way.

In order to get one last function in the associated-type test pass, this PR also fixes #32790.

@rust-highfive
Copy link
Collaborator

r? @Aatch

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb
Copy link
Member Author

eddyb commented Apr 14, 2016

I expect the lldb part in debuginfo/function-prologue-stepping-no-stack-check to work, but I couldn't get the automated testing to work locally.
cc @michaelwoerister

@alexcrichton
Copy link
Member

swoon

// gdb-check:$2 = true
// gdb-command:print c
// gdb-check:$3 = 2.5
// gdb-command:info args
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit hesitant about using info args for debuginfo tests. A gdb-check instruction just verifies that the argument can be found somewhere in the output, so without the numbering it's possible to overlook errors. For example, given the following program...

let x = 1;
breakpoint();
{
    let x = 2;
    breakpoint();
}
breakpoint();

... we get a correct result with print:

gdb-command:print x
gdb-command:continue
gdb-command:print x
gdb-command:continue
gdb-command:print x
gdb-check:$1 = 1
gdb-check:$2 = 2
gdb-check:$3 = 2

produces:
$1 = 1
$2 = 2
$3 = 2 // let's say there's a bug in scoping and x still refers to wrong address

The error will be detected because there is not $3 = 1 in the output. But with info, the overlapping names might hide the error:

gdb-command:info locals
gdb-command:continue
gdb-command:info locals
gdb-command:continue
gdb-command:info locals
gdb-check:x = 1
gdb-check:x = 2
gdb-check:x = 1 // <-- this is actually redundant

produces:
x = 1
x = 2
x = 2 // the test would still pass, because `x = 1` can be found in the output.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's certainly a problem. I don't think I can get this test to work without either this workaround or a generalized solution for #32949.
I'm not entirely sure the test makes any sense anymore, btw, a the whole morestack stuff is gone.

I'd rather have a test that only makes sure the backtrace contains the argument names and their values, and it wouldn't need the myriad of cases found here.

Copy link
Member

Choose a reason for hiding this comment

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

If the morestack stuff is gone for good, then this test should deleted, but function-prologue-stepping-regular.rs should then also handle GDB. I'm surprised that info args and print give different results here...

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of #32949, there isn't actually a point for the debugger to break on where the variables for arguments are not in scope, and the first point where it would stop is before those variables are actually initialized, so you get garbage locals shadowing the perfectly good args.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there just be the arguments? I.e. do we have separate DWARF entries for the arguments and some later incarnation of the arguments in stack frame?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because they are distinct lvalues in MIR. Even if we might skip building allocas for arguments (which would require us using llvm.dbg.value instead) and/or elide their moves to variables, we'd still need a notion of "call arguments" (e.g. what shows up in the backtrace) different from pattern bindings.

Copy link
Member

Choose a reason for hiding this comment

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

OK, makes sense. However, this is exactly what these test cases are for: That print arg will print the correct value when setting a function breakpoint. So using info args is a bit like cheating :P

@michaelwoerister
Copy link
Member

r? @michaelwoerister
I'll review this if nobody minds.

@arielb1
Copy link
Contributor

arielb1 commented Apr 14, 2016

Why is there a spread flag that inverts the point of the rust-call ABI? I can see people complaining "why does my rust-call function store junk on the stack before proxying".

@eddyb
Copy link
Member Author

eddyb commented Apr 14, 2016

@arielb1 It's pretty much how it works in old trans as well.
The flag is there so the MIR can be manipulated independently from the ABI, e.g. if the type is a known tuple, we can spread it into its components (which would not have the spread flag on, unless we get VG and it's some (A, B, Tail...) type).
We also would need a similar mechanism on tuple ADT rvalues and calls, but this is getting offtopic.

@michaelwoerister
Copy link
Member

Excellent work, @eddyb!
I would suggest that you ignore the function-prologue-stepping-no-stack-check.rs with a FIXME for now and we'll take care of it when we have a good solution for #32949.

@eddyb eddyb changed the title Get all debuginfo tests to pass with MIR codegen. Get all (but one) of debuginfo tests to pass with MIR codegen. Apr 16, 2016
@eddyb
Copy link
Member Author

eddyb commented Apr 16, 2016

@michaelwoerister Rebased, addressed the #32949 postponement and updated title & description.

@michaelwoerister
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 16, 2016

📌 Commit e2ac989 has been approved by michaelwoerister

@michaelwoerister
Copy link
Member

Thanks, @eddyb!

@bors
Copy link
Contributor

bors commented Apr 17, 2016

⌛ Testing commit e2ac989 with merge 6892277...

bors added a commit that referenced this pull request Apr 17, 2016
Get all (but one) of debuginfo tests to pass with MIR codegen.

I didn't get much feedback in #31005 so I went ahead and implemented something simple.
Closes #31005, as MIR debuginfo should work now for most usecases.

The `no-debug-attribute` test no longer assumes variables are in scope of `return`.
We might also want to revisit that in #32949, but the test is more reliable now either way.

In order to get one last function in the `associated-type` test pass, this PR also fixes #32790.
@bors bors merged commit e2ac989 into rust-lang:master Apr 17, 2016
@eddyb eddyb deleted the mir-debuginfo-2 branch April 17, 2016 08:01
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.

MIR match bindings have the scope of the match instead of the arm. [MIR] Implement debug info
7 participants