This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Ping: [patch] general updates and improvements to QNX NTO support
- From: Kris Warkentin <kewarken at qnx dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 03 Dec 2004 17:55:03 -0500
- Subject: Re: Ping: [patch] general updates and improvements to QNX NTO support
Mark Kettenis wrote:
> Ah, OK. Sorry, I misread that.
>
>
No problem...kind of a funny looking diff.
> I also changed the macro defines so that I can assign and test. ie.
>
> old:
> define nto_regset_fill(regset, data)
(*current_nto_target.nto_regset_fill) (regset, data)
>
> new:
> #define nto_regset_fill (current_nto_target.nto_regset_fill)
>
> That way I can easily switch targets in code.
>
> Hmm. In that case wouldn't it be better to turn current_nto_target
> into a pointer, and having a `struct nto_target_ops' for each target
> such that you can switch targets by simply doing a pointer assignment?
> That would probably get rid of all the macros.
>
>
That's a good idea and I actually do something very similar in our
remote support (which I haven't submitted yet) As it stands, rather
than just switching a pointer, I initialize all the members in
init_i386nto_ops. I have similar init functions for arm, sh, mips and
ppc. I'm not sure how I'd get rid of the macros though....it's still
convenient to have a generic nto_regset_fill function macro rather than
having to dereference. Plus, it's handy to be able to check for
validity before using a function like in nto_elf_osabi_sniffer. I'm
just thinking that if gdb were truly multi-arched, there could be a
situation where my nto_target_ops haven't been initialized and something
like a sniffer could crash. I could be wrong about that though.
> I am defining current_nto_target in nto-tdep.h as being extern but
I don't declare it there. Is having a global verboten? I has assumed
it was okay since we have many precedents like inferior_ptid and
current_target and such.
>
> Declaring variables as `extern' in a header file is fine, although you
> should avoid globals if as much as possible.
>
I did it that way to be consistent with the current_target idea within
gdb. We actually have five targets so it makes it easier to switch
things around. I'd welcome any ideas for improvement though. Not much
originality on all this - I pretty much tried to do things exactly the
way target.h does. I hope I don't lose marks for plaigarism... ;-)
cheers,
Kris