public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Simon Marchi <simon.marchi@ericsson.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Add "thread-group id" and "id in thread-group" info to -thread-info output
Date: Thu, 19 Jan 2017 14:55:00 -0000	[thread overview]
Message-ID: <b9c2d26c-d745-df26-4c8d-83138bf7df01@codesourcery.com> (raw)
In-Reply-To: <20170119144130.4341-1-simon.marchi@ericsson.com>

On 01/19/2017 08:41 AM, Simon Marchi wrote:
> diff --git a/gdb/testsuite/gdb.mi/mi-qualified-thread-id.exp b/gdb/testsuite/gdb.mi/mi-qualified-thread-id.exp
> new file mode 100644
> index 0000000000..43c1409786
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mi/mi-qualified-thread-id.exp
> @@ -0,0 +1,76 @@
> +# Copyright 2017 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +load_lib mi-support.exp
> +set MIFLAGS "-i=mi"
> +
> +standard_testfile
> +
> +if {[use_gdb_stub]} {
> +    # There is no point in testing inferior-qualified thread ids if we can't
> +    # have multiple inferiors.
> +    untested "multi-inferior not supported"
> +    return
> +}
> +
> +if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
> +     untested ${testfile}

untested "failed to compile"

> +     return -1
> +}
> +
> +# Prepare the inferiors.  Start and run them until the "thread_started" function.
> +
> +proc setup { } {
> +    global binfile
> +    global srcdir
> +    global subdir
> +    global srcfile
> +
> +    gdb_exit
> +    mi_gdb_start
> +    mi_gdb_reinitialize_dir $srcdir/$subdir
> +    mi_gdb_load ${binfile}
> +
> +    mi_create_breakpoint "thread_started" "insert breakpoint at thread_started"
> +
> +    # Start inferior 1
> +    mi_run_cmd
> +    mi_expect_stop "breakpoint-hit" "thread_started" ".*" "${srcfile}" ".*" {"" "disp=\"keep\""} "inferior 1 stops"
> +
> +    # Add and start inferior 2
> +    mi_gdb_test "add-inferior -exec ${binfile}" ".*=thread-group-added,id=\"i2\".*" "add second inferior"
> +    mi_gdb_test "inferior 2" ".*" "switch to inferior 2"
> +    mi_run_cmd
> +    mi_expect_stop "breakpoint-hit" "thread_started" ".*" "${srcfile}" ".*" {"" "disp=\"keep\""} "inferior 2 stops"
> +}
> +
> +proc test_thread_info_qualified_thread_id { } {
> +    setup
> +
> +    set expected [join \
> +	{ "111\\^done,threads=.*" \
> +	  "tg-id=\"1\",id-in-tg=\"1\",id=\"1\".*" \
> +	  "tg-id=\"1\",id-in-tg=\"2\",id=\"2\".*" \
> +	  "tg-id=\"2\",id-in-tg=\"1\",id=\"3\".*" \
> +	  "tg-id=\"2\",id-in-tg=\"2\",id=\"4\".*" \
> +	} ""]
> +
> +    mi_gdb_test \
> +	"111-thread-info" \
> +	 $expected \
> +	"thread ids in -thread-info"
> +}
> +
> +test_thread_info_qualified_thread_id
> diff --git a/gdb/thread.c b/gdb/thread.c
> index e45b25750e..29cfa61e13 100644
> --- a/gdb/thread.c
> +++ b/gdb/thread.c
> @@ -1247,7 +1247,7 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
>        uiout->table_header (1, ui_left, "current", "");
>
>        if (!uiout->is_mi_like_p ())
> -	uiout->table_header (4, ui_left, "id-in-tg", "Id");
> +	uiout->table_header (4, ui_left, "qualified-id", "Id");
>        if (show_global_ids || uiout->is_mi_like_p ())
>  	uiout->table_header (4, ui_left, "id", "GId");
>        uiout->table_header (17, ui_left, "target-id", "Target Id");
> @@ -1282,8 +1282,13 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
>  	    uiout->field_skip ("current");
>  	}
>
> -      if (!uiout->is_mi_like_p ())
> -	uiout->field_string ("id-in-tg", print_thread_id (tp));
> +      if (uiout->is_mi_like_p ())
> +	{
> +	  uiout->field_int ("tg-id", tp->inf->num);
> +	  uiout->field_int ("id-in-tg", tp->per_inf_num);
> +	}
> +      else
> +	uiout->field_string ("qualified-id", print_thread_id (tp));
>
>        if (show_global_ids || uiout->is_mi_like_p ())
>  	uiout->field_int ("id", tp->global_num);
>

FWIW, it sounds OK to me.

  reply	other threads:[~2017-01-19 14:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 14:42 Simon Marchi
2017-01-19 14:55 ` Luis Machado [this message]
2017-01-19 14:57   ` Simon Marchi
2017-02-20 16:18 ` Simon Marchi
2017-02-23 19:50   ` Pedro Alves
2017-02-24 20:22     ` Simon Marchi
2017-02-24 20:32       ` Simon Marchi
2017-03-15 21:36       ` Simon Marchi
2017-03-17 15:27         ` Pedro Alves
2017-03-17 15:26       ` Pedro Alves

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=b9c2d26c-d745-df26-4c8d-83138bf7df01@codesourcery.com \
    --to=lgustavo@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).