-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
debug info fail -- range based for loops and other stuff #20238
Comments
assigned to @adrian-prantl |
I think Adrian had done something here recently? |
Looks like the branch to the for increment is associated with the "end" of the for loop, which makes little sense in the absence of a compound statement. if.end67: ; preds = %if.end, %if.then63 !3047 = metadata !{i32 17, i32 0, metadata !3041, null} |
Strictly speaking it was the continuation block of the IfStmt. |
So to explain this - we were attributing (in clang) the location of a function call (such as the overloaded op<< above) to the beginning of the expression (eg: the 'x' in 'x << y'). So the jumping behavior was produced by evaluating an operand (v[n]) then making the function call (all of which would be attributed to the first character in the whole expression, due to precedence. This has been improved to attribute overloaded operators to the location of the operator, so each op<< will be attributed to the <<, not the start of its LHS. So now we get the behavior: (gdb) Which looks totally sane. This would still get a bit jumpy if you'd happened to put the << on the end of the previous line (then it would've gone to the next line to evaluate the operand, then to the previous line to call <<, then back to the next line, etc)... |
A lot of the discussion on the topic is summarized here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150209/123042.html the meaty bits:
One other thing in favor of the is_stmt solution is that it's fairly robust
|
*** Bug llvm/llvm-bugzilla-archive#45609 has been marked as a duplicate of this bug. *** |
mentioned in issue llvm/llvm-bugzilla-archive#20747 |
mentioned in issue llvm/llvm-bugzilla-archive#45603 |
mentioned in issue llvm/llvm-bugzilla-archive#45609 |
mentioned in issue llvm/llvm-bugzilla-archive#46032 |
1 similar comment
mentioned in issue llvm/llvm-bugzilla-archive#46032 |
mentioned in issue llvm/llvm-bugzilla-archive#47232 |
@llvm/issue-subscribers-debuginfo |
Extended Description
So, I came here to file a bug about debug info for range-based for loops. I wrote the following test case:
Then I compiled and debugged it:
WAT. I have no idea what happened here. But again, this is not why I wanted to file the bug, its just something we should fix. Continuing with GDB...
BUG: We never execute both ++b and ++a. This is a bogus line to jump to, I think it's actually trying to jump to the "end" of the body of the range based for loop, and has this as the source location or something. The behavior of this program is entirely correct, but the debugger is lying to me.
And it happens on every loop where we execute "++b".
But we only see one stop at that line when we execute "++a".
Let me know what else I can provide to help fix!
The text was updated successfully, but these errors were encountered: