GDBserver
Classes | Defines | Functions | Variables
/home/stan/gdb/src/gdb/gdbserver/server.c File Reference
#include "server.h"
#include "gdbthread.h"
#include "agent.h"
#include "notif.h"
#include "tdesc.h"
#include <unistd.h>
#include "gdb_wait.h"
#include "btrace-common.h"
#include "filestuff.h"
#include "tracepoint.h"
#include "dll.h"
#include "hostio.h"

Go to the source code of this file.

Classes

struct  vstop_notif
struct  qxfer

Defines

#define SEARCH_CHUNK_SIZE   16000
#define require_running(BUF)
#define require_running(BUF)

Functions

 DEFINE_QUEUE_P (notif_event_p)
static void queue_stop_reply (ptid_t ptid, struct target_waitstatus *status)
static int remove_all_on_match_pid (QUEUE(notif_event_p)*q, QUEUE_ITER(notif_event_p)*iter, struct notif_event *event, void *data)
static void discard_queued_stop_replies (int pid)
static void vstop_notif_reply (struct notif_event *event, char *own_buf)
static int target_running (void)
static int start_inferior (char **argv)
static int attach_inferior (int pid)
static int decode_xfer_read (char *buf, CORE_ADDR *ofs, unsigned int *len)
static int decode_xfer (char *buf, char **object, char **rw, char **annex, char **offset)
static int write_qxfer_response (char *buf, const void *data, int len, int is_more)
static const char * handle_btrace_enable (struct thread_info *thread)
static const char * handle_btrace_disable (struct thread_info *thread)
static int handle_btrace_general_set (char *own_buf)
static void handle_general_set (char *own_buf)
static const char * get_features_xml (const char *annex)
void monitor_show_help (void)
static int gdb_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
static int gdb_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
static int handle_search_memory_1 (CORE_ADDR start_addr, CORE_ADDR search_space_len, gdb_byte *pattern, unsigned pattern_len, gdb_byte *search_buf, unsigned chunk_size, unsigned search_buf_size, CORE_ADDR *found_addrp)
static void handle_search_memory (char *own_buf, int packet_len)
static void handle_monitor_command (char *mon, char *own_buf)
static int handle_qxfer_auxv (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_features (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_libraries (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_libraries_svr4 (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_osdata (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_siginfo (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_spu (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_statictrace (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static void handle_qxfer_threads_proper (struct buffer *buffer)
static int handle_qxfer_threads (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_traceframe_info (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer_btrace (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static int handle_qxfer (char *own_buf, int packet_len, int *new_packet_len_p)
static unsigned long long crc32 (CORE_ADDR base, int len, unsigned int crc)
void handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
static void gdb_wants_all_threads_stopped (void)
void handle_v_cont (char *own_buf)
int handle_v_attach (char *own_buf)
static int handle_v_run (char *own_buf)
int handle_v_kill (char *own_buf)
void handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
static void myresume (char *own_buf, int step, int sig)
static int queue_stop_reply_callback (struct inferior_list_entry *entry, void *arg)
static void gdb_wants_thread_stopped (struct inferior_list_entry *entry)
static void gdb_reattached_process (struct inferior_list_entry *entry)
static void handle_status (char *own_buf)
static void gdbserver_version (void)
static void gdbserver_usage (FILE *stream)
static void gdbserver_show_disableable (FILE *stream)
static int first_thread_of (struct inferior_list_entry *entry, void *args)
static void kill_inferior_callback (struct inferior_list_entry *entry)
static void detach_or_kill_inferior_callback (struct inferior_list_entry *entry)
static void print_started_pid (struct inferior_list_entry *entry)
static void print_attached_pid (struct inferior_list_entry *entry)
static void detach_or_kill_for_exit (void)
int main (int argc, char *argv[])
static void process_point_options (CORE_ADDR point_addr, char **packet)
static int process_serial_event (void)
int handle_serial_event (int err, gdb_client_data client_data)
int handle_target_event (int err, gdb_client_data client_data)

Variables

ptid_t cont_thread
ptid_t general_thread
int server_waiting
static int extended_protocol
static int response_needed
static int exit_requested
int run_once
int multi_process
int non_stop
int disable_randomization = 1
static char ** program_argv
static char ** wrapper_argv
int debug_threads
int debug_hw_points
int pass_signals [GDB_SIGNAL_LAST]
int program_signals [GDB_SIGNAL_LAST]
int program_signals_p
jmp_buf toplevel
unsigned long signal_pid
int disable_packet_vCont
int disable_packet_Tthread
int disable_packet_qC
int disable_packet_qfThreadInfo
static struct target_waitstatus last_status
static ptid_t last_ptid
static char * own_buf
static unsigned char * mem_buf
struct notif_server notif_stop
int remote_debug
static struct qxfer qxfer_packets []
static unsigned int crc32_table [256]

Define Documentation

#define require_running (   BUF)
Value:
if (!target_running ())                 \
    {                                           \
      write_enn (BUF);                          \
      return;                                   \
    }

Definition at line 2627 of file server.c.

Referenced by handle_query(), handle_v_requests(), and process_serial_event().

#define require_running (   BUF)
Value:
if (!target_running ())                 \
    {                                           \
      write_enn (BUF);                          \
      break;                                    \
    }

Definition at line 2627 of file server.c.

#define SEARCH_CHUNK_SIZE   16000

Referenced by handle_search_memory().


Function Documentation

static int attach_inferior ( int  pid) [static]
static unsigned long long crc32 ( CORE_ADDR  base,
int  len,
unsigned int  crc 
) [static]

Definition at line 1555 of file server.c.

References read_inferior_memory().

Referenced by handle_query().

static int decode_xfer ( char *  buf,
char **  object,
char **  rw,
char **  annex,
char **  offset 
) [static]

Definition at line 354 of file server.c.

Referenced by handle_qxfer().

static int decode_xfer_read ( char *  buf,
CORE_ADDR ofs,
unsigned int *  len 
) [static]

Definition at line 344 of file server.c.

References decode_m_packet().

Referenced by handle_qxfer().

static void detach_or_kill_for_exit ( void  ) [static]
static void detach_or_kill_inferior_callback ( struct inferior_list_entry entry) [static]
static void discard_queued_stop_replies ( int  pid) [static]
static int first_thread_of ( struct inferior_list_entry entry,
void *  args 
) [static]

Definition at line 2635 of file server.c.

References inferior_list_entry::id, and ptid_get_pid().

Referenced by process_serial_event().

static int gdb_read_memory ( CORE_ADDR  memaddr,
unsigned char *  myaddr,
int  len 
) [static]
static void gdb_reattached_process ( struct inferior_list_entry entry) [static]

Definition at line 2532 of file server.c.

References process_info::gdb_detached.

Referenced by handle_status().

static void gdb_wants_all_threads_stopped ( void  ) [static]

Definition at line 2524 of file server.c.

References all_threads, for_each_inferior(), and gdb_wants_thread_stopped().

Referenced by handle_status(), and handle_v_cont().

static void gdb_wants_thread_stopped ( struct inferior_list_entry entry) [static]

Definition at line 2506 of file server.c.

References thread_info::last_resume_kind, and thread_info::last_status.

Referenced by gdb_wants_all_threads_stopped().

static int gdb_write_memory ( CORE_ADDR  memaddr,
const unsigned char *  myaddr,
int  len 
) [static]
static void gdbserver_show_disableable ( FILE *  stream) [static]

Definition at line 2614 of file server.c.

Referenced by main().

static void gdbserver_usage ( FILE *  stream) [static]

Definition at line 2593 of file server.c.

Referenced by main().

static void gdbserver_version ( void  ) [static]

Definition at line 2582 of file server.c.

References host_name, and version.

Referenced by main().

static const char* get_features_xml ( const char *  annex) [static]

Definition at line 649 of file server.c.

References current_target_desc(), and target_desc::xmltarget.

Referenced by handle_qxfer_features().

static const char* handle_btrace_disable ( struct thread_info thread) [static]

Definition at line 420 of file server.c.

References thread_info::btrace, and target_disable_btrace.

Referenced by handle_btrace_general_set().

static const char* handle_btrace_enable ( struct thread_info thread) [static]
static int handle_btrace_general_set ( char *  own_buf) [static]
static void handle_general_set ( char *  own_buf) [static]
static void handle_monitor_command ( char *  mon,
char *  own_buf 
) [static]
void handle_query ( char *  own_buf,
int  packet_len,
int *  new_packet_len_p 
)
static int handle_qxfer ( char *  own_buf,
int  packet_len,
int *  new_packet_len_p 
) [static]
static int handle_qxfer_auxv ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 998 of file server.c.

References offset, target_ops::read_auxv, target_running(), and the_target.

static int handle_qxfer_btrace ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]
static int handle_qxfer_fdpic ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1330 of file server.c.

References offset, target_ops::read_loadmap, target_running(), and the_target.

static int handle_qxfer_features ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1014 of file server.c.

References get_features_xml(), memcpy(), offset, and target_running().

static int handle_qxfer_libraries ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]
static int handle_qxfer_libraries_svr4 ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1114 of file server.c.

References target_ops::qxfer_libraries_svr4, target_running(), and the_target.

static int handle_qxfer_osdata ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1130 of file server.c.

References offset, target_ops::qxfer_osdata, and the_target.

static int handle_qxfer_siginfo ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1143 of file server.c.

References offset, target_ops::qxfer_siginfo, target_running(), and the_target.

static int handle_qxfer_spu ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1159 of file server.c.

References offset, target_ops::qxfer_spu, target_running(), and the_target.

static int handle_qxfer_statictrace ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 1175 of file server.c.

References current_traceframe, target_running(), and traceframe_read_sdata().

static int handle_qxfer_threads ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]
static void handle_qxfer_threads_proper ( struct buffer buffer) [static]
static int handle_qxfer_traceframe_info ( const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]
static void handle_search_memory ( char *  own_buf,
int  packet_len 
) [static]

Definition at line 852 of file server.c.

References decode_search_memory_packet(), error(), handle_search_memory_1(), and SEARCH_CHUNK_SIZE.

Referenced by handle_query().

static int handle_search_memory_1 ( CORE_ADDR  start_addr,
CORE_ADDR  search_space_len,
gdb_byte pattern,
unsigned  pattern_len,
gdb_byte search_buf,
unsigned  chunk_size,
unsigned  search_buf_size,
CORE_ADDR found_addrp 
) [static]

Definition at line 770 of file server.c.

References gdb_read_memory(), memcpy(), and warning().

Referenced by handle_search_memory().

int handle_serial_event ( int  err,
gdb_client_data  client_data 
)
static void handle_status ( char *  own_buf) [static]
int handle_target_event ( int  err,
gdb_client_data  client_data 
)
int handle_v_attach ( char *  own_buf)
void handle_v_cont ( char *  own_buf)
int handle_v_kill ( char *  own_buf)
void handle_v_requests ( char *  own_buf,
int  packet_len,
int *  new_packet_len 
)
static int handle_v_run ( char *  own_buf) [static]
static void kill_inferior_callback ( struct inferior_list_entry entry) [static]
int main ( int  argc,
char *  argv[] 
)
void monitor_show_help ( void  )

Definition at line 688 of file server.c.

References monitor_output().

Referenced by handle_monitor_command().

static void myresume ( char *  own_buf,
int  step,
int  sig 
) [static]
static void print_attached_pid ( struct inferior_list_entry entry) [static]
static void print_started_pid ( struct inferior_list_entry entry) [static]
static void process_point_options ( CORE_ADDR  point_addr,
char **  packet 
) [static]

Definition at line 3049 of file server.c.

References add_breakpoint_commands(), add_breakpoint_condition(), and debug_threads.

Referenced by process_serial_event().

static int process_serial_event ( void  ) [static]

Definition at line 3099 of file server.c.

References all_processes, all_threads, any_persistent_commands(), clear_gdb_breakpoint_conditions(), convert_ascii_to_int(), convert_int_to_ascii(), current_inferior, current_ptid, current_target_desc(), current_traceframe, debug_threads, decode_m_packet(), decode_M_packet(), decode_X_packet(), detach_inferior, disable_async_io(), discard_queued_stop_replies(), disconnected_tracing, exit_requested, extended_protocol, fetch_traceframe_registers(), find_inferior(), find_inferior_id(), find_process_pid(), first_thread_of(), for_each_inferior(), free_register_cache(), process_info::gdb_detached, gdb_id_to_thread_id(), gdb_read_memory(), gdb_signal_to_host(), gdb_signal_to_host_p(), gdb_write_memory(), get_thread_regcache(), getpkt(), handle_general_set(), handle_query(), handle_status(), handle_v_requests(), inferior_list::head, inferior_list_entry::id, target_ops::insert_point, join_inferior, kill_inferior_callback(), thread_resume::kind, last_status, mem_buf, minus_one_ptid, multi_process, myresume(), mythread_alive, new_register_cache(), non_stop, null_ptid, own_buf, pid_to_ptid(), process_point_options(), program_argv, ptid_equal(), ptid_get_pid(), putpkt(), putpkt_binary(), QUEUE_is_empty, read_ptid(), registers_from_string(), registers_to_string(), remote_close(), remote_connection_is_stdio(), target_ops::remove_point, require_running, response_needed, target_ops::resume, set_desired_inferior(), thread_resume::sig, start_inferior(), start_non_stop(), stop_tracing(), target_running(), the_target, thread_resume::thread, tracing, unpack_varlen_hex(), write_enn(), and write_ok().

Referenced by handle_serial_event().

static void queue_stop_reply ( ptid_t  ptid,
struct target_waitstatus *  status 
) [static]
static int queue_stop_reply_callback ( struct inferior_list_entry entry,
void *  arg 
) [static]
static int remove_all_on_match_pid ( QUEUE(notif_event_p)*  q,
QUEUE_ITER(notif_event_p)*  iter,
struct notif_event event,
void *  data 
) [static]

Definition at line 151 of file server.c.

References ptid_get_pid(), and QUEUE_remove_elem.

Referenced by discard_queued_stop_replies().

static int start_inferior ( char **  argv) [static]
static int target_running ( void  ) [static]
static void vstop_notif_reply ( struct notif_event event,
char *  own_buf 
) [static]

Definition at line 181 of file server.c.

References prepare_resume_reply(), vstop_notif::ptid, and vstop_notif::status.

static int write_qxfer_response ( char *  buf,
const void *  data,
int  len,
int  is_more 
) [static]

Definition at line 389 of file server.c.

References PBUFSIZ, and remote_escape_output().

Referenced by handle_qxfer().


Variable Documentation

Definition at line 46 of file server.c.

Referenced by linux_request_interrupt(), linux_wait_1(), and set_desired_inferior().

unsigned int crc32_table[256] [static]
Initial value:
{0, 0}

Definition at line 1546 of file server.c.

Definition at line 71 of file server.c.

Referenced by aarch64_get_pc(), add_insns(), arm_get_pc(), attach_thread(), cancel_breakpoint(), cris_get_pc(), delete_fast_tracepoint_jump(), delete_raw_breakpoint(), dequeue_one_deferred_signal(), enqueue_one_deferred_signal(), find_one_thread(), finish_step_over(), gdb_no_commands_at_breakpoint(), get_detach_signal(), get_pc(), get_stop_pc(), handle_accept_event(), handle_monitor_command(), handle_serial_event(), handle_target_event(), handle_tracepoint_bkpts(), handle_tracepoints(), kill_one_lwp_callback(), linux_async(), linux_attach(), linux_attach_lwp_1(), linux_debug(), linux_detach_one_lwp(), linux_kill(), linux_kill_one_lwp(), linux_resume(), linux_resume_one_lwp(), linux_resume_one_thread(), linux_set_resume_request(), linux_stabilize_threads(), linux_wait(), linux_wait_1(), linux_wait_for_event(), linux_wait_for_lwp(), linux_write_memory(), linux_xfer_siginfo(), lynx_debug(), lynx_ptrace(), m32r_get_pc(), main(), maybe_move_out_of_jump_pad(), move_out_of_jump_pad_callback(), need_step_over_p(), nto_trace(), prepare_resume_reply(), proceed_all_lwps(), proceed_one_lwp(), process_point_options(), process_serial_event(), queue_stop_reply_callback(), reinsert_breakpoints_at(), reinsert_fast_tracepoint_jumps_at(), reinsert_raw_breakpoint(), select_event_lwp(), send_sigstop(), set_fast_tracepoint_jump(), set_raw_breakpoint_at(), sigchld_handler(), sparc_get_pc(), start_inferior(), start_step_over(), thread_db_create_event(), thread_db_find_new_threads(), thread_db_load_search(), trace_buffer_alloc(), tracepoint_look_up_symbols(), try_thread_db_load(), try_thread_db_load_1(), uninsert_breakpoints_at(), uninsert_fast_tracepoint_jumps_at(), uninsert_raw_breakpoint(), unstop_all_lwps(), upload_fast_traceframes(), and wait_for_sigstop().

Definition at line 110 of file server.c.

Referenced by handle_query(), and main().

Definition at line 111 of file server.c.

Referenced by handle_query(), and main().

Definition at line 109 of file server.c.

Referenced by main(), and prepare_resume_reply().

Definition at line 108 of file server.c.

Referenced by handle_v_requests(), and main().

Definition at line 65 of file server.c.

Referenced by handle_general_set(), linux_create_inferior(), and main().

int exit_requested [static]

Definition at line 55 of file server.c.

Referenced by handle_monitor_command(), main(), and process_serial_event().

int extended_protocol [static]

Definition at line 53 of file server.c.

Referenced by handle_v_requests(), and process_serial_event().

Definition at line 49 of file server.c.

Referenced by handle_query(), prepare_resume_reply(), and set_desired_inferior().

ptid_t last_ptid [static]

Definition at line 115 of file server.c.

Referenced by handle_target_event(), and handle_v_run().

struct target_waitstatus last_status [static]
unsigned char* mem_buf [static]

Definition at line 118 of file server.c.

Referenced by look_up_one_symbol(), main(), process_serial_event(), and relocate_instruction().

int non_stop
Initial value:
{
  "vStopped", "Stop", NULL, vstop_notif_reply,
}

Definition at line 188 of file server.c.

Referenced by discard_queued_stop_replies(), and queue_stop_reply().

char* own_buf [static]
int pass_signals[GDB_SIGNAL_LAST]

Definition at line 76 of file server.c.

Referenced by handle_general_set(), and linux_wait_1().

char** program_argv [static]

Definition at line 67 of file server.c.

Referenced by handle_v_run(), main(), and process_serial_event().

int program_signals[GDB_SIGNAL_LAST]

Definition at line 77 of file server.c.

Referenced by get_detach_signal(), and handle_general_set().

Definition at line 78 of file server.c.

Referenced by get_detach_signal(), and handle_general_set().

struct qxfer qxfer_packets[] [static]
Initial value:
  {
    { "auxv", handle_qxfer_auxv },
    { "btrace", handle_qxfer_btrace },
    { "fdpic", handle_qxfer_fdpic},
    { "features", handle_qxfer_features },
    { "libraries", handle_qxfer_libraries },
    { "libraries-svr4", handle_qxfer_libraries_svr4 },
    { "osdata", handle_qxfer_osdata },
    { "siginfo", handle_qxfer_siginfo },
    { "spu", handle_qxfer_spu },
    { "statictrace", handle_qxfer_statictrace },
    { "threads", handle_qxfer_threads },
    { "traceframe-info", handle_qxfer_traceframe_info },
  }

Definition at line 1409 of file server.c.

Referenced by handle_qxfer().

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

int response_needed [static]

Definition at line 54 of file server.c.

Referenced by main(), and process_serial_event().

int run_once

Definition at line 58 of file server.c.

Referenced by handle_accept_event(), and main().

unsigned long signal_pid

Definition at line 87 of file server.c.

Referenced by attach_inferior(), handle_v_kill(), linux_request_interrupt(), and start_inferior().

jmp_buf toplevel

Definition at line 80 of file server.c.

Referenced by error(), and main().

char ** wrapper_argv [static]

Definition at line 67 of file server.c.

Referenced by main(), and start_inferior().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines