This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Getting hold of a bfd in _initialize_<target>_tdep


Jim Blandy wrote:
> 
> > When defining the tm_print_insn parameter in _initialize_cris_tdep (port
> > to be submitted), I need a bfd (not just bfd_arch_info) to supply to a
> > function (cris_get_disassembler) which gives me the correct
> > disassembler. However, I can't seem to get hold of one. Also, no one
> > seems to be using the disassembler (bfd *) function in dis-asm.h, which
> > makes me suspicious as to its applicability. The rs6000 target does make
> > use of the info.abfd in its gdbarch_init () function, though I can't
> > verify that it's actually != 0 inside function.
> >
> > Should I base the choice of disassembler on something else than the
> > actual bfd, or is there a proper way to get hold of it?
> 
> The _initialize functions are called before GDB has opened any BFD's,
> so they can't do anything smart about tm_print_insn.  What you can do
> instead is set tm_print_insn to point to a function in your tdep file
> which calls the right function from libopcodes.a; this is what the
> MIPS target does.
> 
> Shouldn't tm_print_insn be replaced with a gdbarch method?

Yes, no, maybe.  It isn't that simple.  Short term it can either be
replaced by a gdbarch method (or just have the target wack it directly).

Long term things get really messy.  Consider a program with two memory
areas, each belonging to a different architecture (mips2 VS mips4,  arm
vs thumb, IA32 vs IA64, ...).  The dissassembler needs to be able to
determine the correct dissassemble function independant of any thing
that GDB things.  It can take a hint from GDB but that doesn't mean that
it should believe GDB.

A clean solution to this is an open problem.  Among the many things,
there needs to be a standardized way of specifying the ISA for a memory
region.

	Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]