This is the mail archive of the gdb-patches@sourceware.cygnus.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: RFA: gdbarch_free



> > There are no uses for this yet, except in some code that's not ready
> > for release yet.
> > 
> > 2000-02-28  Jim Blandy  <jimb@redhat.com>
> > 
> >         * gdbarch.sh: Emit a definition and declaration for gdbarch_free,
> >         a companion to gdbarch_alloc, which allows a gdbarch init function
> >         to free partially-built gdbarch structures.
> >         * gdbarch.c, gdbarch.h: Regenerated.
> 
> Jim,
> 
> Can you expand a little.
> 
> >From memory, I figured that if an _initialize* function failed to create
> a gdbarch the process was somewhat hosed and calling internal_error()
> was probably the best thing to do.

Whenever one provides an allocation function, one should always
provide a corresponding free function --- it gives you more freedom in
the way you allocate the object.

Why I'm freeing a gdbarch structure isn't really anyone's business but
my own.  The contract of the init function is simply that it returns
null or a valid gdbarch; who knows how I might go about creating that
gdbarch.  I might build it myself, for all you know.

The real story:

gdbarch_update calls the initialization function and checks the return
value.  If it's zero, it says "gdbarch_update: Target rejected
architecture".  I have an architecture with several variants, and I
want to return zero when the variant (info.bfd_arch_info->mach)
doesn't match anything I recognize.

This situation could arise if someone adds support for a new variant
of my architecture, but hasn't updated GDB yet.

I could check for this earlier, before calling gdbarch_alloc, but I'd
like to avoid having two `if' structures that need to stay in sync.

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