Enhance `cmake --trace` (and related modes) by adding a backtrace for the "end" command after "replaying" control structures. Expand the unit test to include control structures. Fixes: #27381