GDBserver
Classes | Macros | Typedefs | Enumerations | Functions | Variables
remote-utils.c File Reference
#include "server.h"
#include "target.h"
#include "gdbthread.h"
#include "tdesc.h"
#include "dll.h"
#include "rsp-low.h"
#include <ctype.h>
#include "gdb_sys_time.h"
#include <unistd.h>
#include <sys/stat.h>

Go to the source code of this file.

Classes

struct  sym_cache
 

Macros

#define INVALID_DESCRIPTOR   -1
 

Typedefs

typedef int socklen_t
 

Enumerations

enum  { NOT_SCHEDULED = -1 }
 

Functions

static int readchar (void)
 
static void reset_readchar (void)
 
static void reschedule (void)
 
int gdb_connected (void)
 
int remote_connection_is_stdio (void)
 
static void enable_async_notification (int fd)
 
static int handle_accept_event (int err, gdb_client_data client_data)
 
void remote_prepare (const char *name)
 
void remote_open (const char *name)
 
void remote_close (void)
 
void decode_address (CORE_ADDR *addrp, const char *start, int len)
 
const char * decode_address_to_semicolon (CORE_ADDR *addrp, const char *start)
 
static int try_rle (char *buf, int remaining, unsigned char *csum, char **p)
 
char * write_ptid (char *buf, ptid_t ptid)
 
static ULONGEST hex_or_minus_one (const char *buf, const char **obuf)
 
ptid_t read_ptid (const char *buf, const char **obuf)
 
static int write_prim (const void *buf, int count)
 
static int read_prim (void *buf, int count)
 
static int putpkt_binary_1 (char *buf, int cnt, int is_notif)
 
int putpkt_binary (char *buf, int cnt)
 
int putpkt (char *buf)
 
int putpkt_notif (char *buf)
 
static void input_interrupt (int unused)
 
void check_remote_input_interrupt_request (void)
 
static void block_unblock_async_io (int block)
 
void enable_async_io (void)
 
void disable_async_io (void)
 
void initialize_async_io (void)
 
static int process_remaining (void *context)
 
int getpkt (char *buf)
 
void write_ok (char *buf)
 
void write_enn (char *buf)
 
static char * outreg (struct regcache *regcache, int regno, char *buf)
 
void prepare_resume_reply (char *buf, ptid_t ptid, struct target_waitstatus *status)
 
void decode_m_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr)
 
void decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr, unsigned char **to_p)
 
int decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr, unsigned char **to_p)
 
int decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset, unsigned int *len, unsigned char *data)
 
int decode_search_memory_packet (const char *buf, int packet_len, CORE_ADDR *start_addrp, CORE_ADDR *search_space_lenp, gdb_byte *pattern, unsigned int *pattern_lenp)
 
static void free_sym_cache (struct sym_cache *sym)
 
void clear_symbol_cache (struct sym_cache **symcache_p)
 
int look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
 
int relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
 
void monitor_output (const char *msg)
 

Variables

static int readchar_callback = NOT_SCHEDULED
 
int remote_debug = 0
 
struct ui_file * gdb_stdlog
 
static int remote_is_stdio = 0
 
static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR
 
static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR
 
int using_threads
 
int debug_threads
 
int noack_mode = 0
 
int transport_is_reliable = 0
 
static int async_io_enabled
 
static unsigned char readchar_buf [BUFSIZ]
 
static int readchar_bufcnt = 0
 
static unsigned char * readchar_bufp
 

Macro Definition Documentation

◆ INVALID_DESCRIPTOR

#define INVALID_DESCRIPTOR   -1

Typedef Documentation

◆ socklen_t

typedef int socklen_t

Definition at line 73 of file remote-utils.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NOT_SCHEDULED 

Definition at line 85 of file remote-utils.c.

Function Documentation

◆ block_unblock_async_io()

static void block_unblock_async_io ( int  block)
static

Definition at line 761 of file remote-utils.c.

Referenced by disable_async_io(), and enable_async_io().

◆ check_remote_input_interrupt_request()

void check_remote_input_interrupt_request ( void  )

Definition at line 745 of file remote-utils.c.

References input_interrupt(), INVALID_DESCRIPTOR, and remote_desc.

Referenced by get_child_debug_event().

◆ clear_symbol_cache()

void clear_symbol_cache ( struct sym_cache **  symcache_p)

Definition at line 1417 of file remote-utils.c.

References free_sym_cache(), and sym_cache::next.

Referenced by remove_process().

◆ decode_address()

void decode_address ( CORE_ADDR addrp,
const char *  start,
int  len 
)

