219 points · by turrini · 2y ago · 64 comments
It is also available at a touch of a button within the most excellent https://godbolt.org/
along side the button that takes your code sample to https://quick-bench.com/
Those sites and https://cppreference.com/ are what I'm using constantly while coding.
I recently discovered https://whitebox.systems/ It's a local app with a $69 one-time charge. And, it only really works with "C With Classes" style functions. But, it looks promising as another productivity boost.
The currently-available version is focused on a "write-based" workflow for C and a subset of C++: JIT-compiling, running and auto-debugging the function you're working on in the background whenever you edit it.
It shows a timeline of how the data in your function changes, with the intent being to give you feedback as immediately as possible.
We're currently working on a "read-focused" workflow, which is basically about making WhiteBox also work as a timeline debugger (for EXEs compiled from any language) with a few extra tricks up its sleeve...
Feel free to ask any questions either here or on our discord: https://chat.whitebox.systems
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.
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++?
I miss the part of what a modern debug lacks.
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-...
# C++ stdlib
skip -gfi /home/trent/mambaforge/envs/td/x86_64-conda-linux-gnu/include/c++/10.3.0/\*
skip -gfi /home/trent/mambaforge/envs/td/x86_64-conda-linux-gnu/include/c++/10.3.0/*/*
skip -gfi /home/trent/mambaforge/envs/td/x86_64-conda-linux-gnu/include/c++/12.3.0/\*
skip -gfi /home/trent/mambaforge/envs/td/x86_64-conda-linux-gnu/include/c++/12.3.0/*/*
# tl::expected
skip -gfi /home/trent/.cache/cpm/expected/5acc53468c550d1f25ce819a675b60bfa0bbc69d/include/tl/\*
It's not perfect, but at least I don't have to step through annoying things like std::unique_ptr<Foo>.get() a million times whilst debugging.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...
Just learn how to use gdb, it's quite capable.
I've found it maps orders of magnitude better than C++ under the same optimisation levels.
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.
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.
Being able to cut through abstraction is very nice and quite important when you want to understand WHAT you are writing from the machine's perspective (or even in general when you don't know the abstraction yet). I love using Haskell, but have no idea what kind of machine code GHC spits out at the end (something based on the spineless tagless G-machine, an abstraction I barely understand by itself).
There is GHC's core, an indermediate representation of your code (mostly "just" desugared Haskell), which is comparable to Andreas' C++ Insights. Which you can get by passing `-ddump-simpl` with additional flags to disable displaying everything.
A list of other internal GHC data to dump is https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_gui...
But getting an idea what assembly is finally generated is still hard (at least for mé). Or, to rephrase, to know if "everything" is finally unpacked and strict or not, and if not: why not.
Btw. IMHO still the best book to read (of course not up-to-date, but to get the basic concepts of GHC) is https://www.microsoft.com/en-us/research/publication/the-imp... https://www.microsoft.com/en-us/research/uploads/prod/1987/0...
https://clang.llvm.org/docs/UsersManual.html#options-to-emit...
Gcc also has similar options
When you say the compiler explorer can do it, do you mean that it will 'inline' the output in a similar way to the assembly i.e. you can view the results 'within' the source code?