public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] introduces ADA language in varobj system
@ 2011-07-12 13:38 Jean-Charles Delay
  2011-07-12 20:09 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Charles Delay @ 2011-07-12 13:38 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

Hi,

The following will be my first, but hopefully not last, contribution to GDB.
Please be indulgent.

The current varobj system does not support the Ada language, and when run on
Ada programs, it relies on its C implementation. This patch prepares the field
by adding the Ada language definitions to the varobj system and creating the
stubs functions wrapping the current C implementation which implies no changes
in the current behavior of GDB. It is a first, but necessary, step to more
changes to enhance the Ada language support in MI.

Comments/reviews will be appreciated.

Kind regards,
 Charly.

-- 
Charly Delay

[-- Attachment #2: Introduces-ADA-language-in-varobj-system.patch --]
[-- Type: text/plain, Size: 4844 bytes --]

From 34e055df606ef5e72d0475b5119ca5bba902df3e Mon Sep 17 00:00:00 2001
From: Jean-Charles Delay <delay@adacore.com>
Date: Tue, 12 Jul 2011 10:26:12 +0200
Subject: [PATCH] Introduces ADA language in varobj system.

The varobj system uses language-specific registered callbacks to browse and
display GDB internal data structures. Until now, the Ada variant was using C
callbacks to display its types/values which irremediably led to limitations on
displaying the correct information to the user.  This patch adds these Ada
specific callbacks definition.  These callbacks are currently just wrappers to
their associated C-like functions but are meant to be progressivly refactored.

gdb/ChangeLog:

	* varobj.h (varobj_languages): Add vlang_ada definition to the list
	of supported languages.
	* varobj.c: Add top definitions and basic implementation of the
	following callbacks: ada_number_of_children, ada_name_of_variable,
	ada_name_of_child, ada_path_expr_of_child, ada_value_of_root,
	ada_value_of_child, ada_type_of_child, ada_value_of_variable.
	(languages): Register Ada-specific callbacks.
	(variable_language): Add the Ada case in the language setter switch.
---
 gdb/varobj.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 gdb/varobj.h |    2 +-
 2 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/gdb/varobj.c b/gdb/varobj.c
index 07dbc27..23bcd8d 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -361,6 +361,25 @@ static struct type *java_type_of_child (struct varobj *parent, int index);
 static char *java_value_of_variable (struct varobj *var,
 				     enum varobj_display_formats format);
 
+/* Ada implementation */
+
+static int ada_number_of_children (struct varobj *var);
+
+static char *ada_name_of_variable (struct varobj *parent);
+
+static char *ada_name_of_child (struct varobj *parent, int index);
+
+static char *ada_path_expr_of_child (struct varobj *child);
+
+static struct value *ada_value_of_root (struct varobj **var_handle);
+
+static struct value *ada_value_of_child (struct varobj *parent, int index);
+
+static struct type *ada_type_of_child (struct varobj *parent, int index);
+
+static char *ada_value_of_variable (struct varobj *var,
+				    enum varobj_display_formats format);
+
 /* The language specific vector */
 
 struct language_specific
@@ -444,7 +463,18 @@ static struct language_specific languages[vlang_end] = {
    java_value_of_root,
    java_value_of_child,
    java_type_of_child,
-   java_value_of_variable}
+   java_value_of_variable},
+  /* Ada */
+  {
+   vlang_ada,
+   ada_number_of_children,
+   ada_name_of_variable,
+   ada_name_of_child,
+   ada_path_expr_of_child,
+   ada_value_of_root,
+   ada_value_of_child,
+   ada_type_of_child,
+   ada_value_of_variable}
 };
 
 /* A little convenience enum for dealing with C++/Java.  */
@@ -2401,6 +2431,9 @@ variable_language (struct varobj *var)
     case language_java:
       lang = vlang_java;
       break;
+    case language_ada:
+      lang = vlang_ada;
+      break;
     }
 
   return lang;
