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

Jim Blandy
2001-10-04T16:28:00Z

Michael Snyder <msnyder@redhat.com> writes:
> > Instead of using bits, what if we added a new `const char *' field to
> > `struct type'? Its value would be a string indicating the name of the
> > space qualifier applied to the type, or zero indicating the default.
>
> Just to make sure I understand you, the string you propose is
> something like "code", not the fully qualified type eg. "code int *";
> right?

Yes.

> > The set of permitted space names would be determined by the
> > architecture, following some basic conventions (like `data' and
> > `code'). There would be a gdbarch method like this:
> >
> > - int gdbarch_valid_addr_space_name_p (struct gdbarch *A, const char *NAME);
> > Return non-zero if NAME is a valid name of an address space
> > for architecture A.
> >
> > The parser would recognize `@ IDENTIFIER' as a space qualifier, call
> > gdbarch_valid_addr_space_name_p to check it, and drop the value into
> > the type it creates if so.
> >
> > The type printer would simply printf ("@%s", type->space); when printing.
> >
> > There would be a core function:
> >
> > - const char *type_default_addr_space (struct type *T);
> > Return "code" if T is a pointer to function or method; return "data"
> > otherwise.
> >
> > The POINTER_TO_ADDRESS and ADDRESS_TO_POINTER methods, which are the
> > ones who actually *use* this info, receive the type object already,
> > and can check the space as appropriate.
>
> OK, the reason I didn't do it like that (and I did consider it) is
> a) it required a new field in the type struct, and
> b) a strcmp takes longer than an integer (flag) test.
>
> However, I agree that this might be a reasonable extension,
> especially once we get ready to let the target architecture
> define its own address spaces. I wanted to get a relatively
> simple initial implementation approved before I went overboard
> on complexity (it's complex enough as it is).

Okay.