This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC v2 12/38] Add target_ops argument to to_can_execute_reverse
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Thu, 6 Feb 2014 13:55:10 -0700
- Subject: [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse
- Authentication-results: sourceware.org; auth=none
- References: <1391720136-2121-1-git-send-email-tromey at redhat dot com>
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_can_execute_reverse>: Add
argument.
(target_can_execute_reverse): Add argument.
* remote.c (remote_can_execute_reverse): Add 'self' argument.
* record-full.c (record_full_can_execute_reverse): Add 'self'
argument.
* record-btrace.c (record_btrace_can_execute_reverse): Add 'self'
argument.
Add target_ops argument to to_execution_direction
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_execution_direction>: Add
argument.
(target_execution_direction): Add argument.
* target.c (default_execution_direction): Add 'self' argument.
* record-full.c (record_full_execution_direction): Add 'self'
argument.
Add target_ops argument to to_supports_multi_process
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_supports_multi_process>: Add
argument.
(target_supports_multi_process): Add argument.
* target.c (update_current_target): Update.
* remote.c (remote_supports_multi_process): Add 'self' argument.
* linux-nat.c (linux_nat_supports_multi_process): Add 'self'
argument.
* darwin-nat.c (darwin_supports_multi_process): Add 'self'
argument.
Add target_ops argument to to_supports_enable_disable_tracepoint
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops)
<to_supports_enable_disable_tracepoint>: Add argument.
(target_supports_enable_disable_tracepoint): Add argument.
* target.c (update_current_target): Update.
* remote.c (remote_supports_enable_disable_tracepoint): Add 'self'
argument.
Add target_ops argument to to_supports_disable_randomization
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops)
<to_supports_disable_randomization>: Add argument.
* target.c (find_default_supports_disable_randomization): Add
argument.
(target_supports_disable_randomization): Add argument.
(find_default_supports_disable_randomization): Add 'self'
argument.
* remote.c (extended_remote_supports_disable_randomization): Add
'self' argument.
(remote_supports_disable_randomization): Add 'self' argument.
(extended_remote_create_inferior): Update.
* linux-nat.c (linux_nat_supports_disable_randomization): Add
'self' argument.
Add target_ops argument to to_supports_string_tracing
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_supports_string_tracing>: Add
argument.
(target_supports_string_tracing): Add argument.
* target.c (update_current_target): Update.
* remote.c (remote_supports_string_tracing): Add 'self' argument.
Add target_ops argument to to_supports_evaluation_of_breakpoint_conditions
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops)
<to_supports_evaluation_of_breakpoint_conditions>: Add argument.
(target_supports_evaluation_of_breakpoint_conditions): Add
argument.
* target.c (update_current_target): Update.
* remote.c (remote_supports_cond_breakpoints): Add 'self'
argument.
(remote_insert_breakpoint): Add 'self' argument.
(remote_insert_hw_breakpoint): Add 'self' argument.
(remote_supports_cond_breakpoints): Add 'self' argument.
Add target_ops argument to to_can_run_breakpoint_commands
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_can_run_breakpoint_commands>:
Add argument.
(target_can_run_breakpoint_commands): Add argument.
* target.c (update_current_target): Update.
* remote.c (remote_can_run_breakpoint_commands): Add 'self'
argument.
(remote_insert_breakpoint): Add 'self' argument.
(remote_insert_hw_breakpoint): Add 'self' argument.
(remote_can_run_breakpoint_commands): Add 'self' argument.
Add target_ops argument to to_fileio_open
2014-02-06 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_fileio_open>: Add argument.
* target.c (target_fileio_open): Add argument.
* remote.c (remote_hostio_open): Add 'self' argument.
(remote_bfd_iovec_open): Add 'self' argument.
(remote_file_put): Add 'self' argument.
(remote_file_get): Add 'self' argument.
* inf-child.c (inf_child_fileio_open): Add 'self' argument.
---
gdb/ChangeLog | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/darwin-nat.c | 2 +-
gdb/inf-child.c | 3 +-
gdb/linux-nat.c | 4 +--
gdb/record-btrace.c | 2 +-
gdb/record-full.c | 4 +--
gdb/remote.c | 42 ++++++++++++----------
gdb/target.c | 20 +++++------
gdb/target.h | 33 ++++++++---------
9 files changed, 158 insertions(+), 52 deletions(-)
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 2a716bc..e1bfe88 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -2059,7 +2059,7 @@ darwin_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
}
static int
-darwin_supports_multi_process (void)
+darwin_supports_multi_process (struct target_ops *self)
{
return 1;
}
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index e047636..cd2aee6 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -231,7 +231,8 @@ inf_child_errno_to_fileio_error (int errnum)
target file descriptor, or -1 if an error occurs (and set
*TARGET_ERRNO). */
static int
-inf_child_fileio_open (const char *filename, int flags, int mode,
+inf_child_fileio_open (struct target_ops *self,
+ const char *filename, int flags, int mode,
int *target_errno)
{
int nat_flags;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2181648..a1dc8fa 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4529,13 +4529,13 @@ linux_nat_supports_non_stop (struct target_ops *self)
int linux_multi_process = 1;
static int
-linux_nat_supports_multi_process (void)
+linux_nat_supports_multi_process (struct target_ops *self)
{
return linux_multi_process;
}
static int
-linux_nat_supports_disable_randomization (void)
+linux_nat_supports_disable_randomization (struct target_ops *self)
{
#ifdef HAVE_PERSONALITY
return 1;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 7d43330..94ff83d 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1712,7 +1712,7 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
/* The to_can_execute_reverse method of target record-btrace. */
static int
-record_btrace_can_execute_reverse (void)
+record_btrace_can_execute_reverse (struct target_ops *self)
{
return 1;
}
diff --git a/gdb/record-full.c b/gdb/record-full.c
index a825f5a..755c815 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1693,7 +1693,7 @@ record_full_remove_breakpoint (struct target_ops *ops,
/* "to_can_execute_reverse" method for process record target. */
static int
-record_full_can_execute_reverse (void)
+record_full_can_execute_reverse (struct target_ops *self)
{
return 1;
}
@@ -1764,7 +1764,7 @@ record_full_is_async_p (struct target_ops *ops)
}
static enum exec_direction_kind
-record_full_execution_direction (void)
+record_full_execution_direction (struct target_ops *self)
{
return record_full_execution_dir;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 0e24500..d5054c8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -231,9 +231,9 @@ static int remote_read_description_p (struct target_ops *target);
static void remote_console_output (char *msg);
-static int remote_supports_cond_breakpoints (void);
+static int remote_supports_cond_breakpoints (struct target_ops *self);
-static int remote_can_run_breakpoint_commands (void);
+static int remote_can_run_breakpoint_commands (struct target_ops *self);
/* For "remote". */
@@ -8041,7 +8041,7 @@ extended_remote_mourn (struct target_ops *ops)
}
static int
-extended_remote_supports_disable_randomization (void)
+extended_remote_supports_disable_randomization (struct target_ops *self)
{
return (remote_protocol_packets[PACKET_QDisableRandomization].support
== PACKET_ENABLE);
@@ -8145,7 +8145,7 @@ extended_remote_create_inferior (struct target_ops *ops,
target_async (inferior_event_handler, 0);
/* Disable address space randomization if requested (and supported). */
- if (extended_remote_supports_disable_randomization ())
+ if (extended_remote_supports_disable_randomization (ops))
extended_remote_disable_randomization (disable_randomization);
/* Now restart the remote server. */
@@ -8286,10 +8286,10 @@ remote_insert_breakpoint (struct target_ops *ops,
p += hexnumstr (p, addr);
xsnprintf (p, endbuf - p, ",%d", bpsize);
- if (remote_supports_cond_breakpoints ())
+ if (remote_supports_cond_breakpoints (ops))
remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
- if (remote_can_run_breakpoint_commands ())
+ if (remote_can_run_breakpoint_commands (ops))
remote_add_target_side_commands (gdbarch, bp_tgt, p);
putpkt (rs->buf);
@@ -8565,10 +8565,10 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
p += hexnumstr (p, (ULONGEST) addr);
xsnprintf (p, endbuf - p, ",%x", bp_tgt->placed_size);
- if (remote_supports_cond_breakpoints ())
+ if (remote_supports_cond_breakpoints (self))
remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
- if (remote_can_run_breakpoint_commands ())
+ if (remote_can_run_breakpoint_commands (self))
remote_add_target_side_commands (gdbarch, bp_tgt, p);
putpkt (rs->buf);
@@ -9845,7 +9845,8 @@ remote_hostio_send_command (int command_bytes, int which_packet,
*REMOTE_ERRNO). */
static int
-remote_hostio_open (const char *filename, int flags, int mode,
+remote_hostio_open (struct target_ops *self,
+ const char *filename, int flags, int mode,
int *remote_errno)
{
struct remote_state *rs = get_remote_state ();
@@ -10091,7 +10092,8 @@ remote_bfd_iovec_open (struct bfd *abfd, void *open_closure)
gdb_assert (remote_filename_p (filename));
- fd = remote_hostio_open (filename + 7, FILEIO_O_RDONLY, 0, &remote_errno);
+ 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);
@@ -10197,7 +10199,8 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
perror_with_name (local_file);
back_to = make_cleanup_fclose (file);
- fd = remote_hostio_open (remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
+ fd = remote_hostio_open (find_target_at (process_stratum),
+ remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
| FILEIO_O_TRUNC),
0700, &remote_errno);
if (fd == -1)
@@ -10281,7 +10284,8 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
if (!rs->remote_desc)
error (_("command can only be used with remote target"));
- fd = remote_hostio_open (remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
+ fd = remote_hostio_open (find_target_at (process_stratum),
+ remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
if (fd == -1)
remote_hostio_error (remote_errno);
@@ -10405,7 +10409,7 @@ remote_command (char *args, int from_tty)
}
static int
-remote_can_execute_reverse (void)
+remote_can_execute_reverse (struct target_ops *self)
{
if (remote_protocol_packets[PACKET_bs].support == PACKET_ENABLE
|| remote_protocol_packets[PACKET_bc].support == PACKET_ENABLE)
@@ -10421,14 +10425,14 @@ remote_supports_non_stop (struct target_ops *self)
}
static int
-remote_supports_disable_randomization (void)
+remote_supports_disable_randomization (struct target_ops *self)
{
/* Only supported in extended mode. */
return 0;
}
static int
-remote_supports_multi_process (void)
+remote_supports_multi_process (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
@@ -10448,7 +10452,7 @@ remote_supports_cond_tracepoints (void)
}
static int
-remote_supports_cond_breakpoints (void)
+remote_supports_cond_breakpoints (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
@@ -10480,7 +10484,7 @@ remote_supports_install_in_trace (void)
}
static int
-remote_supports_enable_disable_tracepoint (void)
+remote_supports_enable_disable_tracepoint (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
@@ -10488,7 +10492,7 @@ remote_supports_enable_disable_tracepoint (void)
}
static int
-remote_supports_string_tracing (void)
+remote_supports_string_tracing (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
@@ -10496,7 +10500,7 @@ remote_supports_string_tracing (void)
}
static int
-remote_can_run_breakpoint_commands (void)
+remote_can_run_breakpoint_commands (struct target_ops *self)
{
struct remote_state *rs = get_remote_state ();
diff --git a/gdb/target.c b/gdb/target.c
index 1716c45..37d44e8 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -543,7 +543,7 @@ default_get_ada_task_ptid (struct target_ops *self, long lwp, long tid)
}
static enum exec_direction_kind
-default_execution_direction (void)
+default_execution_direction (struct target_ops *self)
{
if (!target_can_execute_reverse)
return EXEC_FORWARD;
@@ -840,13 +840,13 @@ update_current_target (void)
(ptid_t (*) (struct target_ops *, long, long))
default_get_ada_task_ptid);
de_fault (to_supports_multi_process,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_supports_enable_disable_tracepoint,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_supports_string_tracing,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_trace_init,
(void (*) (void))
@@ -930,10 +930,10 @@ update_current_target (void)
(struct traceframe_info * (*) (void))
return_null);
de_fault (to_supports_evaluation_of_breakpoint_conditions,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_can_run_breakpoint_commands,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_use_agent,
(int (*) (int))
@@ -3206,13 +3206,13 @@ target_info_proc (char *args, enum info_proc_what what)
}
static int
-find_default_supports_disable_randomization (void)
+find_default_supports_disable_randomization (struct target_ops *self)
{
struct target_ops *t;
t = find_default_run_target (NULL);
if (t && t->to_supports_disable_randomization)
- return (t->to_supports_disable_randomization) ();
+ return (t->to_supports_disable_randomization) (t);
return 0;
}
@@ -3223,7 +3223,7 @@ target_supports_disable_randomization (void)
for (t = ¤t_target; t != NULL; t = t->beneath)
if (t->to_supports_disable_randomization)
- return t->to_supports_disable_randomization ();
+ return t->to_supports_disable_randomization (t);
return 0;
}
@@ -3311,7 +3311,7 @@ target_fileio_open (const char *filename, int flags, int mode,
{
if (t->to_fileio_open != NULL)
{
- int fd = t->to_fileio_open (filename, flags, mode, target_errno);
+ int fd = t->to_fileio_open (t, filename, flags, mode, target_errno);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/target.h b/gdb/target.h
index 419842f..72a811b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -650,34 +650,34 @@ struct target_ops
CORE_ADDR *found_addrp);
/* Can target execute in reverse? */
- int (*to_can_execute_reverse) (void);
+ int (*to_can_execute_reverse) (struct target_ops *);
/* The direction the target is currently executing. Must be
implemented on targets that support reverse execution and async
mode. The default simply returns forward execution. */
- enum exec_direction_kind (*to_execution_direction) (void);
+ enum exec_direction_kind (*to_execution_direction) (struct target_ops *);
/* Does this target support debugging multiple processes
simultaneously? */
- int (*to_supports_multi_process) (void);
+ int (*to_supports_multi_process) (struct target_ops *);
/* Does this target support enabling and disabling tracepoints while a trace
experiment is running? */
- int (*to_supports_enable_disable_tracepoint) (void);
+ int (*to_supports_enable_disable_tracepoint) (struct target_ops *);
/* Does this target support disabling address space randomization? */
- int (*to_supports_disable_randomization) (void);
+ int (*to_supports_disable_randomization) (struct target_ops *);
/* Does this target support the tracenz bytecode for string collection? */
- int (*to_supports_string_tracing) (void);
+ int (*to_supports_string_tracing) (struct target_ops *);
/* Does this target support evaluation of breakpoint conditions on its
end? */
- int (*to_supports_evaluation_of_breakpoint_conditions) (void);
+ int (*to_supports_evaluation_of_breakpoint_conditions) (struct target_ops *);
/* Does this target support evaluation of breakpoint commands on its
end? */
- int (*to_can_run_breakpoint_commands) (void);
+ int (*to_can_run_breakpoint_commands) (struct target_ops *);
/* Determine current architecture of thread PTID.
@@ -703,7 +703,8 @@ struct target_ops
/* Open FILENAME on the target, using FLAGS and MODE. Return a
target file descriptor, or -1 if an error occurs (and set
*TARGET_ERRNO). */
- int (*to_fileio_open) (const char *filename, int flags, int mode,
+ int (*to_fileio_open) (struct target_ops *,
+ const char *filename, int flags, int mode,
int *target_errno);
/* Write up to LEN bytes from WRITE_BUF to FD on the target.
@@ -1091,7 +1092,7 @@ int target_info_proc (char *, enum info_proc_what);
simultaneously. */
#define target_supports_multi_process() \
- (*current_target.to_supports_multi_process) ()
+ (*current_target.to_supports_multi_process) (¤t_target)
/* Returns true if this target can disable address space randomization. */
@@ -1101,22 +1102,22 @@ int target_supports_disable_randomization (void);
while a trace experiment is running. */
#define target_supports_enable_disable_tracepoint() \
- (*current_target.to_supports_enable_disable_tracepoint) ()
+ (*current_target.to_supports_enable_disable_tracepoint) (¤t_target)
#define target_supports_string_tracing() \
- (*current_target.to_supports_string_tracing) ()
+ (*current_target.to_supports_string_tracing) (¤t_target)
/* Returns true if this target can handle breakpoint conditions
on its end. */
#define target_supports_evaluation_of_breakpoint_conditions() \
- (*current_target.to_supports_evaluation_of_breakpoint_conditions) ()
+ (*current_target.to_supports_evaluation_of_breakpoint_conditions) (¤t_target)
/* Returns true if this target can handle breakpoint commands
on its end. */
#define target_can_run_breakpoint_commands() \
- (*current_target.to_can_run_breakpoint_commands) ()
+ (*current_target.to_can_run_breakpoint_commands) (¤t_target)
extern int target_read_string (CORE_ADDR, char **, int, int *);
@@ -1499,7 +1500,7 @@ int target_supports_non_stop (void);
(current_target.to_async (¤t_target, (CALLBACK), (CONTEXT)))
#define target_execution_direction() \
- (current_target.to_execution_direction ())
+ (current_target.to_execution_direction (¤t_target))
/* Converts a process id to a string. Usually, the string just contains
`process xyz', but on some systems it may contain
@@ -1685,7 +1686,7 @@ extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
/* Target can execute in reverse? */
#define target_can_execute_reverse \
(current_target.to_can_execute_reverse ? \
- current_target.to_can_execute_reverse () : 0)
+ current_target.to_can_execute_reverse (¤t_target) : 0)
extern const struct target_desc *target_read_description (struct target_ops *);
--
1.8.1.4