Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2006

Tip: Looking for answers? Try searching our database.

Conditional Breaks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
McWawa - 17 Oct 2006 11:24 GMT
Hi people,

Q: Is there a way to add a conditional break, so that execution breaks if
the value of a variable changes.

A: Yes there is, silly.

Q: But I want execution to halt whenever that variable changes, in ANY line
throughout my code, without having to set a gazillion breakpoints in every
line that accesses that variable.

A: .....anyone????

Jeppe Jespersen
Denmark
Gabriele G. Ponti - 17 Oct 2006 13:11 GMT
Encapsulate your variable into a class, use a property or a method to change
its value, set the breakpoint in the setter or method, and use the Call
Stack window to locate the calling line.
McWawa - 18 Oct 2006 13:49 GMT
> Encapsulate your variable into a class, use a property or a method to
> change
> its value, set the breakpoint in the setter or method, and use the Call
> Stack window to locate the calling line.

Thank you all.

Jeppe Jespersen
Denmark
Loy - 19 Oct 2006 08:39 GMT
I still don't have it clear...

Is there (or isn't) a way to set breakpoint on managed variable change?

A property requires change of code and even than - you need to compare
to previous value and set the breakpoint only if the new value is
different

When I debug production code using windbg + sos.dll - how can I break
when, for example, an Int32 variable has changed value?
And in Visual Studio?

Loy

> > Encapsulate your variable into a class, use a property or a method to
> > change
[quoted text clipped - 5 lines]
> Jeppe Jespersen
> Denmark
Noah Sham - 19 Oct 2006 15:47 GMT
RTM
http://msdn2.microsoft.com/en-us/library/350dyxd0.aspx

What you want is a data breakpoint.  These are only available in C++ navtive
code .

>I still don't have it clear...
>
[quoted text clipped - 19 lines]
>> Jeppe Jespersen
>> Denmark
Ben Voigt - 19 Oct 2006 21:32 GMT
> RTM
> http://msdn2.microsoft.com/en-us/library/350dyxd0.aspx
>
> What you want is a data breakpoint.  These are only available in C++
> navtive code .

The essential problem here is that, even though the JIT turns your managed
code into native code, and the processor debug registers allow you to break
when a memory location is written, the garbage collector will move your
variable here, there, and everywhere and not adjust the address in the debug
register.  Maybe you can find a way using a pinning pointer.  Or you could
use a (global static) gcroot, set a data breakpoint on that to find out when
your variable gets moved around in the gc heap, and then update the data
breakpoint on the variable.  That breakpoint would be hit once each time the
gc collects your generation -- so probably not much fun to track by hand.

>>I still don't have it clear...
>>
[quoted text clipped - 20 lines]
>>> Jeppe Jespersen
>>> Denmark
Loy - 22 Oct 2006 09:04 GMT
Thanks Ben and Noah

Seems like we need help from the sos.dll developers

I know this is tricky due to heap compaction by the GC
Your (Ben) point about memory hit by the GC itself is a good point I
learned

The complexity of this issue cry for help from Microsoft
It would be highly appreciated if the next version of SOS will allow
setting data breakpoint
- and do all the necessary work to move the breakpoint and ignore GC
itself reading the memory ... - behind the scenes
 I assume the same issue exists in Visual studio - and might explain
why conditional breakpoints don't always work

This is a needed tool while debugging and not having it make it harder
to debug some issues in .net applications.

Hope I'm not asking for too much

Loy

> > RTM
> > http://msdn2.microsoft.com/en-us/library/350dyxd0.aspx
[quoted text clipped - 36 lines]
> >>> Jeppe Jespersen
> >>> Denmark
Loy - 31 Oct 2006 10:49 GMT
Can someone from MSFT give us insight?

Loy

> Thanks Ben and Noah
>
[quoted text clipped - 59 lines]
> > >>> Jeppe Jespersen
> > >>> Denmark
Ben Voigt - 17 Oct 2006 21:07 GMT
> Hi people,
>
[quoted text clipped - 9 lines]
>
> A: .....anyone????

Does Debug -> New Breakpoint -> New Data Breakpoint... work for you?

> Jeppe Jespersen
> Denmark
Gabriele G. Ponti - 17 Oct 2006 21:52 GMT
> Does Debug -> New Breakpoint -> New Data Breakpoint... work for you?

I believe that's only for unmanaged (native) code.
Noah Sham - 18 Oct 2006 13:07 GMT
Then I would suggest that you implement the variable as a property and set
the breakpoint in the setter method.

> Q: But I want execution to halt whenever that variable changes, in ANY
> line
> throughout my code, without having to set a gazillion breakpoints in every
> line that accesses that variable.
>
> A: .....anyone????

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.