Definition at line 399 of file remote-utils.c.

References fromhex().

Referenced by decode_address_to_semicolon(), handle_query(), and look_up_one_symbol().

◆ decode_address_to_semicolon()

const char* decode_address_to_semicolon ( CORE_ADDR addrp,
const char *  start 
)

◆ decode_m_packet()

void decode_m_packet ( char *  from,
CORE_ADDR mem_addr_ptr,
unsigned int *  len_ptr 
)

◆ decode_M_packet()

void decode_M_packet ( char *  from,
CORE_ADDR mem_addr_ptr,
unsigned int *  len_ptr,
unsigned char **  to_p 
)

Definition at line 1309 of file remote-utils.c.

References fromhex(), hex2bin(), and xmalloc().

Referenced by process_serial_event(), and relocate_instruction().

◆ decode_search_memory_packet()

int decode_search_memory_packet ( const char *  buf,
int  packet_len,
CORE_ADDR start_addrp,
CORE_ADDR search_space_lenp,
gdb_byte pattern,
unsigned int *  pattern_lenp 
)

Definition at line 1391 of file remote-utils.c.

References decode_address_to_semicolon(), and remote_unescape_input().

Referenced by handle_search_memory().

◆ decode_X_packet()

int decode_X_packet ( char *  from,
int  packet_len,
CORE_ADDR mem_addr_ptr,
unsigned int *  len_ptr,
unsigned char **  to_p 
)

Definition at line 1335 of file remote-utils.c.

References fromhex(), remote_unescape_input(), and xmalloc().

Referenced by process_serial_event(), and relocate_instruction().

◆ decode_xfer_write()

int decode_xfer_write ( char *  buf,
int  packet_len,
CORE_ADDR offset,
unsigned int *  len,
unsigned char *  data 
)

Definition at line 1367 of file remote-utils.c.

References fromhex(), offset, and remote_unescape_input().

Referenced by handle_qxfer().

◆ disable_async_io()

void disable_async_io ( void  )

◆ enable_async_io()

void enable_async_io ( void  )

Definition at line 799 of file remote-utils.c.

References async_io_enabled, and block_unblock_async_io().

Referenced by resume().

◆ enable_async_notification()

static void enable_async_notification ( int  fd)
static

Definition at line 143 of file remote-utils.c.

References fcntl.

Referenced by handle_accept_event(), and remote_open().

◆ free_sym_cache()

static void free_sym_cache ( struct sym_cache sym)
static

Definition at line 1407 of file remote-utils.c.

References free(), and sym_cache::name.

Referenced by clear_symbol_cache().

◆ gdb_connected()

int gdb_connected ( void  )

Definition at line 129 of file remote-utils.c.

References INVALID_DESCRIPTOR, and remote_desc.

Referenced by handle_target_event(), and stop_tracing().

◆ getpkt()

int getpkt ( char *  buf)

◆ handle_accept_event()

static int handle_accept_event ( int  err,
gdb_client_data  client_data 
)
static

◆ hex_or_minus_one()

static ULONGEST hex_or_minus_one ( const char *  buf,
const char **  obuf 
)
static

Definition at line 508 of file remote-utils.c.

References startswith(), and unpack_varlen_hex().

Referenced by read_ptid().

◆ initialize_async_io()

void initialize_async_io ( void  )

Definition at line 829 of file remote-utils.c.

References async_io_enabled, disable_async_io(), and input_interrupt().

Referenced by captured_main().

◆ input_interrupt()

static void input_interrupt ( int  unused)
static

◆ look_up_one_symbol()

int look_up_one_symbol ( const char *  name,
CORE_ADDR addrp,
int  may_ask_gdb 
)

◆ monitor_output()

void monitor_output ( const char *  msg)

◆ outreg()

static char* outreg ( struct regcache regcache,
int  regno,
char *  buf 
)
static

Definition at line 1064 of file remote-utils.c.

References collect_register_as_string(), register_size(), regcache::tdesc, and tohex().

Referenced by prepare_resume_reply().

◆ prepare_resume_reply()

void prepare_resume_reply ( char *  buf,
ptid_t  ptid,
struct target_waitstatus *  status 
)

◆ process_remaining()

static int process_remaining ( void *  context)
static

Definition at line 898 of file remote-utils.c.

References handle_serial_event(), NOT_SCHEDULED, readchar_bufcnt, and readchar_callback.

Referenced by reschedule().

◆ putpkt()

int putpkt ( char *  buf)

◆ putpkt_binary()

int putpkt_binary ( char *  buf,
int  cnt 
)

Definition at line 679 of file remote-utils.c.

