From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdbsupport] Poison ctype.h / cctype functions
Date: Sun, 22 Mar 2026 17:03:38 +0100 [thread overview]
Message-ID: <20260322160338.3224997-1-tdevries@suse.de> (raw)
GDB generally uses c_isprint instead of isprint or std::isprint [1].
Poison uses of ctype.h / cctype functions in gdbsupport/poison.h.
This excludes isupper, islower and toupper because they're currently used in
GDB. Add a fixme to find out whether these exceptions are ok, and if so
document why, otherwise fix them.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34017
[1] https://sourceware.org/pipermail/gdb-patches/2026-March/226117.html
---
gdbsupport/poison.h | 52 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 904646110a5..0963645ee81 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -237,4 +237,56 @@ non-POD data type.");
#undef XOBNEWVEC
#define XOBNEWVEC(O, T, N) xobnewvec<T> (O, N)
+#ifndef IN_PROCESS_AGENT
+/* Poison functions like isprint from header filer ctype.h and std::isprint
+ from header file cctype. */
+
+#define POISON_CCTYPE(F) \
+ template<typename T> \
+ F \
+ { \
+ static_assert (false, "Please use gnulib's c-ctype.h"); \
+ return 0; \
+ }
+
+/* Poisoning of some functions is disabled:
+ - isupper, because it's used in ada_decode.
+ - islower and toupper, because they're used in UNCTRL from readline,
+ which is used in tui_redisplay_readline and gdb_fnprint.
+
+ FIXME: Find out whether these exceptions are ok, and if so document
+ why, otherwise fix them. */
+
+POISON_CCTYPE (int isalnum (T c));
+POISON_CCTYPE (int std::isalnum (T c));
+POISON_CCTYPE (int isalpha (T c));
+POISON_CCTYPE (int std::isalpha (T c));
+POISON_CCTYPE (int isblank (T c));
+POISON_CCTYPE (int std::isblank (T c));
+POISON_CCTYPE (int iscntrl (T c));
+POISON_CCTYPE (int std::iscntrl (T c));
+POISON_CCTYPE (int isdigit (T c));
+POISON_CCTYPE (int std::isdigit (T c));
+POISON_CCTYPE (int isgraph (T c));
+POISON_CCTYPE (int std::isgraph (T c));
+/* Disabled: int islower (T c)). */
+POISON_CCTYPE (int std::islower (T c));
+POISON_CCTYPE (int isprint (T c));
+POISON_CCTYPE (int std::isprint (T c));
+POISON_CCTYPE (int ispunct (T c));
+POISON_CCTYPE (int std::ispunct (T c));
+POISON_CCTYPE (int isspace (T c));
+POISON_CCTYPE (int std::isspace (T c));
+/* Disabled: int isupper (T c). */
+POISON_CCTYPE (int std::isupper (T c));
+POISON_CCTYPE (int isxdigit (T c));
+POISON_CCTYPE (int std::isxdigit (T c));
+POISON_CCTYPE (int tolower (T c));
+POISON_CCTYPE (int std::tolower (T c));
+/* Disabled: int toupper (T c). */
+POISON_CCTYPE (int std::toupper (T c));
+
+#undef POISON_CCTYPE
+#endif
+
#endif /* GDBSUPPORT_POISON_H */
base-commit: efc26507d9998eef6dc0b17480e0d921f40958c1
--
2.51.0
next reply other threads:[~2026-03-22 16:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-22 16:03 Tom de Vries [this message]
2026-03-23 14:17 ` Tom Tromey
2026-03-24 9:05 ` Tom de Vries
2026-03-24 13:28 ` Tom de Vries
2026-03-24 13:55 ` Tom de Vries
2026-03-24 14:42 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260322160338.3224997-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox