This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/RFC] Multi-arch CPLUS_MARKER



The only tricky bit here was keeping libiberty's demangler uptodate
when the target architecture changes.  Initially I thought I could use
the gdb event mechanism to take care of this, but currently that is
unary and really appears to be a hack for the user interfaces of GDB
to make use of.

So as a result I added the call after architecture_changed_event.

The rest was just a matter of getting CPLUS_MARKER evaluated at
runtime.

Ok to install?

2002-04-22  David S. Miller  <davem@redhat.com>

	* cp-valprint.c (vtbl_ptr_name_old): Remove CPLUS_MARKER from
	here...
	(cp_is_vtbl_ptr_type): ... to here so we can compute it at
	runtime.
	* demangle.c (cplus_markers): Remove CPLUS_MARKER from here...
	(is_cplus_marker): ... to here so we can compute it at runtime.
	* stabsread.c (vptr_name, vb_name): Move...
	(read_cpp_abbrev, read_tilde_fields): ...to here so that
	CPLUS_MARKER can be computed at runtime.
	(read_member_functions): Drop static from 'opname' declaration
	so CPLUS_MARKER can be compted at runtime.
	* gdbarch.sh: Add CPLUS_MARKER.  Include demangle.h.  Right
	after architecture_changed_event is invoked, call
	set_cplus_marker_for_demangling with the updated CPLUS_MARKER.
	* gdbarch.c, gdbarch.h: Regenerate.
	
--- ./cp-valprint.c.~1~	Sat Mar 16 12:53:14 2002
+++ ./cp-valprint.c	Mon Apr 22 01:51:21 2002
@@ -167,10 +167,11 @@ cp_print_class_method (char *valaddr,
     }
 }
 
-/* This was what it was for gcc 2.4.5 and earlier.  */
+/* This was what it was for gcc 2.4.5 and earlier, prepended with
+   the character CPLUS_MARKER.  */
 static const char vtbl_ptr_name_old[] =
 {
-  CPLUS_MARKER, 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 
+  'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 
   't', 'y', 'p', 'e', 0
 };
 
@@ -192,7 +193,8 @@ cp_is_vtbl_ptr_type (struct type *type)
 
   return (typename != NULL
 	  && (STREQ (typename, vtbl_ptr_name)
-	      || STREQ (typename, vtbl_ptr_name_old)));
+	      || (typename[0] == CPLUS_MARKER
+		  && STREQ (typename + 1, vtbl_ptr_name_old))));
 }
 
 /* Return truth value for the assertion that TYPE is of the type
--- ./demangle.c.~1~	Mon Feb  4 20:37:21 2002
+++ ./demangle.c	Mon Apr 22 01:52:30 2002
@@ -167,12 +167,12 @@ set_demangling_style (char *style)
    marker symbol (FIXME). */
 
 static char cplus_markers[] =
-{CPLUS_MARKER, '.', '$', '\0'};
+{'.', '$', '\0'};
 
 int
 is_cplus_marker (int c)
 {
-  return c && strchr (cplus_markers, c) != NULL;
+  return c && ((c == CPLUS_MARKER) || strchr (cplus_markers, c) != NULL);
 }
 
 void
--- ./stabsread.c.~1~	Wed Mar 20 16:53:44 2002
+++ ./stabsread.c	Mon Apr 22 01:58:26 2002
@@ -182,11 +182,6 @@ resolve_symbol_reference (struct objfile
 
 void stabsread_clear_cache (void);
 
-static const char vptr_name[] =
-{'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
-static const char vb_name[] =
-{'_', 'v', 'b', CPLUS_MARKER, '\0'};
-
 /* Define this as 1 if a pcc declaration of a char or short argument
    gives the correct address.  Otherwise assume pcc gives the
    address of the corresponding int, which is not the same on a
@@ -3096,8 +3091,8 @@ read_member_functions (struct field_info
 	  /* This lets the user type "break operator+".
 	     We could just put in "+" as the name, but that wouldn't
 	     work for "*".  */
-	  static char opname[32] =
-	  {'o', 'p', CPLUS_MARKER};
+	  /* CPLUS_MARKER must be computed at runtime */
+	  char opname[32] = {'o', 'p', CPLUS_MARKER};
 	  char *o = opname + 3;
 
 	  /* Skip past '::'.  */
@@ -3358,6 +3353,9 @@ static int
 read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
 		 struct objfile *objfile)
 {
+  /* CPLUS_MARKER must be computed at runtime */
+  char vptr_name[] = { '_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
+  char vb_name[] = {'_', 'v', 'b', CPLUS_MARKER, '\0'};
   register char *p;
   char *name;
   char cpp_abbrev;
@@ -3842,6 +3840,8 @@ static int
 read_tilde_fields (struct field_info *fip, char **pp, struct type *type,
 		   struct objfile *objfile)
 {
+  /* CPLUS_MARKER must be computed at runtime */
+  char vptr_name[] = { '_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
   register char *p;
 
   STABS_CONTINUE (pp, objfile);
--- ./gdbarch.sh.~1~	Sat Apr 20 10:41:18 2002
+++ ./gdbarch.sh	Mon Apr 22 02:11:27 2002
@@ -505,6 +505,10 @@ f:2:INIT_FRAME_PC:void:init_frame_pc:int
 v:2:BELIEVE_PCC_PROMOTION:int:believe_pcc_promotion:::::::
 v:2:BELIEVE_PCC_PROMOTION_TYPE:int:believe_pcc_promotion_type:::::::
 f:2:COERCE_FLOAT_TO_DOUBLE:int:coerce_float_to_double:struct type *formal, struct type *actual:formal, actual:::default_coerce_float_to_double::0
+# The character that G++ uses to distinguish compiler-generated identifiers
+# from programmer-specified identifiers.  By default, this expands into
+# '$'.  Most System V target should define this to '.'.
+v:2:CPLUS_MARKER:int:cplus_marker::::'.':::
 # GET_SAVED_REGISTER is like DUMMY_FRAMES.  It is at level one as the
 # old code has strange #ifdef interaction.  So far no one has found
 # that default_get_saved_register() is the default they are after.
@@ -1214,6 +1218,7 @@ cat <<EOF
 #include "value.h"		/* For old tm.h/nm.h macros.  */
 #endif
 #include "symcat.h"
+#include "demangle.h"
 
 #include "floatformat.h"
 
@@ -2176,6 +2181,7 @@ gdbarch_update_p (struct gdbarch_info in
 	    current_gdbarch = new_gdbarch;
 	    swapin_gdbarch_swap (new_gdbarch);
 	    architecture_changed_event ();
+	    set_cplus_marker_for_demangling (CPLUS_MARKER);
 	    return 1;
 	  }
       }
--- ./gdbarch.c.~1~	Sat Apr 20 10:41:18 2002
+++ ./gdbarch.c	Mon Apr 22 02:12:35 2002
@@ -58,6 +58,7 @@
 #include "value.h"		/* For old tm.h/nm.h macros.  */
 #endif
 #include "symcat.h"
+#include "demangle.h"
 
 #include "floatformat.h"
 
@@ -195,6 +196,7 @@ struct gdbarch
   int believe_pcc_promotion;
   int believe_pcc_promotion_type;
   gdbarch_coerce_float_to_double_ftype *coerce_float_to_double;
+  int cplus_marker;
   gdbarch_get_saved_register_ftype *get_saved_register;
   gdbarch_register_convertible_ftype *register_convertible;
   gdbarch_register_convert_to_virtual_ftype *register_convert_to_virtual;
@@ -341,6 +343,7 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   0,
+  '.',
   generic_get_saved_register,
   0,
   0,
@@ -1005,6 +1008,14 @@ gdbarch_dump (struct gdbarch *gdbarch, s
                         (long) current_gdbarch->convert_from_func_ptr_addr
                         /*CONVERT_FROM_FUNC_PTR_ADDR ()*/);
 #endif
+#ifdef CPLUS_MARKER
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: CPLUS_MARKER # %s\n",
+                      XSTRING (CPLUS_MARKER));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: CPLUS_MARKER = %d\n",
+                      CPLUS_MARKER);
+#endif
 #ifdef DECR_PC_AFTER_BREAK
   fprintf_unfiltered (file,
                       "gdbarch_dump: DECR_PC_AFTER_BREAK # %s\n",
@@ -3372,6 +3383,21 @@ set_gdbarch_coerce_float_to_double (stru
   gdbarch->coerce_float_to_double = coerce_float_to_double;
 }
 
+int
+gdbarch_cplus_marker (struct gdbarch *gdbarch)
+{
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_cplus_marker called\n");
+  return gdbarch->cplus_marker;
+}
+
+void
+set_gdbarch_cplus_marker (struct gdbarch *gdbarch,
+                          int cplus_marker)
+{
+  gdbarch->cplus_marker = cplus_marker;
+}
+
 void
 gdbarch_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval)
 {
@@ -4973,6 +4999,7 @@ gdbarch_update_p (struct gdbarch_info in
 	    current_gdbarch = new_gdbarch;
 	    swapin_gdbarch_swap (new_gdbarch);
 	    architecture_changed_event ();
+	    set_cplus_marker_for_demangling (CPLUS_MARKER);
 	    return 1;
 	  }
       }
--- ./gdbarch.h.~1~	Sat Apr 20 10:41:18 2002
+++ ./gdbarch.h	Mon Apr 22 02:11:55 2002
@@ -1190,6 +1190,21 @@ extern void set_gdbarch_coerce_float_to_
 #endif
 #endif
 
+/* The character that G++ uses to distinguish compiler-generated identifiers
+   from programmer-specified identifiers.  By default, this expands into
+   '$'.  Most System V target should define this to '.'. */
+
+extern int gdbarch_cplus_marker (struct gdbarch *gdbarch);
+extern void set_gdbarch_cplus_marker (struct gdbarch *gdbarch, int cplus_marker);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CPLUS_MARKER)
+#error "Non multi-arch definition of CPLUS_MARKER"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (CPLUS_MARKER)
+#define CPLUS_MARKER (gdbarch_cplus_marker (current_gdbarch))
+#endif
+#endif
+
 /* GET_SAVED_REGISTER is like DUMMY_FRAMES.  It is at level one as the
    old code has strange #ifdef interaction.  So far no one has found
    that default_get_saved_register() is the default they are after. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]