From patchwork Fri Mar 20 16:48:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 5737 Received: (qmail 122164 invoked by alias); 20 Mar 2015 17:32:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 122150 invoked by uid 89); 20 Mar 2015 17:32:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 20 Mar 2015 17:32:12 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id AE2FFC408A for ; Fri, 20 Mar 2015 17:32:11 +0000 (UTC) Received: from blade.nx (ovpn-116-93.ams2.redhat.com [10.36.116.93]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2KGmAxq020574 for ; Fri, 20 Mar 2015 12:48:11 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 14D50264108 for ; Fri, 20 Mar 2015 16:48:10 +0000 (GMT) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 2/9] Introduce target_filesystem_is_local Date: Fri, 20 Mar 2015 16:48:00 +0000 Message-Id: <1426870087-32654-3-git-send-email-gbenson@redhat.com> In-Reply-To: <1426870087-32654-1-git-send-email-gbenson@redhat.com> References: <1426870087-32654-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit introduces a new target method target_filesystem_is_local which can be used to determine whether or not the filesystem accessed by the target_fileio_* methods is the local filesystem. gdb/ChangeLog: * target.h (struct target_ops) : New field. (target_filesystem_is_local): New definition. * target-delegates.c: Regenerate. * remote.c (remote_filesystem_is_local): New function. (init_remote_ops): Initialize to_filesystem_is_local. --- gdb/ChangeLog | 9 +++++++++ gdb/remote.c | 10 ++++++++++ gdb/target-delegates.c | 31 +++++++++++++++++++++++++++++++ gdb/target.h | 11 +++++++++++ 4 files changed, 61 insertions(+), 0 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 9c6d2e5..c0fab92 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9890,6 +9890,15 @@ remote_hostio_send_command (int command_bytes, int which_packet, return ret; } +/* Return nonzero if the filesystem accessed by the target_fileio_* + methods is the local filesystem, zero otherwise. */ + +static int +remote_filesystem_is_local (struct target_ops *self) +{ + return 0; +} + /* Open FILENAME on the remote target, using FLAGS and MODE. Return a remote file descriptor, or -1 if an error occurs (and set *REMOTE_ERRNO). */ @@ -11841,6 +11850,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_supports_multi_process = remote_supports_multi_process; remote_ops.to_supports_disable_randomization = remote_supports_disable_randomization; + remote_ops.to_filesystem_is_local = remote_filesystem_is_local; remote_ops.to_fileio_open = remote_hostio_open; remote_ops.to_fileio_pwrite = remote_hostio_pwrite; remote_ops.to_fileio_pread = remote_hostio_pread; diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 0c1309a..20ad257 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -2345,6 +2345,33 @@ debug_thread_address_space (struct target_ops *self, ptid_t arg1) return result; } +static int +delegate_filesystem_is_local (struct target_ops *self) +{ + self = self->beneath; + return self->to_filesystem_is_local (self); +} + +static int +tdefault_filesystem_is_local (struct target_ops *self) +{ + return 1; +} + +static int +debug_filesystem_is_local (struct target_ops *self) +{ + int result; + fprintf_unfiltered (gdb_stdlog, "-> %s->to_filesystem_is_local (...)\n", debug_target.to_shortname); + result = debug_target.to_filesystem_is_local (&debug_target); + fprintf_unfiltered (gdb_stdlog, "<- %s->to_filesystem_is_local (", debug_target.to_shortname); + target_debug_print_struct_target_ops_p (&debug_target); + fputs_unfiltered (") = ", gdb_stdlog); + target_debug_print_int (result); + fputs_unfiltered ("\n", gdb_stdlog); + return result; +} + static void delegate_trace_init (struct target_ops *self) { @@ -4024,6 +4051,8 @@ install_delegators (struct target_ops *ops) ops->to_thread_architecture = delegate_thread_architecture; if (ops->to_thread_address_space == NULL) ops->to_thread_address_space = delegate_thread_address_space; + if (ops->to_filesystem_is_local == NULL) + ops->to_filesystem_is_local = delegate_filesystem_is_local; if (ops->to_trace_init == NULL) ops->to_trace_init = delegate_trace_init; if (ops->to_download_tracepoint == NULL) @@ -4227,6 +4256,7 @@ install_dummy_methods (struct target_ops *ops) ops->to_can_run_breakpoint_commands = tdefault_can_run_breakpoint_commands; ops->to_thread_architecture = default_thread_architecture; ops->to_thread_address_space = default_thread_address_space; + ops->to_filesystem_is_local = tdefault_filesystem_is_local; ops->to_trace_init = tdefault_trace_init; ops->to_download_tracepoint = tdefault_download_tracepoint; ops->to_can_download_tracepoint = tdefault_can_download_tracepoint; @@ -4374,6 +4404,7 @@ init_debug_target (struct target_ops *ops) ops->to_can_run_breakpoint_commands = debug_can_run_breakpoint_commands; ops->to_thread_architecture = debug_thread_architecture; ops->to_thread_address_space = debug_thread_address_space; + ops->to_filesystem_is_local = debug_filesystem_is_local; ops->to_trace_init = debug_trace_init; ops->to_download_tracepoint = debug_download_tracepoint; ops->to_can_download_tracepoint = debug_can_download_tracepoint; diff --git a/gdb/target.h b/gdb/target.h index d2bd152..925abeb 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -825,6 +825,12 @@ struct target_ops /* Target file operations. */ + /* Return nonzero if the filesystem accessed by the + target_fileio_* methods is the local filesystem, + zero otherwise. */ + int (*to_filesystem_is_local) (struct target_ops *) + TARGET_DEFAULT_RETURN (1); + /* Open FILENAME on the target, using FLAGS and MODE. Return a target file descriptor, or -1 if an error occurs (and set *TARGET_ERRNO). */ @@ -1920,6 +1926,11 @@ extern int target_search_memory (CORE_ADDR start_addr, /* Target file operations. */ +/* Nonzero if the filesystem accessed by the target_fileio_* + methods is the local filesystem, zero otherwise. */ +#define target_filesystem_is_local \ + current_target.to_filesystem_is_local (¤t_target) + /* Open FILENAME on the target, using FLAGS and MODE. Return a target file descriptor, or -1 if an error occurs (and set *TARGET_ERRNO). */