binutils-gdb/gdb/remote.h

61 lines
2.3 KiB
C
Raw Normal View History

1999-09-22 05:28:34 +02:00
/* Remote target communications for serial-line targets in custom GDB protocol
Copyright (C) 1999-2020 Free Software Foundation, Inc.
1999-09-22 05:28:34 +02:00
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
1999-09-22 05:28:34 +02:00
(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 <http://www.gnu.org/licenses/>. */
1999-09-22 05:28:34 +02:00
#ifndef REMOTE_H
#define REMOTE_H
gdb/ 2012-12-15 Yao Qi <yao@codesourcery.com> * Makefile.in (REMOTE_OBS): Add "remote-notif.o". (SFILES): Add "remote-notif.c". (HFILES_NO_SRCDIR): Add "remote-notif.h" and "common/queue.h". * remote-notif.c: New. Factored out from remote.c. * remote-notif.h: New. * remote.c: Include "remote-notif.h". (stop_reply_xmalloc, do_stop_reply_xfree): (remote_parse_stop_reply, remote_get_pending_stop_replies): (remote_async_get_pending_events_handler): Remove declarations. (remote_parse_stop_reply): Declare. (pending_stop_reply): Remove. (remote_async_get_pending_events_token): Move to remote-notif.c. (remote_close): Replace 'delete_async_event_handler' with remote_notif_unregister_async_event_handler. Don't call discard_pending_stop_replies. (remote_start_remote): Replace code with remote_notif_parse and remote_notif_get_pending_replies. (remote_open_1): Replace 'create_async_event_handler' with remote_notif_register_async_event_handler. (extended_remote_attach_1): Call remote_notif_parse and notif_stop_reply_push. (struct stop_reply) <next>: Remove. <base>: New field. Callers update. (stop_reply_queue): Change its type. (stop_reply_xmalloc, do_stop_reply_xfree): Remove. (remote_notif_remove_all): New. (discard_pending_stop_replies): Update. (remote_notif_stop_ack, stop_reply_dtr): New. (remote_notif_stop_alloc_event): New. (notif_client_stop): New variable. (stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New. (queued_stop_reply, peek_stop_reply): Adjust. (remote_get_pending_stop_replies): Rename to remote_notif_get_pending_events. (handle_notification): Move to remote-notif.c. (remote_async_get_pending_events_handler): Likewise. (remote_wait_as): Adjust to call remote_notif_parse. Call 'getpkt_or_notif_sane' instead of 'getpkt_sane'. Return minus_one_ptid early if gets a notification. (remote_wait): Call QUEUE_is_empty (notif_reply_p). (_initialize_remote): Call QUEUE_alloc. Update caller. (remote_resume): Call 'remote_notif_process' in all-stop mode. * remote.h: Include "remote-notif.h". (remote_notif_get_pending_replies): Declare.
2012-12-15 04:50:22 +01:00
#include "remote-notif.h"
struct target_desc;
remote: one struct remote_state per struct remote_target 'struct remote_state' today contains per-connection state, however there's only a single global instance of that type. In order to support multiple connections, we must have one such object per connection. Thus this patch eliminates the 'remote_state' global in favor of having a remote_state instance per remote_target instance. The get_remote_state free function is eliminated as well, by making it a remote_target method instead. The patch then fixes the fallout by making all free functions that refer to get_remote_state() directly or indirectly be methods of remote_target too. Likewise, remote-fileio.c and remote-notif.c routines are parameterized with a remote_target pointer too, so they can call into the right remote_target instance. References to the global 'get_remote_state ()->remote_desc' to tell whether the remote target is open (!= nullptr) must be replaced with something else: - Command implementations use a new get_current_remote_target free function. - remote_target::open_1 checks the exception type instead. Finally, remote_target and extended_remote_target are made heap-allocated targets. As with the earlier core target patches, it still won't be possible to have more than one remote_target instance in practice, but this puts us closer. gdb/ChangeLog: 2018-05-22 Pedro Alves <palves@redhat.com> * remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror) (remote_fileio_badfd, remote_fileio_return_errno) (remote_fileio_return_success, remote_fileio_func_open) (remote_fileio_func_open, remote_fileio_func_close) (remote_fileio_func_read, remote_fileio_func_write) (remote_fileio_func_lseek, remote_fileio_func_rename) (remote_fileio_func_unlink, remote_fileio_func_stat) (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) (remote_fileio_func_isatty, remote_fileio_func_system): Add remote_target parameter. (remote_fio_func_map) <func>: Add remote_target parameter. (do_remote_fileio_request, remote_fileio_request): * remote-fileio.h (remote_fileio_request): * remote-notif.c (remote_notif_ack, remote_notif_parse, ): Add remote_target parameter. (remote_notif_process, handle_notification): Adjust to pass down the remote. (remote_notif_state_allocate): Add remote_target parameter. Save it. * remote-notif.h (struct remote_target): Forward declare. (struct notif_client) <parse, ack, can_get_pending_events>: Add remote_target parameter. (struct remote_notif_state) <remote>: New field. (remote_notif_ack, remote_notif_parse): Add remote_target parameter. (remote_notif_state_allocate, remote_notif_state_allocate): Add remote_target parameter. * remote.c (OPAQUETHREADBYTES, threadref, gdb_ext_thread_info) (threads_listing_context, rmt_thread_action, protocol_feature) (packet_reg, stop_reply, stop_reply_p, enum packet_support) (packet_result, struct threads_listing_context, remote_state): Move definitions and declarations higher up. (remote_target) <~remote_target>: Declare. (remote_download_command_source, remote_file_put, remote_file_get) (remote_file_delete, remote_hostio_pread, remote_hostio_pwrite) (remote_hostio_pread_vFile, remote_hostio_send_command) (remote_hostio_set_filesystem, remote_hostio_open) (remote_hostio_close, remote_hostio_unlink, remote_state) (get_remote_state, get_remote_packet_size, get_memory_packet_size) (get_memory_write_packet_size, get_memory_read_packet_size) (append_pending_thread_resumptions, remote_detach_1) (append_resumption, remote_resume_with_vcont) (add_current_inferior_and_thread, wait_ns, wait_as) (process_stop_reply, remote_notice_new_inferior) (process_initial_stop_replies, remote_add_thread) (btrace_sync_conf, remote_btrace_maybe_reopen) (remove_new_fork_children, kill_new_fork_children) (discard_pending_stop_replies, stop_reply_queue_length) (check_pending_events_prevent_wildcard_vcont) (discard_pending_stop_replies_in_queue, stop_reply) (remote_notif_remove_queued_reply, stop_reply *queued_stop_reply) (peek_stop_reply, remote_parse_stop_reply, remote_stop_ns) (remote_interrupt_as, remote_interrupt_ns) (remote_get_noisy_reply, remote_query_attached) (remote_add_inferior, remote_current_thread, get_current_thread) (set_thread, set_general_thread, set_continue_thread) (set_general_process, write_ptid) (remote_unpack_thread_info_response, remote_get_threadinfo) (parse_threadlist_response, remote_get_threadlist) (remote_threadlist_iterator, remote_get_threads_with_ql) (remote_get_threads_with_qxfer) (remote_get_threads_with_qthreadinfo, extended_remote_restart) (get_offsets, remote_check_symbols, remote_supported_packet) (remote_query_supported, remote_packet_size) (remote_serial_quit_handler, remote_detach_pid) (remote_vcont_probe, remote_resume_with_hc) (send_interrupt_sequence, interrupt_query) (remote_notif_get_pending_events, fetch_register_using_p) (send_g_packet, process_g_packet, fetch_registers_using_g) (store_register_using_P, store_registers_using_G) (set_remote_traceframe, check_binary_download) (remote_write_bytes_aux, remote_write_bytes, remote_read_bytes_1) (remote_xfer_live_readonly_partial, remote_read_bytes) (remote_send_printf, remote_flash_write, readchar) (remote_serial_write, putpkt, putpkt_binary, skip_frame) (read_frame, getpkt, getpkt_or_notif_sane_1, getpkt_sane) (getpkt_or_notif_sane, remote_vkill, remote_kill_k) (extended_remote_disable_randomization, extended_remote_run) (send_environment_packet, extended_remote_environment_support) (extended_remote_set_inferior_cwd, remote_write_qxfer) (remote_read_qxfer, push_stop_reply, vcont_r_supported) (packet_command): Now methods of ... (remote_target): ... this class. (m_remote_state) <remote_target>: New field. (struct remote_state) <stop_reply_queue, remote_async_inferior_event_token, wait_forever_enabled_p>: New fields. (remote_state::remote_state): Allocate stop_reply_queue. (remote_state): Delete global. (get_remote_state_raw): Delete. (remote_target::get_remote_state): Allocate m_remote_state on demand. (get_current_remote_target): New. (remote_ops, extended_remote_ops): Delete. (wait_forever_enabled_p, remote_async_inferior_event_token): Delete, moved to struct remote_state. (remote_target::close): Delete self. Destruction bits split to ... (remote_target::~remote_target): ... this. (show_memory_packet_size): Adjust to use get_current_remote_target. (struct protocol_feature) <func>: Add remote_target parameter. All callers adjusted. (curr_quit_handler_target): New. (remote_serial_quit_handler): Reimplement. (remote_target::open_1): Adjust to use get_current_remote_target. Heap-allocate remote_target/extended_remote_target instances. (vcont_builder::vcont_builder): Add remote_target parameter, and save it in m_remote. All callers adjusted. (vcont_builder::m_remote): New field. (vcont_builder::restart, vcont_builder::flush) (vcont_builder::push_action): Use it. (remote_target::commit_resume): Use it. (struct queue_iter_param) <remote>: New field. (remote_target::remove_new_fork_children): Fill in 'remote' field. (check_pending_event_prevents_wildcard_vcont_callback_data): New. (check_pending_event_prevents_wildcard_vcont_callback) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::discard_pending_stop_replies) (remote_target::discard_pending_stop_replies_in_queue) (remote_target::remote_notif_remove_queued_reply): Fill in 'remote' field. (remote_notif_get_pending_events): New. (remote_target::readchar, remote_target::remote_serial_write): Save/restore curr_quit_handler_target. (putpkt): New. (kill_new_fork_children): Fill in 'remote' field. (packet_command): Use get_current_remote_target, defer to remote_target method of same name. (scoped_remote_fd::scoped_remote_fd): Add 'remote_target' parameter, and save it in m_remote. All callers adjusted. (scoped_remote_fd::release): Use m_remote. (scoped_remote_fd::m_remote): New field. (remote_file_put, remote_file_get, remote_file_delete): Use get_current_remote_target, defer to remote_target method of same name. (remote_btrace_reset): Add remote_state paremeter. Update all callers. (remote_async_inferior_event_handler). Pass down 'data'. (remote_new_objfile): Use get_current_remote_target. (remote_target::vcont_r_supported): New. (set_range_stepping): Use get_current_remote_target and remote_target::vcont_r_supported. (_initialize_remote): Don't allocate 'remote_state' and 'stop_reply_queue' globals. * remote.h (struct remote_target): Forward declare. (getpkt, putpkt, remote_notif_get_pending_events): Add 'remote_target' parameter.
2018-05-22 19:22:11 +02:00
struct remote_target;
1999-09-22 05:28:34 +02:00
/* Read a packet from the remote machine, with error checking, and
* remote.c (struct remote_state): Add BUF and BUF_SIZE. (init_remote_state): Initialize the new fields. (get_memory_packet_size): Update BUF and BUF_SIZE if necessary. (set_thread, remote_thread_alive, remote_unpack_thread_info_response) (remote_get_threadinfo, parse_threadlist_response) (remote_get_threadlist, remote_current_thread, remote_threads_info) (remote_threads_extra_info, extended_remote_restart, get_offsets) (remote_check_symbols, remote_open_1, remote_detach) (remove_vcont_probe, remote_vcont_resume, remote_resume) (remote_wait, remote_async_wait, fetch_register_using_p) (remote_fetch_registers, store_register_using_P) (remote_store_registers, check_binary_download, remote_write_bytes) (remote_read_bytes, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_remove_watchpoint, remote_insert_hw_breakpoint) (remote_remove_hw_breakpoint, compare_sections_command) (remote_xfer_partial, remote_rcmd, packet_command) (remote_get_thread_local_address): Use the global incoming buffer instead of alloca or xmalloc. Limit outgoing packets to rs->remote_packet_size and incoming packets to rs->buf_size. Update calls to getpkt and remote_send. (remote_send): Take arguments by reference. (putpkt_binary): Eliminate junkbuf. Use skip_frame. (skip_frame): New function. (read_frame): Take arguments by reference. Expand the packet buffer instead of issuing an error. (getpkt, getpkt_sane): Take arguments by reference. * remote.h (getpkt): Update prototype and doc. * tracepoint.c (remote_get_noisy_reply): Take arguments by reference. (target_buf): Change from array to pointer. (target_buf_size): New variable. (remote_set_transparent_ranges): Update call to getpkt. (trace_start_command, trace_stop_command, trace_status_command): Update calls to remote_get_noisy_reply. (finish_tfind_command): Take arguments by reference. (trace_find_command, trace_find_pc_command) (trace_find_tracepoint_command, trace_find_line_command): (trace_find_range_command, trace_find_outside_command): Update calls to finish_tfind_command. (_initialize_tracepoint): Initialize target_buf_size and target_buf.
2006-03-30 18:25:06 +02:00
store it in *BUF. Resize *BUF using xrealloc if necessary to hold
the result, and update *SIZEOF_BUF. If FOREVER, wait forever
rather than timing out; this is used (in synchronous mode) to wait
for a target that is is executing user code to stop. */
1999-09-22 05:28:34 +02:00
remote: one struct remote_state per struct remote_target 'struct remote_state' today contains per-connection state, however there's only a single global instance of that type. In order to support multiple connections, we must have one such object per connection. Thus this patch eliminates the 'remote_state' global in favor of having a remote_state instance per remote_target instance. The get_remote_state free function is eliminated as well, by making it a remote_target method instead. The patch then fixes the fallout by making all free functions that refer to get_remote_state() directly or indirectly be methods of remote_target too. Likewise, remote-fileio.c and remote-notif.c routines are parameterized with a remote_target pointer too, so they can call into the right remote_target instance. References to the global 'get_remote_state ()->remote_desc' to tell whether the remote target is open (!= nullptr) must be replaced with something else: - Command implementations use a new get_current_remote_target free function. - remote_target::open_1 checks the exception type instead. Finally, remote_target and extended_remote_target are made heap-allocated targets. As with the earlier core target patches, it still won't be possible to have more than one remote_target instance in practice, but this puts us closer. gdb/ChangeLog: 2018-05-22 Pedro Alves <palves@redhat.com> * remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror) (remote_fileio_badfd, remote_fileio_return_errno) (remote_fileio_return_success, remote_fileio_func_open) (remote_fileio_func_open, remote_fileio_func_close) (remote_fileio_func_read, remote_fileio_func_write) (remote_fileio_func_lseek, remote_fileio_func_rename) (remote_fileio_func_unlink, remote_fileio_func_stat) (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) (remote_fileio_func_isatty, remote_fileio_func_system): Add remote_target parameter. (remote_fio_func_map) <func>: Add remote_target parameter. (do_remote_fileio_request, remote_fileio_request): * remote-fileio.h (remote_fileio_request): * remote-notif.c (remote_notif_ack, remote_notif_parse, ): Add remote_target parameter. (remote_notif_process, handle_notification): Adjust to pass down the remote. (remote_notif_state_allocate): Add remote_target parameter. Save it. * remote-notif.h (struct remote_target): Forward declare. (struct notif_client) <parse, ack, can_get_pending_events>: Add remote_target parameter. (struct remote_notif_state) <remote>: New field. (remote_notif_ack, remote_notif_parse): Add remote_target parameter. (remote_notif_state_allocate, remote_notif_state_allocate): Add remote_target parameter. * remote.c (OPAQUETHREADBYTES, threadref, gdb_ext_thread_info) (threads_listing_context, rmt_thread_action, protocol_feature) (packet_reg, stop_reply, stop_reply_p, enum packet_support) (packet_result, struct threads_listing_context, remote_state): Move definitions and declarations higher up. (remote_target) <~remote_target>: Declare. (remote_download_command_source, remote_file_put, remote_file_get) (remote_file_delete, remote_hostio_pread, remote_hostio_pwrite) (remote_hostio_pread_vFile, remote_hostio_send_command) (remote_hostio_set_filesystem, remote_hostio_open) (remote_hostio_close, remote_hostio_unlink, remote_state) (get_remote_state, get_remote_packet_size, get_memory_packet_size) (get_memory_write_packet_size, get_memory_read_packet_size) (append_pending_thread_resumptions, remote_detach_1) (append_resumption, remote_resume_with_vcont) (add_current_inferior_and_thread, wait_ns, wait_as) (process_stop_reply, remote_notice_new_inferior) (process_initial_stop_replies, remote_add_thread) (btrace_sync_conf, remote_btrace_maybe_reopen) (remove_new_fork_children, kill_new_fork_children) (discard_pending_stop_replies, stop_reply_queue_length) (check_pending_events_prevent_wildcard_vcont) (discard_pending_stop_replies_in_queue, stop_reply) (remote_notif_remove_queued_reply, stop_reply *queued_stop_reply) (peek_stop_reply, remote_parse_stop_reply, remote_stop_ns) (remote_interrupt_as, remote_interrupt_ns) (remote_get_noisy_reply, remote_query_attached) (remote_add_inferior, remote_current_thread, get_current_thread) (set_thread, set_general_thread, set_continue_thread) (set_general_process, write_ptid) (remote_unpack_thread_info_response, remote_get_threadinfo) (parse_threadlist_response, remote_get_threadlist) (remote_threadlist_iterator, remote_get_threads_with_ql) (remote_get_threads_with_qxfer) (remote_get_threads_with_qthreadinfo, extended_remote_restart) (get_offsets, remote_check_symbols, remote_supported_packet) (remote_query_supported, remote_packet_size) (remote_serial_quit_handler, remote_detach_pid) (remote_vcont_probe, remote_resume_with_hc) (send_interrupt_sequence, interrupt_query) (remote_notif_get_pending_events, fetch_register_using_p) (send_g_packet, process_g_packet, fetch_registers_using_g) (store_register_using_P, store_registers_using_G) (set_remote_traceframe, check_binary_download) (remote_write_bytes_aux, remote_write_bytes, remote_read_bytes_1) (remote_xfer_live_readonly_partial, remote_read_bytes) (remote_send_printf, remote_flash_write, readchar) (remote_serial_write, putpkt, putpkt_binary, skip_frame) (read_frame, getpkt, getpkt_or_notif_sane_1, getpkt_sane) (getpkt_or_notif_sane, remote_vkill, remote_kill_k) (extended_remote_disable_randomization, extended_remote_run) (send_environment_packet, extended_remote_environment_support) (extended_remote_set_inferior_cwd, remote_write_qxfer) (remote_read_qxfer, push_stop_reply, vcont_r_supported) (packet_command): Now methods of ... (remote_target): ... this class. (m_remote_state) <remote_target>: New field. (struct remote_state) <stop_reply_queue, remote_async_inferior_event_token, wait_forever_enabled_p>: New fields. (remote_state::remote_state): Allocate stop_reply_queue. (remote_state): Delete global. (get_remote_state_raw): Delete. (remote_target::get_remote_state): Allocate m_remote_state on demand. (get_current_remote_target): New. (remote_ops, extended_remote_ops): Delete. (wait_forever_enabled_p, remote_async_inferior_event_token): Delete, moved to struct remote_state. (remote_target::close): Delete self. Destruction bits split to ... (remote_target::~remote_target): ... this. (show_memory_packet_size): Adjust to use get_current_remote_target. (struct protocol_feature) <func>: Add remote_target parameter. All callers adjusted. (curr_quit_handler_target): New. (remote_serial_quit_handler): Reimplement. (remote_target::open_1): Adjust to use get_current_remote_target. Heap-allocate remote_target/extended_remote_target instances. (vcont_builder::vcont_builder): Add remote_target parameter, and save it in m_remote. All callers adjusted. (vcont_builder::m_remote): New field. (vcont_builder::restart, vcont_builder::flush) (vcont_builder::push_action): Use it. (remote_target::commit_resume): Use it. (struct queue_iter_param) <remote>: New field. (remote_target::remove_new_fork_children): Fill in 'remote' field. (check_pending_event_prevents_wildcard_vcont_callback_data): New. (check_pending_event_prevents_wildcard_vcont_callback) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::discard_pending_stop_replies) (remote_target::discard_pending_stop_replies_in_queue) (remote_target::remote_notif_remove_queued_reply): Fill in 'remote' field. (remote_notif_get_pending_events): New. (remote_target::readchar, remote_target::remote_serial_write): Save/restore curr_quit_handler_target. (putpkt): New. (kill_new_fork_children): Fill in 'remote' field. (packet_command): Use get_current_remote_target, defer to remote_target method of same name. (scoped_remote_fd::scoped_remote_fd): Add 'remote_target' parameter, and save it in m_remote. All callers adjusted. (scoped_remote_fd::release): Use m_remote. (scoped_remote_fd::m_remote): New field. (remote_file_put, remote_file_get, remote_file_delete): Use get_current_remote_target, defer to remote_target method of same name. (remote_btrace_reset): Add remote_state paremeter. Update all callers. (remote_async_inferior_event_handler). Pass down 'data'. (remote_new_objfile): Use get_current_remote_target. (remote_target::vcont_r_supported): New. (set_range_stepping): Use get_current_remote_target and remote_target::vcont_r_supported. (_initialize_remote): Don't allocate 'remote_state' and 'stop_reply_queue' globals. * remote.h (struct remote_target): Forward declare. (getpkt, putpkt, remote_notif_get_pending_events): Add 'remote_target' parameter.
2018-05-22 19:22:11 +02:00
extern void getpkt (remote_target *remote,
char **buf, long *sizeof_buf, int forever);
1999-09-22 05:28:34 +02:00
/* Send a packet to the remote machine, with error checking. The data
of the packet is in BUF. The string in BUF can be at most PBUFSIZ
- 5 to account for the $, # and checksum, and for a possible /0 if
we are debugging (remote_debug) and want to print the sent packet
as a string. */
1999-09-22 05:28:34 +02:00
remote: one struct remote_state per struct remote_target 'struct remote_state' today contains per-connection state, however there's only a single global instance of that type. In order to support multiple connections, we must have one such object per connection. Thus this patch eliminates the 'remote_state' global in favor of having a remote_state instance per remote_target instance. The get_remote_state free function is eliminated as well, by making it a remote_target method instead. The patch then fixes the fallout by making all free functions that refer to get_remote_state() directly or indirectly be methods of remote_target too. Likewise, remote-fileio.c and remote-notif.c routines are parameterized with a remote_target pointer too, so they can call into the right remote_target instance. References to the global 'get_remote_state ()->remote_desc' to tell whether the remote target is open (!= nullptr) must be replaced with something else: - Command implementations use a new get_current_remote_target free function. - remote_target::open_1 checks the exception type instead. Finally, remote_target and extended_remote_target are made heap-allocated targets. As with the earlier core target patches, it still won't be possible to have more than one remote_target instance in practice, but this puts us closer. gdb/ChangeLog: 2018-05-22 Pedro Alves <palves@redhat.com> * remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror) (remote_fileio_badfd, remote_fileio_return_errno) (remote_fileio_return_success, remote_fileio_func_open) (remote_fileio_func_open, remote_fileio_func_close) (remote_fileio_func_read, remote_fileio_func_write) (remote_fileio_func_lseek, remote_fileio_func_rename) (remote_fileio_func_unlink, remote_fileio_func_stat) (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) (remote_fileio_func_isatty, remote_fileio_func_system): Add remote_target parameter. (remote_fio_func_map) <func>: Add remote_target parameter. (do_remote_fileio_request, remote_fileio_request): * remote-fileio.h (remote_fileio_request): * remote-notif.c (remote_notif_ack, remote_notif_parse, ): Add remote_target parameter. (remote_notif_process, handle_notification): Adjust to pass down the remote. (remote_notif_state_allocate): Add remote_target parameter. Save it. * remote-notif.h (struct remote_target): Forward declare. (struct notif_client) <parse, ack, can_get_pending_events>: Add remote_target parameter. (struct remote_notif_state) <remote>: New field. (remote_notif_ack, remote_notif_parse): Add remote_target parameter. (remote_notif_state_allocate, remote_notif_state_allocate): Add remote_target parameter. * remote.c (OPAQUETHREADBYTES, threadref, gdb_ext_thread_info) (threads_listing_context, rmt_thread_action, protocol_feature) (packet_reg, stop_reply, stop_reply_p, enum packet_support) (packet_result, struct threads_listing_context, remote_state): Move definitions and declarations higher up. (remote_target) <~remote_target>: Declare. (remote_download_command_source, remote_file_put, remote_file_get) (remote_file_delete, remote_hostio_pread, remote_hostio_pwrite) (remote_hostio_pread_vFile, remote_hostio_send_command) (remote_hostio_set_filesystem, remote_hostio_open) (remote_hostio_close, remote_hostio_unlink, remote_state) (get_remote_state, get_remote_packet_size, get_memory_packet_size) (get_memory_write_packet_size, get_memory_read_packet_size) (append_pending_thread_resumptions, remote_detach_1) (append_resumption, remote_resume_with_vcont) (add_current_inferior_and_thread, wait_ns, wait_as) (process_stop_reply, remote_notice_new_inferior) (process_initial_stop_replies, remote_add_thread) (btrace_sync_conf, remote_btrace_maybe_reopen) (remove_new_fork_children, kill_new_fork_children) (discard_pending_stop_replies, stop_reply_queue_length) (check_pending_events_prevent_wildcard_vcont) (discard_pending_stop_replies_in_queue, stop_reply) (remote_notif_remove_queued_reply, stop_reply *queued_stop_reply) (peek_stop_reply, remote_parse_stop_reply, remote_stop_ns) (remote_interrupt_as, remote_interrupt_ns) (remote_get_noisy_reply, remote_query_attached) (remote_add_inferior, remote_current_thread, get_current_thread) (set_thread, set_general_thread, set_continue_thread) (set_general_process, write_ptid) (remote_unpack_thread_info_response, remote_get_threadinfo) (parse_threadlist_response, remote_get_threadlist) (remote_threadlist_iterator, remote_get_threads_with_ql) (remote_get_threads_with_qxfer) (remote_get_threads_with_qthreadinfo, extended_remote_restart) (get_offsets, remote_check_symbols, remote_supported_packet) (remote_query_supported, remote_packet_size) (remote_serial_quit_handler, remote_detach_pid) (remote_vcont_probe, remote_resume_with_hc) (send_interrupt_sequence, interrupt_query) (remote_notif_get_pending_events, fetch_register_using_p) (send_g_packet, process_g_packet, fetch_registers_using_g) (store_register_using_P, store_registers_using_G) (set_remote_traceframe, check_binary_download) (remote_write_bytes_aux, remote_write_bytes, remote_read_bytes_1) (remote_xfer_live_readonly_partial, remote_read_bytes) (remote_send_printf, remote_flash_write, readchar) (remote_serial_write, putpkt, putpkt_binary, skip_frame) (read_frame, getpkt, getpkt_or_notif_sane_1, getpkt_sane) (getpkt_or_notif_sane, remote_vkill, remote_kill_k) (extended_remote_disable_randomization, extended_remote_run) (send_environment_packet, extended_remote_environment_support) (extended_remote_set_inferior_cwd, remote_write_qxfer) (remote_read_qxfer, push_stop_reply, vcont_r_supported) (packet_command): Now methods of ... (remote_target): ... this class. (m_remote_state) <remote_target>: New field. (struct remote_state) <stop_reply_queue, remote_async_inferior_event_token, wait_forever_enabled_p>: New fields. (remote_state::remote_state): Allocate stop_reply_queue. (remote_state): Delete global. (get_remote_state_raw): Delete. (remote_target::get_remote_state): Allocate m_remote_state on demand. (get_current_remote_target): New. (remote_ops, extended_remote_ops): Delete. (wait_forever_enabled_p, remote_async_inferior_event_token): Delete, moved to struct remote_state. (remote_target::close): Delete self. Destruction bits split to ... (remote_target::~remote_target): ... this. (show_memory_packet_size): Adjust to use get_current_remote_target. (struct protocol_feature) <func>: Add remote_target parameter. All callers adjusted. (curr_quit_handler_target): New. (remote_serial_quit_handler): Reimplement. (remote_target::open_1): Adjust to use get_current_remote_target. Heap-allocate remote_target/extended_remote_target instances. (vcont_builder::vcont_builder): Add remote_target parameter, and save it in m_remote. All callers adjusted. (vcont_builder::m_remote): New field. (vcont_builder::restart, vcont_builder::flush) (vcont_builder::push_action): Use it. (remote_target::commit_resume): Use it. (struct queue_iter_param) <remote>: New field. (remote_target::remove_new_fork_children): Fill in 'remote' field. (check_pending_event_prevents_wildcard_vcont_callback_data): New. (check_pending_event_prevents_wildcard_vcont_callback) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::discard_pending_stop_replies) (remote_target::discard_pending_stop_replies_in_queue) (remote_target::remote_notif_remove_queued_reply): Fill in 'remote' field. (remote_notif_get_pending_events): New. (remote_target::readchar, remote_target::remote_serial_write): Save/restore curr_quit_handler_target. (putpkt): New. (kill_new_fork_children): Fill in 'remote' field. (packet_command): Use get_current_remote_target, defer to remote_target method of same name. (scoped_remote_fd::scoped_remote_fd): Add 'remote_target' parameter, and save it in m_remote. All callers adjusted. (scoped_remote_fd::release): Use m_remote. (scoped_remote_fd::m_remote): New field. (remote_file_put, remote_file_get, remote_file_delete): Use get_current_remote_target, defer to remote_target method of same name. (remote_btrace_reset): Add remote_state paremeter. Update all callers. (remote_async_inferior_event_handler). Pass down 'data'. (remote_new_objfile): Use get_current_remote_target. (remote_target::vcont_r_supported): New. (set_range_stepping): Use get_current_remote_target and remote_target::vcont_r_supported. (_initialize_remote): Don't allocate 'remote_state' and 'stop_reply_queue' globals. * remote.h (struct remote_target): Forward declare. (getpkt, putpkt, remote_notif_get_pending_events): Add 'remote_target' parameter.
2018-05-22 19:22:11 +02:00
extern int putpkt (remote_target *remote, const char *buf);
1999-09-22 05:28:34 +02:00
void register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
const struct target_desc *tdesc);
void register_remote_support_xml (const char *);
* remote.c (remote_cmdlist): New variable. (PACKET_vFile_open, PACKET_vFile_pread, PACKET_vFile_pwrite) (PACKET_vFile_close, PACKET_vFile_unlink): New constants. (remote_buffer_add_string, remote_buffer_add_bytes) (remote_buffer_add_int, remote_hostio_parse_result) (remote_hostio_send_command, remote_hostio_open, remote_hostio_pwrite) (remote_hostio_pread, remote_hostio_close, remote_hostio_unlink) (remote_fileio_errno_to_host, remote_hostio_error, fclose_cleanup) (remote_hostio_close_cleanup, remote_file_put, remote_file_get) (remote_file_delete, remote_put_command, remote_get_command) (remote_delete_command, remote_command): New functions. (_initialize_remote): Register new packets and commands. * Makefile.in (gdb_fileio_h): New variable. (remote.o): Update. (SUBDIR_MI_OBS): Add mi-cmd-target.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-target.c. (mi-cmd-target.o): New rule. * mi/mi-cmd-target.c: New file. * mi/mi-cmds.c (mi_cmds): Add target-file-delete, target-file-get, and target-file-put. * mi/mi-cmds.h (mi_cmd_target_file_get, mi_cmd_target_file_put) (mi_cmd_target_file_delete): Declare. * remote.h (remote_file_put, remote_file_get, remote_file_delete): Declare. * NEWS: Describe new file transfer support. * gdb.texinfo (Debugging Programs with Multiple Processes): Correct formatting. (Remote Debugging): Add File Transfer section. (Remote Configuration): Document Host I/O packets. (GDB/MI): Add GDB/MI File Transfer Commands section. (Remote Protocol): Add Host I/O Packets section. (Packets): Add vFile. * Makefile.in (OBS): Add hostio.o. (hostio.o): New rule. * server.h (handle_vFile): Declare. * hostio.c: New file. * server.c (handle_v_requests): Take packet_len and new_packet_len for binary packets. Call handle_vFile. (main): Update call to handle_v_requests. * gdb.server/file-transfer.exp, gdb.server/transfer.txt, gdb.mi/mi-file-transfer.exp: New.
2007-11-30 22:50:19 +01:00
void remote_file_put (const char *local_file, const char *remote_file,
int from_tty);
void remote_file_get (const char *remote_file, const char *local_file,
int from_tty);
void remote_file_delete (const char *remote_file, int from_tty);
extern int remote_register_number_and_offset (struct gdbarch *gdbarch,
int regnum, int *pnum,
int *poffset);
remote: one struct remote_state per struct remote_target 'struct remote_state' today contains per-connection state, however there's only a single global instance of that type. In order to support multiple connections, we must have one such object per connection. Thus this patch eliminates the 'remote_state' global in favor of having a remote_state instance per remote_target instance. The get_remote_state free function is eliminated as well, by making it a remote_target method instead. The patch then fixes the fallout by making all free functions that refer to get_remote_state() directly or indirectly be methods of remote_target too. Likewise, remote-fileio.c and remote-notif.c routines are parameterized with a remote_target pointer too, so they can call into the right remote_target instance. References to the global 'get_remote_state ()->remote_desc' to tell whether the remote target is open (!= nullptr) must be replaced with something else: - Command implementations use a new get_current_remote_target free function. - remote_target::open_1 checks the exception type instead. Finally, remote_target and extended_remote_target are made heap-allocated targets. As with the earlier core target patches, it still won't be possible to have more than one remote_target instance in practice, but this puts us closer. gdb/ChangeLog: 2018-05-22 Pedro Alves <palves@redhat.com> * remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror) (remote_fileio_badfd, remote_fileio_return_errno) (remote_fileio_return_success, remote_fileio_func_open) (remote_fileio_func_open, remote_fileio_func_close) (remote_fileio_func_read, remote_fileio_func_write) (remote_fileio_func_lseek, remote_fileio_func_rename) (remote_fileio_func_unlink, remote_fileio_func_stat) (remote_fileio_func_fstat, remote_fileio_func_gettimeofday) (remote_fileio_func_isatty, remote_fileio_func_system): Add remote_target parameter. (remote_fio_func_map) <func>: Add remote_target parameter. (do_remote_fileio_request, remote_fileio_request): * remote-fileio.h (remote_fileio_request): * remote-notif.c (remote_notif_ack, remote_notif_parse, ): Add remote_target parameter. (remote_notif_process, handle_notification): Adjust to pass down the remote. (remote_notif_state_allocate): Add remote_target parameter. Save it. * remote-notif.h (struct remote_target): Forward declare. (struct notif_client) <parse, ack, can_get_pending_events>: Add remote_target parameter. (struct remote_notif_state) <remote>: New field. (remote_notif_ack, remote_notif_parse): Add remote_target parameter. (remote_notif_state_allocate, remote_notif_state_allocate): Add remote_target parameter. * remote.c (OPAQUETHREADBYTES, threadref, gdb_ext_thread_info) (threads_listing_context, rmt_thread_action, protocol_feature) (packet_reg, stop_reply, stop_reply_p, enum packet_support) (packet_result, struct threads_listing_context, remote_state): Move definitions and declarations higher up. (remote_target) <~remote_target>: Declare. (remote_download_command_source, remote_file_put, remote_file_get) (remote_file_delete, remote_hostio_pread, remote_hostio_pwrite) (remote_hostio_pread_vFile, remote_hostio_send_command) (remote_hostio_set_filesystem, remote_hostio_open) (remote_hostio_close, remote_hostio_unlink, remote_state) (get_remote_state, get_remote_packet_size, get_memory_packet_size) (get_memory_write_packet_size, get_memory_read_packet_size) (append_pending_thread_resumptions, remote_detach_1) (append_resumption, remote_resume_with_vcont) (add_current_inferior_and_thread, wait_ns, wait_as) (process_stop_reply, remote_notice_new_inferior) (process_initial_stop_replies, remote_add_thread) (btrace_sync_conf, remote_btrace_maybe_reopen) (remove_new_fork_children, kill_new_fork_children) (discard_pending_stop_replies, stop_reply_queue_length) (check_pending_events_prevent_wildcard_vcont) (discard_pending_stop_replies_in_queue, stop_reply) (remote_notif_remove_queued_reply, stop_reply *queued_stop_reply) (peek_stop_reply, remote_parse_stop_reply, remote_stop_ns) (remote_interrupt_as, remote_interrupt_ns) (remote_get_noisy_reply, remote_query_attached) (remote_add_inferior, remote_current_thread, get_current_thread) (set_thread, set_general_thread, set_continue_thread) (set_general_process, write_ptid) (remote_unpack_thread_info_response, remote_get_threadinfo) (parse_threadlist_response, remote_get_threadlist) (remote_threadlist_iterator, remote_get_threads_with_ql) (remote_get_threads_with_qxfer) (remote_get_threads_with_qthreadinfo, extended_remote_restart) (get_offsets, remote_check_symbols, remote_supported_packet) (remote_query_supported, remote_packet_size) (remote_serial_quit_handler, remote_detach_pid) (remote_vcont_probe, remote_resume_with_hc) (send_interrupt_sequence, interrupt_query) (remote_notif_get_pending_events, fetch_register_using_p) (send_g_packet, process_g_packet, fetch_registers_using_g) (store_register_using_P, store_registers_using_G) (set_remote_traceframe, check_binary_download) (remote_write_bytes_aux, remote_write_bytes, remote_read_bytes_1) (remote_xfer_live_readonly_partial, remote_read_bytes) (remote_send_printf, remote_flash_write, readchar) (remote_serial_write, putpkt, putpkt_binary, skip_frame) (read_frame, getpkt, getpkt_or_notif_sane_1, getpkt_sane) (getpkt_or_notif_sane, remote_vkill, remote_kill_k) (extended_remote_disable_randomization, extended_remote_run) (send_environment_packet, extended_remote_environment_support) (extended_remote_set_inferior_cwd, remote_write_qxfer) (remote_read_qxfer, push_stop_reply, vcont_r_supported) (packet_command): Now methods of ... (remote_target): ... this class. (m_remote_state) <remote_target>: New field. (struct remote_state) <stop_reply_queue, remote_async_inferior_event_token, wait_forever_enabled_p>: New fields. (remote_state::remote_state): Allocate stop_reply_queue. (remote_state): Delete global. (get_remote_state_raw): Delete. (remote_target::get_remote_state): Allocate m_remote_state on demand. (get_current_remote_target): New. (remote_ops, extended_remote_ops): Delete. (wait_forever_enabled_p, remote_async_inferior_event_token): Delete, moved to struct remote_state. (remote_target::close): Delete self. Destruction bits split to ... (remote_target::~remote_target): ... this. (show_memory_packet_size): Adjust to use get_current_remote_target. (struct protocol_feature) <func>: Add remote_target parameter. All callers adjusted. (curr_quit_handler_target): New. (remote_serial_quit_handler): Reimplement. (remote_target::open_1): Adjust to use get_current_remote_target. Heap-allocate remote_target/extended_remote_target instances. (vcont_builder::vcont_builder): Add remote_target parameter, and save it in m_remote. All callers adjusted. (vcont_builder::m_remote): New field. (vcont_builder::restart, vcont_builder::flush) (vcont_builder::push_action): Use it. (remote_target::commit_resume): Use it. (struct queue_iter_param) <remote>: New field. (remote_target::remove_new_fork_children): Fill in 'remote' field. (check_pending_event_prevents_wildcard_vcont_callback_data): New. (check_pending_event_prevents_wildcard_vcont_callback) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::discard_pending_stop_replies) (remote_target::discard_pending_stop_replies_in_queue) (remote_target::remote_notif_remove_queued_reply): Fill in 'remote' field. (remote_notif_get_pending_events): New. (remote_target::readchar, remote_target::remote_serial_write): Save/restore curr_quit_handler_target. (putpkt): New. (kill_new_fork_children): Fill in 'remote' field. (packet_command): Use get_current_remote_target, defer to remote_target method of same name. (scoped_remote_fd::scoped_remote_fd): Add 'remote_target' parameter, and save it in m_remote. All callers adjusted. (scoped_remote_fd::release): Use m_remote. (scoped_remote_fd::m_remote): New field. (remote_file_put, remote_file_get, remote_file_delete): Use get_current_remote_target, defer to remote_target method of same name. (remote_btrace_reset): Add remote_state paremeter. Update all callers. (remote_async_inferior_event_handler). Pass down 'data'. (remote_new_objfile): Use get_current_remote_target. (remote_target::vcont_r_supported): New. (set_range_stepping): Use get_current_remote_target and remote_target::vcont_r_supported. (_initialize_remote): Don't allocate 'remote_state' and 'stop_reply_queue' globals. * remote.h (struct remote_target): Forward declare. (getpkt, putpkt, remote_notif_get_pending_events): Add 'remote_target' parameter.
2018-05-22 19:22:11 +02:00
extern void remote_notif_get_pending_events (remote_target *remote,
struct notif_client *np);
1999-09-22 05:28:34 +02:00
#endif