[patch 3/8] New target hook `to_can_download_tracepoint_loc'

Yao Qi
2011-11-08T06:21:42Z

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

This patch is to add a new target hook 'to_can_download_tracepoint_loc'
to determine whether it is OK for remote target to receive tracepoint
locations.

Note that, `download_tracepoint_loc' itself can check this in lower
level, but it is not efficient, and it leaves managing location's status
to lower level.

This patch is needed by patch 4/8.

--
Yao (é½å°§)

[-- Attachment #2: 0003-new-target-hook-can_download_tracepoint_loc.patch --]
[-- Type: text/x-patch, Size: 3450 bytes --]

* target.h (struct target): New field
`to_can_download_tracepoint_loc'.
(target_can_download_tracepoint_loc): New macro.
* target.c (update_current_target): Update.
* remote.c (remote_can_download_tracepoint_loc): New.
---
gdb/remote.c | 19 +++++++++++++++++++
gdb/target.c | 4 ++++
gdb/target.h | 7 +++++++
3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index c34d47b..5ba497a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -10036,6 +10036,24 @@ remote_download_tracepoint_loc (struct bp_location *loc)

}

+static int
+remote_can_download_tracepoint_loc ()
+{
+ struct trace_status *ts = current_trace_status ();
+ int status = remote_get_trace_status (ts);
+
+ if (status == -1 || !ts->running_known || !ts->running)
+ return 0;
+
+ /* If we are in a tracing experiment, but remote stub doesn't support
+ installing tracepoint in trace, we have to return. */
+ if (!remote_supports_install_in_trace ())
+ return 0;
+
+ return 1;
+}
+
+
static void
remote_download_trace_state_variable (struct trace_state_variable *tsv)
{
@@ -10508,6 +10526,7 @@ Specify the serial device it is connected to\n\
remote_ops.to_supports_string_tracing = remote_supports_string_tracing;
remote_ops.to_trace_init = remote_trace_init;
remote_ops.to_download_tracepoint_loc = remote_download_tracepoint_loc;
+ remote_ops.to_can_download_tracepoint_loc = remote_can_download_tracepoint_loc;
remote_ops.to_download_trace_state_variable
= remote_download_trace_state_variable;
remote_ops.to_enable_tracepoint = remote_enable_tracepoint;
diff --git a/gdb/target.c b/gdb/target.c
index 48cd888..d236530 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -675,6 +675,7 @@ update_current_target (void)
INHERIT (to_supports_string_tracing, t);
INHERIT (to_trace_init, t);
INHERIT (to_download_tracepoint_loc, t);
+ INHERIT (to_can_download_tracepoint_loc, t);
INHERIT (to_download_trace_state_variable, t);
INHERIT (to_enable_tracepoint, t);
INHERIT (to_disable_tracepoint, t);
@@ -850,6 +851,9 @@ update_current_target (void)
de_fault (to_download_tracepoint_loc,
(int (*) (struct bp_location *))
tcomplain);
+ de_fault (to_can_download_tracepoint_loc,
+ (int (*) (void))
+ return_zero);
de_fault (to_download_trace_state_variable,
(void (*) (struct trace_state_variable *))
tcomplain);
diff --git a/gdb/target.h b/gdb/target.h
index 74e1d8a..69a2a32 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -693,6 +693,10 @@ struct target_ops
otherwise return 1. */
int (*to_download_tracepoint_loc) (struct bp_location *location);

+ /* Can the target be able to download tracepoint locations in current
+ status? */
+ int (*to_can_download_tracepoint_loc) (void);
+
/* Send full details of a trace state variable to the target. */
void (*to_download_trace_state_variable) (struct trace_state_variable *tsv);

@@ -1481,6 +1485,9 @@ extern int target_search_memory (CORE_ADDR start_addr,
#define target_download_tracepoint_loc(t) \
(*current_target.to_download_tracepoint_loc) (t)

+#define target_can_download_tracepoint_loc() \
+ (*current_target.to_can_download_tracepoint_loc) ()
+
#define target_download_trace_state_variable(tsv) \
(*current_target.to_download_trace_state_variable) (tsv)

--
1.7.0.4