public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: <tromey@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/3] Remove varobj_language_string, languages and varobj_languages
Date: Thu, 07 Nov 2013 07:23:00 -0000	[thread overview]
Message-ID: <527B3DEF.1050105@codesourcery.com> (raw)
In-Reply-To: <83y55cdnua.fsf@gnu.org>

This is what I committed.

-- 
Yao (齐尧)

gdb:

2013-11-07  Yao Qi  <yao@codesourcery.com>

	* mi/mi-cmd-var.c: Include "language.h".
	(mi_cmd_var_info_expression): Get language name from
	language_defn.
	* varobj.c (varobj_language_string): Remove.
	(variable_language): Remove declaration.
	(languages): Remove.
	(varobj_get_language): Change the type of return value.
	(variable_language): Remove.
	* varobj.h (enum varobj_languages): Remove.
	(varobj_language_string): Remove declaration.
	(varobj_get_language): Update declaration.

gdb/doc:

2013-11-07  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (GDB/MI Variable Objects): Update doc about the
	output of "-var-info-expression".
---
 gdb/doc/gdb.texinfo |    3 ++-
 gdb/mi/mi-cmd-var.c |    5 +++--
 gdb/varobj.c        |   43 ++-----------------------------------------
 gdb/varobj.h        |   12 +-----------
 4 files changed, 8 insertions(+), 55 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 28e6ff9..a78b797 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -32400,7 +32400,8 @@ For example, if @code{a} is an array, and variable object
 @end smallexample
 
 @noindent
-Here, the values of @code{lang} can be @code{@{"C" | "C++" | "Java"@}}.
+Here, the value of @code{lang} is the language name, which can be
+found in @ref{Supported Languages}.
 
 Note that the output of the @code{-var-list-children} command also
 includes those expressions, so the @code{-var-info-expression} command
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 57a2f6b..0a2ef5c 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -24,6 +24,7 @@
 #include "ui-out.h"
 #include "mi-out.h"
 #include "varobj.h"
+#include "language.h"
 #include "value.h"
 #include <ctype.h>
 #include "gdb_string.h"
@@ -479,7 +480,7 @@ void
 mi_cmd_var_info_expression (char *command, char **argv, int argc)
 {
   struct ui_out *uiout = current_uiout;
-  enum varobj_languages lang;
+  const struct language_defn *lang;
   struct varobj *var;
 
   if (argc != 1)
@@ -490,7 +491,7 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc)
 
   lang = varobj_get_language (var);
 
-  ui_out_field_string (uiout, "lang", varobj_language_string[(int) lang]);
+  ui_out_field_string (uiout, "lang", lang->la_natural_name);
   ui_out_field_string (uiout, "exp", varobj_get_expression (var));
 }
 
