GDBserver
|
#include "server.h"
#include "terminal.h"
#include "target.h"
#include "gdbthread.h"
#include "tdesc.h"
#include "dll.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "gdb_stat.h"
Go to the source code of this file.
Classes | |
struct | sym_cache |
Defines | |
#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 (char *name) |
void | remote_open (char *name) |
void | remote_close (void) |
static int | fromhex (int a) |
static int | ishex (int ch, int *val) |
int | unhexify (char *bin, const char *hex, int count) |
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 | tohex (int nib) |
int | hexify (char *hex, const char *bin, int count) |
int | remote_escape_output (const gdb_byte *buffer, int len, gdb_byte *out_buf, int *out_len, int out_maxlen) |
static int | remote_unescape_input (const gdb_byte *buffer, int len, gdb_byte *out_buf, int out_maxlen) |
static int | try_rle (char *buf, int remaining, unsigned char *csum, char **p) |
char * | unpack_varlen_hex (char *buff, ULONGEST *result) |
char * | write_ptid (char *buf, ptid_t ptid) |
ULONGEST | hex_or_minus_one (char *buf, char **obuf) |
ptid_t | read_ptid (char *buf, 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 | unblock_async_io (void) |
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) |
void | convert_int_to_ascii (const unsigned char *from, char *to, int n) |
void | convert_ascii_to_int (const char *from, unsigned char *to, int n) |
static char * | outreg (struct regcache *regcache, int regno, char *buf) |
void | new_thread_notify (int id) |
void | dead_thread_notify (int id) |
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 const char | hexchars [] = "0123456789abcdef" |
static int | async_io_enabled |
static unsigned char | readchar_buf [BUFSIZ] |
static int | readchar_bufcnt = 0 |
static unsigned char * | readchar_bufp |
#define INVALID_DESCRIPTOR -1 |
Definition at line 82 of file remote-utils.c.
Referenced by check_remote_input_interrupt_request(), gdb_connected(), and remote_close().
typedef int socklen_t |
Definition at line 74 of file remote-utils.c.
anonymous enum |
Definition at line 86 of file remote-utils.c.
void check_remote_input_interrupt_request | ( | void | ) |
Definition at line 945 of file remote-utils.c.
References input_interrupt(), INVALID_DESCRIPTOR, and remote_desc.
Referenced by get_child_debug_event().
void clear_symbol_cache | ( | struct sym_cache ** | symcache_p | ) |
Definition at line 1569 of file remote-utils.c.
References free_sym_cache(), and sym_cache::next.
Referenced by remove_process().
void convert_ascii_to_int | ( | const char * | from, |
unsigned char * | to, | ||
int | n | ||
) |
Definition at line 1252 of file remote-utils.c.
References fromhex().
Referenced by decode_M_packet(), gdb_parse_agent_expr(), process_serial_event(), and registers_from_string().
void convert_int_to_ascii | ( | const unsigned char * | from, |
char * | to, | ||
int | n | ||
) |
Definition at line 1234 of file remote-utils.c.
References tohex().
Referenced by cmd_qtbuffer(), cmd_qtstatus(), collect_register_as_string(), gdb_unparse_agent_expr(), look_up_one_symbol(), process_serial_event(), registers_to_string(), relocate_instruction(), response_source(), and response_tsv().
void dead_thread_notify | ( | int | id | ) |
Definition at line 1299 of file remote-utils.c.
References disable_async_io(), enable_async_io(), own_buf, and putpkt().
void decode_address | ( | CORE_ADDR * | addrp, |
const char * | start, | ||
int | len | ||
) |
Definition at line 481 of file remote-utils.c.
References fromhex().
Referenced by decode_address_to_semicolon(), handle_query(), and look_up_one_symbol().
const char* decode_address_to_semicolon | ( | CORE_ADDR * | addrp, |
const char * | start | ||
) |
Definition at line 498 of file remote-utils.c.
References decode_address().
Referenced by decode_search_memory_packet(), handle_general_set(), and linux_qxfer_libraries_svr4().
void decode_m_packet | ( | char * | from, |
CORE_ADDR * | mem_addr_ptr, | ||
unsigned int * | len_ptr | ||
) |
Definition at line 1439 of file remote-utils.c.
References fromhex().
Referenced by decode_xfer_read(), look_up_one_symbol(), process_serial_event(), and relocate_instruction().
void decode_M_packet | ( | char * | from, |
CORE_ADDR * | mem_addr_ptr, | ||
unsigned int * | len_ptr, | ||
unsigned char ** | to_p | ||
) |
Definition at line 1461 of file remote-utils.c.
References convert_ascii_to_int(), fromhex(), and xmalloc().
Referenced by process_serial_event(), and relocate_instruction().
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 1543 of file remote-utils.c.
References decode_address_to_semicolon(), and remote_unescape_input().
Referenced by handle_search_memory().
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 1487 of file remote-utils.c.
References fromhex(), remote_unescape_input(), and xmalloc().
Referenced by process_serial_event(), and relocate_instruction().
int decode_xfer_write | ( | char * | buf, |
int | packet_len, | ||
CORE_ADDR * | offset, | ||
unsigned int * | len, | ||
unsigned char * | data | ||
) |
Definition at line 1519 of file remote-utils.c.
References fromhex(), and remote_unescape_input().
Referenced by handle_qxfer().
void disable_async_io | ( | void | ) |
Definition at line 1015 of file remote-utils.c.
Referenced by dead_thread_notify(), handle_v_cont(), initialize_async_io(), myresume(), new_thread_notify(), and process_serial_event().
void enable_async_io | ( | void | ) |
Definition at line 999 of file remote-utils.c.
References input_interrupt().
Referenced by dead_thread_notify(), handle_v_cont(), myresume(), and new_thread_notify().
static void enable_async_notification | ( | int | fd | ) | [static] |
Definition at line 144 of file remote-utils.c.
Referenced by handle_accept_event(), and remote_open().
static void free_sym_cache | ( | struct sym_cache * | sym | ) | [static] |
Definition at line 1559 of file remote-utils.c.
References sym_cache::name.
Referenced by clear_symbol_cache().
static int fromhex | ( | int | a | ) | [static] |
Definition at line 423 of file remote-utils.c.
References error().
Referenced by convert_ascii_to_int(), decode_address(), decode_m_packet(), decode_M_packet(), decode_X_packet(), decode_xfer_write(), getpkt(), and unhexify().
int gdb_connected | ( | void | ) |
Definition at line 130 of file remote-utils.c.
References INVALID_DESCRIPTOR, and remote_desc.
Referenced by handle_target_event(), and stop_tracing().
int getpkt | ( | char * | buf | ) |
Definition at line 1124 of file remote-utils.c.
References fromhex(), noack_mode, readchar(), remote_debug, and write_prim().
Referenced by look_up_one_symbol(), process_serial_event(), and relocate_instruction().
static int handle_accept_event | ( | int | err, |
gdb_client_data | client_data | ||
) | [static] |
Definition at line 158 of file remote-utils.c.
References add_file_handler(), debug_threads, delete_file_handler(), enable_async_notification(), handle_serial_event(), listen_desc, perror_with_name(), remote_desc, run_once, and target_async.
Referenced by remote_open().
ULONGEST hex_or_minus_one | ( | char * | buf, |
char ** | obuf | ||
) |
Definition at line 717 of file remote-utils.c.
References unpack_varlen_hex().
Referenced by read_ptid().
int hexify | ( | char * | hex, |
const char * | bin, | ||
int | count | ||
) |
Definition at line 529 of file remote-utils.c.
References tohex().
Referenced by cmd_qtstatus(), look_up_one_symbol(), and monitor_output().
void initialize_async_io | ( | void | ) |
Definition at line 1031 of file remote-utils.c.
References disable_async_io(), and unblock_async_io().
Referenced by main().
static void input_interrupt | ( | int | unused | ) | [static] |
Definition at line 915 of file remote-utils.c.
References current_inferior, read_prim(), remote_desc, target_ops::request_interrupt, and the_target.
Referenced by check_remote_input_interrupt_request(), and enable_async_io().
static int ishex | ( | int | ch, |
int * | val | ||
) | [static] |
Definition at line 439 of file remote-utils.c.
Referenced by unpack_varlen_hex().
int look_up_one_symbol | ( | const char * | name, |
CORE_ADDR * | addrp, | ||
int | may_ask_gdb | ||
) |
Definition at line 1588 of file remote-utils.c.
References sym_cache::addr, convert_int_to_ascii(), current_process(), decode_address(), decode_m_packet(), getpkt(), hexify(), mem_buf, sym_cache::name, sym_cache::next, own_buf, putpkt(), read_inferior_memory(), process_info::symbol_cache, warning(), write_enn(), xmalloc(), and xstrdup().
Referenced by agent_look_up_symbols(), thread_db_look_up_one_symbol(), thread_db_look_up_symbols(), and tracepoint_look_up_symbols().
void monitor_output | ( | const char * | msg | ) |
Definition at line 1769 of file remote-utils.c.
References hexify(), putpkt(), and xmalloc().
Referenced by handle_monitor_command(), handle_output_debug_string(), monitor_show_help(), and thread_db_handle_monitor_command().
void new_thread_notify | ( | int | id | ) |
Definition at line 1281 of file remote-utils.c.
References disable_async_io(), enable_async_io(), own_buf, putpkt(), and server_waiting.
Definition at line 1264 of file remote-utils.c.
References collect_register_as_string(), register_size(), regcache::tdesc, and tohex().
Referenced by prepare_resume_reply().
void prepare_resume_reply | ( | char * | buf, |
ptid_t | ptid, | ||
struct target_waitstatus * | status | ||
) |
Definition at line 1314 of file remote-utils.c.
References current_inferior, current_target_desc(), debug_threads, disable_packet_Tthread, dlls_changed, error(), target_desc::expedite_regs, find_regno(), find_thread_ptid(), general_thread, get_thread_regcache(), multi_process, non_stop, outreg(), ptid_equal(), ptid_get_pid(), target_ops::stopped_by_watchpoint, target_ops::stopped_data_address, target_core_of_thread, target_pid_to_str(), regcache::tdesc, the_target, tohex(), using_threads, and write_ptid().
Referenced by handle_status(), handle_v_attach(), handle_v_cont(), handle_v_run(), myresume(), and vstop_notif_reply().
static int process_remaining | ( | void * | context | ) | [static] |
Definition at line 1095 of file remote-utils.c.
References handle_serial_event(), NOT_SCHEDULED, and readchar_callback.
Referenced by reschedule().
int putpkt | ( | char * | buf | ) |
Definition at line 897 of file remote-utils.c.
References putpkt_binary().
Referenced by dead_thread_notify(), look_up_one_symbol(), main(), monitor_output(), new_thread_notify(), process_serial_event(), and relocate_instruction().
int putpkt_binary | ( | char * | buf, |
int | cnt | ||
) |
Definition at line 887 of file remote-utils.c.
References putpkt_binary_1().
Referenced by process_serial_event(), and putpkt().
static int putpkt_binary_1 | ( | char * | buf, |
int | cnt, | ||
int | is_notif | ||
) | [static] |
Definition at line 803 of file remote-utils.c.
References current_inferior, noack_mode, perror(), readchar(), remote_debug, target_ops::request_interrupt, the_target, tohex(), try_rle(), write_prim(), and xmalloc().
Referenced by putpkt_binary(), and putpkt_notif().
int putpkt_notif | ( | char * | buf | ) |
Definition at line 903 of file remote-utils.c.
References putpkt_binary_1().
Referenced by notif_push().
static int read_prim | ( | void * | buf, |
int | count | ||
) | [static] |
Definition at line 790 of file remote-utils.c.
References remote_connection_is_stdio(), and remote_desc.
Referenced by input_interrupt(), and readchar().
Definition at line 738 of file remote-utils.c.
References current_ptid, error(), hex_or_minus_one(), ptid_build(), ptid_get_pid(), and unpack_varlen_hex().
Referenced by handle_query(), handle_v_cont(), and process_serial_event().
static int readchar | ( | void | ) | [static] |
Definition at line 1052 of file remote-utils.c.
References perror(), read_prim(), readchar_buf, and reschedule().
Referenced by getpkt(), and putpkt_binary_1().
int relocate_instruction | ( | CORE_ADDR * | to, |
CORE_ADDR | oldloc | ||
) |
Definition at line 1686 of file remote-utils.c.
References convert_int_to_ascii(), decode_m_packet(), decode_M_packet(), decode_X_packet(), getpkt(), mem_buf, own_buf, paddress(), putpkt(), read_inferior_memory(), unpack_varlen_hex(), warning(), write_enn(), write_inferior_memory(), write_ok(), and xmalloc().
Referenced by i386_install_fast_tracepoint_jump_pad().
void remote_close | ( | void | ) |
Definition at line 405 of file remote-utils.c.
References delete_file_handler(), INVALID_DESCRIPTOR, remote_connection_is_stdio(), remote_desc, and reset_readchar().
Referenced by process_serial_event().
int remote_connection_is_stdio | ( | void | ) |
Definition at line 138 of file remote-utils.c.
References remote_is_stdio.
Referenced by linux_create_inferior(), mywait(), process_serial_event(), read_prim(), remote_close(), and write_prim().
int remote_escape_output | ( | const gdb_byte * | buffer, |
int | len, | ||
gdb_byte * | out_buf, | ||
int * | out_len, | ||
int | out_maxlen | ||
) |
Definition at line 554 of file remote-utils.c.
Referenced by write_qxfer_response().
void remote_open | ( | char * | name | ) |
Definition at line 291 of file remote-utils.c.
References add_file_handler(), enable_async_notification(), errno, error(), handle_accept_event(), handle_serial_event(), listen_desc, perror_with_name(), remote_desc, STDIO_CONNECTION_NAME, and strchr().
Referenced by main().
void remote_prepare | ( | char * | name | ) |
Definition at line 224 of file remote-utils.c.
References fatal(), listen_desc, perror_with_name(), remote_is_stdio, STDIO_CONNECTION_NAME, strchr(), and transport_is_reliable.
Referenced by main().
static int remote_unescape_input | ( | const gdb_byte * | buffer, |
int | len, | ||
gdb_byte * | out_buf, | ||
int | out_maxlen | ||
) | [static] |
Definition at line 595 of file remote-utils.c.
References error().
Referenced by decode_search_memory_packet(), decode_X_packet(), and decode_xfer_write().
static void reschedule | ( | void | ) | [static] |
Definition at line 1114 of file remote-utils.c.
References append_callback_event(), NOT_SCHEDULED, process_remaining(), and readchar_callback.
Referenced by readchar().
static void reset_readchar | ( | void | ) | [static] |
Definition at line 1082 of file remote-utils.c.
References delete_callback_event(), NOT_SCHEDULED, and readchar_callback.
Referenced by remote_close().
static int tohex | ( | int | nib | ) | [static] |
Definition at line 518 of file remote-utils.c.
Referenced by convert_int_to_ascii(), hexify(), outreg(), prepare_resume_reply(), and putpkt_binary_1().
static int try_rle | ( | char * | buf, |
int | remaining, | ||
unsigned char * | csum, | ||
char ** | p | ||
) | [static] |
Definition at line 632 of file remote-utils.c.
Referenced by putpkt_binary_1().
static void unblock_async_io | ( | void | ) | [static] |
Definition at line 961 of file remote-utils.c.
Referenced by initialize_async_io().
int unhexify | ( | char * | bin, |
const char * | hex, | ||
int | count | ||
) |
Definition at line 462 of file remote-utils.c.
References fromhex().
Referenced by cmd_qtdpsrc(), cmd_qtdv(), cmd_qtnotes(), handle_query(), and handle_v_run().
char* unpack_varlen_hex | ( | char * | buff, |
ULONGEST * | result | ||
) |
Definition at line 674 of file remote-utils.c.
References ishex().
Referenced by add_tracepoint_action(), cmd_bigqtbuffer_circular(), cmd_bigqtbuffer_size(), cmd_qtbuffer(), cmd_qtdisconnected(), cmd_qtdp(), cmd_qtdpsrc(), cmd_qtdv(), cmd_qtenable_disable(), cmd_qtframe(), cmd_qtp(), cmd_qtro(), cmd_qtv(), gdb_parse_agent_expr(), handle_general_set(), handle_query(), handle_v_cont(), hex_or_minus_one(), process_serial_event(), read_ptid(), and relocate_instruction().
void write_enn | ( | char * | buf | ) |
Definition at line 1222 of file remote-utils.c.
Referenced by cmd_bigqtbuffer_size(), cmd_qtbuffer(), cmd_qtdp(), cmd_qtdpsrc(), cmd_qtenable_disable(), cmd_qtp(), cmd_qtstart(), handle_general_set(), handle_monitor_command(), handle_query(), handle_qxfer(), handle_v_attach(), handle_v_cont(), handle_v_kill(), handle_v_requests(), handle_v_run(), install_tracepoint(), look_up_one_symbol(), main(), process_serial_event(), and relocate_instruction().
void write_ok | ( | char * | buf | ) |
Definition at line 1214 of file remote-utils.c.
Referenced by cmd_bigqtbuffer_circular(), cmd_bigqtbuffer_size(), cmd_qtdisconnected(), cmd_qtdp(), cmd_qtdpsrc(), cmd_qtdv(), cmd_qtenable_disable(), cmd_qtframe(), cmd_qtinit(), cmd_qtnotes(), cmd_qtro(), cmd_qtstart(), cmd_qtstop(), handle_btrace_general_set(), handle_general_set(), handle_query(), handle_v_attach(), handle_v_cont(), handle_v_kill(), install_tracepoint(), myresume(), notif_write_event(), process_serial_event(), and relocate_instruction().
static int write_prim | ( | const void * | buf, |
int | count | ||
) | [static] |
Definition at line 777 of file remote-utils.c.
References remote_connection_is_stdio(), and remote_desc.
Referenced by getpkt(), and putpkt_binary_1().
char* write_ptid | ( | char * | buf, |
ptid_t | ptid | ||
) |
Definition at line 695 of file remote-utils.c.
References multi_process, ptid_get_lwp(), and ptid_get_pid().
Referenced by handle_query(), handle_qxfer_threads_proper(), and prepare_resume_reply().
int async_io_enabled [static] |
Definition at line 995 of file remote-utils.c.
int debug_threads |
struct ui_file* gdb_stdlog |
Definition at line 108 of file remote-utils.c.
const char hexchars[] = "0123456789abcdef" [static] |
Definition at line 436 of file remote-utils.c.
gdb_fildes_t listen_desc = INVALID_DESCRIPTOR [static] |
Definition at line 113 of file remote-utils.c.
Referenced by handle_accept_event(), remote_open(), and remote_prepare().
int noack_mode = 0 |
Definition at line 120 of file remote-utils.c.
Referenced by getpkt(), handle_general_set(), main(), and putpkt_binary_1().
unsigned char readchar_buf[BUFSIZ] [static] |
Definition at line 1045 of file remote-utils.c.
Referenced by readchar().
int readchar_bufcnt = 0 [static] |
Definition at line 1046 of file remote-utils.c.
unsigned char* readchar_bufp [static] |
Definition at line 1047 of file remote-utils.c.
int readchar_callback = NOT_SCHEDULED [static] |
Definition at line 93 of file remote-utils.c.
Referenced by process_remaining(), reschedule(), and reset_readchar().
int remote_debug = 0 |
Definition at line 107 of file remote-utils.c.
Referenced by getpkt(), handle_notif_ack(), notif_event_enque(), and putpkt_binary_1().
gdb_fildes_t remote_desc = INVALID_DESCRIPTOR [static] |
Definition at line 112 of file remote-utils.c.
Referenced by check_remote_input_interrupt_request(), gdb_connected(), handle_accept_event(), input_interrupt(), read_prim(), remote_close(), remote_open(), and write_prim().
int remote_is_stdio = 0 [static] |
Definition at line 110 of file remote-utils.c.
Referenced by remote_connection_is_stdio(), and remote_prepare().
int transport_is_reliable = 0 |
Definition at line 122 of file remote-utils.c.
Referenced by handle_query(), and remote_prepare().
int using_threads |
Definition at line 217 of file linux-low.c.
Referenced by prepare_resume_reply().