From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27045 invoked by alias); 18 Sep 2013 13:55:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26998 invoked by uid 89); 18 Sep 2013 13:55:45 -0000 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Sep 2013 13:55:45 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_20,KHOP_THREADED,RDNS_NONE,SPF_HELO_FAIL autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VMIEF-0006YH-KM from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 18 Sep 2013 06:55:39 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 Sep 2013 06:55:39 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Wed, 18 Sep 2013 06:55:39 -0700 From: Yao Qi To: Subject: [PATCH 5/7] New lang-varobj.h Date: Wed, 18 Sep 2013 13:55:00 -0000 Message-ID: <1379512482-31773-6-git-send-email-yao@codesourcery.com> In-Reply-To: <1379512482-31773-1-git-send-email-yao@codesourcery.com> References: <1379512482-31773-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00596.txt.bz2 This patch moves 'struct language_specific' out of varobj.c to a new file 'lang-varobj.h'. gdb: 2013-09-18 Yao Qi * Makefile.in (HFILES_NO_SRCDIR): Add lang-varobj.h. * lang-varobj.h: New. * varobj.c: Include "lang-varobj.h". (struct varobj_root): : 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 . */ + +#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