Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 5/7] New lang-varobj.h
Date: Wed, 18 Sep 2013 13:55:00 -0000	[thread overview]
Message-ID: <1379512482-31773-6-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1379512482-31773-1-git-send-email-yao@codesourcery.com>

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


  reply	other threads:[~2013-09-18 13:55 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 13:55 [RFC 0/7] Move language-related stuff out of varobj.c Yao Qi
2013-09-18 13:55 ` Yao Qi [this message]
2013-10-02 17:18   ` [PATCH 5/7] New lang-varobj.h Doug Evans
2013-10-08  4:59     ` Joel Brobecker
2013-10-09 23:51       ` Yao Qi
2013-10-09 23:56         ` Doug Evans
2013-10-10  0:19           ` Yao Qi
2013-09-18 13:55 ` [PATCH 4/7] Move struct varobj to varobj.h Yao Qi
2013-10-02  9:46   ` Joel Brobecker
2013-10-02 19:32     ` Doug Evans
2013-10-06  6:33     ` Yao Qi
2013-10-08  4:56       ` Joel Brobecker
2013-10-08 21:03         ` Doug Evans
2013-10-09  0:28         ` Yao Qi
2013-10-14  8:19         ` Yao Qi
2013-09-18 13:55 ` [PATCH 6/7] Move language stuff out of varobj.c Yao Qi
2013-10-11  8:20   ` Yao Qi
2013-10-17  5:40     ` Joel Brobecker
2013-10-17 13:33       ` Yao Qi
2013-09-18 13:55 ` [PATCH 1/7] Remove field language in struct language_specific Yao Qi
2013-10-01 10:03   ` Joel Brobecker
2013-10-01 13:35     ` Yao Qi
2013-09-18 13:55 ` [PATCH 2/7] Remove vlang_unknown Yao Qi
2013-10-01 10:07   ` Joel Brobecker
2013-10-01 13:34     ` Yao Qi
2013-10-02  0:19       ` Doug Evans
2013-10-02  9:32         ` Joel Brobecker
2013-10-04  8:31           ` Yao Qi
2013-09-18 13:55 ` [PATCH 3/7] Remove field value_of_root Yao Qi
2013-10-01 10:16   ` Joel Brobecker
2013-10-01 13:52     ` Yao Qi
2013-09-18 13:55 ` [PATCH 7/7] Remove ada-varobj.h Yao Qi
2013-10-17  5:46   ` Joel Brobecker
2013-10-17 13:34     ` Yao Qi
2013-09-28  0:56 ` [RFC 0/7] Move language-related stuff out of varobj.c Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379512482-31773-6-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox