1

I am writing a debugger for a VBScript host. My debugger is an external application. Everything is fine. I get a call to my IApplicationDebugger::onHandleBreakPoint handler. I can call IDebugApplication::ResumeFromBreakPoint and I can step through the code.

Also it is possible to set breakpoints before I run the script. Again IApplicationDebugger::onHandleBreakPoint is called. Also errors are handled. But now I want to set a new breakpoint while I am suspended in IApplicationDebugger::onHandleBreakPoint.

I have a marshaled pointer to IActiveScriptDebug. But when I call IActiveScriptDebug::EnumCodeContextsOfPosition the application blocks. This seams logical for me. The thread with the IActiveScript (IActiveScriptDebug) object resides in a different STA and is still blocked in the debugger as documented.

But what is the correct way to access the Language engine from my debugger thread. All I need is a IDebugCodeContext or IEnumDebugCodeContexts interface for a specific line of code. Am I missing a different interface that I can access to achive the same functionality.

xMRi
  • 14,982
  • 3
  • 26
  • 59

1 Answers1

1

The main solution is to use a IDebugSyncOperation with a call to CreateAsyncDebugOperation. This allows me to contact the blocked language engine that is currently debugged.

The next problem is that some of the interfaces that I need to set a breakpoint (IDebugApplication32 and IDebugApplicationThread) can not be marshaled to a different process.

It is possible to use this interfaces in the process that hosts the VBScript language engine and they can be used inside this application freely.

So the solution for my problem is, to contact the debugged application from my external debugger EXE and perform all the operations to set the breakpoint inside the debugged application.

It was a hard way to find out that some interfaces of the debugging interface are free to marshal to different apartments and others are not.

All this stuff isn't documented at all. Sadly :(

xMRi
  • 14,982
  • 3
  • 26
  • 59
  • Could you share some links on you were able to start. Example: how do you "attach" your debugger IDE to a running application? – manuell Dec 07 '14 at 17:56
  • The best I found (and even this one is buggy) is this article: http://msdn.microsoft.com/en-us/magazine/cc301316.aspx You still need to do some changes to get it run... – xMRi Dec 08 '14 at 08:43
  • Thank you so much for that link. Source code is unavailable, however. Where did you find it? – manuell Dec 08 '14 at 09:08
  • This link works for me: http://download.microsoft.com/download/0/6/7/0678184e-905e-4783-9511-d4dca1f492b4/oct99VP.exe – xMRi Dec 08 '14 at 09:16
  • Ok, got it. It's two vc6 projects (ScriptControlSvr and usescriptcontrol). Are you sure that's the "SampleDebugger" source code? – manuell Dec 08 '14 at 09:30
  • 1
    No. Doesn't seam to be the correct code. Here a link to my dropbox. https://www.dropbox.com/s/o4pqikirlwvw1ye/pellegrino.exe?dl=0 – xMRi Dec 08 '14 at 13:05
  • Man, I owe you something, now. – manuell Dec 08 '14 at 15:10