Re: [RFA] dwarf2read.c: set TYPE_DOMAIN_TYPE correctly for methods

Andrew Cagney
2002-08-22T21:09:41Z

> On Thu, Aug 22, 2002 at 01:35:50PM -0700, David Carlton wrote:
>
>> I've figured out what caused the regression that I turned up in PR
>> gdb/653; here's a patch that fixes it.
>>
>> David Carlton
>> carlton@math.stanford.edu
>>
>> 2002-08-22 David Carlton <carlton@math.stanford.edu>
>>
>> * dwarf2read.c (dwarf2_add_member_fn): Add back in the type
>> argument that was deleted on 2002-06-14: it was needed after all,
>> as PR gdb/653 demonstrates. Update call to smash_to_method_type.
>> (read_structure_scope): Update call to dwarf2_add_member_fn.
>
>
> Can you explain why this is necessary? I could not find any path to
> that point where type != die->type.

Just a general reminder for people comming up with patches.

The place to put comments explaining changes is in the source code.
Something like:

/* NOTE: cagney/2002-08-12: Replaced a call to
regcache_raw_read_as_address() with a call to
regcache_cooked_read_unsigned(). The old, ...as_address
function was eventually calling extract_unsigned_integer (via
extract_address) to unpack the registers value. The below is
doing an unsigned extract so that it is functionally
equivalent. The read needs to be cooked as, otherwise, it
will never correctly return the value of a register in the
[NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS) range. */

(although, yes, the example is a bit overboard). This might feel
un-natural but it is correct and very very important. The ChangeLog
need only state what changed, not why.

Someone studying the code and trying to figure out why things currently
don't work should be able to do so by just examining the current code
and its commentary. Hopefully that commentry will explain what was
tried in the past and why it failed or why it needed to be changed.

Oh, and adding more comments to the code is always ``obvious'' :-) (Is
there a way to add ``comments'' to the doco?).

enjoy,
Andrew