Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] gdbserver: Remove thread_to_gdb_id
Date: Fri, 15 Sep 2017 11:02:00 -0000	[thread overview]
Message-ID: <8e662d76-08d2-1351-840a-18b01eae136b@redhat.com> (raw)
In-Reply-To: <1505074275-1662-4-git-send-email-simon.marchi@ericsson.com>

On 09/10/2017 09:11 PM, Simon Marchi wrote:
> As explained in the previous patch, the gdb_id concept is no longer
> relevant.  The function thread_to_gdb_id is trivial, it returns the
> thread's ptid.  Remove it and replace its usage with ptid_of.
> 
> The changes in nto-low.c and lynx-low.c are fairly straightforward, but
> I was not able to build test them.

Seems fine to me.  Nits below.

> @@ -869,7 +869,7 @@ nto_stopped_by_watchpoint (void)
>      {
>        ptid_t ptid;
>  
> -      ptid = thread_to_gdb_id (current_thread);
> +      ptid = ptid_of (current_thread);
>        if (nto_set_thread (ptid))
>  	{
>  	  const int watchmask = _DEBUG_FLAG_TRACE_RD | _DEBUG_FLAG_TRACE_WR
> @@ -901,7 +901,7 @@ nto_stopped_data_address (void)
>      {
>        ptid_t ptid;
>  
> -      ptid = thread_to_gdb_id (current_thread);
> +      ptid = ptid_of (current_thread);
>  

Above two hunks could merge decl + init.

> @@ -2070,21 +2070,21 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
>    /* Reply the current thread id.  */
>    if (strcmp ("qC", own_buf) == 0 && !disable_packet_qC)
>      {
> -      ptid_t gdb_id;
> +      ptid_t ptid;
>        require_running (own_buf);
>  
>        if (!ptid_equal (general_thread, null_ptid)
>  	  && !ptid_equal (general_thread, minus_one_ptid))

In the other patch you converted equivalent checks to use op!= ,
I don't mind doing it here as well while at it:

        if (general_thread != null_ptid
            && general_thread != minus_one_ptid)


> -	gdb_id = general_thread;
> +	ptid = general_thread;
>        else
>  	{
>  	  thread_ptr = get_first_inferior (&all_threads);
> -	  gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr);
> +	  ptid = thread_ptr->id;
>  	}
>  
>        sprintf (own_buf, "QC");
>        own_buf += 2;
> -      write_ptid (own_buf, gdb_id);
> +      write_ptid (own_buf, ptid);
>        return;
>      }
>  
> @@ -2140,28 +2140,24 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
>      {
>        if (strcmp ("qfThreadInfo", own_buf) == 0)
>  	{
> -	  ptid_t gdb_id;
> -
>  	  require_running (own_buf);
>  	  thread_ptr = get_first_inferior (&all_threads);
>  
>  	  *own_buf++ = 'm';
> -	  gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr);
> -	  write_ptid (own_buf, gdb_id);
> +	  ptid_t ptid = thread_ptr->id;
> +	  write_ptid (own_buf, ptid);

Could even get rid of the ptid_t variable?

  write_ptid (own_buf, thread_ptr->id);

>  	  thread_ptr = thread_ptr->next;
>  	  return;
>  	}
>  
>        if (strcmp ("qsThreadInfo", own_buf) == 0)
>  	{
> -	  ptid_t gdb_id;
> -
>  	  require_running (own_buf);
>  	  if (thread_ptr != NULL)
>  	    {
>  	      *own_buf++ = 'm';
> -	      gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr);
> -	      write_ptid (own_buf, gdb_id);
> +	      ptid_t ptid = thread_ptr->id;
> +	      write_ptid (own_buf, ptid);

Ditto.

>  	      thread_ptr = thread_ptr->next;
>  	      return;
>  	    }
> 

Thanks,
Pedro Alves


  reply	other threads:[~2017-09-15 11:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 20:11 [PATCH 0/3] Small cleanups in gdbserver Simon Marchi
2017-09-10 20:11 ` [PATCH 3/3] gdbserver: Remove thread_to_gdb_id Simon Marchi
2017-09-15 11:02   ` Pedro Alves [this message]
2017-09-15 13:54     ` Simon Marchi
2017-09-15 14:00       ` Pedro Alves
2017-09-10 20:11 ` [PATCH 2/3] gdbserver: Remove gdb_id_to_thread_id Simon Marchi
2017-09-15 10:55   ` Pedro Alves
2017-09-15 13:07     ` Simon Marchi
2017-09-15 13:34       ` Simon Marchi
2017-09-15 13:44     ` Simon Marchi
2017-09-10 20:11 ` [PATCH 1/3] gdbserver: Remove duplicate functions to find any thread of process Simon Marchi
2017-09-15  4:09   ` Sergio Durigan Junior
2017-09-15 12:53     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e662d76-08d2-1351-840a-18b01eae136b@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox