Debugger API
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.clr.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Aniskevich Sergey via .NET 247 (VIP)
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>
Reply to this message...
 
    
Jan Stranik (VIP)
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

--------------------
[Original message clipped]

8.phx.gbl!TK2MSFTNGP14.phx.gbl
[Original message clipped]

Reply to this message...
 
    
Sergey
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: Click here to reveal e-mail address

Click here to reveal e-mail address (Jan Stranik) wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
    
Jan Stranik (VIP)
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: Click here to reveal e-mail address (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: <Click here to reveal e-mail address>
| References: <#Click here to reveal e-mail address>
<Click here to reveal e-mail address>
| 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: Click here to reveal e-mail address
| 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: Click here to reveal e-mail address
|
| Click here to reveal e-mail address (Jan Stranik) wrote in message
news:<Click here to reveal e-mail address>...
| > 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 <Click here to reveal e-mail address>
| > >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: <#Click here to reveal e-mail address>
| > >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>
| > >
|

Reply to this message...
 
 
System.Diagnostics.Debug
System.IntPtr
System.Runtime.CompilerServices.RuntimeHelpers
System.Runtime.InteropServices.Marshal
System.Text.StringBuilder




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com