locked
Can't stop the ICorDebugProcess object that is returned by OpenVirtualProcess()

    Question

  • Hi,

    I'm afraid I need a little help with dump debugging. I've implemented the ICorDebugDataTarget and ICLRDebuggingLibraryProvider interfaces to read data from a full memory dump file (for now). I think both of them work correctly. I have verified the former implementation using WinDbg as it was suggested by Rick Byers in another thread. I can also call the ICLRDebugging::OpenVirtualProcess() method successfully and it returns me a proper ICorDebugProcess object. But again, I'm a bit stuck here...

    If I call the IsRunning() method on the returned ICorDebugProcess object then that returns true. But if I call Stop() then I get an E_NOTIMPL error. And of course, all other method calls (like EnumerateAppDomains()) return E_FAIL since the process is running.

    So, I have 2 questions:
    1. How can I stop the process and inspect it? I suppose I can get back information from the ICorDebug* objects and I don't have to read the list of threads/modules etc. from the dump file.
    2. Since I don't have any ICorDebug object how can I specify my ICorDebugManagedCallback implementation? I will need callbacks for function evaluation.

    Thank you for the help in advance.

    Regards,
      Zsolt Petreny

    Sunday, July 04, 2010 9:38 AM

Answers

  • Hi,

    And my call stack problem is solved as well. This was pretty easy actually. I just had to use the new ICorDebugThread3:CreateStackWalk() method instead of ICorDebugThread:EnumerateChains().

    To sum it up:
    1. Now I can use the ICorDebugProcess.
    2. Using the ICorDebugProcess I can get back the list of threads, modules etc.
    3. Using the ICorDebugThread3:CreateStackWalk() method I can get back the call stack and from each IL frame I can get local variables, arguments just like earlier.
    4. I can inspect objects in memory, get their fields etc.

    So, I'm almost done. Only 1 more feature is missing: method evaluation. And that's where I'll need the IL interpreter I think. I really hope that it's a public API and not just a custom solution for VS. I'd be glad if anyone could share information about it.

    Regards,
      Zsolt Petreny

    P.S.: I hope my previous comments will be valuable for other debugger developers as well. :-)

    • Marked as answer by SamAgain Friday, August 06, 2010 8:57 AM
    Sunday, July 18, 2010 7:03 AM
  • Hi,

    At last, I have managed to solve my first problem. I've noticed that the OpenVirtualProcess() method calls the Release() method of my ICorDebugDataTarget so I thought I'd call an AddRef() on it before passing it to the OpenVirtualProcess() method and seems like that did the trick. Now I can use the returned ICorDebugProcess more or less. I can get the list of loaded modules, threads and the current exception from it. Although interestingly the ICorDebugThread:EnumerateChains() method returns E_NOTIMPL and the ICorDebugThread:GetActiveFrame() method returns null in all cases so now I'm wondering how I'm supposed to get the call stack, local variables and arguments. But hopefully, I'll be able to figure out this one as well.

    Anyway, I'm still interested in the IL interpreter that Visual Studio uses. :-)

    Regards,
      Zsolt Petreny

    • Marked as answer by SamAgain Friday, August 06, 2010 8:57 AM
    Saturday, July 17, 2010 7:41 PM

All replies

  • Hi,

    I think I have found the answer to the 2nd question. According to Mike Stall's blog entry (http://blogs.msdn.com/b/jmstall/archive/2009/05/21/virtual-code-execution-via-il-interpretation.aspx) VS2010 is using an "IL interpreter" for evaluating expressions (I know, I know, this can be enabled/disabled in VS when a dump file is opened, I just didn't pay so much attention to it :-) ). So, I guess my 2nd question is rather what this IL interpeter is and whether it's a proper API that I could use. Unfortunately, I couldn't find any documentation or technical description of it.

    Regards,
      Zsolt Petreny

    Sunday, July 11, 2010 2:04 PM
  • Hi,

    At last, I have managed to solve my first problem. I've noticed that the OpenVirtualProcess() method calls the Release() method of my ICorDebugDataTarget so I thought I'd call an AddRef() on it before passing it to the OpenVirtualProcess() method and seems like that did the trick. Now I can use the returned ICorDebugProcess more or less. I can get the list of loaded modules, threads and the current exception from it. Although interestingly the ICorDebugThread:EnumerateChains() method returns E_NOTIMPL and the ICorDebugThread:GetActiveFrame() method returns null in all cases so now I'm wondering how I'm supposed to get the call stack, local variables and arguments. But hopefully, I'll be able to figure out this one as well.

    Anyway, I'm still interested in the IL interpreter that Visual Studio uses. :-)

    Regards,
      Zsolt Petreny

    • Marked as answer by SamAgain Friday, August 06, 2010 8:57 AM
    Saturday, July 17, 2010 7:41 PM
  • Hi,

    And my call stack problem is solved as well. This was pretty easy actually. I just had to use the new ICorDebugThread3:CreateStackWalk() method instead of ICorDebugThread:EnumerateChains().

    To sum it up:
    1. Now I can use the ICorDebugProcess.
    2. Using the ICorDebugProcess I can get back the list of threads, modules etc.
    3. Using the ICorDebugThread3:CreateStackWalk() method I can get back the call stack and from each IL frame I can get local variables, arguments just like earlier.
    4. I can inspect objects in memory, get their fields etc.

    So, I'm almost done. Only 1 more feature is missing: method evaluation. And that's where I'll need the IL interpreter I think. I really hope that it's a public API and not just a custom solution for VS. I'd be glad if anyone could share information about it.

    Regards,
      Zsolt Petreny

    P.S.: I hope my previous comments will be valuable for other debugger developers as well. :-)

    • Marked as answer by SamAgain Friday, August 06, 2010 8:57 AM
    Sunday, July 18, 2010 7:03 AM
  • Hi,

      Thanks for sharing your achievements with us. It is of great help to others who have similar problems.


    Please mark the right answer at right time.
    Thanks,
    Sam
    Friday, August 06, 2010 8:59 AM
  • Hi Sam,

    Unfortunately my last question about the IL interpreter is still not answered. But this thread is already a bit messy so I'll just start a new one for my remaining question. I hope you don't mind it. :-)

    Regards,
      Zsolt Petreny

    Saturday, August 07, 2010 4:42 PM