|
-
Aug 23rd, 2023, 06:55 AM
#1
Thread Starter
Lively Member
Setting Automatic Breakpoints a vb6 Feature in Visual Studio
In Visual Studio later versions, I'm looking for a debugging feature similar to VB6's "Add Watch." This feature would automatically set breakpoints when specific conditions are met during runtime.
I've explored conditional execution, but it focuses on checking conditions at existing breakpoints, not before execution.
Is there a way to achieve this in Visual Studio?
I'm open to default settings, macros, or third-party extensions for setting automatic breakpoints based on conditions globally.
I've already looked into:
1. VB Forum Solution: Setting breakpoints within property setters, but it's challenging for many variables in a large codebase.
Referred links:
https://www.vbforums.com/showthread....-value-changes
https://www.vbforums.com/showthread....ariable-Change
2. Stack Overflow Forum Solution: Data breakpoints aren't available for managed code in Visual Studio 2019 or earlier
Tracing variable changes manually - using watch, local or find all reference, but it's impractical for numerous variables.
Another idea was to track variable usage, store values in an auxiliary variable, and trigger DebugBreak() when values change. However, this approach also becomes impractical with many variables in a large codebase.
Links:
https://stackoverflow.com/questions/...tudio-debugger
https://stackoverflow.com/questions/...ndition-is-met
None of the above solutions worked for me
I'd greatly appreciate any insights or recommendations on achieving this functionality. Thank you for your help!
-
Aug 23rd, 2023, 08:30 AM
#2
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
I can't say that I've ever wanted to deal with breakpoints on multiple variables across a large codebase. It seems like it would be impractical, as extraneous breakpoints would be continually interrupting whatever it was I wanted to study. I want few breakpoints and always in very narrow locations. When I wanted a bunch of stuff to be tracked, especially changes, I would use some form of logging, not breakpoints.
Perhaps you could describe a scenario where a lot of breaks on a variety of variables would be useful?
My usual boring signature: Nothing
 
-
Aug 24th, 2023, 04:13 AM
#3
Thread Starter
Lively Member
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
Thank you for the quick response. I want to clarify my question: I'm not actually looking to monitor multiple variables. In VB6, there was a feature where you could set a watch on a single variable, and the debugger would stop when that variable's value changed, regardless of its location in the code. Does a similar feature exist in later versions, and if so, how can I use it?
-
Aug 24th, 2023, 07:58 AM
#4
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
Ah, I remember that feature. It was useful. I don't think that a solution as clean as that one exists in VS, these days. You can do a whole lot with breakpoints, including some odd conditional breakpoint actions, so you might well be able to do the same thing, but not quite as easily. Debug execution works differently in VS than it did in VB6, which may preclude that specific functionality. In VB6, what got executed in debug was not necessarily the same code that was written, which meant that some breakpoints wouldn't be hit because execution could take a different path when there was a breakpoint than the path it took without a breakpoint. I can't say exactly what was going on there, but it no longer happens, so debug functionality is different. I have always suspected that whatever change was made was the reason behind any other changes I saw.
My usual boring signature: Nothing
 
-
Aug 24th, 2023, 08:49 AM
#5
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
That does sound like a useful feature but apparently Visual Studio does not support a Break When Value Changes debugging feature.
An alternative that I found is that you can create a property in My.MyApplication and setup a breakpoint in the setter function:
- Go to Project > {Project Name} Properties's Application tab
- Click on the View Application Events button
- Add the following property:
Code:
Private _watchedProperty As String
Public Property WatchedProperty As String
Get
Return _watchedProperty
End Get
Set(value As String)
If Not _watchedProperty.Equals(value) Then
_watchedProperty = value
End If
End Set
End Property
- Setup a breakpoint where it is setting the value of _watchedProperty
Now you could even backtrack where the value changed from by looking at the stack trace.
-
Aug 24th, 2023, 12:44 PM
#6
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
That also assumes you have the code to the property ... if it isn't something you created, or if it's not a property but a field in the class... then you're kinda sol ... which really really sucks. that was one feature I used a lot back in those days. Times when I wish I could do hte same in my Java code ... where/when the hell is this being changed at?
-tg
-
Aug 24th, 2023, 03:47 PM
#7
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
Yeah, where IS it being changed at? There are times when I have found it to make sense to find every location where the variable is set, and put breakpoints on all of them. Of course, that only really works when you know what problem you are looking for, or else you'll hit lots of irrelevant breakpoints.
My usual boring signature: Nothing
 
-
Aug 25th, 2023, 05:06 AM
#8
Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio
Please remember next time...elections matter!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|