| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GDB uses struct value, or values, as an internal
abstraction for the representation of a variety of inferior objects
and GDB convenience objects.
Values have an associated struct type, that describes a virtual
view of the raw data or object stored in or accessed through the
value.
A value is in addition discriminated by its lvalue-ness, given its
enum lval_type enumeration type:
not_lval
lval_memory
lval_register
lval_internalvar
lval_internalvar_component
lval_computed
Pointers to these functions are stored in a struct lval_funcs
instance (declared in `value.h'), and passed to the
allocate_computed_value function, as in the example below.
static void
nil_value_read (struct value *v)
{
/* This callback reads data from some backend, and stores it in V.
In this case, we always read null data. You'll want to fill in
something more interesting. */
memset (value_contents_all_raw (v),
value_offset (v),
TYPE_LENGTH (value_type (v)));
}
static void
nil_value_write (struct value *v, struct value *fromval)
{
/* Takes the data from FROMVAL and stores it in the backend of V. */
to_oblivion (value_contents_all_raw (fromval),
value_offset (v),
TYPE_LENGTH (value_type (fromval)));
}
static struct lval_funcs nil_value_funcs =
{
nil_value_read,
nil_value_write
};
struct value *
make_nil_value (void)
{
struct type *type;
struct value *v;
type = make_nils_type ();
v = allocate_computed_value (type, &nil_value_funcs, NULL);
return v;
}
|
See the implementation of the $_siginfo convenience variable in
`infrun.c' as a real example use of lval_computed.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to contact the FSF.
These pages are maintained by the GDB developers.
Copyright Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
This document was generated by GDB Administrator on October, 9 2009 using texi2html