From c9b7b80460e47ea4554960af6814de71b3e427cb Mon Sep 17 00:00:00 2001 From: Tankut Baris Aktemur Date: Mon, 17 Feb 2020 16:12:02 +0100 Subject: gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur Turn process_stratum_target's multifs_open, multifs_readlink, multifs_unlink ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Also add 'supports_multifs'. * target.cc: Include "fcntl.h", "unistd.h", "sys/types.h", and "sys/stat.h". (process_target::supports_multifs): Define. (process_target::multifs_open): Define. (process_target::multifs_readlink): Define. (process_target::multifs_unlink): Define. Update the derived classes and callers below. * hostio.cc (handle_setfs): Update. (handle_open): Update. (handle_unlink): Update. (handle_readlink): Update. * linux-low.cc (linux_target_ops): Update. (linux_process_target::supports_multifs): Define. (linux_process_target::multifs_open): Define. (linux_process_target::multifs_readlink): Define. (linux_process_target::multifs_unlink): Define. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. * nto-low.cc (nto_target_ops): Update. * win32-low.cc (win32_target_ops): Update. --- gdbserver/hostio.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'gdbserver/hostio.cc') diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc index a3b32cd..6223b24 100644 --- a/gdbserver/hostio.cc +++ b/gdbserver/hostio.cc @@ -272,9 +272,7 @@ handle_setfs (char *own_buf) then there's no point in GDB sending "vFile:setfs:" packets. We reply with an empty packet (i.e. we pretend we don't understand "vFile:setfs:") and that should stop GDB sending any more. */ - if (the_target->multifs_open == NULL - && the_target->multifs_unlink == NULL - && the_target->multifs_readlink == NULL) + if (!the_target->pt->supports_multifs ()) { own_buf[0] = '\0'; return; @@ -321,9 +319,9 @@ handle_open (char *own_buf) /* We do not need to convert MODE, since the fileio protocol uses the standard values. */ - if (hostio_fs_pid != 0 && the_target->multifs_open != NULL) - fd = the_target->multifs_open (hostio_fs_pid, filename, - flags, mode); + if (hostio_fs_pid != 0) + fd = the_target->pt->multifs_open (hostio_fs_pid, filename, + flags, mode); else fd = open (filename, flags, mode); @@ -541,8 +539,8 @@ handle_unlink (char *own_buf) return; } - if (hostio_fs_pid != 0 && the_target->multifs_unlink != NULL) - ret = the_target->multifs_unlink (hostio_fs_pid, filename); + if (hostio_fs_pid != 0) + ret = the_target->pt->multifs_unlink (hostio_fs_pid, filename); else ret = unlink (filename); @@ -571,10 +569,10 @@ handle_readlink (char *own_buf, int *new_packet_len) return; } - if (hostio_fs_pid != 0 && the_target->multifs_readlink != NULL) - ret = the_target->multifs_readlink (hostio_fs_pid, filename, - linkname, - sizeof (linkname) - 1); + if (hostio_fs_pid != 0) + ret = the_target->pt->multifs_readlink (hostio_fs_pid, filename, + linkname, + sizeof (linkname) - 1); else ret = readlink (filename, linkname, sizeof (linkname) - 1); -- cgit v1.1