-
Notifications
You must be signed in to change notification settings - Fork 261
Enable debugging with LLDB (Xcode, Qt Creator, etc) #744
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
Conversation
Line directive filenames now have absolute paths. These changes are required to enable debugging with LLDB.
This is going to break the line directives in reflect.h. It also means that the builds are not reproducible from different directories. I'm surprised that any debugger at this point would be unable to understand relative #line directives. I suspect that this would need to be a switch, like this: https://github.com/hsutter/cppfront/blob/main/source/cppfront.cpp#L139 |
// Don't print duplicate line directives on subsequent lines | ||
if ( | ||
prev_line_directive.out_pos_line == curr_pos.lineno | ||
&& prev_line_directive.line == line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an example of what was being output that is being suppressed? I know that there are some places where we need to output the same directive multiple times due to intermediate code. It's not 100% clear to me that this will only eliminate truly duplicate line numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code prevents duplicate line directives like this:
#line 11 "C:\\path\\main.cpp2"
#line 11 "C:\\path\\main.cpp2"
auto main() -> int{
print_menu(2023);
}
But it still allows the same line directive line number to be reused elsewhere, just not immediately on subsequent lines.
This is still allowed:
#line 11 "C:\\path\\main.cpp2"
auto main() -> int;
//=== Cpp2 function definitions =================================================
#line 11 "C:\\path\\main.cpp2"
auto main() -> int{
print_menu(2023);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the confirmation.
I hadn't noticed that, thanks. Fortunately, in this case, the impact will be for cppfront developers themselves using lldb if lldb can't find the reflect.h file. End-users of cppfront won't be affected.
Yes, I found that surprising too. Based on my tests (on macOS), lldb uses the current working directory when trying to find a relative filename in a line directive. So if you run your binary from a different working directory then suddenly the debugging experience will fail. Whereas with MSVC I suspect the path to the original source code directory is included in the PDB file, so relative filenames work correctly since the debugger can reconstruct it with the directory from the PDB.
Good thinking, I'll add that to my PR. EDIT - Done, see below. |
Looks good, thanks! |
After merging this I re-ran regression tests, and it made incorrect changes... in the first couple of test files I looked at, the So I've reverted this merge... please create a new PR and try running it against all regression tests? Thanks! |
* Print line directives before function definitions Line directive filenames now have absolute paths. These changes are required to enable debugging with LLDB. * Add command line option to enable absolute paths in line directives (defaults to off)
)" This reverts commit 12793b0.
Some changes are needed in order to enable debugging with LLDB (used by Xcode and Qt Creator):
I also tested these changes with Visual Studio and the debugging experience continues to work as before.