Attaching debugger

  • Thread starter Thread starter Sajjad Akhter
  • Start date Start date
S

Sajjad Akhter

Hi,

I have a program which loads other .net dlls and creates objects from there
and invoke functions from those objects.

I wanted to load debugger so that user can debug those dlls esily i can
attach debugger using Debbuger.Launch()

but it breaks on my this line i want it to stop on first line in a function
i am going to invoke. Any idea any hint how can i achive that.

Basically how the concept of break points heppens in any debugger.

Thanks,
Sajjad
 
Hi Sajjad,

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Hi Sajjad,

Thanks for your posting. As for the System.Diagnostics.Debugger class, the
Launch method will detect whether there is already a debuger and attached
to this process, if not, dialog will popup to let us choose one, and then
the process will break at the current line( where you call
Debugger.Launch).

If we want to break at a certain place. We may need to manually call
Debugger.Break() method, this method will also will also prompt us to
choose a dubugger if no one is attached. And will break at the first code
line after where we call this method. So you can directly use
Debugger.Break() instead of Debbuger.Launch(). For example:

we have the following functions:

static void Main(string[] args)
{

fun1();


fun2();


Console.Read();
}


public static void fun1()
{
//some code......
}


public static void fun2()
{
Debugger.Break();

int i= 0;

int j=0;

int k= 0;

Console.WriteLine(i);
Console.WriteLine(j);
}

When running the code, runtime will popup dialog to let us choose an
available debugger(or new one instance). Then, it will break at the "int
i=0;" after the Debugger.Break(); in fun2. (if a debugger is already
attached, it'll directly break there).

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Sajjad,

Have you had a chance to see the suggestions in my last reply? If not, I'll
repaste the content here for your convenience:

==========================
Hi Sajjad,

Thanks for your posting. As for the System.Diagnostics.Debugger class, the
Launch method will detect whether there is already a debuger and attached
to this process, if not, dialog will popup to let us choose one, and then
the process will break at the current line( where you call
Debugger.Launch).

If we want to break at a certain place. We may need to manually call
Debugger.Break() method, this method will also will also prompt us to
choose a dubugger if no one is attached. And will break at the first code
line after where we call this method. So you can directly use
Debugger.Break() instead of Debbuger.Launch(). For example:

we have the following functions:

static void Main(string[] args)
{

fun1();


fun2();


Console.Read();
}


public static void fun1()
{
//some code......
}


public static void fun2()
{
Debugger.Break();

int i= 0;

int j=0;

int k= 0;

Console.WriteLine(i);
Console.WriteLine(j);
}

When running the code, runtime will popup dialog to let us choose an
available debugger(or new one instance). Then, it will break at the "int
i=0;" after the Debugger.Break(); in fun2. (if a debugger is already
attached, it'll directly break there).

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support
==================================

If you have any further ideas, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
My question was is there a way to break in a function without modifying
code. Same as break point in vs.net code.

in my case user specifies in config file that if they want to break in
certain function My questio is "is there a way to add break point without
modifing and recompiling source.
 
Hi Sajjad,

Thanks for your followup. If we don't modify the code, I'm afraid the
debugger can't get where to break into the source when attached to the
process. In fact , when we add break points in VS.NET,the IDE actually
modify the source and recompile, (add some debug using instructions so that
it can get where to break and hit when debugging). So if you want other
debugs to break into the code automatically when attaching to a program,
there need to contains debug infos in the program's source file which the
debuger can recognize and generally IDE do the works.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top