1 /* Character set conversion support for GDB.
3 Copyright (C) 2001-2016 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "gdb_obstack.h"
25 #include "charset-list.h"
28 #include "arch-utils.h"
36 /* How GDB's character set support works
38 GDB has three global settings:
40 - The `current host character set' is the character set GDB should
41 use in talking to the user, and which (hopefully) the user's
42 terminal knows how to display properly. Most users should not
45 - The `current target character set' is the character set the
46 program being debugged uses.
48 - The `current target wide character set' is the wide character set
49 the program being debugged uses, that is, the encoding used for
52 There are commands to set each of these, and mechanisms for
53 choosing reasonable default values. GDB has a global list of
54 character sets that it can use as its host or target character
57 The header file `charset.h' declares various functions that
58 different pieces of GDB need to perform tasks like:
60 - printing target strings and characters to the user's terminal
61 (mostly target->host conversions),
63 - building target-appropriate representations of strings and
64 characters the user enters in expressions (mostly host->target
69 To avoid excessive code duplication and maintenance efforts,
70 GDB simply requires a capable iconv function. Users on platforms
71 without a suitable iconv can use the GNU iconv library. */
76 /* Provide a phony iconv that does as little as possible. Also,
77 arrange for there to be a single available character set. */
79 #undef GDB_DEFAULT_HOST_CHARSET
81 # define GDB_DEFAULT_HOST_CHARSET "CP1252"
83 # define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
85 #define GDB_DEFAULT_TARGET_CHARSET GDB_DEFAULT_HOST_CHARSET
86 #define GDB_DEFAULT_TARGET_WIDE_CHARSET "UTF-32"
87 #undef DEFAULT_CHARSET_NAMES
88 #define DEFAULT_CHARSET_NAMES GDB_DEFAULT_HOST_CHARSET ,
93 #define iconv_open phony_iconv_open
95 #define iconv phony_iconv
97 #define iconv_close phony_iconv_close
100 #define ICONV_CONST const
102 /* We allow conversions from UTF-32, wchar_t, and the host charset.
103 We allow conversions to wchar_t and the host charset.
104 Return 1 if we are converting from UTF-32BE, 2 if from UTF32-LE,
105 0 otherwise. This is used as a flag in calls to iconv. */
108 phony_iconv_open (const char *to, const char *from)
110 if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
113 if (!strcmp (from, "UTF-32BE") || !strcmp (from, "UTF-32"))
116 if (!strcmp (from, "UTF-32LE"))
119 if (strcmp (from, "wchar_t") && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
126 phony_iconv_close (iconv_t arg)
132 phony_iconv (iconv_t utf_flag, const char **inbuf, size_t *inbytesleft,
133 char **outbuf, size_t *outbytesleft)
137 enum bfd_endian endian
138 = utf_flag == 1 ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
139 while (*inbytesleft >= 4)
142 = extract_unsigned_integer ((const gdb_byte *)*inbuf, 4, endian);
149 if (*outbytesleft < 1)
163 /* Partial sequence on input. */
170 /* In all other cases we simply copy input bytes to the
172 size_t amt = *inbytesleft;
174 if (amt > *outbytesleft)
176 memcpy (*outbuf, *inbuf, amt);
180 *outbytesleft -= amt;
188 /* The number of non-reversible conversions -- but they were all
193 #else /* PHONY_ICONV */
195 /* On systems that don't have EILSEQ, GNU iconv's iconv.h defines it
196 to ENOENT, while gnulib defines it to a different value. Always
197 map ENOENT to gnulib's EILSEQ, leaving callers agnostic. */
200 gdb_iconv (iconv_t utf_flag, ICONV_CONST char **inbuf, size_t *inbytesleft,
201 char **outbuf, size_t *outbytesleft)
205 ret = iconv (utf_flag, inbuf, inbytesleft, outbuf, outbytesleft);
212 #define iconv gdb_iconv
214 #endif /* PHONY_ICONV */
217 /* The global lists of character sets and translations. */
220 #ifndef GDB_DEFAULT_TARGET_CHARSET
221 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
224 #ifndef GDB_DEFAULT_TARGET_WIDE_CHARSET
225 #define GDB_DEFAULT_TARGET_WIDE_CHARSET "UTF-32"
228 static const char *auto_host_charset_name = GDB_DEFAULT_HOST_CHARSET;
229 static const char *host_charset_name = "auto";
231 show_host_charset_name (struct ui_file *file, int from_tty,
232 struct cmd_list_element *c,
235 if (!strcmp (value, "auto"))
236 fprintf_filtered (file,
237 _("The host character set is \"auto; currently %s\".\n"),
238 auto_host_charset_name);
240 fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
243 static const char *target_charset_name = "auto";
245 show_target_charset_name (struct ui_file *file, int from_tty,
246 struct cmd_list_element *c, const char *value)
248 if (!strcmp (value, "auto"))
249 fprintf_filtered (file,
250 _("The target character set is \"auto; "
251 "currently %s\".\n"),
252 gdbarch_auto_charset (get_current_arch ()));
254 fprintf_filtered (file, _("The target character set is \"%s\".\n"),
258 static const char *target_wide_charset_name = "auto";
260 show_target_wide_charset_name (struct ui_file *file,
262 struct cmd_list_element *c,
265 if (!strcmp (value, "auto"))
266 fprintf_filtered (file,
267 _("The target wide character set is \"auto; "
268 "currently %s\".\n"),
269 gdbarch_auto_wide_charset (get_current_arch ()));
271 fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
275 static const char *default_charset_names[] =
277 DEFAULT_CHARSET_NAMES
281 static const char **charset_enum;
284 /* If the target wide character set has big- or little-endian
285 variants, these are the corresponding names. */
286 static const char *target_wide_charset_be_name;
287 static const char *target_wide_charset_le_name;
289 /* The architecture for which the BE- and LE-names are valid. */
290 static struct gdbarch *be_le_arch;
292 /* A helper function which sets the target wide big- and little-endian
293 character set names, if possible. */
296 set_be_le_names (struct gdbarch *gdbarch)
299 const char *target_wide;
301 if (be_le_arch == gdbarch)
303 be_le_arch = gdbarch;
306 /* Match the wide charset names recognized by phony_iconv_open. */
307 target_wide_charset_le_name = "UTF-32LE";
308 target_wide_charset_be_name = "UTF-32BE";
310 target_wide_charset_le_name = NULL;
311 target_wide_charset_be_name = NULL;
313 target_wide = target_wide_charset_name;
314 if (!strcmp (target_wide, "auto"))
315 target_wide = gdbarch_auto_wide_charset (gdbarch);
317 len = strlen (target_wide);
318 for (i = 0; charset_enum[i]; ++i)
320 if (strncmp (target_wide, charset_enum[i], len))
322 if ((charset_enum[i][len] == 'B'
323 || charset_enum[i][len] == 'L')
324 && charset_enum[i][len + 1] == 'E'
325 && charset_enum[i][len + 2] == '\0')
327 if (charset_enum[i][len] == 'B')
328 target_wide_charset_be_name = charset_enum[i];
330 target_wide_charset_le_name = charset_enum[i];
333 # endif /* PHONY_ICONV */
336 /* 'Set charset', 'set host-charset', 'set target-charset', 'set
337 target-wide-charset', 'set charset' sfunc's. */
340 validate (struct gdbarch *gdbarch)
343 const char *host_cset = host_charset ();
344 const char *target_cset = target_charset (gdbarch);
345 const char *target_wide_cset = target_wide_charset_name;
347 if (!strcmp (target_wide_cset, "auto"))
348 target_wide_cset = gdbarch_auto_wide_charset (gdbarch);
350 desc = iconv_open (target_wide_cset, host_cset);
351 if (desc == (iconv_t) -1)
352 error (_("Cannot convert between character sets `%s' and `%s'"),
353 target_wide_cset, host_cset);
356 desc = iconv_open (target_cset, host_cset);
357 if (desc == (iconv_t) -1)
358 error (_("Cannot convert between character sets `%s' and `%s'"),
359 target_cset, host_cset);
362 /* Clear the cache. */
366 /* This is the sfunc for the 'set charset' command. */
368 set_charset_sfunc (char *charset, int from_tty,
369 struct cmd_list_element *c)
371 /* CAREFUL: set the target charset here as well. */
372 target_charset_name = host_charset_name;
373 validate (get_current_arch ());
376 /* 'set host-charset' command sfunc. We need a wrapper here because
377 the function needs to have a specific signature. */
379 set_host_charset_sfunc (char *charset, int from_tty,
380 struct cmd_list_element *c)
382 validate (get_current_arch ());
385 /* Wrapper for the 'set target-charset' command. */
387 set_target_charset_sfunc (char *charset, int from_tty,
388 struct cmd_list_element *c)
390 validate (get_current_arch ());
393 /* Wrapper for the 'set target-wide-charset' command. */
395 set_target_wide_charset_sfunc (char *charset, int from_tty,
396 struct cmd_list_element *c)
398 validate (get_current_arch ());
401 /* sfunc for the 'show charset' command. */
403 show_charset (struct ui_file *file, int from_tty,
404 struct cmd_list_element *c,
407 show_host_charset_name (file, from_tty, c, host_charset_name);
408 show_target_charset_name (file, from_tty, c, target_charset_name);
409 show_target_wide_charset_name (file, from_tty, c,
410 target_wide_charset_name);
414 /* Accessor functions. */
419 if (!strcmp (host_charset_name, "auto"))
420 return auto_host_charset_name;
421 return host_charset_name;
425 target_charset (struct gdbarch *gdbarch)
427 if (!strcmp (target_charset_name, "auto"))
428 return gdbarch_auto_charset (gdbarch);
429 return target_charset_name;
433 target_wide_charset (struct gdbarch *gdbarch)
435 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
437 set_be_le_names (gdbarch);
438 if (byte_order == BFD_ENDIAN_BIG)
440 if (target_wide_charset_be_name)
441 return target_wide_charset_be_name;
445 if (target_wide_charset_le_name)
446 return target_wide_charset_le_name;
449 if (!strcmp (target_wide_charset_name, "auto"))
450 return gdbarch_auto_wide_charset (gdbarch);
452 return target_wide_charset_name;
456 /* Host character set management. For the time being, we assume that
457 the host character set is some superset of ASCII. */
460 host_letter_to_control_character (char c)
467 /* Convert a host character, C, to its hex value. C must already have
468 been validated using isxdigit. */
471 host_hex_value (char c)
475 if (c >= 'a' && c <= 'f')
477 gdb_assert (c >= 'A' && c <= 'F');
482 /* Public character management functions. */
484 /* A cleanup function which is run to close an iconv descriptor. */
487 cleanup_iconv (void *p)
489 iconv_t *descp = (iconv_t *) p;
490 iconv_close (*descp);
494 convert_between_encodings (const char *from, const char *to,
495 const gdb_byte *bytes, unsigned int num_bytes,
496 int width, struct obstack *output,
497 enum transliterations translit)
500 struct cleanup *cleanups;
502 ICONV_CONST char *inp;
503 unsigned int space_request;
505 /* Often, the host and target charsets will be the same. */
506 if (!strcmp (from, to))
508 obstack_grow (output, bytes, num_bytes);
512 desc = iconv_open (to, from);
513 if (desc == (iconv_t) -1)
514 perror_with_name (_("Converting character sets"));
515 cleanups = make_cleanup (cleanup_iconv, &desc);
518 inp = (ICONV_CONST char *) bytes;
520 space_request = num_bytes;
528 old_size = obstack_object_size (output);
529 obstack_blank (output, space_request);
531 outp = (char *) obstack_base (output) + old_size;
532 outleft = space_request;
534 r = iconv (desc, &inp, &inleft, &outp, &outleft);
536 /* Now make sure that the object on the obstack only includes
537 bytes we have converted. */
538 obstack_blank_fast (output, -outleft);
540 if (r == (size_t) -1)
548 /* Invalid input sequence. */
549 if (translit == translit_none)
550 error (_("Could not convert character "
551 "to `%s' character set"), to);
553 /* We emit escape sequence for the bytes, skip them,
555 for (i = 0; i < width; ++i)
559 xsnprintf (octal, sizeof (octal), "\\%.3o", *inp & 0xff);
560 obstack_grow_str (output, octal);
569 /* We ran out of space in the output buffer. Make it
570 bigger next time around. */
575 /* Incomplete input sequence. FIXME: ought to report this
576 to the caller somehow. */
581 perror_with_name (_("Internal error while "
582 "converting character sets"));
587 do_cleanups (cleanups);
592 /* Create a new iterator. */
593 wchar_iterator::wchar_iterator (const gdb_byte *input, size_t bytes,
594 const char *charset, size_t width)
600 m_desc = iconv_open (INTERMEDIATE_ENCODING, charset);
601 if (m_desc == (iconv_t) -1)
602 perror_with_name (_("Converting character sets"));
605 wchar_iterator::~wchar_iterator ()
607 if (m_desc != (iconv_t) -1)
608 iconv_close (m_desc);
612 wchar_iterator::iterate (enum wchar_iterate_result *out_result,
613 gdb_wchar_t **out_chars,
614 const gdb_byte **ptr,
619 /* Try to convert some characters. At first we try to convert just
620 a single character. The reason for this is that iconv does not
621 necessarily update its outgoing arguments when it encounters an
622 invalid input sequence -- but we want to reliably report this to
623 our caller so it can emit an escape sequence. */
627 ICONV_CONST char *inptr = (ICONV_CONST char *) m_input;
628 char *outptr = (char *) m_out.data ();
629 const gdb_byte *orig_inptr = m_input;
630 size_t orig_in = m_bytes;
631 size_t out_avail = out_request * sizeof (gdb_wchar_t);
633 size_t r = iconv (m_desc, &inptr, &m_bytes, &outptr, &out_avail);
635 m_input = (gdb_byte *) inptr;
637 if (r == (size_t) -1)
642 /* Invalid input sequence. We still might have
643 converted a character; if so, return it. */
644 if (out_avail < out_request * sizeof (gdb_wchar_t))
647 /* Otherwise skip the first invalid character, and let
648 the caller know about it. */
649 *out_result = wchar_iterate_invalid;
657 /* We ran out of space. We still might have converted a
658 character; if so, return it. Otherwise, grow the
659 buffer and try again. */
660 if (out_avail < out_request * sizeof (gdb_wchar_t))
664 if (out_request > m_out.size ())
665 m_out.reserve (out_request);
669 /* Incomplete input sequence. Let the caller know, and
670 arrange for future calls to see EOF. */
671 *out_result = wchar_iterate_incomplete;
678 perror_with_name (_("Internal error while "
679 "converting character sets"));
683 /* We converted something. */
684 num = out_request - out_avail / sizeof (gdb_wchar_t);
685 *out_result = wchar_iterate_ok;
686 *out_chars = m_out.data ();
688 *len = orig_in - m_bytes;
693 *out_result = wchar_iterate_eof;
698 /* The charset.c module initialization function. */
700 extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
702 static VEC (char_ptr) *charsets;
707 find_charset_names (void)
709 VEC_safe_push (char_ptr, charsets, GDB_DEFAULT_HOST_CHARSET);
710 VEC_safe_push (char_ptr, charsets, NULL);
713 #else /* PHONY_ICONV */
715 /* Sometimes, libiconv redefines iconvlist as libiconvlist -- but
716 provides different symbols in the static and dynamic libraries.
717 So, configure may see libiconvlist but not iconvlist. But, calling
718 iconvlist is the right thing to do and will work. Hence we do a
719 check here but unconditionally call iconvlist below. */
720 #if defined (HAVE_ICONVLIST) || defined (HAVE_LIBICONVLIST)
722 /* A helper function that adds some character sets to the vector of
723 all character sets. This is a callback function for iconvlist. */
726 add_one (unsigned int count, const char *const *names, void *data)
730 for (i = 0; i < count; ++i)
731 VEC_safe_push (char_ptr, charsets, xstrdup (names[i]));
737 find_charset_names (void)
739 iconvlist (add_one, NULL);
740 VEC_safe_push (char_ptr, charsets, NULL);
745 /* Return non-zero if LINE (output from iconv) should be ignored.
746 Older iconv programs (e.g. 2.2.2) include the human readable
747 introduction even when stdout is not a tty. Newer versions omit
748 the intro if stdout is not a tty. */
751 ignore_line_p (const char *line)
753 /* This table is used to filter the output. If this text appears
754 anywhere in the line, it is ignored (strstr is used). */
755 static const char * const ignore_lines[] =
760 "listed with several",
765 for (i = 0; ignore_lines[i] != NULL; ++i)
767 if (strstr (line, ignore_lines[i]) != NULL)
775 find_charset_names (void)
777 struct pex_obj *child;
782 struct gdb_environ *iconv_env;
785 /* Older iconvs, e.g. 2.2.2, don't omit the intro text if stdout is
786 not a tty. We need to recognize it and ignore it. This text is
787 subject to translation, so force LANGUAGE=C. */
788 iconv_env = make_environ ();
789 init_environ (iconv_env);
790 set_in_environ (iconv_env, "LANGUAGE", "C");
791 set_in_environ (iconv_env, "LC_ALL", "C");
793 child = pex_init (PEX_USE_PIPES, "iconv", NULL);
797 char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
798 ICONV_BIN_RELOCATABLE);
799 iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
803 iconv_program = xstrdup ("iconv");
805 args[0] = iconv_program;
808 flags = PEX_STDERR_TO_STDOUT;
812 /* Note that we simply ignore errors here. */
813 if (!pex_run_in_environment (child, flags,
814 args[0], args, environ_vector (iconv_env),
817 FILE *in = pex_read_output (child, 0);
819 /* POSIX says that iconv -l uses an unspecified format. We
820 parse the glibc and libiconv formats; feel free to add others
823 while (in != NULL && !feof (in))
825 /* The size of buf is chosen arbitrarily. */
830 r = fgets (buf, sizeof (buf), in);
836 if (ignore_line_p (r))
839 /* Strip off the newline. */
841 /* Strip off one or two '/'s. glibc will print lines like
842 "8859_7//", but also "10646-1:1993/UCS4/". */
843 if (buf[len - 1] == '/')
845 if (buf[len - 1] == '/')
849 /* libiconv will print multiple entries per line, separated
850 by spaces. Older iconvs will print multiple entries per
851 line, indented by two spaces, and separated by ", "
852 (i.e. the human readable form). */
859 /* Skip leading blanks. */
860 for (p = start; *p && *p == ' '; ++p)
863 /* Find the next space, comma, or end-of-line. */
864 for ( ; *p && *p != ' ' && *p != ','; ++p)
866 /* Ignore an empty result. */
871 VEC_safe_push (char_ptr, charsets, xstrdup (start));
874 /* Skip any extra spaces. */
875 for (start = p + 1; *start && *start == ' '; ++start)
880 if (pex_get_status (child, 1, &status)
881 && WIFEXITED (status) && !WEXITSTATUS (status))
886 xfree (iconv_program);
888 free_environ (iconv_env);
892 /* Some error occurred, so drop the vector. */
893 free_char_ptr_vec (charsets);
897 VEC_safe_push (char_ptr, charsets, NULL);
900 #endif /* HAVE_ICONVLIST || HAVE_LIBICONVLIST */
901 #endif /* PHONY_ICONV */
903 /* The "auto" target charset used by default_auto_charset. */
904 static const char *auto_target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
907 default_auto_charset (void)
909 return auto_target_charset_name;
913 default_auto_wide_charset (void)
915 return GDB_DEFAULT_TARGET_WIDE_CHARSET;
919 #ifdef USE_INTERMEDIATE_ENCODING_FUNCTION
920 /* Macro used for UTF or UCS endianness suffix. */
922 #define ENDIAN_SUFFIX "BE"
924 #define ENDIAN_SUFFIX "LE"
927 /* The code below serves to generate a compile time error if
928 gdb_wchar_t type is not of size 2 nor 4, despite the fact that
929 macro __STDC_ISO_10646__ is defined.
930 This is better than a gdb_assert call, because GDB cannot handle
931 strings correctly if this size is different. */
933 extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
934 || sizeof (gdb_wchar_t) == 4)
937 /* intermediate_encoding returns the charset used internally by
938 GDB to convert between target and host encodings. As the test above
939 compiled, sizeof (gdb_wchar_t) is either 2 or 4 bytes.
940 UTF-16/32 is tested first, UCS-2/4 is tested as a second option,
941 otherwise an error is generated. */
944 intermediate_encoding (void)
947 static const char *stored_result = NULL;
951 return stored_result;
952 result = xstrprintf ("UTF-%d%s", (int) (sizeof (gdb_wchar_t) * 8),
954 /* Check that the name is supported by iconv_open. */
955 desc = iconv_open (result, host_charset ());
956 if (desc != (iconv_t) -1)
959 stored_result = result;
962 /* Not valid, free the allocated memory. */
964 /* Second try, with UCS-2 type. */
965 result = xstrprintf ("UCS-%d%s", (int) sizeof (gdb_wchar_t),
967 /* Check that the name is supported by iconv_open. */
968 desc = iconv_open (result, host_charset ());
969 if (desc != (iconv_t) -1)
972 stored_result = result;
975 /* Not valid, free the allocated memory. */
977 /* No valid charset found, generate error here. */
978 error (_("Unable to find a vaild charset for string conversions"));
981 #endif /* USE_INTERMEDIATE_ENCODING_FUNCTION */
984 _initialize_charset (void)
986 /* The first element is always "auto". */
987 VEC_safe_push (char_ptr, charsets, xstrdup ("auto"));
988 find_charset_names ();
990 if (VEC_length (char_ptr, charsets) > 1)
991 charset_enum = (const char **) VEC_address (char_ptr, charsets);
993 charset_enum = default_charset_names;
996 #ifdef HAVE_LANGINFO_CODESET
997 /* The result of nl_langinfo may be overwritten later. This may
998 leak a little memory, if the user later changes the host charset,
999 but that doesn't matter much. */
1000 auto_host_charset_name = xstrdup (nl_langinfo (CODESET));
1001 /* Solaris will return `646' here -- but the Solaris iconv then does
1002 not accept this. Darwin (and maybe FreeBSD) may return "" here,
1003 which GNU libiconv doesn't like (infinite loop). */
1004 if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name)
1005 auto_host_charset_name = "ASCII";
1006 auto_target_charset_name = auto_host_charset_name;
1007 #elif defined (USE_WIN32API)
1009 /* "CP" + x<=5 digits + paranoia. */
1010 static char w32_host_default_charset[16];
1012 snprintf (w32_host_default_charset, sizeof w32_host_default_charset,
1014 auto_host_charset_name = w32_host_default_charset;
1015 auto_target_charset_name = auto_host_charset_name;
1020 add_setshow_enum_cmd ("charset", class_support,
1021 charset_enum, &host_charset_name, _("\
1022 Set the host and target character sets."), _("\
1023 Show the host and target character sets."), _("\
1024 The `host character set' is the one used by the system GDB is running on.\n\
1025 The `target character set' is the one used by the program being debugged.\n\
1026 You may only use supersets of ASCII for your host character set; GDB does\n\
1027 not support any others.\n\
1028 To see a list of the character sets GDB supports, type `set charset <TAB>'."),
1029 /* Note that the sfunc below needs to set
1030 target_charset_name, because the 'set
1031 charset' command sets two variables. */
1034 &setlist, &showlist);
1036 add_setshow_enum_cmd ("host-charset", class_support,
1037 charset_enum, &host_charset_name, _("\
1038 Set the host character set."), _("\
1039 Show the host character set."), _("\
1040 The `host character set' is the one used by the system GDB is running on.\n\
1041 You may only use supersets of ASCII for your host character set; GDB does\n\
1042 not support any others.\n\
1043 To see a list of the character sets GDB supports, type `set host-charset <TAB>'."),
1044 set_host_charset_sfunc,
1045 show_host_charset_name,
1046 &setlist, &showlist);
1048 add_setshow_enum_cmd ("target-charset", class_support,
1049 charset_enum, &target_charset_name, _("\
1050 Set the target character set."), _("\
1051 Show the target character set."), _("\
1052 The `target character set' is the one used by the program being debugged.\n\
1053 GDB translates characters and strings between the host and target\n\
1054 character sets as needed.\n\
1055 To see a list of the character sets GDB supports, type `set target-charset'<TAB>"),
1056 set_target_charset_sfunc,
1057 show_target_charset_name,
1058 &setlist, &showlist);
1060 add_setshow_enum_cmd ("target-wide-charset", class_support,
1061 charset_enum, &target_wide_charset_name,
1063 Set the target wide character set."), _("\
1064 Show the target wide character set."), _("\
1065 The `target wide character set' is the one used by the program being debugged.\
1066 \nIn particular it is the encoding used by `wchar_t'.\n\
1067 GDB translates characters and strings between the host and target\n\
1068 character sets as needed.\n\
1069 To see a list of the character sets GDB supports, type\n\
1070 `set target-wide-charset'<TAB>"),
1071 set_target_wide_charset_sfunc,
1072 show_target_wide_charset_name,
1073 &setlist, &showlist);