VS的调试机制是如何工作的? [英] How the debugging mechanism of VS is really working ?

查看:125
本文介绍了VS的调试机制是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我现在正在使用一种脚本语言,它被解释为C#然后通过CSharpCodeProvidor进行编译..(我有自己的IDE用于脚本语言)



好​​吧,首先我想了解VS如何真正在运行时停止应用程序,然后更改(编译)代码,然后保存它并简单地恢复!



真的,我想在我的IDE中创建自己的调试器,如果我成功替换编译对象,就像VS正在做的那样我将能够为我自己的脚本设计一些实时编程和调试机制语言。



我想知道它是如何工作的第一个原因是因为实时编程(更改代码并恢复应用程序,而不是每次都重新启动)



,第二个原因是一些好的调试器(在拥有实时机制后不是必需的)

解决方案

< blockquote>



不错的问题和概念,但根据我的知识,如果你想调试那么整个应用程序将暂停,直到你实时恢复,如果你开始调试然后整个应用程序将进入睡眠状态并且请求将排队,直到它们超时,这是我的担忧。



很少有关于VS调试技术的信息。



http://visualstudiomagazine.com/articles/2010 /08/01/debugging-applications-with-intellitrace.aspx [ ^ ]

http://msdn.microsoft.com/en-us/magazine/ee410778.aspx [ ^ ]

http://blogs.msdn.com/b /jmstall/archive/2004/10/05/237954.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/microsoft.csharp.csharpcodeprovider.aspx [ ^ ]

http://msdn.microsoft.com/en-us/devlabs/debuggercanvas [ ^ ]

http://www.haskell.org/haskellwiki/ThreadScope [ ^ ]



[更新]



http://research.microsoft.com/pubs/161835/rivet.pdf [ ^ ]

http://research.microsoft.com/pubs/101301/esec099-ashok.pdf [ ^ ]

http://research.microsoft.com/en-us/projects/chess/ec2 -submission.pdf [ ^ ]

http://research.microsoft.com/酒吧/ 64516 /雷net-miningweblogs.pdf [ ^ ]

http://msdn.microsoft.com/en-us /library/bb384548.aspx [ ^ ] 阅读本文

http://msdn.microsoft.com/en-us/library/bb145587.aspx [ ^ ]


要做到这一点,你必须具备CLR的优秀知识,而且它是'内部行为和机制。如果没有它,你的所有尝试都将失败。



此外,你必须清楚地想象CLR如何与JIT编译器结合使用。



简而言之,您需要找到一种方法进入CLR,这样您就可以观察应用程序的行为(这可以通过使用分析器完成)。

公共语言运行库(CLR)分析器是一个动态链接库(DLL),它包含通过使用API​​从CLR接收消息并将消息发送到CLR的函数。

此DLL由clr在运行时。



分析API使用管理功能强制执行编译器(在JIT编译之前从例程更改内存中的MSIL代码流)。

以这种方式,profiler api可以动态地将检测代码添加到需要更深入调查的特定例程。

所以基本上,探查器DLL为你提供了很少的回调ICorProfilerInfo和ICorProfilerCallback,最后的o ne得到所有信息,如:函数入口,函数退出,第一个用于查询模块中的数据,检索元数据等。



所以我已经覆盖了它' '是完整机制的一小部分。

如果我很专心,你就在那个问题中提到C#标签。

我的意见,对C#的了解不会是够了,至少你必须知道C ++

如果有任何问题,请询问。


YES!



我在这里找到了一个非常有用的样本! (感谢Suvabrata Roy发布入门博客)



在同一个博客中,我在这里找到了一个很好的ICorDebug样本下载。

使用与VS中建立相同调试器所需的一切!



http://www.microsoft.com/en-us/download/details.aspx?id=19621 [ ^ ]


Hello everyone .
I am working right now on a script language which is interpreted to C# and then compiled via CSharpCodeProvidor .. (I have my own IDE for the script language)

Well , firstly i want to understand how really VS can actually stop the application at runtime and then change (compiled) code and then even save it and simply resume !

Really , i want to create my own debugger in my IDE and also if i will success to replace compiled objects somehow like VS is doing i will be able to design some Real-Time programming and debugging mechanism for my own script language .

The first reason i want to know how it works is because real-time programming (Change code and resume the application without restarting every time)

and the second reason is for some good debugger (which is not really necessary after having the real-time mechanism)

解决方案

Hi,

Nice question and concept, but as per my knowledge if you want to debug then the whole application will pause until you resume so in real time if you start debugging then whole app will go to sleep for while and requests will queued up until they are timed out so that was my concern.

Fallowing are few info on VS debugging technology.

http://visualstudiomagazine.com/articles/2010/08/01/debugging-applications-with-intellitrace.aspx[^]
http://msdn.microsoft.com/en-us/magazine/ee410778.aspx[^]
http://blogs.msdn.com/b/jmstall/archive/2004/10/05/237954.aspx[^]
http://msdn.microsoft.com/en-us/library/microsoft.csharp.csharpcodeprovider.aspx[^]
http://msdn.microsoft.com/en-us/devlabs/debuggercanvas[^]
http://www.haskell.org/haskellwiki/ThreadScope[^]

[Update]

http://research.microsoft.com/pubs/161835/rivet.pdf[^]
http://research.microsoft.com/pubs/101301/esec099-ashok.pdf[^]
http://research.microsoft.com/en-us/projects/chess/ec2-submission.pdf[^]
http://research.microsoft.com/pubs/64516/minenet-miningweblogs.pdf[^]
http://msdn.microsoft.com/en-us/library/bb384548.aspx[^] Read this one
http://msdn.microsoft.com/en-us/library/bb145587.aspx[^]


Well to do that you must have an excellent knowledge in CLR and it''s internall behavior and mechanism. Without it all your attempts will fail.

Also you must have clear imagination of how CLR work with conjunction of JIT compiler.

In brevity, you need to find a way to hhok up into the CLR so you comp can obser the behaviour of your app (this can be done by using a profiler).
A common language runtime (CLR) profiler is a dynamic link library (DLL) taht consist of functions that receive messages from and, send the messages to the CLR by using API.
This DLL is loaded by the clr at runtime.

The profiling API enforces your compiler with management functionality (to change the in-memory MSIL code stream from a routine before it will be JIT compiled).
in this manner profiler api can dynamically add instrumentation code to particular routines that need deeper investigatrion.
So basically profiler DLL provide you with few callbacks ICorProfilerInfo and ICorProfilerCallback, the last one get all information like :function entry, function exit , first one is implemented to query data from modules , retreive it metadata etc.

So all i have covered it''s a tiny part of full mechanism.
And if i was attentive, you mention C# tag in that question.
My opinion, that knowledge of C# won''t be enough, at least you must know C++
So if any questions , please ask.


YES !

I have found here a very useful sample ! (Thanks to Suvabrata Roy for posting the entry blog)

In same blog i found here a download for a good sample of ICorDebug using .
With everything needed to establish same debugger as in VS !

http://www.microsoft.com/en-us/download/details.aspx?id=19621[^]


这篇关于VS的调试机制是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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