Re: [PATCH v2] [gdb] Add c_ctrl/c_unctrl

Tom Tromey
2026-03-25T17:40:51Z

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Use c_iscntrl/c_ctrl/c_unctrl instead of CTRL_CHAR/CTRL/UNCTRL, removing
Tom> redundant RUBOUT handling code.

This looks good to me but I had a small comment on the self-test.

Tom> + /* Consistency check. */
Tom> + for (unsigned int i = 0; i < 0x100; i++)
Tom> + {
Tom> + unsigned char ch = i;
Tom> + unsigned char unctrl_ch = c_unctrl (ch);

The main problem with the <ctype.h> functions is that they accept an int
but are undefined for values outside of 'unsigned char'. So calling
them with an ordinary 'char' value is bad, because on some platforms
char might be signed and so sign extension will apply.

So I think it would be valuable to test this. A simple way might be to
change this loop to iterate from -128 .. 255 and just pass that value.
This would effectively emulate both signed and unsigned char I think.

Tom