Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Petr Hluzín" <petr.hluzin@gmail.com>
To: Triple Yang <triple.yang@gmail.com>
Cc: gdb@sourceware.org, Pedro Alves <pedro@codesourcery.com>
Subject: Re: What role does gdb/remote.c play?
Date: Mon, 15 Aug 2011 15:46:00 -0000	[thread overview]
Message-ID: <CAC=yr6DEY=C4VJSeHPQm6r8nZad=P88qpN83xGs1F7K_o2Mu3Q@mail.gmail.com> (raw)
In-Reply-To: <CAGxstLRqEA0rBjdjDR8wiNYZ7YGY7QN4UTKhYC1tHbiKO9KmOg@mail.gmail.com>

On 15 August 2011 17:09, Triple Yang <triple.yang@gmail.com> wrote:
> 2011/8/15 Pedro Alves <pedro@codesourcery.com>:
>> On Monday 15 August 2011 12:51:11, Triple Yang wrote:
>>
>>> Then, if I want to create a new remote target, should I just modify
>>> remote.c or reuse codes in it?
>>
>> I don't know what your new target does, so I can't answer that for you.
>>
>>> How do I map command 'target remote' to the new target I created?
>>
>> You don't.  Do you _really_ need to implement a new target in gdb?
>> Why not teach the remote end the RSP instead?  Then you can
>> use "target remote", without adding new code to gdb.
>>
>
> Yes, because I am trying porting GDB to a new architecture prototype.
> Implementing a new target seems to be the only way to achieve the
> purpose.

If your users want to debug programs running on a remote
machine/device then you can either:
A: override "target remote" (or other target) implementation in GDB
and use custom communication or
B: use GDB's remote protocol, modify gdbserver sources and write your
own handling or
C: use GDB's remote protocol and write your own parsing and handling

The option A is not recommended (see Pedro Alves) because it either
means you will be distributing your own GDB or be stuck to FSF release
schedule. Also users of older gdbs will not be able to connect (plus
users will get misleading diagnostic). And there is a lot of code in
gdb and many ways to get lost.

For options B and C the user would type "target remote" and it will
behave the way users expect from other archs (as the case may be),
what tutorials describe and what IDEs do well.

> To "teach the remote end the RSP instead", what needs to be done?

On remote system do create a listening TCP socket and implement
processing the remote protocol commands [1]. The gdbserver does that
for several architectures and can serve as an inspiration.

[1] http://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html

-- 
Petr Hluzin


  parent reply	other threads:[~2011-08-15 15:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-15  9:08 yongyong.yang
2011-08-15 10:10 ` Pedro Alves
2011-08-15 11:51   ` Triple Yang
2011-08-15 13:32     ` Pedro Alves
2011-08-15 15:10       ` Triple Yang
2011-08-15 15:26         ` Andrew Burgess
2011-08-15 17:48           ` Triple Yang
2011-08-15 15:28         ` Pedro Alves
     [not found]           ` <CAGxstLS4BjPZOatfSMMUiVNpOyd9gVzdVXbzqUqBzvb1M9gsjw@mail.gmail.com>
2011-08-15 17:54             ` Triple Yang
2011-08-15 15:46         ` Petr Hluzín [this message]
2011-08-15 18:20           ` Triple Yang
2011-08-15 20:13             ` Petr Hluzín

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC=yr6DEY=C4VJSeHPQm6r8nZad=P88qpN83xGs1F7K_o2Mu3Q@mail.gmail.com' \
    --to=petr.hluzin@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=triple.yang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox