+2012-03-02 Joel Brobecker <brobecker@adacore.com>
+
+ * language.h (struct language_defn): New "method" la_read_var_value.
+ * findvar.c: #include "language.h".
+ (default_read_var_value): Renames read_var_value. Rewrite
+ function description.
+ (read_var_value): New function.
+ * value.h (default_read_var_value): Add prototype.
+ * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value):
+ New functions.
+ (ada_language_defn): Add entry for la_read_var_value.
+ * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c,
+ * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update
+ language_defn structures to add entry for new la_read_var_value
+ field.
+
2012-03-02 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
if (len != NULL)
*len = suffix - info;
return kind;
-}
+}
+
+/* Compute the value of the given RENAMING_SYM, which is expected to
+ be a symbol encoding a renaming expression. BLOCK is the block
+ used to evaluate the renaming. */
+static struct value *
+ada_read_renaming_var_value (struct symbol *renaming_sym,
+ struct block *block)
+{
+ char *sym_name;
+ struct expression *expr;
+ struct value *value;
+ struct cleanup *old_chain = NULL;
+
+ sym_name = xstrdup (SYMBOL_LINKAGE_NAME (renaming_sym));
+ old_chain = make_cleanup (xfree, sym_name);
+ expr = parse_exp_1 (&sym_name, block, 0);
+ make_cleanup (free_current_contents, &expr);
+ value = evaluate_expression (expr);
+
+ do_cleanups (old_chain);
+ return value;
+}
\f
/* Evaluation: Function Calls */
return compare_names;
}
+/* Implement the "la_read_var_value" language_defn method for Ada. */
+
+static struct value *
+ada_read_var_value (struct symbol *var, struct frame_info *frame)
+{
+ struct block *frame_block = NULL;
+ struct symbol *renaming_sym = NULL;
+
+ /* The only case where default_read_var_value is not sufficient
+ is when VAR is a renaming... */
+ if (frame)
+ frame_block = get_frame_block (frame, NULL);
+ if (frame_block)
+ renaming_sym = ada_find_renaming_symbol (var, frame_block);
+ if (renaming_sym != NULL)
+ return ada_read_renaming_var_value (renaming_sym, frame_block);
+
+ /* This is a typical case where we expect the default_read_var_value
+ function to work. */
+ return default_read_var_value (var, frame);
+}
+
const struct language_defn ada_language_defn = {
"ada", /* Language name */
language_ada,
ada_print_typedef, /* Print a typedef using appropriate syntax */
ada_val_print, /* Print a value using appropriate syntax */
ada_value_print, /* Print a top-level value */
+ ada_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
cplus_skip_trampoline, /* Language specific skip_trampoline */
"this", /* name_of_this */
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
syntax. */
d_val_print, /* Print a value using appropriate syntax. */
c_value_print, /* Print a top-level value. */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline. */
"this",
basic_lookup_symbol_nonlocal,
default_print_typedef, /* Print a typedef using appropriate syntax */
f_val_print, /* Print a value using appropriate syntax */
c_value_print, /* FIXME */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
#include "user-regs.h"
#include "block.h"
#include "objfiles.h"
+#include "language.h"
/* Basic byte-swapping routines. All 'extract' functions return a
host-format integer from a target-format integer at ADDR which is
return 1;
}
-/* Given a struct symbol for a variable,
- and a stack frame id, read the value of the variable
- and return a (pointer to a) struct value containing the value.
- If the variable cannot be found, throw error. */
+/* A default implementation for the "la_read_var_value" hook in
+ the language vector which should work in most situations. */
struct value *
-read_var_value (struct symbol *var, struct frame_info *frame)
+default_read_var_value (struct symbol *var, struct frame_info *frame)
{
struct value *v;
struct type *type = SYMBOL_TYPE (var);
return v;
}
+/* Calls VAR's language la_read_var_value hook with the given arguments. */
+
+struct value *
+read_var_value (struct symbol *var, struct frame_info *frame)
+{
+ const struct language_defn *lang = language_def (SYMBOL_LANGUAGE (var));
+
+ gdb_assert (lang != NULL);
+ gdb_assert (lang->la_read_var_value != NULL);
+
+ return lang->la_read_var_value (var, frame);
+}
+
/* Install default attributes for register values. */
struct value *
default_print_typedef, /* Print a typedef using appropriate syntax */
java_val_print, /* Print a value using appropriate syntax */
java_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
"this", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
default_print_typedef, /* Print a typedef using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
unk_lang_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
unk_lang_trampoline, /* Language specific skip_trampoline */
"this", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
default_print_typedef, /* Print a typedef using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
unk_lang_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
unk_lang_trampoline, /* Language specific skip_trampoline */
"this", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
default_print_typedef, /* Print a typedef using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
unk_lang_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
unk_lang_trampoline, /* Language specific skip_trampoline */
"this", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
void (*la_value_print) (struct value *, struct ui_file *,
const struct value_print_options *);
+ /* Given a symbol VAR, and a stack frame id FRAME, read the value
+ of the variable an return (pointer to a) struct value containing
+ the value.
+
+ Throw an error if the variable cannot be found. */
+
+ struct value *(*la_read_var_value) (struct symbol *var,
+ struct frame_info *frame);
+
/* PC is possibly an unknown languages trampoline.
If that PC falls in a trampoline belonging to this language,
return the address of the first pc in the real function, or 0
m2_print_typedef, /* Print a typedef using appropriate syntax */
m2_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
objc_skip_trampoline, /* Language specific skip_trampoline */
"self", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
NULL, /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
pascal_print_typedef, /* Print a typedef using appropriate syntax */
pascal_val_print, /* Print a value using appropriate syntax */
pascal_value_print, /* Print a top-level value */
+ default_read_var_value, /* la_read_var_value */
NULL, /* Language specific skip_trampoline */
"this", /* name_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
extern struct value *read_var_value (struct symbol *var,
struct frame_info *frame);
+extern struct value *default_read_var_value (struct symbol *var,
+ struct frame_info *frame);
+
extern struct value *allocate_value (struct type *type);
extern struct value *allocate_value_lazy (struct type *type);
extern void allocate_value_contents (struct value *value);