Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Mohsan Saleem <mohsansaleem_ms@yahoo.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb bug 12417
Date: Mon, 24 Sep 2012 22:19:00 -0000	[thread overview]
Message-ID: <m3zk4f5ak2.fsf@redhat.com> (raw)
In-Reply-To: <1348508232.46785.YahooMailNeo@web114411.mail.gq1.yahoo.com>

Hello Mohsan,

Thanks for the patch.  Not really a technical review, but rather
formatting nits.

On Monday, September 24 2012, Mohsan Saleem wrote:

> diff -ruN ./gdb_old/ChangeLog ./gdb_new/ChangeLog
> --- ./gdb_old/ChangeLog	2012-09-24 13:17:34.000000000 +0500
> +++ ./gdb_new/ChangeLog	2012-09-24 22:25:44.465441936 +0500
> @@ -1,3 +1,12 @@
> +2012-09-24  Mohsan Saleem  <mohsansaleem_ms@yahoo.com>
> +
> +	* thread.c (thread_name): New function. To get thread name
                                               ^^

Two spaces after period.  Missing period at the end of the sentence.
You also don't need to explain what `thread_name' does, therefore you
can get rid of the "To get thread name" part.

> +	(add_thread_with_info): Update to print thread name.
> +	(thread_apply_all_command): Likewise.
> +	(thread_apply_command): Likewise.
> +	(thread_find_command): Likewise.
> +	(do_captured_thread_select): Likewise.

Since you are solving a PR, it is recommended that you put its reference
on the ChangeLog message, like this:

2012-09-24  Mohsan Saleem  <mohsansaleem_ms@yahoo.com>

	PR threads/12417
	...
	
> diff -ruN ./gdb_old/gdb/testsuite/gdb.threads/thread-find.exp ./gdb_new/gdb/testsuite/gdb.threads/thread-find.exp
> --- ./gdb_old/gdb/testsuite/gdb.threads/thread-find.exp	2012-09-24 13:17:38.000000000 +0500
> +++ ./gdb_new/gdb/testsuite/gdb.threads/thread-find.exp	2012-09-24 21:55:44.737537299 +0500
> @@ -186,17 +186,17 @@
>  
>  if { [info exists thread6] } then {
>      gdb_test "thread find $thread6" \
> -	"Thread 6 has .*$thread6.*" "find thread id 6"
> +	"Thread 6 threadname_6 has .*$thread6.*" "find thread id 6"

I have some comments about the printing style, see below.

> diff -ruN ./gdb_old/gdb/thread.c ./gdb_new/gdb/thread.c
> --- ./gdb_old/gdb/thread.c	2012-09-24 13:17:37.000000000 +0500
> +++ ./gdb_new/gdb/thread.c	2012-09-24 21:54:46.689540365 +0500
> @@ -64,6 +64,7 @@
>  static void thread_apply_command (char *, int);
>  static void restore_current_thread (ptid_t);
>  static void prune_threads (void);
> +static const char* thread_name (struct thread_info *);
                    ^

The `*' must be together with `thread_name', not `char':

    static const char *thread_name (struct thread_info *);

> +const char*
             ^

Should be:

     const char *

> +thread_name (struct thread_info *ti)
> +{
> +  const char* name;
               ^

Should be:

     const char *name;

> +  name = ti->name ? ti->name : target_thread_name(ti);

The standard is to explict check for NULL.  Also, there must be one
space between the function name and the open paren.

     name = ti->name != NULL ? ti-> name : target_thread_name (ti);

> +  if (name)
> +    return name;
> +  else
> +    return "";

You could do:

    return name != NULL ? name : "";

This whole function could also be shortened, but I think it's OK as-is.

>  void
>  delete_step_resume_breakpoint (struct thread_info *tp)
>  {
> @@ -236,7 +248,7 @@
>    result->private = private;
>  
>    if (print_thread_events)
> -    printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
> +    printf_unfiltered (_("[New %s %s]\n"), target_pid_to_str (ptid), thread_name (result));
>  
>    annotate_new_thread ();
>    return result;
> @@ -1198,8 +1210,8 @@
>        {
>  	switch_to_thread (tp->ptid);
>  
> -	printf_filtered (_("\nThread %d (%s):\n"),
> -			 tp->num, target_pid_to_str (inferior_ptid));
> +	printf_filtered (_("\nThread %d %s (%s):\n"), tp->num,
> +			 thread_name (tp), target_pid_to_str (inferior_ptid));

I would like to hear others' opinions, but I guess this line could be
printed differently.  Currently it is:

        Thread 2 thread_name2 (12323)...

It could now be:

        Thread thread_name2 [#2] (12323)...

I think it gives more importance to the name.  The same comments applies
to all other commands.  But please, don't change anything yet, wait
until a maintainer states his opinions.

WDYT?

-- 
Sergio


  reply	other threads:[~2012-09-24 22:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24 17:37 Mohsan Saleem
2012-09-24 22:19 ` Sergio Durigan Junior [this message]
     [not found] <A62F3BCAE6F6B540A2F2C0E7E4387B9505B5AA72@EU-MBX-01.mgc.mentorg.com>
2012-09-18 13:17 ` Mohsan Saleem
2012-09-19 11:00   ` [PATCH] " Mohsan Saleem
2012-09-19 13:09     ` Jan Kratochvil
2012-09-19 13:22     ` Yao Qi

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=m3zk4f5ak2.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mohsansaleem_ms@yahoo.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