This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Private data members
- From: Tom Tromey <tromey at redhat dot com>
- To: Vladimir Prus <vladimir at codesourcery dot com>
- Cc: gdb at sources dot redhat dot com
- Date: Wed, 29 Jul 2009 09:32:18 -0600
- Subject: Re: Private data members
- References: <200907291245.32359.vladimir@codesourcery.com>
- Reply-to: tromey at redhat dot com
>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:
Volodya> I have run into a case when it's desirable that all
Volodya> modifications of a certain structure field in GDB codebase go
Volodya> via function that can enforce necessary invariants.
Volodya> At the moment, there are at least 3 places that directly assign
Volodya> a value to that field, and while I can convert them easily,
Volodya> nothing will prevent a direct assignment to appear in future.
In the past somebody solved this same problem for struct value by
putting the struct definition into value.c and adding a bunch of
accessors.
I'm lukewarm about this technique, but it can be made to work.
Daniel's suggested approach would also be fine with me.
If you want a real guarantee, you could write an spatch script to detect
assignments to this field, and run it periodically.
Tom