From patchwork Fri Oct 13 14:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 77671 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 9A2EF385B513 for ; Fri, 13 Oct 2023 14:47:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by sourceware.org (Postfix) with ESMTPS id AB5E3385C6EF for ; Fri, 13 Oct 2023 14:45:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB5E3385C6EF Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l9fYznCqNRWLGuAdeFpKzSjrDuSwdY5f+zBT8ABPdAdsOyKEC3zBIKGVMDqhHcPAsMVrHtHwxjAs+sL0NmAjbCIOdM4QxNLamCvBy8jgM0r6jD1gsAYDJfPFToKlaykgoavxGrNqR7mj4Z0KfgadKr0AHat/kk8K1BPKt9KuW2DDIj4CjU7Y3e9l5u9H7K2vpIqz7UYWZvyq4j3lTuCVBEgqYxU6kzXMOhwlhSnTG+n5ZFBsWxNsM8AXk7OIQ45cxoIE6tmwu4DI0NHCZu+hLXjpLMjLQo0oNnAWCeFB/iY9ZIF2FPyTWHrIyREvg43dwldT4BMZGtGipG6/vLnG0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R/bCcCW3gL/XJ/pG5SOzpfL14yCxdKtWKP5irkTidFw=; b=h3k4XkPrY8PkW8YrlCTeJSELDEcT7zYW2NNTxqmZxzgDjmZZMRYm4ncmSPc8XZMuvrbcy/Ncqfg+pgEg39W9wJNr/kXBVPdHC2Mxrzd2s/BAOGQHA9OsE3UsPgWVm9Yap+jjNRR9lfKZ8+GkSvHTcB5RbjfbfC9bCZVXyGn5hltO8TfXXswri83llBMrXMHbNAO9uiE5R8dMOmS1SPGhAJIBvDwCholWon787pgBOpJC6TpiO6y4uMSSxJSfpuhpLM2Cd0YIOJ0G0P1xcGLB7TxFnftNIROvuTUmH3l12YEk0c/NT7ReypfpRSWF6ZJC/aFe4p6Mcr0uOs4byNJrrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R/bCcCW3gL/XJ/pG5SOzpfL14yCxdKtWKP5irkTidFw=; b=H4sTXfZwTBPhS5O5RXrIXE5O12bo8gd6qQ2sLo7T3NY59UOEcLeEJ1dLQtV8JFs93FYXk4J6FdGZNzwyQtSQgU0T1IWT+//KPQYtJowEULkBg+4MzQn2CKdcr7VzceGncCa/SgbOKg1sy+BSX3jOX2A+mYJWSwwp2AQ2WMYvp7w= Received: from DM6PR11CA0035.namprd11.prod.outlook.com (2603:10b6:5:190::48) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 14:44:56 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::bd) by DM6PR11CA0035.outlook.office365.com (2603:10b6:5:190::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 14:44:56 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 13 Oct 2023 09:44:55 -0500 From: Lancelot Six To: CC: Lancelot Six Subject: [PATCH 04/11] gdb: Replace gdb::optional with std::optional Date: Fri, 13 Oct 2023 14:44:11 +0000 Message-ID: <20231013144418.3180617-5-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com> References: <20231013144418.3180617-1-lancelot.six@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f3bfcef-a4d9-4f9a-cee5-08dbcbfaf818 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3edsG1sSOugbGdB7W7G9eYJVlsjbXSFzZz5IzEMVvGCflRXbTk9U//uuvcstQi4V+pIL6Gt6X2ISpvO8btFiXuitGsxw34sdm13V6SAt0V6DP/0fjZMqkRF7qIAeCFyrY1q1KP5wIYukMNt0KyDntB5uOoI2TlQFdoC0o4Dsl1hFM8hnQ7cxyCS+vFOfydtJxzlWj0AfSIoAeLeHdmzpfu9cHBkDMVpLgegwWdkc7m5ACpmQQ1r4OXyHZOEbwdBjhnDw6K8MsPLRsKtyHLF3UCHgVTZfmOpTqQi1NJXvprK548TA1lP1n255mHn0esumHQf6NUVYWGieBksoZGpEzp8nlrSaKGEV17C14WrbWQI03qF6r8YxoePKjow970pn79YLpV469JVN4KmO0HA2igpvVQ2VZEq1aTAXR3IoOsqIdtohq7vqG3SLWUOF/qCS0kH1lpApLgM+QRLt7pk0bHGF/hKd1ooU9PDT0z/R5xHG990pk3wi1e/wDwbMvQ6qdTT4eqOaaNwNS10MpCoyWM/fZLd9OQfeCgBX5ETyj4EP5xV/ZV03+Bc4f0LcyTuMa7DpD1tlMHjkskgD+ZGsXJRdydHGl8DWepma+lsPgM1tAw1mo/qHL+WfftlvyMkUeG0M9hJ856kSvo3lUb8+O8BrPAZLjkv3ajM902uBtjAu89f+o6WuqA0VeTKuMMnWkpk0jkilRkuZDby3o6Oaxlc45dp3mvTyD1JnZCXWJAWcjox0DtEfY1E+9wV2mTN7qsS2oxeEnSiq0jkFKr6oxVEgUKfeU8xhD/yJ+aLaLEAOT4ynGBg/p2hPtQSkpxO4yNpkbXMZ3q1yXQEX4eDQww== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(230922051799003)(64100799003)(186009)(451199024)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(8936002)(8676002)(4326008)(5660300002)(44832011)(6916009)(40480700001)(70206006)(70586007)(41300700001)(316002)(40460700003)(66899024)(47076005)(81166007)(356005)(82740400003)(1076003)(36756003)(336012)(16526019)(26005)(426003)(2616005)(86362001)(6666004)(30864003)(478600001)(2906002)(83380400001)(7696005)(36860700001)(403724002)(36900700001)(579004)(559001)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 14:44:56.6288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f3bfcef-a4d9-4f9a-cee5-08dbcbfaf818 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_FILL_THIS_FORM_SHORT 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Since GDB now requires C++17, we don't need the internally maintained gdb::optional implementation. This patch does the following replacing: - gdb::optional -> std::optional - gdb::in_place -> std::in_place - #include "gdbsupport/gdb_optional.h" -> #include This change has mostly been done automatically. One exception is gdbsupport/thread-pool.* which did not use the gdb:: prefix as it already lives in the gdb namespace. Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9 --- gdb/aarch64-linux-tdep.c | 10 +++++----- gdb/ada-lang.c | 6 +++--- gdb/ada-lex.l | 2 +- gdb/ada-valprint.c | 4 ++-- gdb/amd-dbgapi-target.c | 4 ++-- gdb/annotate.c | 2 +- gdb/arm-fbsd-tdep.c | 6 +++--- gdb/arm-fbsd-tdep.h | 2 +- gdb/arm-linux-tdep.c | 2 +- gdb/arm-tdep.c | 4 ++-- gdb/auto-load.c | 2 +- gdb/auxv.c | 10 +++++----- gdb/auxv.h | 4 ++-- gdb/avr-tdep.c | 2 +- gdb/breakpoint.c | 19 ++++++++++--------- gdb/buildsym.c | 2 +- gdb/cli/cli-cmds.c | 6 +++--- gdb/cli/cli-cmds.h | 4 ++-- gdb/cli/cli-decode.c | 4 ++-- gdb/cli/cli-decode.h | 2 +- gdb/cli/cli-option.c | 14 +++++++------- gdb/cli/cli-option.h | 2 +- gdb/command.h | 2 +- gdb/compile/compile.c | 4 ++-- gdb/darwin-nat.c | 2 +- gdb/debuginfod-support.c | 10 +++++----- gdb/disasm.c | 14 +++++++------- gdb/disasm.h | 2 +- gdb/dwarf2/attribute.h | 2 +- gdb/dwarf2/cu.h | 8 ++++---- gdb/dwarf2/die.h | 4 ++-- gdb/dwarf2/index-cache.h | 2 +- gdb/dwarf2/index-write.c | 4 ++-- gdb/dwarf2/line-header.c | 4 ++-- gdb/dwarf2/macro.c | 4 ++-- gdb/dwarf2/macro.h | 2 +- gdb/dwarf2/read-gdb-index.c | 4 ++-- gdb/dwarf2/read.c | 24 ++++++++++++------------ gdb/dwarf2/read.h | 2 +- gdb/eval.c | 2 +- gdb/event-top.c | 2 +- gdb/exceptions.c | 4 ++-- gdb/extension-priv.h | 6 +++--- gdb/extension.c | 12 ++++++------ gdb/extension.h | 8 ++++---- gdb/f-lang.c | 2 +- gdb/fbsd-nat.c | 6 +++--- gdb/fbsd-nat.h | 4 ++-- gdb/fbsd-tdep.c | 8 ++++---- gdb/gdbthread.h | 8 ++++---- gdb/gdbtypes.c | 18 +++++++++--------- gdb/gdbtypes.h | 8 ++++---- gdb/guile/scm-ports.c | 4 ++-- gdb/ia64-tdep.c | 4 ++-- gdb/inf-child.c | 2 +- gdb/inf-child.h | 2 +- gdb/infcmd.c | 4 ++-- gdb/inferior.c | 4 ++-- gdb/inferior.h | 2 +- gdb/inflow.c | 4 ++-- gdb/infrun.c | 12 ++++++------ gdb/interps.c | 2 +- gdb/interps.h | 4 ++-- gdb/jit.c | 2 +- gdb/linux-nat.c | 4 ++-- gdb/linux-nat.h | 2 +- gdb/linux-tdep.c | 18 +++++++++--------- gdb/linux-tdep.h | 4 ++-- gdb/linux-thread-db.c | 2 +- gdb/main.c | 4 ++-- gdb/mi/mi-cmd-stack.c | 4 ++-- gdb/mi/mi-cmd-var.c | 2 +- gdb/mi/mi-cmds.c | 2 +- gdb/mi/mi-cmds.h | 8 ++++---- gdb/mi/mi-interp.c | 2 +- gdb/mi/mi-interp.h | 2 +- gdb/mi/mi-main.c | 12 ++++++------ gdb/nat/linux-osdata.c | 8 ++++---- gdb/nat/windows-nat.c | 6 +++--- gdb/nat/windows-nat.h | 4 ++-- gdb/observable.h | 2 +- gdb/osdata.c | 2 +- gdb/parse.c | 4 ++-- gdb/ppc-linux-nat.c | 4 ++-- gdb/ppc-linux-tdep.c | 2 +- gdb/ppc-tdep.h | 2 +- gdb/printcmd.c | 6 +++--- gdb/probe.c | 22 +++++++++++----------- gdb/procfs.c | 2 +- gdb/psymtab.c | 2 +- gdb/psymtab.h | 2 +- gdb/python/py-disasm.c | 22 +++++++++++----------- gdb/python/py-framefilter.c | 10 +++++----- gdb/python/py-inferior.c | 2 +- gdb/python/py-mi.c | 2 +- gdb/python/py-utils.c | 4 ++-- gdb/python/python-internal.h | 4 ++-- gdb/python/python.c | 8 ++++---- gdb/ravenscar-thread.c | 4 ++-- gdb/record-btrace.c | 8 ++++---- gdb/regcache.c | 4 ++-- gdb/remote.c | 16 ++++++++-------- gdb/riscv-tdep.c | 2 +- gdb/s390-linux-tdep.c | 2 +- gdb/skip.c | 4 ++-- gdb/solib-aix.c | 14 +++++++------- gdb/solib-dsbt.c | 2 +- gdb/solib-svr4.c | 16 ++++++++-------- gdb/solib-target.c | 2 +- gdb/source-cache.c | 2 +- gdb/stack.c | 16 ++++++++-------- gdb/stack.h | 2 +- gdb/symfile.c | 2 +- gdb/symtab.c | 24 ++++++++++++------------ gdb/symtab.h | 24 ++++++++++++------------ gdb/target.c | 16 ++++++++-------- gdb/target.h | 10 +++++----- gdb/thread.c | 14 +++++++------- gdb/tracefile-tfile.c | 2 +- gdb/tracepoint.c | 2 +- gdb/tui/tui-disasm.c | 2 +- gdb/tui/tui-layout.c | 2 +- gdb/unittests/optional-selftests.c | 4 ++-- gdb/utils.c | 6 +++--- gdb/valarith.c | 4 ++-- gdb/valops.c | 6 +++--- gdb/value.c | 2 +- gdb/value.h | 4 ++-- gdb/windows-nat.c | 10 +++++----- gdb/xml-support.c | 4 ++-- gdb/xml-support.h | 6 +++--- gdb/xml-syscall.c | 2 +- gdb/xml-tdesc.c | 12 ++++++------ gdb/xml-tdesc.h | 4 ++-- gdbserver/linux-aarch64-low.cc | 4 ++-- gdbserver/regcache.cc | 4 ++-- gdbserver/regcache.h | 2 +- gdbserver/win32-low.cc | 2 +- gdbsupport/common-debug.h | 4 ++-- gdbsupport/event-loop.cc | 6 +++--- gdbsupport/filestuff.cc | 2 +- gdbsupport/filestuff.h | 2 +- gdbsupport/forward-scope-exit.h | 6 +++--- gdbsupport/range-chain.h | 2 +- gdbsupport/scoped_ignore_sigttou.h | 2 +- gdbsupport/thread-pool.cc | 2 +- gdbsupport/thread-pool.h | 4 ++-- 147 files changed, 413 insertions(+), 412 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index f1fcce9b9eb..cd99b33fed2 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1609,7 +1609,7 @@ static const struct target_desc * aarch64_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); CORE_ADDR hwcap2 = linux_get_hwcap2 (auxv, target, gdbarch); @@ -2427,7 +2427,7 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch) Return the allocation tag if successful and nullopt otherwise. */ -static gdb::optional +static std::optional aarch64_mte_get_atag (CORE_ADDR address) { gdb::byte_vector tags; @@ -2481,7 +2481,7 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch, CORE_ADDR addr = value_as_address (address); /* Fetch the allocation tag for ADDRESS. */ - gdb::optional atag + std::optional atag = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr)); if (!atag.has_value ()) @@ -2579,7 +2579,7 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address, /* Remove the top byte. */ addr = gdbarch_remove_non_address_bits (gdbarch, addr); - gdb::optional atag = aarch64_mte_get_atag (addr); + std::optional atag = aarch64_mte_get_atag (addr); if (!atag.has_value ()) return nullptr; @@ -2651,7 +2651,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, uiout->field_core_addr ("fault-addr", gdbarch, fault_addr); uiout->text ("\n"); - gdb::optional atag + std::optional atag = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, fault_addr)); gdb_byte ltag = aarch64_mte_get_ltag (fault_addr); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9bb649e901d..58c70160d31 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3098,7 +3098,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, type0->dyn_prop (DYN_PROP_BYTE_STRIDE), type0->field (0).bitsize ()); int base_low = ada_discrete_type_low_bound (type0->index_type ()); - gdb::optional base_low_pos, low_pos; + std::optional base_low_pos, low_pos; CORE_ADDR base; low_pos = discrete_position (base_index_type, low); @@ -3132,7 +3132,7 @@ ada_value_slice (struct value *array, int low, int high) (alloc, type->target_type (), index_type, type->dyn_prop (DYN_PROP_BYTE_STRIDE), type->field (0).bitsize ()); - gdb::optional low_pos, high_pos; + std::optional low_pos, high_pos; low_pos = discrete_position (base_index_type, low); @@ -8792,7 +8792,7 @@ pos_atr (struct value *arg) if (!discrete_type_p (type)) error (_("'POS only defined on discrete types")); - gdb::optional result = discrete_position (type, value_as_long (val)); + std::optional result = discrete_position (type, value_as_long (val)); if (!result.has_value ()) error (_("enumeration value is invalid: can't find 'POS")); diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 0547b704eaf..0576f361a42 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -713,7 +713,7 @@ processAttribute (const char *str) if (strcasecmp (str, item.name) == 0) return item.code; - gdb::optional found; + std::optional found; for (const auto &item : attributes) if (subseqMatch (str, item.name)) { diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index b32f1e506d1..f1c4e8b0b70 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -385,7 +385,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream) case TYPE_CODE_ENUM: { - gdb::optional posn = discrete_position (type, val); + std::optional posn = discrete_position (type, val); if (posn.has_value ()) fputs_styled (ada_enum_name (type->field (*posn).name ()), variable_name_style.style (), stream); @@ -827,7 +827,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; val = unpack_long (type, valaddr + offset_aligned); - gdb::optional posn = discrete_position (type, val); + std::optional posn = discrete_position (type, val); if (posn.has_value ()) { const char *name = ada_enum_name (type->field (*posn).name ()); diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index 22c81262876..a19d6d0fc95 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -528,7 +528,7 @@ amd_dbgapi_target::xfer_partial (enum target_object object, const char *annex, ULONGEST offset, ULONGEST requested_len, ULONGEST *xfered_len) { - gdb::optional maybe_restore_thread; + std::optional maybe_restore_thread; if (!ptid_is_gpu (inferior_ptid)) return beneath ()->xfer_partial (object, annex, readbuf, writebuf, offset, @@ -1901,7 +1901,7 @@ static void amd_dbgapi_log_message_callback (amd_dbgapi_log_level_t level, const char *message) { - gdb::optional tstate; + std::optional tstate; if (target_supports_terminal_ours ()) { diff --git a/gdb/annotate.c b/gdb/annotate.c index 8385429042d..f3ead9e3ce2 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -233,7 +233,7 @@ annotate_thread_changed (void) static void annotate_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, bool /* silent */) { if (annotation_level > 1) diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index b6aa42a4fd0..03264f744a2 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -215,7 +215,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, /* See arm-fbsd-tdep.h. */ const struct target_desc * -arm_fbsd_read_description_auxv (const gdb::optional &auxv, +arm_fbsd_read_description_auxv (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, bool tls) { CORE_ADDR arm_hwcap = 0; @@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional &auxv, const struct target_desc * arm_fbsd_read_description_auxv (bool tls) { - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); return arm_fbsd_read_description_auxv (auxv, current_inferior ()->top_target (), current_inferior ()->arch (), @@ -260,7 +260,7 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch, { asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls"); - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); return arm_fbsd_read_description_auxv (auxv, target, gdbarch, tls != nullptr); } diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h index 3478e4b6860..7eb1850c1a7 100644 --- a/gdb/arm-fbsd-tdep.h +++ b/gdb/arm-fbsd-tdep.h @@ -47,7 +47,7 @@ extern const struct regset arm_fbsd_tls_regset; AUXV. */ extern const struct target_desc * - arm_fbsd_read_description_auxv (const gdb::optional &auxv, + arm_fbsd_read_description_auxv (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, bool tls); diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index dfa816990ff..4c0f7816d61 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -732,7 +732,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR arm_hwcap = linux_get_hwcap (auxv, target, gdbarch); if (arm_hwcap & HWCAP_VFP) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a0ad1fb7a82..58c550af183 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -302,7 +302,7 @@ struct arm_prologue_cache int framereg; /* True if the return address is signed, false otherwise. */ - gdb::optional ra_signed_state; + std::optional ra_signed_state; /* Saved register offsets. */ trad_frame_saved_reg *saved_regs; @@ -1035,7 +1035,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, while (start < limit) { unsigned short insn; - gdb::optional ra_signed_state; + std::optional ra_signed_state; insn = read_code_unsigned_integer (start, 2, byte_order_for_code); diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 8bbe6696dcc..daea75b7437 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -914,7 +914,7 @@ source_script_file (struct auto_load_pspace_info *pspace_info, return; } - gdb::optional opened = find_and_open_script (file, + std::optional opened = find_and_open_script (file, 1 /*search_path*/); if (opened) diff --git a/gdb/auxv.c b/gdb/auxv.c index 61acd48fc98..994d97c1a2c 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -331,7 +331,7 @@ parse_auxv (target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr, overhead of transfering data from a remote target to the local host. */ struct auxv_info { - gdb::optional data; + std::optional data; }; /* Per-inferior data key for auxv. */ @@ -357,7 +357,7 @@ auxv_all_objfiles_removed (program_space *pspace) /* See auxv.h. */ -const gdb::optional & +const std::optional & target_read_auxv () { inferior *inf = current_inferior (); @@ -374,7 +374,7 @@ target_read_auxv () /* See auxv.h. */ -gdb::optional +std::optional target_read_auxv_raw (target_ops *ops) { return target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL); @@ -413,7 +413,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops, int target_auxv_search (CORE_ADDR match, CORE_ADDR *valp) { - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); if (!auxv.has_value ()) return -1; @@ -572,7 +572,7 @@ fprint_target_auxv (struct ui_file *file) gdbarch *gdbarch = current_inferior ()->arch (); CORE_ADDR type, val; int ents = 0; - const gdb::optional &auxv = target_read_auxv (); + const std::optional &auxv = target_read_auxv (); if (!auxv.has_value ()) return -1; diff --git a/gdb/auxv.h b/gdb/auxv.h index a920f7a5da8..10f31dc84e8 100644 --- a/gdb/auxv.h +++ b/gdb/auxv.h @@ -48,11 +48,11 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr, /* Read auxv data from the current inferior's target stack. */ -extern const gdb::optional &target_read_auxv (); +extern const std::optional &target_read_auxv (); /* Read auxv data from OPS. */ -extern gdb::optional target_read_auxv_raw (target_ops *ops); +extern std::optional target_read_auxv_raw (target_ops *ops); /* Search AUXV for an entry with a_type matching MATCH. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 92aec3b510f..598d740883c 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1566,7 +1566,7 @@ avr_io_reg_read_command (const char *args, int from_tty) unsigned int val; /* Find out how many io registers the target has. */ - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AVR, "avr.io_reg"); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2edcbf6d490..1cc2dfbe66e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -82,7 +82,7 @@ #include #include "progspace-and-thread.h" #include "gdbsupport/array-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/common-utils.h" /* Prototypes for local functions. */ @@ -2067,7 +2067,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) if (b->disposition == disp_del_at_next_stop) return; - gdb::optional restore_frame; + std::optional restore_frame; /* Determine if the watchpoint is within scope. */ if (b->exp_valid_block == NULL) @@ -3365,7 +3365,7 @@ remove_breakpoints (void) static void remove_threaded_breakpoints (thread_info *tp, - gdb::optional /* exit_code */, + std::optional /* exit_code */, int /* silent */) { for (breakpoint &b : all_breakpoints_safe ()) @@ -6780,8 +6780,8 @@ print_one_breakpoint_location (struct breakpoint *b, (uiout->test_flags (fix_breakpoint_script_output) || fix_breakpoint_script_output_globally); - gdb::optional tuple_emitter; - gdb::optional list_emitter; + std::optional tuple_emitter; + std::optional list_emitter; if (use_fixed_output) list_emitter.emplace (uiout, "script"); @@ -6854,7 +6854,8 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag) = (uiout->test_flags (fix_multi_location_breakpoint_output) || fix_multi_location_breakpoint_output_globally); - gdb::optional bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt"); + std::optional bkpt_tuple_emitter (std::in_place, uiout, + "bkpt"); bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc, allflag, false); @@ -6889,7 +6890,7 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag) || !b->first_loc ().enabled || b->first_loc ().disabled_by_cond)))) { - gdb::optional locations_list; + std::optional locations_list; /* For MI version <= 2, keep the behavior where GDB outputs an invalid MI record. For later versions, place breakpoint locations in a @@ -9954,7 +9955,7 @@ watchpoint::print_it (const bpstat *bs) const string_file stb; - gdb::optional tuple_emitter; + std::optional tuple_emitter; switch (this->type) { case bp_watchpoint: @@ -10932,7 +10933,7 @@ until_break_command (const char *arg, int from_tty, int anywhere) std::vector breakpoints; - gdb::optional lj_deleter; + std::optional lj_deleter; if (frame_id_p (caller_frame_id)) { diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b982afea3d2..32d60cc22d4 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -643,7 +643,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line, anyway. */ if (line == 0) { - gdb::optional last_line; + std::optional last_line; while (!subfile->line_vector_entries.empty ()) { diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 8cadd637151..49952eaca6a 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -655,12 +655,12 @@ show_script_ext_mode (struct ui_file *file, int from_tty, If SEARCH_PATH is non-zero, and the file isn't found in cwd, search for it in the source search path. */ -gdb::optional +std::optional find_and_open_script (const char *script_file, int search_path) { int fd; openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; - gdb::optional opened; + std::optional opened; gdb::unique_xmalloc_ptr file (tilde_expand (script_file)); @@ -742,7 +742,7 @@ source_script_with_search (const char *file, int from_tty, int search_path) if (file == NULL || *file == 0) error (_("source command requires file name of file to source.")); - gdb::optional opened = find_and_open_script (file, search_path); + std::optional opened = find_and_open_script (file, search_path); if (!opened) { /* The script wasn't found, or was otherwise inaccessible. diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index 429574426ac..a2579dc25f2 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -18,7 +18,7 @@ #define CLI_CLI_CMDS_H #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb_optional.h" +#include #include "completer.h" /* Chain containing all defined commands. */ @@ -179,7 +179,7 @@ struct open_script } }; -extern gdb::optional +extern std::optional find_and_open_script (const char *file, int search_path); /* Command tracing state. */ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0bbe96b5334..940cd6a2c8e 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -24,7 +24,7 @@ #include "cli/cli-cmds.h" #include "cli/cli-decode.h" #include "cli/cli-style.h" -#include "gdbsupport/gdb_optional.h" +#include /* Prototypes for local functions. */ @@ -2727,7 +2727,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) { if (!cmd->is_command_class_help ()) { - gdb::optional> restore_suppress; + std::optional> restore_suppress; if (cmd->suppress_notification != NULL) restore_suppress.emplace (cmd->suppress_notification, true); diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 8fe9325c2da..14d9c29b464 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -233,7 +233,7 @@ struct cmd_list_element void (*destroyer) (struct cmd_list_element *self, void *context) = nullptr; /* Setting affected by "set" and "show". Not used if type is not_set_cmd. */ - gdb::optional var; + std::optional var; /* Pointer to NULL terminated list of enumerated values (like argv). */ diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 9b303b1304e..d2d489b7219 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -58,11 +58,11 @@ struct option_def_and_value void *ctx; /* The option's value, if any. */ - gdb::optional value; + std::optional value; /* Constructor. */ option_def_and_value (const option_def &option_, void *ctx_, - gdb::optional &&value_ = {}) + std::optional &&value_ = {}) : option (option_), ctx (ctx_), value (std::move (value_)) @@ -99,7 +99,7 @@ struct option_def_and_value allocated on the heap, so we must clear the pointer in the source, to avoid a double free. */ static void clear_value (const option_def &option, - gdb::optional &value) + std::optional &value) { if (value.has_value ()) { @@ -109,7 +109,7 @@ struct option_def_and_value } }; -static void save_option_value_in_ctx (gdb::optional &ov); +static void save_option_value_in_ctx (std::optional &ov); /* Info passed around when handling completion. */ struct parse_option_completion_info @@ -177,7 +177,7 @@ complete_on_all_options (completion_tracker &tracker, /* Parse ARGS, guided by OPTIONS_GROUP. HAVE_DELIMITER is true if the whole ARGS line included the "--" options-terminator delimiter. */ -static gdb::optional +static std::optional parse_option (gdb::array_view options_group, process_options_mode mode, bool have_delimiter, @@ -496,7 +496,7 @@ complete_options (completion_tracker &tracker, } else if (**args == '-') { - gdb::optional ov + std::optional ov = parse_option (options_group, mode, have_delimiter, args, &completion_info); if (!ov && !tracker.have_completions ()) @@ -589,7 +589,7 @@ complete_options (completion_tracker &tracker, /* Save the parsed value in the option's context. */ static void -save_option_value_in_ctx (gdb::optional &ov) +save_option_value_in_ctx (std::optional &ov) { switch (ov->option.type) { diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 7b015b89f47..4c62227f31c 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -20,7 +20,7 @@ #ifndef CLI_OPTION_H #define CLI_OPTION_H 1 -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/array-view.h" #include "completer.h" #include diff --git a/gdb/command.h b/gdb/command.h index 467bb283cdc..1ab953b996b 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -126,7 +126,7 @@ struct literal_def LONGEST use; /* An optional number accepted that stands for the literal. */ - gdb::optional val; + std::optional val; }; /* Return true if a setting of type VAR_TYPE is backed with type T. diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index a93c9404660..be1bcca47b4 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -40,7 +40,7 @@ #include "osabi.h" #include "gdbsupport/gdb_wait.h" #include "valprint.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb_unlinker.h" #include "gdbsupport/pathstuff.h" #include "gdbsupport/scoped_ignore_signal.h" @@ -768,7 +768,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, compile_file_names fnames = get_new_file_names (); - gdb::optional source_remover; + std::optional source_remover; { gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w"); diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 588e9e2a345..af0a360d8ca 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1967,7 +1967,7 @@ darwin_nat_target::create_inferior (const char *exec_file, const std::string &allargs, char **env, int from_tty) { - gdb::optional> restore_startup_with_shell; + std::optional> restore_startup_with_shell; darwin_nat_target *the_target = this; if (startup_with_shell && may_have_sip ()) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 902af405cc6..1ebd98ca705 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -21,7 +21,7 @@ #include #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cli/cli-cmds.h" #include "cli/cli-style.h" #include "cli-out.h" @@ -320,7 +320,7 @@ debuginfod_source_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("source file", srcpath); @@ -366,7 +366,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("separate debug info for", filename); @@ -409,7 +409,7 @@ debuginfod_exec_query (const unsigned char *build_id, char *dname = nullptr; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data ("executable for", filename); @@ -458,7 +458,7 @@ debuginfod_section_query (const unsigned char *build_id, char *dname = nullptr; std::string desc = std::string ("section ") + section_name + " for"; scoped_fd fd; - gdb::optional term_state; + std::optional term_state; { user_data data (desc.c_str (), filename); diff --git a/gdb/disasm.c b/gdb/disasm.c index 2e866f6865e..82b7e990ff9 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -29,7 +29,7 @@ #include "source.h" #include "gdbsupport/gdb-safe-ctype.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "valprint.h" #include "cli/cli-style.h" #include "objfiles.h" @@ -653,8 +653,8 @@ do_mixed_source_and_assembly_deprecated ui_out_emit_list asm_insns_list (uiout, "asm_insns"); - gdb::optional outer_tuple_emitter; - gdb::optional inner_list_emitter; + std::optional outer_tuple_emitter; + std::optional inner_list_emitter; for (i = 0; i < newlines; i++) { @@ -810,8 +810,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, ui_out_emit_list asm_insns_emitter (uiout, "asm_insns"); - gdb::optional tuple_emitter; - gdb::optional list_emitter; + std::optional tuple_emitter; + std::optional list_emitter; last_symtab = NULL; last_line = 0; @@ -1093,7 +1093,7 @@ gdb_print_insn_1 (struct gdbarch *gdbarch, CORE_ADDR vma, struct disassemble_info *info) { /* Call into the extension languages to do the disassembly. */ - gdb::optional length = ext_lang_print_insn (gdbarch, vma, info); + std::optional length = ext_lang_print_insn (gdbarch, vma, info); if (length.has_value ()) return *length; @@ -1125,7 +1125,7 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr, this output. */ if (length > 0 && use_ext_lang_for_styling ()) { - gdb::optional ext_contents; + std::optional ext_contents; ext_contents = ext_lang_colorize_disasm (m_buffer.string (), arch ()); if (ext_contents.has_value ()) m_buffer = std::move (*ext_contents); diff --git a/gdb/disasm.h b/gdb/disasm.h index dbc63e52ed2..5596bd62a10 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -275,7 +275,7 @@ struct gdb_disassembler : public gdb_printing_disassembler, negative value (which indicates an error), then, if this variable has a value, we report a memory error to the user, otherwise, we report a non-memory error. */ - gdb::optional m_err_memaddr; + std::optional m_err_memaddr; /* The stream to which disassembler output will be written. */ ui_file *m_dest; diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 4cfdaa1e355..fdb579a368a 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -29,7 +29,7 @@ #include "dwarf2.h" #include "dwarf2/types.h" -#include "gdbsupport/gdb_optional.h" +#include /* Blocks are a bunch of untyped bytes. */ struct dwarf_block diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 0c15d8b02db..d57f3683a9a 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -22,7 +22,7 @@ #include "buildsym.h" #include "dwarf2/comp-unit-head.h" -#include "gdbsupport/gdb_optional.h" +#include #include "language.h" /* Type used for delaying computation of method physnames. @@ -101,7 +101,7 @@ struct dwarf2_cu struct comp_unit_head header; /* Base address of this compilation unit. */ - gdb::optional base_address; + std::optional base_address; /* The language we are debugging. */ const struct language_defn *language_defn = nullptr; @@ -189,7 +189,7 @@ struct dwarf2_cu /* The DW_AT_addr_base (DW_AT_GNU_addr_base) attribute if present. Note this value comes from the Fission stub CU/TU's DIE. */ - gdb::optional addr_base; + std::optional addr_base; /* The DW_AT_GNU_ranges_base attribute, if present. @@ -242,7 +242,7 @@ struct dwarf2_cu files, the value is implicitly zero. For DWARF 5 version DWO files, the value is often implicit and is the size of the header of .debug_str_offsets section (8 or 4, depending on the address size). */ - gdb::optional str_offsets_base; + std::optional str_offsets_base; /* Mark used when releasing cached dies. */ bool m_mark : 1; diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h index cdee46996d6..c7040776b07 100644 --- a/gdb/dwarf2/die.h +++ b/gdb/dwarf2/die.h @@ -59,7 +59,7 @@ struct die_info /* Return the address base of the compile unit, which, if exists, is stored either at the attribute DW_AT_GNU_addr_base, or DW_AT_addr_base. */ - gdb::optional addr_base () + std::optional addr_base () { for (unsigned i = 0; i < num_attrs; ++i) if (attrs[i].name == DW_AT_addr_base @@ -73,7 +73,7 @@ struct die_info complaint (_("address base attribute (offset %s) as wrong form"), sect_offset_str (sect_off)); } - return gdb::optional (); + return std::optional (); } /* Return the base address of the compile unit into the .debug_ranges section, diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index cfa45435fbd..023fc86fc89 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -52,7 +52,7 @@ struct index_cache_store_context std::string build_id_str; /* Captured value of dwz build id. */ - gdb::optional dwz_build_id_str; + std::optional dwz_build_id_str; }; /* Class to manage the access to the DWARF index cache. */ diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 6ea4217fb22..a6d770c9ee5 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1473,7 +1473,7 @@ struct index_wip_file FILENAME_TEMP is unlinked, because on MS-Windows one cannot delete a file that is still open. So, we wrap the unlinker in an optional and emplace it once we know the file name. */ - gdb::optional unlink_file; + std::optional unlink_file; gdb_file_up out_file; }; @@ -1496,7 +1496,7 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir, ? INDEX5_SUFFIX : INDEX4_SUFFIX); index_wip_file objfile_index_wip (dir, basename, index_suffix); - gdb::optional dwz_index_wip; + std::optional dwz_index_wip; if (dwz_basename != NULL) dwz_index_wip.emplace (dir, dwz_basename, index_suffix); diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index d072a91bac9..ddaf7e4a527 100644 --- a/gdb/dwarf2/line-header.c +++ b/gdb/dwarf2/line-header.c @@ -160,8 +160,8 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd, ULONGEST form = read_unsigned_leb128 (abfd, format, &bytes_read); format += bytes_read; - gdb::optional string; - gdb::optional uint; + std::optional string; + std::optional uint; switch (form) { diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 78cce2d69eb..2e88e670216 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -444,7 +444,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, unsigned int offset_size, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, htab_t include_hash, struct dwarf2_cu *cu) { struct objfile *objfile = per_objfile->objfile; @@ -805,7 +805,7 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, const struct line_header *lh, unsigned int offset_size, unsigned int offset, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu) { bfd *abfd; diff --git a/gdb/dwarf2/macro.h b/gdb/dwarf2/macro.h index d92994fef16..7daf147033a 100644 --- a/gdb/dwarf2/macro.h +++ b/gdb/dwarf2/macro.h @@ -30,7 +30,7 @@ extern void dwarf_decode_macros (dwarf2_per_objfile *per_objfile, unsigned int offset, dwarf2_section_info *str_section, dwarf2_section_info *str_offsets_section, - gdb::optional str_offsets_base, + std::optional str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu); #endif /* GDB_DWARF2_MACRO_H */ diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index da3bf0633fc..dd011900d2b 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -182,7 +182,7 @@ struct dw2_symtab_iterator dwarf2_per_objfile *per_objfile; /* If set, only look for symbols that match that block. Valid values are GLOBAL_BLOCK and STATIC_BLOCK. */ - gdb::optional block_index; + std::optional block_index; /* The kind of symbol we're looking for. */ domain_enum domain; /* The list of CUs from the index entry of the symbol, @@ -204,7 +204,7 @@ struct dw2_symtab_iterator static void dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, dwarf2_per_objfile *per_objfile, - gdb::optional block_index, + std::optional block_index, domain_enum domain, offset_type namei, mapped_gdb_index &index) { diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5bbf208ed5a..e40353975c1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -77,7 +77,7 @@ #include "build-id.h" #include "namespace.h" #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/underlying.h" #include "gdbsupport/hash_enum.h" #include "filename-seen-cache.h" @@ -4080,7 +4080,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu, /* Return the signature of the compile unit, if found. In DWARF 4 and before, the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the signature is part of the header. */ -static gdb::optional +static std::optional lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die) { if (cu->header.version >= 5) @@ -4088,7 +4088,7 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die) struct attribute *attr; attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu); if (attr == nullptr || !attr->form_is_unsigned ()) - return gdb::optional (); + return std::optional (); return attr->as_unsigned (); } @@ -4121,7 +4121,7 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name) dwo_unit = lookup_dwo_type_unit (cu, dwo_name, comp_dir); else { - gdb::optional signature = lookup_dwo_id (cu, comp_unit_die); + std::optional signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) error (_("Dwarf Error: missing dwo_id for dwo_name %s" @@ -7981,7 +7981,7 @@ create_dwo_cu_reader (const struct die_reader_specs *reader, sect_offset sect_off = cu->per_cu->sect_off; struct dwarf2_section_info *section = cu->per_cu->section; - gdb::optional signature = lookup_dwo_id (cu, comp_unit_die); + std::optional signature = lookup_dwo_id (cu, comp_unit_die); if (!signature.has_value ()) { complaint (_("Dwarf Error: debug entry at offset %s is missing" @@ -10785,7 +10785,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, struct objfile *objfile = per_objfile->objfile; bfd *obfd = objfile->obfd.get (); /* Base address selection entry. */ - gdb::optional base; + std::optional base; const gdb_byte *buffer; bool overflow = false; ULONGEST addr_index; @@ -10991,7 +10991,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, unsigned int addr_size = cu_header->addr_size; CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Base address selection entry. */ - gdb::optional base; + std::optional base; unsigned int dummy; const gdb_byte *buffer; @@ -16187,8 +16187,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, bool is_declaration = false; sect_offset origin_offset {}; - gdb::optional low_pc; - gdb::optional high_pc; + std::optional low_pc; + std::optional high_pc; bool high_pc_relative = false; for (int i = 0; i < abbrev->num_attrs; ++i) @@ -17565,7 +17565,7 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf, static unrelocated_addr read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index, - gdb::optional addr_base, int addr_size) + std::optional addr_base, int addr_size) { struct objfile *objfile = per_objfile->objfile; bfd *abfd = objfile->obfd.get (); @@ -17618,7 +17618,7 @@ dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu, unsigned int addr_index) { struct dwarf2_cu *cu = per_objfile->get_cu (per_cu); - gdb::optional addr_base; + std::optional addr_base; int addr_size; /* We need addr_base and addr_size. @@ -21389,7 +21389,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, struct dwarf2_section_info *str_offsets_section; struct dwarf2_section_info *str_section; - gdb::optional str_offsets_base; + std::optional str_offsets_base; if (cu->dwo_unit != nullptr) { diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 1d9432c5c11..0cbe2bb3e69 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -747,7 +747,7 @@ struct dwarf2_per_objfile dwarf2_cu *sym_cu = nullptr; /* CUs that are queued to be read. */ - gdb::optional> queue; + std::optional> queue; private: /* Hold the corresponding compunit_symtab for each CU or TU. This diff --git a/gdb/eval.c b/gdb/eval.c index b859e825925..3358b0d8d32 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -102,7 +102,7 @@ expression::uses_objfile (struct objfile *objfile) const struct value * expression::evaluate (struct type *expect_type, enum noside noside) { - gdb::optional stack_temporaries; + std::optional stack_temporaries; if (target_has_execution () && inferior_ptid != null_ptid && language_defn->la_language == language_cplus && !thread_stack_temporaries_enabled_p (inferior_thread ())) diff --git a/gdb/event-top.c b/gdb/event-top.c index 3d6fa896a9c..ee78768f8a6 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -692,7 +692,7 @@ void gdb_rl_deprep_term_function (void) { #ifdef RL_STATE_EOF - gdb::optional> restore_eof_found; + std::optional> restore_eof_found; if (RL_ISSTATE (RL_STATE_EOF)) { diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 2ba5a9c9fad..61fe74f648c 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -27,7 +27,7 @@ #include "serial.h" #include "gdbthread.h" #include "ui.h" -#include "gdbsupport/gdb_optional.h" +#include static void print_flush (void) @@ -38,7 +38,7 @@ print_flush (void) if (deprecated_error_begin_hook) deprecated_error_begin_hook (); - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h index 3442302a0be..7b74b46ee7c 100644 --- a/gdb/extension-priv.h +++ b/gdb/extension-priv.h @@ -256,13 +256,13 @@ struct extension_language_ops CONTENTS is the contents of the file. This should either return colorized (using ANSI terminal escapes) version of the contents, or an empty option. */ - gdb::optional (*colorize) (const std::string &name, + std::optional (*colorize) (const std::string &name, const std::string &contents); /* Colorize a single line of disassembler output, CONTENT. This should either return colorized (using ANSI terminal escapes) version of the contents, or an empty optional. */ - gdb::optional (*colorize_disasm) (const std::string &content, + std::optional (*colorize_disasm) (const std::string &content, gdbarch *gdbarch); /* Print a single instruction from ADDRESS in architecture GDBARCH. INFO @@ -276,7 +276,7 @@ struct extension_language_ops If no instruction can be disassembled then return an empty value and other extension languages will get a chance to perform the disassembly. */ - gdb::optional (*print_insn) (struct gdbarch *gdbarch, + std::optional (*print_insn) (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info); }; diff --git a/gdb/extension.c b/gdb/extension.c index 65f3bab32a7..0fbba5fc8fc 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -939,10 +939,10 @@ xmethod_worker::get_result_type (value *object, gdb::array_view args) /* See extension.h. */ -gdb::optional +std::optional ext_lang_colorize (const std::string &filename, const std::string &contents) { - gdb::optional result; + std::optional result; for (const struct extension_language_defn *extlang : extension_languages) { @@ -959,10 +959,10 @@ ext_lang_colorize (const std::string &filename, const std::string &contents) /* See extension.h. */ -gdb::optional +std::optional ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch) { - gdb::optional result; + std::optional result; for (const struct extension_language_defn *extlang : extension_languages) { @@ -979,7 +979,7 @@ ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch) /* See extension.h. */ -gdb::optional +std::optional ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info) { @@ -988,7 +988,7 @@ ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, if (extlang->ops == nullptr || extlang->ops->print_insn == nullptr) continue; - gdb::optional length + std::optional length = extlang->ops->print_insn (gdbarch, address, info); if (length.has_value ()) return length; diff --git a/gdb/extension.h b/gdb/extension.h index 28f9e3bc028..bfdd9d51deb 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -22,7 +22,7 @@ #include "mi/mi-cmds.h" #include "gdbsupport/array-view.h" -#include "gdbsupport/gdb_optional.h" +#include struct breakpoint; struct command_line; @@ -316,7 +316,7 @@ extern void get_matching_xmethod_workers either a colorized (using ANSI terminal escapes) version of the source code, or an empty value if colorizing could not be done. */ -extern gdb::optional ext_lang_colorize +extern std::optional ext_lang_colorize (const std::string &filename, const std::string &contents); /* Try to colorize a single line of disassembler output, CONTENT for @@ -324,7 +324,7 @@ extern gdb::optional ext_lang_colorize escapes) version of CONTENT, or an empty value if colorizing could not be done. */ -extern gdb::optional ext_lang_colorize_disasm +extern std::optional ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch); /* Calls extension_language_ops::print_insn for each extension language, @@ -334,7 +334,7 @@ extern gdb::optional ext_lang_colorize_disasm All arguments are forwarded to extension_language_ops::print_insn, see that function for a full description. */ -extern gdb::optional ext_lang_print_insn +extern std::optional ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info); #if GDB_SELF_TEST diff --git a/gdb/f-lang.c b/gdb/f-lang.c index fc0614e5761..ebcca7adea3 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -306,7 +306,7 @@ class fortran_array_repacker_base_impl /* Set and reset to handle removing intermediate values from the value chain. */ - gdb::optional m_mark; + std::optional m_mark; }; /* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 0e0d0cdf621..211b83f555a 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -99,7 +99,7 @@ fbsd_nat_target::have_pending_event (ptid_t filter) /* See fbsd-nat.h. */ -gdb::optional +std::optional fbsd_nat_target::take_pending_event (ptid_t filter) { for (auto it = m_pending_events.begin (); it != m_pending_events.end (); it++) @@ -1663,7 +1663,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, target_options_to_string (target_options).c_str ()); /* If there is a valid pending event, return it. */ - gdb::optional event = take_pending_event (ptid); + std::optional event = take_pending_event (ptid); if (event.has_value ()) { /* Stop any other inferiors currently running. */ @@ -1899,7 +1899,7 @@ fbsd_nat_target::detach_fork_children (inferior *inf) while (1) { - gdb::optional event = take_pending_event (ptid); + std::optional event = take_pending_event (ptid); if (!event.has_value ()) break; diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index 7016cc0242a..8118408bf47 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -20,7 +20,7 @@ #ifndef FBSD_NAT_H #define FBSD_NAT_H -#include "gdbsupport/gdb_optional.h" +#include #include "inf-ptrace.h" #include "regcache.h" #include "regset.h" @@ -262,7 +262,7 @@ class fbsd_nat_target : public inf_ptrace_target FILTER. If there is a matching event, the event is removed from the pending list and returned. */ - gdb::optional take_pending_event (ptid_t filter); + std::optional take_pending_event (ptid_t filter); /* List of pending events. */ diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index d166d785736..4ac33697082 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -650,10 +650,10 @@ find_signalled_thread (struct thread_info *info, void *data) the data is prefixed with a 32-bit integer size to match the format used in FreeBSD NT_PROCSTAT_* notes. */ -static gdb::optional +static std::optional fbsd_make_note_desc (enum target_object object, uint32_t structsize) { - gdb::optional buf = + std::optional buf = target_read_alloc (current_inferior ()->top_target (), object, NULL); if (!buf || buf->empty ()) return {}; @@ -735,7 +735,7 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) /* Auxiliary vector. */ uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo */ - gdb::optional note_desc = + std::optional note_desc = fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize); if (note_desc && !note_desc->empty ()) { @@ -2340,7 +2340,7 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range) else { /* Fetch the list of address space entries from the running target. */ - gdb::optional buf = + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_FREEBSD_VMMAP, nullptr); if (!buf || buf->empty ()) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 48f32bb3a0b..403aed7c838 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -210,10 +210,10 @@ struct thread_suspend_state - If the thread is running, then this field has its value removed by calling stop_pc.reset() (see thread_info::set_executing()). - Attempting to read a gdb::optional with no value is undefined + Attempting to read a std::optional with no value is undefined behaviour and will trigger an assertion error when _GLIBCXX_DEBUG is defined, which should make error easier to track down. */ - gdb::optional stop_pc; + std::optional stop_pc; }; /* Base class for target-specific thread data. */ @@ -645,7 +645,7 @@ extern void delete_thread_silent (struct thread_info *thread); available. If SILENT, then don't inform the CLI about the exit. */ extern void set_thread_exited (thread_info *tp, - gdb::optional exit_code = {}, + std::optional exit_code = {}, bool silent = false); /* Delete a step_resume_breakpoint from the thread database. */ @@ -1042,7 +1042,7 @@ extern bool switch_to_thread_if_alive (thread_info *thr); exception if !FLAGS.SILENT and !FLAGS.CONT and CMD fails. */ extern void thread_try_catch_cmd (thread_info *thr, - gdb::optional ada_task, + std::optional ada_task, const char *cmd, int from_tty, const qcs_flags &flags); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 534b7a2bfa2..284793c055d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1046,7 +1046,7 @@ has_static_range (const struct range_bounds *bounds) /* See gdbtypes.h. */ -gdb::optional +std::optional get_discrete_low_bound (struct type *type) { type = check_typedef (type); @@ -1062,7 +1062,7 @@ get_discrete_low_bound (struct type *type) if (type->target_type ()->code () == TYPE_CODE_ENUM) { - gdb::optional low_pos + std::optional low_pos = discrete_position (type->target_type (), low); if (low_pos.has_value ()) @@ -1113,7 +1113,7 @@ get_discrete_low_bound (struct type *type) /* See gdbtypes.h. */ -gdb::optional +std::optional get_discrete_high_bound (struct type *type) { type = check_typedef (type); @@ -1129,7 +1129,7 @@ get_discrete_high_bound (struct type *type) if (type->target_type ()->code () == TYPE_CODE_ENUM) { - gdb::optional high_pos + std::optional high_pos = discrete_position (type->target_type (), high); if (high_pos.has_value ()) @@ -1192,11 +1192,11 @@ get_discrete_high_bound (struct type *type) bool get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) { - gdb::optional low = get_discrete_low_bound (type); + std::optional low = get_discrete_low_bound (type); if (!low.has_value ()) return false; - gdb::optional high = get_discrete_high_bound (type); + std::optional high = get_discrete_high_bound (type); if (!high.has_value ()) return false; @@ -1244,7 +1244,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound) in which case the value of POS is unmodified. */ -gdb::optional +std::optional discrete_position (struct type *type, LONGEST val) { if (type->code () == TYPE_CODE_RANGE) @@ -2535,7 +2535,7 @@ compute_variant_fields_inner (struct type *type, std::vector &flags) { /* Evaluate the discriminant. */ - gdb::optional discr_value; + std::optional discr_value; if (part.discriminant_index != -1) { int idx = part.discriminant_index; @@ -2758,7 +2758,7 @@ resolve_dynamic_type_internal (struct type *type, if (!is_dynamic_type_internal (real_type, top_level)) return type; - gdb::optional type_length; + std::optional type_length; prop = TYPE_DYNAMIC_LENGTH (type); if (prop != NULL && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 505c8ba12b5..d5bd6d2d2d7 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -47,7 +47,7 @@ #include "hashtab.h" #include "gdbsupport/array-view.h" #include "gdbsupport/gdb-hashtab.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/offset-type.h" #include "gdbsupport/enum-flags.h" #include "gdbsupport/underlying.h" @@ -2663,11 +2663,11 @@ extern bool get_discrete_bounds (struct type *type, LONGEST *lowp, /* If TYPE's low bound is a known constant, return it, else return nullopt. */ -extern gdb::optional get_discrete_low_bound (struct type *type); +extern std::optional get_discrete_low_bound (struct type *type); /* If TYPE's high bound is a known constant, return it, else return nullopt. */ -extern gdb::optional get_discrete_high_bound (struct type *type); +extern std::optional get_discrete_high_bound (struct type *type); /* Assuming TYPE is a simple, non-empty array type, compute its upper and lower bound. Save the low bound into LOW_BOUND if not NULL. @@ -2679,7 +2679,7 @@ extern gdb::optional get_discrete_high_bound (struct type *type); extern bool get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound); -extern gdb::optional discrete_position (struct type *type, +extern std::optional discrete_position (struct type *type, LONGEST val); extern int class_types_same_p (const struct type *, const struct type *); diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index a27ea8b3c80..ceca60b37e5 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -26,7 +26,7 @@ #include "ui.h" #include "target.h" #include "guile-internal.h" -#include "gdbsupport/gdb_optional.h" +#include #ifdef HAVE_POLL #if defined (HAVE_POLL_H) @@ -602,7 +602,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport, ? &gdb_stderr : &gdb_stdout); { - gdb::optional redirect_popper; + std::optional redirect_popper; if (oport == GDB_STDERR) gdb_stderr = port_file.get (); else diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index cdd5553cf5d..6d537c4c8d3 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -69,7 +69,7 @@ struct ia64_table_entry }; static struct ia64_table_entry *ktab = NULL; -static gdb::optional ktab_buf; +static std::optional ktab_buf; #endif @@ -2648,7 +2648,7 @@ ia64_access_mem (unw_addr_space_t as, } /* Call low-level function to access the kernel unwind table. */ -static gdb::optional +static std::optional getunwind_table () { /* FIXME drow/2005-09-10: This code used to call diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 25afdb2202e..4eeb68be8f0 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -352,7 +352,7 @@ inf_child_target::fileio_unlink (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional inf_child_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { diff --git a/gdb/inf-child.h b/gdb/inf-child.h index 017e8e35680..4aeb3898028 100644 --- a/gdb/inf-child.h +++ b/gdb/inf-child.h @@ -85,7 +85,7 @@ class inf_child_target int fileio_unlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; - gdb::optional fileio_readlink (struct inferior *inf, + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; bool use_agent (bool use) override; diff --git a/gdb/infcmd.c b/gdb/infcmd.c index cf8cd527955..3901a1aae66 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -52,7 +52,7 @@ #include "ui.h" #include "interps.h" #include "skip.h" -#include "gdbsupport/gdb_optional.h" +#include #include "source.h" #include "cli/cli-style.h" #include "dwarf2/loc.h" @@ -2790,7 +2790,7 @@ notice_new_inferior (thread_info *thr, bool leave_running, int from_tty) enum attach_post_wait_mode mode = leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING; - gdb::optional restore_thread; + std::optional restore_thread; if (inferior_ptid != null_ptid) restore_thread.emplace (); diff --git a/gdb/inferior.c b/gdb/inferior.c index efe57cceae3..c9575e17749 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -731,10 +731,10 @@ switch_to_inferior_no_thread (inferior *inf) /* See regcache.h. */ -gdb::optional +std::optional maybe_switch_inferior (inferior *inf) { - gdb::optional maybe_restore_thread; + std::optional maybe_restore_thread; if (inf != current_inferior ()) { maybe_restore_thread.emplace (); diff --git a/gdb/inferior.h b/gdb/inferior.h index 33eff7a9141..f8f9395aec4 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -340,7 +340,7 @@ extern void switch_to_inferior_no_thread (inferior *inf); If the current inferior was changed, return an RAII object that will restore the original current context. */ -extern gdb::optional maybe_switch_inferior +extern std::optional maybe_switch_inferior (inferior *inf); /* Info about an inferior's target description. There's one of these diff --git a/gdb/inflow.c b/gdb/inflow.c index 095c5f03672..749f620739d 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -113,9 +113,9 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *); we save our handlers in these two variables and set SIGINT and SIGQUIT to SIG_IGN. */ -static gdb::optional sigint_ours; +static std::optional sigint_ours; #ifdef SIGQUIT -static gdb::optional sigquit_ours; +static std::optional sigquit_ours; #endif /* The name of the tty (from the `tty' command) that we're giving to diff --git a/gdb/infrun.c b/gdb/infrun.c index 4fde96800fb..0fe9fd0c6dc 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -62,7 +62,7 @@ #include "thread-fsm.h" #include "gdbsupport/enum-flags.h" #include "progspace-and-thread.h" -#include "gdbsupport/gdb_optional.h" +#include #include "arch-utils.h" #include "gdbsupport/scope-exit.h" #include "gdbsupport/forward-scope-exit.h" @@ -711,7 +711,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ { /* If FOLLOW_CHILD, we leave CHILD_INF as the current inferior (do not restore the parent as the current inferior). */ - gdb::optional maybe_restore; + std::optional maybe_restore; if (!follow_child && !sched_multi) maybe_restore.emplace (); @@ -4399,7 +4399,7 @@ fetch_inferior_event () debugging. If we're looking at traceframes while the target is running, we're going to need to get back to that mode after handling the event. */ - gdb::optional maybe_restore_traceframe; + std::optional maybe_restore_traceframe; if (non_stop) { maybe_restore_traceframe.emplace (); @@ -4772,7 +4772,7 @@ adjust_pc_after_break (struct thread_info *thread, || (target_is_non_stop_p () && moribund_breakpoint_here_p (aspace, breakpoint_pc))) { - gdb::optional> restore_operation_disable; + std::optional> restore_operation_disable; if (record_full_is_used ()) restore_operation_disable.emplace @@ -6722,7 +6722,7 @@ handle_signal_stop (struct execution_control_state *ecs) decr_pc = gdbarch_decr_pc_after_break (gdbarch); if (decr_pc != 0) { - gdb::optional> + std::optional> restore_operation_disable; if (record_full_is_used ()) @@ -8930,7 +8930,7 @@ normal_stop () else if (last.kind () != TARGET_WAITKIND_NO_RESUMED) finish_ptid = inferior_ptid; - gdb::optional maybe_finish_thread_state; + std::optional maybe_finish_thread_state; if (finish_ptid != null_ptid) { maybe_finish_thread_state.emplace diff --git a/gdb/interps.c b/gdb/interps.c index f91b2b62c1b..5f2a484a032 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -430,7 +430,7 @@ interps_notify_new_thread (thread_info *t) void interps_notify_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, int silent) { interps_notify (&interp::on_thread_exited, t, exit_code, silent); diff --git a/gdb/interps.h b/gdb/interps.h index 287df2c8c81..986110b9b6a 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -123,7 +123,7 @@ class interp : public intrusive_list_node /* Notify the interpreter that thread T has exited. */ virtual void on_thread_exited (thread_info *, - gdb::optional exit_code, + std::optional exit_code, int silent) {} /* Notify the interpreter that inferior INF was added. */ @@ -292,7 +292,7 @@ extern void interps_notify_new_thread (thread_info *t); /* Notify all interpreters that thread T has exited. */ extern void interps_notify_thread_exited (thread_info *t, - gdb::optional exit_code, + std::optional exit_code, int silent); /* Notify all interpreters that inferior INF was added. */ diff --git a/gdb/jit.c b/gdb/jit.c index 9e8325ab803..0e3a4285bdd 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -76,7 +76,7 @@ maint_info_jit_cmd (const char *args, int from_tty) inferior *inf = current_inferior (); bool printed_header = false; - gdb::optional table_emitter; + std::optional table_emitter; /* Print a line for each JIT-ed objfile. */ for (objfile *obj : inf->pspace->objfiles ()) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 9148dda4aad..42991c71266 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4003,7 +4003,7 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf, static bool proc_mem_file_is_writable () { - static gdb::optional writable; + static std::optional writable; if (writable.has_value ()) return *writable; @@ -4424,7 +4424,7 @@ linux_nat_target::fileio_open (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional linux_nat_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 770fe924427..e9c3a1a7436 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -103,7 +103,7 @@ class linux_nat_target : public inf_ptrace_target int flags, int mode, int warn_if_slow, fileio_error *target_errno) override; - gdb::optional + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index f7b8a594097..6dcc56cd562 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -38,7 +38,7 @@ #include "gdbcmd.h" #include "gdbsupport/gdb_regex.h" #include "gdbsupport/enum-flags.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gcore.h" #include "gcore-elf.h" #include "solib-svr4.h" @@ -229,7 +229,7 @@ struct linux_info int vsyscall_range_p = 0; /* Inferior's displaced step buffers. */ - gdb::optional disp_step_bufs; + std::optional disp_step_bufs; }; /* Per-inferior data key. */ @@ -589,7 +589,7 @@ struct mapping_regexes static int mapping_is_anonymous_p (const char *filename) { - static gdb::optional regexes; + static std::optional regexes; static int init_regex_p = 0; if (!init_regex_p) @@ -873,7 +873,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (cwd_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid); - gdb::optional contents + std::optional contents = target_fileio_readlink (NULL, filename, &target_errno); if (contents.has_value ()) gdb_printf ("cwd = '%s'\n", contents->c_str ()); @@ -883,7 +883,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (exe_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid); - gdb::optional contents + std::optional contents = target_fileio_readlink (NULL, filename, &target_errno); if (contents.has_value ()) gdb_printf ("exe = '%s'\n", contents->c_str ()); @@ -2108,7 +2108,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) return NULL; /* Auxillary vector. */ - gdb::optional auxv = + std::optional auxv = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AUXV, NULL); if (auxv && !auxv->empty ()) @@ -2675,7 +2675,7 @@ linux_displaced_step_restore_all_in_ptid (inferior *parent_inf, ptid_t ptid) /* Helper for linux_get_hwcap and linux_get_hwcap2. */ static CORE_ADDR -linux_get_hwcap_helper (const gdb::optional &auxv, +linux_get_hwcap_helper (const std::optional &auxv, target_ops *target, gdbarch *gdbarch, CORE_ADDR match) { CORE_ADDR field; @@ -2688,7 +2688,7 @@ linux_get_hwcap_helper (const gdb::optional &auxv, /* See linux-tdep.h. */ CORE_ADDR -linux_get_hwcap (const gdb::optional &auxv, +linux_get_hwcap (const std::optional &auxv, target_ops *target, gdbarch *gdbarch) { return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP); @@ -2707,7 +2707,7 @@ linux_get_hwcap () /* See linux-tdep.h. */ CORE_ADDR -linux_get_hwcap2 (const gdb::optional &auxv, +linux_get_hwcap2 (const std::optional &auxv, target_ops *target, gdbarch *gdbarch) { return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP2); diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h index e09a6ef32b1..819b221e599 100644 --- a/gdb/linux-tdep.h +++ b/gdb/linux-tdep.h @@ -94,7 +94,7 @@ extern int linux_is_uclinux (void); parse auxv entries. On error, 0 is returned. */ -extern CORE_ADDR linux_get_hwcap (const gdb::optional &auxv, +extern CORE_ADDR linux_get_hwcap (const std::optional &auxv, struct target_ops *target, gdbarch *gdbarch); /* Same as the above, but obtain all the inputs from the current inferior. */ @@ -105,7 +105,7 @@ extern CORE_ADDR linux_get_hwcap (); parse auxv entries. On error, 0 is returned. */ -extern CORE_ADDR linux_get_hwcap2 (const gdb::optional &auxv, +extern CORE_ADDR linux_get_hwcap2 (const std::optional &auxv, struct target_ops *target, gdbarch *gdbarch); /* Same as the above, but obtain all the inputs from the current inferior. */ diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index cef78f599be..c2ec422b7f3 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -312,7 +312,7 @@ struct thread_db_thread_info : public private_thread_info /* Cached thread state. */ td_thrhandle_t th {}; thread_t tid {}; - gdb::optional thread_handle; + std::optional thread_handle; }; static thread_db_thread_info * diff --git a/gdb/main.c b/gdb/main.c index 2da39f89a90..486c1ffe071 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -361,7 +361,7 @@ get_init_files (std::vector *system_gdbinit, { /* Cache the file lookup object so we only actually search for the files once. */ - static gdb::optional init_files; + static std::optional init_files; if (!init_files.has_value ()) init_files.emplace (GDBINIT, SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE, SYSTEM_GDBINIT_DIR, SYSTEM_GDBINIT_DIR_RELOCATABLE, @@ -381,7 +381,7 @@ get_earlyinit_files (std::string *home_gdbearlyinit) { /* Cache the file lookup object so we only actually search for the files once. */ - static gdb::optional init_files; + static std::optional init_files; if (!init_files.has_value ()) init_files.emplace (GDBEARLYINIT, nullptr, false, nullptr, false, false); diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index e473be7d465..6982338751a 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -34,7 +34,7 @@ #include "extension.h" #include #include "mi-parse.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb-safe-ctype.h" #include "inferior.h" #include "observable.h" @@ -515,7 +515,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, arg->val->type ()->length ())))) return; - gdb::optional tuple_emitter; + std::optional tuple_emitter; if (values != PRINT_NO_VALUES || what == all) tuple_emitter.emplace (uiout, nullptr); diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 8b4dd6d0c96..87c54c8c95d 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -30,7 +30,7 @@ #include "mi-getopt.h" #include "gdbthread.h" #include "mi-parse.h" -#include "gdbsupport/gdb_optional.h" +#include #include "inferior.h" static void varobj_update_one (struct varobj *var, diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 5ea31fc98d1..dbee2d010ea 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -183,7 +183,7 @@ mi_command::mi_command (const char *name, int *suppress_notification) /* See mi-cmds.h. */ -gdb::optional> +std::optional> mi_command::do_suppress_notification () const { if (m_suppress_notification != nullptr) diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index e67c486a997..f99c24313b9 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -23,7 +23,7 @@ #define MI_MI_CMDS_H #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "mi/mi-main.h" enum print_values { @@ -180,12 +180,12 @@ struct mi_command /* If this command was created with a suppress notifications pointer, then this function will set the suppress flag and return a - gdb::optional with its value set to an object that will restore the + std::optional with its value set to an object that will restore the previous value of the suppress notifications flag. If this command was created without a suppress notifications points, - then this function returns an empty gdb::optional. */ - gdb::optional> do_suppress_notification () const; + then this function returns an empty std::optional. */ + std::optional> do_suppress_notification () const; private: diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 0d3c8235c2c..a0e41006c56 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -278,7 +278,7 @@ mi_interp::on_new_thread (thread_info *t) void mi_interp::on_thread_exited (thread_info *t, - gdb::optional /* exit_code */, + std::optional /* exit_code */, int /* silent */) { target_terminal::scoped_restore_terminal_state term_state; diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index f9af61f0a57..353c0c6d593 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -51,7 +51,7 @@ class mi_interp final : public interp void on_command_error () override; void on_user_selected_context_changed (user_selected_what selection) override; void on_new_thread (thread_info *t) override; - void on_thread_exited (thread_info *t, gdb::optional exit_code, + void on_thread_exited (thread_info *t, std::optional exit_code, int silent) override; void on_inferior_added (inferior *inf) override; void on_inferior_appeared (inferior *inf) override; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index d750371f917..3fa36fc77ed 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -52,7 +52,7 @@ #include "extension.h" #include "gdbcmd.h" #include "observable.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/byte-vector.h" #include @@ -2097,7 +2097,7 @@ mi_cmd_execute (struct mi_parse *parse) user_selected_context current_user_selected_context; - gdb::optional thread_saver; + std::optional thread_saver; if (parse->thread != -1) { thread_info *tp = find_thread_global_id (parse->thread); @@ -2114,7 +2114,7 @@ mi_cmd_execute (struct mi_parse *parse) switch_to_thread (tp); } - gdb::optional frame_saver; + std::optional frame_saver; if (parse->frame != -1) { frame_info_ptr fid; @@ -2132,7 +2132,7 @@ mi_cmd_execute (struct mi_parse *parse) error (_("Invalid frame id: %d"), frame); } - gdb::optional lang_saver; + std::optional lang_saver; if (parse->language != language_unknown) { lang_saver.emplace (); @@ -2143,7 +2143,7 @@ mi_cmd_execute (struct mi_parse *parse) gdb_assert (parse->cmd != nullptr); - gdb::optional> restore_suppress_notification + std::optional> restore_suppress_notification = parse->cmd->do_suppress_notification (); parse->cmd->invoke (parse); @@ -2514,7 +2514,7 @@ print_variable_or_computed (const char *expression, enum print_values values) else val = expr->evaluate (); - gdb::optional tuple_emitter; + std::optional tuple_emitter; if (values != PRINT_NO_VALUES) tuple_emitter.emplace (uiout, nullptr); uiout->field_string ("name", expression); diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c index 103b7ab26cd..e85384660d4 100644 --- a/gdb/nat/linux-osdata.c +++ b/gdb/nat/linux-osdata.c @@ -66,7 +66,7 @@ linux_common_core_of_thread (ptid_t ptid) sprintf (filename, "/proc/%lld/task/%lld/stat", (PID_T) ptid.pid (), (PID_T) ptid.lwp ()); - gdb::optional content = read_text_file_to_string (filename); + std::optional content = read_text_file_to_string (filename); if (!content.has_value ()) return -1; @@ -257,10 +257,10 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores) /* get_core_array_size helper that uses /sys/devices/system/cpu/possible. */ -static gdb::optional +static std::optional get_core_array_size_using_sys_possible () { - gdb::optional possible + std::optional possible = read_text_file_to_string ("/sys/devices/system/cpu/possible"); if (!possible.has_value ()) @@ -310,7 +310,7 @@ get_core_array_size () we are in a container that has access to a subset of the host's cores. It will return a size that considers all the CPU cores available to the host. If that fails for some reason, fall back to sysconf. */ - gdb::optional count = get_core_array_size_using_sys_possible (); + std::optional count = get_core_array_size_using_sys_possible (); if (count.has_value ()) return *count; diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index 8028494de20..bf4c4387886 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -698,10 +698,10 @@ windows_process_info::matching_pending_stop (bool debug_events) /* See nat/windows-nat.h. */ -gdb::optional +std::optional windows_process_info::fetch_pending_stop (bool debug_events) { - gdb::optional result; + std::optional result; for (auto iter = pending_stops.begin (); iter != pending_stops.end (); ++iter) @@ -818,7 +818,7 @@ create_process_wrapper (FUNC *do_create_process, const CHAR *image, InitializeProcThreadAttributeList (info_ex.lpAttributeList, 1, 0, &size); - gdb::optional return_value; + std::optional return_value; DWORD attr_flags = relocate_aslr_flags; if (!UpdateProcThreadAttribute (info_ex.lpAttributeList, 0, mitigation_policy, diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index e3ea7dbb525..0dc37b29705 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -23,7 +23,7 @@ #include #include -#include "gdbsupport/gdb_optional.h" +#include #include "target/waitstatus.h" #define STATUS_WX86_BREAKPOINT 0x4000001F @@ -246,7 +246,7 @@ struct windows_process_info remove it from the list of pending stops, set 'current_event', and return it. Otherwise, return an empty optional. */ - gdb::optional fetch_pending_stop (bool debug_events); + std::optional fetch_pending_stop (bool debug_events); const char *pid_to_exec_file (int); diff --git a/gdb/observable.h b/gdb/observable.h index acb05e9b535..5cf2d159096 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -124,7 +124,7 @@ extern observable new_thread; removing the thread from its tables without wanting to notify the CLI about it. */ extern observable /* exit_code */, + std::optional /* exit_code */, bool /* silent */> thread_exit; /* An explicit stop request was issued to PTID. If PTID equals diff --git a/gdb/osdata.c b/gdb/osdata.c index 21b8eb01f6b..cb1e950df5c 100644 --- a/gdb/osdata.c +++ b/gdb/osdata.c @@ -162,7 +162,7 @@ std::unique_ptr get_osdata (const char *type) { std::unique_ptr osdata; - gdb::optional xml = target_get_osdata (type); + std::optional xml = target_get_osdata (type); if (xml) { diff --git a/gdb/parse.c b/gdb/parse.c index c69b53addff..b57d112fafd 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -49,7 +49,7 @@ #include "objfiles.h" #include "user-regs.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "c-exp.h" static unsigned int expressiondebug = 0; @@ -471,7 +471,7 @@ parse_expression (const char *string, innermost_block_tracker *tracker, expression_up parse_expression_with_language (const char *string, enum language lang) { - gdb::optional lang_saver; + std::optional lang_saver; if (current_language->la_language != lang) { lang_saver.emplace (); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index a0205119f00..f34de9cb666 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -464,7 +464,7 @@ class ppc_linux_dreg_interface }; /* The interface option. Initialized if has_value () returns true. */ - gdb::optional m_interface; + std::optional m_interface; /* The info returned by the kernel with PPC_PTRACE_GETHWDBGINFO. Only valid if we determined that the interface is HWDEBUG. */ @@ -485,7 +485,7 @@ struct ppc_linux_process_info /* The watchpoint value that GDB requested for this process. Only used when the interface is DEBUGREG. */ - gdb::optional requested_wp_val; + std::optional requested_wp_val; }; struct ppc_linux_nat_target final : public linux_nat_target diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 7c75bb5693d..c8f138f3b3e 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1609,7 +1609,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, if (vsx) features.vsx = true; - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); features.isa205 = ppc_linux_has_isa205 (hwcap); diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index ddeb810f35b..b24154998ec 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -447,7 +447,7 @@ struct ppc_inferior_data /* This is an optional in case we add more fields to ppc_inferior_data, we don't want it instantiated as soon as we get the ppc_inferior_data for an inferior. */ - gdb::optional disp_step_buf; + std::optional disp_step_buf; }; extern ppc_inferior_data * get_ppc_per_inferior (inferior *inf); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 5e9c8a5b222..5afbc565cf7 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -52,7 +52,7 @@ #include "gdbsupport/format.h" #include "source.h" #include "gdbsupport/byte-vector.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/rsp-low.h" #include "inferior.h" @@ -435,7 +435,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, /* Some cases below will unpack the value again. In the biased range case, we want to avoid this, so we store the unpacked value here for possible use later. */ - gdb::optional val_long; + std::optional val_long; if ((is_fixed_point_type (type) && (options->format == 'o' || options->format == 'x' @@ -2521,7 +2521,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, struct type *wctype = lookup_typename (current_language, "wchar_t", NULL, 0); int wcwidth = wctype->length (); - gdb::optional tem_str; + std::optional tem_str; if (value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) diff --git a/gdb/probe.c b/gdb/probe.c index 13e95bcfb20..d9079be4d62 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -36,7 +36,7 @@ #include "location.h" #include #include -#include "gdbsupport/gdb_optional.h" +#include /* Class that implements the static probe methods for "any" probe. */ @@ -280,7 +280,7 @@ collect_probes (const std::string &objname, const std::string &provider, const std::string &probe_name, const static_probe_ops *spops) { std::vector result; - gdb::optional obj_pat, prov_pat, probe_pat; + std::optional obj_pat, prov_pat, probe_pat; if (!provider.empty ()) prov_pat.emplace (provider.c_str (), REG_NOSUB, @@ -683,9 +683,9 @@ disable_probes_command (const char *arg, int from_tty) static bool ignore_probes_p = false; static bool ignore_probes_idx = 0; static bool ignore_probes_verbose_p; -static gdb::optional ignore_probes_prov_pat[2]; -static gdb::optional ignore_probes_name_pat[2]; -static gdb::optional ignore_probes_obj_pat[2]; +static std::optional ignore_probes_prov_pat[2]; +static std::optional ignore_probes_name_pat[2]; +static std::optional ignore_probes_obj_pat[2]; /* See comments in probe.h. */ @@ -696,11 +696,11 @@ ignore_probe_p (const char *provider, const char *name, if (!ignore_probes_p) return false; - gdb::optional &re_prov + std::optional &re_prov = ignore_probes_prov_pat[ignore_probes_idx]; - gdb::optional &re_name + std::optional &re_name = ignore_probes_name_pat[ignore_probes_idx]; - gdb::optional &re_obj + std::optional &re_obj = ignore_probes_obj_pat[ignore_probes_idx]; bool res @@ -755,11 +755,11 @@ ignore_probes_command (const char *arg, int from_tty) /* Parse the regular expressions, making sure that the old regular expressions are still valid if an exception is throw. */ int new_ignore_probes_idx = 1 - ignore_probes_idx; - gdb::optional &re_prov + std::optional &re_prov = ignore_probes_prov_pat[new_ignore_probes_idx]; - gdb::optional &re_name + std::optional &re_name = ignore_probes_name_pat[new_ignore_probes_idx]; - gdb::optional &re_obj + std::optional &re_obj = ignore_probes_obj_pat[new_ignore_probes_idx]; re_prov.reset (); re_name.reset (); diff --git a/gdb/procfs.c b/gdb/procfs.c index 0e8a08f99d3..f8b88bf8754 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -3615,7 +3615,7 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size) proc_iterate_over_threads (pi, procfs_corefile_thread_callback, &thread_args); - gdb::optional auxv = + std::optional auxv = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_AUXV, NULL); if (auxv && !auxv->empty ()) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 41ecf31424b..484d4eaa651 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1025,7 +1025,7 @@ psymbol_functions::expand_symtabs_matching for (partial_symtab *ps : partial_symbols (objfile)) ps->searched_flag = PST_NOT_SEARCHED; - gdb::optional psym_lookup_name; + std::optional psym_lookup_name; if (lookup_name != nullptr) psym_lookup_name = lookup_name->make_ignore_params (); diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 41337d0db89..4bafc6e998e 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -131,7 +131,7 @@ class psymtab_storage /* The obstack where allocations are made. This is lazily allocated so that we don't waste memory when there are no psymtabs. */ - gdb::optional m_obstack; + std::optional m_obstack; }; /* A partial_symbol records the name, domain, and address class of diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index 6f0fed137e6..7a13b81a0c2 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -176,7 +176,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* Return a reference to an optional that contains the address at which a memory error occurred. The optional will only have a value if a memory error actually occurred. */ - const gdb::optional &memory_error_address () const + const std::optional &memory_error_address () const { return m_memory_error_address; } /* Return the content of the disassembler as a string. The contents are @@ -221,7 +221,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* When the user indicates that a memory error has occurred then the address of the memory error is stored in here. */ - gdb::optional m_memory_error_address; + std::optional m_memory_error_address; /* When the user calls the builtin_disassemble function, if they pass a memory source object then a pointer to the object is placed in here, @@ -245,7 +245,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* Store a single exception. This is used to pass Python exceptions back from ::memory_read to disasmpy_builtin_disassemble. */ - gdb::optional m_stored_exception; + std::optional m_stored_exception; }; /* Return true if OBJ is still valid, otherwise, return false. A valid OBJ @@ -1215,7 +1215,7 @@ struct scoped_disasm_info_object /* See python-internal.h. */ -gdb::optional +std::optional gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, disassemble_info *info) { @@ -1294,7 +1294,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, addr = disasm_info->address; info->memory_error_func (-1, addr, info); - return gdb::optional (-1); + return std::optional (-1); } else if (PyErr_ExceptionMatches (gdbpy_gdberror_exc)) { @@ -1302,12 +1302,12 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb::unique_xmalloc_ptr msg = err.to_string (); info->fprintf_func (info->stream, "%s", msg.get ()); - return gdb::optional (-1); + return std::optional (-1); } else { gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } } @@ -1326,7 +1326,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, PyErr_SetString (PyExc_TypeError, _("Result is not a DisassemblerResult.")); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } /* The result from the Python disassembler has the correct type. Convert @@ -1345,7 +1345,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, (PyExc_ValueError, _("Invalid length attribute: length must be greater than 0.")); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } if (length > max_insn_length) { @@ -1354,7 +1354,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, _("Invalid length attribute: length %d greater than architecture maximum of %d"), length, max_insn_length); gdbpy_print_stack (); - return gdb::optional (-1); + return std::optional (-1); } /* It is impossible to create a DisassemblerResult object with an empty @@ -1390,7 +1390,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, } } - return gdb::optional (length); + return std::optional (length); } /* The tp_dealloc callback for the DisassemblerResult type. Takes care of diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e555dc3d879..dc7e47d70f0 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -32,7 +32,7 @@ #include "demangle.h" #include "mi/mi-cmds.h" #include "python-internal.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cli/cli-style.h" enum mi_print_types @@ -322,7 +322,7 @@ py_print_single_arg (struct ui_out *out, else val = fv; - gdb::optional maybe_tuple; + std::optional maybe_tuple; /* MI has varying rules for tuples, but generally if there is only one element in each item in the list, do not start a tuple. The @@ -562,7 +562,7 @@ enumerate_locals (PyObject *iter, struct symbol *sym; const struct block *sym_block; int local_indent = 8 + (8 * indent); - gdb::optional tuple; + std::optional tuple; gdbpy_ref<> item (PyIter_Next (iter)); if (item == NULL) @@ -773,7 +773,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, get_user_print_options (&opts); if (print_frame_info) { - gdb::optional user_frame_info_print_what; + std::optional user_frame_info_print_what; get_user_print_what_frame_info (&user_frame_info_print_what); if (!out->is_mi_like_p () && user_frame_info_print_what.has_value ()) @@ -808,7 +808,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, return EXT_LANG_BT_OK; } - gdb::optional tuple; + std::optional tuple; /* -stack-list-locals does not require a wrapping frame attribute. */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index c0bd6a69895..ed153d668ac 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -364,7 +364,7 @@ add_thread_object (struct thread_info *tp) static void delete_thread_object (thread_info *tp, - gdb::optional /* exit_code */, + std::optional /* exit_code */, bool /* silent */) { if (!gdb_python_initialized) diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index a43fac98c43..c338636b3c1 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -146,7 +146,7 @@ class py_ui_out : public ui_out /* If an error occurred, this holds the exception information for use by the 'release' method. */ - gdb::optional m_error; + std::optional m_error; /* Return a reference to the object under construction. */ object_desc ¤t () diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 15520849f15..f1ca9ea0a5d 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -469,12 +469,12 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr doc) (user left a single stray space at the start of an otherwise blank line), we don't consider lines without content when updating the MIN_WHITESPACE value. */ - gdb::optional min_whitespace; + std::optional min_whitespace; /* The index into WS_INFO at which the processing of DOC can be considered "all done", that is, after this point there are no further lines with useful content and we should just stop. */ - gdb::optional all_done_idx; + std::optional all_done_idx; /* White-space information for each line in DOC. */ std::vector ws_info; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 847bed84dfe..86eb5436f2a 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -732,7 +732,7 @@ class gdbpy_enter /* An optional is used here because we don't want to call PyErr_Fetch too early. */ - gdb::optional m_error; + std::optional m_error; }; /* Like gdbpy_enter, but takes a varobj. This is a subclass just to @@ -953,7 +953,7 @@ extern gdb::unique_xmalloc_ptr gdbpy_fix_doc_string_indentation If no instruction can be disassembled then return an empty value. */ -extern gdb::optional gdbpy_print_insn (struct gdbarch *gdbarch, +extern std::optional gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, disassemble_info *info); diff --git a/gdb/python/python.c b/gdb/python/python.c index d3dea088c3b..5fc883745db 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -121,9 +121,9 @@ static void gdbpy_set_quit_flag (const struct extension_language_defn *); static int gdbpy_check_quit_flag (const struct extension_language_defn *); static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt); -static gdb::optional gdbpy_colorize +static std::optional gdbpy_colorize (const std::string &filename, const std::string &contents); -static gdb::optional gdbpy_colorize_disasm +static std::optional gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch); /* The interface between gdb proper and loading of python scripts. */ @@ -1191,7 +1191,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, /* This is the extension_language_ops.colorize "method". */ -static gdb::optional +static std::optional gdbpy_colorize (const std::string &filename, const std::string &contents) { if (!gdb_python_initialized) @@ -1268,7 +1268,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) /* This is the extension_language_ops.colorize_disasm "method". */ -static gdb::optional +static std::optional gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch) { if (!gdb_python_initialized) diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index 3558cfd3875..f147b66b3c6 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -685,7 +685,7 @@ ravenscar_thread_target::fetch_registers (struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); bool is_active = task_is_currently_active (ptid); struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch); - gdb::optional fp_state; + std::optional fp_state; int low_reg = regnum == -1 ? 0 : regnum; int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1; @@ -731,7 +731,7 @@ ravenscar_thread_target::store_registers (struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); bool is_active = task_is_currently_active (ptid); struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch); - gdb::optional fp_state; + std::optional fp_state; int low_reg = regnum == -1 ? 0 : regnum; int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index abab79f3132..7a7d7617bc9 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -758,8 +758,8 @@ btrace_find_line_range (CORE_ADDR pc) static void btrace_print_lines (struct btrace_line_range lines, struct ui_out *uiout, - gdb::optional *src_and_asm_tuple, - gdb::optional *asm_list, + std::optional *src_and_asm_tuple, + std::optional *asm_list, gdb_disassembly_flags flags) { print_source_lines_flags psl_flags; @@ -798,8 +798,8 @@ btrace_insn_history (struct ui_out *uiout, ui_out_emit_list list_emitter (uiout, "asm_insns"); - gdb::optional src_and_asm_tuple; - gdb::optional asm_list; + std::optional src_and_asm_tuple; + std::optional asm_list; gdb_pretty_print_disassembler disasm (gdbarch, uiout); diff --git a/gdb/regcache.c b/gdb/regcache.c index 5acac2b8e47..c2802183fbe 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -596,7 +596,7 @@ regcache::raw_update (int regnum) if (get_register_status (regnum) == REG_UNKNOWN) { - gdb::optional maybe_restore_thread + std::optional maybe_restore_thread = maybe_switch_inferior (m_inf_for_target_calls); target_fetch_registers (this, regnum); @@ -850,7 +850,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf) m_descr->sizeof_register[regnum]) == 0)) return; - gdb::optional maybe_restore_thread + std::optional maybe_restore_thread = maybe_switch_inferior (m_inf_for_target_calls); target_prepare_to_store (this); diff --git a/gdb/remote.c b/gdb/remote.c index 961061e02a9..b405cb6abf7 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -915,7 +915,7 @@ class remote_target : public process_stratum_target const char *filename, fileio_error *target_errno) override; - gdb::optional + std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) override; @@ -4074,7 +4074,7 @@ remote_target::remote_get_threads_with_qxfer (threads_listing_context *context) #if defined(HAVE_LIBEXPAT) if (m_features.packet_support (PACKET_qXfer_threads) == PACKET_ENABLE) { - gdb::optional xml + std::optional xml = target_read_stralloc (this, TARGET_OBJECT_THREADS, NULL); if (xml && (*xml)[0] != '\0') @@ -11767,7 +11767,7 @@ std::vector remote_target::memory_map () { std::vector result; - gdb::optional text + std::optional text = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY_MAP, NULL); @@ -12732,7 +12732,7 @@ remote_target::fileio_unlink (struct inferior *inf, const char *filename, /* Implementation of to_fileio_readlink. */ -gdb::optional +std::optional remote_target::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *remote_errno) { @@ -13999,7 +13999,7 @@ remote_target::set_circular_trace_buffer (int val) traceframe_info_up remote_target::traceframe_info () { - gdb::optional text + std::optional text = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_TRACEFRAME_INFO, NULL); @@ -14540,7 +14540,7 @@ btrace_read_config (thread_info *tp, btrace_config *conf) scoped_restore_current_thread restore_thread; switch_to_thread (tp); - gdb::optional xml + std::optional xml = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_BTRACE_CONF, ""); if (xml) @@ -14740,7 +14740,7 @@ remote_target::read_btrace (struct btrace_data *btrace, (unsigned int) type); } - gdb::optional xml + std::optional xml = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_BTRACE, annex); if (!xml) @@ -14780,7 +14780,7 @@ remote_target::load (const char *name, int from_tty) const char * remote_target::pid_to_exec_file (int pid) { - static gdb::optional filename; + static std::optional filename; char *annex = NULL; if (m_features.packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 3a2891c2c92..3725be44276 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1676,7 +1676,7 @@ class riscv_insn passed, is the value to place in rs1, otherwise rd is duplicated into rs1. */ void decode_ci_type_insn (enum opcode opcode, ULONGEST ival, - gdb::optional rs1_regnum = {}) + std::optional rs1_regnum = {}) { m_opcode = opcode; m_rd = decode_register_index (ival, OP_SH_CRS1S); diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 414238a4db2..ae45ec6b5df 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -332,7 +332,7 @@ s390_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { asection *section = bfd_get_section_by_name (abfd, ".reg"); - gdb::optional auxv = target_read_auxv_raw (target); + std::optional auxv = target_read_auxv_raw (target); CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch); bool high_gprs, v1, v2, te, vx, gs; diff --git a/gdb/skip.c b/gdb/skip.c index 28902a6d326..465978ff9cc 100644 --- a/gdb/skip.c +++ b/gdb/skip.c @@ -34,7 +34,7 @@ #include "filenames.h" #include "fnmatch.h" #include "gdbsupport/gdb_regex.h" -#include "gdbsupport/gdb_optional.h" +#include #include #include "cli/cli-style.h" #include "gdbsupport/buildargv.h" @@ -113,7 +113,7 @@ class skiplist_entry std::string m_function; /* If this is a function regexp, the compiled form. */ - gdb::optional m_compiled_function_regexp; + std::optional m_compiled_function_regexp; /* Enabled/disabled state. */ bool m_enabled = true; diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index fd6b1e7a454..320e1bf2034 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -65,7 +65,7 @@ struct solib_aix_inferior_data the same principles applied to shared libraries also apply to the main executable. So it's simpler to keep it as part of this list. */ - gdb::optional> library_list; + std::optional> library_list; }; /* Key to our per-inferior data. */ @@ -91,7 +91,7 @@ get_solib_aix_inferior_data (struct inferior *inf) /* Dummy implementation if XML support is not compiled in. */ -static gdb::optional> +static std::optional> solib_aix_parse_libraries (const char *library) { static int have_warned; @@ -201,7 +201,7 @@ static const struct gdb_xml_element library_list_elements[] = Return an empty option if the parsing failed. */ -static gdb::optional> +static std::optional> solib_aix_parse_libraries (const char *library) { std::vector result; @@ -225,7 +225,7 @@ solib_aix_parse_libraries (const char *library) is not NULL, then print a warning including WARNING_MSG and a description of the error. */ -static gdb::optional> & +static std::optional> & solib_aix_get_library_list (struct inferior *inf, const char *warning_msg) { struct solib_aix_inferior_data *data; @@ -235,7 +235,7 @@ solib_aix_get_library_list (struct inferior *inf, const char *warning_msg) if (data->library_list.has_value ()) return data->library_list; - gdb::optional library_document + std::optional library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES_AIX, NULL); @@ -442,7 +442,7 @@ solib_aix_solib_create_inferior_hook (int from_tty) /* We need to relocate the main executable... */ - gdb::optional> &library_list + std::optional> &library_list = solib_aix_get_library_list (current_inferior (), warning_msg); if (!library_list.has_value ()) return; /* Warning already printed. */ @@ -472,7 +472,7 @@ solib_aix_current_sos (void) struct so_list *start = NULL, *last = NULL; int ix; - gdb::optional> &library_list + std::optional> &library_list = solib_aix_get_library_list (current_inferior (), NULL); if (!library_list.has_value ()) return NULL; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index c29b2b81b11..7b0adc1137e 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -281,7 +281,7 @@ static void dsbt_get_initial_loadmaps (void) { struct dsbt_info *info = get_dsbt_info (); - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_FDPIC, "exec"); diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 7bc6ca45c37..2d7e9453827 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -453,7 +453,7 @@ static int match_main (const char *); architecture size (32-bit or 64-bit) is returned to *P_ARCH_SIZE. Likewise, the base address of the section is returned in *BASE_ADDR. */ -static gdb::optional +static std::optional read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) { bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); @@ -586,7 +586,7 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) /* Return program interpreter string. */ -static gdb::optional +static std::optional find_program_interpreter (void) { /* If we have a current exec_bfd, use its section table. */ @@ -631,7 +631,7 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr, CORE_ADDR base_addr; /* Read in .dynamic section. */ - gdb::optional ph_data + std::optional ph_data = read_program_header (PT_DYNAMIC, &arch_size, &base_addr); if (!ph_data) return 0; @@ -1219,7 +1219,7 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ()); /* Fetch the list of shared libraries. */ - gdb::optional svr4_library_document + std::optional svr4_library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES_SVR4, annex); @@ -2426,7 +2426,7 @@ enable_break (struct svr4_info *info, int from_tty) /* Find the program interpreter; if not found, warn the user and drop into the old breakpoint at symbol code. */ - gdb::optional interp_name_holder + std::optional interp_name_holder = find_program_interpreter (); if (interp_name_holder) { @@ -2637,7 +2637,7 @@ enable_break (struct svr4_info *info, int from_tty) /* Read the ELF program headers from ABFD. */ -static gdb::optional +static std::optional read_program_headers_from_bfd (bfd *abfd) { Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd); @@ -2750,9 +2750,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp) really do not match. */ int arch_size; - gdb::optional phdrs_target + std::optional phdrs_target = read_program_header (-1, &arch_size, NULL); - gdb::optional phdrs_binary + std::optional phdrs_binary = read_program_headers_from_bfd (current_program_space->exec_bfd ()); if (phdrs_target && phdrs_binary) { diff --git a/gdb/solib-target.c b/gdb/solib-target.c index ca9478f2ec3..fe766544211 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -233,7 +233,7 @@ solib_target_current_sos (void) struct so_list *new_solib, *start = NULL, *last = NULL; /* Fetch the list of shared libraries. */ - gdb::optional library_document + std::optional library_document = target_read_stralloc (current_inferior ()->top_target (), TARGET_OBJECT_LIBRARIES, NULL); if (!library_document) diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 77b357cb42b..0d80bfc99d0 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -269,7 +269,7 @@ source_cache::ensure (struct symtab *s) if (!already_styled) #endif /* HAVE_SOURCE_HIGHLIGHT */ { - gdb::optional ext_contents; + std::optional ext_contents; ext_contents = ext_lang_colorize (fullname, contents); if (ext_contents.has_value ()) contents = std::move (*ext_contents); diff --git a/gdb/stack.c b/gdb/stack.c index 0b35d62f82f..efb36d0ea4f 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -97,7 +97,7 @@ static const char *const print_frame_info_choices[] = /* print_frame_info_print_what[i] maps a choice to the corresponding print_what enum. */ -static const gdb::optional print_frame_info_print_what[] = +static const std::optional print_frame_info_print_what[] = {{}, /* Empty value for "auto". */ SRC_LINE, LOCATION, SRC_AND_LOC, LOC_AND_ADDRESS, SHORT_LOCATION}; @@ -973,7 +973,7 @@ do_gdb_disassembly (struct gdbarch *gdbarch, Value not present indicates to the caller to use default values specific to the command being executed. */ -static gdb::optional +static std::optional print_frame_info_to_print_what (const char *print_frame_info) { for (int i = 0; print_frame_info_choices[i] != NULL; i++) @@ -1004,7 +1004,7 @@ print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info_ptr frame, /* See stack.h. */ void -get_user_print_what_frame_info (gdb::optional *what) +get_user_print_what_frame_info (std::optional *what) { *what = print_frame_info_to_print_what @@ -2261,8 +2261,8 @@ iterate_over_block_local_vars (const struct block *block, struct print_variable_and_value_data { - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; struct frame_id frame_id; int num_tabs; struct ui_file *stream; @@ -2307,7 +2307,7 @@ print_variable_and_value_data::operator() (const char *print_name, If REGEXP is NULL, it results in an empty regular expression. */ static void -prepare_reg (const char *regexp, gdb::optional *reg) +prepare_reg (const char *regexp, std::optional *reg) { if (regexp != NULL) { @@ -2503,8 +2503,8 @@ print_frame_arg_vars (frame_info_ptr frame, struct print_variable_and_value_data cb_data; struct symbol *func; CORE_ADDR pc; - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; if (!get_frame_pc_if_available (frame, &pc)) { diff --git a/gdb/stack.h b/gdb/stack.h index 1b0c2b342a4..a64abaf52b5 100644 --- a/gdb/stack.h +++ b/gdb/stack.h @@ -38,7 +38,7 @@ void iterate_over_block_local_vars (const struct block *block, information to print, otherwise the printing function should print the relevant information. */ -void get_user_print_what_frame_info (gdb::optional *what); +void get_user_print_what_frame_info (std::optional *what); /* Return true if we should display the address in addition to the location, because we are in the middle of a statement. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 5eb1638b781..a6236804b08 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -913,7 +913,7 @@ syms_from_objfile_1 (struct objfile *objfile, /* Make sure that partially constructed symbol tables will be cleaned up if an error occurs during symbol reading. */ - gdb::optional defer_clear_users; + std::optional defer_clear_users; objfile_up objfile_holder (objfile); diff --git a/gdb/symtab.c b/gdb/symtab.c index 46547f8b0ae..7f67159b516 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -66,7 +66,7 @@ #include "parser-defs.h" #include "completer.h" #include "progspace-and-thread.h" -#include "gdbsupport/gdb_optional.h" +#include #include "filename-seen-cache.h" #include "arch-utils.h" #include @@ -943,7 +943,7 @@ void general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, bool copy_name, objfile_per_bfd_storage *per_bfd, - gdb::optional hash) + std::optional hash) { struct demangled_name_entry **slot; @@ -3714,7 +3714,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab) the function starting at FUNC_ADDR which has prologue_end set to true if such entry exist, otherwise return an empty optional. */ -static gdb::optional +static std::optional skip_prologue_using_linetable (CORE_ADDR func_addr) { CORE_ADDR start_pc, end_pc; @@ -3838,7 +3838,7 @@ skip_prologue_sal (struct symtab_and_line *sal) be placed to skip the prologue. */ if (!ignore_prologue_end_flag && skip) { - gdb::optional linetable_pc + std::optional linetable_pc = skip_prologue_using_linetable (pc); if (linetable_pc) { @@ -4450,8 +4450,8 @@ info_sources_worker (struct ui_out *uiout, output_source_filename_data data (uiout, filter); ui_out_emit_list results_emitter (uiout, "files"); - gdb::optional output_tuple; - gdb::optional sources_list; + std::optional output_tuple; + std::optional sources_list; gdb_assert (group_by_objfile || uiout->is_mi_like_p ()); @@ -4652,7 +4652,7 @@ global_symbol_searcher::is_suitable_msymbol bool global_symbol_searcher::expand_symtabs - (objfile *objfile, const gdb::optional &preg) const + (objfile *objfile, const std::optional &preg) const { enum search_domain kind = m_kind; bool found_msymbol = false; @@ -4734,8 +4734,8 @@ global_symbol_searcher::expand_symtabs bool global_symbol_searcher::add_matching_symbols (objfile *objfile, - const gdb::optional &preg, - const gdb::optional &treg, + const std::optional &preg, + const std::optional &treg, std::set *result_set) const { enum search_domain kind = m_kind; @@ -4813,7 +4813,7 @@ global_symbol_searcher::add_matching_symbols bool global_symbol_searcher::add_matching_msymbols - (objfile *objfile, const gdb::optional &preg, + (objfile *objfile, const std::optional &preg, std::vector *results) const { enum search_domain kind = m_kind; @@ -4860,8 +4860,8 @@ global_symbol_searcher::add_matching_msymbols std::vector global_symbol_searcher::search () const { - gdb::optional preg; - gdb::optional treg; + std::optional preg; + std::optional treg; gdb_assert (m_kind != ALL_DOMAIN); diff --git a/gdb/symtab.h b/gdb/symtab.h index 365743384e1..d61d5bb7815 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -30,7 +30,7 @@ #include "gdbsupport/gdb_regex.h" #include "gdbsupport/enum-flags.h" #include "gdbsupport/function-view.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/gdb_string_view.h" #include "gdbsupport/next-iterator.h" #include "gdbsupport/iterator-range.h" @@ -364,10 +364,10 @@ class lookup_name_info final around by const reference (see intro), and they're conceptually "cache" that can always be reconstructed from the non-mutable fields. */ - mutable gdb::optional m_ada; - mutable gdb::optional m_cplus; - mutable gdb::optional m_d; - mutable gdb::optional m_go; + mutable std::optional m_ada; + mutable std::optional m_cplus; + mutable std::optional m_d; + mutable std::optional m_go; /* The demangled hashes. Stored in an array with one entry for each possible language. The second array records whether we've @@ -511,8 +511,8 @@ struct general_symbol_info copy_name must be set to true. */ void compute_and_set_names (gdb::string_view linkage_name, bool copy_name, struct objfile_per_bfd_storage *per_bfd, - gdb::optional hash - = gdb::optional ()); + std::optional hash + = std::optional ()); CORE_ADDR value_address () const { @@ -2601,7 +2601,7 @@ class global_symbol_searcher true if any msymbols were seen that we should later consider adding to the results list. */ bool expand_symtabs (objfile *objfile, - const gdb::optional &preg) const; + const std::optional &preg) const; /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are of type M_KIND, to the results set RESULTS_SET. Return false if we @@ -2610,8 +2610,8 @@ class global_symbol_searcher Returning true does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_symbols (objfile *objfile, - const gdb::optional &preg, - const gdb::optional &treg, + const std::optional &preg, + const std::optional &treg, std::set *result_set) const; /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results @@ -2621,7 +2621,7 @@ class global_symbol_searcher does not indicate that any results were added, just that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */ bool add_matching_msymbols (objfile *objfile, - const gdb::optional &preg, + const std::optional &preg, std::vector *results) const; /* Return true if MSYMBOL is of type KIND. */ @@ -2910,7 +2910,7 @@ struct info_sources_filter /* A compiled version of M_REGEXP. This object is only given a value if M_REGEXP is not nullptr and is not the empty string. */ - gdb::optional m_c_regexp; + std::optional m_c_regexp; }; /* Perform the core of the 'info sources' command. diff --git a/gdb/target.c b/gdb/target.c index 6853c143231..73df178e69d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2264,7 +2264,7 @@ target_write (struct target_ops *ops, for details. */ template -gdb::optional> +std::optional> target_read_alloc_1 (struct target_ops *ops, enum target_object object, const char *annex) { @@ -2313,7 +2313,7 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object, /* See target.h */ -gdb::optional +std::optional target_read_alloc (struct target_ops *ops, enum target_object object, const char *annex) { @@ -2322,11 +2322,11 @@ target_read_alloc (struct target_ops *ops, enum target_object object, /* See target.h. */ -gdb::optional +std::optional target_read_stralloc (struct target_ops *ops, enum target_object object, const char *annex) { - gdb::optional buf + std::optional buf = target_read_alloc_1 (ops, object, annex); if (!buf) @@ -3008,7 +3008,7 @@ target_supports_multi_process (void) /* See target.h. */ -gdb::optional +std::optional target_get_osdata (const char *type) { struct target_ops *t; @@ -3250,7 +3250,7 @@ target_ops::fileio_unlink (struct inferior *inf, const char *filename, return -1; } -gdb::optional +std::optional target_ops::fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { @@ -3421,13 +3421,13 @@ target_fileio_unlink (struct inferior *inf, const char *filename, /* See target.h. */ -gdb::optional +std::optional target_fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno) { for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ()) { - gdb::optional ret + std::optional ret = t->fileio_readlink (inf, filename, target_errno); if (!ret.has_value () && *target_errno == FILEIO_ENOSYS) diff --git a/gdb/target.h b/gdb/target.h index 446c0a9fdbf..1d7926bb962 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -345,7 +345,7 @@ LONGEST target_write_with_progress (struct target_ops *ops, size is known in advance. Don't try to read TARGET_OBJECT_MEMORY through this function. */ -extern gdb::optional target_read_alloc +extern std::optional target_read_alloc (struct target_ops *ops, enum target_object object, const char *annex); /* Read OBJECT/ANNEX using OPS. The result is a NUL-terminated character vector @@ -355,7 +355,7 @@ extern gdb::optional target_read_alloc the returned vector is guaranteed to have at least one element. A warning is issued if the result contains any embedded NUL bytes. */ -extern gdb::optional target_read_stralloc +extern std::optional target_read_stralloc (struct target_ops *ops, enum target_object object, const char *annex); /* See target_ops->to_xfer_partial. */ @@ -994,7 +994,7 @@ struct target_ops seen by the debugger (GDB or, for remote targets, the remote stub). Return a string, or an empty optional if an error occurs (and set *TARGET_ERRNO). */ - virtual gdb::optional fileio_readlink (struct inferior *inf, + virtual std::optional fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno); @@ -2199,7 +2199,7 @@ extern int target_fileio_unlink (struct inferior *inf, by the debugger (GDB or, for remote targets, the remote stub). Return a null-terminated string allocated via xmalloc, or NULL if an error occurs (and set *TARGET_ERRNO). */ -extern gdb::optional target_fileio_readlink +extern std::optional target_fileio_readlink (struct inferior *inf, const char *filename, fileio_error *target_errno); /* Read target file FILENAME, in the filesystem as seen by INF. If @@ -2462,7 +2462,7 @@ struct target_ops *find_target_at (enum strata stratum); /* Read OS data object of type TYPE from the target, and return it in XML format. The return value follows the same rules as target_read_stralloc. */ -extern gdb::optional target_get_osdata (const char *type); +extern std::optional target_get_osdata (const char *type); /* Stuff that should be shared among the various remote targets. */ diff --git a/gdb/thread.c b/gdb/thread.c index c8145da59bc..f97f2768fb2 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -46,7 +46,7 @@ #include "thread-fsm.h" #include "tid-parse.h" #include -#include "gdbsupport/gdb_optional.h" +#include #include "inline-frame.h" #include "stack.h" #include "interps.h" @@ -194,7 +194,7 @@ clear_thread_inferior_resources (struct thread_info *tp) /* Notify interpreters and observers that thread T has exited. */ static void -notify_thread_exited (thread_info *t, gdb::optional exit_code, +notify_thread_exited (thread_info *t, std::optional exit_code, int silent) { if (!silent && print_thread_events) @@ -215,7 +215,7 @@ notify_thread_exited (thread_info *t, gdb::optional exit_code, /* See gdbthread.h. */ void -set_thread_exited (thread_info *tp, gdb::optional exit_code, +set_thread_exited (thread_info *tp, std::optional exit_code, bool silent) { /* Dead threads don't need to step-over. Remove from chain. */ @@ -486,7 +486,7 @@ global_thread_step_over_chain_remove (struct thread_info *tp) /* Helper for the different delete_thread variants. */ static void -delete_thread_1 (thread_info *thr, gdb::optional exit_code, +delete_thread_1 (thread_info *thr, std::optional exit_code, bool silent) { gdb_assert (thr != nullptr); @@ -1089,8 +1089,8 @@ print_thread_info_1 (struct ui_out *uiout, const char *requested_threads, /* For backward compatibility, we make a list for MI. A table is preferable for the CLI, though, because it shows table headers. */ - gdb::optional list_emitter; - gdb::optional table_emitter; + std::optional list_emitter; + std::optional table_emitter; /* We'll be switching threads temporarily below. */ scoped_restore_current_thread restore_thread; @@ -1520,7 +1520,7 @@ tp_array_compar_descending (const thread_info_ref &a, const thread_info_ref &b) /* See gdbthread.h. */ void -thread_try_catch_cmd (thread_info *thr, gdb::optional ada_task, +thread_try_catch_cmd (thread_info *thr, std::optional ada_task, const char *cmd, int from_tty, const qcs_flags &flags) { diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index b698b4004cc..a710246d7ad 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -305,7 +305,7 @@ tfile_write_tdesc (struct trace_file_writer *self) struct tfile_trace_file_writer *writer = (struct tfile_trace_file_writer *) self; - gdb::optional tdesc + std::optional tdesc = target_fetch_description_xml (current_inferior ()->top_target ()); if (!tdesc) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2c548688570..b1b31ad378c 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3732,7 +3732,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) { /* We need to read the whole object before we know its size. */ - gdb::optional buf + std::optional buf = target_read_alloc (current_inferior ()->top_target (), TARGET_OBJECT_STATIC_TRACE_DATA, NULL); diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index c1ed491c558..ebd8bf0e2d1 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -234,7 +234,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) promising starting point then we record it in this structure. If the next address we try is not a suitable starting point then we will fall back to the address held here. */ - gdb::optional possible_new_low; + std::optional possible_new_low; /* The previous value of NEW_LOW so we know if the new value is different or not. */ diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 159445dc520..b932649b3ac 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -819,7 +819,7 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_, }; /* This is given a value only if we fix the size of the cmd window. */ - gdb::optional old_cmd_info; + std::optional old_cmd_info; std::vector info (m_splits.size ()); diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c index 8a727c02159..51135b8b98c 100644 --- a/gdb/unittests/optional-selftests.c +++ b/gdb/unittests/optional-selftests.c @@ -31,7 +31,7 @@ #define VERIFY SELF_CHECK /* Used to disable testing features not supported by - gdb::optional. */ + std::optional. */ #define GDB_OPTIONAL namespace selftests { @@ -41,7 +41,7 @@ namespace optional { copied over from libstdc++'s testsuite. To preserve the structure and help with comparison with the original tests, the file names have been preserved, and only minimal modification was done to have - them compile against gdb::optional instead of std::optional: + them compile against std::optional instead of std::optional: - std::optional->gdb:optional, etc. - ATTRIBUTE_UNUSED in a few places diff --git a/gdb/utils.c b/gdb/utils.c index a191d26a007..94a7cafa65b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -68,7 +68,7 @@ #include "gdbsupport/gdb_regex.h" #include "gdbsupport/job-control.h" #include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_optional.h" +#include #include "cp-support.h" #include #include "gdbsupport/pathstuff.h" @@ -143,7 +143,7 @@ vwarning (const char *string, va_list args) (*deprecated_warning_hook) (string, args); else { - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); @@ -375,7 +375,7 @@ internal_vproblem (struct internal_problem *problem, } /* Try to get the message out and at the start of a new line. */ - gdb::optional term_state; + std::optional term_state; if (target_supports_terminal_ours ()) { term_state.emplace (); diff --git a/gdb/valarith.c b/gdb/valarith.c index f3acf98c98b..6cf56302aee 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -150,14 +150,14 @@ value_subscript (struct value *array, LONGEST index) || tarray->code () == TYPE_CODE_STRING) { struct type *range_type = tarray->index_type (); - gdb::optional lowerbound = get_discrete_low_bound (range_type); + std::optional lowerbound = get_discrete_low_bound (range_type); if (!lowerbound.has_value ()) lowerbound = 0; if (array->lval () != lval_memory) return value_subscripted_rvalue (array, index, *lowerbound); - gdb::optional upperbound + std::optional upperbound = get_discrete_high_bound (range_type); if (!upperbound.has_value ()) diff --git a/gdb/valops.c b/gdb/valops.c index 70851cd40b4..a8760ccf3e4 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -52,7 +52,7 @@ static struct value *search_struct_field (const char *, struct value *, struct type *, int); static struct value *search_struct_method (const char *, struct value **, - gdb::optional>, + std::optional>, LONGEST, int *, struct type *); static int find_oload_champ_namespace (gdb::array_view args, @@ -2196,7 +2196,7 @@ search_struct_field (const char *name, struct value *arg1, static struct value * search_struct_method (const char *name, struct value **arg1p, - gdb::optional> args, + std::optional> args, LONGEST offset, int *static_memfuncp, struct type *type) { @@ -2332,7 +2332,7 @@ search_struct_method (const char *name, struct value **arg1p, struct value * value_struct_elt (struct value **argp, - gdb::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err) { struct type *t; diff --git a/gdb/value.c b/gdb/value.c index 17b7c53d052..7067ae94df0 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -826,7 +826,7 @@ exceeds_max_value_size (ULONGEST length) /* When this has a value, it is used to limit the number of array elements of an array that are loaded into memory when an array value is made non-lazy. */ -static gdb::optional array_length_limiting_element_count; +static std::optional array_length_limiting_element_count; /* See value.h. */ scoped_array_length_limiting::scoped_array_length_limiting (int elements) diff --git a/gdb/value.h b/gdb/value.h index e4912717684..6d91e8eee7a 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1269,7 +1269,7 @@ extern struct value *value_neg (struct value *arg1); extern struct value *value_complement (struct value *arg1); extern struct value *value_struct_elt (struct value **argp, - gdb::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err); @@ -1635,7 +1635,7 @@ struct scoped_array_length_limiting private: /* Used to hold the previous array value element limit. */ - gdb::optional m_old_value; + std::optional m_old_value; }; #endif /* !defined (VALUE_H) */ diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index b446afd72d8..e4d50d081c9 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1335,7 +1335,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, th->suspend (); } - gdb::optional err; + std::optional err; do_synchronously ([&] () { if (!continue_last_debug_event (continue_status, debug_events)) @@ -1561,7 +1561,7 @@ windows_nat_target::get_windows_debug_event /* If there is a relevant pending stop, report it now. See the comment by the definition of "pending_stops" for details on why this is needed. */ - gdb::optional stop + std::optional stop = windows_process.fetch_pending_stop (debug_events); if (stop.has_value ()) { @@ -2024,7 +2024,7 @@ windows_nat_target::attach (const char *args, int from_tty) windows_init_thread_list (); windows_process.saw_create = 0; - gdb::optional err; + std::optional err; do_synchronously ([&] () { BOOL ok = DebugActiveProcess (pid); @@ -2074,7 +2074,7 @@ windows_nat_target::detach (inferior *inf, int from_tty) { windows_continue (DBG_CONTINUE, -1, 0, true); - gdb::optional err; + std::optional err; do_synchronously ([&] () { if (!DebugActiveProcessStop (windows_process.current_event.dwProcessId)) @@ -2533,7 +2533,7 @@ windows_nat_target::create_inferior (const char *exec_file, #endif /* !__CYGWIN__ */ const char *allargs = origallargs.c_str (); PROCESS_INFORMATION pi; - gdb::optional ret; + std::optional ret; DWORD flags = 0; const std::string &inferior_tty = current_inferior ()->tty (); diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 0c98dc7e6b4..2d231b6f4bb 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -785,7 +785,7 @@ xinclude_start_include (struct gdb_xml_parser *parser, gdb_xml_error (parser, _("Maximum XInclude depth (%d) exceeded"), MAX_XINCLUDE_DEPTH); - gdb::optional text = data->fetcher (href); + std::optional text = data->fetcher (href); if (!text) gdb_xml_error (parser, _("Could not load XML document \"%s\""), href); @@ -960,7 +960,7 @@ show_debug_xml (struct ui_file *file, int from_tty, gdb_printf (file, _("XML debugging is %s.\n"), value); } -gdb::optional +std::optional xml_fetch_content_from_file (const char *filename, const char *dirname) { gdb_file_up file; diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 1f9ac68b745..8388276df25 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -24,7 +24,7 @@ #include "gdbsupport/gdb_obstack.h" #include "gdbsupport/xml-utils.h" #include "gdbsupport/byte-vector.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/function-view.h" struct gdb_xml_parser; @@ -49,7 +49,7 @@ LONGEST xml_builtin_xfer_partial (const char *filename, /* Callback to fetch a new XML file, based on the provided HREF. */ -using xml_fetch_another = gdb::function_view +using xml_fetch_another = gdb::function_view (const char * /* href */)>; /* Append the expansion of TEXT after processing tags in @@ -230,7 +230,7 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser, the text. If something goes wrong, return an uninstantiated optional and warn. */ -extern gdb::optional xml_fetch_content_from_file +extern std::optional xml_fetch_content_from_file (const char *filename, const char *dirname); #endif diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c index da1211ef8e9..cfb54347431 100644 --- a/gdb/xml-syscall.c +++ b/gdb/xml-syscall.c @@ -314,7 +314,7 @@ syscall_parse_xml (const char *document, xml_fetch_another fetcher) static struct syscalls_info * xml_init_syscalls_info (const char *filename) { - gdb::optional full_file + std::optional full_file = xml_fetch_content_from_file (filename, const_cast(gdb_datadir.c_str ())); if (!full_file) diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index a8b0b0566c7..daf123af69d 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -663,7 +663,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher) const struct target_desc * file_read_description_xml (const char *filename) { - gdb::optional tdesc_str + std::optional tdesc_str = xml_fetch_content_from_file (filename, NULL); if (!tdesc_str) { @@ -687,7 +687,7 @@ file_read_description_xml (const char *filename) is "target.xml". Other calls may be performed for the DTD or for . */ -static gdb::optional +static std::optional fetch_available_features_from_target (const char *name, target_ops *ops) { /* Read this object as a string. This ensures that a NUL @@ -704,7 +704,7 @@ fetch_available_features_from_target (const char *name, target_ops *ops) const struct target_desc * target_read_description_xml (struct target_ops *ops) { - gdb::optional tdesc_str + std::optional tdesc_str = fetch_available_features_from_target ("target.xml", ops); if (!tdesc_str) return NULL; @@ -721,7 +721,7 @@ target_read_description_xml (struct target_ops *ops) includes, but not parsing it. Used to dump whole tdesc as a single XML file. */ -gdb::optional +std::optional target_fetch_description_xml (struct target_ops *ops) { #if !defined(HAVE_LIBEXPAT) @@ -736,7 +736,7 @@ target_fetch_description_xml (struct target_ops *ops) return {}; #else - gdb::optional + std::optional tdesc_str = fetch_available_features_from_target ("target.xml", ops); if (!tdesc_str) return {}; @@ -765,6 +765,6 @@ string_read_description_xml (const char *xml) return tdesc_parse_xml (xml, [] (const char *href) { error (_("xincludes are unsupported with this method")); - return gdb::optional (); + return std::optional (); }); } diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h index 0fbfc7e043e..0ffca92ed7a 100644 --- a/gdb/xml-tdesc.h +++ b/gdb/xml-tdesc.h @@ -22,7 +22,7 @@ #ifndef XML_TDESC_H #define XML_TDESC_H -#include "gdbsupport/gdb_optional.h" +#include #include struct target_ops; @@ -42,7 +42,7 @@ const struct target_desc *target_read_description_xml (struct target_ops *); but not parsing it. Used to dump whole tdesc as a single XML file. Returns the description on success, and a disengaged optional otherwise. */ -gdb::optional target_fetch_description_xml (target_ops *ops); +std::optional target_fetch_description_xml (target_ops *ops); /* Take an xml string, parse it, and return the parsed description. Does not handle a string containing includes. */ diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index fcbe7bb64d7..70454652720 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -299,7 +299,7 @@ aarch64_fill_tlsregset (struct regcache *regcache, void *buf) collect_register (regcache, tls_regnum, tls_buf); /* Read TPIDR2, if it exists. */ - gdb::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); + std::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); if (regnum.has_value ()) collect_register (regcache, *regnum, tls_buf + sizeof (uint64_t)); @@ -316,7 +316,7 @@ aarch64_store_tlsregset (struct regcache *regcache, const void *buf) supply_register (regcache, tls_regnum, tls_buf); /* Write TPIDR2, if it exists. */ - gdb::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); + std::optional regnum = find_regno_no_throw (regcache->tdesc, "tpidr2"); if (regnum.has_value ()) supply_register (regcache, *regnum, tls_buf + sizeof (uint64_t)); diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 0b1141662ac..2e75a948a19 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -249,7 +249,7 @@ registers_from_string (struct regcache *regcache, char *buf) /* See regcache.h */ -gdb::optional +std::optional find_regno_no_throw (const struct target_desc *tdesc, const char *name) { for (int i = 0; i < tdesc->reg_defs.size (); ++i) @@ -263,7 +263,7 @@ find_regno_no_throw (const struct target_desc *tdesc, const char *name) int find_regno (const struct target_desc *tdesc, const char *name) { - gdb::optional regnum = find_regno_no_throw (tdesc, name); + std::optional regnum = find_regno_no_throw (tdesc, name); if (regnum.has_value ()) return *regnum; diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 7248bcf5808..4700c03f104 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -112,7 +112,7 @@ int register_size (const struct target_desc *tdesc, int n); /* No throw version of find_regno. If NAME is not a known register, return an empty value. */ -gdb::optional find_regno_no_throw (const struct target_desc *tdesc, +std::optional find_regno_no_throw (const struct target_desc *tdesc, const char *name); int find_regno (const struct target_desc *tdesc, const char *name); diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 3246957ec44..3842c80daff 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -1019,7 +1019,7 @@ get_child_debug_event (DWORD *continue_status, windows_process.attaching = 0; { - gdb::optional stop + std::optional stop = windows_process.fetch_pending_stop (debug_threads); if (stop.has_value ()) { diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h index 33b15a005f1..8908669696c 100644 --- a/gdbsupport/common-debug.h +++ b/gdbsupport/common-debug.h @@ -20,7 +20,7 @@ #ifndef COMMON_COMMON_DEBUG_H #define COMMON_COMMON_DEBUG_H -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/preprocessor.h" #include @@ -200,7 +200,7 @@ struct scoped_debug_start_end const char *m_end_prefix; /* The result of formatting the format string in the constructor. */ - gdb::optional m_msg; + std::optional m_msg; /* True is a non-nullptr format was passed to the constructor. */ bool m_with_format; diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 52e7fd2223f..031c2ff500f 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -33,7 +33,7 @@ #include #include "gdbsupport/gdb_sys_time.h" #include "gdbsupport/gdb_select.h" -#include "gdbsupport/gdb_optional.h" +#include #include "gdbsupport/scope-exit.h" /* See event-loop.h. */ @@ -246,7 +246,7 @@ gdb_do_one_event (int mstimeout) When the timeout is reached, events are not monitored again: they already have been checked in the loop above. */ - gdb::optional timer_id; + std::optional timer_id; SCOPE_EXIT { @@ -258,7 +258,7 @@ gdb_do_one_event (int mstimeout) timer_id = create_timer (mstimeout, [] (gdb_client_data arg) { - ((gdb::optional *) arg)->reset (); + ((std::optional *) arg)->reset (); }, &timer_id); return gdb_wait_for_event (1); diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc index 9e61fea1195..334bae88dce 100644 --- a/gdbsupport/filestuff.cc +++ b/gdbsupport/filestuff.cc @@ -504,7 +504,7 @@ mkdir_recursive (const char *dir) /* See gdbsupport/filestuff.h. */ -gdb::optional +std::optional read_text_file_to_string (const char *path) { gdb_file_up file = gdb_fopen_cloexec (path, "r"); diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h index 48bef51f259..206b51e50e9 100644 --- a/gdbsupport/filestuff.h +++ b/gdbsupport/filestuff.h @@ -131,6 +131,6 @@ extern bool mkdir_recursive (const char *dir); /* Read the entire content of file PATH into an std::string. */ -extern gdb::optional read_text_file_to_string (const char *path); +extern std::optional read_text_file_to_string (const char *path); #endif /* COMMON_FILESTUFF_H */ diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h index bf591ddf170..0552e1132f0 100644 --- a/gdbsupport/forward-scope-exit.h +++ b/gdbsupport/forward-scope-exit.h @@ -52,9 +52,9 @@ obj.release (); // Optional cancel if needed. forward_scope_exit is also handy when you would need to wrap a - scope_exit in a gdb::optional: + scope_exit in a std::optional: - gdb::optional cleanup; + std::optional cleanup; if (some condition) cleanup.emplace (thread); ... @@ -62,7 +62,7 @@ cleanup->release (); since with scope exit, you would have to know the scope_exit's - callable template type when you create the gdb::optional: + callable template type when you create the std::optional: gdb:optional> diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h index 01d6cf0e4fc..3cebce014ad 100644 --- a/gdbsupport/range-chain.h +++ b/gdbsupport/range-chain.h @@ -90,7 +90,7 @@ struct range_chain /* The current iterator into one of the vector ranges. If no value then this (outer) iterator is at the end of the overall range. */ - gdb::optional m_current; + std::optional m_current; /* Vector of ranges. */ const std::vector &m_ranges; }; diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h index a3f8361512a..558fb7f0a29 100644 --- a/gdbsupport/scoped_ignore_sigttou.h +++ b/gdbsupport/scoped_ignore_sigttou.h @@ -26,7 +26,7 @@ #ifdef SIGTTOU /* Simple wrapper that allows lazy initialization / destruction of T. - Slightly more efficient than gdb::optional, because it doesn't + Slightly more efficient than std::optional, because it doesn't carry storage to track whether the object has been initialized. */ template class lazy_init diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc index 1c871ed378f..bbe043dc0a3 100644 --- a/gdbsupport/thread-pool.cc +++ b/gdbsupport/thread-pool.cc @@ -225,7 +225,7 @@ thread_pool::thread_function () while (true) { - optional t; + std::optional t; { /* We want to hold the lock while examining the task list, but diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h index cb8696e1fa4..d5e1dc7fce1 100644 --- a/gdbsupport/thread-pool.h +++ b/gdbsupport/thread-pool.h @@ -30,7 +30,7 @@ #include #include #endif -#include "gdbsupport/gdb_optional.h" +#include namespace gdb { @@ -198,7 +198,7 @@ class thread_pool to represent a task. If the optional is empty, then this means that the receiving thread should terminate. If the optional is non-empty, then it is an actual task to evaluate. */ - std::queue> m_tasks; + std::queue> m_tasks; /* A condition variable and mutex that are used for communication between the main thread and the worker threads. */