diff --git a/gdb/varobj.c b/gdb/varobj.c
index b5cf17d..f15c9de 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -55,9 +55,6 @@ show_varobjdebug (struct ui_file *file, int from_tty,
 char *varobj_format_string[] =
   { "natural", "binary", "decimal", "hexadecimal", "octal" };
 
-/* String representations of gdb's known languages.  */
-char *varobj_language_string[] = { "C", "C++", "Java" };
-
 /* True if we want to allow Python-based pretty-printing.  */
 static int pretty_printing = 0;
 
@@ -199,8 +196,6 @@ static int install_new_value (struct varobj *var, struct value *value,
 
 /* Language-specific routines.  */
 
-static enum varobj_languages variable_language (struct varobj *var);
-
 static int number_of_children (struct varobj *);
 
 static char *name_of_variable (struct varobj *);
@@ -224,14 +219,6 @@ static struct varobj *varobj_add_child (struct varobj *var,
 
 #endif /* HAVE_PYTHON */
 
-/* Array of known source language routines.  */
-static const struct lang_varobj_ops *languages[vlang_end] = {
-  &c_varobj_ops,
-  &cplus_varobj_ops,
-  &java_varobj_ops,
-  &ada_varobj_ops,
-};
-
 /* Private data */
 
 /* Mappings of varobj_display_formats enums to gdb's format codes.  */
@@ -1126,10 +1113,10 @@ varobj_get_path_expr (struct varobj *var)
     }
 }
 
-enum varobj_languages
+const struct language_defn *
 varobj_get_language (struct varobj *var)
 {
-  return variable_language (var);
+  return var->root->exp->language_defn;
 }
 
 int
@@ -2332,32 +2319,6 @@ cppop (struct cpstack **pstack)
 
 /* Common entry points */
 
-/* Get the language of variable VAR.  */
-static enum varobj_languages
-variable_language (struct varobj *var)
-{
-  enum varobj_languages lang;
-
-  switch (var->root->exp->language_defn->la_language)
-    {
-    default:
-    case language_c:
-      lang = vlang_c;
-      break;
-    case language_cplus:
-      lang = vlang_cplus;
-      break;
-    case language_java:
-      lang = vlang_java;
-      break;
-    case language_ada:
-      lang = vlang_ada;
-      break;
-    }
-
-  return lang;
-}
-
 /* Return the number of children for a given variable.
    The result of this function is defined by the language
    implementation.  The number of children returned by this function
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 2379c3d..978d9b9 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -52,16 +52,6 @@ enum varobj_scope_status
 /* String representations of gdb's format codes (defined in varobj.c).  */
 extern char *varobj_format_string[];
 
-/* Languages supported by this variable objects system.  This enum is used
-   to index arrays so we make its first enum explicitly zero.  */
-enum varobj_languages
-  {
-    vlang_c = 0, vlang_cplus, vlang_java, vlang_ada, vlang_end
-  };
-
-/* String representations of gdb's known languages (defined in varobj.c).  */
-extern char *varobj_language_string[];
-
 /* Struct thar describes a variable object instance.  */
 
 struct varobj;
@@ -286,7 +276,7 @@ extern struct type *varobj_get_gdb_type (struct varobj *var);
 
 extern char *varobj_get_path_expr (struct varobj *var);
 
-extern enum varobj_languages varobj_get_language (struct varobj *var);
+extern const struct language_defn *varobj_get_language (struct varobj *var);
 
 extern int varobj_get_attributes (struct varobj *var);
 
-- 
1.7.7.6

  parent reply	other threads:[~2013-11-07  7:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  0:54 [PATCH 1/2] New field la_varobj_ops in struct language_defn Yao Qi
2013-10-18  0:54 ` [PATCH 2/2] Remove varobj_language_string, languages and varobj_languages Yao Qi
2013-10-25  4:15   ` Joel Brobecker
2013-10-25 13:38     ` Yao Qi
2013-10-26  4:09       ` Joel Brobecker
2013-10-28 12:50     ` [PATCH 1/3] Constify 'la_name' in struct language_defn Yao Qi
2013-10-28 12:50       ` [PATCH 3/3] Remove varobj_language_string, languages and varobj_languages Yao Qi
2013-10-28 18:52         ` Tom Tromey
2013-10-29  8:33           ` Yao Qi
2013-10-29 16:49             ` Eli Zaretskii
2013-10-31  3:10               ` Yao Qi
2013-10-31 17:31                 ` Eli Zaretskii
2013-11-07  7:23               ` Yao Qi [this message]
2013-10-28 12:50       ` [PATCH 2/3] New field 'la_natural_name' in struct language_defn Yao Qi
2013-10-28 18:34         ` Tom Tromey
2013-10-29  8:41         ` Yao Qi
2013-11-07  7:18           ` Yao Qi
2013-10-28 15:02       ` [PATCH 1/3] Constify 'la_name' " Tom Tromey
2013-10-25  3:34 ` [PATCH 1/2] New field la_varobj_ops " Joel Brobecker
2013-10-25 13:16   ` Yao Qi
2013-10-27 12:04   ` Rename field 'lang' to 'lang_ops' ([PATCH 1/2] New field la_varobj_ops in struct language_defn) 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=527B3DEF.1050105@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).