.NETGURU
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 Guru (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 Guru (http://www.dot-net-guru.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 Guru <Click here to reveal e-mail address>
| > >X-Newsreader: AspNNTP 1.50 (Dot Net Guruhew 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 Guru (http://www.dot-net-guru.com/)
| > >
| > ><Id>SOeem8tB8UWHhvFHTwmSdA==</Id>
| > >
|

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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification