From 802db21b617808df4dd4a47aec3ccbe828f694f5 Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Sat, 15 Jul 2000 17:40:30 +0000 Subject: [PATCH] Properly handle references --- gdb/ChangeLog | 7 +++++++ gdb/valops.c | 34 ++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ccf3b51f41a..45e69b0eaa9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2000-07-15 Daniel Berlin + + * valops.c (typecmp): Seperate loop into two, add support for + references. This way, we can say a reference to a pointer to a + char is compatible with a pointer to a char. Before, this would + not be true. + 2000-07-14 Nicholas Duffek * ppcbug-rom.c (ppcbug_regnames[]): Make array size implicit. diff --git a/gdb/valops.c b/gdb/valops.c index a32db08c9e2..711392f9b62 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -274,7 +274,7 @@ value_cast (type, arg2) case TYPE_CODE_MEMBER: retvalp = value_from_longest (type, value_as_long (arg2)); /* force evaluation */ - ptr = (unsigned int *) VALUE_CONTENTS (retvalp); + ptr = (unsigned int *) VALUE_CONTENTS (retvalp); *ptr &= ~0x20000000; /* zap 29th bit to remove bias */ return retvalp; @@ -287,10 +287,10 @@ value_cast (type, arg2) } } longest = value_as_long (arg2); - return value_from_longest (type, convert_to_boolean ? + return value_from_longest (type, convert_to_boolean ? (LONGEST) (longest ? 1 : 0) : longest); } - else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT || + else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_ENUM || code2 == TYPE_CODE_RANGE)) { @@ -561,7 +561,7 @@ value_fetch_lazy (val) } else if (length) read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), length); - + VALUE_LAZY (val) = 0; return 0; } @@ -676,7 +676,7 @@ value_assign (toval, fromval) if (VALUE_BITSIZE (toval)) { char buffer[sizeof (LONGEST)]; - int len = + int len = REGISTER_RAW_SIZE (VALUE_REGNO (toval)) - VALUE_OFFSET (toval); if (len > (int) sizeof (LONGEST)) @@ -2029,12 +2029,22 @@ typecmp (staticp, t1, t2) continue; } - while (TYPE_CODE (tt1) == TYPE_CODE_PTR - && (TYPE_CODE (tt2) == TYPE_CODE_ARRAY - || TYPE_CODE (tt2) == TYPE_CODE_PTR)) + /* djb - 20000715 - Until the new type structure is in the + place, and we can attempt things like implicit conversions, + we need to do this so you can take something like a map, and properly access map["hello"], because the + argument to [] will be a reference to a pointer to a char, + and the arrgument will be a pointer to a char. */ + while ( TYPE_CODE(tt1) == TYPE_CODE_REF || + TYPE_CODE (tt1) == TYPE_CODE_PTR) + { + tt1 = check_typedef( TYPE_TARGET_TYPE(tt1) ); + } + while ( TYPE_CODE(tt2) == TYPE_CODE_ARRAY || + TYPE_CODE(tt2) == TYPE_CODE_PTR || + TYPE_CODE(tt2) == TYPE_CODE_REF) { - tt1 = check_typedef (TYPE_TARGET_TYPE (tt1)); - tt2 = check_typedef (TYPE_TARGET_TYPE (tt2)); + tt2 = check_typedef( TYPE_TARGET_TYPE(tt2) ); } if (TYPE_CODE (tt1) == TYPE_CODE (tt2)) continue; @@ -3324,7 +3334,7 @@ value_rtti_type (v, full, top, using_enc) /* Right now this is G++ RTTI. Plan on this changing in the future as i get around to setting the vtables properly for G++ - compiled stuff. Also, i'll be using the type info functions, + compiled stuff. Also, i'll be using the type info functions, which are always right. Deal with it until then. */ { @@ -3353,7 +3363,7 @@ value_rtti_type (v, full, top, using_enc) *using_enc=1; } /* - We can't use value_ind here, because it would want to use RTTI, and + We can't use value_ind here, because it would want to use RTTI, and we'd waste a bunch of time figuring out we already know the type. Besides, we don't care about the type, just the actual pointer */ -- 2.30.2