gdb: Convert language la_value_print field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 1 Jun 2020 14:21:33 +0000 (15:21 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 17 Jun 2020 08:25:11 +0000 (09:25 +0100)
This commit changes the language_data::la_value_print function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_value_print
initializer.
(ada_language::value_print): New member function.
* c-lang.c (c_language_data): Delete la_value_print initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unk_lang_value_print): Delete.
(language_defn::value_print): Define new member function.
(unknown_language_data): Delete la_value_print initializer.
(unknown_language::value_print): New member function.
(auto_language_data): Delete la_value_print initializer.
(auto_language::value_print): New member function.
* language.h (language_data): Delete la_value_print field.
(language_defn::value_print): Declare new member function.
(LA_VALUE_PRINT): Update call to value_print.
* m2-lang.c (m2_language_data): Delete la_value_print initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::value_print): New member function.
* rust-lang.c (rust_language_data): Delete la_value_print
initializer.

13 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c

index 2b8ea9617f3b97553f7f0dcaed55192fa5e3da08..d1acf26d8ef65bad21d318b2885eee0fd3377d79 100644 (file)
@@ -1,3 +1,32 @@
+2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete la_value_print
+       initializer.
+       (ada_language::value_print): New member function.
+       * c-lang.c (c_language_data): Delete la_value_print initializer.
+       (cplus_language_data): Likewise.
+       (asm_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * f-lang.c (f_language_data): Likewise.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (unk_lang_value_print): Delete.
+       (language_defn::value_print): Define new member function.
+       (unknown_language_data): Delete la_value_print initializer.
+       (unknown_language::value_print): New member function.
+       (auto_language_data): Delete la_value_print initializer.
+       (auto_language::value_print): New member function.
+       * language.h (language_data): Delete la_value_print field.
+       (language_defn::value_print): Declare new member function.
+       (LA_VALUE_PRINT): Update call to value_print.
+       * m2-lang.c (m2_language_data): Delete la_value_print initializer.
+       * objc-lang.c (objc_language_data): Likewise.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       (pascal_language::value_print): New member function.
+       * rust-lang.c (rust_language_data): Delete la_value_print
+       initializer.
+
 2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_watch_location_expression): Rename to
index 392b1a679c57b9175cbaccf4f5f30d5a243db666..85483d4e4b64adebdac3094fc472dab40ca5081b 100644 (file)
@@ -13765,7 +13765,6 @@ extern const struct language_data ada_language_data =
   emit_char,                    /* Function to print single char (not used) */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   ada_value_print_inner,       /* la_value_print_inner */
-  ada_value_print,              /* Print a top-level value */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
@@ -14101,6 +14100,14 @@ public:
       (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
   }
 
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    return ada_value_print (val, stream, options);
+  }
+
 protected:
   /* See language.h.  */
 
index 42141e28dd4cb255b40d4b5a20d3111ce165720d..6aa05a63119855c561bfc6d49bf354351ec8f0a2 100644 (file)
@@ -896,7 +896,6 @@ extern const struct language_data c_language_data =
   c_emit_char,                 /* Print a single char */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -1007,7 +1006,6 @@ extern const struct language_data cplus_language_data =
   c_emit_char,                 /* Print a single char */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   "this",                       /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
@@ -1206,7 +1204,6 @@ extern const struct language_data asm_language_data =
   c_emit_char,                 /* Print a single char */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -1272,7 +1269,6 @@ extern const struct language_data minimal_language_data =
   c_emit_char,                 /* Print a single char */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 001af06a82af1fdfc1bcd583460bbea9dda97c39..553b38de81e770bfad33b1807d0c7e2098af8a58 100644 (file)
@@ -150,7 +150,6 @@ extern const struct language_data d_language_data =
   c_print_typedef,             /* Print a typedef using appropriate
                                   syntax.  */
   d_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value.  */
   "this",
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
index e421e5f96451298ebdc77e401ff6cd0ce9489ad7..3e2c97c06192a18e6de1ebd87a0be9b8da042434 100644 (file)
@@ -571,7 +571,6 @@ extern const struct language_data f_language_data =
   f_emit_char,                 /* Function to print a single character */
   f_print_typedef,             /* Print a typedef using appropriate syntax */
   f_value_print_innner,                /* la_value_print_inner */
-  c_value_print,               /* FIXME */
   NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
index 5e742d710945f012c75cab7be261b06ce83f16f2..14d63ab7e8c4b6806bfd825278e67b682af8f9a4 100644 (file)
@@ -535,7 +535,6 @@ extern const struct language_data go_language_data =
   c_print_typedef,             /* Print a typedef using appropriate
                                   syntax.  */
   go_value_print_inner,                /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value.  */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
