Why doesn't 'Edit & Continue' feature work in VS2015?
The debugger will ignore the edit and you will see an error message when you continue execution and I get the following
“The source file has changed. It no longer matches the version of the
file used to build the application being debugged.”
You must set the Debug Information Format to be “Program Database for Edit and Continue (/ZI)”. If this option is incorrectly set the debugger will ignore the edit, it will be just like modifying a file with edit and continue disabled.
If you make an edit in a binary not compiled with this option, the debugger will ignore the edit and you will see an error message when you continue execution “The source file has changed. It no longer matches the version of the file used to build the application being debugged.”
Open the Property Pages of the project.
Under Configuration Properties -> C/C++ -> set the Debug Information
Format to “Program Database for Edit and Continue (/ZI)”
Edit & Continue has only been introduced in VS2015, therefore this option is not available on earlier versions.
Related
I am using VSCode to debug a C++ project configured and built using CMake tools (extension in VScode).
I have to use below command to trigger the execution:
./cbs_ta -i ifile.yaml -o ofile.yaml
As you can see, there are two command line inputs (-i and file name for input file) (-o and file name for output file). I read that using "args" parameter in launch.json, we can pass command line arguments. So I modified "args" in launch.json as follows:
"args": ["-i", "ifile_1.yaml", "-o", "ofile_1.yaml"],
Unfortunately, I am getting error that
the option '--input' is required but missing
I used CMake Tools extension to configure and build the targets.
Please help.
Edit: I have identified that when I click "debug" menu option in CMake in VSCode, the debug session starts but it does not take into consideration launch.json. I identified it since I kept ```"stopAtEntry": true''' but it did not stop at entry point.
It sounds like you have encountered the confusing 'extra' debug button which the CMake Tools extension places on the toolbar. The C/C++ extension's main debugger, configured via 'launch.json', needs to be invoked using the 'debug' view in the left side panel
(as do other debug extensions such as cortex-debug).
Once a debug configuration has been selected, a debug launch button is added to the status bar. This means that users of the CMake Tools extension will then have two different debug buttons on the status bar, which is confusing to say the least. Presumably in part because of this confusion, the CMake Tools extension has options which can be placed in 'settings.json' to remove the buttons it adds to the status bar, either selectively or all together. This is also a useful way to recover quite a bit of status bar real estate, if you don't often need to use things like the toolchain selector.
To remove all buttons added by CMake Tools:
"cmake.statusbar.visibility": "hidden"
And to selectively remove the debug launch button:
"cmake.statusbar.advanced": {
"debug": {
"visibility": "hidden"
}
}
I would expect most users to prefer the selective option, as things like the build target selector are fairly essential to most use cases.
The underlying issue here is that for some reason the CMake Tools extension does not use the standard extension point for debugging functionality, but instead just places an extra button on the status bar to invoke debugging directly without a configuration entry in 'launch.json'. The CMake Tools extension docs describe this as a 'quick' debug function, which suggests that their reason for this design decision is related to different use cases, although personally I can't really see a clear use case for it. Debugging is by its nature an activity which is highly dependent on configuration, as everything from the choice of actual debug program on down needs to be specified in most cases.
I made a simple hello world program. I clicked on "Start Debugging" and the window showed "Project is out of date. Would you like to build it?" As I click on "yes", the next window shows "There were build errors. Would you like to continue and run the last successful build?". I choose yes again, and it shows this window: (attached screenshot)enter image description here
There were build errors. Would you like to continue and run the last successful build?
The only correct answer to that question is "No". If you clicked "Debug", you obviously want to debug the current version of the source, not some stale old version that won't match what you're seeing in the editor.
Disable this nonsense message in Tools → Options → Projects and Solutions → Build and Run. For "On Run, when projects are out of date", set it to "Always build". For "On Run, when build or deployment errors occur", set it to "Do not launch".
I cannot think of a reason why you ever want the other options as default settings. If you want to launch an old, stale build, you can always do so manually.
I choose yes again, and it shows this window: "The system cannot find the file specified."
Yet another reason why this is a stupid setting. The second one in particular, the one that controls Run behavior when build errors occur.
What happens is, when you tried to build the project, the first step was to do a clean, which effectively means delete the old files. With the old files gone, it kicks off a build. The build fails, you get an error. You ask it to ignore the error and run an old version. But wait! The old version got deleted at the start of the build, so it no longer exists!
If a build fails, return to the IDE, fix the errors, and then relaunch to rebuild.
Bonus: The build error that you're getting is "fatal error C1010", which is a rather silly error that can be very confusing to those unaccustomed to Visual Studio. Basically, what it's telling you is that because you are using precompiled headers (the default for new projects), the very first line in every source file needs to be the inclusion of your precompiled header. By default, it is named stdafx.h, so the first line in your code file should be:
#include "stdafx.h"
This should go before you include the system header <iostream>. The precompiled header must be included at the very top of the file, or you'll get a build error.
If you do not like that, then you can turn off precompiled headers:
Right-click on your project in the Solution Explorer, and choose Properties.
At the top, click the "Configuration" combobox and select "All Configurations".
Expand "C/C++" in the tree view, and select "Precompiled Headers".
Set the top option, "Precompiled Header", to "Not Using Precompiled Headers".
Sorry: your last successful build was deleted earlier - possibly as a result of an attempted compile/link. You need to fix the source code that you've got now before you've got anything to debug...
It seems to appear that some .dll files are missing for the debug mode for many users.
You don't need to run the debug mode for this, if your program works on normal running, then let it run.
I also can see that you wrote void main() but in C++ the good syntax is int main() and terminated by a return 0; instruction. By the way, think about letting at least a space between #include and the libraries like <iostream> here.
I've got a C++ project in MSVS 2013, which causes problems when debugging: whenever I run a debug session, a message box shows up, saying "No Debug Information -- Debugging information for 'xy.exe' cannot be found or does not match. Cannot find the PDB file. Do you want to continue debugging?" This is a common issue and the question was asked several times, however, none of the answers I found so far apply to my case.
Project Properties -> Configuration Properties -> C/C++ ->
Optimization -> Optimization is disabled
Project Properties -> Configuration Properties -> Linker -> Debugging -> Generate Debug Info is turned on
Path and filename are correct; Project Properties -> Configuration Properties -> Linker -> Debugging -> Generate Program Database File is "$(OutDir)$(TargetName).pdb" (Output File is "$(OutDir)$(TargetName)$(TargetExt)", so there's no misconfiguration here either)
I tried deleting the file manually, restarting Visual Studio, cleaning and rebuilding. From the file timestamp I see it is indeed the PDB file just created, and both exe and pdb are built to the very same folder and are named correctly.
Someone suggested doublechecking the task manager and see if devenv.exe is still running in the background -- indeed, it was. I killed it, deleted PDB files, restarted, cleaned, rebuilt, no luck.
I switched the startup project to a different one and back, as a poster suggested [1]. No luck.
Somebody reported having this issue when the local PDB file of the main project has the same name as the final PDB file for the entire executable [2]. This is not the case here.
When I open the Modules Window [3], I see that for my exe, in the "Symbol Status" column, it says "Cannot find or open the PDB" file. When I try to right click -> Load Symbols, I see they are right there (e.g. xy.pdb for xy.exe). When I select them, a message box says "A maching symbol file was not found in this folder."
Interestingly, none of the projects in this solution work. Other projects, however, work withouth any problems. I tried to compare each and every setting in the project properties with the ones that work, but I cannot find any differences.
Any more ideas?
[1] https://stackoverflow.com/a/15378106/4508058
[2] https://stackoverflow.com/a/21640745/4508058
[3] https://stackoverflow.com/a/540599/4508058
Okay, a hint to future readers: now it is finally working. I noticed that the project shared it's intermediate directory with another project. However, just changing this, cleaning, rebuilding, even deleting the intermediate directory manually didn't help. But after some builds it finally worked, so it might have had something to do with it (?). So I don't have an absolute solution to the problem, but maybe it helps.
I sometimes still get the Linker error I mentioned in my comment above, though (LNK1209: program database 'D:\work-coding-\Projects\vrtheater\LoadingApp\bin\LoadingAppD.pdb') so there still might be something wrong...
The c++ compile also needs generate debug info /Zi. If that is also set, use windbg with !sym noisy to see where it is trying to load symbols.
I'm just diving into VC++ after a number of years in other areas of programming. I am puzzled by the errors that come up when I go from a debug version to a release version. I'm probably doing something stupid here...
For example, this code works fine for debug compiles:
ofn.lpstrFile = (LPSTR)title;
However, if I go to release mode, I get an error and have to put in a W:
ofn.lpstrFile = (LPWSTR)title;
What am I doing wrong? This is not a MFC program, it's really just a very simple program where I read a file, take the information from it to eliminate certain parts of another file, and then write the final file to disc.
This is because you have different settings in the Debug and Release configuration. Your debug configuration is set to have the character set "Not set" while the Release configuration is using "Use Unicode character set".
To change the character set go to the project properties, select your configuration and from Configuration Properties > General > Character Set select the same for all your configurations.
I have a C++ application, using VS2008, and i want to include the debug information into the binary so that i don't need to publish the ".pdb" file with my application. My application has made use of the dgbhelp.dll, and i do need those debug information so that i can get the source code line number when there's exception occurred. But without the ".pdb" file, my application failed to get the line number, and it would be better if i can include the debug info in the ".pdb" file into the binary.
According to the documentation, you need /Z7 instead of /Zi. (I've never tried it though.)