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-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
;
168 static const char *target_charset_name
= GDB_DEFAULT_TARGET_CHARSET
;
170 static const char *host_charset_enum
[] =
177 static const char *target_charset_enum
[] =
186 /* The global list of all the charsets GDB knows about. */
187 static struct charset
*all_charsets
;
191 register_charset (struct charset
*cs
)
193 struct charset
**ptr
;
195 /* Put the new charset on the end, so that the list ends up in the
196 same order as the registrations in the _initialize function. */
197 for (ptr
= &all_charsets
; *ptr
; ptr
= &(*ptr
)->next
)
205 static struct charset
*
206 lookup_charset (const char *name
)
210 for (cs
= all_charsets
; cs
; cs
= cs
->next
)
211 if (! strcmp (name
, cs
->name
))
218 /* The global list of translations. */
219 static struct translation
*all_translations
;
223 register_translation (struct translation
*t
)
225 t
->next
= all_translations
;
226 all_translations
= t
;
230 static struct translation
*
231 lookup_translation (const char *from
, const char *to
)
233 struct translation
*t
;
235 for (t
= all_translations
; t
; t
= t
->next
)
236 if (! strcmp (from
, t
->from
)
237 && ! strcmp (to
, t
->to
))
245 /* Constructing charsets. */
247 /* Allocate, initialize and return a straightforward charset.
248 Use this function, rather than creating the structures yourself,
249 so that we can add new fields to the structure in the future without
250 having to tweak all the old charset descriptions. */
251 static struct charset
*
252 simple_charset (const char *name
,
253 int valid_host_charset
,
254 int (*host_char_print_literally
) (void *baton
, int host_char
),
255 void *host_char_print_literally_baton
,
256 int (*target_char_to_control_char
) (void *baton
,
258 int *target_ctrl_char
),
259 void *target_char_to_control_char_baton
)
261 struct charset
*cs
= xmalloc (sizeof (*cs
));
263 memset (cs
, 0, sizeof (*cs
));
265 cs
->valid_host_charset
= valid_host_charset
;
266 cs
->host_char_print_literally
= host_char_print_literally
;
267 cs
->host_char_print_literally_baton
= host_char_print_literally_baton
;
268 cs
->target_char_to_control_char
= target_char_to_control_char
;
269 cs
->target_char_to_control_char_baton
= target_char_to_control_char_baton
;
276 /* ASCII functions. */
279 ascii_print_literally (void *baton
, int c
)
283 return (0x20 <= c
&& c
<= 0x7e);
288 ascii_to_control (void *baton
, int c
, int *ctrl_char
)
290 *ctrl_char
= (c
& 037);
295 /* ISO-8859 family functions. */
299 iso_8859_print_literally (void *baton
, int c
)
303 return ((0x20 <= c
&& c
<= 0x7e) /* ascii printables */
304 || (! sevenbit_strings
&& 0xA0 <= c
)); /* iso 8859 printables */
309 iso_8859_to_control (void *baton
, int c
, int *ctrl_char
)
311 *ctrl_char
= (c
& 0200) | (c
& 037);
316 /* Construct an ISO-8859-like character set. */
317 static struct charset
*
318 iso_8859_family_charset (const char *name
)
320 return simple_charset (name
, 1,
321 iso_8859_print_literally
, 0,
322 iso_8859_to_control
, 0);
327 /* EBCDIC family functions. */
331 ebcdic_print_literally (void *baton
, int c
)
335 return (64 <= c
&& c
<= 254);
340 ebcdic_to_control (void *baton
, int c
, int *ctrl_char
)
342 /* There are no control character equivalents in EBCDIC. Use
348 /* Construct an EBCDIC-like character set. */
349 static struct charset
*
350 ebcdic_family_charset (const char *name
)
352 return simple_charset (name
, 0,
353 ebcdic_print_literally
, 0,
354 ebcdic_to_control
, 0);
361 /* Fallback functions using iconv. */
363 #if defined(HAVE_ICONV)
365 struct cached_iconv
{
366 struct charset
*from
, *to
;
371 /* Make sure the iconv cache *CI contains an iconv descriptor
372 translating from FROM to TO. If it already does, fine; otherwise,
373 close any existing descriptor, and open up a new one. On success,
374 return zero; on failure, return -1 and set errno. */
376 check_iconv_cache (struct cached_iconv
*ci
,
377 struct charset
*from
,
382 /* Does the cached iconv descriptor match the conversion we're trying
386 && ci
->i
!= (iconv_t
) 0)
389 /* It doesn't. If we actually had any iconv descriptor open at
390 all, close it now. */
391 if (ci
->i
!= (iconv_t
) 0)
396 if (iconv_close (i
) == -1)
397 error ("Error closing `iconv' descriptor for "
398 "`%s'-to-`%s' character conversion: %s",
399 ci
->from
->name
, ci
->to
->name
, safe_strerror (errno
));
402 /* Open a new iconv descriptor for the required conversion. */
403 i
= iconv_open (to
->name
, from
->name
);
404 if (i
== (iconv_t
) -1)
415 /* Convert FROM_CHAR using the cached iconv conversion *CI. Return
416 non-zero if the conversion was successful, zero otherwise. */
418 cached_iconv_convert (struct cached_iconv
*ci
, int from_char
, int *to_char
)
421 ICONV_CONST
char *from_ptr
= &from
;
422 char to
, *to_ptr
= &to
;
423 size_t from_left
= sizeof (from
), to_left
= sizeof (to
);
425 gdb_assert (ci
->i
!= (iconv_t
) 0);
428 if (iconv (ci
->i
, &from_ptr
, &from_left
, &to_ptr
, &to_left
)
431 /* These all suggest that the input or output character sets
432 have multi-byte encodings of some characters, which means
433 it's unsuitable for use as a GDB character set. We should
434 never have selected it. */
435 gdb_assert (errno
!= E2BIG
&& errno
!= EINVAL
);
437 /* This suggests a bug in the code managing *CI. */
438 gdb_assert (errno
!= EBADF
);
440 /* This seems to mean that there is no equivalent character in
441 the `to' character set. */
445 /* Anything else is mysterious. */
446 internal_error (__FILE__
, __LINE__
,
447 "Error converting character `%d' from `%s' to `%s' "
449 from_char
, ci
->from
->name
, ci
->to
->name
,
450 safe_strerror (errno
));
453 /* If the pointers weren't advanced across the input, that also
454 suggests something was wrong. */
455 gdb_assert (from_left
== 0 && to_left
== 0);
457 *to_char
= (unsigned char) to
;
463 register_iconv_charsets (void)
465 /* Here we should check whether various character sets were
466 recognized by the local iconv implementation.
468 The first implementation registered a bunch of character sets
469 recognized by iconv, but then we discovered that iconv on Solaris
470 and iconv on GNU/Linux had no character sets in common. So we
471 replaced them with the hard-coded tables that appear later in the
475 #endif /* defined (HAVE_ICONV) */
478 /* Fallback routines for systems without iconv. */
480 #if ! defined (HAVE_ICONV)
481 struct cached_iconv
{ char nothing
; };
484 check_iconv_cache (struct cached_iconv
*ci
,
485 struct charset
*from
,
493 cached_iconv_convert (struct cached_iconv
*ci
, int from_char
, int *to_char
)
495 /* This function should never be called. */
500 register_iconv_charsets (void)
504 #endif /* ! defined(HAVE_ICONV) */
507 /* Default trivial conversion functions. */
510 identity_either_char_to_other (void *baton
, int either_char
, int *other_char
)
512 *other_char
= either_char
;
518 /* Default non-trivial conversion functions. */
521 static char backslashable
[] = "abfnrtv";
522 static char *backslashed
[] = {"a", "b", "f", "n", "r", "t", "v", "0"};
523 static char represented
[] = "\a\b\f\n\r\t\v";
526 /* Translate TARGET_CHAR into the host character set, and see if it
527 matches any of our standard escape sequences. */
529 default_c_target_char_has_backslash_escape (void *baton
, int target_char
)
534 /* If target_char has no equivalent in the host character set,
535 assume it doesn't have a backslashed form. */
536 if (! target_char_to_host (target_char
, &host_char
))
539 ix
= strchr (represented
, host_char
);
541 return backslashed
[ix
- represented
];
547 /* Translate the backslash the way we would in the host character set,
548 and then try to translate that into the target character set. */
550 default_c_parse_backslash (void *baton
, int host_char
, int *target_char
)
554 ix
= strchr (backslashable
, host_char
);
559 return host_char_to_target (represented
[ix
- backslashable
],
564 /* Convert using a cached iconv descriptor. */
566 iconv_convert (void *baton
, int from_char
, int *to_char
)
568 struct cached_iconv
*ci
= baton
;
569 return cached_iconv_convert (ci
, from_char
, to_char
);
574 /* Conversion tables. */
577 /* I'd much rather fall back on iconv whenever possible. But the
578 character set names you use with iconv aren't standardized at all,
579 a lot of platforms have really meager character set coverage, etc.
580 I wanted to have at least something we could use to exercise the
581 test suite on all platforms.
583 In the long run, we should have a configure-time process explore
584 somehow which character sets the host platform supports, and some
585 arrangement that allows GDB users to use platform-indepedent names
586 for character sets. */
589 /* We generated these tables using iconv on a GNU/Linux machine. */
592 static int ascii_to_iso_8859_1_table
[] = {
593 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
594 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
595 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
596 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
597 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
598 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
599 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
600 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
601 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
602 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
603 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
605 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
606 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
612 static int ascii_to_ebcdic_us_table
[] = {
613 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
614 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
615 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
616 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
617 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
618 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
619 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
620 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
623 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
627 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
628 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
632 static int ascii_to_ibm1047_table
[] = {
633 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
634 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
635 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
636 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
637 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
638 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
639 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
640 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
642 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
643 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
645 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
647 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
652 static int iso_8859_1_to_ascii_table
[] = {
653 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
654 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
655 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
656 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
657 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
658 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
659 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
660 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
661 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
662 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
663 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
664 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
665 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
666 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
667 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
668 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
672 static int iso_8859_1_to_ebcdic_us_table
[] = {
673 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
674 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
675 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
676 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
677 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
678 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
679 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
680 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
681 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
682 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
683 -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
684 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
685 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
686 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
687 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
688 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
692 static int iso_8859_1_to_ibm1047_table
[] = {
693 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
694 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
695 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
696 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
697 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
698 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
699 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
700 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
701 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
702 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
703 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
704 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
705 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
706 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
707 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
708 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
712 static int ebcdic_us_to_ascii_table
[] = {
713 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
714 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
715 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
716 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
717 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
718 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
719 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
720 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
721 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
722 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
723 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
724 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
725 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
726 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
727 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
728 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
732 static int ebcdic_us_to_iso_8859_1_table
[] = {
733 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
734 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
735 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
736 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
737 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
738 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
739 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
740 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
741 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
742 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
743 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
744 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
745 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
746 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
747 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
748 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
752 static int ebcdic_us_to_ibm1047_table
[] = {
753 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
754 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
755 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
756 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
757 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
758 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
759 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
760 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
761 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
762 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
763 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
764 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
765 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
766 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
767 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
768 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
772 static int ibm1047_to_ascii_table
[] = {
773 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
774 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
775 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
776 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
777 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
778 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
779 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
780 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
781 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
782 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
783 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
784 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
785 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
786 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
787 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
788 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
792 static int ibm1047_to_iso_8859_1_table
[] = {
793 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
794 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
795 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
796 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
797 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
798 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
799 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
800 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
801 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
802 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
803 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
804 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
805 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
806 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
807 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
808 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
812 static int ibm1047_to_ebcdic_us_table
[] = {
813 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
814 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
815 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
816 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
817 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
818 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
819 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
820 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
821 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
822 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
823 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
824 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
825 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
826 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
827 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
828 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
833 table_convert_char (void *baton
, int from
, int *to
)
835 int *table
= (int *) baton
;
837 if (0 <= from
&& from
<= 255
838 && table
[from
] != -1)
848 static struct translation
*
849 table_translation (const char *from
, const char *to
, int *table
,
850 const char *(*c_target_char_has_backslash_escape
)
851 (void *baton
, int target_char
),
852 void *c_target_char_has_backslash_escape_baton
,
853 int (*c_parse_backslash
) (void *baton
,
856 void *c_parse_backslash_baton
)
858 struct translation
*t
= xmalloc (sizeof (*t
));
860 memset (t
, 0, sizeof (*t
));
863 t
->c_target_char_has_backslash_escape
= c_target_char_has_backslash_escape
;
864 t
->c_target_char_has_backslash_escape_baton
865 = c_target_char_has_backslash_escape_baton
;
866 t
->c_parse_backslash
= c_parse_backslash
;
867 t
->c_parse_backslash_baton
= c_parse_backslash_baton
;
868 t
->convert_char
= table_convert_char
;
869 t
->convert_char_baton
= (void *) table
;
875 static struct translation
*
876 simple_table_translation (const char *from
, const char *to
, int *table
)
878 return table_translation (from
, to
, table
, 0, 0, 0, 0);
883 /* Setting and retrieving the host and target charsets. */
886 /* The current host and target character sets. */
887 static struct charset
*current_host_charset
, *current_target_charset
;
889 /* The current functions and batons we should use for the functions in
892 static const char *(*c_target_char_has_backslash_escape_func
)
893 (void *baton
, int target_char
);
894 static void *c_target_char_has_backslash_escape_baton
;
896 static int (*c_parse_backslash_func
) (void *baton
,
899 static void *c_parse_backslash_baton
;
901 static int (*host_char_to_target_func
) (void *baton
,
904 static void *host_char_to_target_baton
;
906 static int (*target_char_to_host_func
) (void *baton
,
909 static void *target_char_to_host_baton
;
912 /* Cached iconv conversions, that might be useful to fallback
914 static struct cached_iconv cached_iconv_host_to_target
;
915 static struct cached_iconv cached_iconv_target_to_host
;
918 /* Charset structures manipulation functions. */
920 static struct charset
*
921 lookup_charset_or_error (const char *name
)
923 struct charset
*cs
= lookup_charset (name
);
926 error ("GDB doesn't know of any character set named `%s'.", name
);
932 check_valid_host_charset (struct charset
*cs
)
934 if (! cs
->valid_host_charset
)
935 error ("GDB can't use `%s' as its host character set.", cs
->name
);
938 /* Set the host and target character sets to HOST and TARGET. */
940 set_host_and_target_charsets (struct charset
*host
, struct charset
*target
)
942 struct translation
*h2t
, *t2h
;
944 /* If they're not both initialized yet, then just do nothing for
945 now. As soon as we're done running our initialize function,
946 everything will be initialized. */
947 if (! host
|| ! target
)
949 current_host_charset
= host
;
950 current_target_charset
= target
;
954 h2t
= lookup_translation (host
->name
, target
->name
);
955 t2h
= lookup_translation (target
->name
, host
->name
);
957 /* If the translations don't provide conversion functions, make sure
958 iconv can back them up. Do this *before* modifying any state. */
961 if (! h2t
|| ! h2t
->convert_char
)
963 if (check_iconv_cache (&cached_iconv_host_to_target
, host
, target
)
965 error ("GDB can't convert from the `%s' character set to `%s'.",
966 host
->name
, target
->name
);
968 if (! t2h
|| ! t2h
->convert_char
)
970 if (check_iconv_cache (&cached_iconv_target_to_host
, target
, host
)
972 error ("GDB can't convert from the `%s' character set to `%s'.",
973 target
->name
, host
->name
);
977 if (t2h
&& t2h
->c_target_char_has_backslash_escape
)
979 c_target_char_has_backslash_escape_func
980 = t2h
->c_target_char_has_backslash_escape
;
981 c_target_char_has_backslash_escape_baton
982 = t2h
->c_target_char_has_backslash_escape_baton
;
985 c_target_char_has_backslash_escape_func
986 = default_c_target_char_has_backslash_escape
;
988 if (h2t
&& h2t
->c_parse_backslash
)
990 c_parse_backslash_func
= h2t
->c_parse_backslash
;
991 c_parse_backslash_baton
= h2t
->c_parse_backslash_baton
;
994 c_parse_backslash_func
= default_c_parse_backslash
;
996 if (h2t
&& h2t
->convert_char
)
998 host_char_to_target_func
= h2t
->convert_char
;
999 host_char_to_target_baton
= h2t
->convert_char_baton
;
1001 else if (host
== target
)
1002 host_char_to_target_func
= identity_either_char_to_other
;
1005 host_char_to_target_func
= iconv_convert
;
1006 host_char_to_target_baton
= &cached_iconv_host_to_target
;
1009 if (t2h
&& t2h
->convert_char
)
1011 target_char_to_host_func
= t2h
->convert_char
;
1012 target_char_to_host_baton
= t2h
->convert_char_baton
;
1014 else if (host
== target
)
1015 target_char_to_host_func
= identity_either_char_to_other
;
1018 target_char_to_host_func
= iconv_convert
;
1019 target_char_to_host_baton
= &cached_iconv_target_to_host
;
1022 current_host_charset
= host
;
1023 current_target_charset
= target
;
1026 /* Do the real work of setting the host charset. */
1028 set_host_charset (const char *charset
)
1030 struct charset
*cs
= lookup_charset_or_error (charset
);
1031 check_valid_host_charset (cs
);
1032 set_host_and_target_charsets (cs
, current_target_charset
);
1035 /* Do the real work of setting the target charset. */
1037 set_target_charset (const char *charset
)
1039 struct charset
*cs
= lookup_charset_or_error (charset
);
1041 set_host_and_target_charsets (current_host_charset
, cs
);
1045 /* 'Set charset', 'set host-charset', 'set target-charset', 'show
1046 charset' sfunc's. */
1048 /* This is the sfunc for the 'set charset' command. */
1050 set_charset_sfunc (char *charset
, int from_tty
, struct cmd_list_element
*c
)
1052 struct charset
*cs
= lookup_charset_or_error (host_charset_name
);
1053 check_valid_host_charset (cs
);
1054 /* CAREFUL: set the target charset here as well. */
1055 target_charset_name
= host_charset_name
;
1056 set_host_and_target_charsets (cs
, cs
);
1059 /* 'set host-charset' command sfunc. We need a wrapper here because
1060 the function needs to have a specific signature. */
1062 set_host_charset_sfunc (char *charset
, int from_tty
,
1063 struct cmd_list_element
*c
)
1065 set_host_charset (host_charset_name
);
1068 /* Wrapper for the 'set target-charset' command. */
1070 set_target_charset_sfunc (char *charset
, int from_tty
,
1071 struct cmd_list_element
*c
)
1073 set_target_charset (target_charset_name
);
1076 /* sfunc for the 'show charset' command. */
1078 show_charset (char *arg
, int from_tty
)
1080 if (current_host_charset
== current_target_charset
)
1082 printf_filtered ("The current host and target character set is `%s'.\n",
1087 printf_filtered ("The current host character set is `%s'.\n",
1089 printf_filtered ("The current target character set is `%s'.\n",
1095 /* Accessor functions. */
1100 return current_host_charset
->name
;
1104 target_charset (void)
1106 return current_target_charset
->name
;
1111 /* Public character management functions. */
1115 c_target_char_has_backslash_escape (int target_char
)
1117 return ((*c_target_char_has_backslash_escape_func
)
1118 (c_target_char_has_backslash_escape_baton
, target_char
));
1123 c_parse_backslash (int host_char
, int *target_char
)
1125 return (*c_parse_backslash_func
) (c_parse_backslash_baton
,
1126 host_char
, target_char
);
1131 host_char_print_literally (int host_char
)
1133 return ((*current_host_charset
->host_char_print_literally
)
1134 (current_host_charset
->host_char_print_literally_baton
,
1140 target_char_to_control_char (int target_char
, int *target_ctrl_char
)
1142 return ((*current_target_charset
->target_char_to_control_char
)
1143 (current_target_charset
->target_char_to_control_char_baton
,
1144 target_char
, target_ctrl_char
));
1149 host_char_to_target (int host_char
, int *target_char
)
1151 return ((*host_char_to_target_func
)
1152 (host_char_to_target_baton
, host_char
, target_char
));
1157 target_char_to_host (int target_char
, int *host_char
)
1159 return ((*target_char_to_host_func
)
1160 (target_char_to_host_baton
, target_char
, host_char
));
1165 /* The charset.c module initialization function. */
1167 extern initialize_file_ftype _initialize_charset
; /* -Wmissing-prototype */
1170 _initialize_charset (void)
1172 struct cmd_list_element
*new_cmd
;
1174 /* Register all the character set GDB knows about.
1176 You should use the same names that iconv does, where possible, to
1177 take advantage of the iconv-based default behaviors.
1179 CAUTION: if you register a character set, you must also register
1180 as many translations as are necessary to make that character set
1181 interoperate correctly with all the other character sets. We do
1182 provide default behaviors when no translation is available, or
1183 when a translation's function pointer for a particular operation
1184 is zero. Hopefully, these defaults will be correct often enough
1185 that we won't need to provide too many translations. */
1186 register_charset (simple_charset ("ASCII", 1,
1187 ascii_print_literally
, 0,
1188 ascii_to_control
, 0));
1189 register_charset (iso_8859_family_charset ("ISO-8859-1"));
1190 register_charset (ebcdic_family_charset ("EBCDIC-US"));
1191 register_charset (ebcdic_family_charset ("IBM1047"));
1192 register_iconv_charsets ();
1195 struct { char *from
; char *to
; int *table
; } tlist
[] = {
1196 { "ASCII", "ISO-8859-1", ascii_to_iso_8859_1_table
},
1197 { "ASCII", "EBCDIC-US", ascii_to_ebcdic_us_table
},
1198 { "ASCII", "IBM1047", ascii_to_ibm1047_table
},
1199 { "ISO-8859-1", "ASCII", iso_8859_1_to_ascii_table
},
1200 { "ISO-8859-1", "EBCDIC-US", iso_8859_1_to_ebcdic_us_table
},
1201 { "ISO-8859-1", "IBM1047", iso_8859_1_to_ibm1047_table
},
1202 { "EBCDIC-US", "ASCII", ebcdic_us_to_ascii_table
},
1203 { "EBCDIC-US", "ISO-8859-1", ebcdic_us_to_iso_8859_1_table
},
1204 { "EBCDIC-US", "IBM1047", ebcdic_us_to_ibm1047_table
},
1205 { "IBM1047", "ASCII", ibm1047_to_ascii_table
},
1206 { "IBM1047", "ISO-8859-1", ibm1047_to_iso_8859_1_table
},
1207 { "IBM1047", "EBCDIC-US", ibm1047_to_ebcdic_us_table
}
1212 for (i
= 0; i
< (sizeof (tlist
) / sizeof (tlist
[0])); i
++)
1213 register_translation (simple_table_translation (tlist
[i
].from
,
1218 set_host_charset (host_charset_name
);
1219 set_target_charset (target_charset_name
);
1221 new_cmd
= add_set_enum_cmd ("charset",
1225 "Set the host and target character sets.\n"
1226 "The `host character set' is the one used by the system GDB is running on.\n"
1227 "The `target character set' is the one used by the program being debugged.\n"
1228 "You may only use supersets of ASCII for your host character set; GDB does\n"
1229 "not support any others.\n"
1230 "To see a list of the character sets GDB supports, type `set charset <TAB>'.",
1233 /* Note that the sfunc below needs to set target_charset_name, because
1234 the 'set charset' command sets two variables. */
1235 set_cmd_sfunc (new_cmd
, set_charset_sfunc
);
1236 /* Don't use set_from_show - need to print some extra info. */
1237 add_cmd ("charset", class_support
, show_charset
,
1238 "Show the host and target character sets.\n"
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>'.",
1247 new_cmd
= add_set_enum_cmd ("host-charset",
1251 "Set the host character set.\n"
1252 "The `host character set' is the one used by the system GDB is running on.\n"
1253 "You may only use supersets of ASCII for your host character set; GDB does\n"
1254 "not support any others.\n"
1255 "To see a list of the character sets GDB supports, type `set host-charset <TAB>'.",
1258 set_cmd_sfunc (new_cmd
, set_host_charset_sfunc
);
1260 add_show_from_set (new_cmd
, &showlist
);
1264 new_cmd
= add_set_enum_cmd ("target-charset",
1266 target_charset_enum
,
1267 &target_charset_name
,
1268 "Set the target character set.\n"
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>",
1275 set_cmd_sfunc (new_cmd
, set_target_charset_sfunc
);
1276 add_show_from_set (new_cmd
, &showlist
);