Re: [RFC/RFA] gdb extension for Harvard architectures

Andrew Cagney
2001-10-10T00:45:00Z

>> > Those set off warning bells, for me. You can special-case this stuff
>> > to make the naive user's behavior do the right thing want all you
>> > want. If you've ever had Microsoft Word correct your capitalization
>> > or automatically munge your paragraph formatting, you know what the
>> > resulting systems feel like to use.
>
>>
>> Have a look at the way GDB vs GCC implements ``func + 4'' for AIX. We
>> do this now.
>
>
> And indeed, that discrepancy is undesirable, right? We should not
> introduce more.

To be honest, I think GCC has a bug. In the case of AIX it is
implementing meaningless behavour by accident. I think GCC, if nothing
else, should issue a warning.

To expand on the problem, (kevin correctly me if I'm wrong). AIX has
function descriptors and a C function pointer designates a descriptor
(in data space) and not the code of the function. Thus, what to the C
programmer looks like (to use pseudo pascal syntax):

pointer to function

is implemented as:

pointer to record
pointer to function;
pointer to table_of_contents;
pointer to something else;
end

When GCC encounters:

function + 1

it implements

&function + 1

Remembering that a function pointer points to a record/struct in data
space (and not the actual function) the above ends up pointing to what
ever lies beyond the function descriptor in data memory.

GDB on the other hand implements the above as

function+1

(i.e. the second byte (should it be word?) of function's code).

Anyway, my point here is that I don't think GCC should be held up as the
reference implementation. Just like in GDB, I suspect GCC has edge
cases that no one has thought through.

enjoy,
Andrew