1 /* Character set conversion support for GDB.
3 Copyright 2001, 2003 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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, 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-insensitive. */
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-insensitive. */
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 /* Character set names are always compared ignoring case. */
161 strcmp_case_insensitive (const char *p
, const char *q
)
163 while (*p
&& *q
&& tolower (*p
) == tolower (*q
))
166 return tolower (*p
) - tolower (*q
);
170 /* The global list of all the charsets GDB knows about. */
171 static struct charset
*all_charsets
;
175 register_charset (struct charset
*cs
)
177 struct charset
**ptr
;
179 /* Put the new charset on the end, so that the list ends up in the
180 same order as the registrations in the _initialize function. */
181 for (ptr
= &all_charsets
; *ptr
; ptr
= &(*ptr
)->next
)
189 static struct charset
*
190 lookup_charset (const char *name
)
194 for (cs
= all_charsets
; cs
; cs
= cs
->next
)
195 if (! strcmp_case_insensitive (name
, cs
->name
))
202 /* The global list of translations. */
203 static struct translation
*all_translations
;
207 register_translation (struct translation
*t
)
209 t
->next
= all_translations
;
210 all_translations
= t
;
214 static struct translation
*
215 lookup_translation (const char *from
, const char *to
)
217 struct translation
*t
;
219 for (t
= all_translations
; t
; t
= t
->next
)
220 if (! strcmp_case_insensitive (from
, t
->from
)
221 && ! strcmp_case_insensitive (to
, t
->to
))
229 /* Constructing charsets. */
231 /* Allocate, initialize and return a straightforward charset.
232 Use this function, rather than creating the structures yourself,
233 so that we can add new fields to the structure in the future without
234 having to tweak all the old charset descriptions. */
235 static struct charset
*
236 simple_charset (const char *name
,
237 int valid_host_charset
,
238 int (*host_char_print_literally
) (void *baton
, int host_char
),
239 void *host_char_print_literally_baton
,
240 int (*target_char_to_control_char
) (void *baton
,
242 int *target_ctrl_char
),
243 void *target_char_to_control_char_baton
)
245 struct charset
*cs
= xmalloc (sizeof (*cs
));
247 memset (cs
, 0, sizeof (*cs
));
249 cs
->valid_host_charset
= valid_host_charset
;
250 cs
->host_char_print_literally
= host_char_print_literally
;
251 cs
->host_char_print_literally_baton
= host_char_print_literally_baton
;
252 cs
->target_char_to_control_char
= target_char_to_control_char
;
253 cs
->target_char_to_control_char_baton
= target_char_to_control_char_baton
;
260 /* ASCII functions. */
263 ascii_print_literally (void *baton
, int c
)
267 return (0x20 <= c
&& c
<= 0x7e);
272 ascii_to_control (void *baton
, int c
, int *ctrl_char
)
274 *ctrl_char
= (c
& 037);
279 /* ISO-8859 family functions. */
283 iso_8859_print_literally (void *baton
, int c
)
287 return ((0x20 <= c
&& c
<= 0x7e) /* ascii printables */
288 || (! sevenbit_strings
&& 0xA0 <= c
)); /* iso 8859 printables */
293 iso_8859_to_control (void *baton
, int c
, int *ctrl_char
)
295 *ctrl_char
= (c
& 0200) | (c
& 037);
300 /* Construct an ISO-8859-like character set. */
301 static struct charset
*
302 iso_8859_family_charset (const char *name
)
304 return simple_charset (name
, 1,
305 iso_8859_print_literally
, 0,
306 iso_8859_to_control
, 0);
311 /* EBCDIC family functions. */
315 ebcdic_print_literally (void *baton
, int c
)
319 return (64 <= c
&& c
<= 254);
324 ebcdic_to_control (void *baton
, int c
, int *ctrl_char
)
326 /* There are no control character equivalents in EBCDIC. Use
332 /* Construct an EBCDIC-like character set. */
333 static struct charset
*
334 ebcdic_family_charset (const char *name
)
336 return simple_charset (name
, 0,
337 ebcdic_print_literally
, 0,
338 ebcdic_to_control
, 0);
345 /* Fallback functions using iconv. */
347 #if defined(HAVE_ICONV)
349 struct cached_iconv
{
350 struct charset
*from
, *to
;
355 /* Make sure the iconv cache *CI contains an iconv descriptor
356 translating from FROM to TO. If it already does, fine; otherwise,
357 close any existing descriptor, and open up a new one. On success,
358 return zero; on failure, return -1 and set errno. */
360 check_iconv_cache (struct cached_iconv
*ci
,
361 struct charset
*from
,
366 /* Does the cached iconv descriptor match the conversion we're trying
370 && ci
->i
!= (iconv_t
) 0)
373 /* It doesn't. If we actually had any iconv descriptor open at
374 all, close it now. */
375 if (ci
->i
!= (iconv_t
) 0)
380 if (iconv_close (i
) == -1)
381 error ("Error closing `iconv' descriptor for "
382 "`%s'-to-`%s' character conversion: %s",
383 ci
->from
->name
, ci
->to
->name
, safe_strerror (errno
));
386 /* Open a new iconv descriptor for the required conversion. */
387 i
= iconv_open (to
->name
, from
->name
);
388 if (i
== (iconv_t
) -1)
399 /* Convert FROM_CHAR using the cached iconv conversion *CI. Return
400 non-zero if the conversion was successful, zero otherwise. */
402 cached_iconv_convert (struct cached_iconv
*ci
, int from_char
, int *to_char
)
405 ICONV_CONST
char *from_ptr
= &from
;
406 char to
, *to_ptr
= &to
;
407 size_t from_left
= sizeof (from
), to_left
= sizeof (to
);
409 gdb_assert (ci
->i
!= (iconv_t
) 0);
412 if (iconv (ci
->i
, &from_ptr
, &from_left
, &to_ptr
, &to_left
)
415 /* These all suggest that the input or output character sets
416 have multi-byte encodings of some characters, which means
417 it's unsuitable for use as a GDB character set. We should
418 never have selected it. */
419 gdb_assert (errno
!= E2BIG
&& errno
!= EINVAL
);
421 /* This suggests a bug in the code managing *CI. */
422 gdb_assert (errno
!= EBADF
);
424 /* This seems to mean that there is no equivalent character in
425 the `to' character set. */
429 /* Anything else is mysterious. */
430 internal_error ("Error converting character `%d' from `%s' to `%s' "
432 from_char
, ci
->from
->name
, ci
->to
->name
,
433 safe_strerror (errno
));
436 /* If the pointers weren't advanced across the input, that also
437 suggests something was wrong. */
438 gdb_assert (from_left
== 0 && to_left
== 0);
440 *to_char
= (unsigned char) to
;
446 register_iconv_charsets (void)
448 /* Here we should check whether various character sets were
449 recognized by the local iconv implementation.
451 The first implementation registered a bunch of character sets
452 recognized by iconv, but then we discovered that iconv on Solaris
453 and iconv on GNU/Linux had no character sets in common. So we
454 replaced them with the hard-coded tables that appear later in the
458 #endif /* defined (HAVE_ICONV) */
461 /* Fallback routines for systems without iconv. */
463 #if ! defined (HAVE_ICONV)
464 struct cached_iconv
{ char nothing
; };
467 check_iconv_cache (struct cached_iconv
*ci
,
468 struct charset
*from
,
476 cached_iconv_convert (struct cached_iconv
*ci
, int from_char
, int *to_char
)
478 /* This function should never be called. */
483 register_iconv_charsets (void)
487 #endif /* ! defined(HAVE_ICONV) */
490 /* Default trivial conversion functions. */
493 identity_either_char_to_other (void *baton
, int either_char
, int *other_char
)
495 *other_char
= either_char
;
501 /* Default non-trivial conversion functions. */
504 static char backslashable
[] = "abefnrtv";
505 static char *backslashed
[] = {"a", "b", "e", "f", "n", "r", "t", "v", "0"};
506 static char represented
[] = "\a\b\e\f\n\r\t\v";
509 /* Translate TARGET_CHAR into the host character set, and see if it
510 matches any of our standard escape sequences. */
512 default_c_target_char_has_backslash_escape (void *baton
, int target_char
)
517 /* If target_char has no equivalent in the host character set,
518 assume it doesn't have a backslashed form. */
519 if (! target_char_to_host (target_char
, &host_char
))
522 ix
= strchr (represented
, host_char
);
524 return backslashed
[ix
- represented
];
530 /* Translate the backslash the way we would in the host character set,
531 and then try to translate that into the target character set. */
533 default_c_parse_backslash (void *baton
, int host_char
, int *target_char
)
537 ix
= strchr (backslashable
, host_char
);
542 return host_char_to_target (represented
[ix
- backslashable
],
547 /* Convert using a cached iconv descriptor. */
549 iconv_convert (void *baton
, int from_char
, int *to_char
)
551 struct cached_iconv
*ci
= baton
;
552 return cached_iconv_convert (ci
, from_char
, to_char
);
557 /* Conversion tables. */
560 /* I'd much rather fall back on iconv whenever possible. But the
561 character set names you use with iconv aren't standardized at all,
562 a lot of platforms have really meager character set coverage, etc.
563 I wanted to have at least something we could use to exercise the
564 test suite on all platforms.
566 In the long run, we should have a configure-time process explore
567 somehow which character sets the host platform supports, and some
568 arrangement that allows GDB users to use platform-indepedent names
569 for character sets. */
572 /* We generated these tables using iconv on a GNU/Linux machine. */
575 static int ascii_to_iso_8859_1_table
[] = {
576 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
577 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
578 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
579 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
580 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
581 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
582 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
583 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
584 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
585 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
586 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
587 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
588 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
589 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
590 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
591 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
595 static int ascii_to_ebcdic_us_table
[] = {
596 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
597 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
598 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
599 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
600 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
601 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
602 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
603 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
605 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
606 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
609 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
610 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
611 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
615 static int ascii_to_ibm1047_table
[] = {
616 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
617 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
618 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
619 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
620 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
621 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
622 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
623 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
627 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
628 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
629 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
630 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
631 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
635 static int iso_8859_1_to_ascii_table
[] = {
636 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
637 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
638 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
639 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
640 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
641 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
642 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
643 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
645 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
647 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
650 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
651 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
655 static int iso_8859_1_to_ebcdic_us_table
[] = {
656 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
657 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
658 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
659 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
660 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
661 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
662 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
663 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
664 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
665 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
666 -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
667 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
668 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
669 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
670 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
671 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
675 static int iso_8859_1_to_ibm1047_table
[] = {
676 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
677 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
678 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
679 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
680 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
681 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
682 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
683 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
684 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
685 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
686 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
687 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
688 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
689 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
690 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
691 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
695 static int ebcdic_us_to_ascii_table
[] = {
696 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
697 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
698 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
699 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
700 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
701 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
702 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
703 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
704 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
705 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
706 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
707 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
708 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
709 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
710 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
711 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
715 static int ebcdic_us_to_iso_8859_1_table
[] = {
716 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
717 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
718 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
719 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
720 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
721 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
722 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
723 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
724 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
725 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
726 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
727 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
728 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
729 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
730 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
731 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
735 static int ebcdic_us_to_ibm1047_table
[] = {
736 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
737 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
738 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
739 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
740 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
741 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
742 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
743 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
744 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
745 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
746 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
747 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
748 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
749 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
750 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
751 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
755 static int ibm1047_to_ascii_table
[] = {
756 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
757 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
758 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
759 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
760 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
761 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
762 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
763 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
764 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
765 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
766 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
767 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
768 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
769 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
770 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
771 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
775 static int ibm1047_to_iso_8859_1_table
[] = {
776 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
777 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
778 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
779 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
780 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
781 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
782 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
783 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
784 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
785 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
786 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
787 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
788 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
789 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
790 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
791 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
795 static int ibm1047_to_ebcdic_us_table
[] = {
796 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
797 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
798 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
799 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
800 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
801 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
802 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
803 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
804 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
805 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
806 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
807 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
808 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
809 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
810 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
811 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
816 table_convert_char (void *baton
, int from
, int *to
)
818 int *table
= (int *) baton
;
820 if (0 <= from
&& from
<= 255
821 && table
[from
] != -1)
831 static struct translation
*
832 table_translation (const char *from
, const char *to
, int *table
,
833 const char *(*c_target_char_has_backslash_escape
)
834 (void *baton
, int target_char
),
835 void *c_target_char_has_backslash_escape_baton
,
836 int (*c_parse_backslash
) (void *baton
,
839 void *c_parse_backslash_baton
)
841 struct translation
*t
= xmalloc (sizeof (*t
));
843 memset (t
, 0, sizeof (*t
));
846 t
->c_target_char_has_backslash_escape
= c_target_char_has_backslash_escape
;
847 t
->c_target_char_has_backslash_escape_baton
848 = c_target_char_has_backslash_escape_baton
;
849 t
->c_parse_backslash
= c_parse_backslash
;
850 t
->c_parse_backslash_baton
= c_parse_backslash_baton
;
851 t
->convert_char
= table_convert_char
;
852 t
->convert_char_baton
= (void *) table
;
858 static struct translation
*
859 simple_table_translation (const char *from
, const char *to
, int *table
)
861 return table_translation (from
, to
, table
, 0, 0, 0, 0);
866 /* Setting and retrieving the host and target charsets. */
869 /* The current host and target character sets. */
870 static struct charset
*current_host_charset
, *current_target_charset
;
872 /* The current functions and batons we should use for the functions in
875 static const char *(*c_target_char_has_backslash_escape_func
)
876 (void *baton
, int target_char
);
877 static void *c_target_char_has_backslash_escape_baton
;
879 static int (*c_parse_backslash_func
) (void *baton
,
882 static void *c_parse_backslash_baton
;
884 static int (*host_char_to_target_func
) (void *baton
,
887 static void *host_char_to_target_baton
;
889 static int (*target_char_to_host_func
) (void *baton
,
892 static void *target_char_to_host_baton
;
895 /* Cached iconv conversions, that might be useful to fallback
897 static struct cached_iconv cached_iconv_host_to_target
;
898 static struct cached_iconv cached_iconv_target_to_host
;
901 /* Set the host and target character sets to HOST and TARGET. */
903 set_host_and_target_charsets (struct charset
*host
, struct charset
*target
)
905 struct translation
*h2t
, *t2h
;
907 /* If they're not both initialized yet, then just do nothing for
908 now. As soon as we're done running our initialize function,
909 everything will be initialized. */
910 if (! host
|| ! target
)
912 current_host_charset
= host
;
913 current_target_charset
= target
;
917 h2t
= lookup_translation (host
->name
, target
->name
);
918 t2h
= lookup_translation (target
->name
, host
->name
);
920 /* If the translations don't provide conversion functions, make sure
921 iconv can back them up. Do this *before* modifying any state. */
924 if (! h2t
|| ! h2t
->convert_char
)
926 if (check_iconv_cache (&cached_iconv_host_to_target
, host
, target
)
928 error ("GDB can't convert from the `%s' character set to `%s'.",
929 host
->name
, target
->name
);
931 if (! t2h
|| ! t2h
->convert_char
)
933 if (check_iconv_cache (&cached_iconv_target_to_host
, target
, host
)
935 error ("GDB can't convert from the `%s' character set to `%s'.",
936 target
->name
, host
->name
);
940 if (t2h
&& t2h
->c_target_char_has_backslash_escape
)
942 c_target_char_has_backslash_escape_func
943 = t2h
->c_target_char_has_backslash_escape
;
944 c_target_char_has_backslash_escape_baton
945 = t2h
->c_target_char_has_backslash_escape_baton
;
948 c_target_char_has_backslash_escape_func
949 = default_c_target_char_has_backslash_escape
;
951 if (h2t
&& h2t
->c_parse_backslash
)
953 c_parse_backslash_func
= h2t
->c_parse_backslash
;
954 c_parse_backslash_baton
= h2t
->c_parse_backslash_baton
;
957 c_parse_backslash_func
= default_c_parse_backslash
;
959 if (h2t
&& h2t
->convert_char
)
961 host_char_to_target_func
= h2t
->convert_char
;
962 host_char_to_target_baton
= h2t
->convert_char_baton
;
964 else if (host
== target
)
965 host_char_to_target_func
= identity_either_char_to_other
;
968 host_char_to_target_func
= iconv_convert
;
969 host_char_to_target_baton
= &cached_iconv_host_to_target
;
972 if (t2h
&& t2h
->convert_char
)
974 target_char_to_host_func
= t2h
->convert_char
;
975 target_char_to_host_baton
= t2h
->convert_char_baton
;
977 else if (host
== target
)
978 target_char_to_host_func
= identity_either_char_to_other
;
981 target_char_to_host_func
= iconv_convert
;
982 target_char_to_host_baton
= &cached_iconv_target_to_host
;
985 current_host_charset
= host
;
986 current_target_charset
= target
;
990 static struct charset
*
991 lookup_charset_or_error (const char *name
)
993 struct charset
*cs
= lookup_charset (name
);
996 error ("GDB doesn't know of any character set named `%s'.", name
);
1003 check_valid_host_charset (struct charset
*cs
)
1005 if (! cs
->valid_host_charset
)
1006 error ("GDB can't use `%s' as its host character set.", cs
->name
);
1011 set_host_charset (const char *charset
)
1013 struct charset
*cs
= lookup_charset_or_error (charset
);
1014 check_valid_host_charset (cs
);
1015 set_host_and_target_charsets (cs
, current_target_charset
);
1022 return current_host_charset
->name
;
1027 set_target_charset (const char *charset
)
1029 struct charset
*cs
= lookup_charset_or_error (charset
);
1031 set_host_and_target_charsets (current_host_charset
, cs
);
1036 target_charset (void)
1038 return current_target_charset
->name
;
1043 /* Public character management functions. */
1047 c_target_char_has_backslash_escape (int target_char
)
1049 return ((*c_target_char_has_backslash_escape_func
)
1050 (c_target_char_has_backslash_escape_baton
, target_char
));
1055 c_parse_backslash (int host_char
, int *target_char
)
1057 return (*c_parse_backslash_func
) (c_parse_backslash_baton
,
1058 host_char
, target_char
);
1063 host_char_print_literally (int host_char
)
1065 return ((*current_host_charset
->host_char_print_literally
)
1066 (current_host_charset
->host_char_print_literally_baton
,
1072 target_char_to_control_char (int target_char
, int *target_ctrl_char
)
1074 return ((*current_target_charset
->target_char_to_control_char
)
1075 (current_target_charset
->target_char_to_control_char_baton
,
1076 target_char
, target_ctrl_char
));
1081 host_char_to_target (int host_char
, int *target_char
)
1083 return ((*host_char_to_target_func
)
1084 (host_char_to_target_baton
, host_char
, target_char
));
1089 target_char_to_host (int target_char
, int *host_char
)
1091 return ((*target_char_to_host_func
)
1092 (target_char_to_host_baton
, target_char
, host_char
));
1100 /* List the valid character sets. If HOST_ONLY is non-zero, list only
1101 those character sets which can be used as GDB's host character set. */
1103 list_charsets (int host_only
)
1107 printf_filtered ("Valid character sets are:\n");
1109 for (cs
= all_charsets
; cs
; cs
= cs
->next
)
1110 if (host_only
&& cs
->valid_host_charset
)
1111 printf_filtered (" %s\n", cs
->name
);
1113 printf_filtered (" %s %s\n",
1115 cs
->valid_host_charset
? "*" : " ");
1118 printf_filtered ("* - can be used as a host character set\n");
1123 set_charset_command (char *arg
, int from_tty
)
1125 if (! arg
|| arg
[0] == '\0')
1129 struct charset
*cs
= lookup_charset_or_error (arg
);
1130 check_valid_host_charset (cs
);
1131 set_host_and_target_charsets (cs
, cs
);
1137 set_host_charset_command (char *arg
, int from_tty
)
1139 if (! arg
|| arg
[0] == '\0')
1143 struct charset
*cs
= lookup_charset_or_error (arg
);
1144 check_valid_host_charset (cs
);
1145 set_host_and_target_charsets (cs
, current_target_charset
);
1151 set_target_charset_command (char *arg
, int from_tty
)
1153 if (! arg
|| arg
[0] == '\0')
1157 struct charset
*cs
= lookup_charset_or_error (arg
);
1158 set_host_and_target_charsets (current_host_charset
, cs
);
1164 show_charset_command (char *arg
, int from_tty
)
1166 if (current_host_charset
== current_target_charset
)
1168 printf_filtered ("The current host and target character set is `%s'.\n",
1173 printf_filtered ("The current host character set is `%s'.\n",
1175 printf_filtered ("The current target character set is `%s'.\n",
1182 /* The charset.c module initialization function. */
1184 #ifndef GDB_DEFAULT_HOST_CHARSET
1185 #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
1188 #ifndef GDB_DEFAULT_TARGET_CHARSET
1189 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
1193 _initialize_charset (void)
1195 /* Register all the character set GDB knows about.
1197 You should use the same names that iconv does, where possible, to
1198 take advantage of the iconv-based default behaviors.
1200 CAUTION: if you register a character set, you must also register
1201 as many translations as are necessary to make that character set
1202 interoperate correctly with all the other character sets. We do
1203 provide default behaviors when no translation is available, or
1204 when a translation's function pointer for a particular operation
1205 is zero. Hopefully, these defaults will be correct often enough
1206 that we won't need to provide too many translations. */
1207 register_charset (simple_charset ("ascii", 1,
1208 ascii_print_literally
, 0,
1209 ascii_to_control
, 0));
1210 register_charset (iso_8859_family_charset ("iso-8859-1"));
1211 register_charset (ebcdic_family_charset ("ebcdic-us"));
1212 register_charset (ebcdic_family_charset ("ibm1047"));
1213 register_iconv_charsets ();
1216 struct { char *from
; char *to
; int *table
; } tlist
[] = {
1217 { "ascii", "iso-8859-1", ascii_to_iso_8859_1_table
},
1218 { "ascii", "ebcdic-us", ascii_to_ebcdic_us_table
},
1219 { "ascii", "ibm1047", ascii_to_ibm1047_table
},
1220 { "iso-8859-1", "ascii", iso_8859_1_to_ascii_table
},
1221 { "iso-8859-1", "ebcdic-us", iso_8859_1_to_ebcdic_us_table
},
1222 { "iso-8859-1", "ibm1047", iso_8859_1_to_ibm1047_table
},
1223 { "ebcdic-us", "ascii", ebcdic_us_to_ascii_table
},
1224 { "ebcdic-us", "iso-8859-1", ebcdic_us_to_iso_8859_1_table
},
1225 { "ebcdic-us", "ibm1047", ebcdic_us_to_ibm1047_table
},
1226 { "ibm1047", "ascii", ibm1047_to_ascii_table
},
1227 { "ibm1047", "iso-8859-1", ibm1047_to_iso_8859_1_table
},
1228 { "ibm1047", "ebcdic-us", ibm1047_to_ebcdic_us_table
}
1233 for (i
= 0; i
< (sizeof (tlist
) / sizeof (tlist
[0])); i
++)
1234 register_translation (simple_table_translation (tlist
[i
].from
,
1239 set_host_charset (GDB_DEFAULT_HOST_CHARSET
);
1240 set_target_charset (GDB_DEFAULT_TARGET_CHARSET
);
1242 add_cmd ("charset", class_support
, set_charset_command
,
1243 "Use CHARSET as the host and target character set.\n"
1244 "The `host character set' is the one used by the system GDB is running on.\n"
1245 "The `target character set' is the one used by the program being debugged.\n"
1246 "You may only use supersets of ASCII for your host character set; GDB does\n"
1247 "not support any others.\n"
1248 "To see a list of the character sets GDB supports, type `set charset'\n"
1249 "with no argument.",
1252 add_cmd ("host-charset", class_support
, set_host_charset_command
,
1253 "Use CHARSET as the host character set.\n"
1254 "The `host character set' is the one used by the system GDB is running on.\n"
1255 "You may only use supersets of ASCII for your host character set; GDB does\n"
1256 "not support any others.\n"
1257 "To see a list of the character sets GDB supports, type `set host-charset'\n"
1258 "with no argument.",
1261 add_cmd ("target-charset", class_support
, set_target_charset_command
,
1262 "Use CHARSET as the target character set.\n"
1263 "The `target character set' is the one used by the program being debugged.\n"
1264 "GDB translates characters and strings between the host and target\n"
1265 "character sets as needed.\n"
1266 "To see a list of the character sets GDB supports, type `set target-charset'\n"
1267 "with no argument.",
1270 add_cmd ("charset", class_support
, show_charset_command
,
1271 "Show the current host and target character sets.",
1273 add_alias_cmd ("host-charset", "charset", class_alias
, 1, &showlist
);
1274 add_alias_cmd ("target-charset", "charset", class_alias
, 1, &showlist
);