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 w…
C++ Insights – See your source code with the eyes of a compiler
21–30 of 70 posts
Re: C++ Insights – See your source code with the eyes of a compiler
#22I wish there was a way to show the code that is generated when using co_return or co_await e.g. https://cppinsights.io/lnk?code=Ly8gaHR0cHM6Ly93d3cuc2NzLnN0...
Just open the drop-down to select the C++ standard. Below, there is a section "More Transformations". Enable "Show coroutine transformation", and you will get the transformation you're looking for: https://cppinsights.io/s/4d8c3fc1
Disclaimer: I'm the author.
Re: C++ Insights – See your source code with the eyes of a compiler
#23It looks like a perfect candidate for a vs code extension.
Re: C++ Insights – See your source code with the eyes of a compiler
#24It looks like a perfect candidate for a vs code extension.
I use neovim btw
Re: C++ Insights – See your source code with the eyes of a compiler
#25Earlier quoted context omitted.
Don'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…
Use modern IDEs with features like Just My Code, which already help a lot. 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-im...
> 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++.
Re: C++ Insights – See your source code with the eyes of a compiler
#26Earlier quoted context omitted.
Don'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…
Use modern IDEs with features like Just My Code, which already help a lot. 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-im...
Re: C++ Insights – See your source code with the eyes of a compiler
#27Earlier quoted context omitted.
Use modern IDEs with features like Just My Code, which already help a lot. 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-im...
Can 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…
Re: C++ Insights – See your source code with the eyes of a compiler
#28Re: C++ Insights – See your source code with the eyes of a compiler
#29Earlier quoted context omitted.
Even 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.
Don'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…
Just learn how to use gdb, it's quite capable.
Re: C++ Insights – See your source code with the eyes of a compiler
#30Earlier quoted context omitted.
Use modern IDEs with features like Just My Code, which already help a lot. 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-im...
Can 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…