From patchwork Thu Apr 27 21:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manoj Gupta X-Patchwork-Id: 68423 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 ECFB33858C2D for ; Thu, 27 Apr 2023 21:46:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECFB33858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682632020; bh=p8PLhZcXNyT5csp0z990H4YfTVjcFNCar22mCMMdblI=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=e7Orkh2r6cHCHGHmzmHX89Ag/VfxUh1dwgQVWeYxVcv545Vmf2XLzD2sFG0x1iVW0 eZ365HiV1BOat0bR9y7o1KmIJhv3ZzGKMWV7/noHA/Ap/XSvlv4K2d2VR48oeNdO+/ eWTKMnBKMPo6xjy0unVfUW1cYQD9RB70JNEQ4OwQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by sourceware.org (Postfix) with ESMTPS id DF1B93858D37 for ; Thu, 27 Apr 2023 21:46:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF1B93858D37 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-b9a79db4e7fso1420803276.0 for ; Thu, 27 Apr 2023 14:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682631995; x=1685223995; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=p8PLhZcXNyT5csp0z990H4YfTVjcFNCar22mCMMdblI=; b=TL+HkTB1HBDFh5WB93DghepvE47VcGEPQfI56ZGKEra1fju+QAE5bXis611gGmIbbm wwjqP5mXdbL17i0p4W+1f9Z1zohjRVvaC7HkXER7OteGDcUxuZNOcGDk8QK6ANc896/X LJT9A4ygrpqog+t7aJQx4ARjOaZhZyqMCMJaG50kXQHyZ9lkoOxpYyjR6L0hg198XKDd c1GCQZCUxehoyYeAD6S9eLdYMthgiYelR7Bk0pMRqIMKQMaWuI8IwwjoA5Jx3vwbqmfw pmB9yH2abWez07U3oacQ6grBPgdfsFDP5SghJzr8ZCa2zee92Q6KGiSvJramlT0I3nTD a/Sw== X-Gm-Message-State: AC+VfDyCtSzbwlnL1lVx8Lc6TDc1rDKhI0jUiPEn78qqem/v3I2AU5XA ReCyujuWsUtHRoSoVkYTNxTYThhPEZVwDVF5ALtxLCVl0K4DtHiAPx3ryZisYzgjCOQ5CooSfK2 8VokAfamPqBEABHn+IVz00xD2OwBa/SdRSWlPu3B4G99S5Eezfxp6O08yIJd7v6UQypRCvkNjtX 7TCw== X-Google-Smtp-Source: ACHHUZ6sgGmhxVSI43oeXzVYj+b3RbHxMSBfbwvkA5y+YuOAsb6/j+6LVdB8odKNWrq3jjBQMv0J26qnb9RXZhyN X-Received: from manojg.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:3eb7]) (user=manojgupta job=sendgmr) by 2002:a05:6902:1891:b0:b99:4c9d:3b5a with SMTP id cj17-20020a056902189100b00b994c9d3b5amr1765787ybb.7.1682631995309; Thu, 27 Apr 2023 14:46:35 -0700 (PDT) Date: Thu, 27 Apr 2023 14:46:30 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230427214630.3099059-1-manojgupta@google.com> Subject: [PATCH v3] gdb: Fix building with latest libc++ To: gdb-patches@sourceware.org Cc: manojgupta@google.com X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Manoj Gupta via Gdb-patches From: Manoj Gupta Reply-To: Manoj Gupta Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Latest libc++[1] causes transitive include to when or header is included. This causes gdb to not build[2] since defines isupper/islower etc. functions that are explicitly macroed-out in safe-ctype.h to prevent their use. Use the suggestion from libc++ to include internally when building in C++ mode to avoid build errors. Use safe-gdb-ctype.h as the include instead of "safe-ctype.h" to keep this isolated to gdb since rest of binutils does not seem to use much C++. [1]: https://reviews.llvm.org/D144331 [2]: https://issuetracker.google.com/issues/277967395 --- gdb/cp-name-parser.y | 2 +- gdb/cp-support.c | 2 +- gdb/dictionary.c | 2 +- gdb/disasm.c | 2 +- gdb/dwarf2/cooked-index.c | 2 +- gdb/mi/mi-cmd-stack.c | 2 +- gdb/minsyms.c | 2 +- gdb/or1k-tdep.c | 2 +- gdb/printcmd.c | 2 +- gdb/riscv-tdep.c | 2 +- gdb/tui/tui-layout.c | 2 +- gdb/tui/tui-winsource.c | 2 +- gdb/xml-support.c | 2 +- gdbsupport/common-utils.cc | 2 +- gdbsupport/gdb-safe-ctype.h | 5 ++++- 15 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 175e763a423..80188074202 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -40,7 +40,7 @@ #include "defs.h" #include -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "demangle.h" #include "cp-support.h" #include "c-support.h" diff --git a/gdb/cp-support.c b/gdb/cp-support.c index f39c5d051dd..e804024c08f 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -36,7 +36,7 @@ #include "namespace.h" #include #include "gdbsupport/gdb_setjmp.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/selftest.h" #include "gdbsupport/gdb-sigmask.h" #include diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 403508adfdc..4f8df240a3e 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -26,7 +26,7 @@ #include "symtab.h" #include "buildsym.h" #include "dictionary.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include #include "language.h" diff --git a/gdb/disasm.c b/gdb/disasm.c index 03cd4b7ee02..e6b31bf3633 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -27,7 +27,7 @@ #include "gdbcmd.h" #include "dis-asm.h" #include "source.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include #include "gdbsupport/gdb_optional.h" #include "valprint.h" diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 1b1a16b1ae2..25635d9b72e 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -29,7 +29,7 @@ #include "observable.h" #include "run-on-main-thread.h" #include -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/selftest.h" #include #include diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 4c4662ab5d7..b8169a67e44 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -35,7 +35,7 @@ #include #include "mi-parse.h" #include "gdbsupport/gdb_optional.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "inferior.h" #include "observable.h" diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 3fa07f47b9f..e269420e87f 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -52,7 +52,7 @@ #include "cli/cli-utils.h" #include "gdbsupport/symbol.h" #include -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/parallel-for.h" #include "inferior.h" diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 0d520661f09..5cef1fa279c 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -29,7 +29,7 @@ #include "gdbtypes.h" #include "target.h" #include "regcache.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "reggroups.h" #include "arch-utils.h" #include "frame-unwind.h" diff --git a/gdb/printcmd.c b/gdb/printcmd.c index dd92e31d31b..d732c6d704d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -53,7 +53,7 @@ #include "source.h" #include "gdbsupport/byte-vector.h" #include "gdbsupport/gdb_optional.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/rsp-low.h" /* Chain containing all defined memory-tag subcommands. */ diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 144eb7e0132..500279e1ae9 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -56,7 +56,7 @@ #include "prologue-value.h" #include "arch/riscv.h" #include "riscv-ravenscar-thread.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" /* The stack must be 16-byte aligned. */ #define SP_ALIGNMENT 16 diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 01d243ba9a1..50c568fb7d7 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -43,7 +43,7 @@ #include "tui/tui-layout.h" #include "tui/tui-source.h" #include "gdb_curses.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *); diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 84f9d97c554..3c4ce501e5e 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -28,7 +28,7 @@ #include "source.h" #include "objfiles.h" #include "filenames.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "tui/tui.h" #include "tui/tui-data.h" diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 255c10864c5..0c98dc7e6b4 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -22,7 +22,7 @@ #include "xml-builtin.h" #include "xml-support.h" #include "gdbsupport/filestuff.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include #include diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc index 4a96f2c0e11..a2dde636011 100644 --- a/gdbsupport/common-utils.cc +++ b/gdbsupport/common-utils.cc @@ -20,7 +20,7 @@ #include "common-defs.h" #include "common-utils.h" #include "host-defs.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/gdb-xfree.h" void * diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h index f9743ba26f1..bec85c0014d 100644 --- a/gdbsupport/gdb-safe-ctype.h +++ b/gdbsupport/gdb-safe-ctype.h @@ -23,7 +23,9 @@ /* After safe-ctype.h is included, we can no longer use the host's ctype routines. Trying to do so results in compile errors. Code that uses safe-ctype.h that wants to refer to the locale-dependent - ctype functions must call these wrapper versions instead. */ + ctype functions must call these wrapper versions instead. + When compiling in C++ mode, also include before "safe-ctype.h" + which also defines is* functions. */ static inline int gdb_isprint (int ch) @@ -41,6 +43,7 @@ gdb_isprint (int ch) #undef ISUPPER #undef ISXDIGIT +#include #include "safe-ctype.h" #endif