gdb: Convert language skip_trampoline field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 14 May 2020 22:19:48 +0000 (23:19 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 2 Jun 2020 12:53:11 +0000 (13:53 +0100)
This commit changes the language_data::skip_trampoline 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 skip_trampoline
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::skip_trampoline): New member function.
(asm_language_data): Delete skip_trampoline initializer.
(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_trampoline): Delete function.
(skip_language_trampoline): Update.
(unknown_language_data): Delete skip_trampoline initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete skip_trampoline field.
(language_defn::skip_trampoline): New function.
* m2-lang.c (m2_language_data): Delete skip_trampoline
initializer.
* objc-lang.c (objc_skip_trampoline): Delete function, move
implementation to objc_language::skip_trampoline.
(objc_language_data): Delete skip_trampoline initializer.
(objc_language::skip_trampoline): New member function with
implementation from objc_skip_trampoline.
* opencl-lang.c (opencl_language_data): Delete skip_trampoline
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

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 1390be1933f9fa960b1b0409d5c2af309c02c809..393651799ef9a73cfeb64a4751ee4f04a671378f 100644 (file)
@@ -1,3 +1,33 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete skip_trampoline
+       initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (cplus_language_data): Likewise.
+       (cplus_language::skip_trampoline): New member function.
+       (asm_language_data): Delete skip_trampoline initializer.
+       (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_trampoline): Delete function.
+       (skip_language_trampoline): Update.
+       (unknown_language_data): Delete skip_trampoline initializer.
+       (auto_language_data): Likewise.
+       * language.h (language_data): Delete skip_trampoline field.
+       (language_defn::skip_trampoline): New function.
+       * m2-lang.c (m2_language_data): Delete skip_trampoline
+       initializer.
+       * objc-lang.c (objc_skip_trampoline): Delete function, move
+       implementation to objc_language::skip_trampoline.
+       (objc_language_data): Delete skip_trampoline initializer.
+       (objc_language::skip_trampoline): New member function with
+       implementation from objc_skip_trampoline.
+       * opencl-lang.c (opencl_language_data): Delete skip_trampoline
+       initializer.
+       * p-lang.c (pascal_language_data): Likewise.
+       * rust-lang.c (rust_language_data): Likewise.
+
 2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Delete la_demangle initializer.
index 42e57093bf97eed48711b31560825cde4e921b8e..b1c689beb0fe307799cbfc20f73f1ae3ca495090 100644 (file)
@@ -13922,7 +13922,6 @@ extern const struct language_data ada_language_data =
   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,                         /* Language specific skip_trampoline */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
index de7a1bda3466449652623baa2b49345c7e4f4b96..364a672119aec2d8404ab58a39e419b06e376f3c 100644 (file)
@@ -908,7 +908,6 @@ extern const struct language_data c_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -1017,7 +1016,6 @@ extern const struct language_data cplus_language_data =
   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 */
-  cplus_skip_trampoline,       /* Language specific skip_trampoline */
   "this",                       /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
@@ -1157,6 +1155,14 @@ public:
   {
     c_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  CORE_ADDR skip_trampoline (struct frame_info *fi,
+                            CORE_ADDR pc) const override
+  {
+    return cplus_skip_trampoline (fi, pc);
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1189,7 +1195,6 @@ extern const struct language_data asm_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -1263,7 +1268,6 @@ extern const struct language_data minimal_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index fb56e1e9bafd105aed46b784f962047c8720c7ef..81e3aac87ba6bb4a73b0df5ac3e0af0f4b8e3714 100644 (file)
@@ -151,7 +151,6 @@ extern const struct language_data d_language_data =
                                   syntax.  */
   d_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value.  */
-  NULL,                                /* Language specific skip_trampoline.  */
   "this",
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
index bd5f78ccbef23292c21c4c3e2a07c7cfdc50a379..90a794ef4bab10a3c940e767777bd4e5d6e72147 100644 (file)
@@ -611,7 +611,6 @@ extern const struct language_data f_language_data =
   f_print_typedef,             /* Print a typedef using appropriate syntax */
   f_value_print_innner,                /* la_value_print_inner */
   c_value_print,               /* FIXME */
-  NULL,                                /* Language specific skip_trampoline */
   NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
index 6bd87aa597bba0af39d7481aa82e8c21334a9cf4..3975dfcb482ee2c0400e4ce9cfe3b45dc430013e 100644 (file)
@@ -536,7 +536,6 @@ extern const struct language_data go_language_data =
                                   syntax.  */
   go_value_print_inner,                /* la_value_print_inner */
   c_value_print,               /* Print a top-level value.  */
-  NULL,                                /* Language specific skip_trampoline.  */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
index c447eaba0c5540a64cdf10715eb2628d687e729c..ba4d96cf89b4a043d7cc01cfb6acc629bbeaf068 100644 (file)
@@ -60,8 +60,6 @@ static void unk_lang_printchar (int c, struct type *type,
 static void unk_lang_value_print (struct value *, struct ui_file *,
                                  const struct value_print_options *);
 
-static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
-
 /* 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
@@ -567,13 +565,10 @@ skip_language_trampoline (struct frame_info *frame, CORE_ADDR pc)
 {
   for (const auto &lang : language_defn::languages)
     {
-      if (lang->skip_trampoline != NULL)
-       {
-         CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
+      CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
 
-         if (real_pc)
-           return real_pc;
-       }
+      if (real_pc != 0)
+       return real_pc;
     }
 
   return 0;
@@ -744,11 +739,6 @@ unk_lang_value_print (struct value *val, struct ui_file *stream,
           "function unk_lang_value_print called."));
 }
 
-static CORE_ADDR unk_lang_trampoline (struct frame_info *frame, CORE_ADDR pc)
-{
-  return 0;
-}
-
 static char *unk_lang_class_name (const char *mangled)
 {
   return NULL;
@@ -790,7 +780,6 @@ extern const struct language_data unknown_language_data =
   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 */
-  unk_lang_trampoline,         /* Language specific skip_trampoline */
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
@@ -868,7 +857,6 @@ extern const struct language_data auto_language_data =
   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 */
-  unk_lang_trampoline,         /* Language specific skip_trampoline */
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index c456189b14dc359b32357cc693c1375a33b2e520..05ad132d01b5ffee9715849f525fdbc14d50890b 100644 (file)
@@ -267,12 +267,6 @@ struct language_data
     void (*la_value_print) (struct value *, struct ui_file *,
                            const struct value_print_options *);
 
-    /* PC is possibly an unknown languages trampoline.
-       If that PC falls in a trampoline belonging to this language,
-       return the address of the first pc in the real function, or 0
-       if it isn't a language tramp for this language.  */
-    CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
-
     /* Now come some hooks for lookup_symbol.  */
 
     /* If this is non-NULL, specifies the name that of the implicit
@@ -520,6 +514,15 @@ struct language_defn : language_data
   virtual void print_type (struct type *, const char *, struct ui_file *, int,
                           int, const struct type_print_options *) const = 0;
 
+  /* PC is possibly an unknown languages trampoline.
+     If that PC falls in a trampoline belonging to this language, return
+     the address of the first pc in the real function, or 0 if it isn't a
+     language tramp for this language.  */
+  virtual CORE_ADDR skip_trampoline (struct frame_info *fi, CORE_ADDR pc) const
+  {
+    return (CORE_ADDR) 0;
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
index a83cf1451b1297280e1748c779bce59217d79d34..f174ad55823f30a487441d9d5f0ee9b080707037 100644 (file)
@@ -370,7 +370,6 @@ extern const struct language_data m2_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 1e3d1fd3616510c207437c3c1c7570690de00acc..ff028fc012a9164f850b684cb1572af833ff2733 100644 (file)
@@ -281,37 +281,6 @@ objc_demangle (const char *mangled, int options)
     return NULL;       /* Not an objc mangled name.  */
 }
 
-/* Determine if we are currently in the Objective-C dispatch function.
-   If so, get the address of the method function that the dispatcher
-   would call and use that as the function to step into instead.  Also
-   skip over the trampoline for the function (if any).  This is better
-   for the user since they are only interested in stepping into the
-   method function anyway.  */
-static CORE_ADDR 
-objc_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  CORE_ADDR real_stop_pc;
-  CORE_ADDR method_stop_pc;
-  
-  real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc);
-
-  if (real_stop_pc != 0)
-    find_objc_msgcall (real_stop_pc, &method_stop_pc);
-  else
-    find_objc_msgcall (stop_pc, &method_stop_pc);
-
-  if (method_stop_pc)
-    {
-      real_stop_pc = gdbarch_skip_trampoline_code
-                      (gdbarch, frame, method_stop_pc);
-      if (real_stop_pc == 0)
-       real_stop_pc = method_stop_pc;
-    }
-
-  return real_stop_pc;
-}
-
 
 /* Table mapping opcodes into strings for printing operators
    and precedences of the operators.  */
@@ -376,7 +345,6 @@ extern const struct language_data objc_language_data =
   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 */
-  objc_skip_trampoline,        /* Language specific skip_trampoline */
   "self",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
@@ -434,6 +402,40 @@ public:
   {
     c_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  CORE_ADDR skip_trampoline (struct frame_info *frame,
+                            CORE_ADDR stop_pc) const override
+  {
+    struct gdbarch *gdbarch = get_frame_arch (frame);
+    CORE_ADDR real_stop_pc;
+    CORE_ADDR method_stop_pc;
+
+    /* Determine if we are currently in the Objective-C dispatch function.
+       If so, get the address of the method function that the dispatcher
+       would call and use that as the function to step into instead.  Also
+       skip over the trampoline for the function (if any).  This is better
+       for the user since they are only interested in stepping into the
+       method function anyway.  */
+
+    real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc);
+
+    if (real_stop_pc != 0)
+      find_objc_msgcall (real_stop_pc, &method_stop_pc);
+    else
+      find_objc_msgcall (stop_pc, &method_stop_pc);
+
+    if (method_stop_pc)
+      {
+       real_stop_pc = gdbarch_skip_trampoline_code
+         (gdbarch, frame, method_stop_pc);
+       if (real_stop_pc == 0)
+         real_stop_pc = method_stop_pc;
+      }
+
+    return real_stop_pc;
+  }
 };
 
 /* Single instance of the class representing the Objective-C language.  */
index d98b228bc74dcb86488c80e9188d226853b773f7..eaf61c3fc1aad18e7bf3bcf4e81a75946fbdd300 100644 (file)
@@ -1024,7 +1024,6 @@ extern const struct language_data opencl_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                         /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 50b913e8b6c12900cc7360646b3bd1ef81013e4b..777f1ffe217a2c42325769983a354c86ea2cb599 100644 (file)
@@ -401,7 +401,6 @@ extern const struct language_data pascal_language_data =
   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 */
-  NULL,                                /* Language specific skip_trampoline */
   "this",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
index 8848e975228b003426dcd8ab8c6755a4d4f1d682..0929daf0511090df9acc46aa5f0cad19e10d2eaf 100644 (file)
@@ -2056,7 +2056,6 @@ extern const struct language_data rust_language_data =
   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,                                /* Language specific skip_trampoline */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */