all groups > dotnet clr > march 2007 >
You're in the

dotnet clr

group:

debugging dynamic code


debugging dynamic code MoriCristian
3/30/2007 4:20:03 AM
dotnet clr:
Hi.
I want to debug in an app written by me (not in vs) in step by step a
routine copiled using the microsoft.csharp.compiler.
Is there any way to do so?
Thanks
RE: debugging dynamic code Wibberlet
3/30/2007 7:50:02 AM
Hi MoriCristian,

I am not quite sure what you mean here...do you want to debug an assembly
that has been compiled to IL where you do not have the associated source code?

Debugging IL is possible but certainly not easy and there will be
compromises that you have to make because of the way sequence points are
generated. Sequence points essentially map between IL instructions and native
instructions.

Depending on the size of the assembly it may be possible for you to convert
the IL code back in to source code using a tool such as .Net reflector. If
this is not possible then you could take a look at the managed debugger
located here: http://blogs.msdn.com/jmstall/archive/2004/09/30/236281.aspx.
It is restricted to #2 of the framework and is really not recommended as a
production strength utility. I guess it depends on how desperate you are to
get into the assembly.

I hope I have understood your problem properly, please let me know if that
is not the case.

wibbleret
Development blog at http://wibberlet.blogspot.com

====================================================

[quoted text, click to view]
RE: debugging dynamic code MoriCristian
3/30/2007 12:08:00 PM
Gi wibbleret, thanks for your reply
I need to add dynamic "scripting" in c# to a program I made (this program is
also made in c#)
I want to open an internal editor from my program, load my source file,
compile it and debug it. All this while the other components of my program
continue running.
I hope I made myself clearer.
Do you think you can help me with this issue?

Thanks
Cristian Mori
[quoted text, click to view]
RE: debugging dynamic code Wibberlet
4/1/2007 5:48:01 AM
Hi,

You can attach referenced code that you have written to a running process
and then debug your code when it is called (assuming you have the source
code); your reply here implies that perhaps you do.

The process is described here
http://msdn2.microsoft.com/en-us/library/c6wf8e4z.aspx

You can attach to multiple processes at once if required. I guess it all
depends on how you are referencing your dependant assemblies.

regards wibbleret
Development blog at http://wibberlet.blogspot.com

===================================================

[quoted text, click to view]
RE: debugging dynamic code MoriCristian
4/1/2007 5:56:01 AM
the problem is that i do not want to use vs to debug the script.
the debugger must be inside my app, so iI need to have a debugger that dubug
the dynamic code generate insie my app inside itself.

cristian

[quoted text, click to view]
RE: debugging dynamic code Wibberlet
4/1/2007 7:16:00 AM
Hi Cristian,

My apologies for not quite understanding your requirements. Given what you
are trying to do I think your only chance is to look at something like
Cordbg.exe that ships with the framework SDK (including source code I
believe). http://msdn2.microsoft.com/en-us/library/a6zb7c8d(vs.80).aspx

There is also DbgCLR.exe
http://msdn2.microsoft.com/en-us/library/7zxbks7z(VS.80).aspx which may be
suitable for what you are trying to do. This provides a graphical UI for
debugging services.

Other than that you are probably stuck with the VS IDE (and the licensing
fee) or a free utility such as SharpDevelop altho this would have to be
spawned as a separate process from your application (which is of course what
you are trying to avoid).

regards wibbleret
Development blog at http://wibberlet.blogspot.com

=====================================================

[quoted text, click to view]
RE: debugging dynamic code MoriCristian
4/1/2007 10:14:02 AM
thanks for your reply.
I'll take a look at the samples you gave me, maybe i'll find a way.
Anyway I want to point that i need to avoid vs not for fee issues, but
becaouse in out toolkit we neet to implement a c# script engine and a
debugger for those scripts, so vs cannot be used as debugging engine and
another way must be found

Thanks
Cristian Mori

[quoted text, click to view]
RE: debugging dynamic code jetan NO[at]SPAM online.microsoft.com (
4/2/2007 12:00:00 AM
Hi Cristian,

Based on my understanding, your application is dynamically generating C#
code through microsoft.csharp.compiler. Now, you want to employ a debugging
function in your own application to debug the generated C# code step by
step. If I have misunderstood you, please feel free to tell me, thanks.

Based on my knowledge, the CLR debugging feature is exposed through
ICorDebug as managed debugging service. So your application may leverage
this interface to get debugging feature. The CLR team has implemented a
sample C# debugger MDbg with source code available. All the best resource
regarding MDbg is maintained here:
"MDbg Linkfest"
http://blogs.msdn.com/jmstall/archive/2005/11/08/mdbg_linkfest.aspx

The CLR developer Mike Stall also created a category regarding MDBG below:
http://blogs.msdn.com/jmstall/archive/tags/MDbg/default.aspx

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


AddThis Social Bookmark Button