Reputation: 510
I have a huge program (VS project) which contains global variable. It modifies from hundreds places. Actually it standard STL container (std::vector) and question is how can I track down this particular variable modifications? In my work I use VS debugger (Prof 2017 15.9.5)
Upvotes: 1
Views: 33
Reputation: 4369
There are a few solutions which come to my mind:
Create another class which will encapsulte this vector. Then allow users to use this vector by adding getter returning reference to it. Then you can put a breakpoint in getter.
Put a memory breakpoint on one of vector
's members but it is plantform specific solution which may not work in all scenarios.
Replace std::vector
with your custom type with interface identical to std::vector
's which would use original std::vector
in its internals.
With this solution you can monitor accesses more precisely.
P.S. remove this global ASAP.
Upvotes: 1