I am aware of the Debugger
class within the System.Diagnostics
namespace which has the IsAttached
property.
我知道System.Diagnostics命名空间中具有IsAttached属性的Debugger类。
Is there a property, somewhere, that can augment this call and tell me if we're actually stepping through code, rather than simply just being attached? I understand this may be highly unlikely, but it would be useful to know.
在某个地方是否有一个属性可以增加这个调用并告诉我,如果我们实际上是在逐步执行代码,而不仅仅是简单地附加?我知道这可能不太可能,但知道它会很有用。
EDIT
Perhaps a better question, rather than "stepping" is running some code:
也许一个更好的问题,而不是“踩踏”运行一些代码:
- When the debugger "breaks" for the first time (enters debug mode, after being attached)
- When it runs again (but is still attached, but not "stepping through").
当调试器第一次“中断”时(进入调试模式,附加后)
当它再次运行时(但仍然附着,但不是“踩踏”)。
1 个解决方案
#1
2
You can get the debugger state from the Debugger.CurrentMode property. But that's only going to tell you whether it is currently in the break state or if the program is running. There is no "step" mode, that's a fleeting moment which pretty much ensures that, if you could find about it, that acting on it would already be too late. Practically guaranteed to be a threading race.
您可以从Debugger.CurrentMode属性获取调试器状态。但这只会告诉你它目前是处于休息状态还是程序正在运行。没有“步进”模式,这是一个短暂的时刻,几乎可以确保,如果你能找到它,那么采取行动就已经太晚了。实际上保证是一个穿线比赛。
#1
2
You can get the debugger state from the Debugger.CurrentMode property. But that's only going to tell you whether it is currently in the break state or if the program is running. There is no "step" mode, that's a fleeting moment which pretty much ensures that, if you could find about it, that acting on it would already be too late. Practically guaranteed to be a threading race.
您可以从Debugger.CurrentMode属性获取调试器状态。但这只会告诉你它目前是处于休息状态还是程序正在运行。没有“步进”模式,这是一个短暂的时刻,几乎可以确保,如果你能找到它,那么采取行动就已经太晚了。实际上保证是一个穿线比赛。