This is the mail archive of the gdb@sourceware.org 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]
Other format: [Raw text]

Re: What role does gdb/remote.c play?


On 15 August 2011 20:20, Triple Yang <triple.yang@gmail.com> wrote:
> 2011/8/15 Petr HluzÃn <petr.hluzin@gmail.com>:
>> On 15 August 2011 17:09, Triple Yang <triple.yang@gmail.com> wrote:
>>> 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.
>>
>
> So in option B or C, will reusing codes in remote.c be satisfying?
> (Thus I may save some time in writing codes parsing/wrapping RSP
> packets.)

No, you cannot reuse code in [1]. GDB uses the code to format commands
and parse responses.

You can reuse code of gdbserver in [2]. This directory includes the
code for parsing commands from GDB and formatting responses.

However there are many more implementations of a GDB remote
monitor/stub in the world, the gdbserver is just one of them.

[1] http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/remote.c?cvsroot=src
[2] http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdbserver/?cvsroot=src

-- 
Petr Hluzin


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