From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Snyder To: Jim Blandy Cc: Michael Snyder , Andrew Cagney , gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] gdb extension for Harvard architectures Date: Thu, 04 Oct 2001 11:44:00 -0000 Message-id: <3BBCADB6.6166@redhat.com> References: <3BB4D843.A92818B9@cygnus.com> <3BB4E273.5020308@cygnus.com> <3BBB4D90.AE2B5AEE@cygnus.com> X-SW-Source: 2001-10/msg00082.html Jim Blandy wrote: > > Michael Snyder writes: > > > Should these spaces be flags or an enumeration? I don't think being > > > able to specify space = (CODE | DATA) is meanginful. Haveing bit masks > > > also puts a limitation on the number of spaces. > > > > Yes, but it's a generous limitation (there are 20 more bits available). > > I'll go either way -- the trade-off is that if we don't use the "flags" > > field, we have to add a new field to the (struct type) data > > structure. > > (This is a suggested enhancement to Michael's patch; I think it's a > step forward as is.) > > 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? > 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). Michael