From patchwork Tue Nov 21 22:29:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 24433 Received: (qmail 38827 invoked by alias); 21 Nov 2017 22:29:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 38666 invoked by uid 89); 21 Nov 2017 22:29:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=!!!, SMP, smp, irrelevant X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Nov 2017 22:29:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A9B0911652A; Tue, 21 Nov 2017 17:29:28 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xX2Ia4pwqTfb; Tue, 21 Nov 2017 17:29:28 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7833B116523; Tue, 21 Nov 2017 17:29:28 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id BFAB38745B; Tue, 21 Nov 2017 14:29:26 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Xavier Roirand Subject: [Ada 2/6] Provide the "Base CPU" in output of "info task" (if set by runtime). Date: Tue, 21 Nov 2017 14:29:19 -0800 Message-Id: <20171121222923.8951-3-brobecker@adacore.com> In-Reply-To: <20171121222923.8951-1-brobecker@adacore.com> References: <20171121222923.8951-1-brobecker@adacore.com> At the user level, this patch enhances the debugger to print the ID of the base CPU a task is running on: (gdb) info task 3 Ada Task: 0x13268 Name: raven1 Thread: 0x13280 LWP: 0 !!!-> Base CPU: 1 No parent Base Priority: 127 State: Runnable This new field is only printed when the base CPU is nonzero or, in other words, if the base CPU info is being provided by the runtime. For instance, on native systems, where threads/processes can "jump" from CPU to CPU, the info is not available, and the output of the command above then remains unchanged. At the internal level, the real purpose of this change is to prepare the way for ravenscar-thread to start handling SMP systems. For that, we'll need to know which CPU each task is running on... More info on that in the commit that actually adds support for it. gdb/ChangeLog: * ada-lang.h (struct ada_task_info) : New field. * ada-lang.c (struct atcb_fieldno) : New field. (get_tcb_types_info): Set fieldnos.base_cpu. (read_atcb): Set task_info->base_cpu. (info_task): Print "Base CPU" info if set by runtime. --- gdb/ada-lang.h | 6 ++++++ gdb/ada-tasks.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index d15fbbdd42..c11fb48c1b 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -141,6 +141,12 @@ struct ada_task_info /* If the task is accepting a rendezvous with another task, this field contains the ID of the calling task. Zero otherwise. */ CORE_ADDR caller_task; + + /* The CPU on which the task is running. This is dependent on + the runtime actually providing that info, which is not always + the case. Normally, we should be able to count on it on + bare-metal targets. */ + int base_cpu; }; /* Assuming V points to an array of S objects, make sure that it contains at diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 1d5542d5d6..e29b563d6c 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -123,6 +123,7 @@ struct atcb_fieldnos int activation_link; int call; int ll; + int base_cpu; /* Fields in Task_Primitives.Private_Data. */ int ll_thread; @@ -535,6 +536,7 @@ get_tcb_types_info (void) "activation_link", 1); fieldnos.call = ada_get_field_index (common_type, "call", 1); fieldnos.ll = ada_get_field_index (common_type, "ll", 0); + fieldnos.base_cpu = ada_get_field_index (common_type, "base_cpu", 0); fieldnos.ll_thread = ada_get_field_index (ll_type, "thread", 0); fieldnos.ll_lwp = ada_get_field_index (ll_type, "lwp", 1); fieldnos.call_self = ada_get_field_index (call_type, "self", 0); @@ -748,6 +750,10 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info) } } + task_info->base_cpu + = value_as_long (value_field (common_value, + pspace_data->atcb_fieldno.base_cpu)); + /* And finally, compute the task ptid. Note that there are situations where this cannot be determined: - The task is no longer alive - the ptid is irrelevant; @@ -1179,6 +1185,10 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf) printf_filtered (_("Thread: %#lx\n"), ptid_get_tid (task_info->ptid)); printf_filtered (_("LWP: %#lx\n"), ptid_get_lwp (task_info->ptid)); + /* If set, print the base CPU. */ + if (task_info->base_cpu != 0) + printf_filtered (_("Base CPU: %d\n"), task_info->base_cpu); + /* Print who is the parent (if any). */ if (task_info->parent != 0) parent_taskno = get_task_number_from_id (task_info->parent, inf);