Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

已鎖定 Mdbg API - Possible to load symbols from disk?

  • Wednesday, April 11, 2012 1:29 PM
     
      Has Code

    Hi. I recently start using the mdbg API (or tried to)

    For testing purposes I wrote some little C# HelloWorld console application which I then

    tried to debug.

    Here is the debug code:

    static MDbgBreakpoint _BreakPoint;
    static AutoResetEvent _AutoResetEvent = new AutoResetEvent(false);
    
    [MTAThread]
    static void Main(string[] args)
    {
         string nameApplication = "./toDebug/HelloWorld.exe";
    
         MDbgEngine debugger = new MDbgEngine();
    
         debugger.Options.CreateProcessWithNewConsole = true;
         debugger.Options.StopOnModuleLoad = true;
         debugger.Options.StopOnAssemblyLoad = true;
    
         // Launch the debuggee.            
         MDbgProcess proc = debugger.CreateProcess (nameApplication, "", DebugModeFlag.Debug, null);
               
         _BreakPoint = proc.Breakpoints.CreateBreakpoint("./toDebug/HelloWorld.cs", 9);
    
         while (proc.IsAlive)
         {
             proc.Go().WaitOne();
             object o = proc.StopReason;
    
             Console.WriteLine(o.ToString());
    
         }
         
         Console.WriteLine("Done!");
         Console.ReadKey();
    }

    Within the folder "toDebug" there are HelloWorld.cs, HelloWorld.exe and HelloWorld.pdb

    When the Module gets loaded the breakPoints which are unbound shall be bound in CorDebug.

    This raises a COM Exception of type Symbols are not supplied for modules loaded from disk. (Exception from HRESULT: 0x80131C3A), in the CorModul which is ignored by the lines:

    // Common error cases - no symbols available or module is loaded

    // from disk so symbols not in-memory if ((e.ErrorCode == unchecked((int)HResult.CORDBG_E_SYMBOLS_NOT_AVAILABLE)) || (e.ErrorCode == unchecked((int)HResult.CORDBG_E_MODULE_LOADED_FROM_DISK)) ) { return null; }

    Is there any way to load symbols from disk or am I doing something completely wrong?

    The near goal is to just be able to hit breakpoints and see the corresponding line in this simple C# application.

    Later I would like to do the same with a Boo program.

    With kind regards

    Tobias


    • Edited by Tobi_B Wednesday, April 11, 2012 1:35 PM removed blank lines
    •  

All Replies

  • Thursday, April 12, 2012 7:12 AM
     
     Answered

    How can one be that stupid... (You don't have to answer to this question)

    I have the solution.

    The Problem was, that my breakpoint did not get bound an I thought that would be because of the

    exception I mentioned above. But the Problem was my own fault.

    To save some time writing the longer path to the source file I copied the pdb, the cs and the exe file to

    the binary folder of my debugger, and told him to set a breakpoint in the cs file.

    Of course the URL inside the pdb file still links to the original location of the cs file and as this does not

    match to the path I provided, the hole thing will not work. Telling the debugger to set a break point in the original cs file which the pdb file links to - oh what a miracle - it works.

    With kind regards

    Tobias

    • Marked As Answer by Tobi_B Thursday, April 12, 2012 7:12 AM
    •  
  • Thursday, April 12, 2012 8:34 AM
    Moderator
     
     
    If you can share your solutions and experience here, it will be very beneficial for other community members who have similar questions.

    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us