References putpkt_binary_1().

Referenced by look_up_one_symbol(), process_serial_event(), and putpkt().

◆ putpkt_binary_1()

static int putpkt_binary_1 ( char *  buf,
int  cnt,
int  is_notif 
)
static

◆ putpkt_notif()

int putpkt_notif ( char *  buf)

Definition at line 695 of file remote-utils.c.

References putpkt_binary_1().

Referenced by notif_push().

◆ read_prim()

static int read_prim ( void *  buf,
int  count 
)
static

Definition at line 582 of file remote-utils.c.

References remote_connection_is_stdio(), and remote_desc.

Referenced by input_interrupt(), and readchar().

◆ read_ptid()

ptid_t read_ptid ( const char *  buf,
const char **  obuf 
)

◆ readchar()

static int readchar ( void  )
static

◆ relocate_instruction()

int relocate_instruction ( CORE_ADDR to,
CORE_ADDR  oldloc 
)

◆ remote_close()

void remote_close ( void  )

◆ remote_connection_is_stdio()

int remote_connection_is_stdio ( void  )

Definition at line 137 of file remote-utils.c.

References remote_is_stdio.

Referenced by linux_ptrace_fun(), mywait(), read_prim(), remote_close(), and write_prim().

◆ remote_open()

void remote_open ( const char *  name)

◆ remote_prepare()

void remote_prepare ( const char *  name)

◆ reschedule()

static void reschedule ( void  )
static

◆ reset_readchar()

static void reset_readchar ( void  )
static

Definition at line 885 of file remote-utils.c.

References delete_callback_event(), NOT_SCHEDULED, readchar_bufcnt, and readchar_callback.

Referenced by remote_close().

◆ try_rle()

static int try_rle ( char *  buf,
int  remaining,
unsigned char *  csum,
char **  p 
)
static

Definition at line 440 of file remote-utils.c.

Referenced by putpkt_binary_1().

◆ write_enn()

void write_enn ( char *  buf)

◆ write_ok()

void write_ok ( char *  buf)

◆ write_prim()

static int write_prim ( const void *  buf,
int  count 
)
static

Definition at line 569 of file remote-utils.c.

References remote_connection_is_stdio(), and remote_desc.

Referenced by getpkt(), and putpkt_binary_1().

◆ write_ptid()

char* write_ptid ( char *  buf,
ptid_t  ptid 
)

Variable Documentation

◆ async_io_enabled

int async_io_enabled
static

Definition at line 795 of file remote-utils.c.

Referenced by disable_async_io(), enable_async_io(), and initialize_async_io().

◆ debug_threads

int debug_threads

Definition at line 24 of file debug.c.

Referenced by handle_accept_event(), and prepare_resume_reply().

◆ gdb_stdlog

struct ui_file* gdb_stdlog

Definition at line 107 of file remote-utils.c.

◆ listen_desc

gdb_fildes_t listen_desc = INVALID_DESCRIPTOR
static

Definition at line 112 of file remote-utils.c.

Referenced by handle_accept_event(), remote_open(), and remote_prepare().

◆ noack_mode

int noack_mode = 0

Definition at line 119 of file remote-utils.c.

Referenced by captured_main(), getpkt(), handle_general_set(), and putpkt_binary_1().

◆ readchar_buf

unsigned char readchar_buf[BUFSIZ]
static

Definition at line 845 of file remote-utils.c.

Referenced by readchar().

◆ readchar_bufcnt

int readchar_bufcnt = 0
static

Definition at line 846 of file remote-utils.c.

Referenced by getpkt(), process_remaining(), readchar(), reschedule(), and reset_readchar().

◆ readchar_bufp

unsigned char* readchar_bufp
static

Definition at line 847 of file remote-utils.c.

Referenced by getpkt(), and readchar().

◆ readchar_callback

int readchar_callback = NOT_SCHEDULED
static

Definition at line 92 of file remote-utils.c.

Referenced by process_remaining(), reschedule(), and reset_readchar().

◆ remote_debug

int remote_debug = 0

◆ remote_desc

gdb_fildes_t remote_desc = INVALID_DESCRIPTOR
static

◆ remote_is_stdio

int remote_is_stdio = 0
static

Definition at line 109 of file remote-utils.c.

Referenced by remote_connection_is_stdio(), and remote_prepare().

◆ transport_is_reliable

int transport_is_reliable = 0

Definition at line 121 of file remote-utils.c.

Referenced by handle_query(), and remote_prepare().

◆ using_threads

int using_threads

Definition at line 255 of file linux-low.c.

Referenced by prepare_resume_reply().