From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19992 invoked by alias); 3 Dec 2004 22:53:10 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19972 invoked from network); 3 Dec 2004 22:53:05 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by sourceware.org with SMTP; 3 Dec 2004 22:53:05 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id SAA23407 for ; Fri, 3 Dec 2004 18:14:34 -0500 Received: from [192.168.20.25] ([192.168.20.25]) by smtp.ott.qnx.com (8.8.8/8.6.12) with ESMTP id RAA26922 for ; Fri, 3 Dec 2004 17:53:04 -0500 Message-ID: <41B0EEC7.2080104@qnx.com> Date: Fri, 03 Dec 2004 23:16:00 -0000 From: Kris Warkentin User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Re: Ping: [patch] general updates and improvements to QNX NTO support Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-12/txt/msg00096.txt.bz2 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