aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2013-10-17 21:15:21 +0800
committerTom Tromey <tromey@sourceware.org>2013-10-25 14:03:02 +0000
commita53b64eaa0816d9136f92b51f5e0d23e718b84f3 (patch)
tree5fe5ffa5cc606ccf84d43873dcf764c8b714f510 /gdb
parent38095c27fb67d4828c0b55f37714fe5c8e7dd9cd (diff)
downloadgdb-a53b64eaa0816d9136f92b51f5e0d23e718b84f3.zip
gdb-a53b64eaa0816d9136f92b51f5e0d23e718b84f3.tar.gz
gdb-a53b64eaa0816d9136f92b51f5e0d23e718b84f3.tar.bz2
New field la_varobj_ops in struct language_defn
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog30
-rw-r--r--gdb/ada-lang.c2
-rw-r--r--gdb/c-lang.c5
-rw-r--r--gdb/d-lang.c2
-rw-r--r--gdb/f-lang.c2
-rw-r--r--gdb/go-lang.c2
-rw-r--r--gdb/jv-lang.c2
-rw-r--r--gdb/language.c4
-rw-r--r--gdb/language.h4
-rw-r--r--gdb/m2-lang.c2
-rw-r--r--gdb/objc-lang.c2
-rw-r--r--gdb/opencl-lang.c2
-rw-r--r--gdb/p-lang.c2
-rw-r--r--gdb/varobj.c4
-rw-r--r--gdb/varobj.h1
15 files changed, 63 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 88b8340..4dd055f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,33 @@
+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
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9ff3ab9..75f9fe8 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -32,6 +32,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "inferior.h"
#include "symfile.h"
@@ -12834,6 +12835,7 @@ const struct language_defn ada_language_defn = {
c_get_string,
ada_get_symbol_name_cmp, /* la_get_symbol_name_cmp */
ada_iterate_over_symbols,
+ &ada_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 33bb444..7c09029 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -23,6 +23,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "valprint.h"
#include "macroscope.h"
@@ -846,6 +847,7 @@ const struct language_defn c_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &c_varobj_ops,
LANG_MAGIC
};
@@ -969,6 +971,7 @@ const struct language_defn cplus_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &cplus_varobj_ops,
LANG_MAGIC
};
@@ -1010,6 +1013,7 @@ const struct language_defn asm_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
@@ -1056,6 +1060,7 @@ const struct language_defn minimal_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 15f56df..b4c8664 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -20,6 +20,7 @@
#include "defs.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "d-lang.h"
#include "c-lang.h"
#include "gdb_string.h"
@@ -274,6 +275,7 @@ static const struct language_defn d_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index f40e98d..ee52561 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -27,6 +27,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "f-lang.h"
#include "valprint.h"
#include "value.h"
@@ -273,6 +274,7 @@ const struct language_defn f_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 309b1eb..fd0bae3 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -38,6 +38,7 @@
#include "block.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "go-lang.h"
#include "c-lang.h"
#include "parser-defs.h"
@@ -596,6 +597,7 @@ static const struct language_defn go_language_defn =
c_get_string,
NULL,
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 63bcc98..9c2cc13 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -31,6 +31,7 @@
#include "value.h"
#include "c-lang.h"
#include "jv-lang.h"
+#include "varobj.h"
#include "gdbcore.h"
#include "block.h"
#include "demangle.h"
@@ -1196,6 +1197,7 @@ const struct language_defn java_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &java_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/language.c b/gdb/language.c
index 10073e1..dcad5f3 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -38,6 +38,7 @@
#include "gdbcmd.h"
#include "expression.h"
#include "language.h"
+#include "varobj.h"
#include "target.h"
#include "parser-defs.h"
#include "jv-lang.h"
@@ -826,6 +827,7 @@ const struct language_defn unknown_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
@@ -869,6 +871,7 @@ const struct language_defn auto_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
@@ -910,6 +913,7 @@ const struct language_defn local_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/language.h b/gdb/language.h
index e36da31..5e029ea 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -31,6 +31,7 @@ struct expression;
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. */
@@ -344,6 +345,9 @@ struct language_defn
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. */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 31e9a56..158ca07 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -23,6 +23,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "m2-lang.h"
#include "c-lang.h"
#include "valprint.h"
@@ -391,6 +392,7 @@ const struct language_defn m2_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index bcce435..efec3b3 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -26,6 +26,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "objc-lang.h"
#include "exceptions.h"
@@ -389,6 +390,7 @@ const struct language_defn objc_language_defn = {
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 4720e2b..faf88d9 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -26,6 +26,7 @@
#include "parser-defs.h"
#include "symtab.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "gdb_assert.h"
@@ -1137,6 +1138,7 @@ const struct language_defn opencl_language_defn =
c_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 07006cd..d239190 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -26,6 +26,7 @@
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "p-lang.h"
#include "valprint.h"
#include "value.h"
@@ -449,6 +450,7 @@ const struct language_defn pascal_language_defn =
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 01cf3d2..60ed810 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -318,7 +318,6 @@ varobj_create (char *objname,
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;
@@ -433,8 +432,7 @@ varobj_create (char *objname,
}
/* 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 */);
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 7efaedb..2379c3d 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -230,6 +230,7 @@ const struct lang_varobj_ops cplus_varobj_ops;
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,