From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Jim Blandy Cc: Michael Snyder , gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] gdb extension for Harvard architectures Date: Wed, 10 Oct 2001 00:45:00 -0000 Message-id: <3BC3FC63.8010407@cygnus.com> References: <3BB4D843.A92818B9@cygnus.com> <3BB512A9.6050801@cygnus.com> <3BB5195F.6050603@cygnus.com> <3BBB50C0.BD01BF20@cygnus.com> <3BBB5391.4010001@cygnus.com> <3BBB86B6.8090809@cygnus.com> X-SW-Source: 2001-10/msg00107.html >> > 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