This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
(patch) hpjyg23: gdbtypes.[ch] & values.c
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: (patch) hpjyg23: gdbtypes.[ch] & values.c
- From: Jimmy Guo <guo at cup dot hp dot com>
- Date: Fri, 12 Nov 1999 12:31:41 -0800 (PST)
***
Patch dependency: hpjyg11 (gdbtypes.h)
***
This patch covers misc. fixes to gdbtypes.c and values.c, and introduces
builtin_type_CORE_ADDR (for 32x64 fix) as well as is_float_type.
ChangeLog:
1999-11-12 Jimmy Guo <guo@cup.hp.com>
* gdbtypes.c: Misc. fixes and builtin_type_CORE_ADDR support.
(rank_one_type): return INTEGER_PROMOTION_BADNESS if parm is of
TYPE_CODE_ENUM, arg is of a compatible type, but TYPE_LENGTH
(arg) <= TYPE_LENGTH (parm); when both parm and arg are of
TYPE_CODE_STRUCT, return 0 if the tag names are the same (for
same type in different shared libraries), same for
TYPE_CODE_UNION.
(build_gdbtypes): init builtin_type_CORE_ADDR to
builtin_type_unsigned_long_long (64bit) or
builtin_type_unsigned_long (32bit).
(is_float_type): New function.
* gdbtypes.h: Misc. fixes and builtin_type_CORE_ADDR support.
(TYPE_IS_OPAQUE): include TYPE_CODE_TEMPLATE too.
(builtin_type_CORE_ADDR): Declare.
(builtin_type_f_integer_s2,builtin_type_f_integer_s8,
builtin_type_f_logical_s8): Declare, for Fortran support.
(is_float_type): Declare.
* values.c: Misc. 32x64 fixes.
Index: gdb/gdbtypes.c
/opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/gdbtypes.c gdb/gdbtypes.c
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/gdbtypes.c Thu Nov 11 14:32:32 1999
--- gdb/gdbtypes.c Fri Nov 12 12:11:03 1999
***************
*** 65,70 ****
--- 65,71 ----
struct type *builtin_type_int64;
struct type *builtin_type_uint64;
struct type *builtin_type_bool;
+ struct type *builtin_type_CORE_ADDR;
struct type *builtin_type_v4sf;
int opaque_type_resolution = 1;
***************
*** 1435,1441 ****
char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = cplus_demangle (mangled_name,
DMGL_PARAMS | DMGL_ANSI);
! char *argtypetext, *p;
int depth = 0, argcount = 1;
struct type **argtypes;
struct type *mtype;
--- 1436,1442 ----
char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = cplus_demangle (mangled_name,
DMGL_PARAMS | DMGL_ANSI);
! char *argtypetext, *p = NULL;
int depth = 0, argcount = 1;
struct type **argtypes;
struct type *mtype;
***************
*** 1669,1674 ****
--- 1670,1685 ----
|| (TYPE_CODE (t) == TYPE_CODE_BOOL)));
}
+ int
+ is_float_type (t)
+ struct type *t;
+ {
+ CHECK_TYPEDEF (t);
+ return
+ ((t != NULL) &&
+ (TYPE_CODE(t) == TYPE_CODE_FLT));
+ }
+
/* Chill varying string and arrays are represented as follows:
struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
***************
*** 2025,2040 ****
* base classes too.
*/
! /* pai: FIXME This doesn't do the right thing: count redefined virtual
! * functions only once (latest redefinition)
! */
int
count_virtual_fns (dclass)
struct type *dclass;
{
int fn, oi; /* function and overloaded instance indices */
! int vfuncs; /* count to return */
/* recurse on bases that can share virtual table */
struct type *pbc = primary_base_class (dclass);
--- 2036,2051 ----
* base classes too.
*/
! /* pai: FIXME I'm not sure that this does the right thing: it should
! probably count redefined virtual functions only once (latest redefinition).
! But see use in cp-valprint.c before changing this. */
int
count_virtual_fns (dclass)
struct type *dclass;
{
int fn, oi; /* function and overloaded instance indices */
! int vfuncs = 0; /* count to return */
/* recurse on bases that can share virtual table */
struct type *pbc = primary_base_class (dclass);
***************
*** 2291,2297 ****
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
case TYPE_CODE_ENUM:
! return INTEGER_COERCION_BADNESS;
case TYPE_CODE_FLT:
return INT_FLOAT_CONVERSION_BADNESS;
default:
--- 2302,2311 ----
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
case TYPE_CODE_ENUM:
! if (TYPE_LENGTH (arg) <= TYPE_LENGTH (parm))
! return INTEGER_PROMOTION_BADNESS;
! else
! return INTEGER_COERCION_BADNESS;
case TYPE_CODE_FLT:
return INT_FLOAT_CONVERSION_BADNESS;
default:
***************
*** 2405,2410 ****
--- 2419,2435 ----
switch (TYPE_CODE (arg))
{
case TYPE_CODE_STRUCT:
+ /* RM: the two structs may be the same type but in
+ different shared libraries. The type ptrs won't
+ compare equal, but they really are the same type (or
+ we have a violation of C++'s one definition
+ rule). Compare names to see if the two types refer to
+ the same struct. */
+ /* RM: compare tag names -- one or both names may have a
+ class/struct prefix */
+ if (!strcmp(TYPE_TAG_NAME(arg), TYPE_TAG_NAME(parm)))
+ return 0;
+
/* Check for derivation */
if (is_ancestor (parm, arg))
return BASE_CONVERSION_BADNESS;
***************
*** 2417,2422 ****
--- 2442,2456 ----
switch (TYPE_CODE (arg))
{
case TYPE_CODE_UNION:
+ /* RM: the two unions may be the same type but in
+ different shared libraries. The type ptrs won't
+ compare equal, but they really are the same type (or
+ we have a violation of C++'s one definition
+ rule). Compare names to see if the two types refer to
+ the same union. */
+ if (!strcmp(TYPE_NAME(arg), TYPE_NAME(parm)))
+ return 0;
+ /* else fall through */
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
***************
*** 2955,2960 ****
--- 2989,3000 ----
init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0,
"bool", (struct objfile *) NULL);
+
+ #ifdef BFD64
+ builtin_type_CORE_ADDR = builtin_type_unsigned_long_long;
+ #else
+ builtin_type_CORE_ADDR = builtin_type_unsigned_long;
+ #endif
/* Add user knob for controlling resolution of opaque types */
add_show_from_set
Index: gdb/gdbtypes.h
/opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/gdbtypes.h gdb/gdbtypes.h
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/gdbtypes.h Fri Nov 5 13:04:38 1999
--- gdb/gdbtypes.h Thu Nov 11 14:49:10 1999
***************
*** 827,836 ****
#define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file)
#define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line)
! #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
! (TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
! (TYPE_NFIELDS (thistype) == 0) && \
! (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
--- 827,839 ----
#define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file)
#define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line)
! #define TYPE_IS_OPAQUE(thistype) \
! (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
! (TYPE_CODE (thistype) == TYPE_CODE_UNION) || \
! /* RM: templates too */ \
! (TYPE_CODE (thistype) == TYPE_CODE_TEMPLATE)) && \
! (TYPE_NFIELDS (thistype) == 0) && \
! (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
***************
*** 877,882 ****
--- 880,891 ----
extern struct type *builtin_type_long_long;
extern struct type *builtin_type_unsigned_long_long;
+ /* builtin_type_CORE_ADDR in a 32-bit gdb will point to the same thing
+ as builtin_type_unsigned_long. In a 64-bit gdb it will point to
+ builtin_type_unsigned_long_long */
+
+ extern struct type *builtin_type_CORE_ADDR;
+
/* Modula-2 types */
extern struct type *builtin_type_m2_char;
***************
*** 897,907 ****
extern struct type *builtin_type_f_character;
extern struct type *builtin_type_f_integer;
extern struct type *builtin_type_f_logical;
extern struct type *builtin_type_f_logical_s1;
extern struct type *builtin_type_f_logical_s2;
! extern struct type *builtin_type_f_integer;
! extern struct type *builtin_type_f_integer_s2;
extern struct type *builtin_type_f_real;
extern struct type *builtin_type_f_real_s8;
extern struct type *builtin_type_f_real_s16;
--- 906,917 ----
extern struct type *builtin_type_f_character;
extern struct type *builtin_type_f_integer;
+ extern struct type *builtin_type_f_integer_s2;
+ extern struct type *builtin_type_f_integer_s8;
extern struct type *builtin_type_f_logical;
extern struct type *builtin_type_f_logical_s1;
extern struct type *builtin_type_f_logical_s2;
! extern struct type *builtin_type_f_logical_s8;
extern struct type *builtin_type_f_real;
extern struct type *builtin_type_f_real_s8;
extern struct type *builtin_type_f_real_s16;
***************
*** 1147,1152 ****
--- 1157,1164 ----
extern int can_dereference PARAMS ((struct type *));
extern int is_integral_type PARAMS ((struct type *));
+
+ extern int is_float_type PARAMS ((struct type *));
extern void maintenance_print_type PARAMS ((char *, int));
Index: gdb/values.c
/opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/values.c gdb/values.c
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/values.c Thu Nov 11 13:04:26 1999
--- gdb/values.c Thu Nov 11 13:30:04 1999
***************
*** 931,940 ****
if (VALUE_ADDRESS (argp) == 0)
error ("Address of object is null; object may not have been created.");
! /* pai: FIXME -- 32x64 possible problem? */
! /* First word (4 bytes) in object layout is the vtable pointer */
! coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (argp)); /* pai: (temp) */
! /* + offset + VALUE_EMBEDDED_OFFSET (argp)); */
if (!coreptr)
error ("Virtual table pointer is null for object; object may not have been created.");
--- 931,939 ----
if (VALUE_ADDRESS (argp) == 0)
error ("Address of object is null; object may not have been created.");
! /* First word (sizeof(CORE_ADDR) bytes) in object layout is
! the vtable pointer */
! coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (argp));
if (!coreptr)
error ("Virtual table pointer is null for object; object may not have been created.");
***************
*** 955,964 ****
* the beginning of the vtable; but first we have to adjust
* by HP_ACC_VFUNC_START to account for other entries */
! /* pai: FIXME: 32x64 problem here, a word may be 8 bytes in
! * which case the multiplier should be 8 and values should be long */
! vp = value_at (builtin_type_int,
! coreptr + 4 * (TYPE_FN_FIELD_VOFFSET (f, j) + HP_ACC_VFUNC_START), NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
--- 954,965 ----
* the beginning of the vtable; but first we have to adjust
* by HP_ACC_VFUNC_START to account for other entries */
! vp = value_at (builtin_type_CORE_ADDR,
! coreptr +
! sizeof (CORE_ADDR) *
! (TYPE_FN_FIELD_VOFFSET (f, j) +
! HP_ACC_VFUNC_START),
! NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
***************
*** 974,987 ****
/* Find class segment pointer. These are in the vtable slots after
* some other entries, so adjust by HP_ACC_VFUNC_START for that. */
! /* pai: FIXME 32x64 problem here, if words are 8 bytes long
! * the multiplier below has to be 8 and value should be long. */
! vp = value_at (builtin_type_int,
! coreptr + 4 * (HP_ACC_VFUNC_START + class_index), NULL);
/* Indirect once more, offset by function index */
! /* pai: FIXME 32x64 problem here, again multiplier could be 8 and value long */
! coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp) + 4 * TYPE_FN_FIELD_VOFFSET (f, j));
! vp = value_at (builtin_type_int, coreptr, NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
--- 975,992 ----
/* Find class segment pointer. These are in the vtable slots after
* some other entries, so adjust by HP_ACC_VFUNC_START for that. */
!
! vp = value_at (builtin_type_CORE_ADDR,
! coreptr +
! sizeof (CORE_ADDR) *
! (HP_ACC_VFUNC_START + class_index),
! NULL);
/* Indirect once more, offset by function index */
!
! coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp) +
! sizeof (CORE_ADDR) *
! TYPE_FN_FIELD_VOFFSET (f, j));
! vp = value_at (builtin_type_CORE_ADDR, coreptr, NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
***************
*** 997,1003 ****
VALUE_TYPE (vp) = ftype;
VALUE_ADDRESS (vp) = coreptr;
! /* pai: (temp) do we need the value_ind stuff in value_fn_field? */
return vp;
}
else
--- 1002,1008 ----
VALUE_TYPE (vp) = ftype;
VALUE_ADDRESS (vp) = coreptr;
! /* pai: do we need the value_ind stuff in value_fn_field? */
return vp;
}
else
***************
*** 1009,1015 ****
with a strange type, so cast it to type `pointer to long' (which
should serve just fine as a function type). Then, index into
the table, and convert final value to appropriate function type. */
! value_ptr entry, vfn, vtbl;
value_ptr vi = value_from_longest (builtin_type_int,
(LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j);
--- 1014,1020 ----
with a strange type, so cast it to type `pointer to long' (which
should serve just fine as a function type). Then, index into
the table, and convert final value to appropriate function type. */
! value_ptr entry, vfn = NULL, vtbl;
value_ptr vi = value_from_longest (builtin_type_int,
(LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j);
***************
*** 1102,1107 ****
--- 1107,1114 ----
FIXME-tiemann: should work with dossier entries as well. */
+ /* pai: Note -- not for HP aCC */
+
static value_ptr
value_headof (in_arg, btype, dtype)
value_ptr in_arg;
***************
*** 1196,1201 ****
--- 1203,1210 ----
of its baseclasses) to figure out the most derived type that ARG
could actually be a pointer to. */
+ /* pai: Note -- not for HP aCC */
+
value_ptr
value_from_vtable_info (arg, type)
value_ptr arg;
***************
*** 1213,1218 ****
--- 1222,1229 ----
/* Return true if the INDEXth field of TYPE is a virtual baseclass
pointer which is for the base class whose type is BASECLASS. */
+ /* pai: Note -- not for HP aCC */
+
static int
vb_match (type, index, basetype)
struct type *type;
***************
*** 1266,1271 ****
--- 1277,1284 ----
to (the address of)(ARG) + OFFSET.
-1 is returned on error. */
+
+ /* pai: Note -- not for HP aCC */
int
baseclass_offset (type, index, valaddr, address)