1 /* Character set conversion support for GDB.
3 Copyright (C) 2001, 2003, 2007, 2008 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_assert.h"
26 #include "gdb_string.h"
34 /* How GDB's character set support works
36 GDB has two global settings:
38 - The `current host character set' is the character set GDB should
39 use in talking to the user, and which (hopefully) the user's
40 terminal knows how to display properly.
42 - The `current target character set' is the character set the
43 program being debugged uses.
45 There are commands to set each of these, and mechanisms for
46 choosing reasonable default values. GDB has a global list of
47 character sets that it can use as its host or target character
50 The header file `charset.h' declares various functions that
51 different pieces of GDB need to perform tasks like:
53 - printing target strings and characters to the user's terminal
54 (mostly target->host conversions),
56 - building target-appropriate representations of strings and
57 characters the user enters in expressions (mostly host->target
62 Now, many of these operations are specific to a particular
63 host/target character set pair. If GDB supports N character sets,
64 there are N^2 possible pairs. This means that, the larger GDB's
65 repertoire of character sets gets, the more expensive it gets to add
68 To make sure that GDB can do the right thing for every possible
69 pairing of host and target character set, while still allowing
70 GDB's repertoire to scale, we use a two-tiered approach:
72 - We maintain a global table of "translations" --- groups of
73 functions specific to a particular pair of character sets.
75 - However, a translation can be incomplete: some functions can be
76 omitted. Where there is not a translation to specify exactly
77 what function to use, we provide reasonable defaults. The
78 default behaviors try to use the "iconv" library functions, which
79 support a wide range of character sets. However, even if iconv
80 is not available, there are fallbacks to support trivial
81 translations: when the host and target character sets are the
85 /* The character set and translation structures. */
88 /* A character set GDB knows about. GDB only supports character sets
89 with stateless encodings, in which every character is one byte
93 /* A singly-linked list of all known charsets. */
96 /* The name of the character set. Comparisons on character set
97 names are case-sensitive. */
100 /* Non-zero iff this character set can be used as a host character
101 set. At present, GDB basically assumes that the host character
102 set is a superset of ASCII. */
103 int valid_host_charset;
105 /* Pointers to charset-specific functions that depend only on a
106 single character set, and data pointers to pass to them. */
107 int (*host_char_print_literally) (void *baton,
109 void *host_char_print_literally_baton;
111 int (*target_char_to_control_char) (void *baton,
113 int *target_ctrl_char);
114 void *target_char_to_control_char_baton;
118 /* A translation from one character set to another. */
121 /* A singly-linked list of all known translations. */
122 struct translation *next;
124 /* This structure describes functions going from the FROM character
125 set to the TO character set. Comparisons on character set names
126 are case-sensitive. */
127 const char *from, *to;
129 /* Pointers to translation-specific functions, and data pointers to
130 pass to them. These pointers can be zero, indicating that GDB
131 should fall back on the default behavior. We hope the default
132 behavior will be correct for many from/to pairs, reducing the
133 number of translations that need to be registered explicitly. */
135 /* TARGET_CHAR is in the `from' charset.
136 Returns a string in the `to' charset. */
137 const char *(*c_target_char_has_backslash_escape) (void *baton,
139 void *c_target_char_has_backslash_escape_baton;
141 /* HOST_CHAR is in the `from' charset.
142 TARGET_CHAR points to a char in the `to' charset. */
143 int (*c_parse_backslash) (void *baton, int host_char, int *target_char);
144 void *c_parse_backslash_baton;
146 /* This is used for the host_char_to_target and target_char_to_host
148 int (*convert_char) (void *baton, int from, int *to);
149 void *convert_char_baton;
154 /* The global lists of character sets and translations. */
157 #ifndef GDB_DEFAULT_HOST_CHARSET
158 #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
161 #ifndef GDB_DEFAULT_TARGET_CHARSET
162 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
165 static const char *host_charset_name = GDB_DEFAULT_HOST_CHARSET;
167 show_host_charset_name (struct ui_file *file, int from_tty,
168 struct cmd_list_element *c,
171 fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
174 static const char *target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
176 show_target_charset_name (struct ui_file *file, int from_tty,
177 struct cmd_list_element *c, const char *value)
179 fprintf_filtered (file, _("The target character set is \"%s\".\n"),
184 static const char *host_charset_enum[] =
191 static const char *target_charset_enum[] =
200 /* The global list of all the charsets GDB knows about. */
201 static struct charset *all_charsets;
205 register_charset (struct charset *cs)
207 struct charset **ptr;
209 /* Put the new charset on the end, so that the list ends up in the
210 same order as the registrations in the _initialize function. */
211 for (ptr = &all_charsets; *ptr; ptr = &(*ptr)->next)
219 static struct charset *
220 lookup_charset (const char *name)
224 for (cs = all_charsets; cs; cs = cs->next)
225 if (! strcmp (name, cs->name))
232 /* The global list of translations. */
233 static struct translation *all_translations;
237 register_translation (struct translation *t)
239 t->next = all_translations;
240 all_translations = t;
244 static struct translation *
245 lookup_translation (const char *from, const char *to)
247 struct translation *t;
249 for (t = all_translations; t; t = t->next)
250 if (! strcmp (from, t->from)
251 && ! strcmp (to, t->to))
259 /* Constructing charsets. */
261 /* Allocate, initialize and return a straightforward charset.
262 Use this function, rather than creating the structures yourself,
263 so that we can add new fields to the structure in the future without
264 having to tweak all the old charset descriptions. */
265 static struct charset *
266 simple_charset (const char *name,
267 int valid_host_charset,
268 int (*host_char_print_literally) (void *baton, int host_char),
269 void *host_char_print_literally_baton,
270 int (*target_char_to_control_char) (void *baton,
272 int *target_ctrl_char),
273 void *target_char_to_control_char_baton)
275 struct charset *cs = xmalloc (sizeof (*cs));
277 memset (cs, 0, sizeof (*cs));
279 cs->valid_host_charset = valid_host_charset;
280 cs->host_char_print_literally = host_char_print_literally;
281 cs->host_char_print_literally_baton = host_char_print_literally_baton;
282 cs->target_char_to_control_char = target_char_to_control_char;
283 cs->target_char_to_control_char_baton = target_char_to_control_char_baton;
290 /* ASCII functions. */
293 ascii_print_literally (void *baton, int c)
297 return (0x20 <= c && c <= 0x7e);
302 ascii_to_control (void *baton, int c, int *ctrl_char)
304 *ctrl_char = (c & 037);
309 /* ISO-8859 family functions. */
313 iso_8859_print_literally (void *baton, int c)
317 return ((0x20 <= c && c <= 0x7e) /* ascii printables */
318 || (! sevenbit_strings && 0xA0 <= c)); /* iso 8859 printables */
323 iso_8859_to_control (void *baton, int c, int *ctrl_char)
325 *ctrl_char = (c & 0200) | (c & 037);
330 /* Construct an ISO-8859-like character set. */
331 static struct charset *
332 iso_8859_family_charset (const char *name)
334 return simple_charset (name, 1,
335 iso_8859_print_literally, 0,
336 iso_8859_to_control, 0);
341 /* EBCDIC family functions. */
345 ebcdic_print_literally (void *baton, int c)
349 return (64 <= c && c <= 254);
354 ebcdic_to_control (void *baton, int c, int *ctrl_char)
356 /* There are no control character equivalents in EBCDIC. Use
362 /* Construct an EBCDIC-like character set. */
363 static struct charset *
364 ebcdic_family_charset (const char *name)
366 return simple_charset (name, 0,
367 ebcdic_print_literally, 0,
368 ebcdic_to_control, 0);
375 /* Fallback functions using iconv. */
377 #if defined(HAVE_ICONV)
379 struct cached_iconv {
380 struct charset *from, *to;
385 /* Make sure the iconv cache *CI contains an iconv descriptor
386 translating from FROM to TO. If it already does, fine; otherwise,
387 close any existing descriptor, and open up a new one. On success,
388 return zero; on failure, return -1 and set errno. */
390 check_iconv_cache (struct cached_iconv *ci,
391 struct charset *from,
396 /* Does the cached iconv descriptor match the conversion we're trying
400 && ci->i != (iconv_t) 0)
403 /* It doesn't. If we actually had any iconv descriptor open at
404 all, close it now. */
405 if (ci->i != (iconv_t) 0)
410 if (iconv_close (i) == -1)
411 error (_("Error closing `iconv' descriptor for "
412 "`%s'-to-`%s' character conversion: %s"),
413 ci->from->name, ci->to->name, safe_strerror (errno));
416 /* Open a new iconv descriptor for the required conversion. */
417 i = iconv_open (to->name, from->name);
418 if (i == (iconv_t) -1)
429 /* Convert FROM_CHAR using the cached iconv conversion *CI. Return
430 non-zero if the conversion was successful, zero otherwise. */
432 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
435 ICONV_CONST char *from_ptr = &from;
436 char to, *to_ptr = &to;
437 size_t from_left = sizeof (from), to_left = sizeof (to);
439 gdb_assert (ci->i != (iconv_t) 0);
442 if (iconv (ci->i, &from_ptr, &from_left, &to_ptr, &to_left)
445 /* These all suggest that the input or output character sets
446 have multi-byte encodings of some characters, which means
447 it's unsuitable for use as a GDB character set. We should
448 never have selected it. */
449 gdb_assert (errno != E2BIG && errno != EINVAL);
451 /* This suggests a bug in the code managing *CI. */
452 gdb_assert (errno != EBADF);
454 /* This seems to mean that there is no equivalent character in
455 the `to' character set. */
459 /* Anything else is mysterious. */
460 internal_error (__FILE__, __LINE__,
461 _("Error converting character `%d' from `%s' to `%s' "
462 "character set: %s"),
463 from_char, ci->from->name, ci->to->name,
464 safe_strerror (errno));
467 /* If the pointers weren't advanced across the input, that also
468 suggests something was wrong. */
469 gdb_assert (from_left == 0 && to_left == 0);
471 *to_char = (unsigned char) to;
477 register_iconv_charsets (void)
479 /* Here we should check whether various character sets were
480 recognized by the local iconv implementation.
482 The first implementation registered a bunch of character sets
483 recognized by iconv, but then we discovered that iconv on Solaris
484 and iconv on GNU/Linux had no character sets in common. So we
485 replaced them with the hard-coded tables that appear later in the
489 #endif /* defined (HAVE_ICONV) */
492 /* Fallback routines for systems without iconv. */
494 #if ! defined (HAVE_ICONV)
495 struct cached_iconv { char nothing; };
498 check_iconv_cache (struct cached_iconv *ci,
499 struct charset *from,
507 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
509 /* This function should never be called. */
514 register_iconv_charsets (void)
518 #endif /* ! defined(HAVE_ICONV) */
521 /* Default trivial conversion functions. */
524 identity_either_char_to_other (void *baton, int either_char, int *other_char)
526 *other_char = either_char;
532 /* Default non-trivial conversion functions. */
535 static char backslashable[] = "abfnrtv";
536 static char *backslashed[] = {"a", "b", "f", "n", "r", "t", "v", "0"};
537 static char represented[] = "\a\b\f\n\r\t\v";
540 /* Translate TARGET_CHAR into the host character set, and see if it
541 matches any of our standard escape sequences. */
543 default_c_target_char_has_backslash_escape (void *baton, int target_char)
548 /* If target_char has no equivalent in the host character set,
549 assume it doesn't have a backslashed form. */
550 if (! target_char_to_host (target_char, &host_char))
553 ix = strchr (represented, host_char);
555 return backslashed[ix - represented];
561 /* Translate the backslash the way we would in the host character set,
562 and then try to translate that into the target character set. */
564 default_c_parse_backslash (void *baton, int host_char, int *target_char)
568 ix = strchr (backslashable, host_char);
573 return host_char_to_target (represented[ix - backslashable],
578 /* Convert using a cached iconv descriptor. */
580 iconv_convert (void *baton, int from_char, int *to_char)
582 struct cached_iconv *ci = baton;
583 return cached_iconv_convert (ci, from_char, to_char);
588 /* Conversion tables. */
591 /* I'd much rather fall back on iconv whenever possible. But the
592 character set names you use with iconv aren't standardized at all,
593 a lot of platforms have really meager character set coverage, etc.
594 I wanted to have at least something we could use to exercise the
595 test suite on all platforms.
597 In the long run, we should have a configure-time process explore
598 somehow which character sets the host platform supports, and some
599 arrangement that allows GDB users to use platform-indepedent names
600 for character sets. */
603 /* We generated these tables using iconv on a GNU/Linux machine. */
606 static int ascii_to_iso_8859_1_table[] = {
607 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
608 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
609 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
610 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
611 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
612 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
613 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
614 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
615 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
616 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
617 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
618 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
620 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
626 static int ascii_to_ebcdic_us_table[] = {
627 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
628 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
629 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
630 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
631 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
632 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
633 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
634 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
635 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
636 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
637 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
638 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
640 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
642 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
646 static int ascii_to_ibm1047_table[] = {
647 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
648 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
649 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
650 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
651 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
652 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
653 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
654 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
655 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
656 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
657 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
658 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
659 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
660 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
661 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
666 static int iso_8859_1_to_ascii_table[] = {
667 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
668 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
669 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
670 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
671 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
672 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
673 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
674 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
675 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
676 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
677 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
678 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
679 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
680 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
681 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
682 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
686 static int iso_8859_1_to_ebcdic_us_table[] = {
687 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
688 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
689 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
690 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
691 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
692 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
693 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
694 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
695 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
696 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
697 -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
698 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
699 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
700 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
701 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
702 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
706 static int iso_8859_1_to_ibm1047_table[] = {
707 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
708 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
709 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
710 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
711 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
712 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
713 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
714 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
715 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
716 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
717 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
718 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
719 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
720 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
721 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
722 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
726 static int ebcdic_us_to_ascii_table[] = {
727 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
728 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
729 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
730 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
731 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
732 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
733 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
734 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
735 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
736 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
737 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
738 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
739 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
740 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
741 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
742 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
746 static int ebcdic_us_to_iso_8859_1_table[] = {
747 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
748 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
749 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
750 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
751 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
752 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
753 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
754 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
755 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
756 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
757 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
758 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
759 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
760 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
761 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
762 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
766 static int ebcdic_us_to_ibm1047_table[] = {
767 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
768 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
769 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
770 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
771 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
772 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
773 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
774 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
775 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
776 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
777 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
778 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
779 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
780 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
781 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
782 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
786 static int ibm1047_to_ascii_table[] = {
787 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
788 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
789 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
790 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
791 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
792 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
793 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
794 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
795 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
796 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
797 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
798 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
799 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
800 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
801 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
802 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
806 static int ibm1047_to_iso_8859_1_table[] = {
807 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
808 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
809 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
810 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
811 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
812 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
813 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
814 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
815 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
816 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
817 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
818 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
819 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
820 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
821 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
822 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
826 static int ibm1047_to_ebcdic_us_table[] = {
827 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
828 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
829 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
830 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
831 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
832 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
833 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
834 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
835 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
836 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
837 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
838 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
839 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
840 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
841 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
842 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
847 table_convert_char (void *baton, int from, int *to)
849 int *table = (int *) baton;
851 if (0 <= from && from <= 255
852 && table[from] != -1)
862 static struct translation *
863 table_translation (const char *from, const char *to, int *table,
864 const char *(*c_target_char_has_backslash_escape)
865 (void *baton, int target_char),
866 void *c_target_char_has_backslash_escape_baton,
867 int (*c_parse_backslash) (void *baton,
870 void *c_parse_backslash_baton)
872 struct translation *t = xmalloc (sizeof (*t));
874 memset (t, 0, sizeof (*t));
877 t->c_target_char_has_backslash_escape = c_target_char_has_backslash_escape;
878 t->c_target_char_has_backslash_escape_baton
879 = c_target_char_has_backslash_escape_baton;
880 t->c_parse_backslash = c_parse_backslash;
881 t->c_parse_backslash_baton = c_parse_backslash_baton;
882 t->convert_char = table_convert_char;
883 t->convert_char_baton = (void *) table;
889 static struct translation *
890 simple_table_translation (const char *from, const char *to, int *table)
892 return table_translation (from, to, table, 0, 0, 0, 0);
897 /* Setting and retrieving the host and target charsets. */
900 /* The current host and target character sets. */
901 static struct charset *current_host_charset, *current_target_charset;
903 /* The current functions and batons we should use for the functions in
906 static const char *(*c_target_char_has_backslash_escape_func)
907 (void *baton, int target_char);
908 static void *c_target_char_has_backslash_escape_baton;
910 static int (*c_parse_backslash_func) (void *baton,
913 static void *c_parse_backslash_baton;
915 static int (*host_char_to_target_func) (void *baton,
918 static void *host_char_to_target_baton;
920 static int (*target_char_to_host_func) (void *baton,
923 static void *target_char_to_host_baton;
926 /* Cached iconv conversions, that might be useful to fallback
928 static struct cached_iconv cached_iconv_host_to_target;
929 static struct cached_iconv cached_iconv_target_to_host;
932 /* Charset structures manipulation functions. */
934 static struct charset *
935 lookup_charset_or_error (const char *name)
937 struct charset *cs = lookup_charset (name);
940 error (_("GDB doesn't know of any character set named `%s'."), name);
946 check_valid_host_charset (struct charset *cs)
948 if (! cs->valid_host_charset)
949 error (_("GDB can't use `%s' as its host character set."), cs->name);
952 /* Set the host and target character sets to HOST and TARGET. */
954 set_host_and_target_charsets (struct charset *host, struct charset *target)
956 struct translation *h2t, *t2h;
958 /* If they're not both initialized yet, then just do nothing for
959 now. As soon as we're done running our initialize function,
960 everything will be initialized. */
961 if (! host || ! target)
963 current_host_charset = host;
964 current_target_charset = target;
968 h2t = lookup_translation (host->name, target->name);
969 t2h = lookup_translation (target->name, host->name);
971 /* If the translations don't provide conversion functions, make sure
972 iconv can back them up. Do this *before* modifying any state. */
975 if (! h2t || ! h2t->convert_char)
977 if (check_iconv_cache (&cached_iconv_host_to_target, host, target)
979 error (_("GDB can't convert from the `%s' character set to `%s'."),
980 host->name, target->name);
982 if (! t2h || ! t2h->convert_char)
984 if (check_iconv_cache (&cached_iconv_target_to_host, target, host)
986 error (_("GDB can't convert from the `%s' character set to `%s'."),
987 target->name, host->name);
991 if (t2h && t2h->c_target_char_has_backslash_escape)
993 c_target_char_has_backslash_escape_func
994 = t2h->c_target_char_has_backslash_escape;
995 c_target_char_has_backslash_escape_baton
996 = t2h->c_target_char_has_backslash_escape_baton;
999 c_target_char_has_backslash_escape_func
1000 = default_c_target_char_has_backslash_escape;
1002 if (h2t && h2t->c_parse_backslash)
1004 c_parse_backslash_func = h2t->c_parse_backslash;
1005 c_parse_backslash_baton = h2t->c_parse_backslash_baton;
1008 c_parse_backslash_func = default_c_parse_backslash;
1010 if (h2t && h2t->convert_char)
1012 host_char_to_target_func = h2t->convert_char;
1013 host_char_to_target_baton = h2t->convert_char_baton;
1015 else if (host == target)
1016 host_char_to_target_func = identity_either_char_to_other;
1019 host_char_to_target_func = iconv_convert;
1020 host_char_to_target_baton = &cached_iconv_host_to_target;
1023 if (t2h && t2h->convert_char)
1025 target_char_to_host_func = t2h->convert_char;
1026 target_char_to_host_baton = t2h->convert_char_baton;
1028 else if (host == target)
1029 target_char_to_host_func = identity_either_char_to_other;
1032 target_char_to_host_func = iconv_convert;
1033 target_char_to_host_baton = &cached_iconv_target_to_host;
1036 current_host_charset = host;
1037 current_target_charset = target;
1040 /* Do the real work of setting the host charset. */
1042 set_host_charset (const char *charset)
1044 struct charset *cs = lookup_charset_or_error (charset);
1045 check_valid_host_charset (cs);
1046 set_host_and_target_charsets (cs, current_target_charset);
1049 /* Do the real work of setting the target charset. */
1051 set_target_charset (const char *charset)
1053 struct charset *cs = lookup_charset_or_error (charset);
1055 set_host_and_target_charsets (current_host_charset, cs);
1059 /* 'Set charset', 'set host-charset', 'set target-charset', 'show
1060 charset' sfunc's. */
1062 /* This is the sfunc for the 'set charset' command. */
1064 set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
1066 struct charset *cs = lookup_charset_or_error (host_charset_name);
1067 check_valid_host_charset (cs);
1068 /* CAREFUL: set the target charset here as well. */
1069 target_charset_name = host_charset_name;
1070 set_host_and_target_charsets (cs, cs);
1073 /* 'set host-charset' command sfunc. We need a wrapper here because
1074 the function needs to have a specific signature. */
1076 set_host_charset_sfunc (char *charset, int from_tty,
1077 struct cmd_list_element *c)
1079 set_host_charset (host_charset_name);
1082 /* Wrapper for the 'set target-charset' command. */
1084 set_target_charset_sfunc (char *charset, int from_tty,
1085 struct cmd_list_element *c)
1087 set_target_charset (target_charset_name);
1090 /* sfunc for the 'show charset' command. */
1092 show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
1095 if (current_host_charset == current_target_charset)
1096 fprintf_filtered (file,
1097 _("The current host and target character set is `%s'.\n"),
1101 fprintf_filtered (file, _("The current host character set is `%s'.\n"),
1103 fprintf_filtered (file, _("The current target character set is `%s'.\n"),
1109 /* Accessor functions. */
1114 return current_host_charset->name;
1118 target_charset (void)
1120 return current_target_charset->name;
1125 /* Public character management functions. */
1129 c_target_char_has_backslash_escape (int target_char)
1131 return ((*c_target_char_has_backslash_escape_func)
1132 (c_target_char_has_backslash_escape_baton, target_char));
1137 c_parse_backslash (int host_char, int *target_char)
1139 return (*c_parse_backslash_func) (c_parse_backslash_baton,
1140 host_char, target_char);
1145 host_char_print_literally (int host_char)
1147 return ((*current_host_charset->host_char_print_literally)
1148 (current_host_charset->host_char_print_literally_baton,
1154 target_char_to_control_char (int target_char, int *target_ctrl_char)
1156 return ((*current_target_charset->target_char_to_control_char)
1157 (current_target_charset->target_char_to_control_char_baton,
1158 target_char, target_ctrl_char));
1163 host_char_to_target (int host_char, int *target_char)
1165 return ((*host_char_to_target_func)
1166 (host_char_to_target_baton, host_char, target_char));
1171 target_char_to_host (int target_char, int *host_char)
1173 return ((*target_char_to_host_func)
1174 (target_char_to_host_baton, target_char, host_char));
1179 /* The charset.c module initialization function. */
1181 extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
1184 _initialize_charset (void)
1186 struct cmd_list_element *new_cmd;
1188 /* Register all the character set GDB knows about.
1190 You should use the same names that iconv does, where possible, to
1191 take advantage of the iconv-based default behaviors.
1193 CAUTION: if you register a character set, you must also register
1194 as many translations as are necessary to make that character set
1195 interoperate correctly with all the other character sets. We do
1196 provide default behaviors when no translation is available, or
1197 when a translation's function pointer for a particular operation
1198 is zero. Hopefully, these defaults will be correct often enough
1199 that we won't need to provide too many translations. */
1200 register_charset (simple_charset ("ASCII", 1,
1201 ascii_print_literally, 0,
1202 ascii_to_control, 0));
1203 register_charset (iso_8859_family_charset ("ISO-8859-1"));
1204 register_charset (ebcdic_family_charset ("EBCDIC-US"));
1205 register_charset (ebcdic_family_charset ("IBM1047"));
1206 register_iconv_charsets ();
1209 struct { char *from; char *to; int *table; } tlist[] = {
1210 { "ASCII", "ISO-8859-1", ascii_to_iso_8859_1_table },
1211 { "ASCII", "EBCDIC-US", ascii_to_ebcdic_us_table },
1212 { "ASCII", "IBM1047", ascii_to_ibm1047_table },
1213 { "ISO-8859-1", "ASCII", iso_8859_1_to_ascii_table },
1214 { "ISO-8859-1", "EBCDIC-US", iso_8859_1_to_ebcdic_us_table },
1215 { "ISO-8859-1", "IBM1047", iso_8859_1_to_ibm1047_table },
1216 { "EBCDIC-US", "ASCII", ebcdic_us_to_ascii_table },
1217 { "EBCDIC-US", "ISO-8859-1", ebcdic_us_to_iso_8859_1_table },
1218 { "EBCDIC-US", "IBM1047", ebcdic_us_to_ibm1047_table },
1219 { "IBM1047", "ASCII", ibm1047_to_ascii_table },
1220 { "IBM1047", "ISO-8859-1", ibm1047_to_iso_8859_1_table },
1221 { "IBM1047", "EBCDIC-US", ibm1047_to_ebcdic_us_table }
1226 for (i = 0; i < (sizeof (tlist) / sizeof (tlist[0])); i++)
1227 register_translation (simple_table_translation (tlist[i].from,
1232 set_host_charset (host_charset_name);
1233 set_target_charset (target_charset_name);
1235 add_setshow_enum_cmd ("charset", class_support,
1236 host_charset_enum, &host_charset_name, _("\
1237 Set the host and target character sets."), _("\
1238 Show the host and target character sets."), _("\
1239 The `host character set' is the one used by the system GDB is running on.\n\
1240 The `target character set' is the one used by the program being debugged.\n\
1241 You may only use supersets of ASCII for your host character set; GDB does\n\
1242 not support any others.\n\
1243 To see a list of the character sets GDB supports, type `set charset <TAB>'."),
1244 /* Note that the sfunc below needs to set
1245 target_charset_name, because the 'set
1246 charset' command sets two variables. */
1249 &setlist, &showlist);
1251 add_setshow_enum_cmd ("host-charset", class_support,
1252 host_charset_enum, &host_charset_name, _("\
1253 Set the host character set."), _("\
1254 Show the host character set."), _("\
1255 The `host character set' is the one used by the system GDB is running on.\n\
1256 You may only use supersets of ASCII for your host character set; GDB does\n\
1257 not support any others.\n\
1258 To see a list of the character sets GDB supports, type `set host-charset <TAB>'."),
1259 set_host_charset_sfunc,
1260 show_host_charset_name,
1261 &setlist, &showlist);
1263 add_setshow_enum_cmd ("target-charset", class_support,
1264 target_charset_enum, &target_charset_name, _("\
1265 Set the target character set."), _("\
1266 Show the target character set."), _("\
1267 The `target character set' is the one used by the program being debugged.\n\
1268 GDB translates characters and strings between the host and target\n\
1269 character sets as needed.\n\
1270 To see a list of the character sets GDB supports, type `set target-charset'<TAB>"),
1271 set_target_charset_sfunc,
1272 show_target_charset_name,
1273 &setlist, &showlist);