6 ms·
I wonder how helpful it is for g++? Myself and my ancient h/w and s/w engineering friends have been having a discussion recently about how the modern C++ langu
by johnea 3y ago
I wonder how helpful it is for g++?
Myself and my ancient h/w and s/w engineering friends have been having a discussion recently about how the modern C++ language features are generating code that is not readily debugged at the source level.
The compiler has always created assembly that implements the feature described by teh high level language, but histoirically these have had a relatively one-to-one relationship with the source code.
However in the world of post C++11 many more abstracted features are supported, and they no longer have any kind of relation to the source in terms of something you could inspect with a debugger (except in assembly).
So it seems a tool like this is really useful, but unfortunately almost inherently compiler specific.
Maybe GNU can port this to g++?
- ColonelPhantom 3y agoThe readme indicates that it uses system headers (G++ libstdc++) by default. Since it's source-to-source, I don't think being based on clang actually matters for anything unless you happen to use GCC-specific extensions. I would also expect clang and gcc to behave similary when cutting through abstraction. I'm not sure, but it also seems like the output code should be able to compile? Then you can probably use g++ for that step.
- khuey 3y ago> Myself and my ancient h/w and s/w engineering friends have been having a discussion recently about how the modern C++ language features are generating code that is not readily debugged at the source level. What specific features do you have in mind? I generally believe this is because DWARF and debuggers haven't been keeping up, not because of inherent limitations.
- meindnoch 3y agoWhat do you mean exactly? Like the inability of putting a breakpoint on the loop condition of a range-based for loop?
- pjmlp 3y agoPretty easy in VC++ debugger.
- pjmlp 3y agoEven C doesn't map any longer when taking into consideration -O3, UB, vector units, and compiler replaced standard library calls. I miss the part of what a modern debug lacks.
- jstimpfle 3y agoDon't debug -O3, or -O2 for that matter. Debug a separate debug build without optimizations, or don't heavily optimize your release build if you want to debug that (you know that obviously). Even with optimizations disabled, debugging C++ can be quite painful. Only add a little template stuff to the source code, and a few "zero-cost" methods like indexing operators or cast operators, and it quickly becomes painful to step through code. There should be a way to avoid stepping through boilerplate methods, but apart from specifying string patterns to exclude methods by name -- not inline with the method but in a separate debugging configuration (which is very very annoying). The only solution I know is to use C++ features very lightly. Any other practical options? Check this link and the twitter posts linked there, other well known developers have this issue: https://developercommunity.visualstudio.com/t/std::move-and-similar-functions-resu/1681875?q=%5BFixed+In%3A+Visual+Studio+2022+version+17.5+Preview+2%5D https://developercommunity.visualstudio.com/t/std::move-and-...
- pjmlp 3y agoUse modern IDEs with features like Just My Code, which already help a lot. https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=vs-2022#BKMK_C___Just_My_Code https://learn.microsoft.com/en-us/visualstudio/debugger/just... Also, there are scenarios where debugging without optimizations isn't an option. The issue with std::move has been solved for a while and was a VC++ bug, not C++. https://devblogs.microsoft.com/visualstudio/a-year-of-cpp-improvements-in-visual-studio/ https://devblogs.microsoft.com/visualstudio/a-year-of-cpp-im...
- jstimpfle 3y agoCan Just My Code help if it is precisely my code that I want to skip over? I believe it does not -- IIUC it works based on modules i.e. the DLL that contains the machine code. IOW it doesn't even help if I move the "zero-cost" stuff to a separate source file -- templates and other stuff that have to be instanciated or inlined won't be separable from the code that I want to debug based on the module they're running in. > Also, there are scenarios where debugging without optimizations isn't an option. There are scenarios where debugging isn't an option in the first place. Doesn't mean that I should have to suffer in the typical case where debugging with no or only light optimizations is perfectly viable. An acceptable solution I guess would be to have a [DebuggerHidden] function attribute as I found for C#. Didn't find one for C++.
- nurettin 3y agoSounds like a huge undertaking, but why not use clang for introspection and gcc for compiling? It is still useful.
- rymiel 3y agogcc lacks usable tooling, in the past it was a conscious decision to not allow any other program to "steal" the work of gcc. Every single tool for c++ is built around clang, because clang is actually built to allow other tools to use it