Skip to content

Commit

Permalink
OSD-GDB server: Adds following features
Browse files Browse the repository at this point in the history
(1) Connect to GDB over TCP
(2) Send and Recieve data to/from the client
(3) Receive RSP packet from the client
(4) Validate the obtained packet using checksum
(5) Send RSP packet to the client
  • Loading branch information
shivmgg committed Jun 27, 2018
1 parent 59de556 commit 8f92087
Show file tree
Hide file tree
Showing 2 changed files with 422 additions and 0 deletions.
123 changes: 123 additions & 0 deletions src/libosd/include/osd/osd_gdbserver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* Copyright 2018 The Open SoC Debug Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef OSD_GDBSERVER_H
#define OSD_GDBSERVER_H

#include <osd/hostmod.h>
#include <osd/osd.h>

#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @defgroup libosd-gdbserver OSD-GDB server utility
* @ingroup libosd
*
* @{
*/

struct connection;

/**
* Connect GDB server with GDB
*
* @return OSD_OK on success, any other value indicates an error
*/
osd_result add_connection(char *name, char *port);

/**
* Read a character from the obtained buffer
*/
osd_result get_char(struct connection *c, int client_fd, int *ch);

/**
* Read data from the GDB client
*
* @param c the connection object
* @param client_fd the client_fd of the GDB
*
* @return OSD_OK on success, any other value indicates an error
*
* @see put_data()
*/
osd_result get_data(struct connection *c, int client_fd);

/**
* Write data to the GDB client
*
* @param c the connection object
* @param client_fd the client_fd of the GDB
* @param data the data to write to the connected client
* @param len the length of the data to be written
* @return OSD_OK on success, any other value indicates an error
*
* @see get_data()
*/
osd_result put_data(struct connection *c, int client_fd, char *data, int len);

/**
*
* Get the packet-data from obtained buffer $<packet-data>#<checksum>
*
* @param c the connection object
* @param client_fd the client_fd of the GDB
* @param buffer the packet-data obtained from the connected client
* @param len the length of the packet-data
* @return OSD_OK on success, any other value indicates an error
*
* @see put_packet()
*/
osd_result get_packet(struct connection *c, int client_fd, char *buffer,
int *len);

/**
* Verify the checksum of obtained packet
*
* @param c the connection object
* @param client_fd the client_fd of the GDB
* @param ver_checksum indicates if the obtained checksum is correct or not
* @param buffer the packet-data obtained from the connected client
* @param len the length of the packet-data
* @return OSD_OK on success, any other value indicates an error
*/
osd_result validate_packet(struct connection *c, int client_fd,
bool *ver_checksum, int *len, char *buffer);

/**
*
* Send the packet-data to the buffer $<packet-data>#<checksum>
*
* @param c the connection object
* @param client_fd the client_fd of the GDB
* @param buffer the packet-data to send to the connected client
* @param len the length of the packet-data
* @return OSD_OK on success, any other value indicates an error
*
* @see get_packet()
*/
osd_result put_packet(struct connection *c, int client_fd, char *buffer,
int len);

/**@}*/ /* end of doxygen group libosd-gdbserver */

#ifdef __cplusplus
}
#endif

#endif // OSD_GDBSERVER_H
Loading

0 comments on commit 8f92087

Please sign in to comment.