Relying on tm-target.h macros in target-tdep.c

Orjan Friberg orjan.friberg@axis.com
Thu Nov 16 03:51:00 GMT 2000


I'm looking to initialise register_bytes in a multi-arched target
(cris), which means I do it in my gdbarch_init function. I'd like to
rely on the register_raw_size / register_virtual_size function to do the
job. I have some thoughts related to that:

My register_size function uses macros defined in tm-cris.h. The macros
are used only in cris-tdep.c, which means I could move them there, but
since the macros (called NUM_GENREGS, NUM_SPECREGS) are related to the
architecture's registers it seems they should stay in tm-cris.h. To get
around this I would have to #include tm-cris.h in cris-tdep.c. Would
that be ok?

The register_size function (again, called inside gdbarch_init) also uses
NUM_REGS, which I've multi-arched, which means NUM_REGS is not defined
yet. Would it be ok to defer the multi-arching of that particular macro,
and continue to have it as a regular #define in tm-cris.h?

register_size also uses a macro that depends on current_gdbarch being
set to the gdbarch I'm working on in gdbarch_init (for access of data in
the tdep struct). Forcing a premature update of current_gdbarch inside
gdbarch_init feels like a bad idea.

Ok, I see where this is going. Maybe gdbarch_init must be kept pretty
much self-contained. I'll try to live with the fact that I will be
duplicating information that is already elsewhere in gdb (in opcodes/).
 
-- 
Orjan Friberg              E-mail: orjan.friberg@axis.com
Axis Communications AB     Phone:  +46 46 272 17 68


More information about the Gdb-patches mailing list