-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to debug my test #2074
Comments
@CatsNipYummy, can you set the
|
@bobbrow I believe I've set the cmake.loggingLevel to "Debug" for User, Remote, and Workspace. Doesn't seem to be giving me any more logs. Am I missing something here?
|
If it's set in all 3, the value in the Workspace setting wins. |
I tried the "reload window" command and also manually restarting VS Code. Removed my build folder and ran cmake again. Dont seem to be getting any extra logs. Are these write to a log file I can look at? |
Ok, let me look at the code, it could be because of the failure on the "start" line that it's exiting early. |
The code that is failing is looking for an executable target. Can you share a screenshot of the CMAKE: PROJECT OUTLINE panel, or is there a repo we can clone? The name of the target it's looking for has a .cpp extension which seems a little suspicious. |
The logs I shared with you are from the 'output' panel. Unfortunately, can't share the codebase. This is what a part of the outline panel looks like I've renamed some of the internal namings of the project 😄 The unit tests do have the .cpp extension to them. That part has been set up for a while. Is there a way to know if that's what's throwing the cmake tools off? |
The file extension shouldn't throw cmake tools off. CMake Tools just needs the target to be an "executable" target. Did you add this target with When you right click on your target, do you get an option to set it as the Debug/Launch target? And if you select that option, does it put a rocket ship emoji next to the hammer emoji? One last question. Are you using CMakePresets.json to configure your project? |
Yes I am using add_executable() in CMakeLists.txt When I press "Debug/Launch Target", I don't see the rocket ship emoji. The output when I press that option looks the following:
I am not using CMakePresets.json . At least I'm not aware of it. Nothing along those lines exists inside my .vscode folder. Is there a local folder I can check just incase? |
If you have a CMakePresets.json it would be in the same folder as your root CMakeLists.txt. I think we're going to need more logging since you can't share your project. I'll instrument the extension a bit and then send a link to install the special version. |
Here is a build of the extension with some additional logging. Please set Instructions:
|
Here's the log file. I've renamed some internal namings. So please take those typos (if any) with a pinch of salt. We're using CMake 3.21.2 |
Thanks. The target looks correct (it appears you removed the One other thing I noticed in there was your usage of snaps. We don't support that right now, but there is a workaround here: #838 (comment). If you can apply that workaround and let me know if it fixes anything, that would be appreciated. |
I built a new VSIX: https://github.com/microsoft/vscode-cmake-tools/suites/3617086280/artifacts/87429502 If you can install that, run your scenario and share the log again, I'll take a look. |
Here are the logs you requested. I've used the snap worked around as well (that's right. removed the .cpp as well) |
@bobbrow do you need any other logs from my end? |
Sorry I didn't get to this yesterday. The logs look strangely the same as the first one. Could you check the version number for me? |
Yes, the hash number should be the same as mine. You might need to uninstall the first VSIX I gave you to get the new one to install properly. You can also "uninstall" it by deleting the matching folder under |
my bad. here are the logs from the right version VS_Code3.log |
Another option is for me to give you a line of code for you to insert into your copy of the extension and that will add the logging. |
Sure. I can add that line of code and see what's happening |
The screenshot is sufficient. You are trying to select "Debug", but the information the extension has indicates that the "Release" configuration is being generated. Is there anything in your CMakeLists.txt that changes the CMAKE_BUILD_TYPE? I see that the generator command is correctly setting the CMAKE_BUILD_TYPE to Debug, but all of the files written here: |
That's true. To your point, when I tried "CMake: [Release]: Ready", it did try to compile the project but then all my paths are missing. So I get 'cannot open *.h' errors. Let me try deleting the build folder and try again. I've been doing that for all my tests each time. But let me see if something's explicitly changing the CMAKE_BUILD_TYPE to Release at some point. |
So I did delete the .cmake file you mentioned and I was able to get the debugger to start and I see my unit test output which is great! The only issue is that the breakpoints are not getting activated. Even if this is in release, shouldn't the breakpoints inside int main() get called? |
By default, I don't believe CMake's 'Release' config sets up the binary to have any debug information in it so that's why your breakpoints don't bind. There is a 'RelWithDebInfo' config that does that. Sorry, I should have thought of that earlier. |
'RelWithDebInfo' is still not doing anything for me
This does sound like a shortcut to the problem. The fact its getting switched to Release is probably why this is not working either. |
Correct. This is the exact same problem as the 'Debug' config. If you can figure out where in the project the CMAKE_BUILD_TYPE is getting overwritten, I think everything should start working as expected. |
Dug around the project a bit and found the source of the issue. We're forcing the CMAKE_BUILD_TYPE cause of some cross-platform support like you mentioned. That's something on our end that needs to be changed. But removing that fixed this issue. Thanks a lot for your help @bobbrow . Feel free to close this issue if you like. |
I'm glad you were able to resolve this. I'll close this issue, but create a new one for us to investigate whether we can throw in a warning about this type of situation. |
I am facing a similar issue with one of my cmake projects. I am trying to run this on a remote machine. The host machine is OSX 11.4 (Big Sur). The remote is a Ubuntu 20.04.3. The project configures and builds okay. But I am not able to debug any of my unit tests. This is the error I get when I right-click on the test and press 'Debug'
[extension] [1484] cmake.debugTarget started [main] Failed to prepare executable target with name 'core-01_hello_test.cpp' [extension] [1484] cmake.debugTarget finished (returned null)
Does not give me any other information.
This is what my cmake command looks like:
"cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja"
I have tried Debug, 'Debug', and also 'DEBUG'. Doesn't seem to make a difference.
Originally posted by @CatsNipYummy in #1692 (comment)
The text was updated successfully, but these errors were encountered: