From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 04/16] push remote_desc into struct remote_state
Date: Fri, 21 Jun 2013 17:25:00 -0000 [thread overview]
Message-ID: <1371835506-15691-5-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1371835506-15691-1-git-send-email-tromey@redhat.com>
This moves the "remote_desc" global into remote_state.
* remote.c (struct remote_state) <remote_desc>: New field.
(remote_desc): Remove.
(remote_threads_info, remote_threads_extra_info, remote_close)
(send_interrupt_sequence, remote_start_remote, remote_open_1)
(readchar, remote_xfer_partial, remote_rcmd, packet_command)
(remote_hostio_send_command, remote_file_put, remote_file_get)
(remote_file_delete, remote_can_async_p, remote_is_async_p)
(remote_async, remote_new_objfile, set_range_stepping): Update.
---
gdb/remote.c | 98 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 58 insertions(+), 40 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 7aa20f3..8d94eba 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -368,6 +368,11 @@ struct remote_state
/* Nonzero if the user has pressed Ctrl-C, but the target hasn't
responded to that. */
int ctrlc_pending_p;
+
+ /* Descriptor for I/O to remote machine. Initialize it to NULL so that
+ remote_open knows that we don't have a file open when the program
+ starts. */
+ struct serial *remote_desc;
};
/* Private data that we'll store in (struct thread_info)->private. */
@@ -844,11 +849,6 @@ show_remotebreak (struct ui_file *file, int from_tty,
{
}
-/* Descriptor for I/O to remote machine. Initialize it to NULL so that
- remote_open knows that we don't have a file open when the program
- starts. */
-static struct serial *remote_desc = NULL;
-
/* This variable sets the number of bits in an address that are to be
sent in a memory ("M" or "m") packet. Normally, after stripping
leading zeros, the entire address would be sent. This variable
@@ -2738,7 +2738,7 @@ remote_threads_info (struct target_ops *ops)
char *bufp;
ptid_t new_thread;
- if (remote_desc == 0) /* paranoia */
+ if (rs->remote_desc == 0) /* paranoia */
error (_("Command can only be used when connected to the remote target."));
#if defined(HAVE_LIBEXPAT)
@@ -2864,7 +2864,7 @@ remote_threads_extra_info (struct thread_info *tp)
static char display_buf[100]; /* arbitrary... */
int n = 0; /* position in display_buf */
- if (remote_desc == 0) /* paranoia */
+ if (rs->remote_desc == 0) /* paranoia */
internal_error (__FILE__, __LINE__,
_("remote_threads_extra_info"));
@@ -3041,15 +3041,17 @@ extended_remote_restart (void)
static void
remote_close (void)
{
- if (remote_desc == NULL)
+ struct remote_state *rs = get_remote_state ();
+
+ if (rs->remote_desc == NULL)
return; /* already closed */
/* Make sure we leave stdin registered in the event loop, and we
don't leave the async SIGINT signal handler installed. */
remote_terminal_ours ();
- serial_close (remote_desc);
- remote_desc = NULL;
+ serial_close (rs->remote_desc);
+ rs->remote_desc = NULL;
/* We don't have a connection to the remote stub anymore. Get rid
of all the inferiors and their threads we were controlling.
@@ -3250,13 +3252,15 @@ set_stop_requested_callback (struct thread_info *thread, void *data)
static void
send_interrupt_sequence (void)
{
+ struct remote_state *rs = get_remote_state ();
+
if (interrupt_sequence_mode == interrupt_sequence_control_c)
remote_serial_write ("\x03", 1);
else if (interrupt_sequence_mode == interrupt_sequence_break)
- serial_send_break (remote_desc);
+ serial_send_break (rs->remote_desc);
else if (interrupt_sequence_mode == interrupt_sequence_break_g)
{
- serial_send_break (remote_desc);
+ serial_send_break (rs->remote_desc);
remote_serial_write ("g", 1);
}
else
@@ -3373,7 +3377,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
send_interrupt_sequence ();
/* Ack any packet which the remote side has already sent. */
- serial_write (remote_desc, "+", 1);
+ serial_write (rs->remote_desc, "+", 1);
/* Signal other parts that we're going through the initial setup,
and so things may not be stable yet. */
@@ -4267,7 +4271,7 @@ remote_open_1 (char *name, int from_tty,
/* If we're connected to a running target, target_preopen will kill it.
Ask this question first, before target_preopen has a chance to kill
anything. */
- if (remote_desc != NULL && !have_inferiors ())
+ if (rs->remote_desc != NULL && !have_inferiors ())
{
if (from_tty
&& !query (_("Already connected to a remote target. Disconnect? ")))
@@ -4290,29 +4294,29 @@ remote_open_1 (char *name, int from_tty,
reopen_exec_file ();
reread_symbols ();
- remote_desc = remote_serial_open (name);
- if (!remote_desc)
+ rs->remote_desc = remote_serial_open (name);
+ if (!rs->remote_desc)
perror_with_name (name);
if (baud_rate != -1)
{
- if (serial_setbaudrate (remote_desc, baud_rate))
+ if (serial_setbaudrate (rs->remote_desc, baud_rate))
{
/* The requested speed could not be set. Error out to
top level after closing remote_desc. Take care to
set remote_desc to NULL to avoid closing remote_desc
more than once. */
- serial_close (remote_desc);
- remote_desc = NULL;
+ serial_close (rs->remote_desc);
+ rs->remote_desc = NULL;
perror_with_name (name);
}
}
- serial_raw (remote_desc);
+ serial_raw (rs->remote_desc);
/* If there is something sitting in the buffer we might take it as a
response to a command, which would be bad. */
- serial_flush_input (remote_desc);
+ serial_flush_input (rs->remote_desc);
if (from_tty)
{
@@ -4395,7 +4399,7 @@ remote_open_1 (char *name, int from_tty,
{
/* Pop the partially set up target - unless something else did
already before throwing the exception. */
- if (remote_desc != NULL)
+ if (rs->remote_desc != NULL)
remote_unpush_target ();
if (target_async_permitted)
wait_forever_enabled_p = 1;
@@ -7145,8 +7149,9 @@ static int
readchar (int timeout)
{
int ch;
+ struct remote_state *rs = get_remote_state ();
- ch = serial_readchar (remote_desc, timeout);
+ ch = serial_readchar (rs->remote_desc, timeout);
if (ch >= 0)
return ch;
@@ -7173,7 +7178,9 @@ readchar (int timeout)
static void
remote_serial_write (const char *str, int len)
{
- if (serial_write (remote_desc, str, len))
+ struct remote_state *rs = get_remote_state ();
+
+ if (serial_write (rs->remote_desc, str, len))
{
unpush_and_perror (_("Remote communication error. "
"Target disconnected."));
@@ -8902,7 +8909,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
case TARGET_OBJECT_OSDATA:
/* Should only get here if we're connected. */
- gdb_assert (remote_desc);
+ gdb_assert (rs->remote_desc);
return remote_read_qxfer
(ops, "osdata", annex, readbuf, offset, len,
&remote_protocol_packets[PACKET_qXfer_osdata]);
@@ -8945,7 +8952,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
len = get_remote_packet_size ();
/* Except for querying the minimum buffer size, target must be open. */
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("remote query is only available after target open"));
gdb_assert (annex != NULL);
@@ -9079,7 +9086,7 @@ remote_rcmd (char *command,
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("remote rcmd is only available after target open"));
/* Send a NULL command across as an empty command. */
@@ -9165,7 +9172,7 @@ packet_command (char *args, int from_tty)
{
struct remote_state *rs = get_remote_state ();
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("command can only be used with remote target"));
if (!args)
@@ -9705,7 +9712,7 @@ remote_hostio_send_command (int command_bytes, int which_packet,
int ret, bytes_read;
char *attachment_tmp;
- if (!remote_desc
+ if (!rs->remote_desc
|| remote_protocol_packets[which_packet].support == PACKET_DISABLE)
{
*remote_errno = FILEIO_ENOSYS;
@@ -10106,8 +10113,9 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
int bytes_in_buffer;
int saw_eof;
ULONGEST offset;
+ struct remote_state *rs = get_remote_state ();
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("command can only be used with remote target"));
file = gdb_fopen_cloexec (local_file, "rb");
@@ -10194,8 +10202,9 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
FILE *file;
gdb_byte *buffer;
ULONGEST offset;
+ struct remote_state *rs = get_remote_state ();
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("command can only be used with remote target"));
fd = remote_hostio_open (remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
@@ -10245,8 +10254,9 @@ void
remote_file_delete (const char *remote_file, int from_tty)
{
int retcode, remote_errno;
+ struct remote_state *rs = get_remote_state ();
- if (!remote_desc)
+ if (!rs->remote_desc)
error (_("command can only be used with remote target"));
retcode = remote_hostio_unlink (remote_file, &remote_errno);
@@ -11602,23 +11612,27 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
static int
remote_can_async_p (void)
{
+ struct remote_state *rs = get_remote_state ();
+
if (!target_async_permitted)
/* We only enable async when the user specifically asks for it. */
return 0;
/* We're async whenever the serial device is. */
- return serial_can_async_p (remote_desc);
+ return serial_can_async_p (rs->remote_desc);
}
static int
remote_is_async_p (void)
{
+ struct remote_state *rs = get_remote_state ();
+
if (!target_async_permitted)
/* We only enable async when the user specifically asks for it. */
return 0;
/* We're async whenever the serial device is. */
- return serial_is_async_p (remote_desc);
+ return serial_is_async_p (rs->remote_desc);
}
/* Pass the SERIAL event on and up to the client. One day this code
@@ -11648,14 +11662,16 @@ static void
remote_async (void (*callback) (enum inferior_event_type event_type,
void *context), void *context)
{
+ struct remote_state *rs = get_remote_state ();
+
if (callback != NULL)
{
- serial_async (remote_desc, remote_async_serial_handler, NULL);
+ serial_async (rs->remote_desc, remote_async_serial_handler, NULL);
async_client_callback = callback;
async_client_context = context;
}
else
- serial_async (remote_desc, NULL, NULL);
+ serial_async (rs->remote_desc, NULL, NULL);
}
static void
@@ -11705,7 +11721,9 @@ show_remote_cmd (char *args, int from_tty)
static void
remote_new_objfile (struct objfile *objfile)
{
- if (remote_desc != 0) /* Have a remote connection. */
+ struct remote_state *rs = get_remote_state ();
+
+ if (rs->remote_desc != 0) /* Have a remote connection. */
remote_check_symbols ();
}
@@ -11774,14 +11792,14 @@ static void
set_range_stepping (char *ignore_args, int from_tty,
struct cmd_list_element *c)
{
+ struct remote_state *rs = get_remote_state ();
+
/* Whene enabling, check whether range stepping is actually
supported by the target, and warn if not. */
if (use_range_stepping)
{
- if (remote_desc != NULL)
+ if (rs->remote_desc != NULL)
{
- struct remote_state *rs = get_remote_state ();
-
if (remote_protocol_packets[PACKET_vCont].support == PACKET_SUPPORT_UNKNOWN)
remote_vcont_probe (rs);
--
1.8.1.4
next prev parent reply other threads:[~2013-06-21 17:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 17:25 [PATCH 00/16] clean up remote.c state Tom Tromey
2013-06-21 17:25 ` [PATCH 07/16] push last_pass_packet into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 08/16] push last_program_signals_packet " Tom Tromey
2013-06-24 17:36 ` Pedro Alves
2013-06-27 20:13 ` Tom Tromey
2013-06-21 17:25 ` [PATCH 06/16] push remote_traceframe_number " Tom Tromey
2013-06-21 17:25 ` [PATCH 16/16] move some static thread state into remote_state Tom Tromey
2013-06-24 17:33 ` Pedro Alves
2013-06-27 20:21 ` Tom Tromey
2013-06-21 17:25 ` [PATCH 14/16] move async_client_callback and async_client_context " Tom Tromey
2013-06-24 17:32 ` Pedro Alves
2013-06-24 18:44 ` Tom Tromey
2013-06-24 19:03 ` Pedro Alves
2013-06-21 17:25 ` [PATCH 10/16] push last_sent_step into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 09/16] push last_sent_signal " Tom Tromey
2013-06-21 17:25 ` [PATCH 01/16] use the libiberty crc code Tom Tromey
2013-06-24 17:24 ` Pedro Alves
2013-06-27 20:12 ` Tom Tromey
2013-06-21 17:25 ` Tom Tromey [this message]
2013-06-24 17:25 ` [PATCH 04/16] push remote_desc into struct remote_state Pedro Alves
2013-06-27 20:29 ` Tom Tromey
2013-06-28 16:43 ` [PATCH] Make file transfer commands work with all (native) targets. (was: Re: [PATCH 04/16] push remote_desc into struct remote_state) Pedro Alves
2013-06-28 17:40 ` [PATCH] Make file transfer commands work with all (native) targets Tom Tromey
2013-06-28 17:46 ` [PATCH] Make file transfer commands work with all (native) targets. (was: Re: [PATCH 04/16] push remote_desc into struct remote_state) Eli Zaretskii
2013-06-28 19:05 ` [PATCH] Make file transfer commands work with all (native) targets Pedro Alves
2013-06-28 19:35 ` Eli Zaretskii
2013-07-01 14:28 ` Tom Tromey
2013-07-01 16:34 ` Pedro Alves
2013-07-01 16:41 ` Eli Zaretskii
2013-07-01 16:44 ` Pedro Alves
2013-06-21 17:25 ` [PATCH 15/16] move remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 13/16] move sizeof_pkt into remote_trace_find Tom Tromey
2013-06-24 1:45 ` Yao Qi
2013-06-24 14:54 ` Tom Tromey
2013-06-24 17:32 ` Pedro Alves
2013-06-21 17:25 ` [PATCH 12/16] move use_threadinfo_query and use_threadextra_query into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 11/16] move some statics from remote_read_qxfer " Tom Tromey
2013-06-24 17:25 ` Pedro Alves
2013-06-21 17:25 ` [PATCH 05/16] push general_thread and continue_thread " Tom Tromey
2013-06-21 17:25 ` [PATCH 03/16] Add new_remote_state Tom Tromey
2013-06-21 17:30 ` [PATCH 02/16] make remote_protocol_features "const" Tom Tromey
2013-06-24 18:35 ` [PATCH 00/16] clean up remote.c state Pedro Alves
2013-07-05 3:07 ` Yao Qi
2013-07-05 14:27 ` Pedro Alves
2013-08-14 17:53 ` Tom Tromey
2013-06-28 17:40 [PATCH v2 00/16] Tom Tromey
2013-06-28 17:40 ` [PATCH 04/16] push remote_desc into struct remote_state Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371835506-15691-5-git-send-email-tromey@redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox