From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5038 invoked by alias); 5 Jul 2019 20:05:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5030 invoked by uid 89); 5 Jul 2019 20:05:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=foot, 20190609, 2019-06-08, Two X-HELO: mailsec106.isp.belgacom.be Received: from mailsec106.isp.belgacom.be (HELO mailsec106.isp.belgacom.be) (195.238.20.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 05 Jul 2019 20:05:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1562357139; x=1593893139; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=6QjjccsT/jV2vpaONg9ZAedzI+tqMZ/ciT8kpwwrUKQ=; b=GekNqfiecBmwCBRPSfrTa7Q0Rbe+grZE45g97h+O91VkS3a77D+Yprdi 77Y4fV1aB8Nqyzptu8M9V7pTzBR06w==; Received: from 96.218-128-109.adsl-dyn.isp.belgacom.be (HELO md) ([109.128.218.96]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 05 Jul 2019 22:05:37 +0200 Message-ID: <1562357137.1956.9.camel@skynet.be> Subject: PING Re: [RFA] Output the Ada task name in more messages. From: Philippe Waroquiers To: gdb-patches@sourceware.org Date: Fri, 05 Jul 2019 20:05:00 -0000 In-Reply-To: <20190609084637.14513-1-philippe.waroquiers@skynet.be> References: <20190609084637.14513-1-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg00181.txt.bz2 Ping ? Thanks Philippe On Sun, 2019-06-09 at 10:46 +0200, Philippe Waroquiers wrote: > With this patch, we e.g. get: > [Switching to task 2 task_list(1)] > [Current task is 2 task_list(1)] > instead of > [Switching to task 2] > [Current task is 2] > > This is just the Ada related changes in > https://sourceware.org/ml/gdb-patches/2019-05/msg00444.html > [RFA] Give thread names in thread events, give Ada task names in more output. > > Compared to the above, the logic to produce the taskno optionally followed > by the task name has been factorized in the task_to_str function. > > gdb/ChangeLog > 2019-06-08 Philippe Waroquiers > > * NEWS: Announce that Ada task names are now shown at more places. > * gdb/ada-tasks.c (task_to_str): New function. > (display_current_task_id): Call task_to_str. > (task_command_1): Likewise. > > gdb/doc/ChangeLog > 2019-06-08 Philippe Waroquiers > > * gdb.texinfo (Ada Tasks): Tell the task name is printed, update > examples. > --- > gdb/NEWS | 3 ++ > gdb/ada-tasks.c | 31 ++++++++++++++++--- > gdb/doc/gdb.texinfo | 8 ++--- > gdb/testsuite/gdb.ada/rdv_wait.exp | 2 +- > gdb/testsuite/gdb.ada/task_switch_in_core.exp | 2 +- > 5 files changed, 35 insertions(+), 11 deletions(-) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 9e1462b6bf..afb74cbb96 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -21,6 +21,9 @@ > * Two new convenience functions $_cimag and $_creal that extract the > imaginary and real parts respectively from complex numbers. > > +* GDB now shows the Ada task names at more places, e.g. in task switching > + messages. > + > * Python API > > ** The gdb.Value type has a new method 'format_string' which returns a > diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c > index 9c07f0ca22..a18aa2a55e 100644 > --- a/gdb/ada-tasks.c > +++ b/gdb/ada-tasks.c > @@ -240,6 +240,18 @@ struct ada_tasks_inferior_data > static const struct inferior_key > ada_tasks_inferior_data_handle; > > +/* Return a string with TASKNO followed by the task name if TASK_INFO > + contains a name. */ > + > +static std::string > +task_to_str (int taskno, const ada_task_info *task_info) > +{ > + if (task_info->name[0] == '\0') > + return string_printf ("%d", taskno); > + else > + return string_printf ("%d %s", taskno, task_info->name); > +} > + > /* Return the ada-tasks module's data for the given program space (PSPACE). > If none is found, add a zero'ed one now. > > @@ -1255,7 +1267,14 @@ display_current_task_id (void) > if (current_task == 0) > printf_filtered (_("[Current task is unknown]\n")); > else > - printf_filtered (_("[Current task is %d]\n"), current_task); > + { > + struct ada_tasks_inferior_data *data > + = get_ada_tasks_inferior_data (current_inferior ()); > + struct ada_task_info *task_info = &data->task_list[current_task - 1]; > + > + printf_filtered (_("[Current task is %s]\n"), > + task_to_str (current_task, task_info).c_str ()); > + } > } > > /* Parse and evaluate TIDSTR into a task id, and try to switch to > @@ -1274,7 +1293,8 @@ task_command_1 (const char *taskno_str, int from_tty, struct inferior *inf) > task_info = &data->task_list[taskno - 1]; > > if (!ada_task_is_alive (task_info)) > - error (_("Cannot switch to task %d: Task is no longer running"), taskno); > + error (_("Cannot switch to task %s: Task is no longer running"), > + task_to_str (taskno, task_info).c_str ()); > > /* On some platforms, the thread list is not updated until the user > performs a thread-related operation (by using the "info threads" > @@ -1295,13 +1315,14 @@ task_command_1 (const char *taskno_str, int from_tty, struct inferior *inf) > it's nicer for the user to just refuse to perform the task switch. */ > thread_info *tp = find_thread_ptid (task_info->ptid); > if (tp == NULL) > - error (_("Unable to compute thread ID for task %d.\n" > + error (_("Unable to compute thread ID for task %s.\n" > "Cannot switch to this task."), > - taskno); > + task_to_str (taskno, task_info).c_str ()); > > switch_to_thread (tp); > ada_find_printable_frame (get_selected_frame (NULL)); > - printf_filtered (_("[Switching to task %d]\n"), taskno); > + printf_filtered (_("[Switching to task %s]\n"), > + task_to_str (taskno, task_info).c_str ()); > print_stack_frame (get_selected_frame (NULL), > frame_relative_level (get_selected_frame (NULL)), > SRC_AND_LOC, 1); > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 0df345338e..393662da98 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -17369,7 +17369,7 @@ State: Runnable > @item task > @kindex task@r{ (Ada)} > @cindex current Ada task ID > -This command prints the ID of the current task. > +This command prints the ID and name of the current task. > > @smallexample > @iftex > @@ -17378,9 +17378,9 @@ This command prints the ID of the current task. > (@value{GDBP}) info tasks > ID TID P-ID Pri State Name > 1 8077870 0 15 Child Activation Wait main_task > -* 2 807c458 1 15 Runnable t > +* 2 807c458 1 15 Runnable some_task > (@value{GDBP}) task > -[Current task is 2] > +[Current task is 2 some_task] > @end smallexample > > @item task @var{taskno} > @@ -17396,7 +17396,7 @@ from the current task to the given task. > (@value{GDBP}) info tasks > ID TID P-ID Pri State Name > 1 8077870 0 15 Child Activation Wait main_task > -* 2 807c458 1 15 Runnable t > +* 2 807c458 1 15 Runnable some_task > (@value{GDBP}) task 1 > [Switching to task 1] > #0 0x8067726 in pthread_cond_wait () > diff --git a/gdb/testsuite/gdb.ada/rdv_wait.exp b/gdb/testsuite/gdb.ada/rdv_wait.exp > index c0c4e29f5f..fa309a1341 100644 > --- a/gdb/testsuite/gdb.ada/rdv_wait.exp > +++ b/gdb/testsuite/gdb.ada/rdv_wait.exp > @@ -31,5 +31,5 @@ runto "break_me" > # Switch to task 2, and verify that GDB is able to unwind all the way > # to foo.T. > gdb_test "task 2" \ > - [join {"\\\[Switching to task 2\\\].*" \ > + [join {"\\\[Switching to task 2 mit\\\].*" \ > ".*foo\\.t \\(.*\\).*foo\\.adb:.*"} ""] > diff --git a/gdb/testsuite/gdb.ada/task_switch_in_core.exp b/gdb/testsuite/gdb.ada/task_switch_in_core.exp > index 4c482834bc..f0ac8dbc98 100644 > --- a/gdb/testsuite/gdb.ada/task_switch_in_core.exp > +++ b/gdb/testsuite/gdb.ada/task_switch_in_core.exp > @@ -71,7 +71,7 @@ gdb_test "info tasks" \ > # we will verify right after with an additional test that the current > # task is now task 2. > gdb_test "task 2" \ > - "\\\[Switching to task 2\\\].*" > + "\\\[Switching to task 2 my_t\\\].*" > > gdb_test "info tasks" \ > [multi_line "\\s+ID\\s+TID\\s+P-ID\\s+Pri\\s+State\\s+Name" \