diff options
author | Gary Benson <gbenson@redhat.com> | 2015-04-02 13:38:28 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-04-02 13:38:28 +0100 |
commit | 4bd7dc42558fcf53bb0c783f852f03dcac38866f (patch) | |
tree | b88717681fa2110b29de6ae589a3a489a4f96e07 | |
parent | 9b15c1f0419ae693fdcf6cca399e9a916e14c48e (diff) | |
download | gdb-4bd7dc42558fcf53bb0c783f852f03dcac38866f.zip gdb-4bd7dc42558fcf53bb0c783f852f03dcac38866f.tar.gz gdb-4bd7dc42558fcf53bb0c783f852f03dcac38866f.tar.bz2 |
Introduce target_filesystem_is_local
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) <to_filesystem_is_local>:
New field.
(target_filesystem_is_local): New macro.
* target-delegates.c: Regenerate.
* remote.c (remote_filesystem_is_local): New function.
(init_remote_ops): Initialize to_filesystem_is_local.
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/remote.c | 10 | ||||
-rw-r--r-- | gdb/target-delegates.c | 31 | ||||
-rw-r--r-- | gdb/target.h | 11 |
4 files changed, 61 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 22b9289..697aeb1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2015-04-02 Gary Benson <gbenson@redhat.com> + * target.h (struct target_ops) <to_filesystem_is_local>: + New field. + (target_filesystem_is_local): New macro. + * target-delegates.c: Regenerate. + * remote.c (remote_filesystem_is_local): New function. + (init_remote_ops): Initialize to_filesystem_is_local. + +2015-04-02 Gary Benson <gbenson@redhat.com> + * target.h (struct target_ops) <to_fileio_fstat>: New field. (target_fileio_fstat): New declaration. * target.c (target_fileio_fstat): New function. diff --git a/gdb/remote.c b/gdb/remote.c index e0c831e..43f3165 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9863,6 +9863,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). */ @@ -11814,6 +11823,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 b29abaf..36eacbf 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -2343,6 +2343,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) { @@ -4022,6 +4049,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) @@ -4225,6 +4254,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; @@ -4372,6 +4402,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 c4440ce..f57e431 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). */ @@ -1921,6 +1927,11 @@ extern int target_search_memory (CORE_ADDR start_addr, /* Target file operations. */ +/* Return 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). */ |