[PATCH 5/7] New lang-varobj.h
Yao Qi
yao@codesourcery.com
Wed Sep 18 13:55:00 GMT 2013
This patch moves 'struct language_specific' out of varobj.c to a new file
'lang-varobj.h'.
gdb:
2013-09-18 Yao Qi <yao@codesourcery.com>
* Makefile.in (HFILES_NO_SRCDIR): Add lang-varobj.h.
* lang-varobj.h: New.
* varobj.c: Include "lang-varobj.h".
(struct varobj_root): <lang>: Update its type.
(struct language_specific): Move it to lang-varobj.h.
---
gdb/Makefile.in | 2 +-
gdb/lang-varobj.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/varobj.c | 61 +++----------------------------------------
3 files changed, 80 insertions(+), 57 deletions(-)
create mode 100644 gdb/lang-varobj.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 93a3d6a..3081e1d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -827,7 +827,7 @@ m68k-tdep.h spu-tdep.h jv-lang.h environ.h solib-irix.h amd64-tdep.h \
doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h ppc64-tdep.h \
rs6000-tdep.h rs6000-aix-tdep.h \
common/gdb_locale.h common/gdb_dirent.h arch-utils.h trad-frame.h gnu-nat.h \
-language.h nbsd-tdep.h solib-svr4.h \
+language.h lang-varobj.h nbsd-tdep.h solib-svr4.h \
macroexp.h ui-file.h regcache.h tracepoint.h i386-tdep.h \
inf-child.h p-lang.h event-top.h gdbtypes.h user-regs.h \
regformats/regdef.h config/alpha/nm-osf3.h config/i386/nm-i386gnu.h \
diff --git a/gdb/lang-varobj.h b/gdb/lang-varobj.h
new file mode 100644
index 0000000..b49e42a
--- /dev/null
+++ b/gdb/lang-varobj.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 1999-2013 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef LANG_VAROBJ_H
+#define LANG_VAROBJ_H 1
+
+#include "varobj.h"
+
+/* The language specific vector */
+
+struct lang_varobj_ops
+{
+ /* The number of children of PARENT. */
+ int (*number_of_children) (struct varobj * parent);
+
+ /* The name (expression) of a root varobj. */
+ char *(*name_of_variable) (struct varobj * parent);
+
+ /* The name of the INDEX'th child of PARENT. */
+ char *(*name_of_child) (struct varobj * parent, int index);
+
+ /* Returns the rooted expression of CHILD, which is a variable
+ obtain that has some parent. */
+ char *(*path_expr_of_child) (struct varobj * child);
+
+ /* The ``struct value *'' of the INDEX'th child of PARENT. */
+ struct value *(*value_of_child) (struct varobj * parent, int index);
+
+ /* The type of the INDEX'th child of PARENT. */
+ struct type *(*type_of_child) (struct varobj * parent, int index);
+
+ /* The current value of VAR. */
+ char *(*value_of_variable) (struct varobj * var,
+ enum varobj_display_formats format);
+
+ /* Return non-zero if changes in value of VAR must be detected and
+ reported by -var-update. Return zero if -var-update should never
+ report changes of such values. This makes sense for structures
+ (since the changes in children values will be reported separately),
+ or for artifical objects (like 'public' pseudo-field in C++).
+
+ Return value of 0 means that gdb need not call value_fetch_lazy
+ for the value of this variable object. */
+ int (*value_is_changeable_p) (struct varobj *var);
+
+ /* Return nonzero if the type of VAR has mutated.
+
+ VAR's value is still the varobj's previous value, while NEW_VALUE
+ is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
+ may be NULL indicating that there is no value available (the varobj
+ may be out of scope, of may be the child of a null pointer, for
+ instance). NEW_TYPE, on the other hand, must never be NULL.
+
+ This function should also be able to assume that var's number of
+ children is set (not < 0).
+
+ Languages where types do not mutate can set this to NULL. */
+ int (*value_has_mutated) (struct varobj *var, struct value *new_value,
+ struct type *new_type);
+};
+
+#endif /* LANG_VAROBJ_H */
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 672d246..43d5dbf 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -35,6 +35,7 @@
#include "inferior.h"
#include "ada-varobj.h"
#include "ada-lang.h"
+#include "lang-varobj.h"
#if HAVE_PYTHON
#include "python/python.h"
@@ -106,8 +107,9 @@ struct varobj_root
to symbols that do not exist anymore. */
int is_valid;
- /* Language info for this variable and its children. */
- struct language_specific *lang;
+ /* Language-related operations for this variable and its
+ children. */
+ struct lang_varobj_ops *lang;
/* The varobj for this root node. */
struct varobj *rootvar;
@@ -320,61 +322,8 @@ static int ada_value_is_changeable_p (struct varobj *var);
static int ada_value_has_mutated (struct varobj *var, struct value *new_val,
struct type *new_type);
-/* The language specific vector */
-
-struct language_specific
-{
- /* The number of children of PARENT. */
- int (*number_of_children) (struct varobj * parent);
-
- /* The name (expression) of a root varobj. */
- char *(*name_of_variable) (struct varobj * parent);
-
- /* The name of the INDEX'th child of PARENT. */
- char *(*name_of_child) (struct varobj * parent, int index);
-
- /* Returns the rooted expression of CHILD, which is a variable
- obtain that has some parent. */
- char *(*path_expr_of_child) (struct varobj * child);
-
- /* The ``struct value *'' of the INDEX'th child of PARENT. */
- struct value *(*value_of_child) (struct varobj * parent, int index);
-
- /* The type of the INDEX'th child of PARENT. */
- struct type *(*type_of_child) (struct varobj * parent, int index);
-
- /* The current value of VAR. */
- char *(*value_of_variable) (struct varobj * var,
- enum varobj_display_formats format);
-
- /* Return non-zero if changes in value of VAR must be detected and
- reported by -var-update. Return zero if -var-update should never
- report changes of such values. This makes sense for structures
- (since the changes in children values will be reported separately),
- or for artifical objects (like 'public' pseudo-field in C++).
-
- Return value of 0 means that gdb need not call value_fetch_lazy
- for the value of this variable object. */
- int (*value_is_changeable_p) (struct varobj *var);
-
- /* Return nonzero if the type of VAR has mutated.
-
- VAR's value is still the varobj's previous value, while NEW_VALUE
- is VAR's new value and NEW_TYPE is the var's new type. NEW_VALUE
- may be NULL indicating that there is no value available (the varobj
- may be out of scope, of may be the child of a null pointer, for
- instance). NEW_TYPE, on the other hand, must never be NULL.
-
- This function should also be able to assume that var's number of
- children is set (not < 0).
-
- Languages where types do not mutate can set this to NULL. */
- int (*value_has_mutated) (struct varobj *var, struct value *new_value,
- struct type *new_type);
-};
-
/* Array of known source language routines. */
-static struct language_specific languages[vlang_end] = {
+static struct lang_varobj_ops languages[vlang_end] = {
/* C */
{
c_number_of_children,
--
1.7.7.6
More information about the Gdb-patches
mailing list