从应用程序内观察堆栈上的值类型和堆上的对象
如果这是一个愚蠢的问题,请原谅我。当应用程序(例如控制台应用程序)运行时,可以以编程方式“观察”堆栈和堆的内容吗?有没有 API 可以做到这一点?
Forgive me If this is a dumb question. Can one programmatically "observe" the contents of stack and heap while an application (say a console app) is running? Are there any APIs which would do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您可以尝试使用 CLR 调试器 API - 尽管我不确定您是否可以在同一进程中使用它。但是,我认为可能有更好的解决方案......您实际上想做什么?这里的大局是什么?
Well, you could try using the CLR Debugger API - although I'm not sure whether you can use that within the same process. However, I think it's likely that there's a better solution... what are you actually trying to do? What's the bigger picture here?
我不知道,尽管一些非托管代码可以轻松跟踪堆栈,而跟踪堆则需要考虑 GC,因为指针可以在每次 GC 之后移动。
现在,由于唯一可以更改变量的应用程序是控制台应用程序(!),那么为什么要这样做呢?当然,您只会跟踪您自己在应用程序中所做的事情。是为了修复错误吗?在这种情况下,我建议您进行代码审查而不是黑魔法。
I do not know although some unmanaged code can easily track the stack while tracking heap requires considering GC since pointers can move after each GC.
Now, since the only application that can change variable is your console application (!) so why would you wanna do that? Surely you will be only tracking what you are doing yourself in the application. Is it for bug-fixing? In that case I recommend you do code review instead of black magic.