diff options
-rw-r--r-- | gdb/gdbserver/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/gdbserver/tracepoint.c | 119 |
2 files changed, 65 insertions, 69 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 2c11f89..0e8c5ae 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,18 @@ +2016-02-11 Wei-cheng Wang <cole945@gmail.com> + Marcin KoĆcielnicki <koriakin@0x04.net> + + * tracepoint.c (struct tracepoint_action_ops): Remove. + (struct tracepoint_action): Remove ops. + (m_tracepoint_action_download, r_tracepoint_action_download) + (x_tracepoint_action_download, l_tracepoint_action_download): Adjust + size and offset accordingly. + (m_tracepoint_action_ops, r_tracepoint_action_ops) + (x_tracepoint_action_ops, l_tracepoint_action_ops): Remove. + (tracepoint_action_send, tracepoint_action_download): New functions. + Helpers for trace action handlers. + (add_tracepoint_action): Remove setup actions ops. + (download_tracepoint_1, tracepoint_send_agent): Call helper functions. + 2016-02-10 Yao Qi <yao.qi@linaro.org> * regcache.c (regcache_raw_read_unsigned): Clear *VAL. diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 0671999..67995ac 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -462,28 +462,10 @@ static int write_inferior_data_ptr (CORE_ADDR where, CORE_ADDR ptr); #endif -/* Operations on various types of tracepoint actions. */ - -struct tracepoint_action; - -struct tracepoint_action_ops -{ - /* Download tracepoint action ACTION to IPA. Return the address of action - in IPA/inferior. */ - CORE_ADDR (*download) (const struct tracepoint_action *action); - - /* Send ACTION to agent via command buffer started from BUFFER. Return - updated head of command buffer. */ - char* (*send) (char *buffer, const struct tracepoint_action *action); -}; - /* Base action. Concrete actions inherit this. */ struct tracepoint_action { -#ifndef IN_PROCESS_AGENT - const struct tracepoint_action_ops *ops; -#endif char type; }; @@ -523,12 +505,10 @@ struct collect_static_trace_data_action static CORE_ADDR m_tracepoint_action_download (const struct tracepoint_action *action) { - int size_in_ipa = (sizeof (struct collect_memory_action) - - offsetof (struct tracepoint_action, type)); - CORE_ADDR ipa_action = target_malloc (size_in_ipa); + CORE_ADDR ipa_action = target_malloc (sizeof (struct collect_memory_action)); - write_inferior_memory (ipa_action, (unsigned char *) &action->type, - size_in_ipa); + write_inferior_memory (ipa_action, (unsigned char *) action, + sizeof (struct collect_memory_action)); return ipa_action; } @@ -545,21 +525,13 @@ m_tracepoint_action_send (char *buffer, const struct tracepoint_action *action) return buffer; } -static const struct tracepoint_action_ops m_tracepoint_action_ops = -{ - m_tracepoint_action_download, - m_tracepoint_action_send, -}; - static CORE_ADDR r_tracepoint_action_download (const struct tracepoint_action *action) { - int size_in_ipa = (sizeof (struct collect_registers_action) - - offsetof (struct tracepoint_action, type)); - CORE_ADDR ipa_action = target_malloc (size_in_ipa); + CORE_ADDR ipa_action = target_malloc (sizeof (struct collect_registers_action)); - write_inferior_memory (ipa_action, (unsigned char *) &action->type, - size_in_ipa); + write_inferior_memory (ipa_action, (unsigned char *) action, + sizeof (struct collect_registers_action)); return ipa_action; } @@ -570,27 +542,19 @@ r_tracepoint_action_send (char *buffer, const struct tracepoint_action *action) return buffer; } -static const struct tracepoint_action_ops r_tracepoint_action_ops = -{ - r_tracepoint_action_download, - r_tracepoint_action_send, -}; - static CORE_ADDR download_agent_expr (struct agent_expr *expr); static CORE_ADDR x_tracepoint_action_download (const struct tracepoint_action *action) { - int size_in_ipa = (sizeof (struct eval_expr_action) - - offsetof (struct tracepoint_action, type)); - CORE_ADDR ipa_action = target_malloc (size_in_ipa); + CORE_ADDR ipa_action = target_malloc (sizeof (struct eval_expr_action)); CORE_ADDR expr; - write_inferior_memory (ipa_action, (unsigned char *) &action->type, - size_in_ipa); - expr = download_agent_expr (((struct eval_expr_action *)action)->expr); - write_inferior_data_ptr (ipa_action + offsetof (struct eval_expr_action, expr) - - offsetof (struct tracepoint_action, type), + write_inferior_memory (ipa_action, (unsigned char *) action, + sizeof (struct eval_expr_action)); + expr = download_agent_expr (((struct eval_expr_action *) action)->expr); + write_inferior_data_ptr (ipa_action + + offsetof (struct eval_expr_action, expr), expr); return ipa_action; @@ -628,21 +592,14 @@ x_tracepoint_action_send ( char *buffer, const struct tracepoint_action *action) return agent_expr_send (buffer, eaction->expr); } -static const struct tracepoint_action_ops x_tracepoint_action_ops = -{ - x_tracepoint_action_download, - x_tracepoint_action_send, -}; - static CORE_ADDR l_tracepoint_action_download (const struct tracepoint_action *action) { - int size_in_ipa = (sizeof (struct collect_static_trace_data_action) - - offsetof (struct tracepoint_action, type)); - CORE_ADDR ipa_action = target_malloc (size_in_ipa); + CORE_ADDR ipa_action + = target_malloc (sizeof (struct collect_static_trace_data_action)); - write_inferior_memory (ipa_action, (unsigned char *) &action->type, - size_in_ipa); + write_inferior_memory (ipa_action, (unsigned char *) action, + sizeof (struct collect_static_trace_data_action)); return ipa_action; } @@ -653,11 +610,39 @@ l_tracepoint_action_send (char *buffer, const struct tracepoint_action *action) return buffer; } -static const struct tracepoint_action_ops l_tracepoint_action_ops = +static char * +tracepoint_action_send (char *buffer, const struct tracepoint_action *action) +{ + switch (action->type) + { + case 'M': + return m_tracepoint_action_send (buffer, action); + case 'R': + return r_tracepoint_action_send (buffer, action); + case 'X': + return x_tracepoint_action_send (buffer, action); + case 'L': + return l_tracepoint_action_send (buffer, action); + } + error ("Unknown trace action '%c'.", action->type); +} + +static CORE_ADDR +tracepoint_action_download (const struct tracepoint_action *action) { - l_tracepoint_action_download, - l_tracepoint_action_send, -}; + switch (action->type) + { + case 'M': + return m_tracepoint_action_download (action); + case 'R': + return r_tracepoint_action_download (action); + case 'X': + return x_tracepoint_action_download (action); + case 'L': + return l_tracepoint_action_download (action); + } + error ("Unknown trace action '%c'.", action->type); +} #endif /* This structure describes a piece of the source-level definition of @@ -1944,7 +1929,6 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet) int is_neg; maction->base.type = *act; - maction->base.ops = &m_tracepoint_action_ops; action = &maction->base; ++act; @@ -1970,7 +1954,6 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet) XNEW (struct collect_registers_action); raction->base.type = *act; - raction->base.ops = &r_tracepoint_action_ops; action = &raction->base; trace_debug ("Want to collect registers"); @@ -1986,7 +1969,6 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet) XNEW (struct collect_static_trace_data_action); raction->base.type = *act; - raction->base.ops = &l_tracepoint_action_ops; action = &raction->base; trace_debug ("Want to collect static trace data"); @@ -2002,7 +1984,6 @@ add_tracepoint_action (struct tracepoint *tpoint, char *packet) struct eval_expr_action *xaction = XNEW (struct eval_expr_action); xaction->base.type = *act; - xaction->base.ops = &x_tracepoint_action_ops; action = &xaction->base; trace_debug ("Want to evaluate expression"); @@ -6066,7 +6047,7 @@ download_tracepoint_1 (struct tracepoint *tpoint) for (i = 0; i < tpoint->numactions; i++) { struct tracepoint_action *action = tpoint->actions[i]; - CORE_ADDR ipa_action = action->ops->download (action); + CORE_ADDR ipa_action = tracepoint_action_download (action); if (ipa_action != 0) write_inferior_data_ptr @@ -6116,7 +6097,7 @@ tracepoint_send_agent (struct tracepoint *tpoint) struct tracepoint_action *action = tpoint->actions[i]; p[0] = action->type; - p = action->ops->send (&p[1], action); + p = tracepoint_action_send (&p[1], action); } get_jump_space_head (); |