Open petervdonovan opened 1 year ago
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:
Line number 15 out of range; file:/home/peter/vscode-lingua-franca/lingua-franca/test/C/src/Minimal.lf has 8 lines.
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 gdb
, which seems to work fine, but is apparently not flawless... Also tagging @lsk567.
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 :-)
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.