Re: Debugger API

From: Jan Stranik (jstranik_at_online.microsoft.com)
Date: 09/15/04

  • Next message: Notre Poubelle: "Re: Dynamically creating satellite assemblies with embedded resour"
    Date: Wed, 15 Sep 2004 19:06:15 GMT
    
    

    Hello Aniskevich,
    I understand the reading (and also writing) debugger code is non-trivial.
    The API is pretty complicated. On the other hand you
    need to expect non-trivial API for anything that is doing so powerfull
    operation as enabling debugging.

    I recommend you studying code in the corapi\debug directory first in the
    sample. Also, please refer to CorDebug.idl header file that describes
    what individual API do.

    If you want to learn more about the debugger, and would like to get to some
    more simplistic code, I would recommand, that you start with
    the mentioned sample and keep removing parts that you don't need.

    /jan

    --------------------
    | From: aniskevichsn@mail.ru (Sergey)
    | Newsgroups: microsoft.public.dotnet.framework.clr
    | Subject: Re: Debugger API
    | Date: 13 Sep 2004 23:00:17 -0700
    | Organization: http://groups.google.com
    | Lines: 115
    | Message-ID: <be01093e.0409132200.2c052a94@posting.google.com>
    | References: <#fXueyZkEHA.3788@TK2MSFTNGP14.phx.gbl>
    <dcAuBkbmEHA.404@cpmsftngxa06.phx.gbl>
    | NNTP-Posting-Host: 195.225.130.127
    | Content-Type: text/plain; charset=ISO-8859-1
    | Content-Transfer-Encoding: 8bit
    | X-Trace: posting.google.com 1095141617 7566 127.0.0.1 (14 Sep 2004
    06:00:17 GMT)
    | X-Complaints-To: groups-abuse@google.com
    | NNTP-Posting-Date: Tue, 14 Sep 2004 06:00:17 +0000 (UTC)
    | Path:
    cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
    e.de!news.glorb.com!postnews2.google.com!not-for-mail
    | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.clr:11802
    | X-Tomcat-NG: microsoft.public.dotnet.framework.clr
    |
    | Thanks for your answer.
    | I studied before your example
    |
    (http://www.microsoft.com/downloads/details.aspx?familyid=38449a42-6b7a-4e28
    -80ce-c55645ab1310&displaylang=en),
    | however it very complex and I has got confused.
    |
    | If it is possible, send, please, the simple example in which occurs
    | creation ICorDebug, ICorDebugManagedCallback and calling method
    | CreateProcess.
    |
    |
    | Beforehand thanks.
    | e-mail: aniskevichsn@mail.ru
    |
    | jstranik@online.microsoft.com (Jan Stranik) wrote in message
    news:<dcAuBkbmEHA.404@cpmsftngxa06.phx.gbl>...
    | > Hello Aniskevich,
    | > from your code snippet I cannot determine why is your code not working.
    | > Generally it is possible to write a debugger in managed code.
    | > We have a complete sample of managed debugger written in C#, feel free
    to
    | > refer to it for your needs,
    | > The sample is located at:
    | >
    http://www.microsoft.com/downloads/details.aspx?familyid=38449a42-6b7a-4e28-
    | > 80ce-c55645ab1310&displaylang=en.
    | >
    | > Regards
    | > /jan
    | >
    | > --------------------
    | > >From: Aniskevich Sergey via .NET 247 <anonymous@dotnet247.com>
    | > >X-Newsreader: AspNNTP 1.50 (Matthew Reynolds Consulting)
    | > >Subject: Debugger API
    | > >Mime-Version: 1.0
    | > >Content-Type: text/plain; charset="us-ascii"
    | > >Content-Transfer-Encoding: 7bit
    | > >Message-ID: <#fXueyZkEHA.3788@TK2MSFTNGP14.phx.gbl>
    | > >Newsgroups: microsoft.public.dotnet.framework.clr
    | > >Date: Fri, 03 Sep 2004 02:58:52 -0700
    | > >NNTP-Posting-Host: 81-86-69-114.dsl.pipex.com 81.86.69.114
    | > >Lines: 1
    | > >Path:
    | >
    cpmsftngxa10.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP0
    | > 8.phx.gbl!TK2MSFTNGP14.phx.gbl
    | > >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:11779
    | > >X-Tomcat-NG: microsoft.public.dotnet.framework.clr
    | > >
    | > >I am have problem with Debugging API under C# (Framework 2.0). A am
    run
    | > Debugged process as follows:
    | > >
    | > >int size;
    | > > GetCORVersion(null, 0, out size);
    | > > Debug.Assert(size > 0);
    | > > StringBuilder sb = new StringBuilder(size);
    | > > int hr = GetCORVersion(sb, sb.Capacity, out size);
    | > >
    | > > CreateDebuggingInterfaceFromVersion(3, sb.ToString(), out
    | > m_ICorDebug);
    | > > Debug.Assert(m_ICorDebug != null);
    | > >
    | > > m_ICorDebug.Initialize();
    | > > CManagedCallback _mc = new CManagedCallback(this);
    | > > m_ICorDebug.SetManagedHandler(_mc);
    | > >
    | > >
    | > > PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
    | > >
    | > > STARTUPINFO si = new STARTUPINFO();
    | > > si.cb = Marshal.SizeOf(si);
    | > >
    | > > // initialize safe handles
    | > > si.hStdInput = new
    | > Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false);
    | > > si.hStdOutput = new
    | > Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false);
    | > > si.hStdError = new
    | > Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false);
    | > >
    | > > //constrained execution region (CER)
    | > >
    | >
    System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
    | > > string commandLine = "WindowsApplication1.exe";
    | > > string applicationName = null;
    | > > int flags = 0;
    | > > string currentDirectory = ".";
    | > > IntPtr environment = new IntPtr(0);
    | > >
    | > > m_ICorDebug.CreateProcess(
    | > > applicationName,
    | > > commandLine,
    | > > null,
    | > > null,
    | > > 1,
    | > > (uint)flags,
    | > > environment,
    | > > currentDirectory,
    | > > si,
    | > > pi,
    | > >
    | > CorDebugCreateProcessFlags.DEBUG_NO_SPECIAL_OPTIONS,
    | > > out m_ICorDebugProcess);
    | > >
    | > > CloseHandle(pi.hThread);
    | > > CloseHandle(pi.hProcess);
    | > >
    | > >
    | > >
    | > >But one function of a class (CManagedCallbck :
    ICorDebugManagedCallback)
    | > is not callback.
    | > >In what a problem?
    | > >
    | > >Best regards
    | > >
    | > >-----------------------
    | > >Posted by a user from .NET 247 (http://www.dotnet247.com/)
    | > >
    | > ><Id>SOeem8tB8UWHhvFHTwmSdA==</Id>
    | > >
    |


  • Next message: Notre Poubelle: "Re: Dynamically creating satellite assemblies with embedded resour"

    Relevant Pages

    • Re: Why does tsSource[j].Text.ToUpper() causes side effects
      ... there's something about the API that prevents the debugger from doing ... but my debugger doesn't complain when I call ... but I find all this discussion about methods vs. properties to be tangential to the real question. ... But either way I don't see how lecturing on the question of .NET API design is helping me toward that goal. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: winsock2 trouble
      ... Paul, thanks! ... I found the tcphelper API and that apparently does what I was looking for. ... Only now my debugger frequently crashes the mobile device ... >> which lists WSAIoctl as available but is either incomplete or lacking ...
      (microsoft.public.windowsce.embedded.vc)
    • Re: IntPtr != HANDLE conversion problem
      ... > an abstraction used by the OS API. ... > A first-chance exception is not necessarily a bad thing. ... > That's how the OS Exception Handling interacts with the debugger: ... it returns the proper handle. ...
      (microsoft.public.dotnet.languages.vc)
    • Re: Get the status of a running application
      ... If you want to give it a shot, I suggest you take a look at ... existing debugger (cdb+sos or cordbg) and use its output (in-fact I believe ... > You can use the debugger API to do this, but it's a lot of work. ...
      (microsoft.public.dotnet.framework.clr)
    • *weird* overflow error *after* API call; call works OK, but later simple steps fail
      ... I have a VB application that makes a API call, returns OK, but which then ... Private Function DoGetEntityAs Long ... Running this in the debugger or as an EXE results in an overflow on the ... Other OSs I have used jave a calling standard that says 'save & restore ...
      (microsoft.public.vb.winapi)