[PATCH] gdb.trace: Deduplicate write_inferior_data_ptr.

Marcin Kościelnicki koriakin@0x04.net
Sat Feb 6 01:05:00 GMT 2016


Ping

On 28/01/16 16:42, Marcin Kościelnicki wrote:
> This function is now basically identical to write_inferior_data_pointer,
> remove it and change all references.
>
> gdb/gdbserver/ChangeLog:
>
> 	* tracepoint.c (x_tracepoint_action_download): Change
> 	write_inferior_data_ptr to write_inferior_data_pointer.
> 	(cmd_qtstart): Likewise.
> 	(write_inferior_data_ptr): Remove.
> 	(download_agent_expr): Change write_inferior_data_ptr to
> 	write_inferior_data_pointer.
> 	(download_tracepoint_1): Likewise.
> 	(download_tracepoint): Likewise.
> 	(download_trace_state_variables): Likewise.
> ---
> OK to push?
>
>   gdb/gdbserver/ChangeLog    | 12 ++++++++++++
>   gdb/gdbserver/tracepoint.c | 44 ++++++++++++++++----------------------------
>   2 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
> index 1f9c139..50eda62 100644
> --- a/gdb/gdbserver/ChangeLog
> +++ b/gdb/gdbserver/ChangeLog
> @@ -1,3 +1,15 @@
> +2016-01-28  Marcin Kościelnicki  <koriakin@0x04.net>
> +
> +	* tracepoint.c (x_tracepoint_action_download): Change
> +	write_inferior_data_ptr to write_inferior_data_pointer.
> +	(cmd_qtstart): Likewise.
> +	(write_inferior_data_ptr): Remove.
> +	(download_agent_expr): Change write_inferior_data_ptr to
> +	write_inferior_data_pointer.
> +	(download_tracepoint_1): Likewise.
> +	(download_tracepoint): Likewise.
> +	(download_trace_state_variables): Likewise.
> +
>   2016-01-28  Simon Marchi  <simon.marchi@ericsson.com>
>
>   	* server.c (skip_to_semicolon):  Remove.
> diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
> index 0671999..6b9a33c 100644
> --- a/gdb/gdbserver/tracepoint.c
> +++ b/gdb/gdbserver/tracepoint.c
> @@ -452,7 +452,6 @@ write_inferior_uinteger (CORE_ADDR symaddr, unsigned int val)
>   }
>
>   static CORE_ADDR target_malloc (ULONGEST size);
> -static int write_inferior_data_ptr (CORE_ADDR where, CORE_ADDR ptr);
>
>   #define COPY_FIELD_TO_BUF(BUF, OBJ, FIELD)	\
>     do {							\
> @@ -589,7 +588,7 @@ x_tracepoint_action_download (const struct tracepoint_action *action)
>     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)
> +  write_inferior_data_pointer (ipa_action + offsetof (struct eval_expr_action, expr)
>   			   - offsetof (struct tracepoint_action, type),
>   			   expr);
>
> @@ -3233,7 +3232,7 @@ cmd_qtstart (char *packet)
>
>     /* Start out empty.  */
>     if (agent_loaded_p ())
> -    write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, 0);
> +    write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints, 0);
>
>     /* Download and install tracepoints.  */
>     for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
> @@ -3329,9 +3328,9 @@ cmd_qtstart (char *packet)
>   	  if (tpoint == tracepoints)
>   	    /* First object in list, set the head pointer in the
>   	       inferior.  */
> -	    write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, tpptr);
> +	    write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints, tpptr);
>   	  else
> -	    write_inferior_data_ptr (prev_tpptr + offsetof (struct tracepoint,
> +	    write_inferior_data_pointer (prev_tpptr + offsetof (struct tracepoint,
>   							    next),
>   				     tpptr);
>   	}
> @@ -5931,17 +5930,6 @@ compile_tracepoint_condition (struct tracepoint *tpoint,
>     *jump_entry += 16;
>   }
>
> -/* We'll need to adjust these when we consider bi-arch setups.  */
> -
> -static int
> -write_inferior_data_ptr (CORE_ADDR where, CORE_ADDR ptr)
> -{
> -  uintptr_t pptr = ptr;
> -
> -  return write_inferior_memory (where,
> -				(unsigned char *) &pptr, sizeof pptr);
> -}
> -
>   /* The base pointer of the IPA's heap.  This is the only memory the
>      IPA is allowed to use.  The IPA should _not_ call the inferior's
>      `malloc' during operation.  That'd be slow, and, most importantly,
> @@ -5987,7 +5975,7 @@ download_agent_expr (struct agent_expr *expr)
>     write_inferior_memory (expr_addr, (unsigned char *) expr, sizeof (*expr));
>
>     expr_bytes = target_malloc (expr->length);
> -  write_inferior_data_ptr (expr_addr + offsetof (struct agent_expr, bytes),
> +  write_inferior_data_pointer (expr_addr + offsetof (struct agent_expr, bytes),
>   			   expr_bytes);
>     write_inferior_memory (expr_bytes, expr->bytes, expr->length);
>
> @@ -6046,7 +6034,7 @@ download_tracepoint_1 (struct tracepoint *tpoint)
>   			 sizeof (target_tracepoint));
>
>     if (tpoint->cond)
> -    write_inferior_data_ptr (tpptr + offsetof (struct tracepoint,
> +    write_inferior_data_pointer (tpptr + offsetof (struct tracepoint,
>   					       cond),
>   			     download_agent_expr (tpoint->cond));
>
> @@ -6058,7 +6046,7 @@ download_tracepoint_1 (struct tracepoint *tpoint)
>         /* The pointers array.  */
>         actions_array
>   	= target_malloc (sizeof (*tpoint->actions) * tpoint->numactions);
> -      write_inferior_data_ptr (tpptr + offsetof (struct tracepoint,
> +      write_inferior_data_pointer (tpptr + offsetof (struct tracepoint,
>   						 actions),
>   			       actions_array);
>
> @@ -6069,7 +6057,7 @@ download_tracepoint_1 (struct tracepoint *tpoint)
>   	  CORE_ADDR ipa_action = action->ops->download (action);
>
>   	  if (ipa_action != 0)
> -	    write_inferior_data_ptr
> +	    write_inferior_data_pointer
>   	      (actions_array + i * sizeof (*tpoint->actions),
>   	       ipa_action);
>   	}
> @@ -6195,18 +6183,18 @@ download_tracepoint (struct tracepoint *tpoint)
>   	}
>
>         /* tpoint->next = tp_prev->next */
> -      write_inferior_data_ptr (tpoint->obj_addr_on_target
> +      write_inferior_data_pointer (tpoint->obj_addr_on_target
>   			       + offsetof (struct tracepoint, next),
>   			       tp_prev_target_next_addr);
>         /* tp_prev->next = tpoint */
> -      write_inferior_data_ptr (tp_prev->obj_addr_on_target
> +      write_inferior_data_pointer (tp_prev->obj_addr_on_target
>   			       + offsetof (struct tracepoint, next),
>   			       tpoint->obj_addr_on_target);
>       }
>     else
>       /* First object in list, set the head pointer in the
>          inferior.  */
> -    write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints,
> +    write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints,
>   			     tpoint->obj_addr_on_target);
>
>   }
> @@ -6218,7 +6206,7 @@ download_trace_state_variables (void)
>     struct trace_state_variable *tsv;
>
>     /* Start out empty.  */
> -  write_inferior_data_ptr (ipa_sym_addrs.addr_trace_state_variables, 0);
> +  write_inferior_data_pointer (ipa_sym_addrs.addr_trace_state_variables, 0);
>
>     for (tsv = trace_state_variables; tsv != NULL; tsv = tsv->next)
>       {
> @@ -6239,12 +6227,12 @@ download_trace_state_variables (void)
>   	  /* First object in list, set the head pointer in the
>   	     inferior.  */
>
> -	  write_inferior_data_ptr (ipa_sym_addrs.addr_trace_state_variables,
> +	  write_inferior_data_pointer (ipa_sym_addrs.addr_trace_state_variables,
>   				   ptr);
>   	}
>         else
>   	{
> -	  write_inferior_data_ptr (prev_ptr
> +	  write_inferior_data_pointer (prev_ptr
>   				   + offsetof (struct trace_state_variable,
>   					       next),
>   				   ptr);
> @@ -6263,7 +6251,7 @@ download_trace_state_variables (void)
>   	  CORE_ADDR name_addr = target_malloc (size);
>   	  write_inferior_memory (name_addr,
>   				 (unsigned char *) tsv->name, size);
> -	  write_inferior_data_ptr (ptr
> +	  write_inferior_data_pointer (ptr
>   				   + offsetof (struct trace_state_variable,
>   					       name),
>   				   name_addr);
> @@ -6275,7 +6263,7 @@ download_trace_state_variables (void)
>     if (prev_ptr != 0)
>       {
>         /* Fixup the next pointer in the last item in the list.  */
> -      write_inferior_data_ptr (prev_ptr
> +      write_inferior_data_pointer (prev_ptr
>   			       + offsetof (struct trace_state_variable,
>   					   next), 0);
>       }
>



More information about the Gdb-patches mailing list