forked from Imagelibrary/binutils-gdb
Implement multiple-filesystem support for remote targets
This commit allows GDB to access executables and shared libraries on remote targets where the remote stub does not share a common filesystem with the inferior(s). A new packet "vFile:setfs" is added to the remote protocol and the three remote hostio functions with filename arguments are modified to send "vFile:setfs" packets as necessary. gdb/ChangeLog: * remote.c (struct remote_state) <fs_pid>: New field. (new_remote_state): Initialize the above. (PACKET_vFile_setfs): New enum value. (remote_hostio_set_filesystem): New function. (remote_hostio_open): Call the above. (remote_hostio_unlink): Likewise. (remote_hostio_readlink): Likewise. (_initialize_remote): Register new "set/show remote hostio-setfs-packet" command. * NEWS: Announce new vFile:setfs packet. gdb/doc/ChangeLog: * gdb.texinfo (Remote Configuration): Document the "set/show remote hostio-setfs-packet" command. (Host I/O Packets): Document the vFile:setfs packet.
This commit is contained in:
@@ -1,3 +1,16 @@
|
|||||||
|
2015-06-10 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* remote.c (struct remote_state) <fs_pid>: New field.
|
||||||
|
(new_remote_state): Initialize the above.
|
||||||
|
(PACKET_vFile_setfs): New enum value.
|
||||||
|
(remote_hostio_set_filesystem): New function.
|
||||||
|
(remote_hostio_open): Call the above.
|
||||||
|
(remote_hostio_unlink): Likewise.
|
||||||
|
(remote_hostio_readlink): Likewise.
|
||||||
|
(_initialize_remote): Register new "set/show remote
|
||||||
|
hostio-setfs-packet" command.
|
||||||
|
* NEWS: Announce new vFile:setfs packet.
|
||||||
|
|
||||||
2015-06-10 Gary Benson <gbenson@redhat.com>
|
2015-06-10 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
* linux-nat.c (nat/linux-namespaces.h): New include.
|
* linux-nat.c (nat/linux-namespaces.h): New include.
|
||||||
|
|||||||
6
gdb/NEWS
6
gdb/NEWS
@@ -174,6 +174,12 @@ qXfer:exec-file:read
|
|||||||
Return the full absolute name of the file that was executed to
|
Return the full absolute name of the file that was executed to
|
||||||
create a process running on the remote system.
|
create a process running on the remote system.
|
||||||
|
|
||||||
|
vFile:setfs:
|
||||||
|
Select the filesystem on which vFile: operations with filename
|
||||||
|
arguments will operate. This is required for GDB to be able to
|
||||||
|
access files on remote targets where the remote stub does not
|
||||||
|
share a common filesystem with the inferior(s).
|
||||||
|
|
||||||
fork stop reason
|
fork stop reason
|
||||||
Indicates that a fork system call was executed.
|
Indicates that a fork system call was executed.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
2015-06-10 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* gdb.texinfo (Remote Configuration): Document the
|
||||||
|
"set/show remote hostio-setfs-packet" command.
|
||||||
|
(Host I/O Packets): Document the vFile:setfs packet.
|
||||||
|
|
||||||
2015-06-10 Gary Benson <gbenson@redhat.com>
|
2015-06-10 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
* gdb.texinfo (Debugging Output): Document the "set/show debug
|
* gdb.texinfo (Debugging Output): Document the "set/show debug
|
||||||
|
|||||||
@@ -19916,6 +19916,10 @@ are:
|
|||||||
@tab @code{vFile:fstat}
|
@tab @code{vFile:fstat}
|
||||||
@tab Host I/O
|
@tab Host I/O
|
||||||
|
|
||||||
|
@item @code{hostio-setfs-packet}
|
||||||
|
@tab @code{vFile:setfs}
|
||||||
|
@tab Host I/O
|
||||||
|
|
||||||
@item @code{noack-packet}
|
@item @code{noack-packet}
|
||||||
@tab @code{QStartNoAckMode}
|
@tab @code{QStartNoAckMode}
|
||||||
@tab Packet acknowledgment
|
@tab Packet acknowledgment
|
||||||
@@ -37742,6 +37746,20 @@ attachment (i.e.@: a trailing semicolon). The return value is the
|
|||||||
number of target bytes read; the binary attachment may be longer if
|
number of target bytes read; the binary attachment may be longer if
|
||||||
some characters were escaped.
|
some characters were escaped.
|
||||||
|
|
||||||
|
@item vFile:setfs: @var{pid}
|
||||||
|
Select the filesystem on which @code{vFile} operations with
|
||||||
|
@var{filename} arguments will operate. This is required for
|
||||||
|
@value{GDBN} to be able to access files on remote targets where
|
||||||
|
the remote stub does not share a common filesystem with the
|
||||||
|
inferior(s).
|
||||||
|
|
||||||
|
If @var{pid} is nonzero, select the filesystem as seen by process
|
||||||
|
@var{pid}. If @var{pid} is zero, select the filesystem as seen by
|
||||||
|
the remote stub. Return 0 on success, or -1 if an error occurs.
|
||||||
|
If @code{vFile:setfs:} indicates success, the selected filesystem
|
||||||
|
remains selected until the next successful @code{vFile:setfs:}
|
||||||
|
operation.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Interrupts
|
@node Interrupts
|
||||||
|
|||||||
57
gdb/remote.c
57
gdb/remote.c
@@ -373,6 +373,12 @@ struct remote_state
|
|||||||
|
|
||||||
/* The branch trace configuration. */
|
/* The branch trace configuration. */
|
||||||
struct btrace_config btrace_config;
|
struct btrace_config btrace_config;
|
||||||
|
|
||||||
|
/* The argument to the last "vFile:setfs:" packet we sent, used
|
||||||
|
to avoid sending repeated unnecessary "vFile:setfs:" packets.
|
||||||
|
Initialized to -1 to indicate that no "vFile:setfs:" packet
|
||||||
|
has yet been sent. */
|
||||||
|
int fs_pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Private data that we'll store in (struct thread_info)->private. */
|
/* Private data that we'll store in (struct thread_info)->private. */
|
||||||
@@ -415,6 +421,7 @@ new_remote_state (void)
|
|||||||
result->buf = xmalloc (result->buf_size);
|
result->buf = xmalloc (result->buf_size);
|
||||||
result->remote_traceframe_number = -1;
|
result->remote_traceframe_number = -1;
|
||||||
result->last_sent_signal = GDB_SIGNAL_0;
|
result->last_sent_signal = GDB_SIGNAL_0;
|
||||||
|
result->fs_pid = -1;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1249,6 +1256,7 @@ enum {
|
|||||||
PACKET_Z2,
|
PACKET_Z2,
|
||||||
PACKET_Z3,
|
PACKET_Z3,
|
||||||
PACKET_Z4,
|
PACKET_Z4,
|
||||||
|
PACKET_vFile_setfs,
|
||||||
PACKET_vFile_open,
|
PACKET_vFile_open,
|
||||||
PACKET_vFile_pread,
|
PACKET_vFile_pread,
|
||||||
PACKET_vFile_pwrite,
|
PACKET_vFile_pwrite,
|
||||||
@@ -10213,6 +10221,43 @@ remote_hostio_send_command (int command_bytes, int which_packet,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the filesystem remote_hostio functions that take FILENAME
|
||||||
|
arguments will use. Return 0 on success, or -1 if an error
|
||||||
|
occurs (and set *REMOTE_ERRNO). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
remote_hostio_set_filesystem (struct inferior *inf, int *remote_errno)
|
||||||
|
{
|
||||||
|
struct remote_state *rs = get_remote_state ();
|
||||||
|
int required_pid = (inf == NULL || inf->fake_pid_p) ? 0 : inf->pid;
|
||||||
|
char *p = rs->buf;
|
||||||
|
int left = get_remote_packet_size () - 1;
|
||||||
|
char arg[9];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (packet_support (PACKET_vFile_setfs) == PACKET_DISABLE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (rs->fs_pid != -1 && required_pid == rs->fs_pid)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
remote_buffer_add_string (&p, &left, "vFile:setfs:");
|
||||||
|
|
||||||
|
xsnprintf (arg, sizeof (arg), "%x", required_pid);
|
||||||
|
remote_buffer_add_string (&p, &left, arg);
|
||||||
|
|
||||||
|
ret = remote_hostio_send_command (p - rs->buf, PACKET_vFile_setfs,
|
||||||
|
remote_errno, NULL, NULL);
|
||||||
|
|
||||||
|
if (packet_support (PACKET_vFile_setfs) == PACKET_DISABLE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
|
rs->fs_pid = required_pid;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Implementation of to_fileio_open. */
|
/* Implementation of to_fileio_open. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -10224,6 +10269,9 @@ remote_hostio_open (struct target_ops *self,
|
|||||||
char *p = rs->buf;
|
char *p = rs->buf;
|
||||||
int left = get_remote_packet_size () - 1;
|
int left = get_remote_packet_size () - 1;
|
||||||
|
|
||||||
|
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
remote_buffer_add_string (&p, &left, "vFile:open:");
|
remote_buffer_add_string (&p, &left, "vFile:open:");
|
||||||
|
|
||||||
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
||||||
@@ -10333,6 +10381,9 @@ remote_hostio_unlink (struct target_ops *self,
|
|||||||
char *p = rs->buf;
|
char *p = rs->buf;
|
||||||
int left = get_remote_packet_size () - 1;
|
int left = get_remote_packet_size () - 1;
|
||||||
|
|
||||||
|
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
remote_buffer_add_string (&p, &left, "vFile:unlink:");
|
remote_buffer_add_string (&p, &left, "vFile:unlink:");
|
||||||
|
|
||||||
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
||||||
@@ -10357,6 +10408,9 @@ remote_hostio_readlink (struct target_ops *self,
|
|||||||
int read_len;
|
int read_len;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
|
if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
remote_buffer_add_string (&p, &left, "vFile:readlink:");
|
remote_buffer_add_string (&p, &left, "vFile:readlink:");
|
||||||
|
|
||||||
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
|
||||||
@@ -12711,6 +12765,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
|
|||||||
add_packet_config_cmd (&remote_protocol_packets[PACKET_qTStatus],
|
add_packet_config_cmd (&remote_protocol_packets[PACKET_qTStatus],
|
||||||
"qTStatus", "trace-status", 0);
|
"qTStatus", "trace-status", 0);
|
||||||
|
|
||||||
|
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_setfs],
|
||||||
|
"vFile:setfs", "hostio-setfs", 0);
|
||||||
|
|
||||||
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_open],
|
add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_open],
|
||||||
"vFile:open", "hostio-open", 0);
|
"vFile:open", "hostio-open", 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user