1 /* Character set conversion support for GDB.
3 Copyright (C) 2001, 2003, 2007 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 2 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, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
25 #include "gdb_assert.h"
28 #include "gdb_string.h"
36 /* How GDB's character set support works
38 GDB has two 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.
44 - The `current target character set' is the character set the
45 program being debugged uses.
47 There are commands to set each of these, and mechanisms for
48 choosing reasonable default values. GDB has a global list of
49 character sets that it can use as its host or target character
52 The header file `charset.h' declares various functions that
53 different pieces of GDB need to perform tasks like:
55 - printing target strings and characters to the user's terminal
56 (mostly target->host conversions),
58 - building target-appropriate representations of strings and
59 characters the user enters in expressions (mostly host->target
64 Now, many of these operations are specific to a particular
65 host/target character set pair. If GDB supports N character sets,
66 there are N^2 possible pairs. This means that, the larger GDB's
67 repertoire of character sets gets, the more expensive it gets to add
70 To make sure that GDB can do the right thing for every possible
71 pairing of host and target character set, while still allowing
72 GDB's repertoire to scale, we use a two-tiered approach:
74 - We maintain a global table of "translations" --- groups of
75 functions specific to a particular pair of character sets.
77 - However, a translation can be incomplete: some functions can be
78 omitted. Where there is not a translation to specify exactly
79 what function to use, we provide reasonable defaults. The
80 default behaviors try to use the "iconv" library functions, which
81 support a wide range of character sets. However, even if iconv
82 is not available, there are fallbacks to support trivial
83 translations: when the host and target character sets are the
87 /* The character set and translation structures. */
90 /* A character set GDB knows about. GDB only supports character sets
91 with stateless encodings, in which every character is one byte
95 /* A singly-linked list of all known charsets. */
98 /* The name of the character set. Comparisons on character set
99 names are case-sensitive. */
102 /* Non-zero iff this character set can be used as a host character
103 set. At present, GDB basically assumes that the host character
104 set is a superset of ASCII. */
105 int valid_host_charset;
107 /* Pointers to charset-specific functions that depend only on a
108 single character set, and data pointers to pass to them. */
109 int (*host_char_print_literally) (void *baton,
111 void *host_char_print_literally_baton;
113 int (*target_char_to_control_char) (void *baton,
115 int *target_ctrl_char);
116 void *target_char_to_control_char_baton;
120 /* A translation from one character set to another. */
123 /* A singly-linked list of all known translations. */
124 struct translation *next;
126 /* This structure describes functions going from the FROM character
127 set to the TO character set. Comparisons on character set names
128 are case-sensitive. */
129 const char *from, *to;
131 /* Pointers to translation-specific functions, and data pointers to
132 pass to them. These pointers can be zero, indicating that GDB
133 should fall back on the default behavior. We hope the default
134 behavior will be correct for many from/to pairs, reducing the
135 number of translations that need to be registered explicitly. */
137 /* TARGET_CHAR is in the `from' charset.
138 Returns a string in the `to' charset. */
139 const char *(*c_target_char_has_backslash_escape) (void *baton,
141 void *c_target_char_has_backslash_escape_baton;
143 /* HOST_CHAR is in the `from' charset.
144 TARGET_CHAR points to a char in the `to' charset. */
145 int (*c_parse_backslash) (void *baton, int host_char, int *target_char);
146 void *c_parse_backslash_baton;
148 /* This is used for the host_char_to_target and target_char_to_host
150 int (*convert_char) (void *baton, int from, int *to);
151 void *convert_char_baton;
156 /* The global lists of character sets and translations. */
159 #ifndef GDB_DEFAULT_HOST_CHARSET
160 #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
163 #ifndef GDB_DEFAULT_TARGET_CHARSET
164 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
167 static const char *host_charset_name = GDB_DEFAULT_HOST_CHARSET;
169 show_host_charset_name (struct ui_file *file, int from_tty,
170 struct cmd_list_element *c,
173 fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
176 static const char *target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
178 show_target_charset_name (struct ui_file *file, int from_tty,
179 struct cmd_list_element *c, const char *value)
181 fprintf_filtered (file, _("The target character set is \"%s\".\n"),
186 static const char *host_charset_enum[] =
193 static const char *target_charset_enum[] =
202 /* The global list of all the charsets GDB knows about. */
203 static struct charset *all_charsets;
207 register_charset (struct charset *cs)
209 struct charset **ptr;
211 /* Put the new charset on the end, so that the list ends up in the
212 same order as the registrations in the _initialize function. */
213 for (ptr = &all_charsets; *ptr; ptr = &(*ptr)->next)
221 static struct charset *
222 lookup_charset (const char *name)
226 for (cs = all_charsets; cs; cs = cs->next)
227 if (! strcmp (name, cs->name))
234 /* The global list of translations. */
235 static struct translation *all_translations;
239 register_translation (struct translation *t)
241 t->next = all_translations;
242 all_translations = t;
246 static struct translation *
247 lookup_translation (const char *from, const char *to)
249 struct translation *t;
251 for (t = all_translations; t; t = t->next)
252 if (! strcmp (from, t->from)
253 && ! strcmp (to, t->to))
261 /* Constructing charsets. */
263 /* Allocate, initialize and return a straightforward charset.
264 Use this function, rather than creating the structures yourself,
265 so that we can add new fields to the structure in the future without
266 having to tweak all the old charset descriptions. */
267 static struct charset *
268 simple_charset (const char *name,
269 int valid_host_charset,
270 int (*host_char_print_literally) (void *baton, int host_char),
271 void *host_char_print_literally_baton,
272 int (*target_char_to_control_char) (void *baton,
274 int *target_ctrl_char),
275 void *target_char_to_control_char_baton)
277 struct charset *cs = xmalloc (sizeof (*cs));
279 memset (cs, 0, sizeof (*cs));
281 cs->valid_host_charset = valid_host_charset;
282 cs->host_char_print_literally = host_char_print_literally;
283 cs->host_char_print_literally_baton = host_char_print_literally_baton;
284 cs->target_char_to_control_char = target_char_to_control_char;
285 cs->target_char_to_control_char_baton = target_char_to_control_char_baton;
292 /* ASCII functions. */
295 ascii_print_literally (void *baton, int c)
299 return (0x20 <= c && c <= 0x7e);
304 ascii_to_control (void *baton, int c, int *ctrl_char)
306 *ctrl_char = (c & 037);
311 /* ISO-8859 family functions. */
315 iso_8859_print_literally (void *baton, int c)
319 return ((0x20 <= c && c <= 0x7e) /* ascii printables */
320 || (! sevenbit_strings && 0xA0 <= c)); /* iso 8859 printables */
325 iso_8859_to_control (void *baton, int c, int *ctrl_char)
327 *ctrl_char = (c & 0200) | (c & 037);
332 /* Construct an ISO-8859-like character set. */
333 static struct charset *
334 iso_8859_family_charset (const char *name)
336 return simple_charset (name, 1,
337 iso_8859_print_literally, 0,
338 iso_8859_to_control, 0);
343 /* EBCDIC family functions. */
347 ebcdic_print_literally (void *baton, int c)
351 return (64 <= c && c <= 254);
356 ebcdic_to_control (void *baton, int c, int *ctrl_char)
358 /* There are no control character equivalents in EBCDIC. Use
364 /* Construct an EBCDIC-like character set. */
365 static struct charset *
366 ebcdic_family_charset (const char *name)
368 return simple_charset (name, 0,
369 ebcdic_print_literally, 0,
370 ebcdic_to_control, 0);
377 /* Fallback functions using iconv. */
379 #if defined(HAVE_ICONV)
381 struct cached_iconv {
382 struct charset *from, *to;
387 /* Make sure the iconv cache *CI contains an iconv descriptor
388 translating from FROM to TO. If it already does, fine; otherwise,
389 close any existing descriptor, and open up a new one. On success,
390 return zero; on failure, return -1 and set errno. */
392 check_iconv_cache (struct cached_iconv *ci,
393 struct charset *from,
398 /* Does the cached iconv descriptor match the conversion we're trying
402 && ci->i != (iconv_t) 0)
405 /* It doesn't. If we actually had any iconv descriptor open at
406 all, close it now. */
407 if (ci->i != (iconv_t) 0)
412 if (iconv_close (i) == -1)
413 error (_("Error closing `iconv' descriptor for "
414 "`%s'-to-`%s' character conversion: %s"),
415 ci->from->name, ci->to->name, safe_strerror (errno));
418 /* Open a new iconv descriptor for the required conversion. */
419 i = iconv_open (to->name, from->name);
420 if (i == (iconv_t) -1)
431 /* Convert FROM_CHAR using the cached iconv conversion *CI. Return
432 non-zero if the conversion was successful, zero otherwise. */
434 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
437 ICONV_CONST char *from_ptr = &from;
438 char to, *to_ptr = &to;
439 size_t from_left = sizeof (from), to_left = sizeof (to);
441 gdb_assert (ci->i != (iconv_t) 0);
444 if (iconv (ci->i, &from_ptr, &from_left, &to_ptr, &to_left)
447 /* These all suggest that the input or output character sets
448 have multi-byte encodings of some characters, which means
449 it's unsuitable for use as a GDB character set. We should
450 never have selected it. */
451 gdb_assert (errno != E2BIG && errno != EINVAL);
453 /* This suggests a bug in the code managing *CI. */
454 gdb_assert (errno != EBADF);
456 /* This seems to mean that there is no equivalent character in
457 the `to' character set. */
461 /* Anything else is mysterious. */
462 internal_error (__FILE__, __LINE__,
463 _("Error converting character `%d' from `%s' to `%s' "
464 "character set: %s"),
465 from_char, ci->from->name, ci->to->name,
466 safe_strerror (errno));
469 /* If the pointers weren't advanced across the input, that also
470 suggests something was wrong. */
471 gdb_assert (from_left == 0 && to_left == 0);
473 *to_char = (unsigned char) to;
479 register_iconv_charsets (void)
481 /* Here we should check whether various character sets were
482 recognized by the local iconv implementation.
484 The first implementation registered a bunch of character sets
485 recognized by iconv, but then we discovered that iconv on Solaris
486 and iconv on GNU/Linux had no character sets in common. So we
487 replaced them with the hard-coded tables that appear later in the
491 #endif /* defined (HAVE_ICONV) */
494 /* Fallback routines for systems without iconv. */
496 #if ! defined (HAVE_ICONV)
497 struct cached_iconv { char nothing; };
500 check_iconv_cache (struct cached_iconv *ci,
501 struct charset *from,
509 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
511 /* This function should never be called. */
516 register_iconv_charsets (void)
520 #endif /* ! defined(HAVE_ICONV) */
523 /* Default trivial conversion functions. */
526 identity_either_char_to_other (void *baton, int either_char, int *other_char)
528 *other_char = either_char;
534 /* Default non-trivial conversion functions. */
537 static char backslashable[] = "abfnrtv";
538 static char *backslashed[] = {"a", "b", "f", "n", "r", "t", "v", "0"};
539 static char represented[] = "\a\b\f\n\r\t\v";
542 /* Translate TARGET_CHAR into the host character set, and see if it
543 matches any of our standard escape sequences. */
545 default_c_target_char_has_backslash_escape (void *baton, int target_char)
550 /* If target_char has no equivalent in the host character set,
551 assume it doesn't have a backslashed form. */
552 if (! target_char_to_host (target_char, &host_char))
555 ix = strchr (represented, host_char);
557 return backslashed[ix - represented];
563 /* Translate the backslash the way we would in the host character set,
564 and then try to translate that into the target character set. */
566 default_c_parse_backslash (void *baton, int host_char, int *target_char)
570 ix = strchr (backslashable, host_char);
575 return host_char_to_target (represented[ix - backslashable],
580 /* Convert using a cached iconv descriptor. */
582 iconv_convert (void *baton, int from_char, int *to_char)
584 struct cached_iconv *ci = baton;
585 return cached_iconv_convert (ci, from_char, to_char);
590 /* Conversion tables. */
593 /* I'd much rather fall back on iconv whenever possible. But the
594 character set names you use with iconv aren't standardized at all,
595 a lot of platforms have really meager character set coverage, etc.
596 I wanted to have at least something we could use to exercise the
597 test suite on all platforms.
599 In the long run, we should have a configure-time process explore
600 somehow which character sets the host platform supports, and some
601 arrangement that allows GDB users to use platform-indepedent names
602 for character sets. */
605 /* We generated these tables using iconv on a GNU/Linux machine. */
608 static int ascii_to_iso_8859_1_table[] = {
609 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
610 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
611 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
612 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
613 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
614 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
615 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
616 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
617 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
618 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
620 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
623 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
628 static int ascii_to_ebcdic_us_table[] = {
629 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
630 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
631 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
632 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
633 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
634 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
635 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
636 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
637 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
638 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
640 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
642 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
643 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
648 static int ascii_to_ibm1047_table[] = {
649 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
650 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
651 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
652 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
653 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
654 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
655 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
656 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
657 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
658 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
659 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
660 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
661 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
663 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
664 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
668 static int iso_8859_1_to_ascii_table[] = {
669 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
670 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
671 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
672 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
673 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
674 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
675 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
676 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
677 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
678 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
679 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
680 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
681 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
682 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
683 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
684 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
688 static int iso_8859_1_to_ebcdic_us_table[] = {
689 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
690 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
691 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
692 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
693 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
694 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
695 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
696 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
697 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
698 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
699 -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
700 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
701 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
702 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
703 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
704 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
708 static int iso_8859_1_to_ibm1047_table[] = {
709 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
710 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
711 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
712 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
713 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
714 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
715 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
716 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
717 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
718 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
719 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
720 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
721 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
722 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
723 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
724 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
728 static int ebcdic_us_to_ascii_table[] = {
729 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
730 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
731 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
732 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
733 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
734 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
735 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
736 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
737 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
738 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
739 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
740 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
741 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
742 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
743 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
744 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
748 static int ebcdic_us_to_iso_8859_1_table[] = {
749 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
750 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
751 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
752 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
753 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
754 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
755 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
756 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
757 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
758 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
759 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
760 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
761 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
762 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
763 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
764 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
768 static int ebcdic_us_to_ibm1047_table[] = {
769 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
770 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
771 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
772 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
773 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
774 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
775 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
776 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
777 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
778 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
779 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
780 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
781 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
782 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
783 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
784 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
788 static int ibm1047_to_ascii_table[] = {
789 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
790 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
791 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
792 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
793 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
794 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
795 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
796 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
797 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
798 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
799 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
800 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
801 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
802 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
803 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
804 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
808 static int ibm1047_to_iso_8859_1_table[] = {
809 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
810 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
811 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
812 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
813 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
814 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
815 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
816 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
817 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
818 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
819 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
820 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
821 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
822 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
823 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
824 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
828 static int ibm1047_to_ebcdic_us_table[] = {
829 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
830 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
831 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
832 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
833 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
834 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
835 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
836 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
837 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
838 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
839 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
840 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
841 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
842 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
843 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
844 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
849 table_convert_char (void *baton, int from, int *to)
851 int *table = (int *) baton;
853 if (0 <= from && from <= 255
854 && table[from] != -1)
864 static struct translation *
865 table_translation (const char *from, const char *to, int *table,
866 const char *(*c_target_char_has_backslash_escape)
867 (void *baton, int target_char),
868 void *c_target_char_has_backslash_escape_baton,
869 int (*c_parse_backslash) (void *baton,
872 void *c_parse_backslash_baton)
874 struct translation *t = xmalloc (sizeof (*t));
876 memset (t, 0, sizeof (*t));
879 t->c_target_char_has_backslash_escape = c_target_char_has_backslash_escape;
880 t->c_target_char_has_backslash_escape_baton
881 = c_target_char_has_backslash_escape_baton;
882 t->c_parse_backslash = c_parse_backslash;
883 t->c_parse_backslash_baton = c_parse_backslash_baton;
884 t->convert_char = table_convert_char;
885 t->convert_char_baton = (void *) table;
891 static struct translation *
892 simple_table_translation (const char *from, const char *to, int *table)
894 return table_translation (from, to, table, 0, 0, 0, 0);
899 /* Setting and retrieving the host and target charsets. */
902 /* The current host and target character sets. */
903 static struct charset *current_host_charset, *current_target_charset;
905 /* The current functions and batons we should use for the functions in
908 static const char *(*c_target_char_has_backslash_escape_func)
909 (void *baton, int target_char);
910 static void *c_target_char_has_backslash_escape_baton;
912 static int (*c_parse_backslash_func) (void *baton,
915 static void *c_parse_backslash_baton;
917 static int (*host_char_to_target_func) (void *baton,
920 static void *host_char_to_target_baton;
922 static int (*target_char_to_host_func) (void *baton,
925 static void *target_char_to_host_baton;
928 /* Cached iconv conversions, that might be useful to fallback
930 static struct cached_iconv cached_iconv_host_to_target;
931 static struct cached_iconv cached_iconv_target_to_host;
934 /* Charset structures manipulation functions. */
936 static struct charset *
937 lookup_charset_or_error (const char *name)
939 struct charset *cs = lookup_charset (name);
942 error (_("GDB doesn't know of any character set named `%s'."), name);
948 check_valid_host_charset (struct charset *cs)
950 if (! cs->valid_host_charset)
951 error (_("GDB can't use `%s' as its host character set."), cs->name);
954 /* Set the host and target character sets to HOST and TARGET. */
956 set_host_and_target_charsets (struct charset *host, struct charset *target)
958 struct translation *h2t, *t2h;
960 /* If they're not both initialized yet, then just do nothing for
961 now. As soon as we're done running our initialize function,
962 everything will be initialized. */
963 if (! host || ! target)
965 current_host_charset = host;
966 current_target_charset = target;
970 h2t = lookup_translation (host->name, target->name);
971 t2h = lookup_translation (target->name, host->name);
973 /* If the translations don't provide conversion functions, make sure
974 iconv can back them up. Do this *before* modifying any state. */
977 if (! h2t || ! h2t->convert_char)
979 if (check_iconv_cache (&cached_iconv_host_to_target, host, target)
981 error (_("GDB can't convert from the `%s' character set to `%s'."),
982 host->name, target->name);
984 if (! t2h || ! t2h->convert_char)
986 if (check_iconv_cache (&cached_iconv_target_to_host, target, host)
988 error (_("GDB can't convert from the `%s' character set to `%s'."),
989 target->name, host->name);
993 if (t2h && t2h->c_target_char_has_backslash_escape)
995 c_target_char_has_backslash_escape_func
996 = t2h->c_target_char_has_backslash_escape;
997 c_target_char_has_backslash_escape_baton
998 = t2h->c_target_char_has_backslash_escape_baton;
1001 c_target_char_has_backslash_escape_func
1002 = default_c_target_char_has_backslash_escape;
1004 if (h2t && h2t->c_parse_backslash)
1006 c_parse_backslash_func = h2t->c_parse_backslash;
1007 c_parse_backslash_baton = h2t->c_parse_backslash_baton;
1010 c_parse_backslash_func = default_c_parse_backslash;
1012 if (h2t && h2t->convert_char)
1014 host_char_to_target_func = h2t->convert_char;
1015 host_char_to_target_baton = h2t->convert_char_baton;
1017 else if (host == target)
1018 host_char_to_target_func = identity_either_char_to_other;
1021 host_char_to_target_func = iconv_convert;
1022 host_char_to_target_baton = &cached_iconv_host_to_target;
1025 if (t2h && t2h->convert_char)
1027 target_char_to_host_func = t2h->convert_char;
1028 target_char_to_host_baton = t2h->convert_char_baton;
1030 else if (host == target)
1031 target_char_to_host_func = identity_either_char_to_other;
1034 target_char_to_host_func = iconv_convert;
1035 target_char_to_host_baton = &cached_iconv_target_to_host;
1038 current_host_charset = host;
1039 current_target_charset = target;
1042 /* Do the real work of setting the host charset. */
1044 set_host_charset (const char *charset)
1046 struct charset *cs = lookup_charset_or_error (charset);
1047 check_valid_host_charset (cs);
1048 set_host_and_target_charsets (cs, current_target_charset);
1051 /* Do the real work of setting the target charset. */
1053 set_target_charset (const char *charset)
1055 struct charset *cs = lookup_charset_or_error (charset);
1057 set_host_and_target_charsets (current_host_charset, cs);
1061 /* 'Set charset', 'set host-charset', 'set target-charset', 'show
1062 charset' sfunc's. */
1064 /* This is the sfunc for the 'set charset' command. */
1066 set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
1068 struct charset *cs = lookup_charset_or_error (host_charset_name);
1069 check_valid_host_charset (cs);
1070 /* CAREFUL: set the target charset here as well. */
1071 target_charset_name = host_charset_name;
1072 set_host_and_target_charsets (cs, cs);
1075 /* 'set host-charset' command sfunc. We need a wrapper here because
1076 the function needs to have a specific signature. */
1078 set_host_charset_sfunc (char *charset, int from_tty,
1079 struct cmd_list_element *c)
1081 set_host_charset (host_charset_name);
1084 /* Wrapper for the 'set target-charset' command. */
1086 set_target_charset_sfunc (char *charset, int from_tty,
1087 struct cmd_list_element *c)
1089 set_target_charset (target_charset_name);
1092 /* sfunc for the 'show charset' command. */
1094 show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
1097 if (current_host_charset == current_target_charset)
1098 fprintf_filtered (file,
1099 _("The current host and target character set is `%s'.\n"),
1103 fprintf_filtered (file, _("The current host character set is `%s'.\n"),
1105 fprintf_filtered (file, _("The current target character set is `%s'.\n"),
1111 /* Accessor functions. */
1116 return current_host_charset->name;
1120 target_charset (void)
1122 return current_target_charset->name;
1127 /* Public character management functions. */
1131 c_target_char_has_backslash_escape (int target_char)
1133 return ((*c_target_char_has_backslash_escape_func)
1134 (c_target_char_has_backslash_escape_baton, target_char));
1139 c_parse_backslash (int host_char, int *target_char)
1141 return (*c_parse_backslash_func) (c_parse_backslash_baton,
1142 host_char, target_char);
1147 host_char_print_literally (int host_char)
1149 return ((*current_host_charset->host_char_print_literally)
1150 (current_host_charset->host_char_print_literally_baton,
1156 target_char_to_control_char (int target_char, int *target_ctrl_char)
1158 return ((*current_target_charset->target_char_to_control_char)
1159 (current_target_charset->target_char_to_control_char_baton,
1160 target_char, target_ctrl_char));
1165 host_char_to_target (int host_char, int *target_char)
1167 return ((*host_char_to_target_func)
1168 (host_char_to_target_baton, host_char, target_char));
1173 target_char_to_host (int target_char, int *host_char)
1175 return ((*target_char_to_host_func)
1176 (target_char_to_host_baton, target_char, host_char));
1181 /* The charset.c module initialization function. */
1183 extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
1186 _initialize_charset (void)
1188 struct cmd_list_element *new_cmd;
1190 /* Register all the character set GDB knows about.
1192 You should use the same names that iconv does, where possible, to
1193 take advantage of the iconv-based default behaviors.
1195 CAUTION: if you register a character set, you must also register
1196 as many translations as are necessary to make that character set
1197 interoperate correctly with all the other character sets. We do
1198 provide default behaviors when no translation is available, or
1199 when a translation's function pointer for a particular operation
1200 is zero. Hopefully, these defaults will be correct often enough
1201 that we won't need to provide too many translations. */
1202 register_charset (simple_charset ("ASCII", 1,
1203 ascii_print_literally, 0,
1204 ascii_to_control, 0));
1205 register_charset (iso_8859_family_charset ("ISO-8859-1"));
1206 register_charset (ebcdic_family_charset ("EBCDIC-US"));
1207 register_charset (ebcdic_family_charset ("IBM1047"));
1208 register_iconv_charsets ();
1211 struct { char *from; char *to; int *table; } tlist[] = {
1212 { "ASCII", "ISO-8859-1", ascii_to_iso_8859_1_table },
1213 { "ASCII", "EBCDIC-US", ascii_to_ebcdic_us_table },
1214 { "ASCII", "IBM1047", ascii_to_ibm1047_table },
1215 { "ISO-8859-1", "ASCII", iso_8859_1_to_ascii_table },
1216 { "ISO-8859-1", "EBCDIC-US", iso_8859_1_to_ebcdic_us_table },
1217 { "ISO-8859-1", "IBM1047", iso_8859_1_to_ibm1047_table },
1218 { "EBCDIC-US", "ASCII", ebcdic_us_to_ascii_table },
1219 { "EBCDIC-US", "ISO-8859-1", ebcdic_us_to_iso_8859_1_table },
1220 { "EBCDIC-US", "IBM1047", ebcdic_us_to_ibm1047_table },
1221 { "IBM1047", "ASCII", ibm1047_to_ascii_table },
1222 { "IBM1047", "ISO-8859-1", ibm1047_to_iso_8859_1_table },
1223 { "IBM1047", "EBCDIC-US", ibm1047_to_ebcdic_us_table }
1228 for (i = 0; i < (sizeof (tlist) / sizeof (tlist[0])); i++)
1229 register_translation (simple_table_translation (tlist[i].from,
1234 set_host_charset (host_charset_name);
1235 set_target_charset (target_charset_name);
1237 add_setshow_enum_cmd ("charset", class_support,
1238 host_charset_enum, &host_charset_name, _("\
1239 Set the host and target character sets."), _("\
1240 Show the host and target character sets."), _("\
1241 The `host character set' is the one used by the system GDB is running on.\n\
1242 The `target character set' is the one used by the program being debugged.\n\
1243 You may only use supersets of ASCII for your host character set; GDB does\n\
1244 not support any others.\n\
1245 To see a list of the character sets GDB supports, type `set charset <TAB>'."),
1246 /* Note that the sfunc below needs to set
1247 target_charset_name, because the 'set
1248 charset' command sets two variables. */
1251 &setlist, &showlist);
1253 add_setshow_enum_cmd ("host-charset", class_support,
1254 host_charset_enum, &host_charset_name, _("\
1255 Set the host character set."), _("\
1256 Show the host character set."), _("\
1257 The `host character set' is the one used by the system GDB is running on.\n\
1258 You may only use supersets of ASCII for your host character set; GDB does\n\
1259 not support any others.\n\
1260 To see a list of the character sets GDB supports, type `set host-charset <TAB>'."),
1261 set_host_charset_sfunc,
1262 show_host_charset_name,
1263 &setlist, &showlist);
1265 add_setshow_enum_cmd ("target-charset", class_support,
1266 target_charset_enum, &target_charset_name, _("\
1267 Set the target character set."), _("\
1268 Show the target character set."), _("\
1269 The `target character set' is the one used by the program being debugged.\n\
1270 GDB translates characters and strings between the host and target\n\
1271 character sets as needed.\n\
1272 To see a list of the character sets GDB supports, type `set target-charset'<TAB>"),
1273 set_target_charset_sfunc,
1274 show_target_charset_name,
1275 &setlist, &showlist);