1 /* Character set conversion support for GDB.
3 Copyright (C) 2001-2015 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
80 #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
81 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
82 #define GDB_DEFAULT_TARGET_WIDE_CHARSET "ISO-8859-1"
83 #undef DEFAULT_CHARSET_NAMES
84 #define DEFAULT_CHARSET_NAMES GDB_DEFAULT_HOST_CHARSET ,
89 #define iconv_open phony_iconv_open
91 #define iconv phony_iconv
93 #define iconv_close phony_iconv_close
96 #define ICONV_CONST const
99 phony_iconv_open (const char *to, const char *from)
101 /* We allow conversions from UTF-32BE, wchar_t, and the host charset.
102 We allow conversions to wchar_t and the host charset. */
103 if (strcmp (from, "UTF-32BE") && strcmp (from, "wchar_t")
104 && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
106 if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
109 /* Return 1 if we are converting from UTF-32BE, 0 otherwise. This is
110 used as a flag in calls to iconv. */
111 return !strcmp (from, "UTF-32BE");
115 phony_iconv_close (iconv_t arg)
121 phony_iconv (iconv_t utf_flag, const char **inbuf, size_t *inbytesleft,
122 char **outbuf, size_t *outbytesleft)
126 while (*inbytesleft >= 4)
131 for (j = 0; j < 4; ++j)
134 c += (*inbuf)[j] & 0xff;
149 if (*inbytesleft < 4)
157 /* In all other cases we simply copy input bytes to the
159 size_t amt = *inbytesleft;
161 if (amt > *outbytesleft)
163 memcpy (*outbuf, *inbuf, amt);
167 *outbytesleft -= amt;
176 /* The number of non-reversible conversions -- but they were all
181 #else /* PHONY_ICONV */
183 /* On systems that don't have EILSEQ, GNU iconv's iconv.h defines it
184 to ENOENT, while gnulib defines it to a different value. Always
185 map ENOENT to gnulib's EILSEQ, leaving callers agnostic. */
188 gdb_iconv (iconv_t utf_flag, ICONV_CONST char **inbuf, size_t *inbytesleft,
189 char **outbuf, size_t *outbytesleft)
193 ret = iconv (utf_flag, inbuf, inbytesleft, outbuf, outbytesleft);
200 #define iconv gdb_iconv
202 #endif /* PHONY_ICONV */
205 /* The global lists of character sets and translations. */
208 #ifndef GDB_DEFAULT_TARGET_CHARSET
209 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
212 #ifndef GDB_DEFAULT_TARGET_WIDE_CHARSET
213 #define GDB_DEFAULT_TARGET_WIDE_CHARSET "UTF-32"
216 static const char *auto_host_charset_name = GDB_DEFAULT_HOST_CHARSET;
217 static const char *host_charset_name = "auto";
219 show_host_charset_name (struct ui_file *file, int from_tty,
220 struct cmd_list_element *c,
223 if (!strcmp (value, "auto"))
224 fprintf_filtered (file,
225 _("The host character set is \"auto; currently %s\".\n"),
226 auto_host_charset_name);
228 fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
231 static const char *target_charset_name = "auto";
233 show_target_charset_name (struct ui_file *file, int from_tty,
234 struct cmd_list_element *c, const char *value)
236 if (!strcmp (value, "auto"))
237 fprintf_filtered (file,
238 _("The target character set is \"auto; "
239 "currently %s\".\n"),
240 gdbarch_auto_charset (get_current_arch ()));
242 fprintf_filtered (file, _("The target character set is \"%s\".\n"),
246 static const char *target_wide_charset_name = "auto";
248 show_target_wide_charset_name (struct ui_file *file,
250 struct cmd_list_element *c,
253 if (!strcmp (value, "auto"))
254 fprintf_filtered (file,
255 _("The target wide character set is \"auto; "
256 "currently %s\".\n"),
257 gdbarch_auto_wide_charset (get_current_arch ()));
259 fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
263 static const char *default_charset_names[] =
265 DEFAULT_CHARSET_NAMES
269 static const char **charset_enum;
272 /* If the target wide character set has big- or little-endian
273 variants, these are the corresponding names. */
274 static const char *target_wide_charset_be_name;
275 static const char *target_wide_charset_le_name;
277 /* The architecture for which the BE- and LE-names are valid. */
278 static struct gdbarch *be_le_arch;
280 /* A helper function which sets the target wide big- and little-endian
281 character set names, if possible. */
284 set_be_le_names (struct gdbarch *gdbarch)
287 const char *target_wide;
289 if (be_le_arch == gdbarch)
291 be_le_arch = gdbarch;
293 target_wide_charset_le_name = NULL;
294 target_wide_charset_be_name = NULL;
296 target_wide = target_wide_charset_name;
297 if (!strcmp (target_wide, "auto"))
298 target_wide = gdbarch_auto_wide_charset (gdbarch);
300 len = strlen (target_wide);
301 for (i = 0; charset_enum[i]; ++i)
303 if (strncmp (target_wide, charset_enum[i], len))
305 if ((charset_enum[i][len] == 'B'
306 || charset_enum[i][len] == 'L')
307 && charset_enum[i][len + 1] == 'E'
308 && charset_enum[i][len + 2] == '\0')
310 if (charset_enum[i][len] == 'B')
311 target_wide_charset_be_name = charset_enum[i];
313 target_wide_charset_le_name = charset_enum[i];
318 /* 'Set charset', 'set host-charset', 'set target-charset', 'set
319 target-wide-charset', 'set charset' sfunc's. */
322 validate (struct gdbarch *gdbarch)
325 const char *host_cset = host_charset ();
326 const char *target_cset = target_charset (gdbarch);
327 const char *target_wide_cset = target_wide_charset_name;
329 if (!strcmp (target_wide_cset, "auto"))
330 target_wide_cset = gdbarch_auto_wide_charset (gdbarch);
332 desc = iconv_open (target_wide_cset, host_cset);
333 if (desc == (iconv_t) -1)
334 error (_("Cannot convert between character sets `%s' and `%s'"),
335 target_wide_cset, host_cset);
338 desc = iconv_open (target_cset, host_cset);
339 if (desc == (iconv_t) -1)
340 error (_("Cannot convert between character sets `%s' and `%s'"),
341 target_cset, host_cset);
344 /* Clear the cache. */
348 /* This is the sfunc for the 'set charset' command. */
350 set_charset_sfunc (char *charset, int from_tty,
351 struct cmd_list_element *c)
353 /* CAREFUL: set the target charset here as well. */
354 target_charset_name = host_charset_name;
355 validate (get_current_arch ());
358 /* 'set host-charset' command sfunc. We need a wrapper here because
359 the function needs to have a specific signature. */
361 set_host_charset_sfunc (char *charset, int from_tty,
362 struct cmd_list_element *c)
364 validate (get_current_arch ());
367 /* Wrapper for the 'set target-charset' command. */
369 set_target_charset_sfunc (char *charset, int from_tty,
370 struct cmd_list_element *c)
372 validate (get_current_arch ());
375 /* Wrapper for the 'set target-wide-charset' command. */
377 set_target_wide_charset_sfunc (char *charset, int from_tty,
378 struct cmd_list_element *c)
380 validate (get_current_arch ());
383 /* sfunc for the 'show charset' command. */
385 show_charset (struct ui_file *file, int from_tty,
386 struct cmd_list_element *c,
389 show_host_charset_name (file, from_tty, c, host_charset_name);
390 show_target_charset_name (file, from_tty, c, target_charset_name);
391 show_target_wide_charset_name (file, from_tty, c,
392 target_wide_charset_name);
396 /* Accessor functions. */
401 if (!strcmp (host_charset_name, "auto"))
402 return auto_host_charset_name;
403 return host_charset_name;
407 target_charset (struct gdbarch *gdbarch)
409 if (!strcmp (target_charset_name, "auto"))
410 return gdbarch_auto_charset (gdbarch);
411 return target_charset_name;
415 target_wide_charset (struct gdbarch *gdbarch)
417 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
419 set_be_le_names (gdbarch);
420 if (byte_order == BFD_ENDIAN_BIG)
422 if (target_wide_charset_be_name)
423 return target_wide_charset_be_name;
427 if (target_wide_charset_le_name)
428 return target_wide_charset_le_name;
431 if (!strcmp (target_wide_charset_name, "auto"))
432 return gdbarch_auto_wide_charset (gdbarch);
434 return target_wide_charset_name;
438 /* Host character set management. For the time being, we assume that
439 the host character set is some superset of ASCII. */
442 host_letter_to_control_character (char c)
449 /* Convert a host character, C, to its hex value. C must already have
450 been validated using isxdigit. */
453 host_hex_value (char c)
457 if (c >= 'a' && c <= 'f')
459 gdb_assert (c >= 'A' && c <= 'F');
464 /* Public character management functions. */
466 /* A cleanup function which is run to close an iconv descriptor. */
469 cleanup_iconv (void *p)
472 iconv_close (*descp);
476 convert_between_encodings (const char *from, const char *to,
477 const gdb_byte *bytes, unsigned int num_bytes,
478 int width, struct obstack *output,
479 enum transliterations translit)
482 struct cleanup *cleanups;
484 ICONV_CONST char *inp;
485 unsigned int space_request;
487 /* Often, the host and target charsets will be the same. */
488 if (!strcmp (from, to))
490 obstack_grow (output, bytes, num_bytes);
494 desc = iconv_open (to, from);
495 if (desc == (iconv_t) -1)
496 perror_with_name (_("Converting character sets"));
497 cleanups = make_cleanup (cleanup_iconv, &desc);
500 inp = (ICONV_CONST char *) bytes;
502 space_request = num_bytes;
510 old_size = obstack_object_size (output);
511 obstack_blank (output, space_request);
513 outp = (char *) obstack_base (output) + old_size;
514 outleft = space_request;
516 r = iconv (desc, &inp, &inleft, &outp, &outleft);
518 /* Now make sure that the object on the obstack only includes
519 bytes we have converted. */
520 obstack_blank_fast (output, -outleft);
522 if (r == (size_t) -1)
530 /* Invalid input sequence. */
531 if (translit == translit_none)
532 error (_("Could not convert character "
533 "to `%s' character set"), to);
535 /* We emit escape sequence for the bytes, skip them,
537 for (i = 0; i < width; ++i)
541 xsnprintf (octal, sizeof (octal), "\\%.3o", *inp & 0xff);
542 obstack_grow_str (output, octal);
551 /* We ran out of space in the output buffer. Make it
552 bigger next time around. */
557 /* Incomplete input sequence. FIXME: ought to report this
558 to the caller somehow. */
563 perror_with_name (_("Internal error while "
564 "converting character sets"));
569 do_cleanups (cleanups);
574 /* An iterator that returns host wchar_t's from a target string. */
575 struct wchar_iterator
577 /* The underlying iconv descriptor. */
580 /* The input string. This is updated as convert characters. */
581 const gdb_byte *input;
582 /* The number of bytes remaining in the input. */
585 /* The width of an input character. */
588 /* The output buffer and its size. */
593 /* Create a new iterator. */
594 struct wchar_iterator *
595 make_wchar_iterator (const gdb_byte *input, size_t bytes,
596 const char *charset, size_t width)
598 struct wchar_iterator *result;
601 desc = iconv_open (INTERMEDIATE_ENCODING, charset);
602 if (desc == (iconv_t) -1)
603 perror_with_name (_("Converting character sets"));
605 result = XNEW (struct wchar_iterator);
607 result->input = input;
608 result->bytes = bytes;
609 result->width = width;
611 result->out = XNEW (gdb_wchar_t);
612 result->out_size = 1;
618 do_cleanup_iterator (void *p)
620 struct wchar_iterator *iter = p;
622 iconv_close (iter->desc);
628 make_cleanup_wchar_iterator (struct wchar_iterator *iter)
630 return make_cleanup (do_cleanup_iterator, iter);
634 wchar_iterate (struct wchar_iterator *iter,
635 enum wchar_iterate_result *out_result,
636 gdb_wchar_t **out_chars,
637 const gdb_byte **ptr,
642 /* Try to convert some characters. At first we try to convert just
643 a single character. The reason for this is that iconv does not
644 necessarily update its outgoing arguments when it encounters an
645 invalid input sequence -- but we want to reliably report this to
646 our caller so it can emit an escape sequence. */
648 while (iter->bytes > 0)
650 ICONV_CONST char *inptr = (ICONV_CONST char *) iter->input;
651 char *outptr = (char *) &iter->out[0];
652 const gdb_byte *orig_inptr = iter->input;
653 size_t orig_in = iter->bytes;
654 size_t out_avail = out_request * sizeof (gdb_wchar_t);
656 size_t r = iconv (iter->desc, &inptr, &iter->bytes, &outptr, &out_avail);
658 iter->input = (gdb_byte *) inptr;
660 if (r == (size_t) -1)
665 /* Invalid input sequence. We still might have
666 converted a character; if so, return it. */
667 if (out_avail < out_request * sizeof (gdb_wchar_t))
670 /* Otherwise skip the first invalid character, and let
671 the caller know about it. */
672 *out_result = wchar_iterate_invalid;
675 iter->input += iter->width;
676 iter->bytes -= iter->width;
680 /* We ran out of space. We still might have converted a
681 character; if so, return it. Otherwise, grow the
682 buffer and try again. */
683 if (out_avail < out_request * sizeof (gdb_wchar_t))
687 if (out_request > iter->out_size)
689 iter->out_size = out_request;
690 iter->out = xrealloc (iter->out,
691 out_request * sizeof (gdb_wchar_t));
696 /* Incomplete input sequence. Let the caller know, and
697 arrange for future calls to see EOF. */
698 *out_result = wchar_iterate_incomplete;
705 perror_with_name (_("Internal error while "
706 "converting character sets"));
710 /* We converted something. */
711 num = out_request - out_avail / sizeof (gdb_wchar_t);
712 *out_result = wchar_iterate_ok;
713 *out_chars = iter->out;
715 *len = orig_in - iter->bytes;
720 *out_result = wchar_iterate_eof;
725 /* The charset.c module initialization function. */
727 extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
729 static VEC (char_ptr) *charsets;
734 find_charset_names (void)
736 VEC_safe_push (char_ptr, charsets, GDB_DEFAULT_HOST_CHARSET);
737 VEC_safe_push (char_ptr, charsets, NULL);
740 #else /* PHONY_ICONV */
742 /* Sometimes, libiconv redefines iconvlist as libiconvlist -- but
743 provides different symbols in the static and dynamic libraries.
744 So, configure may see libiconvlist but not iconvlist. But, calling
745 iconvlist is the right thing to do and will work. Hence we do a
746 check here but unconditionally call iconvlist below. */
747 #if defined (HAVE_ICONVLIST) || defined (HAVE_LIBICONVLIST)
749 /* A helper function that adds some character sets to the vector of
750 all character sets. This is a callback function for iconvlist. */
753 add_one (unsigned int count, const char *const *names, void *data)
757 for (i = 0; i < count; ++i)
758 VEC_safe_push (char_ptr, charsets, xstrdup (names[i]));
764 find_charset_names (void)
766 iconvlist (add_one, NULL);
767 VEC_safe_push (char_ptr, charsets, NULL);
772 /* Return non-zero if LINE (output from iconv) should be ignored.
773 Older iconv programs (e.g. 2.2.2) include the human readable
774 introduction even when stdout is not a tty. Newer versions omit
775 the intro if stdout is not a tty. */
778 ignore_line_p (const char *line)
780 /* This table is used to filter the output. If this text appears
781 anywhere in the line, it is ignored (strstr is used). */
782 static const char * const ignore_lines[] =
787 "listed with several",
792 for (i = 0; ignore_lines[i] != NULL; ++i)
794 if (strstr (line, ignore_lines[i]) != NULL)
802 find_charset_names (void)
804 struct pex_obj *child;
809 struct gdb_environ *iconv_env;
812 /* Older iconvs, e.g. 2.2.2, don't omit the intro text if stdout is
813 not a tty. We need to recognize it and ignore it. This text is
814 subject to translation, so force LANGUAGE=C. */
815 iconv_env = make_environ ();
816 init_environ (iconv_env);
817 set_in_environ (iconv_env, "LANGUAGE", "C");
818 set_in_environ (iconv_env, "LC_ALL", "C");
820 child = pex_init (PEX_USE_PIPES, "iconv", NULL);
824 char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
825 ICONV_BIN_RELOCATABLE);
826 iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
830 iconv_program = xstrdup ("iconv");
832 args[0] = iconv_program;
835 flags = PEX_STDERR_TO_STDOUT;
839 /* Note that we simply ignore errors here. */
840 if (!pex_run_in_environment (child, flags,
841 args[0], args, environ_vector (iconv_env),
844 FILE *in = pex_read_output (child, 0);
846 /* POSIX says that iconv -l uses an unspecified format. We
847 parse the glibc and libiconv formats; feel free to add others
850 while (in != NULL && !feof (in))
852 /* The size of buf is chosen arbitrarily. */
857 r = fgets (buf, sizeof (buf), in);
863 if (ignore_line_p (r))
866 /* Strip off the newline. */
868 /* Strip off one or two '/'s. glibc will print lines like
869 "8859_7//", but also "10646-1:1993/UCS4/". */
870 if (buf[len - 1] == '/')
872 if (buf[len - 1] == '/')
876 /* libiconv will print multiple entries per line, separated
877 by spaces. Older iconvs will print multiple entries per
878 line, indented by two spaces, and separated by ", "
879 (i.e. the human readable form). */
886 /* Skip leading blanks. */
887 for (p = start; *p && *p == ' '; ++p)
890 /* Find the next space, comma, or end-of-line. */
891 for ( ; *p && *p != ' ' && *p != ','; ++p)
893 /* Ignore an empty result. */
898 VEC_safe_push (char_ptr, charsets, xstrdup (start));
901 /* Skip any extra spaces. */
902 for (start = p + 1; *start && *start == ' '; ++start)
907 if (pex_get_status (child, 1, &status)
908 && WIFEXITED (status) && !WEXITSTATUS (status))
913 xfree (iconv_program);
915 free_environ (iconv_env);
919 /* Some error occurred, so drop the vector. */
920 free_char_ptr_vec (charsets);
924 VEC_safe_push (char_ptr, charsets, NULL);
927 #endif /* HAVE_ICONVLIST || HAVE_LIBICONVLIST */
928 #endif /* PHONY_ICONV */
930 /* The "auto" target charset used by default_auto_charset. */
931 static const char *auto_target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
934 default_auto_charset (void)
936 return auto_target_charset_name;
940 default_auto_wide_charset (void)
942 return GDB_DEFAULT_TARGET_WIDE_CHARSET;
946 #ifdef USE_INTERMEDIATE_ENCODING_FUNCTION
947 /* Macro used for UTF or UCS endianness suffix. */
949 #define ENDIAN_SUFFIX "BE"
951 #define ENDIAN_SUFFIX "LE"
954 /* The code below serves to generate a compile time error if
955 gdb_wchar_t type is not of size 2 nor 4, despite the fact that
956 macro __STDC_ISO_10646__ is defined.
957 This is better than a gdb_assert call, because GDB cannot handle
958 strings correctly if this size is different. */
960 extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
961 || sizeof (gdb_wchar_t) == 4)
964 /* intermediate_encoding returns the charset used internally by
965 GDB to convert between target and host encodings. As the test above
966 compiled, sizeof (gdb_wchar_t) is either 2 or 4 bytes.
967 UTF-16/32 is tested first, UCS-2/4 is tested as a second option,
968 otherwise an error is generated. */
971 intermediate_encoding (void)
974 static const char *stored_result = NULL;
978 return stored_result;
979 result = xstrprintf ("UTF-%d%s", (int) (sizeof (gdb_wchar_t) * 8),
981 /* Check that the name is supported by iconv_open. */
982 desc = iconv_open (result, host_charset ());
983 if (desc != (iconv_t) -1)
986 stored_result = result;
989 /* Not valid, free the allocated memory. */
991 /* Second try, with UCS-2 type. */
992 result = xstrprintf ("UCS-%d%s", (int) sizeof (gdb_wchar_t),
994 /* Check that the name is supported by iconv_open. */
995 desc = iconv_open (result, host_charset ());
996 if (desc != (iconv_t) -1)
999 stored_result = result;
1002 /* Not valid, free the allocated memory. */
1004 /* No valid charset found, generate error here. */
1005 error (_("Unable to find a vaild charset for string conversions"));
1008 #endif /* USE_INTERMEDIATE_ENCODING_FUNCTION */
1011 _initialize_charset (void)
1013 /* The first element is always "auto". */
1014 VEC_safe_push (char_ptr, charsets, xstrdup ("auto"));
1015 find_charset_names ();
1017 if (VEC_length (char_ptr, charsets) > 1)
1018 charset_enum = (const char **) VEC_address (char_ptr, charsets);
1020 charset_enum = default_charset_names;
1023 #ifdef HAVE_LANGINFO_CODESET
1024 /* The result of nl_langinfo may be overwritten later. This may
1025 leak a little memory, if the user later changes the host charset,
1026 but that doesn't matter much. */
1027 auto_host_charset_name = xstrdup (nl_langinfo (CODESET));
1028 /* Solaris will return `646' here -- but the Solaris iconv then does
1029 not accept this. Darwin (and maybe FreeBSD) may return "" here,
1030 which GNU libiconv doesn't like (infinite loop). */
1031 if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name)
1032 auto_host_charset_name = "ASCII";
1033 auto_target_charset_name = auto_host_charset_name;
1034 #elif defined (USE_WIN32API)
1036 /* "CP" + x<=5 digits + paranoia. */
1037 static char w32_host_default_charset[16];
1039 snprintf (w32_host_default_charset, sizeof w32_host_default_charset,
1041 auto_host_charset_name = w32_host_default_charset;
1042 auto_target_charset_name = auto_host_charset_name;
1047 add_setshow_enum_cmd ("charset", class_support,
1048 charset_enum, &host_charset_name, _("\
1049 Set the host and target character sets."), _("\
1050 Show the host and target character sets."), _("\
1051 The `host character set' is the one used by the system GDB is running on.\n\
1052 The `target character set' is the one used by the program being debugged.\n\
1053 You may only use supersets of ASCII for your host character set; GDB does\n\
1054 not support any others.\n\
1055 To see a list of the character sets GDB supports, type `set charset <TAB>'."),
1056 /* Note that the sfunc below needs to set
1057 target_charset_name, because the 'set
1058 charset' command sets two variables. */
1061 &setlist, &showlist);
1063 add_setshow_enum_cmd ("host-charset", class_support,
1064 charset_enum, &host_charset_name, _("\
1065 Set the host character set."), _("\
1066 Show the host character set."), _("\
1067 The `host character set' is the one used by the system GDB is running on.\n\
1068 You may only use supersets of ASCII for your host character set; GDB does\n\
1069 not support any others.\n\
1070 To see a list of the character sets GDB supports, type `set host-charset <TAB>'."),
1071 set_host_charset_sfunc,
1072 show_host_charset_name,
1073 &setlist, &showlist);
1075 add_setshow_enum_cmd ("target-charset", class_support,
1076 charset_enum, &target_charset_name, _("\
1077 Set the target character set."), _("\
1078 Show the target character set."), _("\
1079 The `target character set' is the one used by the program being debugged.\n\
1080 GDB translates characters and strings between the host and target\n\
1081 character sets as needed.\n\
1082 To see a list of the character sets GDB supports, type `set target-charset'<TAB>"),
1083 set_target_charset_sfunc,
1084 show_target_charset_name,
1085 &setlist, &showlist);
1087 add_setshow_enum_cmd ("target-wide-charset", class_support,
1088 charset_enum, &target_wide_charset_name,
1090 Set the target wide character set."), _("\
1091 Show the target wide character set."), _("\
1092 The `target wide character set' is the one used by the program being debugged.\
1093 \nIn particular it is the encoding used by `wchar_t'.\n\
1094 GDB translates characters and strings between the host and target\n\
1095 character sets as needed.\n\
1096 To see a list of the character sets GDB supports, type\n\
1097 `set target-wide-charset'<TAB>"),
1098 set_target_wide_charset_sfunc,
1099 show_target_wide_charset_name,
1100 &setlist, &showlist);