@@ -3584,6 +3617,56 @@ java_value_of_variable (struct varobj *var, enum varobj_display_formats format)
   return cplus_value_of_variable (var, format);
 }
 
+/* Ada specific callbacks for VAROBJs.  */
+
+static int
+ada_number_of_children (struct varobj *var)
+{
+  return c_number_of_children (var);
+}
+
+static char *
+ada_name_of_variable (struct varobj *parent)
+{
+  return c_name_of_variable (parent);
+}
+
+static char *
+ada_name_of_child (struct varobj *parent, int index)
+{
+  return c_name_of_child (parent, index);
+}
+
+static char*
+ada_path_expr_of_child (struct varobj *child)
+{
+  return c_path_expr_of_child (child);
+}
+
+static struct value *
+ada_value_of_root (struct varobj **var_handle)
+{
+  return c_value_of_root (var_handle);
+}
+
+static struct value *
+ada_value_of_child (struct varobj *parent, int index)
+{
+  return c_value_of_child (parent, index);
+}
+
+static struct type *
+ada_type_of_child (struct varobj *parent, int index)
+{
+  return c_type_of_child (parent, index);
+}
+
+static char *
+ada_value_of_variable (struct varobj *var, enum varobj_display_formats format)
+{
+  return c_value_of_variable (var, format);
+}
+
 /* Iterate all the existing _root_ VAROBJs and call the FUNC callback for them
    with an arbitrary caller supplied DATA pointer.  */
 
diff --git a/gdb/varobj.h b/gdb/varobj.h
index ef984c8..7bf87d9 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -56,7 +56,7 @@ extern char *varobj_format_string[];
 /* Languages supported by this variable objects system.  */
 enum varobj_languages
   {
-    vlang_unknown = 0, vlang_c, vlang_cplus, vlang_java, vlang_end
+    vlang_unknown = 0, vlang_c, vlang_cplus, vlang_java, vlang_ada, vlang_end
   };
 
 /* String representations of gdb's known languages (defined in varobj.c).  */
-- 
1.7.6


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] introduces ADA language in varobj system
  2011-07-12 13:38 [PATCH] introduces ADA language in varobj system Jean-Charles Delay
@ 2011-07-12 20:09 ` Tom Tromey
  2011-07-18 15:15   ` Jean-Charles Delay
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2011-07-12 20:09 UTC (permalink / raw)
  To: delay; +Cc: gdb-patches

>>>>> "Charly" == Jean-Charles Delay <delay@adacore.com> writes:

Charly> The following will be my first, but hopefully not last,
Charly> contribution to GDB.

Welcome!

Charly> This patch prepares the field by adding the Ada language
Charly> definitions to the varobj system and creating the stubs
Charly> functions wrapping the current C implementation which implies no
Charly> changes in the current behavior of GDB. It is a first, but
Charly> necessary, step to more changes to enhance the Ada language
Charly> support in MI.

I think it is generally best to hold a patch like this until you have
written the follow-on patches; then submit them as a patch series.

That said, this patch is ok.  Please also send and commit a patch adding
yourself to the write-after-approval section of gdb/MAINTAINERS.  If you
do not have a sourceware account, let me know off-list and I will tell
you how to get one.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] introduces ADA language in varobj system
  2011-07-12 20:09 ` Tom Tromey
@ 2011-07-18 15:15   ` Jean-Charles Delay
  0 siblings, 0 replies; 3+ messages in thread
From: Jean-Charles Delay @ 2011-07-18 15:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: delay, gdb-patches

* Tom Tromey <tromey@redhat.com>:
> That said, this patch is ok.  Please also send and commit a patch adding
> yourself to the write-after-approval section of gdb/MAINTAINERS.

Thanks for the review. Both patches committed.

-- 
Charly

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-18  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12 13:38 [PATCH] introduces ADA language in varobj system Jean-Charles Delay
2011-07-12 20:09 ` Tom Tromey
2011-07-18 15:15   ` Jean-Charles Delay

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).