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

Enable debugging with LLDB (Xcode, Qt Creator, etc) #932

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

bluetarpmedia
Copy link
Contributor

Debugging with LLDB (used by Xcode and Qt Creator) requires the following:

  • Print line directives before each function definition
  • Use absolute paths for filenames in line directives

Changes in this PR

  1. Print line directives before each function definition
  2. Add a new command line option to use absolute paths in line directives (defaults to off). LLDB users will have to turn this on.
  3. Update the test-results with the new line directives preceding function definitions

I manually verified the line numbers in the updated test-results and also tested the debugging experience.

The implementation in this PR is significantly simpler than the previous one (#785, now closed) thanks to the recent refactoring that Herb made in to_cpp1.h.

* Print line directives before function definitions
* Add command line option to enable absolute paths in line directives (defaults to off)

These changes are required to enable debugging with LLDB (turn on absolute paths).

Update test-results with line directives before function definitions
@JohelEGP
Copy link
Contributor

2. LLDB users will have to turn this on.

Is it really an issue with LLDB?
I have no problems debugging with GCC + LLDB.
I do have problems debugging with Clang + LLDB.
The issue seems to be https://stackoverflow.com/questions/20985673/how-to-configure-qt-creator-to-show-c-code-rather-than-disassembler?rq=3.
I've solved it by making the input source to cppfront be an absolute path.

@bluetarpmedia
Copy link
Contributor Author

I've solved it by making the input source to cppfront be an absolute path.

Yeah, supplying an absolute path as the argument to cppfront solves the problem, but I added the flag so that users (or tools) can still supply a relative path for convenience while ensuring that the line directives are absolute.

@gregmarr
Copy link
Contributor

It still boggles my mind that lldb won't work properly without redundant #line specifiers. They truly are redundant. Every single one of them has absolutely zero effect on the effective line number based on the previous #line specifiers in the file. Has this been reported to lldb as a bug?

@bluetarpmedia
Copy link
Contributor Author

It still boggles my mind that lldb won't work properly without redundant #line specifiers. They truly are redundant. Every single one of them has absolutely zero effect on the effective line number based on the previous #line specifiers in the file. Has this been reported to lldb as a bug?

I haven't investigated further to find out whether the problem is with clang+lldb or just lldb. What I found on macOS with Xcode and Qt Creator is that the line directives preceding function declarations were not enough for breakpoints and stepping to work, and the workaround I found was to put the directives before each function definition.

@MaxSagebaum
Copy link
Contributor

  1. LLDB users will have to turn this on.

Is it really an issue with LLDB? I have no problems debugging with GCC + LLDB. I do have problems debugging with Clang + LLDB. The issue seems to be https://stackoverflow.com/questions/20985673/how-to-configure-qt-creator-to-show-c-code-rather-than-disassembler?rq=3. I've solved it by making the input source to cppfront be an absolute path.

The same issue exists with GDB. I had to copy the regex.h2 from the cppfront source directory to the test directory in order to debug the tests.

@JohelEGP
Copy link
Contributor

GDB

Yeah, that's what I (and QtCreator) use, not LLDB.

@hsutter
Copy link
Owner

hsutter commented Jan 12, 2024

Looks good -- do I need to worry about the 3 failing tests before merging, or are those failures spurious-ish/otherwise-non-blocking?

@bluetarpmedia
Copy link
Contributor Author

Looks good -- do I need to worry about the 3 failing tests before merging, or are those failures spurious-ish/otherwise-non-blocking?

Those are the same failures happening in ‘main’ and I created #933 to fix that.

@hsutter
Copy link
Owner

hsutter commented Jan 16, 2024

Thanks!

@hsutter hsutter merged commit f9ac5a0 into hsutter:main Jan 16, 2024
13 of 15 checks passed
@bluetarpmedia bluetarpmedia deleted the linedirs2 branch January 17, 2024 00:56
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