Edit and Continue in VS2019 - c++

I've just updated a major C++ project from VS2010 to VS2019, and I'm having problems getting Edit and Continue to work like it used to, specifically in relation to the 'Require source files to exactly match the original version' setting (which I will refer to as the 'require match' setting, because it's shorter).
I'm used to running my program, making changes to the source code while it's running, then setting a breakpoint to catch the running application just before the changed code. When the breakpoint is hit, I could hit F5 to rebuild and continue.
In VS2019, it seems that Edit and Continue will not work without the 'require match' setting, but setting breakpoints in existing code cannot be done with 'require match' once any changes are made.
There's a couple of workarounds, but none are ideal. It's possible to turn on "require match" to build and run the program, then after some code changes are made, turn it off to set the breakpoint, then turn it back on again for the rebuild and continue. That's a huge pain. It's possible to use pause and continue to force a rebuild of any edits, but this only works if the code change is complete enough to build. If I want to break to inspect a variable, this doesn't work. Once or twice I did manage to set a breakpoint on changed code, and it automatically went to the stale code, which is acceptable, but I can't get this to happen now. Also, now I have breakpoints that are showing as valid on edited code that has been rebuilt and I know is running, but the breakpoints are not being hit.
Any solutions here, or does Edit and Continue simply not work as well as it used to?
Here's some pictures...
Firstly, while my program is running, I made some change to surfdraw_panels.cpp, then went to add a breakpoint. It shows the following message...
Then loads up a [stale] version of the code, with the breakpoint set in the stale code...
Other times, when I make a change, I get a different result, and it won't allow me to set a breakpoint at all... In VS2010, it was possible to turn off the 'require match' setting and still use 'Edit and continue', but VS2019 will not allow this, even though it is still the recommended 'solution' in the message!
Github project that shows the issue is below. It's a simple MFC app, dialog based, created by the new project wizard in VS2019. There is a single button on the dialog, and some simple code to do something in the button. To recreate the problem, start the app in the debugger, then make a change to OnBnClickedButton1(), and then try to set a breakpoint.
https://github.com/surfdabbler/MFCApplication1

Not quite understand your specific situation and operation, because there are not some pictures and code to explain the issue in detail.
But this function which I used could break into the changed code during debugging with require match option. You should move your cursor back to the changed code and then Debug the below code step by step. And when you move the cursor back to the changed code, vc++ project will rebuild the changed code automatically and you do not have to stop debugging and restart build.
Update 1
I also faced the same behavior in my side. And since we could not handle the issue here any more, I reported the issue on our DC Forum.
You can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention. And I hope the Team will give you a satisfactory reply.

Related

Breakpoints work differently than in examples

I'm coding in C++ with Visual Studio. As I'm following along in a YouTube tutorial by The Cherno, he suggests placing breakpoints in certain places. He places them there and they work. When I place them in the same places in my copy of his code, the debugger doesn't run them (the red circle which marks breakpoints turns black upon debugging). The particular place I'm trying to break at is the initialization of a variable as an integer.
I notice that every place I try to put a breakpoint besides the first bracket of my main() turns black and doesn't run.
This is what The Cherno's code looks like with one working breakpoint.
This is what my code looks like. If I move the first breakpoint down to where his is, it doesn't run. Also note no other breakpoint runs.
I have made sure I'm running in debug mode.This is my screen before I press F5 to run, note "debug" selected in dropdown menu.
I have also made sure optimizations are disabled in the C++ section of the properties menu of my project.
You're building in Release mode. Change your build to Debug mode. Release builds are hard to debug, because many lines of code are compiled together, and thus cannot be individually broken upon. If your breakpoints don't get set or hit properly, it's because you're in Release mode.
I suggest you could check whether the Solution Configuration and Properties settings are consistent.
Moreover, it is not recommended that you set breakpoints on the { and } of the if, which will cause conditional compilation. Also, compResult is false, which means that the program cannot enter if (compResult){}.
Besides, I suggest that you could clean and rebuild the program. You could try to lear the Require source files that exactly match the original version option in Debug->Options->Debugging->General.

Chromium-browser build fatal errors in module_list.cc: Check Failed

I've been trying to build chromium on Windows 10, but I am getting weird errors on runtime, which appear to be caused by that pattern:
void CheckFreeLibrary(HMODULE module) {
BOOL result = ::FreeLibrary(module);
DCHECK(result);
}
The first errors are displayed after a few seconds after Chromium is started. Here's what it says:
[5904:9192:0726/025753:FATAL:module_list.cc(18)] Check failed: result.
Backtrace:
base:debug:StackTrace:StackTrace [0x0000....] (e:\projects\clones\chromium\src\base\debug\stack_trace.cc) ...
Since I couldn't copy paste the whole stack, I will join a screenshot of what it all feels like:
I am successful in building the last revision, or at least, it appears to be successful since no errors are showing up when compiling with the toolchain recommended in Building instructions.
Luckily, the first errors aren't modal and it is possible to browse a little bit afterwards. Then, if I put the application into heavy loading (such as Facebook newsfeed), it will suddently stop responding in a silent way. Mouse hovering effects will not show anymore and reloading the page will result in infinite loading. This behavior is also reproductible when right-clicking on some pages (e.g.: google's home page does it sometimes).
What could be an explanation of this not working "out of the box" with default configuration? How to fix this?
P.S.: This question is complementary to this question:
Windows chromium-browser fresh build stacktrace and anonymous fatal errors on runtime, if it can help getting the big picture of the question.
P.S.2.: I am currently trying to rebuild from start again with this slight change to see if it works out better. I will be able to see it after about 10 hours, though (yes, the build is painful on my current setup).
void CheckFreeLibrary(HMODULE module) {
BOOL result = ::FreeLibrary(module);
if (!result) {
result = ::UnmapViewOfFile(module);
}
DCHECK(result);
}
Update - 2016/07/29
Test with CheckFreeLibrary still failed in debug, but I finally found a way to resolve the issues in a build. See update 3 in superuser question. What I did was configuring the build into release mode via gn args. This is, obviously, almost impossible to debug with, so a solution / explanation is yet to be found about why it fails in debug mode. This is quite close now, though.
Update 2 - 2016/08/13
Started all over again to have a debug version again with the latest version in the repositories, and this time I was sure enough to find something. In fact, after I've run through the usual procedure to update, generate and build, I noticed that some win-core-* DLL libraries located in the Windows Kit debugger weren't copied src folder but one of those was assumed to be there during the link process. As a precaution, I've simply copied them all to be sure that any delay-load or build dependency was there. The first time chromium has launched, the errors didn't show up and thought it was resolving the issue. However, right-clicking on the Google Homepage had the same effect (no response, then browser not showing pages anymore). After closing and reopening it, errors are beginning to show up.
Is there anyone that had experienced that? I would be very happy with something like "do it on linux, it works better on this platform". I am not willing to do it without knowing it will work any better, though.
So
BOOL result = ::FreeLibrary(module);
fails in debug builds see if you have a
DWORD WINAPI GetLastError(void);
to get the real error.
I could guess
module not loaded
module is NULL
Perhaps some DEBUG statement is changing the value of module?

