Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: "Saleem\, Mohsan" <Mohsan_Saleem@mentor.com>
Cc: Mohsan Saleem <mohsansaleem_ms@yahoo.com>,
	       "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
	       "palves\@redhat.com" <palves@redhat.com>
Subject: Re: [PATCH] fix PR-12417
Date: Thu, 15 May 2014 19:03:00 -0000	[thread overview]
Message-ID: <8738gaampx.fsf@fleche.redhat.com> (raw)
In-Reply-To: <D5A5FA7510B2BE4089BC6266520C345FABDEBA@EU-MBX-04.mgc.mentorg.com>	(Mohsan Saleem's message of "Fri, 14 Feb 2014 10:40:52 +0000")

Finally responding to this...

Mohsan> if (print_thread_events)
Mohsan> -    printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
Mohsan> +    printf_unfiltered (_("[New %s \"%s\"]\n"), 
Mohsan> + target_pid_to_str (ptid), thread_name (result));

Tom> This line is too long.
Tom> Also, I think the output will be weird if the thread does not have a name.

Mohsan> What I'm supposed to do about line length?

Normally one splits the line at the appropriate point, and then indents
the continuation line appropriately.  There is some discussion in the
GNU Coding Standards document, plus a plethora of examples in gdb.

In your patch the line looked like:

    printf_unfiltered (_("[New %s \"%s\"\n"), target_pid_to_str (ptid), thread_name (result));

I would write this as:

    printf_unfiltered (_("[New %s \"%s\"\n"), target_pid_to_str (ptid),
                       thread_name (result));

Mohsan> Any thread without a name is automatically assigned with the program
Mohsan> name argv[0]. So Empty string could not be a problem here.

But the new thread_name function can return "".
If this happens then the output will be strange.
It this cannot happen then thread_name ought to be changed.

I think it can happen, though, because the default to_thread_name
returns NULL.

Tom> Two thoughts come to mind for the patch.

Tom> First, perhaps a single function for emitting the thread description
Tom> would be better.  Then it could be normalized across all of gdb.
Tom> Second, it would be nice to use ui-out properly in such a function,
Tom> so that MI can see the thread name distinctly from the other bits.

Mohsan> Sorry, I didn't got your point here. Could you please elaborate it a
Mohsan> little more, as I am new to GDB.

Sure, no problem.

The patch has a number of hunks like this:

-      printf_filtered (_("Thread %d has target id '%s'\n"),
-               tp->num, tmp);
+          printf_filtered (_("Thread %d \"%s\" has target id '%s'\n"),
+               tp->num, thread_name (tp), tmp);

Given the fact that an empty result from thread_name will result in
strange-looking output, it would probably be better to normalize the
thread-name-printing parts into a single function.

Second, the patch says:

-  ui_out_text (uiout, " (");
+  ui_out_text (uiout, " \"");
+  ui_out_text (uiout, thread_name (tp));
+  ui_out_text (uiout, "\" (");

This means that the thread name is just dropped from the MI output.
However, since care is already taken here to use ui_out, it is
preferable to emit the thread name in an MI-readable form.  This can be
done with a call to ui_out_field_string.

Tom


      reply	other threads:[~2014-05-15 19:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D5A5FA7510B2BE4089BC6266520C345F9D995C@EU-MBX-02.mgc.mentorg.com>
2013-08-28 16:24 ` Mohsan Saleem
2013-09-03  2:39   ` Mohsan Saleem
2013-09-04  8:19     ` Mohsan Saleem
2013-09-04  8:58       ` Agovic, Sanimir
2013-09-04 11:25         ` Mohsan Saleem
2013-09-04 12:24           ` Agovic, Sanimir
2013-09-17  4:18           ` Mohsan Saleem
2013-11-06 22:23             ` Tom Tromey
2014-02-14 10:41               ` Saleem, Mohsan
2014-05-15 19:03                 ` Tom Tromey [this message]

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=8738gaampx.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=Mohsan_Saleem@mentor.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mohsansaleem_ms@yahoo.com \
    --cc=palves@redhat.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