From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25426 invoked by alias); 15 Aug 2011 17:48:50 -0000 Received: (qmail 25415 invoked by uid 22791); 15 Aug 2011 17:48:49 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yw0-f41.google.com (HELO mail-yw0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 17:48:35 +0000 Received: by ywm13 with SMTP id 13so2714405ywm.0 for ; Mon, 15 Aug 2011 10:48:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.73.233 with SMTP id v69mr7288743yhd.242.1313430514717; Mon, 15 Aug 2011 10:48:34 -0700 (PDT) Received: by 10.147.34.4 with HTTP; Mon, 15 Aug 2011 10:48:34 -0700 (PDT) In-Reply-To: <4E493A79.3060002@broadcom.com> References: <54475b.156ef.131ccb300f5.Coremail.yongyong.yang@ia.ac.cn> <201108151109.56890.pedro@codesourcery.com> <201108151432.33454.pedro@codesourcery.com> <4E493A79.3060002@broadcom.com> Date: Mon, 15 Aug 2011 17:48:00 -0000 Message-ID: Subject: Re: What role does gdb/remote.c play? From: Triple Yang To: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-08/txt/msg00054.txt.bz2 2011/8/15 Andrew Burgess : > On 15/08/2011 16:09, Triple Yang wrote: > >> The Question is, when I created my own "struct target_ops" object and >> initialized it properly, then added it to targetlist, I could expect >> it would respond to commands like target remote and break. > > The commands "target remote" and "break" are different, the "target remote" > is used to pick which "struct target_ops" is used to talk to a target, > commands like "break" use the functions linked into the "struct target_ops" > in order to do debugging stuff with your target. > > The remote in "target remote" comes from the to_shortname field of the > struct target_ops. If you have created your own struct target_ops then you > should fill this field in with a unique target name, say xxx, you can then > say "target xxx" and gdb will use your struct target_ops to talk to the > target. > Great! I think that's exactly the point where I made mistakes. I'm so grateful for your concise and meaningful explanation. Best regards. >> As I've mentioned in a previous mail, current_target holds the value >> specified in remote.c rather than my own remote-XXX.c. I guess the >> expected value is overrided in init.c (which is a generated file >> during building) since _initialize_remote() is called after calling >> _initialize_remote_XXX(). It is easy to find an ugly and offensive way >> to avoid that situation. But I tend to believe there are some clean >> and pretty means to do that and I don't know yet. > > The calls to _initialize_ build up the total list of all possible > targets. Just having a target in the list doesn't mean it's being used, a > target type is selected when you issue the target command to gdb. > > Andrew > >