积极答复者
mdbg启用“仅我的代码”后无法调试

问题
-
最近做一个项目,需要实现在线调试功能,就是在网页上调试程序。
然后找到了这个东西https://msdn.microsoft.com/zh-cn/library/ms229861(v=vs.110).aspx
初步尝试了一下发现可以实现命令行调试,并且找到了它的源码
大概看了一下源码,尝试稍微修改下然后配合SignalR实现在线调试
实现的过程中发现了一个问题,它默认会走到.net源码里面去,也就是关闭了“仅我的代码”这个功能
在源码里面找了一下,确实默认是关闭的,然后手动把这个选项打开,也就修改了源码的一个字段值,从false改成了true
public CorStepper Step() { EnsureNotYetStepped(); m_HasIssuedStep = true; // // 1. Create the stepper on the proper thread / frame. // CorThread thread = m_thread; if (thread == null) { thread = m_process.Threads.Active.CorThread; } CorStepper stepper; if (m_frame == null) { stepper = thread.CreateStepper(); } else { stepper = m_frame.CreateStepper(); } Debug.Assert(stepper != null); // // 2. Set the flags // stepper.SetUnmappedStopMask(m_StopMask); stepper.SetInterceptMask(m_InterceptMask); if (m_isJmc)//把这个字段值从false改成了true { stepper.SetJmcStatus(true); } stepper.SetRangeIL(m_isRangeIl); // // 3. Issue the proper Step() command. // // 3a. Step-out if (m_type == StepperType.Out) { stepper.StepOut(); return stepper; } // // Step In-Over // bool stepInto = (m_type == StepperType.In); if (m_stepRanges == null) { // 3b. Single-Step In/Over, no ranges stepper.Step(stepInto); } else { // 3c. Step-range in/over. stepper.StepRange(stepInto, m_stepRanges); } return stepper; }
以为这样就搞定了,结果······
在改之前,单步步过、步入、步出都是正常的,只不过会走到.net源码里面去,改了之后,这些全都失效了
没有错误提示,具体表现为,断点断住之后,我只要执行这三个操作的任意一个操作,代码都会直接走到底,失去了控制,像是执行了“继续”命令
后来谷歌找了一下mdbg如何打开just my code功能,结果在msdn找到了答案:mdbg没考虑过要支持这个功能
我觉得是可以支持的,只是我不知道要怎么做
找到SharpDevelop的源码,发现两者的实现差距有点大,不想改成用它的
那么要怎么改代码才能实现?
谢谢大家!
- 已编辑 馨辰 2016年1月3日 7:57 改进问题
答案
-
被一个我忽略了N次的文章解决了,如果早点认真看那篇文章或许已经搞定了。
文章地址:http://blogs.msdn.com/b/jmstall/archive/2005/08/23/icordebug-jmc-stepping-.aspx
重点段落:What about Just-My-Code?
文章中讲了四个接口要设置JMC,而mdbg里面只有一个地方设置了
我把四个全部设置之后,貌似就好了,还没有全部测试通过。
- 已建议为答案 Albert_Zhang 2016年1月4日 10:59
- 已标记为答案 馨辰 2016年1月6日 4:06
全部回复
-
被一个我忽略了N次的文章解决了,如果早点认真看那篇文章或许已经搞定了。
文章地址:http://blogs.msdn.com/b/jmstall/archive/2005/08/23/icordebug-jmc-stepping-.aspx
重点段落:What about Just-My-Code?
文章中讲了四个接口要设置JMC,而mdbg里面只有一个地方设置了
我把四个全部设置之后,貌似就好了,还没有全部测试通过。
- 已建议为答案 Albert_Zhang 2016年1月4日 10:59
- 已标记为答案 馨辰 2016年1月6日 4:06