[Open SoC Debug] CDM: Next Steps

Philipp Wagner philipp.wagner at tum.de
Thu Jul 19 10:27:22 CEST 2018

On 07/18/2018 12:33 PM, SHIVAM AGGARWAL wrote:
> Hi
> I have completed the implementation of following commands in the GDBserver.
> `g'                                   --   read general-purpose registers
> `G'XX...      --   write general-purpose register
> `p n'                                --   Read the value of register n
> `P n...=r...'                    --   Write register n... with value r
> `m'ADDR`,'LENGTH         --   read memory
> `M'ADDR,LENGTH`:'XX... --   write memory
> I have added unit tests to check the functionality of intermediate 
> functions like encodeRSPpacket, etc.
> What's Next?
> I am trying to implement a *mock_gdbclient program* to test various 
> functionality of GDBserver. I am not thoroughly clear with the 
> implementation details of the mock_gdbclient program. I went through the 
> implementation of both mock_hostmod and mock_hostcontroller.
> Based on my understanding and previous discussions, some utilities of 
> the mock_gdbclient program:
> 1. It should be able to connect to the GDBserver via TCP.
> For this part, I think I need to use functions from the *PThreads API 
> *with one thread running GDBserver.**We need to run the client and the 
> server part simultaneously and hence, multithreading.
> **

OSD contains a worker class 
which can be used if you need non-blocking processing and communication.

However, for TCP multiple non-blocking alternatives exist already within 
the standard API (e.g. non-blocking sockets).

That said, you probably need to give a bit more thought to which parts 
of your code are blocking and which ones are not. Typically OSD makes 
all long-running (blocking) operations asynchronous.

For example, introduce two functions osd_gdbserver_start() and 
osd_gdbserver_stop() instead of a blocking osd_gdbserver_run() 
(hypothetical function names).

* osd_gdbserver_start() would create a processing thread (most likely 
using the worker helper) and answer requests from a GDB client there.

* osd_gdbserver_stop() would then tear down the processing thread again.

> 2. The program should respond to the queries/requests made by the 
> GDBserver. This part of the program essentially depends upon the 
> connection with the GDBserver.
> It would be great if you could elaborate a bit on the specific details 
> of the establishing a TCP connection.

Establishing a TCP connection is discussed in many tutorials online, 
e.g. http://www.microhowto.info/howto/establish_a_tcp_connection_in_c.html


More information about the OpenSoCDebug mailing list