Convert "remote:" sysroots to "target:" and remove "remote:"
The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
This commit is contained in:
parent
f08e97fed1
commit
2938e6cf08
8 changed files with 80 additions and 165 deletions
107
gdb/remote.c
107
gdb/remote.c
|
@ -10180,113 +10180,6 @@ remote_hostio_close_cleanup (void *opaque)
|
|||
remote_hostio_close (find_target_at (process_stratum), 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 (find_target_at (process_stratum),
|
||||
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 (find_target_at (process_stratum), fd, &remote_errno);
|
||||
|
||||
/* Zero means success. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 (find_target_at (process_stratum),
|
||||
fd, (gdb_byte *) 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)
|
||||
{
|
||||
int fd = *(int *) stream;
|
||||
int remote_errno;
|
||||
int result;
|
||||
|
||||
result = remote_hostio_fstat (find_target_at (process_stratum),
|
||||
fd, sb, &remote_errno);
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
errno = remote_fileio_errno_to_host (remote_errno);
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
remote_filename_p (const char *filename)
|
||||
{
|
||||
return startswith (filename, REMOTE_SYSROOT_PREFIX);
|
||||
}
|
||||
|
||||
bfd *
|
||||
remote_bfd_open (const char *remote_file, const char *target)
|
||||
{
|
||||
bfd *abfd = gdb_bfd_openr_iovec (remote_file, target,
|
||||
remote_bfd_iovec_open, NULL,
|
||||
remote_bfd_iovec_pread,
|
||||
remote_bfd_iovec_close,
|
||||
remote_bfd_iovec_stat);
|
||||
|
||||
return abfd;
|
||||
}
|
||||
|
||||
void
|
||||
remote_file_put (const char *local_file, const char *remote_file, int from_tty)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue