microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 452 forks source link

Automatically rebuild target after restarting a debug session #4114

Open GitSparTV opened 1 week ago

GitSparTV commented 1 week ago

Brief Issue Summary

CMake extension allows to start debugging right from the box, however, if you modify source files while debugging and then hit Restart on debugging controls it won't rebuild the project.

Is it possible to control the behavior of this button to check for modifications?

Demo: https://github.com/microsoft/vscode-cmake-tools/issues/4114#issuecomment-2407098500

Yingzi1234 commented 1 week ago

Hello @GitSparTV , we were unable to reproduce this issue in the latest CMake tools version 1.94.1, you can get the detailed steps to reproduce it below, please let us know if you have any issues. Thank you!

ENV:

  1. VSCode: 1.94.1(user setup)
  2. CMake Tools: 1.20.14(pre-release)
  3. C/C++: 1.22.8(pre-release)

Repro steps:

  1. Download and open this folder with VSCode
  2. Set a breakpoint on main.cpp
  3. Click F1 and run "CMake: debug" command
  4. Change the fourth line of code to std::cout << "Hello, Debugging!" << std::endl;
  5. Click "Restart debug"

Actual result: Debug Successful Image

GitSparTV commented 6 days ago

What I see on your gif, that you modified the string then hit restart and CMake didn't trigger the rebuild. You just restarted the previously compiled program. You can verify by looking at the terminal tab, it's for sure printing hello world

Yingzi1234 commented 6 days ago

Hi @GitSparTV , thank you very much for your reply! We were able to reproduce the issue where the output window would not respond when the string was modified and restarted. We have changed this issue to “bug”. Hi @gcampbell-msft We were able to reproduce this issue where the output window do not output logs when the string is modified, you can get the repro steps below. And we have been changed the label to "bug". Please let us know if you have any concerns! Thank you! Image

GitSparTV commented 6 days ago

The output is empty because the breakpoint is on the cout line. Let me record the demo

Yingzi1234 commented 6 days ago

@GitSparTV Thank you very much for your reply!

GitSparTV commented 5 days ago

https://github.com/user-attachments/assets/e1230efc-3575-4951-b4ef-2c2cbd3e5f8a

  1. Have a first version of the code
  2. Press debug
  3. CMake will build it and then run a debugger
  4. Console shows the text from the first version of the code
  5. Modify the code (second version)
  6. Hit Restart on debugger bar
  7. Debugger restarts without rebuilding the project
  8. Console shows the text from the first version of the code, expected to see the second version.
  9. Debug console displays a warning: Warning: Source file 'main.cpp' is newer than module file 'project_name'..

Try to compile a file in Visual Studio. If you make changes, it will rebuild the project first and only then run the debugger. Otherwise you are debugging with old debug information.

Yingzi1234 commented 5 days ago

@GitSparTV Thank you for your reply! We can reproduce your issue on latest CMake Tools version, you can get the details below. Thank you! @gcampbell-msft The problem for users is that the code output does not change when they click on re-debug after making changes. You can get the detail repro steps below and we have been changed the label to "Bug". Thank you!

ENV: VSCode: 1.94.2 CMake tools: v1.20.15(pre-release) C/C++: v1.22.8(pre-release)

Repro steps:

  1. Download and open this folderTest.zip with Vscode
  2. Click F1 to run command "CMake: Configure"
  3. Click the debug button
  4. Change the fourth line of code version 1 to version2
  5. Click re-debug button

Actual result: The debug console box still shows the previous output “Version 1” Image