Visual C# 2005: How can I trigger a breakpoint upon a class member variable change?

M

Max2006

Hi,



I am using Visual C# 2005 and I like to setup breakpoint that pause
execution upon a class variable change.



Is that possible?



Thank you,

Max
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Set your BP and right click in the red indicator, you will get a list of
options
 
M

Max2006

I am aware of those options. I don't know how to specify: **"break at the
palce that assigns new value to this variable"**.

I remember we had this feature with old VB6. DO we still have it?

Thanks for help,
Max
 
R

rammer

Hello Max,

me either not aware of that feature but you can place breakpoints in
the place your code changes that variable:)
or just add that variable to watch list and step over your whole
application's run and see in watch list where is the place that
changes that variable.
 
J

Jeffrey Tan[MSFT]

Hi Max,

This type of breakpoint is called data breakpoint, which is a type of
hardware breakpoint.

The normal breakpoint is called software breakpoint, which is implemented
by inserting a "int 3" instruction in the function start. So if the code
executed the "int 3", it will notify the debugger that a breakpoint is
triggered. To monitor the data variable change, it is different from normal
breakpoint, because it is not code. "int 3" trick can not be used here. We
need hardware support from CPU. So x86 CPU provided the debug registers to
help debugger implement data breakpoints for this purpose.

However, because the GC will move the objects frequently in managed code,
it makes the data breakpoints almost impossible for managed objects data.
That's why data breakpoint is only supported for native debugging
currently. Our Visual Studio debugger team developer confirmed this in his
blog below:
"Data Breakpoints"
http://blogs.msdn.com/greggm/archive/2004/04/30/124161.aspx

So we can not set data breakpoint on class member variable yet. 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.
 
J

Jeffrey Tan[MSFT]

Hi Max,

Have you reviewed my reply to you? Does it make sense to you? If you still
need any help or have any concern, please feel free to tell me, thanks.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top