index 6320577addf84e6c5d5cea7f2c6defb1248b9291..5b47a4956ed25721ad1688a22b6ca6baca0e7809 100644 (file)
@@ -57,9 +57,6 @@ static void unk_lang_emit_char (int c, struct type *type,
 static void unk_lang_printchar (int c, struct type *type,
                                struct ui_file *stream);
 
-static void unk_lang_value_print (struct value *, struct ui_file *,
-                                 const struct value_print_options *);
-
 /* The current (default at startup) state of type and range checking.
    (If the modes are set to "auto", though, these are changed based
    on the default language at startup, and then again based on the
@@ -635,6 +632,15 @@ language_defn::watch_location_expression (struct type *type,
     (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
 }
 
+/* See language.h.  */
+
+void
+language_defn::value_print (struct value *val, struct ui_file *stream,
+              const struct value_print_options *options) const
+{
+  return c_value_print (val, stream, options);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -742,14 +748,6 @@ unk_lang_value_print_inner (struct value *val,
           "function unk_lang_value_print_inner called."));
 }
 
-static void
-unk_lang_value_print (struct value *val, struct ui_file *stream,
-                     const struct value_print_options *options)
-{
-  error (_("internal error - unimplemented "
-          "function unk_lang_value_print called."));
-}
-
 static const struct op_print unk_op_print_tab[] =
 {
   {NULL, OP_NULL, PREC_NULL, 0}
@@ -785,7 +783,6 @@ extern const struct language_data unknown_language_data =
   unk_lang_emit_char,
   default_print_typedef,       /* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,  /* la_value_print_inner */
-  unk_lang_value_print,                /* Print a top-level value */
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
@@ -829,6 +826,14 @@ public:
     /* The unknown language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    error (_("unimplemented unknown_language::value_print called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -855,7 +860,6 @@ extern const struct language_data auto_language_data =
   unk_lang_emit_char,
   default_print_typedef,       /* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,  /* la_value_print_inner */
-  unk_lang_value_print,                /* Print a top-level value */
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -899,6 +903,14 @@ public:
     /* The auto language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    error (_("unimplemented auto_language::value_print called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
index 1cd3785ab0b8e7270605bc648849f27d6d9ca6b7..4b27c010b0e947e06d8538b899671063522139a6 100644 (file)
@@ -265,11 +265,6 @@ struct language_data
                                  int recurse,
                                  const struct value_print_options *);
 
-    /* Print a top-level value using syntax appropriate for this language.  */
-
-    void (*la_value_print) (struct value *, struct ui_file *,
-                           const struct value_print_options *);
-
     /* Now come some hooks for lookup_symbol.  */
 
     /* If this is non-NULL, specifies the name that of the implicit
@@ -543,6 +538,10 @@ struct language_defn : language_data
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
+  /* Print a top-level value using syntax appropriate for this language.  */
+  virtual void value_print (struct value *val, struct ui_file *stream,
+                           const struct value_print_options *options) const;
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -642,7 +641,7 @@ extern enum language set_language (enum language);
   (current_language->la_print_typedef(type,new_symbol,stream))
 
 #define LA_VALUE_PRINT(val,stream,options) \
-  (current_language->la_value_print(val,stream,options))
+  (current_language->value_print (val,stream,options))
 
 #define LA_PRINT_CHAR(ch, type, stream) \
   (current_language->la_printchar(ch, type, stream))
index 6dbc48767dcb8018b3be913a4b27434fb30b6a86..615c2f95bd2709fec9a400f56c94276aaf5fe7cf 100644 (file)
@@ -369,7 +369,6 @@ extern const struct language_data m2_language_data =
   m2_emit_char,                        /* Function to print a single character */
   m2_print_typedef,            /* Print a typedef using appropriate syntax */
   m2_value_print_inner,                /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index fa5aa9bc06e4eaad13c82aa7add08f0ceaecdb6c..aa9d1a9312cb06de918f015b6782b68272ddb137 100644 (file)
@@ -344,7 +344,6 @@ extern const struct language_data objc_language_data =
   c_emit_char,
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   "self",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 4cdfc045e04df10149d3316a04d307a00b872fc0..1b7553dde6e1435aced737b72d1bfc6e19cd11d2 100644 (file)
@@ -1023,7 +1023,6 @@ extern const struct language_data opencl_language_data =
   c_emit_char,                 /* Print a single char */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                         /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 808e9e51a2705517e88f79b02a4222b793b94a3c..ff3ba3b56e048d53bfed68ecf33f6c54779f3a18 100644 (file)
@@ -400,7 +400,6 @@ extern const struct language_data pascal_language_data =
   pascal_emit_char,            /* Print a single char */
   pascal_print_typedef,                /* Print a typedef using appropriate syntax */
   pascal_value_print_inner,    /* la_value_print_inner */
-  pascal_value_print,          /* Print a top-level value */
   "this",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -478,6 +477,14 @@ public:
   {
     pascal_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    return pascal_value_print (val, stream, options);
+  }
 };
 
 /* Single instance of the Pascal language class.  */
index fec68e3819374e2593b93f897e16f5ba1185270b..e48be115afcef506041a37733bfc3ee74ee0edb4 100644 (file)
@@ -2041,7 +2041,6 @@ extern const struct language_data rust_language_data =
   rust_emitchar,               /* Print a single char */
   rust_print_typedef,          /* Print a typedef using appropriate syntax */
   rust_value_print_inner,      /* la_value_print_inner */
-  c_value_print,               /* Print a top-level value */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */