Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdbsupport] Poison ctype.h / cctype functions
@ 2026-03-22 16:03 Tom de Vries
  2026-03-23 14:17 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2026-03-22 16:03 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-24 14:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-22 16:03 [PATCH] [gdbsupport] Poison ctype.h / cctype functions Tom de Vries
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox