This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA/RFC] Multi-arch CPLUS_MARKER
From: Daniel Jacobowitz <drow@mvista.com>
Date: Mon, 22 Apr 2002 10:28:39 -0400
> -/* 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
> };
One of the other uses you cleaned up (cplus_markers) had a legitimate
reason to be an array instead of a string. This one doesn't now that
it doesn't include CPLUS_MARKER. Please clean that up - and I'd prefer
a comment like:
/* This (prepended with the character CPLUS_MARKER) is what it was for
gcc 2.4.5 and earlier. */
("This was what it was" is disturbingly bad grammar...)
Ok, done.
You don't need to, but feel free to kill STREQ every time you run
across it.
Ok, done.
Comment lies. You changed the default to a '.' there, which is almost
certainly wrong. Did you mean '$'?
Indeed, fixed.
How does it look now?
2002-04-22 David S. Miller <davem@redhat.com>
* cp-valprint.c (vtbl_ptr_name_old): Fix comment and 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~ Tue Apr 23 03:44:35 2002
+++ cp-valprint.c Tue Apr 23 03:49:12 2002
@@ -167,12 +167,9 @@ cp_print_class_method (char *valaddr,
}
}
-/* This was what it was for gcc 2.4.5 and earlier. */
-static const char vtbl_ptr_name_old[] =
-{
- CPLUS_MARKER, 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_',
- 't', 'y', 'p', 'e', 0
-};
+/* This (prepended with the character CPLUS_MARKER) is what it was for
+ gcc 2.4.5 and earlier. */
+static const char vtbl_ptr_name_old[] = "vtbl_ptr_type";
/* It was changed to this after 2.4.5. */
const char vtbl_ptr_name[] = "__vtbl_ptr_type";
@@ -191,8 +188,9 @@ cp_is_vtbl_ptr_type (struct type *type)
char *typename = type_name_no_tag (type);
return (typename != NULL
- && (STREQ (typename, vtbl_ptr_name)
- || STREQ (typename, vtbl_ptr_name_old)));
+ && (! strcmp (typename, vtbl_ptr_name)
+ || (typename[0] == CPLUS_MARKER
+ && ! strcmp (typename + 1, vtbl_ptr_name_old))));
}
/* Return truth value for the assertion that TYPE is of the type
--- demangle.c.~1~ Tue Apr 23 03:38:39 2002
+++ demangle.c Tue Apr 23 03:44:48 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
--- gdbarch.c.~1~ Tue Apr 23 03:38:39 2002
+++ gdbarch.c Tue Apr 23 03:51:04 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~ Tue Apr 23 03:38:39 2002
+++ gdbarch.h Tue Apr 23 03:44:48 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. */
--- gdbarch.sh.~1~ Tue Apr 23 03:38:39 2002
+++ gdbarch.sh Tue Apr 23 03:49:34 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;
}
}
--- stabsread.c.~1~ Tue Apr 23 03:38:39 2002
+++ stabsread.c Tue Apr 23 03:44:48 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);