简体   繁体   中英

How to change a variable value on conditional breakpoint in visual studio 2015

Is there any way to change value of variable to on a conditional breakpoint and continue execution.

My code is like this

switch(var){ //conditional breakpoint on this line
    case 1:
    break;
...
}

I put conditional breakpoint like below (var == 0 ) || (var ==1) (var == 0 ) || (var ==1) is true

So when this breakpoint hits, I want to change var = 2 , and continue execution.

What I found: I found Action also, but it only log messages. Is there any way to executing a statement like var = 2 as Action taken on this conditional breakpoint.

I don't want to change code because building it takes hell lot of time.

Note: I am working C++ on Visual studio 2015

In Log a message to Output Window write {my_variable=12345} the side effect of log output is assigning 12345 to my_variable .

Take into account that Log a message can accept and evaluate complex expressions in curly braces.

您可以直接在内存中修改变量,以通过快速监视 (Shift + F9)或Visual Studio中的监视窗口来更改执行流程。

Make sure that in Tools / Options / Debugging you have the "Enable Edit and Continue" Enabled/Checked and then you will be able to edit your code while debugging and continue without the need to rebuild or to stop execution.

More information can be found in How to: Enable and Disable Edit and Continue

This used to work, I can't seem to get it to work now. Worked excellent on loops and also good for altering values without altering the source or the code (and accidently committing it).

Conditional break point, break if true

(url = "http://localhost:1234/") != url

This works thanks to assignment always returns it's assigned value. This will never be true as url becomes localhost

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM