[PATCHv2,13/13] gdb: Convert language skip_trampoline field to a method

Message ID fc9395b63955c1d5cee8581712371ec4aac177c7.1589555077.git.andrew.burgess@embecosm.com
State New
Headers show
Series
  • Starting to convert languages to separate classes
Related show

Commit Message

Andrew Burgess May 15, 2020, 3:06 p.m.
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.
---
 gdb/ChangeLog     | 30 +++++++++++++++++++++
 gdb/ada-lang.c    |  1 -
 gdb/c-lang.c      | 12 ++++++---
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      |  1 -
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 18 +++----------
 gdb/language.h    | 15 ++++++-----
 gdb/m2-lang.c     |  1 -
 gdb/objc-lang.c   | 66 ++++++++++++++++++++++++-----------------------
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      |  1 -
 gdb/rust-lang.c   |  1 -
 13 files changed, 84 insertions(+), 65 deletions(-)

-- 
2.25.4

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3c151588ecb..6acaaa6d86a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13919,7 +13919,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.  */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 75efb6ae592..c998c5886b3 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -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 @@  class cplus_language : public language_defn
   {
     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 */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index fb56e1e9baf..81e3aac87ba 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -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,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index bd5f78ccbef..90a794ef4ba 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -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 */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 47a4abcc2fe..76408f4fecb 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -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, 
diff --git a/gdb/language.c b/gdb/language.c
index e6ca03f4916..f7faa2b8a4c 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -61,8 +61,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
@@ -568,13 +566,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;
@@ -743,11 +738,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;
@@ -789,7 +779,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 */
@@ -867,7 +856,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 */
diff --git a/gdb/language.h b/gdb/language.h
index bee479720ae..697cdb4909d 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -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
@@ -519,6 +513,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];
 };
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 4bc25ce82fe..7e306b4b2f4 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -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 */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 1e3d1fd3616..ff028fc012a 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -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 @@  class objc_language : public language_defn
   {
     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.  */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index dc5d69873f6..e128fbc676a 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -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 */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 70f8e5af80a..50143b9facd 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -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 */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 9afe0b1f16f..682dbf02214 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -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 */