如何“编辑并继续”在Visual Studio中工作? [英] How does "Edit and continue" work in Visual Studio?

查看:373
本文介绍了如何“编辑并继续”在Visual Studio中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直觉得这是一个非常有用的功能在Visual Studio。对于那些不知道它的人,它允许您在调试正在运行的进程时编辑代码,在二进制文件仍在运行时重新编译代码 并继续使用应用程序新代码,无需重新启动它。

I have always found this to be a very useful feature in Visual Studio. For those who don't know about it, it allows you to edit code while you are debugging a running process, re-compile the code while the binary is still running and continue using the application seamlessly with the new code, without the need to restart it.

如何实现此功能?如果我修改的代码是在应用程序加载的DLL,应用程序只是卸载DLL并重新加载它吗?这似乎在我喜欢它会容易不稳定的问题,所以我认为它会比这更聪明。任何想法?

How is this feature implemented? If the code I am modifying is in a DLL loaded by the application, does the application simply unload the DLL and reload it again? This would seem to me like it would be prone to instability issues, so I assume it would be smarter than this. Any ideas?

推荐答案

我的理解是,当应用程序编译支持编辑和继续启用,围绕二进制映像中的函数,以允许添加附加代码。然后调试器可以编译新版本的函数,替换现有版本(根据需要使用填充空间),修复堆栈,设置指令指针并继续运行。

My understanding is that when the app is compiled with support for Edit and Continue enabled, the compiler leaves extra room around the functions in the binary image to allow for adding additional code. Then the debugger can compile a new version of the function, replace the existing version (using the padding space as necessary), fix up the stack, set the instruction pointer, and keep going. That way you don't have to fix up any jump pointers, as long as you have enough padding.

请注意,编辑和继续通常不适用于代码,因此, libs / dlls,只有主可执行代码。

Note that Edit and Continue doesn't usually work on code in libs/dlls, only with the main executable code.

这篇关于如何“编辑并继续”在Visual Studio中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