mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-02 04:27:46 +08:00
ChangeLog:
* remote.h (remote_filename_p, remote_bfd_open): Add prototypes. * remote.c (remote_bfd_iovec_open, remote_bfd_iovec_close, remote_bfd_iovec_pread, remote_bfd_iovec_stat, remote_filename_p, remote_bfd_open): New functions. (remote_hostio_send_command): Fail safely if remote connection is not set up. * solist.h (solib_open): Remove prototype. (solib_bfd_open): Add prototype. * solib.c: Include "remote.h". (solib_open): Remove, replace by ... (solib_bfd_open): ... this new function. Handle remote BFDs. (solib_map_sections): Replace solib_open by solib_bfd_open. * solib-frv.c: Include "exceptions.h". (enable_break2): Replace solib_open by solib_bfd_open. * solib-svr4.c: Include "exceptions.h". (enable_break): Replace solib_open by solib_bfd_open. * symfile.c: Include "remote.h". (build_id_verify): Handle remote BFDs. (separate_debug_file_exists): Use BFD to access file. Handle remote BFDs. (symfile_bfd_open): Handle remote BFDs. (reread_symbols): Handle remote BFDs. * NEWS: Mention "remote:" argument prefix to "set sysroot". doc/ChangeLog: * gdb.texinfo (Commands to Specify Files): Document "remote:" argument prefix to "set sysroot".
This commit is contained in:
94
gdb/remote.c
94
gdb/remote.c
@ -6668,7 +6668,8 @@ remote_hostio_send_command (int command_bytes, int which_packet,
|
||||
int ret, bytes_read;
|
||||
char *attachment_tmp;
|
||||
|
||||
if (remote_protocol_packets[which_packet].support == PACKET_DISABLE)
|
||||
if (!remote_desc
|
||||
|| remote_protocol_packets[which_packet].support == PACKET_DISABLE)
|
||||
{
|
||||
*remote_errno = FILEIO_ENOSYS;
|
||||
return -1;
|
||||
@ -6932,6 +6933,97 @@ remote_hostio_close_cleanup (void *opaque)
|
||||
remote_hostio_close (fd, &remote_errno);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
remote_bfd_iovec_open (struct bfd *abfd, void *open_closure)
|
||||
{
|
||||
const char *filename = bfd_get_filename (abfd);
|
||||
int fd, remote_errno;
|
||||
int *stream;
|
||||
|
||||
gdb_assert (remote_filename_p (filename));
|
||||
|
||||
fd = remote_hostio_open (filename + 7, FILEIO_O_RDONLY, 0, &remote_errno);
|
||||
if (fd == -1)
|
||||
{
|
||||
errno = remote_fileio_errno_to_host (remote_errno);
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stream = xmalloc (sizeof (int));
|
||||
*stream = fd;
|
||||
return stream;
|
||||
}
|
||||
|
||||
static int
|
||||
remote_bfd_iovec_close (struct bfd *abfd, void *stream)
|
||||
{
|
||||
int fd = *(int *)stream;
|
||||
int remote_errno;
|
||||
|
||||
xfree (stream);
|
||||
|
||||
/* Ignore errors on close; these may happen if the remote
|
||||
connection was already torn down. */
|
||||
remote_hostio_close (fd, &remote_errno);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static file_ptr
|
||||
remote_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
|
||||
file_ptr nbytes, file_ptr offset)
|
||||
{
|
||||
int fd = *(int *)stream;
|
||||
int remote_errno;
|
||||
file_ptr pos, bytes;
|
||||
|
||||
pos = 0;
|
||||
while (nbytes > pos)
|
||||
{
|
||||
bytes = remote_hostio_pread (fd, (char *)buf + pos, nbytes - pos,
|
||||
offset + pos, &remote_errno);
|
||||
if (bytes == 0)
|
||||
/* Success, but no bytes, means end-of-file. */
|
||||
break;
|
||||
if (bytes == -1)
|
||||
{
|
||||
errno = remote_fileio_errno_to_host (remote_errno);
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos += bytes;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
remote_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
|
||||
{
|
||||
/* FIXME: We should probably implement remote_hostio_stat. */
|
||||
sb->st_size = INT_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
remote_filename_p (const char *filename)
|
||||
{
|
||||
return strncmp (filename, "remote:", 7) == 0;
|
||||
}
|
||||
|
||||
bfd *
|
||||
remote_bfd_open (const char *remote_file, const char *target)
|
||||
{
|
||||
return bfd_openr_iovec (remote_file, target,
|
||||
remote_bfd_iovec_open, NULL,
|
||||
remote_bfd_iovec_pread,
|
||||
remote_bfd_iovec_close,
|
||||
remote_bfd_iovec_stat);
|
||||
}
|
||||
|
||||
void
|
||||
remote_file_put (const char *local_file, const char *remote_file, int from_tty)
|
||||
{
|
||||
|
Reference in New Issue
Block a user