all groups > dotnet clr > october 2006 >
You're in the

dotnet clr

group:

Conditional Breaks


Re: Conditional Breaks Gabriele G. Ponti
10/17/2006 8:11:20 AM
dotnet clr:
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.

Conditional Breaks McWawa
10/17/2006 12:24:10 PM
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


Re: Conditional Breaks Ben Voigt
10/17/2006 3:07:36 PM
[quoted text, click to view]

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

[quoted text, click to view]

Re: Conditional Breaks Gabriele G. Ponti
10/17/2006 4:52:49 PM
[quoted text, click to view]

I believe that's only for unmanaged (native) code.

Re: Conditional Breaks Noah Sham
10/18/2006 8:07:57 AM
Then I would suggest that you implement the variable as a property and set
the breakpoint in the setter method.

[quoted text, click to view]

Re: Conditional Breaks McWawa
10/18/2006 2:49:53 PM

[quoted text, click to view]

Thank you all.

Jeppe Jespersen
Denmark


Re: Conditional Breaks Loy
10/19/2006 12:39:03 AM
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

[quoted text, click to view]
Re: Conditional Breaks Noah Sham
10/19/2006 10:47:54 AM
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 .


[quoted text, click to view]

Re: Conditional Breaks Ben Voigt
10/19/2006 3:32:26 PM

[quoted text, click to view]

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.

[quoted text, click to view]

Re: Conditional Breaks Loy
10/22/2006 1:04:29 AM
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




[quoted text, click to view]
Re: Conditional Breaks Loy
10/31/2006 1:49:21 AM
Can someone from MSFT give us insight?

Loy

[quoted text, click to view]
AddThis Social Bookmark Button