This is a follow-up series to move language stuff out of varobj.c.
This patch adds a new field la_varobj_ops in struct language_defn so
that each language has varobj-related options. Not every language
supports varobj, and the operations are identical to operations of c
languages.
'struct language_defn' is the ideal place to save all language-related
operations. After this patch, some cleanups can be done in patch 2/2,
which removes language-related stuff completely from varobj.c.
Regression tested on x86_64-linux.
gdb:
2013-10-25 Yao Qi <yao@codesourcery.com>
* language.h (struct lang_varobj_ops): Declare.
(struct language_defn) <la_varobj_ops>: New field.
* ada-lang.c: Include "varobj.h"
(defn ada_language_defn): Initialize field 'la_varobj_ops' by
ada_varobj_ops.
* c-lang.c: Include "varobj.h"
(c_language_defn): Initialize field 'la_varobj_ops' by
c_varobj_ops.
(cplus_language_defn): Initialize field 'la_varobj_ops' by
cplus_varobj_ops.
(asm_language_defn): Initialize field 'la_varobj_ops' by
default_varobj_ops.
(minimal_language_defn): Likewise.
* d-lang.c (d_language_defn): Likewise.
* f-lang.c (f_language_defn): Likewise.
* go-lang.c (go_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* opencl-lang.c (opencl_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
* language.c (unknown_language_defn): Likewise.
(auto_language_defn): Likewise.
(local_language_defn): Likewise.
* jv-lang.c (java_language_defn): Initialize field
'la_varobj_ops' by java_varobj_ops.
* varobj.c (varobj_create): Update.
* varobj.h (default_varobj_ops): Define macro.
+2013-10-25 Yao Qi <yao@codesourcery.com>
+
+ * language.h (struct lang_varobj_ops): Declare.
+ (struct language_defn) <la_varobj_ops>: New field.
+ * ada-lang.c: Include "varobj.h"
+ (defn ada_language_defn): Initialize field 'la_varobj_ops' with
+ ada_varobj_ops.
+ * c-lang.c: Include "varobj.h"
+ (c_language_defn): Initialize field 'la_varobj_ops' with
+ c_varobj_ops.
+ (cplus_language_defn): Initialize field 'la_varobj_ops' with
+ cplus_varobj_ops.
+ (asm_language_defn): Initialize field 'la_varobj_ops' with
+ default_varobj_ops.
+ (minimal_language_defn): Likewise.
+ * d-lang.c (d_language_defn): Likewise.
+ * f-lang.c (f_language_defn): Likewise.
+ * go-lang.c (go_language_defn): Likewise.
+ * m2-lang.c (m2_language_defn): Likewise.
+ * objc-lang.c (objc_language_defn): Likewise.
+ * opencl-lang.c (opencl_language_defn): Likewise.
+ * p-lang.c (pascal_language_defn): Likewise.
+ * language.c (unknown_language_defn): Likewise.
+ (auto_language_defn): Likewise.
+ (local_language_defn): Likewise.
+ * jv-lang.c (java_language_defn): Initialize field
+ 'la_varobj_ops' with java_varobj_ops.
+ * varobj.c (varobj_create): Update.
+ * varobj.h (default_varobj_ops): Define macro.
+
2013-10-25 Pedro Alves <palves@redhat.com>
* cp-valprint.c (cp_print_value_fields): No longer handle a NULL
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "inferior.h"
#include "symfile.h"
c_get_string,
ada_get_symbol_name_cmp, /* la_get_symbol_name_cmp */
ada_iterate_over_symbols,
+ &ada_varobj_ops,
LANG_MAGIC
};
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "valprint.h"
#include "macroscope.h"
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &c_varobj_ops,
LANG_MAGIC
};
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &cplus_varobj_ops,
LANG_MAGIC
};
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "defs.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "d-lang.h"
#include "c-lang.h"
#include "gdb_string.h"
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "f-lang.h"
#include "valprint.h"
#include "value.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "block.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "go-lang.h"
#include "c-lang.h"
#include "parser-defs.h"
c_get_string,
NULL,
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "value.h"
#include "c-lang.h"
#include "jv-lang.h"
+#include "varobj.h"
#include "gdbcore.h"
#include "block.h"
#include "demangle.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &java_varobj_ops,
LANG_MAGIC
};
#include "gdbcmd.h"
#include "expression.h"
#include "language.h"
+#include "varobj.h"
#include "target.h"
#include "parser-defs.h"
#include "jv-lang.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
\f
struct ui_file;
struct value_print_options;
struct type_print_options;
+struct lang_varobj_ops;
#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */
symbol_found_callback_ftype *callback,
void *data);
+ /* Various operations on varobj. */
+ const struct lang_varobj_ops *la_varobj_ops;
+
/* Add fields above this point, so the magic number is always last. */
/* Magic number for compat checking. */
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "m2-lang.h"
#include "c-lang.h"
#include "valprint.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "objc-lang.h"
#include "exceptions.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "parser-defs.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "gdb_assert.h"
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "p-lang.h"
#include "valprint.h"
#include "value.h"
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
struct frame_id old_id = null_frame_id;
struct block *block;
const char *p;
- enum varobj_languages lang;
struct value *value = NULL;
volatile struct gdb_exception except;
CORE_ADDR pc;
}
/* Set language info */
- lang = variable_language (var);
- var->root->lang = languages[lang];
+ var->root->lang = var->root->exp->language_defn->la_varobj_ops;
install_new_value (var, value, 1 /* Initial assignment */);
const struct lang_varobj_ops java_varobj_ops;
const struct lang_varobj_ops ada_varobj_ops;
+#define default_varobj_ops c_varobj_ops
/* API functions */
extern struct varobj *varobj_create (char *objname,