This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [PATCH] Big-endian targets: Don't ignore offset into DW_OP_stack_value


On Wed, Mar 15 2017, Ulrich Weigand wrote:

> Andreas Arnez wrote:

[...]

>> +  /* Get type of pointed-to DIE.  */
>> +  struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu);
>> +
>>    /* If pointed-to DIE has a DW_AT_location, evaluate it and return the
>>       resulting value.  Otherwise, it may have a DW_AT_const_value instead,
>>       or it may've been optimized out.  */
>>    if (baton.data != NULL)
>> -    return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame,
>> -					  baton.data, baton.size, baton.per_cu,
>> +    return dwarf2_evaluate_loc_desc_full (orig_type, frame, baton.data,
>
> Can orig_type ever be NULL here?  It probably would not be a good idea
> to pass NULL as the type argument.

>From looking at the code, it looks like it can.  But only for very
special cases, it seems.  For instance, in case of a missing DW_AT_TYPE
attribute for the pointed-to die we get the type "void" instead.

>
>> -	    if (byte_offset != 0)
>> +	    if (subobj_byte_offset != 0)
>>  	      error (_("cannot use offset on synthetic pointer to register"));
>
> As an aside: now that we have the full object type, we may actually be able
> to lift that restriction (do a value_from_register on the full type, and
> then extract the subobject).  Might be interesting to look into as a
> follow-on change ...

Right, I'll look into that.

>
>>  	    size_t n = TYPE_LENGTH (value_type (value));
>> +	    size_t len = TYPE_LENGTH (subobj_type);
>> +	    size_t max = type != NULL ? TYPE_LENGTH (type) : n;
>
> As mentioned above, I don't think it makes sense to allow a NULL type here.

OK.  I'll adjust the patch with the delta-patch below.  Is that ready to
apply then?

--
Andreas


-- >8 --
1 file changed, 3 insertions(+), 1 deletion(-)
gdb/dwarf2loc.c | 4 +++-

modified   gdb/dwarf2loc.c
@@ -2166,6 +2166,8 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset,
 
   /* Get type of pointed-to DIE.  */
   struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu);
+  if (orig_type == NULL)
+    invalid_synthetic_pointer ();
 
   /* If pointed-to DIE has a DW_AT_location, evaluate it and return the
      resulting value.  Otherwise, it may have a DW_AT_const_value instead,
@@ -2487,7 +2489,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
 	    struct value *value = ctx.fetch (0);
 	    size_t n = TYPE_LENGTH (value_type (value));
 	    size_t len = TYPE_LENGTH (subobj_type);
-	    size_t max = type != NULL ? TYPE_LENGTH (type) : n;
+	    size_t max = TYPE_LENGTH (type);
 	    struct gdbarch *objfile_gdbarch = get_objfile_arch (objfile);
 	    struct cleanup *cleanup;
 


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