diff options
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/gdb/value.c b/gdb/value.c index eae3e2d..d498289 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1629,7 +1629,14 @@ struct internalvar struct value *value; /* The call-back routine used with INTERNALVAR_MAKE_VALUE. */ - internalvar_make_value make_value; + struct + { + /* The functions to call. */ + const struct internalvar_funcs *functions; + + /* The function's user-data. */ + void *data; + } make_value; /* The internal function used with INTERNALVAR_FUNCTION. */ struct @@ -1728,18 +1735,39 @@ create_internalvar (const char *name) /* Create an internal variable with name NAME and register FUN as the function that value_of_internalvar uses to create a value whenever this variable is referenced. NAME should not normally include a - dollar sign. */ + dollar sign. DATA is passed uninterpreted to FUN when it is + called. CLEANUP, if not NULL, is called when the internal variable + is destroyed. It is passed DATA as its only argument. */ struct internalvar * -create_internalvar_type_lazy (char *name, internalvar_make_value fun) +create_internalvar_type_lazy (const char *name, + const struct internalvar_funcs *funcs, + void *data) { struct internalvar *var = create_internalvar (name); var->kind = INTERNALVAR_MAKE_VALUE; - var->u.make_value = fun; + var->u.make_value.functions = funcs; + var->u.make_value.data = data; return var; } +/* See documentation in value.h. */ + +int +compile_internalvar_to_ax (struct internalvar *var, + struct agent_expr *expr, + struct axs_value *value) +{ + if (var->kind != INTERNALVAR_MAKE_VALUE + || var->u.make_value.functions->compile_to_ax == NULL) + return 0; + + var->u.make_value.functions->compile_to_ax (var, expr, value, + var->u.make_value.data); + return 1; +} + /* Look up an internal variable with name NAME. NAME should not normally include a dollar sign. @@ -1812,7 +1840,8 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) break; case INTERNALVAR_MAKE_VALUE: - val = (*var->u.make_value) (gdbarch, var); + val = (*var->u.make_value.functions->make_value) (gdbarch, var, + var->u.make_value.data); break; default: @@ -2008,6 +2037,11 @@ clear_internalvar (struct internalvar *var) xfree (var->u.string); break; + case INTERNALVAR_MAKE_VALUE: + if (var->u.make_value.functions->destroy != NULL) + var->u.make_value.functions->destroy (var->u.make_value.data); + break; + default: break; } |