From 270c6aeaf2ebc84b1d36449a451fe006b240f397 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 5 Sep 2013 22:18:48 +0000 Subject: [PATCH] Add missing new files from these previous commits: 2013-09-05 Pedro Alves * server.h (handle_vFile, hostio_last_error_from_errno): Move to ... * hostio.h: ... this new file. * hostio.c, server.c, linux-low.c, nto-low.c, spu-low, win32-low.c: Include hostio.h. 2013-09-05 Pedro Alves * server.h (gdb_client_data, handler_func, callback_handler_func) (delete_file_handler, add_file_handler, append_callback_event) (delete_callback_event, start_event_loop, initialize_event_loop): Move to event-loop.h and include it. * event-loop.h: New file. 2013-09-05 Pedro Alves * dll.c, inferiors.c, remote-utils.c, server.c: Include "dll.h". * server.h (struct dll_info, all_dlls, dlls_changed, clear_dlls) (loaded_dll, unloaded_dll): Move to ... * dll.h: ... this new file. * inferiors.c, remote-utils.c, win32-low.c: Include "dll.h". 2013-09-05 Pedro Alves * server.h (current_process, get_thread_process, all_processes) (add_inferior_to_list, for_each_inferior, current_inferior) (remove_inferior, add_process, remove_process, find_process_pid) (have_started_inferiors_p, have_attached_inferiors_p) (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id) (clear_inferiors, find_inferior, find_inferior_id) (inferior_target_data, set_inferior_target_data) (inferior_regcache_data, set_inferior_regcache_data): Move to inferiors.h, and include it. * inferiors.h: New file. 2013-09-05 Pedro Alves * ax.c, linux-low.c, linux-x86-low.c, server.c: Include tracepoint.h. * server.h (IPA_BUFSIZ, initialize_tracepoint, tracing) (disconnected_tracing, tracepoint_look_up_symbols, stop_tracing (handle_tracepoint_general_set, handle_tracepoint_query) (tracepoint_finished_step, tracepoint_was_hit) (release_while_stepping_state_list, current_traceframe) (in_readonly_region, traceframe_read_mem) (fetch_traceframe_registers, traceframe_read_sdata) (traceframe_read_info, struct fast_tpoint_collect_status) (fast_tracepoint_collecting, force_unlock_trace_buffer) (handle_tracepoit_bkpts, initialize_low_tracepoint) (supply_fast_tracepoint_registers) (supply_static_tracepoint_registers, set_trampoline_buffer_space) (ipa_tdesc, claim_trampoline_space) (have_fast_tracepoint_trampoline_buffer, gdb_agent_about_to_close) (agent_mem_read, agent_get_trace_state_variable_value) (agent_set_trace_state_variable_value, agent_tsv_read) (agent_mem_read_string, get_raw_reg_func_addr) (get_get_tsv_func_addr, get_set_tsv_func_addr): Move to ... * tracepoint.h: ... this new file. 2013-09-05 Pedro Alves * server.h (perror_with_name, error, fatal, warning, paddress) (pulongest, plongest, phex_nz, pfildes): Move to utils.h, and include it. * utils.h: New file. 2013-09-05 Pedro Alves * server.h (remote_debug, noack_mode, transport_is_reliable) (gdb_connected, STDIO_CONNECTION_NAME, remote_connection_is_stdio) (read_ptid, write_ptid, putpkt, putpkt_binary, putpkt_notif) (getpkt, remote_prepare, remote_open, remote_close, write_ok) (write_enn, initialize_async_io, enable_async_io) (disable_async_io, check_remote_input_interrupt_request) (convert_ascii_to_int, convert_int_to_ascii, new_thread_notify) (dead_thread_notify, prepare_resume_reply) (decode_address_to_semicolon, decode_address, decode_m_packet) (decode_M_packet, decode_X_packet, decode_xfer_write) (decode_search_memory_packet, unhexify, hexify) (remote_escape_output, unpack_varlen_hex, clear_symbol_cache) (look_up_one_symbol, relocate_instruction) (monitor_output): Move to remote-utils.h, and include it. * remote-utils.h: New file. --- gdb/gdbserver/dll.h | 35 ++++++++++ gdb/gdbserver/event-loop.h | 36 ++++++++++ gdb/gdbserver/hostio.h | 28 ++++++++ gdb/gdbserver/inferiors.h | 114 ++++++++++++++++++++++++++++++ gdb/gdbserver/remote-utils.h | 85 ++++++++++++++++++++++ gdb/gdbserver/tracepoint.h | 132 +++++++++++++++++++++++++++++++++++ gdb/gdbserver/utils.h | 32 +++++++++ 7 files changed, 462 insertions(+) create mode 100644 gdb/gdbserver/dll.h create mode 100644 gdb/gdbserver/event-loop.h create mode 100644 gdb/gdbserver/hostio.h create mode 100644 gdb/gdbserver/inferiors.h create mode 100644 gdb/gdbserver/remote-utils.h create mode 100644 gdb/gdbserver/tracepoint.h create mode 100644 gdb/gdbserver/utils.h diff --git a/gdb/gdbserver/dll.h b/gdb/gdbserver/dll.h new file mode 100644 index 00000000000..428c60c4e9b --- /dev/null +++ b/gdb/gdbserver/dll.h @@ -0,0 +1,35 @@ +/* Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef DLL_H +#define DLL_H + +struct dll_info +{ + struct inferior_list_entry entry; + char *name; + CORE_ADDR base_addr; +}; + +extern struct inferior_list all_dlls; +extern int dlls_changed; + +extern void clear_dlls (void); +extern void loaded_dll (const char *name, CORE_ADDR base_addr); +extern void unloaded_dll (const char *name, CORE_ADDR base_addr); + +#endif /* DLL_H */ diff --git a/gdb/gdbserver/event-loop.h b/gdb/gdbserver/event-loop.h new file mode 100644 index 00000000000..49673899b7f --- /dev/null +++ b/gdb/gdbserver/event-loop.h @@ -0,0 +1,36 @@ +/* Event loop machinery for the remote server for GDB. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef EVENT_LOOP_H +#define EVENT_LOOP_H + +typedef void *gdb_client_data; +typedef int (handler_func) (int, gdb_client_data); +typedef int (callback_handler_func) (gdb_client_data); + +extern void delete_file_handler (gdb_fildes_t fd); +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, + gdb_client_data client_data); +extern int append_callback_event (callback_handler_func *proc, + gdb_client_data client_data); +extern void delete_callback_event (int id); + +extern void start_event_loop (void); +extern void initialize_event_loop (void); + +#endif /* EVENT_LOOP_H */ diff --git a/gdb/gdbserver/hostio.h b/gdb/gdbserver/hostio.h new file mode 100644 index 00000000000..802374cbdb4 --- /dev/null +++ b/gdb/gdbserver/hostio.h @@ -0,0 +1,28 @@ +/* Host file transfer support for gdbserver. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef HOSTIO_H +#define HOSTIO_H + +/* Functions from hostio.c. */ +extern int handle_vFile (char *, int, int *); + +/* Functions from hostio-errno.c. */ +extern void hostio_last_error_from_errno (char *own_buf); + +#endif /* HOSTIO_H */ diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h new file mode 100644 index 00000000000..ba28d5a599a --- /dev/null +++ b/gdb/gdbserver/inferiors.h @@ -0,0 +1,114 @@ +/* Inferior process information for the remote server for GDB. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef INFERIORS_H +#define INFERIORS_H + +/* Generic information for tracking a list of ``inferiors'' - threads, + processes, etc. */ +struct inferior_list +{ + struct inferior_list_entry *head; + struct inferior_list_entry *tail; +}; +struct inferior_list_entry +{ + ptid_t id; + struct inferior_list_entry *next; +}; + +struct thread_info; +struct target_desc; +struct sym_cache; +struct breakpoint; +struct raw_breakpoint; +struct fast_tracepoint_jump; +struct process_info_private; + +struct process_info +{ + struct inferior_list_entry head; + + /* Nonzero if this child process was attached rather than + spawned. */ + int attached; + + /* True if GDB asked us to detach from this process, but we remained + attached anyway. */ + int gdb_detached; + + /* The symbol cache. */ + struct sym_cache *symbol_cache; + + /* The list of memory breakpoints. */ + struct breakpoint *breakpoints; + + /* The list of raw memory breakpoints. */ + struct raw_breakpoint *raw_breakpoints; + + /* The list of installed fast tracepoints. */ + struct fast_tracepoint_jump *fast_tracepoint_jumps; + + const struct target_desc *tdesc; + + /* Private target data. */ + struct process_info_private *private; +}; + +/* Return a pointer to the process that corresponds to the current + thread (current_inferior). It is an error to call this if there is + no current thread selected. */ + +struct process_info *current_process (void); +struct process_info *get_thread_process (struct thread_info *); + +extern struct inferior_list all_processes; + +void add_inferior_to_list (struct inferior_list *list, + struct inferior_list_entry *new_inferior); +void for_each_inferior (struct inferior_list *list, + void (*action) (struct inferior_list_entry *)); + +extern struct thread_info *current_inferior; +void remove_inferior (struct inferior_list *list, + struct inferior_list_entry *entry); + +struct process_info *add_process (int pid, int attached); +void remove_process (struct process_info *process); +struct process_info *find_process_pid (int pid); +int have_started_inferiors_p (void); +int have_attached_inferiors_p (void); + +ptid_t thread_id_to_gdb_id (ptid_t); +ptid_t thread_to_gdb_id (struct thread_info *); +ptid_t gdb_id_to_thread_id (ptid_t); + +void clear_inferiors (void); +struct inferior_list_entry *find_inferior + (struct inferior_list *, + int (*func) (struct inferior_list_entry *, + void *), + void *arg); +struct inferior_list_entry *find_inferior_id (struct inferior_list *list, + ptid_t id); +void *inferior_target_data (struct thread_info *); +void set_inferior_target_data (struct thread_info *, void *); +void *inferior_regcache_data (struct thread_info *); +void set_inferior_regcache_data (struct thread_info *, void *); + +#endif /* INFERIORS_H */ diff --git a/gdb/gdbserver/remote-utils.h b/gdb/gdbserver/remote-utils.h new file mode 100644 index 00000000000..5a82ad044ee --- /dev/null +++ b/gdb/gdbserver/remote-utils.h @@ -0,0 +1,85 @@ +/* Remote utility routines for the remote server for GDB. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef REMOTE_UTILS_H +#define REMOTE_UTILS_H + +extern int remote_debug; +extern int noack_mode; +extern int transport_is_reliable; + +int gdb_connected (void); + +#define STDIO_CONNECTION_NAME "stdio" +int remote_connection_is_stdio (void); + +ptid_t read_ptid (char *buf, char **obuf); +char *write_ptid (char *buf, ptid_t ptid); + +int putpkt (char *buf); +int putpkt_binary (char *buf, int len); +int putpkt_notif (char *buf); +int getpkt (char *buf); +void remote_prepare (char *name); +void remote_open (char *name); +void remote_close (void); +void write_ok (char *buf); +void write_enn (char *buf); +void initialize_async_io (void); +void enable_async_io (void); +void disable_async_io (void); +void check_remote_input_interrupt_request (void); +void convert_ascii_to_int (const char *from, unsigned char *to, int n); +void convert_int_to_ascii (const unsigned char *from, char *to, int n); +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); + +const char *decode_address_to_semicolon (CORE_ADDR *addrp, const char *start); +void decode_address (CORE_ADDR *addrp, const char *start, int len); +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); + +int unhexify (char *bin, const char *hex, int count); +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); +char *unpack_varlen_hex (char *buff, ULONGEST *result); + +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); + +#endif /* REMOTE_UTILS_H */ diff --git a/gdb/gdbserver/tracepoint.h b/gdb/gdbserver/tracepoint.h new file mode 100644 index 00000000000..77590339e25 --- /dev/null +++ b/gdb/gdbserver/tracepoint.h @@ -0,0 +1,132 @@ +/* Tracepoint code for remote server for GDB. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef TRACEPOINT_H +#define TRACEPOINT_H + +/* Size for a small buffer to report problems from the in-process + agent back to GDBserver. */ +#define IPA_BUFSIZ 100 + +void initialize_tracepoint (void); + +extern int tracing; +extern int disconnected_tracing; + +void tracepoint_look_up_symbols (void); + +void stop_tracing (void); + +int handle_tracepoint_general_set (char *own_buf); +int handle_tracepoint_query (char *own_buf); + +int tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc); +int tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc); + +void release_while_stepping_state_list (struct thread_info *tinfo); + +extern int current_traceframe; + +int in_readonly_region (CORE_ADDR addr, ULONGEST length); +int traceframe_read_mem (int tfnum, CORE_ADDR addr, + unsigned char *buf, ULONGEST length, + ULONGEST *nbytes); +int fetch_traceframe_registers (int tfnum, + struct regcache *regcache, + int regnum); + +int traceframe_read_sdata (int tfnum, ULONGEST offset, + unsigned char *buf, ULONGEST length, + ULONGEST *nbytes); + +int traceframe_read_info (int tfnum, struct buffer *buffer); + +/* If a thread is determined to be collecting a fast tracepoint, this + structure holds the collect status. */ + +struct fast_tpoint_collect_status +{ + /* The tracepoint that is presently being collected. */ + int tpoint_num; + CORE_ADDR tpoint_addr; + + /* The address range in the jump pad of where the original + instruction the tracepoint jump was inserted was relocated + to. */ + CORE_ADDR adjusted_insn_addr; + CORE_ADDR adjusted_insn_addr_end; +}; + +int fast_tracepoint_collecting (CORE_ADDR thread_area, + CORE_ADDR stop_pc, + struct fast_tpoint_collect_status *status); +void force_unlock_trace_buffer (void); + +int handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc); + +#ifdef IN_PROCESS_AGENT +void initialize_low_tracepoint (void); +void supply_fast_tracepoint_registers (struct regcache *regcache, + const unsigned char *regs); +void supply_static_tracepoint_registers (struct regcache *regcache, + const unsigned char *regs, + CORE_ADDR pc); +void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end, + char *errmsg); + +extern const struct target_desc *ipa_tdesc; + +#else +void stop_tracing (void); + +int claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline); +int have_fast_tracepoint_trampoline_buffer (char *msgbuf); +void gdb_agent_about_to_close (int pid); +#endif + +struct traceframe; +struct eval_agent_expr_context; + +/* Do memory copies for bytecodes. */ +/* Do the recording of memory blocks for actions and bytecodes. */ + +int agent_mem_read (struct eval_agent_expr_context *ctx, + unsigned char *to, CORE_ADDR from, + ULONGEST len); + +LONGEST agent_get_trace_state_variable_value (int num); +void agent_set_trace_state_variable_value (int num, LONGEST val); + +/* Record the value of a trace state variable. */ + +int agent_tsv_read (struct eval_agent_expr_context *ctx, int n); +int agent_mem_read_string (struct eval_agent_expr_context *ctx, + unsigned char *to, + CORE_ADDR from, + ULONGEST len); + +/* Returns the address of the get_raw_reg function in the IPA. */ +CORE_ADDR get_raw_reg_func_addr (void); +/* Returns the address of the get_trace_state_variable_value + function in the IPA. */ +CORE_ADDR get_get_tsv_func_addr (void); +/* Returns the address of the set_trace_state_variable_value + function in the IPA. */ +CORE_ADDR get_set_tsv_func_addr (void); + +#endif /* TRACEPOINT_H */ diff --git a/gdb/gdbserver/utils.h b/gdb/gdbserver/utils.h new file mode 100644 index 00000000000..7f5f1d9b4f9 --- /dev/null +++ b/gdb/gdbserver/utils.h @@ -0,0 +1,32 @@ +/* General utility routines for the remote server for GDB. + Copyright (C) 1993-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef UTILS_H +#define UTILS_H + +void perror_with_name (const char *string); +void error (const char *string,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); +void fatal (const char *string,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); +void warning (const char *string,...) ATTRIBUTE_PRINTF (1, 2); +char *paddress (CORE_ADDR addr); +char *pulongest (ULONGEST u); +char *plongest (LONGEST l); +char *phex_nz (ULONGEST l, int sizeof_l); +char *pfildes (gdb_fildes_t fd); + +#endif /* UTILS_H */