Django view won't stop at breakpoint using Eclipse environment

Looks like a stupid question, but I just can't make the code execution stop at breakpoint
I tried to run the project by both pressing F9 and F11, but it still does not stop at the breakpoint. I use the local url http://127.0.0.1:8000/task_list/ which should call the createTask view. And it does actually call the view, and everything works perfect with the only exception that the debugger ignores all my breakpoints
Most major ide's have two different ways of running normally,
Debug - This is usually denoted by some sort of bug image (as shown in your screenshot) or separate symbol
Run - This is usually a "play" button
The debug mode is the one you want, this is the one that inserts debug symbols. The run doesn't set any of these up so you will find that your program may run slightly faster this way, which makes it more advantageous when modifying files that don't require you to restart the server.

Attaching the debugger to a process doesn't seem to do anything

I've got a C++ application that doesn't quite work right. When I ask VisualStudio to run it, it runs just fine. But when I copy the compiled binary to its final location, it whinges about some sort of permissions problem.
I would dearly love to know exactly where it's getting stuck. According to this MSDN article, it's supposed to be possible to attach the VisualStudio debugger to an arbitrary process. But when I do this... nothing happens.
I copy my compiled binary to the right place, and run it. I leave it running, and switch back to VS. Go to Debug → Attach to process… and select my running program. VS clearly goes into debug mode, but... I can't see anything. The call stack is blank, it won't tell me what code is running... I can't do anything!
(Again: There's no error message. It seems to have connected just fine. It's just that nothing happens.)
Clearly a debugger that won't let you do anything is utterly pointless, so this obviously isn't what's supposed to happen. How do I make it so VS will actually show me what's running, let me poke variables, step through stuff, etc. You know, debug stuff?
(Again, this is unmanaged C++ code compiled to native machine code.)
The "Break All" button will break into a running process that you are attached to. It's the one that looks like a pause button.

XCode automatically deactivating breakpoints

I'm using xcode in C++. I'm trying to debug my project, but at random intervals, it seems to ignore my breakpoints. There are three things that it does:
1) Sometimes, when I run, it automatically switches to "de-activate break points" mode. (the relevant button goes light and says "Activate")
2) Sometimes when I run, ALL of my breakpoints go "can't find" mode, with the yellow insides. I need to click twice on them to get them back dark blue (once to light blue = inactive, once to dark blue = active)
3) Sometimes, when I run, my breakpoint is dark blue, the button says "deactivate" and it still just ignores my breakpoint, running straight past it.
This makes it very difficult to debug my program...
I should add that I'm using XCode 3.1 beta on OSX 10.5.6, in case that matters.
thanks.
Try unchecking the Load symbols lazy in the Debugging panel in Preferences
alt text http://img.skitch.com/20090209-gj947qk7dxdyms1wij4q5em2f2.jpg
Had the same problem but only restarting the iPhone Simulator seemed to fix it.
I faced the same issue right now.
I tried all the options : enabling the GCC, active, base targets and restarting and closing xcode, nothing solved.
I finally restarted the simulator and things have started working.
I have more or less the same set of issues, and this suggestion of loading symbols lazily unfortunately does not resolve it for me. Moreover, I am not developing for the iphone, just a regular application.
To be specific, sometimes I can't disable or enable breakpoints on the fly - sometimes my code doesn't stop in breakpoints which I later prove are being executed (with print statements) and nothing I can do will make it stop there - I see that very annoying debug symbol with an orange center, even though I only have one project active.
Quitting and restarting XCode occasionally has an effect - and annoyingly, there have been a very small number of cases where quitting and restarting or rebuilding from clean fixed hard-to-diagnose compilation/linking errors. Unfortunately, I just tried all of these with no effect.
(Unrelated, my keyboard shortcuts are also unreliable. My shortcut of F2 for continue worked for weeks for me, stopped working for a long time, was working this morning and now doesn't work at exactly the same breakpoint it worked before - yet my F1, step over, key has been completely reliable...)
I'm a little disappointed to have to do so much debugging with print statements!