-
Notifications
You must be signed in to change notification settings - Fork 3
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
Replace #line directives in the C generator with mappings that use CodeMap.java #84
Comments
Are you sure we want to do this? Wouldn't this break gdb, among other things? |
I am not sure if the #line directives ever were useful for debugging (although if they are, then yes, certainly this would break that). Just now I tried to use them with GDB to debug the original LF source, and I got an error:
In my experience, the #line directives only make it more difficult to use GDB because I often want to debug the generated code. For an end user, things might be different, but I'm not sure. In any case, this will become less important if/when we implement our own debugger on top of GDB. Such a debugger should use CodeMap so that it is compatible with the C++ and Rust targets (Rust does not have #line directives). |
Perhaps we can disable them by default but have a switch to enable them? Students in the lab are using |
Okay, no problem -- I simply was not aware of that. This issue should probably wait until we have a good alternative for debugging. It has been on my to-dos for almost a year and it can wait for a year longer. |
Or perhaps @Aldenysq can sink his teeth into this :-) |
Thanks to @cmnrd and edwardalee for pointing out that this was needed. Lines are correctly adjusted in VS Code now. Note that this could have been merged without this fix because I chose to specifically exclude C from the LSP tests out of reluctance to maintain the #line directive mechanism; see lf-lang/vscode-lingua-franca#84
In the C generator, we insert #line compiler directives into generated code. This makes generated C programs difficult to debug and confuses tools that measure code coverage. It also is a source of code complexity since the C target is the only target that works that way; if the C generator behaved the same way as the other targets, it would have one line matching system to maintain instead of two.
This change may result in regressions because #line directives allow generated code to be matched to the original code even if they are not copied verbatim from the LF source. However, this is not a fundamental limitation of CodeMap and should be fixed.
The text was updated successfully, but these errors were encountered: