From patchwork Fri Jan 27 16:53:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=A9vin_Le_Gouguec?= X-Patchwork-Id: 63803 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1E3E385B51F for ; Fri, 27 Jan 2023 16:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1E3E385B51F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674838550; bh=WS9nyGvhE5pUDb7s7ifpol+T3DtWo5vedz12qI/tTGM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=D3cuNAyunKw0vSmh59LQKFjihNDwzFY2nf02tzPuN7kr+1Dwx3sWC3+k/uSRz64pX m6krP41IGzoINTrVmydXlCyCfIUKsuVsnN7wJDusF9+tp3qBYN+xO1WgFPPpabOscU DtvvBAQfaVvCaOhF28kLiAgd5oHuMBWZzOKvfPA0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 1F9E83858423 for ; Fri, 27 Jan 2023 16:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F9E83858423 Received: by mail-wm1-x332.google.com with SMTP id fl24so3905049wmb.1 for ; Fri, 27 Jan 2023 08:54:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WS9nyGvhE5pUDb7s7ifpol+T3DtWo5vedz12qI/tTGM=; b=5SHbH2E2uevye10DqkRexflRosptB5onqblo5l8pU0aZRiYCYE2KtFp91ruxSZ5FPl 4alkS+m3H7A3WfxVwfQv7Aea36G02TeW6Gq9MJcOkjXPCQeaJkgJ6RftJVfBqtlM1FFd gS6R+dM+vA2LQAptk4DOr+6rPcz8p3lf4b2zlxeBlIHL7zSFn8GOc1/RCugI60s8Xylb C6s8Ks+DrsJINA4yZheJ6VAGFu1VDIVTqRUYJyETXPeDU7Gd1W/PGcXh+Y6XN/1bAW0c EoOOANrBNIkqmX32xSoKSm3bQutHKJtfNCzHEfDjKTsljvrk7LVBXpwpcda4YHyJ12r7 qhcg== X-Gm-Message-State: AFqh2koBdw9rte+ZNxBcd9Oidk4Ih0PompVd9V1yudrgfStRLCHY+SA5 BzQXOI7+IfQh6ZmUnUF31Fw0TA1fFu1N6KMM X-Google-Smtp-Source: AMrXdXtfCCZrRqPA68fpeHdStqeOJXuVoM8i8ktJuXiKIrVXpqvBk4kIaJomkgtlSLdAaE/Bxjb1MQ== X-Received: by 2002:a05:600c:54eb:b0:3da:2090:d404 with SMTP id jb11-20020a05600c54eb00b003da2090d404mr41408830wmb.18.1674838484503; Fri, 27 Jan 2023 08:54:44 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:253:fe0:b0cf:cb2e:f4d5:6223]) by smtp.gmail.com with ESMTPSA id g9-20020a05600c308900b003db0dbbea53sm4590502wmn.30.2023.01.27.08.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 08:54:44 -0800 (PST) To: gdb-patches@sourceware.org Cc: simark@simark.ca, =?utf-8?q?K=C3=A9vin_Le_Gouguec?= Subject: [PATCH v2 1/3] gdb: Introduce ada-tasks.h for functions defined in ada-tasks.c Date: Fri, 27 Jan 2023 17:53:35 +0100 Message-Id: <20230127165337.1832937-2-legouguec@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127165337.1832937-1-legouguec@adacore.com> References: <87tu0ugxt7.fsf@adacore.com> <20230127165337.1832937-1-legouguec@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?K=C3=A9vin_Le_Gouguec_via_Gdb-patches?= From: =?utf-8?q?K=C3=A9vin_Le_Gouguec?= Reply-To: =?utf-8?q?K=C3=A9vin_Le_Gouguec?= Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Also move the documentation for these functions to the new header, instead of at the top of their definition, to align with our current practice. I tried to honor our guideline that .c files should not rely on indirect inclusion, hence I only removed #include "ada-lang.h" directives in .c files that, as far as I could tell, only rely on symbols declared in ada-tasks.h. --- gdb/ada-lang.h | 19 ---------- gdb/ada-tasks.c | 26 ++++---------- gdb/ada-tasks.h | 72 ++++++++++++++++++++++++++++++++++++++ gdb/breakpoint.c | 1 + gdb/guile/scm-breakpoint.c | 2 +- gdb/mi/mi-main.c | 2 +- gdb/python/py-breakpoint.c | 2 +- gdb/ravenscar-thread.c | 1 + 8 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 gdb/ada-tasks.h diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 9fb7ac7f384..e0d44756218 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -366,25 +366,6 @@ struct ada_exc_info extern std::vector ada_exceptions_list (const char *regexp); -/* Tasking-related: ada-tasks.c */ - -extern int valid_task_id (int); - -extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid); - -extern int ada_get_task_number (thread_info *thread); - -typedef gdb::function_view - ada_task_list_iterator_ftype; -extern void iterate_over_live_ada_tasks - (ada_task_list_iterator_ftype iterator); - -extern const char *ada_get_tcb_types_info (void); - -extern void print_ada_task_info (struct ui_out *uiout, - const char *taskno_str, - struct inferior *inf); - /* Look for a symbol for an overloaded operator for the operation OP. PARSE_COMPLETION is true if currently parsing for completion. NARGS and ARGVEC describe the arguments to the call. Returns a diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index a3a28063daa..bdabc0909cb 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -16,6 +16,7 @@ along with this program. If not, see . */ #include "defs.h" +#include "ada-tasks.h" #include "observable.h" #include "gdbcmd.h" #include "target.h" @@ -327,8 +328,7 @@ get_ada_tasks_inferior_data (struct inferior *inf) return data; } -/* Return the task number of the task whose thread is THREAD, or zero - if the task could not be found. */ +/* See ada-tasks.h. */ int ada_get_task_number (thread_info *thread) @@ -364,7 +364,7 @@ get_task_number_from_id (CORE_ADDR task_id, struct inferior *inf) return 0; } -/* Return non-zero if TASK_NUM is a valid task number. */ +/* See ada-tasks.h. */ int valid_task_id (int task_num) @@ -385,8 +385,7 @@ ada_task_is_alive (const struct ada_task_info *task_info) return (task_info->state != Terminated); } -/* Search through the list of known tasks for the one whose ptid is - PTID, and return it. Return NULL if the task was not found. */ +/* See ada-tasks.h. */ struct ada_task_info * ada_get_task_info_from_ptid (ptid_t ptid) @@ -405,8 +404,7 @@ ada_get_task_info_from_ptid (ptid_t ptid) return NULL; } -/* Call the ITERATOR function once for each Ada task that hasn't been - terminated yet. */ +/* See ada-tasks.h. */ void iterate_over_live_ada_tasks (ada_task_list_iterator_ftype iterator) @@ -490,14 +488,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len) dest[len] = '\0'; } -/* Get, from the debugging information, the type description of all types - related to the Ada Task Control Block that are needed in order to - read the list of known tasks in the Ada runtime. If all of the info - needed to do so is found, then save that info in the module's per- - program-space data, and return NULL. Otherwise, if any information - cannot be found, leave the per-program-space data untouched, and - return an error message explaining what was missing (that error - message does NOT need to be deallocated). */ +/* See ada-tasks.h. */ const char * ada_get_tcb_types_info (void) @@ -1056,10 +1047,7 @@ ada_build_task_list () return data->task_list.size (); } -/* Print a table providing a short description of all Ada tasks - running inside inferior INF. If ARG_STR is set, it will be - interpreted as a task number, and the table will be limited to - that task only. */ +/* See ada-tasks.h. */ void print_ada_task_info (struct ui_out *uiout, diff --git a/gdb/ada-tasks.h b/gdb/ada-tasks.h new file mode 100644 index 00000000000..5a948c27a44 --- /dev/null +++ b/gdb/ada-tasks.h @@ -0,0 +1,72 @@ +/* Helper routines for Ada tasking support in GBD. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +#ifndef ADA_TASKS_H +#define ADA_TASKS_H + +#include "gdbsupport/function-view.h" +#include "ada-lang.h" +#include "gdbthread.h" +#include "inferior.h" +#include "ui-out.h" + +/* Return non-zero if TASK_NUM is a valid task number. */ + +extern int valid_task_id (int task_num); + +/* Search through the list of known tasks for the one whose ptid is + PTID, and return it. Return NULL if the task was not found. */ + +extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid); + +/* Return the task number of the task whose thread is THREAD, or zero + if the task could not be found. */ + +extern int ada_get_task_number (thread_info *thread); + +typedef gdb::function_view + ada_task_list_iterator_ftype; + +/* Call the ITERATOR function once for each Ada task that hasn't been + terminated yet. */ + +extern void iterate_over_live_ada_tasks + (ada_task_list_iterator_ftype iterator); + +/* Get, from the debugging information, the type description of all types + related to the Ada Task Control Block that are needed in order to + read the list of known tasks in the Ada runtime. If all of the info + needed to do so is found, then save that info in the module's per- + program-space data, and return NULL. Otherwise, if any information + cannot be found, leave the per-program-space data untouched, and + return an error message explaining what was missing (that error + message does NOT need to be deallocated). */ + +extern const char *ada_get_tcb_types_info (void); + +/* Print a table providing a short description of all Ada tasks + running inside inferior INF. If ARG_STR is set, it will be + interpreted as a task number, and the table will be limited to + that task only. */ + +extern void print_ada_task_info (struct ui_out *uiout, + const char *taskno_str, + struct inferior *inf); + +#endif /* ADA_TASKS_H */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 00cc2ab401c..a21f8d5f8ae 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -52,6 +52,7 @@ #include "observable.h" #include "memattr.h" #include "ada-lang.h" +#include "ada-tasks.h" #include "top.h" #include "valprint.h" #include "jit.h" diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index a7e043d847b..6b7b91cd322 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -27,7 +27,7 @@ #include "gdbthread.h" #include "observable.h" #include "cli/cli-script.h" -#include "ada-lang.h" +#include "ada-tasks.h" #include "arch-utils.h" #include "language.h" #include "guile-internal.h" diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index e0cade2edc3..73f917f6071 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -46,7 +46,7 @@ #include "osdata.h" #include "gdbsupport/gdb_splay_tree.h" #include "tracepoint.h" -#include "ada-lang.h" +#include "ada-tasks.h" #include "linespec.h" #include "extension.h" #include "gdbcmd.h" diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 1b10ccd5415..5189b3af0ad 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -27,7 +27,7 @@ #include "gdbthread.h" #include "observable.h" #include "cli/cli-script.h" -#include "ada-lang.h" +#include "ada-tasks.h" #include "arch-utils.h" #include "language.h" #include "location.h" diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index 22fbdbe9662..57ac9634233 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -21,6 +21,7 @@ #include "gdbcore.h" #include "gdbthread.h" #include "ada-lang.h" +#include "ada-tasks.h" #include "target.h" #include "inferior.h" #include "command.h"