2009-03-19  Tom Tromey  <tromey@redhat.com>
	    Julian Brown  <julian@codesourcery.com>

	PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
	PR i18n/9401, PR exp/9613:
	* NEWS: Update
	* value.h (value_typed_string): Declare.
	(val_print_string): Update.
	* valprint.h (print_char_chars): Update.
	* valprint.c (print_char_chars): Add type argument.  Update.
	(val_print_string): Likewise.
	* valops.c (value_typed_string): New function.
	* utils.c (host_char_to_target): New function.
	(parse_escape): Use host_char_to_target, host_hex_value.  Update.
	Remove '^' case.
	(no_control_char_error): Remove.
	* typeprint.c (print_type_scalar): Update.
	* scm-valprint.c (scm_scmval_print): Update.
	* scm-lang.h (scm_printchar, scm_printstr): Update.
	* scm-lang.c (scm_printchar): Add type argument.
	(scm_printstr): Likewise.
	* printcmd.c (print_formatted): Update.
	(print_scalar_formatted): Update.
	(printf_command) <wide_string_arg, wide_char_arg>: New constants.
	Handle '%lc' and '%ls'.
	* parser-defs.h (struct typed_stoken): New type.
	(struct stoken_vector): Likewise.
	(write_exp_string_vector): Declare.
	* parse.c (write_exp_string_vector): New function.
	* p-valprint.c (pascal_val_print): Update.
	* p-lang.h (is_pascal_string_type, pascal_printchar,
	pascal_printstr): Update.
	* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
	Add 'char_type' argument.
	(pascal_emit_char): Add type argument.
	(pascal_printchar): Likewise.
	(pascal_printstr): Likewise.
	* objc-lang.c (objc_emit_char): Add type argument.
	(objc_printchar): Likewise.
	(objc_printstr): Likewise.
	* macroexp.c (get_character_constant): Handle unicode characters.
	Use c_parse_escape.
	(get_string_literal): Handle unicode strings.  Use
	c_parse_escape.
	* m2-valprint.c (print_unpacked_pointer): Update.
	(m2_print_array_contents): Update.
	(m2_val_print): Update.
	* m2-lang.c (m2_emit_char): Add type argument.
	(m2_printchar): Likewise.
	(m2_printstr): Likewise.
	* language.h (struct language_defn) <la_printchar>: Add type
	argument.
	<la_printstr, la_emitchar>: Likewise.
	(LA_PRINT_CHAR): Likewise.
	(LA_PRINT_STRING): Likewise.
	(LA_EMIT_CHAR): Likewise.
	* language.c (unk_lang_emit_char): Add type argument.
	(unk_lang_printchar): Likewise.
	(unk_lang_printstr): Likewise.
	* jv-valprint.c (java_val_print): Update.
	* jv-lang.c (java_emit_char): Add type argument.
	* f-valprint.c (f_val_print): Update.
	* f-lang.c (f_emit_char): Add type argument.
	(f_printchar): Likewise.
	(f_printstr): Likewise.
	* expprint.c (print_subexp_standard): Update.
	* charset.h (target_wide_charset): Declare.
	(c_target_char_has_backslash_escape, c_parse_backslash,
	host_char_print_literally, host_char_to_target,
	target_char_to_host, target_char_to_control_char): Remove.
	(enum transliterations): New type.
	(convert_between_encodings): Declare.
	(HOST_ESCAPE_CHAR): New define.
	(host_letter_to_control_character, host_hex_value): Declare.
	(enum wchar_iterate_result): New enum.
	(struct wchar_iterator): Declare.
	(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
	wchar_push_back): Declare.
	* charset-list.h: New file.
	* c-valprint.c (textual_name): New function.
	(textual_element_type): Handle wide character types.
	(c_val_print): Pass original type to textual_element_type.  Handle
	wide character types.
	(c_value_print): Use textual_element_type.  Pass original type of
	value to val_print.
	* c-lang.h (enum c_string_type): New type.
	(c_printchar, c_printstr): Update.
	* c-lang.c (classify_type): New function.
	(print_wchar): Likewise.
	(c_emit_char): Add type argument.  Handle wide characters.
	(c_printchar): Likewise.
	(c_printstr): Add type argument.  Handle wide and multibyte
	character sets.
	(convert_ucn): New function.
	(emit_numeric_character): Likewise.
	(convert_octal): Likewise.
	(convert_hex): Likewise.
	(ADVANCE): New macro.
	(convert_escape): New function.
	(parse_one_string): Likewise.
	(evaluate_subexp_c): Likewise.
	(exp_descriptor_c): New global.
	(c_language_defn): Use exp_descriptor_c.
	(cplus_language_defn): Likewise.
	(asm_language_defn): Likewise.
	(minimal_language_defn): Likewise.
	(charset_for_string_type): New function.
	* c-exp.y (%union): Add 'svec' and 'tsval'.
	(CHAR): New token.
	(exp): Add CHAR production.
	(string_exp): Rewrite.
	(exp) <string_exp>: Rewrite.
	(tempbuf): Now global.
	(tempbuf_init): New global.
	(parse_string_or_char): New function.
	(yylex) <tempbuf>: Now global.
	<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
	Remove.
	Handle 'u', 'U', and 'L' prefixes.  Call parse_string_or_char.
	(c_parse_escape): New function.
	* auxv.c (fprint_target_auxv): Update.
	* ada-valprint.c (ada_emit_char): Add type argument.
	(ada_printchar): Likewise.
	(ada_print_scalar): Update.
	(printstr): Add type argument.  Update calls to ada_emit_char.
	(ada_printstr): Add type argument.
	(ada_val_print_array): Update.
	(ada_val_print_1): Likewise.
	* ada-lang.c (emit_char): Add type argument.
	* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
	type arguments.
	* gdb_locale.h: Include langinfo.h.
	* charset.c (_initialize_charset): Set default host charset from
	the locale.  Don't register charsets.  Add target-wide-charset
	commands.  Call find_charset_names.
	(struct charset, struct translation): Remove.
	(GDB_DEFAULT_HOST_CHARSET): Remove.
	(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
	(target_wide_charset_name): New global.
	(show_host_charset_name): Handle "auto".
	(show_target_wide_charset_name): New function.
	(host_charset_enum, target_charset_enum): Remove.
	(charset_enum): New global.
	(all_charsets, register_charset, lookup_charset, all_translations,
	register_translation, lookup_translation): Remove.
	(simple_charset, ascii_print_literally, ascii_to_control): Remove.
	(iso_8859_print_literally, iso_8859_to_control,
	iso_8859_family_charset): Remove.
	(ebcdic_print_literally, ebcdic_to_control,
	ebcdic_family_charset): Remove.
	(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
	register_iconv_charsets): Remove.
	(target_wide_charset_be_name, target_wide_charset_le_name): New
	globals.
	(identity_either_char_to_other): Remove.
	(set_be_le_names, validate): New functions.
	(backslashable, backslashed, represented): Remove.
	(default_c_target_char_has_backslash_escape): Remove.
	(default_c_parse_backslash, iconv_convert): Remove.
	(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
	ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
	iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
	ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
	ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
	ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
	(table_convert_char, table_translation, simple_table_translation):
	Remove.
	(current_host_charset, current_target_charset,
	c_target_char_has_backslash_escape_func,
	c_target_char_has_backslash_escape_baton): Remove.
	(c_parse_backslash_func, c_parse_backslash_baton): Remove.
	(host_char_to_target_func, host_char_to_target_baton): Remove.
	(target_char_to_host_func, target_char_to_host_baton): Remove.
	(cached_iconv_host_to_target, cached_iconv_target_to_host):
	Remove.
	(lookup_charset_or_error, check_valid_host_charset): Remove.
	(set_host_and_target_charsets): Remove.
	(set_host_charset, set_target_charset): Remove.
	(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
	(set_target_wide_charset_sfunc): New function.
	(show_charset): Print target wide character set.
	(host_charset, target_charset): Rewrite.
	(target_wide_charset): New function.
	(c_target_char_has_backslash_escape): Remove.
	(c_parse_backslash): Remove.
	(host_letter_to_control_character): New function.
	(host_char_print_literally): Remove.
	(host_hex_value): New function.
	(target_char_to_control_char): Remove.
	(cleanup_iconv): New function.
	(convert_between_encodings): New function.
	(target_char_to_host): Remove.
	(struct wchar_iterator): Define.
	(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
	wchar_push_back): New functions.
	(do_cleanup_iterator): New function.
	(char_ptr): New typedef.
	(charsets): New global.
	(add_one, find_charset_names): New functions.
	(default_charset_names): New global.
	(auto_host_charset_name): Likewise.
	* aclocal.m4, config.in, configure: Rebuild.
	* configure.ac: Call AM_LANGINFO_CODESET.
	(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
	(AM_ICONV): Invoke earlier.
	* acinclude.m4: Include codeset.m4.  Subst LIBICONV_INCLUDE and
	LIBICONV_LIBDIR.  Check for libiconv in build tree.
	* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
	(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
	(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
	* gdb_obstack.h (obstack_grow_wstr): New define.
        * gdb_wchar.h: New file.
        * defs.h: Include it.
gdb/testsuite:
	* gdb.base/store.exp: Update for change to escape output.
	* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
	to escape output.
	* gdb.base/pointers.exp: Update for change to escape output.
	* gdb.base/long_long.exp (gdb_test_long_long): Update for change
	to escape output.
	* gdb.base/constvars.exp (do_constvar_tests): Update for change to
	escape output.
	* gdb.base/call-rt-st.exp (print_struct_call): Update for change
	to escape output.
	* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
	escape output.
	* gdb.base/setvar.exp: Update for change to escape output.
	* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
	* gdb.base/printcmds.exp (test_print_all_chars): Update for change
	to escape output.
	(test_print_string_constants): Likewise.
	* gdb.base/charset.exp (valid_host_charset): Check size of
	wchar_t.  Handle UCS-2 and UCS-4.  Add tests for wide and unicode
	cases.  Handle "auto"-related output.
	* gdb.base/charset.c (char16_t, char32_t): New typedefs.
	(uvar, Uvar): New globals.
gdb/doc:
	* gdb.texinfo (Character Sets): Remove obsolete text.  Document
	set target-wide-charset.
	(Requirements): Mention iconv.
This commit is contained in:
Tom Tromey 2009-03-20 23:04:40 +00:00
parent cb249c71f6
commit 6c7a06a3fa
63 changed files with 4459 additions and 1979 deletions

View File

@ -1,3 +1,217 @@
2009-03-20 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
2009-03-20 Tom Tromey <tromey@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>

View File

@ -165,6 +165,8 @@ INTL_CFLAGS = @INCINTL@
# Where is the ICONV library? This can be empty if libc has iconv.
LIBICONV = @LIBICONV@
LIBICONV_INCLUDE = @LIBICONV_INCLUDE@
LIBICONV_LIBDIR = @LIBICONV_LIBDIR@
# Did the user give us a --with-sysroot option?
TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
@ -388,7 +390,8 @@ INTERNAL_CFLAGS_BASE = \
$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) \
$(LIBICONV_INCLUDE)
INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
@ -400,7 +403,7 @@ LDFLAGS = @LDFLAGS@
# I think it's perfectly reasonable for a user to set -pg in CFLAGS
# and have it work; that's why CFLAGS is here.
# PROFILE_CFLAGS is _not_ included, however, because we use monstartup.
INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS)
INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS) $(LIBICONV_LIBDIR)
# If your system is missing alloca(), or, more likely, it's there but
# it doesn't work, then refer to libiberty.

View File

@ -3,6 +3,15 @@
*** Changes since GDB 6.8
* GDB now has support for multi-byte and wide character sets on the
target. Strings whose character type is wchar_t, char16_t, or
char32_t are now correctly printed. GDB supports wide- and unicode-
literals in C, that is, L'x', L"string", u'x', u"string", U'x', and
U"string" syntax. And, GDB allows the "%ls" and "%lc" formats in
`printf'. This feature requires iconv to work properly; if your
system does not have a working iconv, GDB can use GNU libiconv. See
the installation instructions for more information.
* GDB now supports automatic retrieval of shared library files from
remote targets. To use this feature, specify a system root that begins
with the `remote:' prefix, either via the `set sysroot' command or via
@ -182,6 +191,11 @@ set target-async
with GDB while the target is running. "show target-async" displays the
current state of asynchronous execution of the target.
set target-wide-charset
show target-wide-charset
The target-wide-charset is the name of the character set that GDB
uses when printing characters whose type is wchar_t.
set tcp auto-retry (on|off)
show tcp auto-retry
set tcp connect-timeout

View File

@ -29,6 +29,9 @@ sinclude([../config/depstand.m4])
dnl For AM_LC_MESSAGES
sinclude([../config/lcmessage.m4])
dnl For AM_LANGINFO_CODESET.
sinclude([../config/codeset.m4])
#
# Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
# makes configure think it's cross compiling. If --target wasn't used, then
@ -174,14 +177,18 @@ AC_DEFUN([AM_ICONV],
AC_ARG_WITH([libiconv-prefix],
[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
for dir in `echo "$withval" | tr : ' '`; do
if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; LDFLAGS="$LDFLAGS -L$dir/lib"; fi
done
])
BUILD_LIBICONV_LIBDIR="-L../libiconv/lib/.libs -L../libiconv/lib/_libs"
BUILD_LIBICONV_INCLUDE="-I../libiconv/include"
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
am_cv_use_build_libiconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
@ -200,6 +207,26 @@ AC_DEFUN([AM_ICONV],
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
# Look for libiconv in the build tree.
if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
am_save_LIBS="$LIBS"
am_save_CPPFLAGS="$CPPFLAGS"
LIBS="$LIBS $BUILD_LIBICONV_LIBDIR -liconv"
CPPFLAGS="$CPPFLAGS $BUILD_LIBICONV_INCLUDE"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
if test "$am_cv_func_iconv" = "yes"; then
am_cv_use_build_libiconv=yes
else
CPPFLAGS="$am_save_CPPFLAGS"
fi
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
@ -229,7 +256,13 @@ size_t iconv();
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
fi
if test "$am_cv_use_build_libiconv" = yes; then
LIBICONV_LIBDIR="$BUILD_LIBICONV_LIBDIR"
LIBICONV_INCLUDE="$BUILD_LIBICONV_INCLUDE"
fi
AC_SUBST(LIBICONV)
AC_SUBST(LIBICONV_INCLUDE)
AC_SUBST(LIBICONV_LIBDIR)
])
dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva

View File

@ -11022,9 +11022,9 @@ ada_language_arch_info (struct gdbarch *gdbarch,
/* Not really used, but needed in the ada_language_defn. */
static void
emit_char (int c, struct ui_file *stream, int quoter)
emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
ada_emit_char (c, stream, quoter, 1);
ada_emit_char (c, type, stream, quoter, 1);
}
static int

View File

@ -255,12 +255,12 @@ extern int ada_value_print (struct value *, struct ui_file *,
/* Defined in ada-lang.c */
extern void ada_emit_char (int, struct ui_file *, int, int);
extern void ada_emit_char (int, struct type *, struct ui_file *, int, int);
extern void ada_printchar (int, struct ui_file *);
extern void ada_printchar (int, struct type *, struct ui_file *);
extern void ada_printstr (struct ui_file *, const gdb_byte *,
unsigned int, int, int,
extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *,
unsigned int, int,
const struct value_print_options *);
struct value *ada_convert_actual (struct value *actual,

View File

@ -269,7 +269,8 @@ printable_val_type (struct type *type, const gdb_byte *valaddr)
(1 or 2) of the character. */
void
ada_emit_char (int c, struct ui_file *stream, int quoter, int type_len)
ada_emit_char (int c, struct type *type, struct ui_file *stream,
int quoter, int type_len)
{
if (type_len != 2)
type_len = 1;
@ -366,10 +367,10 @@ ada_print_floating (const gdb_byte *valaddr, struct type *type,
}
void
ada_printchar (int c, struct ui_file *stream)
ada_printchar (int c, struct type *type, struct ui_file *stream)
{
fputs_filtered ("'", stream);
ada_emit_char (c, stream, '\'', 1);
ada_emit_char (c, type, stream, '\'', 1);
fputs_filtered ("'", stream);
}
@ -411,7 +412,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
break;
case TYPE_CODE_CHAR:
LA_PRINT_CHAR ((unsigned char) val, stream);
LA_PRINT_CHAR ((unsigned char) val, type, stream);
break;
case TYPE_CODE_BOOL:
@ -454,7 +455,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
*/
static void
printstr (struct ui_file *stream, const gdb_byte *string,
printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
unsigned int length, int force_ellipses, int type_len,
const struct value_print_options *options)
{
@ -506,7 +507,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
in_quotes = 0;
}
fputs_filtered ("'", stream);
ada_emit_char (char_at (string, i, type_len), stream, '\'',
ada_emit_char (char_at (string, i, type_len), elttype, stream, '\'',
type_len);
fputs_filtered ("'", stream);
fprintf_filtered (stream, _(" <repeats %u times>"), reps);
@ -524,7 +525,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("\"", stream);
in_quotes = 1;
}
ada_emit_char (char_at (string, i, type_len), stream, '"',
ada_emit_char (char_at (string, i, type_len), elttype, stream, '"',
type_len);
things_printed += 1;
}
@ -544,11 +545,12 @@ printstr (struct ui_file *stream, const gdb_byte *string,
}
void
ada_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
ada_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
printstr (stream, string, length, force_ellipses, width, options);
printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type),
options);
}
@ -637,7 +639,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
len = temp_len;
}
printstr (stream, valaddr, len, 0, eltlen, options);
printstr (stream, elttype, valaddr, len, 0, eltlen, options);
result = len;
}
else
@ -817,7 +819,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
{
fputs_filtered (" ", stream);
ada_printchar ((unsigned char) unpack_long (type, valaddr),
stream);
type, stream);
}
}
return 0;

View File

@ -248,7 +248,8 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
get_user_print_options (&opts);
if (opts.addressprint)
fprintf_filtered (file, "0x%s", paddr_nz (val));
val_print_string (val, -1, 1, file, &opts);
val_print_string (builtin_type (target_gdbarch)->builtin_char,
val, -1, file, &opts);
fprintf_filtered (file, "\n");
}
break;

View File

@ -141,6 +141,7 @@ void yyerror (char *);
struct symbol *sym;
struct type *tval;
struct stoken sval;
struct typed_stoken tsval;
struct ttype tsym;
struct symtoken ssym;
int voidval;
@ -148,6 +149,7 @@ void yyerror (char *);
enum exp_opcode opcode;
struct internalvar *ivar;
struct stoken_vector svec;
struct type **tvec;
int *ivec;
}
@ -180,11 +182,13 @@ static int parse_number (char *, int, int, YYSTYPE *);
Contexts where this distinction is not important can use the
nonterminal "name", which matches either NAME or TYPENAME. */
%token <sval> STRING
%token <tsval> STRING
%token <tsval> CHAR
%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
%token <voidval> COMPLETE
%token <tsym> TYPENAME
%type <sval> name string_exp
%type <sval> name
%type <svec> string_exp
%type <ssym> name_not_typename
%type <tsym> typename
@ -522,6 +526,15 @@ exp : INT
write_exp_elt_opcode (OP_LONG); }
;
exp : CHAR
{
struct stoken_vector vec;
vec.len = 1;
vec.tokens = &$1;
write_exp_string_vector ($1.type, &vec);
}
;
exp : NAME_OR_INT
{ YYSTYPE val;
parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
@ -570,48 +583,64 @@ string_exp:
string. Note that we follow the
NUL-termination convention of the
lexer. */
$$.length = $1.length;
$$.ptr = malloc ($1.length + 1);
memcpy ($$.ptr, $1.ptr, $1.length + 1);
struct typed_stoken *vec = XNEW (struct typed_stoken);
$$.len = 1;
$$.tokens = vec;
vec->type = $1.type;
vec->length = $1.length;
vec->ptr = malloc ($1.length + 1);
memcpy (vec->ptr, $1.ptr, $1.length + 1);
}
| string_exp STRING
{
/* Note that we NUL-terminate here, but just
for convenience. */
struct stoken t;
t.length = $1.length + $2.length;
t.ptr = malloc (t.length + 1);
memcpy (t.ptr, $1.ptr, $1.length);
memcpy (t.ptr + $1.length, $2.ptr, $2.length + 1);
free ($1.ptr);
$$ = t;
char *p;
++$$.len;
$$.tokens = realloc ($$.tokens,
$$.len * sizeof (struct typed_stoken));
p = malloc ($2.length + 1);
memcpy (p, $2.ptr, $2.length + 1);
$$.tokens[$$.len - 1].type = $2.type;
$$.tokens[$$.len - 1].length = $2.length;
$$.tokens[$$.len - 1].ptr = p;
}
;
exp : string_exp
{ /* C strings are converted into array constants with
an explicit null byte added at the end. Thus
the array upper bound is the string length.
There is no such thing in C as a completely empty
string. */
char *sp = $1.ptr; int count = $1.length;
while (count-- > 0)
{
int i;
enum c_string_type type = C_STRING;
for (i = 0; i < $1.len; ++i)
{
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG);
switch ($1.tokens[i].type)
{
case C_STRING:
break;
case C_WIDE_STRING:
case C_STRING_16:
case C_STRING_32:
if (type != C_STRING
&& type != $1.tokens[i].type)
error ("Undefined string concatenation.");
type = $1.tokens[i].type;
break;
default:
/* internal error */
internal_error (__FILE__, __LINE__,
"unrecognized type in string concatenation");
}
}
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY);
write_exp_elt_longcst ((LONGEST) 0);
write_exp_elt_longcst ((LONGEST) ($1.length));
write_exp_elt_opcode (OP_ARRAY);
free ($1.ptr);
write_exp_string_vector (type, &$1);
for (i = 0; i < $1.len; ++i)
free ($1.tokens[i].ptr);
free ($1.tokens);
}
;
@ -1359,6 +1388,263 @@ parse_number (p, len, parsed_float, putithere)
return INT;
}
/* Temporary obstack used for holding strings. */
static struct obstack tempbuf;
static int tempbuf_init;
/* Parse a C escape sequence. The initial backslash of the sequence
is at (*PTR)[-1]. *PTR will be updated to point to just after the
last character of the sequence. If OUTPUT is not NULL, the
translated form of the escape sequence will be written there. If
OUTPUT is NULL, no output is written and the call will only affect
*PTR. If an escape sequence is expressed in target bytes, then the
entire sequence will simply be copied to OUTPUT. Return 1 if any
character was emitted, 0 otherwise. */
int
c_parse_escape (char **ptr, struct obstack *output)
{
char *tokptr = *ptr;
int result = 1;
/* Some escape sequences undergo character set conversion. Those we
translate here. */
switch (*tokptr)
{
/* Hex escapes do not undergo character set conversion, so keep
the escape sequence for later. */
case 'x':
if (output)
obstack_grow_str (output, "\\x");
++tokptr;
if (!isxdigit (*tokptr))
error (_("\\x escape without a following hex digit"));
while (isxdigit (*tokptr))
{
if (output)
obstack_1grow (output, *tokptr);
++tokptr;
}
break;
/* Octal escapes do not undergo character set conversion, so
keep the escape sequence for later. */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
if (output)
obstack_grow_str (output, "\\");
while (isdigit (*tokptr) && *tokptr != '8' && *tokptr != '9')
{
if (output)
obstack_1grow (output, *tokptr);
++tokptr;
}
break;
/* We handle UCNs later. We could handle them here, but that
would mean a spurious error in the case where the UCN could
be converted to the target charset but not the host
charset. */
case 'u':
case 'U':
{
char c = *tokptr;
int i, len = c == 'U' ? 8 : 4;
if (output)
{
obstack_1grow (output, '\\');
obstack_1grow (output, *tokptr);
}
++tokptr;
if (!isxdigit (*tokptr))
error (_("\\%c escape without a following hex digit"), c);
for (i = 0; i < len && isxdigit (*tokptr); ++i)
{
if (output)
obstack_1grow (output, *tokptr);
++tokptr;
}
}
break;
/* We must pass backslash through so that it does not
cause quoting during the second expansion. */
case '\\':
if (output)
obstack_grow_str (output, "\\\\");
++tokptr;
break;
/* Escapes which undergo conversion. */
case 'a':
if (output)
obstack_1grow (output, '\a');
++tokptr;
break;
case 'b':
if (output)
obstack_1grow (output, '\b');
++tokptr;
break;
case 'f':
if (output)
obstack_1grow (output, '\f');
++tokptr;
break;
case 'n':
if (output)
obstack_1grow (output, '\n');
++tokptr;
break;
case 'r':
if (output)
obstack_1grow (output, '\r');
++tokptr;
break;
case 't':
if (output)
obstack_1grow (output, '\t');
++tokptr;
break;
case 'v':
if (output)
obstack_1grow (output, '\v');
++tokptr;
break;
/* GCC extension. */
case 'e':
if (output)
obstack_1grow (output, HOST_ESCAPE_CHAR);
++tokptr;
break;
/* Backslash-newline expands to nothing at all. */
case '\n':
++tokptr;
result = 0;
break;
/* A few escapes just expand to the character itself. */
case '\'':
case '\"':
case '?':
/* GCC extensions. */
case '(':
case '{':
case '[':
case '%':
/* Unrecognized escapes turn into the character itself. */
default:
if (output)
obstack_1grow (output, *tokptr);
++tokptr;
break;
}
*ptr = tokptr;
return result;
}
/* Parse a string or character literal from TOKPTR. The string or
character may be wide or unicode. *OUTPTR is set to just after the
end of the literal in the input string. The resulting token is
stored in VALUE. This returns a token value, either STRING or
CHAR, depending on what was parsed. *HOST_CHARS is set to the
number of host characters in the literal. */
static int
parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
int *host_chars)
{
int quote, i;
enum c_string_type type;
/* Build the gdb internal form of the input string in tempbuf. Note
that the buffer is null byte terminated *only* for the
convenience of debugging gdb itself and printing the buffer
contents when the buffer contains no embedded nulls. Gdb does
not depend upon the buffer being null byte terminated, it uses
the length string instead. This allows gdb to handle C strings
(as well as strings in other languages) with embedded null
bytes */
if (!tempbuf_init)
tempbuf_init = 1;
else
obstack_free (&tempbuf, NULL);
obstack_init (&tempbuf);
/* Record the string type. */
if (*tokptr == 'L')
{
type = C_WIDE_STRING;
++tokptr;
}
else if (*tokptr == 'u')
{
type = C_STRING_16;
++tokptr;
}
else if (*tokptr == 'U')
{
type = C_STRING_32;
++tokptr;
}
else
type = C_STRING;
/* Skip the quote. */
quote = *tokptr;
if (quote == '\'')
type |= C_CHAR;
++tokptr;
*host_chars = 0;
while (*tokptr)
{
char c = *tokptr;
if (c == '\\')
{
++tokptr;
*host_chars += c_parse_escape (&tokptr, &tempbuf);
}
else if (c == quote)
break;
else
{
obstack_1grow (&tempbuf, c);
++tokptr;
/* FIXME: this does the wrong thing with multi-byte host
characters. We could use mbrlen here, but that would
make "set host-charset" a bit less useful. */
++*host_chars;
}
}
if (*tokptr != quote)
{
if (quote == '"')
error ("Unterminated string in expression.");
else
error ("Unmatched single quote.");
}
++tokptr;
value->type = type;
value->ptr = obstack_base (&tempbuf);
value->length = obstack_object_size (&tempbuf);
*outptr = tokptr;
return quote == '"' ? STRING : CHAR;
}
struct token
{
char *operator;
@ -1528,12 +1814,6 @@ yylex ()
int namelen;
unsigned int i;
char *tokstart;
char *tokptr;
int tempbufindex;
static char *tempbuf;
static int tempbufsize;
char * token_string = NULL;
int class_prefix = 0;
int saw_structop = last_was_structop;
char *copy;
@ -1605,46 +1885,6 @@ yylex ()
lexptr++;
goto retry;
case '\'':
/* We either have a character constant ('0' or '\177' for example)
or we have a quoted symbol reference ('foo(int,int)' in C++
for example). */
lexptr++;
c = *lexptr++;
if (c == '\\')
c = parse_escape (&lexptr);
else if (c == '\'')
error ("Empty character constant.");
else if (! host_char_to_target (c, &c))
{
int toklen = lexptr - tokstart + 1;
char *tok = alloca (toklen + 1);
memcpy (tok, tokstart, toklen);
tok[toklen] = '\0';
error ("There is no character corresponding to %s in the target "
"character set `%s'.", tok, target_charset ());
}
yylval.typed_val_int.val = c;
yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++;
if (c != '\'')
{
namelen = skip_quoted (tokstart) - tokstart;
if (namelen > 2)
{
lexptr = tokstart + namelen;
if (lexptr[-1] != '\'')
error ("Unmatched single quote.");
namelen -= 2;
tokstart++;
goto tryname;
}
error ("Invalid character constant.");
}
return INT;
case '(':
paren_depth++;
lexptr++;
@ -1762,70 +2002,33 @@ yylex ()
lexptr++;
return c;
case 'L':
case 'u':
case 'U':
if (tokstart[1] != '"' && tokstart[1] != '\'')
break;
/* Fall through. */
case '\'':
case '"':
/* Build the gdb internal form of the input string in tempbuf,
translating any standard C escape forms seen. Note that the
buffer is null byte terminated *only* for the convenience of
debugging gdb itself and printing the buffer contents when
the buffer contains no embedded nulls. Gdb does not depend
upon the buffer being null byte terminated, it uses the length
string instead. This allows gdb to handle C strings (as well
as strings in other languages) with embedded null bytes */
tokptr = ++tokstart;
tempbufindex = 0;
do {
char *char_start_pos = tokptr;
/* Grow the static temp buffer if necessary, including allocating
the first one on demand. */
if (tempbufindex + 1 >= tempbufsize)
{
int host_len;
int result = parse_string_or_char (tokstart, &lexptr, &yylval.tsval,
&host_len);
if (result == CHAR)
{
tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
}
switch (*tokptr)
{
case '\0':
case '"':
/* Do nothing, loop will terminate. */
break;
case '\\':
tokptr++;
c = parse_escape (&tokptr);
if (c == -1)
if (host_len == 0)
error ("Empty character constant.");
else if (host_len > 2 && c == '\'')
{
continue;
++tokstart;
namelen = lexptr - tokstart - 1;
goto tryname;
}
tempbuf[tempbufindex++] = c;
break;
default:
c = *tokptr++;
if (! host_char_to_target (c, &c))
{
int len = tokptr - char_start_pos;
char *copy = alloca (len + 1);
memcpy (copy, char_start_pos, len);
copy[len] = '\0';
error ("There is no character corresponding to `%s' "
"in the target character set `%s'.",
copy, target_charset ());
}
tempbuf[tempbufindex++] = c;
break;
else if (host_len > 1)
error ("Invalid character constant.");
}
} while ((*tokptr != '"') && (*tokptr != '\0'));
if (*tokptr++ != '"')
{
error ("Unterminated string in expression.");
}
tempbuf[tempbufindex] = '\0'; /* See note above */
yylval.sval.ptr = tempbuf;
yylval.sval.length = tempbufindex;
lexptr = tokptr;
return (STRING);
return result;
}
}
if (!(c == '_' || c == '$'

View File

@ -33,48 +33,304 @@
#include "demangle.h"
#include "cp-abi.h"
#include "cp-support.h"
#include "gdb_obstack.h"
#include <ctype.h>
extern void _initialize_c_language (void);
static void c_emit_char (int c, struct ui_file * stream, int quoter);
/* Given a C string type, STR_TYPE, return the corresponding target
character set name. */
static const char *
charset_for_string_type (enum c_string_type str_type)
{
switch (str_type & ~C_CHAR)
{
case C_STRING:
return target_charset ();
case C_WIDE_STRING:
return target_wide_charset ();
case C_STRING_16:
/* FIXME: UCS-2 is not always correct. */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
return "UCS-2BE";
else
return "UCS-2LE";
case C_STRING_32:
/* FIXME: UCS-4 is not always correct. */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
return "UCS-4BE";
else
return "UCS-4LE";
}
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
}
/* Classify ELTTYPE according to what kind of character it is. Return
the enum constant representing the character type. Also set
*ENCODING to the name of the character set to use when converting
characters of this type to the host character set. */
static enum c_string_type
classify_type (struct type *elttype, const char **encoding)
{
struct type *saved_type;
enum c_string_type result;
/* We do one or two passes -- one on ELTTYPE, and then maybe a
second one on a typedef target. */
do
{
char *name = TYPE_NAME (elttype);
if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
{
result = C_CHAR;
goto done;
}
if (!strcmp (name, "wchar_t"))
{
result = C_WIDE_CHAR;
goto done;
}
if (!strcmp (name, "char16_t"))
{
result = C_CHAR_16;
goto done;
}
if (!strcmp (name, "char32_t"))
{
result = C_CHAR_32;
goto done;
}
saved_type = elttype;
CHECK_TYPEDEF (elttype);
}
while (elttype != saved_type);
/* Punt. */
result = C_CHAR;
done:
*encoding = charset_for_string_type (result);
return result;
}
/* Return true if print_wchar can display W without resorting to a
numeric escape, false otherwise. */
static int
wchar_printable (gdb_wchar_t w)
{
return (gdb_iswprint (w)
|| w == LCST ('\a') || w == LCST ('\b')
|| w == LCST ('\f') || w == LCST ('\n')
|| w == LCST ('\r') || w == LCST ('\t')
|| w == LCST ('\v'));
}
/* A helper function that converts the contents of STRING to wide
characters and then appends them to OUTPUT. */
static void
append_string_as_wide (const char *string, struct obstack *output)
{
for (; *string; ++string)
{
gdb_wchar_t w = gdb_btowc (*string);
obstack_grow (output, &w, sizeof (gdb_wchar_t));
}
}
/* Print a wide character W to OUTPUT. ORIG is a pointer to the
original (target) bytes representing the character, ORIG_LEN is the
number of valid bytes. WIDTH is the number of bytes in a base
characters of the type. OUTPUT is an obstack to which wide
characters are emitted. QUOTER is a (narrow) character indicating
the style of quotes surrounding the character to be printed.
NEED_ESCAPE is an in/out flag which is used to track numeric
escapes across calls. */
static void
print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
int width, struct obstack *output, int quoter,
int *need_escapep)
{
int need_escape = *need_escapep;
*need_escapep = 0;
if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
&& w != LCST ('8')
&& w != LCST ('9'))))
{
if (w == gdb_btowc (quoter) || w == LCST ('\\'))
obstack_grow_wstr (output, LCST ("\\"));
obstack_grow (output, &w, sizeof (gdb_wchar_t));
}
else
{
switch (w)
{
case LCST ('\a'):
obstack_grow_wstr (output, LCST ("\\a"));
break;
case LCST ('\b'):
obstack_grow_wstr (output, LCST ("\\b"));
break;
case LCST ('\f'):
obstack_grow_wstr (output, LCST ("\\f"));
break;
case LCST ('\n'):
obstack_grow_wstr (output, LCST ("\\n"));
break;
case LCST ('\r'):
obstack_grow_wstr (output, LCST ("\\r"));
break;
case LCST ('\t'):
obstack_grow_wstr (output, LCST ("\\t"));
break;
case LCST ('\v'):
obstack_grow_wstr (output, LCST ("\\v"));
break;
default:
{
int i;
for (i = 0; i + width <= orig_len; i += width)
{
char octal[30];
ULONGEST value = extract_unsigned_integer (&orig[i], width);
sprintf (octal, "\\%lo", (long) value);
append_string_as_wide (octal, output);
}
/* If we somehow have extra bytes, print them now. */
while (i < orig_len)
{
char octal[5];
sprintf (octal, "\\%.3o", orig[i] & 0xff);
append_string_as_wide (octal, output);
++i;
}
*need_escapep = 1;
}
break;
}
}
}
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
characters and strings is language specific. */
static void
c_emit_char (int c, struct ui_file *stream, int quoter)
c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
const char *escape;
int host_char;
struct obstack wchar_buf, output;
struct cleanup *cleanups;
const char *encoding;
gdb_byte *buf;
struct wchar_iterator *iter;
int need_escape = 0;
c &= 0xFF; /* Avoid sign bit follies */
classify_type (type, &encoding);
escape = c_target_char_has_backslash_escape (c);
if (escape)
buf = alloca (TYPE_LENGTH (type));
pack_long (buf, type, c);
iter = make_wchar_iterator (buf, TYPE_LENGTH (type), encoding,
TYPE_LENGTH (type));
cleanups = make_cleanup_wchar_iterator (iter);
/* This holds the printable form of the wchar_t data. */
obstack_init (&wchar_buf);
make_cleanup_obstack_free (&wchar_buf);
while (1)
{
if (quoter == '"' && strcmp (escape, "0") == 0)
/* Print nulls embedded in double quoted strings as \000 to
prevent ambiguity. */
fprintf_filtered (stream, "\\000");
else
fprintf_filtered (stream, "\\%s", escape);
int num_chars;
gdb_wchar_t *chars;
const gdb_byte *buf;
size_t buflen;
int print_escape = 1;
enum wchar_iterate_result result;
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
if (num_chars < 0)
break;
if (num_chars > 0)
{
/* If all characters are printable, print them. Otherwise,
we're going to have to print an escape sequence. We
check all characters because we want to print the target
bytes in the escape sequence, and we don't know character
boundaries there. */
int i;
print_escape = 0;
for (i = 0; i < num_chars; ++i)
if (!wchar_printable (chars[i]))
{
print_escape = 1;
break;
}
if (!print_escape)
{
for (i = 0; i < num_chars; ++i)
print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
&wchar_buf, quoter, &need_escape);
}
}
/* This handles the NUM_CHARS == 0 case as well. */
if (print_escape)
print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), &wchar_buf,
quoter, &need_escape);
}
else if (target_char_to_host (c, &host_char)
&& host_char_print_literally (host_char))
{
if (host_char == '\\' || host_char == quoter)
fputs_filtered ("\\", stream);
fprintf_filtered (stream, "%c", host_char);
}
else
fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
/* The output in the host encoding. */
obstack_init (&output);
make_cleanup_obstack_free (&output);
convert_between_encodings ("wchar_t", host_charset (),
obstack_base (&wchar_buf),
obstack_object_size (&wchar_buf),
1, &output, translit_char);
obstack_1grow (&output, '\0');
fputs_filtered (obstack_base (&output), stream);
do_cleanups (cleanups);
}
void
c_printchar (int c, struct ui_file *stream)
c_printchar (int c, struct type *type, struct ui_file *stream)
{
enum c_string_type str_type;
const char *encoding;
str_type = classify_type (type, &encoding);
switch (str_type)
{
case C_CHAR:
break;
case C_WIDE_CHAR:
fputc_filtered ('L', stream);
break;
case C_CHAR_16:
fputc_filtered ('u', stream);
break;
case C_CHAR_32:
fputc_filtered ('U', stream);
break;
}
fputc_filtered ('\'', stream);
LA_EMIT_CHAR (c, stream, '\'');
LA_EMIT_CHAR (c, type, stream, '\'');
fputc_filtered ('\'', stream);
}
@ -85,87 +341,208 @@ c_printchar (int c, struct ui_file *stream)
printing LENGTH characters, or if FORCE_ELLIPSES. */
void
c_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
int width = TYPE_LENGTH (type);
struct obstack wchar_buf, output;
struct cleanup *cleanup;
enum c_string_type str_type;
const char *encoding;
struct wchar_iterator *iter;
int finished = 0;
int need_escape = 0;
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
style. */
if (!force_ellipses
&& length > 0
&& (extract_unsigned_integer (string + (length - 1) * width, width)
== '\0'))
&& (extract_unsigned_integer (string + (length - 1) * width, width) == 0))
length--;
str_type = classify_type (type, &encoding) & ~C_CHAR;
switch (str_type)
{
case C_STRING:
break;
case C_WIDE_STRING:
fputs_filtered ("L", stream);
break;
case C_STRING_16:
fputs_filtered ("u", stream);
break;
case C_STRING_32:
fputs_filtered ("U", stream);
break;
}
if (length == 0)
{
fputs_filtered ("\"\"", stream);
return;
}
for (i = 0; i < length && things_printed < options->print_max; ++i)
if (length == -1)
{
/* Position of the character we are examining
to see whether it is repeated. */
unsigned int rep1;
/* Number of repetitions we have detected so far. */
unsigned int reps;
unsigned long current_char;
unsigned long current_char = 1;
for (i = 0; current_char; ++i)
{
QUIT;
current_char = extract_unsigned_integer (string + i * width, width);
}
length = i;
}
/* Arrange to iterate over the characters, in wchar_t form. */
iter = make_wchar_iterator (string, length * width, encoding, width);
cleanup = make_cleanup_wchar_iterator (iter);
/* WCHAR_BUF is the obstack we use to represent the string in
wchar_t form. */
obstack_init (&wchar_buf);
make_cleanup_obstack_free (&wchar_buf);
while (!finished && things_printed < options->print_max)
{
int num_chars;
enum wchar_iterate_result result;
gdb_wchar_t *chars;
const gdb_byte *buf;
size_t buflen;
QUIT;
if (need_comma)
{
fputs_filtered (", ", stream);
obstack_grow_wstr (&wchar_buf, LCST (", "));
need_comma = 0;
}
current_char = extract_unsigned_integer (string + i * width, width);
rep1 = i + 1;
reps = 1;
while (rep1 < length
&& extract_unsigned_integer (string + rep1 * width, width)
== current_char)
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
/* We only look at repetitions when we were able to convert a
single character in isolation. This makes the code simpler
and probably does the sensible thing in the majority of
cases. */
while (num_chars == 1)
{
++rep1;
++reps;
}
/* Count the number of repetitions. */
unsigned int reps = 0;
gdb_wchar_t current_char = chars[0];
const gdb_byte *orig_buf = buf;
int orig_len = buflen;
if (reps > options->repeat_count_threshold)
{
if (in_quotes)
if (need_comma)
{
if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
in_quotes = 0;
obstack_grow_wstr (&wchar_buf, LCST (", "));
need_comma = 0;
}
while (num_chars == 1 && current_char == chars[0])
{
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
++reps;
}
/* Emit CURRENT_CHAR according to the repetition count and
options. */
if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
if (options->inspect_it)
obstack_grow_wstr (&wchar_buf, LCST ("\\\", "));
else
obstack_grow_wstr (&wchar_buf, LCST ("\", "));
in_quotes = 0;
}
obstack_grow_wstr (&wchar_buf, LCST ("'"));
need_escape = 0;
print_wchar (current_char, orig_buf, orig_len, width,
&wchar_buf, '\'', &need_escape);
obstack_grow_wstr (&wchar_buf, LCST ("'"));
{
/* Painful gyrations. */
int j;
char *s = xstrprintf (_(" <repeats %u times>"), reps);
for (j = 0; s[j]; ++j)
{
gdb_wchar_t w = gdb_btowc (s[j]);
obstack_grow (&wchar_buf, &w, sizeof (gdb_wchar_t));
}
xfree (s);
}
things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
/* Saw the character one or more times, but fewer than
the repetition threshold. */
if (!in_quotes)
{
if (options->inspect_it)
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
else
obstack_grow_wstr (&wchar_buf, LCST ("\""));
in_quotes = 1;
need_escape = 0;
}
while (reps-- > 0)
{
print_wchar (current_char, orig_buf, orig_len, width,
&wchar_buf, '"', &need_escape);
++things_printed;
}
}
LA_PRINT_CHAR (current_char, stream);
fprintf_filtered (stream, _(" <repeats %u times>"), reps);
i = rep1 - 1;
things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
/* NUM_CHARS and the other outputs from wchar_iterate are valid
here regardless of which branch was taken above. */
if (num_chars < 0)
{
/* Hit EOF. */
finished = 1;
break;
}
switch (result)
{
case wchar_iterate_invalid:
if (!in_quotes)
{
if (options->inspect_it)
fputs_filtered ("\\\"", stream);
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
else
fputs_filtered ("\"", stream);
obstack_grow_wstr (&wchar_buf, LCST ("\""));
in_quotes = 1;
}
LA_EMIT_CHAR (current_char, stream, '"');
++things_printed;
need_escape = 0;
print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
'"', &need_escape);
break;
case wchar_iterate_incomplete:
if (in_quotes)
{
if (options->inspect_it)
obstack_grow_wstr (&wchar_buf, LCST ("\\\","));
else
obstack_grow_wstr (&wchar_buf, LCST ("\","));
in_quotes = 0;
}
obstack_grow_wstr (&wchar_buf, LCST (" <incomplete sequence "));
print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
0, &need_escape);
obstack_grow_wstr (&wchar_buf, LCST (">"));
finished = 1;
break;
}
}
@ -173,13 +550,27 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
if (in_quotes)
{
if (options->inspect_it)
fputs_filtered ("\\\"", stream);
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
else
fputs_filtered ("\"", stream);
obstack_grow_wstr (&wchar_buf, LCST ("\""));
}
if (force_ellipses || i < length)
fputs_filtered ("...", stream);
if (force_ellipses || !finished)
obstack_grow_wstr (&wchar_buf, LCST ("..."));
/* OUTPUT is where we collect `char's for printing. */
obstack_init (&output);
make_cleanup_obstack_free (&output);
convert_between_encodings ("wchar_t", host_charset (),
obstack_base (&wchar_buf),
obstack_object_size (&wchar_buf),
1, &output, translit_char);
obstack_1grow (&output, '\0');
fputs_filtered (obstack_base (&output), stream);
do_cleanups (cleanup);
}
/* Obtain a C string from the inferior storing it in a newly allocated
@ -298,7 +689,285 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
}
/* Preprocessing and parsing C and C++ expressions. */
/* Evaluating C and C++ expressions. */
/* Convert a UCN. The digits of the UCN start at P and extend no
farther than LIMIT. DEST_CHARSET is the name of the character set
into which the UCN should be converted. The results are written to
OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
Returns a pointer to just after the final digit of the UCN. */
static char *
convert_ucn (char *p, char *limit, const char *dest_charset,
struct obstack *output, int length)
{
unsigned long result = 0;
gdb_byte data[4];
int i;
for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
result = (result << 4) + host_hex_value (*p);
for (i = 3; i >= 0; --i)
{
data[i] = result & 0xff;
result >>= 8;
}
convert_between_encodings ("UCS-4BE", dest_charset, data, 4, 4, output,
translit_none);
return p;
}
/* Emit a character, VALUE, which was specified numerically, to
OUTPUT. TYPE is the target character type. */
static void
emit_numeric_character (struct type *type, unsigned long value,
struct obstack *output)
{
gdb_byte *buffer;
buffer = alloca (TYPE_LENGTH (type));
pack_long (buffer, type, value);
obstack_grow (output, buffer, TYPE_LENGTH (type));
}
/* Convert an octal escape sequence. TYPE is the target character
type. The digits of the escape sequence begin at P and extend no
farther than LIMIT. The result is written to OUTPUT. Returns a
pointer to just after the final digit of the escape sequence. */
static char *
convert_octal (struct type *type, char *p, char *limit, struct obstack *output)
{
unsigned long value = 0;
while (p < limit && isdigit (*p) && *p != '8' && *p != '9')
{
value = 8 * value + host_hex_value (*p);
++p;
}
emit_numeric_character (type, value, output);
return p;
}
/* Convert a hex escape sequence. TYPE is the target character type.
The digits of the escape sequence begin at P and extend no farther
than LIMIT. The result is written to OUTPUT. Returns a pointer to
just after the final digit of the escape sequence. */
static char *
convert_hex (struct type *type, char *p, char *limit, struct obstack *output)
{
unsigned long value = 0;
while (p < limit && isxdigit (*p))
{
value = 16 * value + host_hex_value (*p);
++p;
}
emit_numeric_character (type, value, output);
return p;
}
#define ADVANCE \
do { \
++p; \
if (p == limit) \
error (_("Malformed escape sequence")); \
} while (0)
/* Convert an escape sequence to a target format. TYPE is the target
character type to use, and DEST_CHARSET is the name of the target
character set. The backslash of the escape sequence is at *P, and
the escape sequence will not extend past LIMIT. The results are
written to OUTPUT. Returns a pointer to just past the final
character of the escape sequence. */
static char *
convert_escape (struct type *type, const char *dest_charset,
char *p, char *limit, struct obstack *output)
{
/* Skip the backslash. */
ADVANCE;
switch (*p)
{
case '\\':
obstack_1grow (output, '\\');
++p;
break;
case 'x':
ADVANCE;
if (!isxdigit (*p))
error (_("\\x used with no following hex digits."));
p = convert_hex (type, p, limit, output);
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
p = convert_octal (type, p, limit, output);
break;
case 'u':
case 'U':
{
int length = *p == 'u' ? 4 : 8;
ADVANCE;
if (!isxdigit (*p))
error (_("\\u used with no following hex digits"));
p = convert_ucn (p, limit, dest_charset, output, length);
}
}
return p;
}
/* Given a single string from a (C-specific) OP_STRING list, convert
it to a target string, handling escape sequences specially. The
output is written to OUTPUT. DATA is the input string, which has
length LEN. DEST_CHARSET is the name of the target character set,
and TYPE is the type of target character to use. */
static void
parse_one_string (struct obstack *output, char *data, int len,
const char *dest_charset, struct type *type)
{
char *limit;
limit = data + len;
while (data < limit)
{
char *p = data;
/* Look for next escape, or the end of the input. */
while (p < limit && *p != '\\')
++p;
/* If we saw a run of characters, convert them all. */
if (p > data)
convert_between_encodings (host_charset (), dest_charset,
data, p - data, 1, output, translit_none);
/* If we saw an escape, convert it. */
if (p < limit)
p = convert_escape (type, dest_charset, p, limit, output);
data = p;
}
}
/* Expression evaluator for the C language family. Most operations
are delegated to evaluate_subexp_standard; see that function for a
description of the arguments. */
static struct value *
evaluate_subexp_c (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
{
enum exp_opcode op = exp->elts[*pos].opcode;
switch (op)
{
case OP_STRING:
{
int oplen, limit;
struct type *type;
struct obstack output;
struct cleanup *cleanup;
struct value *result;
enum c_string_type dest_type;
const char *dest_charset;
obstack_init (&output);
cleanup = make_cleanup_obstack_free (&output);
++*pos;
oplen = longest_to_int (exp->elts[*pos].longconst);
++*pos;
limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
dest_type
= (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
switch (dest_type & ~C_CHAR)
{
case C_STRING:
type = language_string_char_type (current_language,
current_gdbarch);
break;
case C_WIDE_STRING:
type = lookup_typename ("wchar_t", NULL, 0);
break;
case C_STRING_16:
type = lookup_typename ("char16_t", NULL, 0);
break;
case C_STRING_32:
type = lookup_typename ("char32_t", NULL, 0);
break;
default:
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
}
dest_charset = charset_for_string_type (dest_type);
++*pos;
while (*pos < limit)
{
int len;
len = longest_to_int (exp->elts[*pos].longconst);
++*pos;
if (noside != EVAL_SKIP)
parse_one_string (&output, &exp->elts[*pos].string, len,
dest_charset, type);
*pos += BYTES_TO_EXP_ELEM (len);
}
/* Skip the trailing length and opcode. */
*pos += 2;
if (noside == EVAL_SKIP)
return NULL;
if ((dest_type & C_CHAR) != 0)
{
LONGEST value;
if (obstack_object_size (&output) != TYPE_LENGTH (type))
error (_("Could not convert character constant to target character set"));
value = unpack_long (type, obstack_base (&output));
result = value_from_longest (type, value);
}
else
{
int i;
/* Write the terminating character. */
for (i = 0; i < TYPE_LENGTH (type); ++i)
obstack_1grow (&output, 0);
result = value_typed_string (obstack_base (&output),
obstack_object_size (&output),
type);
}
do_cleanups (cleanup);
return result;
}
break;
default:
break;
}
return evaluate_subexp_standard (expect_type, exp, pos, noside);
}
@ -396,6 +1065,15 @@ c_language_arch_info (struct gdbarch *gdbarch,
lai->bool_type_default = builtin->builtin_int;
}
static const struct exp_descriptor exp_descriptor_c =
{
print_subexp_standard,
operator_length_standard,
op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_c
};
const struct language_defn c_language_defn =
{
"c", /* Language name */
@ -405,7 +1083,7 @@ const struct language_defn c_language_defn =
case_sensitive_on,
array_row_major,
macro_expansion_c,
&exp_descriptor_standard,
&exp_descriptor_c,
c_parse,
c_error,
null_post_parser,
@ -524,7 +1202,7 @@ const struct language_defn cplus_language_defn =
case_sensitive_on,
array_row_major,
macro_expansion_c,
&exp_descriptor_standard,
&exp_descriptor_c,
c_parse,
c_error,
null_post_parser,
@ -562,7 +1240,7 @@ const struct language_defn asm_language_defn =
case_sensitive_on,
array_row_major,
macro_expansion_c,
&exp_descriptor_standard,
&exp_descriptor_c,
c_parse,
c_error,
null_post_parser,
@ -605,7 +1283,7 @@ const struct language_defn minimal_language_defn =
case_sensitive_on,
array_row_major,
macro_expansion_c,
&exp_descriptor_standard,
&exp_descriptor_c,
c_parse,
c_error,
null_post_parser,

View File

@ -29,9 +29,38 @@ struct language_arch_info;
#include "macroexp.h"
extern int c_parse (void); /* Defined in c-exp.y */
/* The various kinds of C string and character. Note that these
values are chosen so that they may be or'd together in certain
ways. */
enum c_string_type
{
/* An ordinary string: "value". */
C_STRING = 0,
/* A wide string: L"value". */
C_WIDE_STRING = 1,
/* A 16-bit Unicode string: u"value". */
C_STRING_16 = 2,
/* A 32-bit Unicode string: U"value". */
C_STRING_32 = 3,
/* An ordinary char: 'v'. This can also be or'd with one of the
above to form the corresponding CHAR value from a STRING
value. */
C_CHAR = 4,
/* A wide char: L'v'. */
C_WIDE_CHAR = 5,
/* A 16-bit Unicode char: u'v'. */
C_CHAR_16 = 6,
/* A 32-bit Unicode char: U'v'. */
C_CHAR_32 = 7
};
extern void c_error (char *); /* Defined in c-exp.y */
/* Defined in c-exp.y. */
extern int c_parse (void);
extern void c_error (char *);
extern int c_parse_escape (char **, struct obstack *);
/* Defined in c-typeprint.c */
extern void c_print_type (struct type *, char *, struct ui_file *, int,
@ -48,10 +77,10 @@ extern int c_value_print (struct value *, struct ui_file *,
/* These are in c-lang.c: */
extern void c_printchar (int, struct ui_file *);
extern void c_printchar (int, struct type *, struct ui_file *);
extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
unsigned int length, int width,
extern void c_printstr (struct ui_file * stream, struct type *elttype,
const gdb_byte *string, unsigned int length,
int force_ellipses,
const struct value_print_options *options);

View File

@ -55,6 +55,18 @@ print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
}
/* A helper for textual_element_type. This checks the name of the
typedef. This is bogus but it isn't apparent that the compiler
provides us the help we may need. */
static int
textual_name (const char *name)
{
return (!strcmp (name, "wchar_t")
|| !strcmp (name, "char16_t")
|| !strcmp (name, "char32_t"));
}
/* Apply a heuristic to decide whether an array of TYPE or a pointer
to TYPE should be printed as a textual string. Return non-zero if
it should, or zero if it should be treated as an array of integers
@ -77,6 +89,15 @@ textual_element_type (struct type *type, char format)
/* TYPE_CODE_CHAR is always textual. */
if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
return 1;
/* Any other character-like types must be integral. */
if (TYPE_CODE (true_type) != TYPE_CODE_INT)
return 0;
/* Check the names of the type and the typedef. */
if (TYPE_NAME (type) && textual_name (TYPE_NAME (type)))
return 1;
if (TYPE_NAME (true_type) && textual_name (TYPE_NAME (true_type)))
return 1;
if (format == 's')
{
@ -115,7 +136,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
{
unsigned int i = 0; /* Number of characters printed */
unsigned len;
struct type *elttype;
struct type *elttype, *unresolved_elttype;
struct type *unresolved_type = type;
unsigned eltlen;
LONGEST val;
CORE_ADDR addr;
@ -124,8 +146,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
unresolved_elttype = TYPE_TARGET_TYPE (type);
elttype = check_typedef (unresolved_elttype);
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
{
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
@ -135,7 +158,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
/* Print arrays of textual chars with a string syntax. */
if (textual_element_type (elttype, options->format))
if (textual_element_type (unresolved_elttype, options->format))
{
/* If requested, look for the first null char and only print
elements up to it. */
@ -143,15 +166,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
{
unsigned int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(valaddr + embedded_offset)[temp_len]
&& temp_len < len && temp_len < options->print_max;
temp_len++);
(temp_len < len
&& temp_len < options->print_max
&& extract_unsigned_integer (valaddr + embedded_offset
+ temp_len * eltlen,
eltlen) == 0);
++temp_len)
;
len = temp_len;
}
LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
LA_PRINT_STRING (stream, unresolved_elttype,
valaddr + embedded_offset, len, 0, options);
i = len;
}
else
@ -209,7 +236,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
print_function_pointer_address (addr, stream, options->addressprint);
break;
}
elttype = check_typedef (TYPE_TARGET_TYPE (type));
unresolved_elttype = TYPE_TARGET_TYPE (type);
elttype = check_typedef (unresolved_elttype);
{
addr = unpack_pointer (type, valaddr + embedded_offset);
print_unpacked_pointer:
@ -228,12 +256,11 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
/* For a pointer to a textual type, also print the string
pointed to, unless pointer is null. */
/* FIXME: need to handle wchar_t here... */
if (textual_element_type (elttype, options->format)
if (textual_element_type (unresolved_elttype, options->format)
&& addr != 0)
{
i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
i = val_print_string (unresolved_elttype, addr, -1, stream,
options);
}
else if (cp_is_vtbl_member (type))
@ -268,7 +295,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
else
{
wtype = TYPE_TARGET_TYPE (type);
wtype = unresolved_elttype;
}
vt_val = value_at (wtype, vt_address);
common_val_print (vt_val, stream, recurse + 1, options,
@ -442,11 +469,11 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
Since we don't know whether the value is really intended to
be used as an integer or a character, print the character
equivalent as well. */
if (textual_element_type (type, options->format))
if (textual_element_type (unresolved_type, options->format))
{
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
stream);
unresolved_type, stream);
}
}
break;
@ -468,7 +495,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
else
fprintf_filtered (stream, "%d", (int) val);
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) val, stream);
LA_PRINT_CHAR ((unsigned char) val, unresolved_type, stream);
}
break;
@ -540,7 +567,7 @@ int
c_value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options)
{
struct type *type, *real_type;
struct type *type, *real_type, *val_type;
int full, top, using_enc;
struct value_print_options opts = *options;
@ -553,7 +580,11 @@ c_value_print (struct value *val, struct ui_file *stream,
C++: if it is a member pointer, we will take care
of that when we print it. */
type = check_typedef (value_type (val));
/* Preserve the original type before stripping typedefs. We prefer
to pass down the original type when possible, but for local
checks it is better to look past the typedefs. */
val_type = value_type (val);
type = check_typedef (val_type);
if (TYPE_CODE (type) == TYPE_CODE_PTR
|| TYPE_CODE (type) == TYPE_CODE_REF)
@ -561,11 +592,12 @@ c_value_print (struct value *val, struct ui_file *stream,
/* Hack: remove (char *) for char strings. Their
type is indicated by the quoted string anyway.
(Don't use textual_element_type here; quoted strings
are always exactly (char *). */
if (TYPE_CODE (type) == TYPE_CODE_PTR
&& TYPE_NAME (type) == NULL
&& TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
&& strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
are always exactly (char *), (wchar_t *), or the like. */
if (TYPE_CODE (val_type) == TYPE_CODE_PTR
&& TYPE_NAME (val_type) == NULL
&& TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL
&& (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)), "char") == 0
|| textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
{
/* Print nothing */
}
@ -608,6 +640,7 @@ c_value_print (struct value *val, struct ui_file *stream,
}
type_print (type, "", stream, -1);
fprintf_filtered (stream, ") ");
val_type = type;
}
else
{
@ -653,7 +686,7 @@ c_value_print (struct value *val, struct ui_file *stream,
/* Otherwise, we end up at the return outside this "if" */
}
return val_print (type, value_contents_all (val),
return val_print (val_type, value_contents_all (val),
value_embedded_offset (val),
VALUE_ADDRESS (val) + value_offset (val),
stream, 0, &opts, current_language);

1190
gdb/charset-list.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,89 +19,129 @@
#ifndef CHARSET_H
#define CHARSET_H
/* If the target program uses a different character set than the host,
GDB has some support for translating between the two; GDB converts
characters and strings to the host character set before displaying
them, and converts characters and strings appearing in expressions
entered by the user to the target character set.
At the moment, GDB only supports single-byte, stateless character
sets. This includes the ISO-8859 family (ASCII extended with
accented characters, and (I think) Cyrillic, for European
languages), and the EBCDIC family (used on IBM's mainframes).
Unfortunately, it excludes many Asian scripts, the fixed- and
variable-width Unicode encodings, and other desireable things.
Patches are welcome! (For example, it would be nice if the Java
string support could simply get absorbed into some more general
multi-byte encoding support.)
Furthermore, GDB's code pretty much assumes that the host character
set is some superset of ASCII; there are plenty if ('0' + n)
expressions and the like.
When the `iconv' library routine supports a character set meeting
the requirements above, it's easy to plug an entry into GDB's table
that uses iconv to handle the details. */
GDB's code pretty much assumes that the host character set is some
superset of ASCII; there are plenty if ('0' + n) expressions and
the like. */
/* Return the name of the current host/target character set. The
result is owned by the charset module; the caller should not free
it. */
const char *host_charset (void);
const char *target_charset (void);
const char *target_wide_charset (void);
/* In general, the set of C backslash escapes (\n, \f) is specific to
the character set. Not all character sets will have form feed
characters, for example.
/* These values are used to specify the type of transliteration done
by convert_between_encodings. */
enum transliterations
{
/* Error on failure to convert. */
translit_none,
/* Transliterate to host char. */
translit_char
};
The following functions allow GDB to parse and print control
characters in a character-set-independent way. They are both
language-specific (to C and C++) and character-set-specific.
Putting them here is a compromise. */
/* Convert between two encodings.
FROM is the name of the source encoding.
TO is the name of the target encoding.
BYTES holds the bytes to convert; this is assumed to be characters
in the target encoding.
NUM_BYTES is the number of bytes.
WIDTH is the width of a character from the FROM charset, in bytes.
For a variable width encoding, WIDTH should be the size of a "base
character".
OUTPUT is an obstack where the converted data is written. The
caller is responsible for initializing the obstack, and for
destroying the obstack should an error occur.
TRANSLIT specifies how invalid conversions should be handled. */
void convert_between_encodings (const char *from, const char *to,
const gdb_byte *bytes, unsigned int num_bytes,
int width, struct obstack *output,
enum transliterations translit);
/* If the target character TARGET_CHAR have a backslash escape in the
C language (i.e., a character like 'n' or 't'), return the host
character string that should follow the backslash. Otherwise,
return zero.
/* These values are used by wchar_iterate to report errors. */
enum wchar_iterate_result
{
/* Ordinary return. */
wchar_iterate_ok,
/* Invalid input sequence. */
wchar_iterate_invalid,
/* Incomplete input sequence at the end of the input. */
wchar_iterate_incomplete,
/* EOF. */
wchar_iterate_eof
};
When this function returns non-zero, the string it returns is
statically allocated; the caller is not responsible for freeing it. */
const char *c_target_char_has_backslash_escape (int target_char);
/* Declaration of the opaque wchar iterator type. */
struct wchar_iterator;
/* Create a new character iterator which returns wchar_t's. INPUT is
the input buffer. BYTES is the number of bytes in the input
buffer. CHARSET is the name of the character set in which INPUT is
encoded. WIDTH is the number of bytes in a base character of
CHARSET.
This function either returns a new character set iterator, or calls
error. The result can be freed using a cleanup; see
make_cleanup_wchar_iterator. */
struct wchar_iterator *make_wchar_iterator (const gdb_byte *input, size_t bytes,
const char *charset,
size_t width);
/* If the host character HOST_CHAR is a valid backslash escape in the
C language for the target character set, return non-zero, and set
*TARGET_CHAR to the target character the backslash escape represents.
Otherwise, return zero. */
int c_parse_backslash (int host_char, int *target_char);
/* Return a new cleanup suitable for destroying the wchar iterator
ITER. */
struct cleanup *make_cleanup_wchar_iterator (struct wchar_iterator *iter);
/* Perform a single iteration of a wchar_t iterator.
Returns the number of characters converted. A negative result
means that EOF has been reached. A positive result indicates the
number of valid wchar_ts in the result; *OUT_CHARS is updated to
point to the first valid character.
/* Return non-zero if the host character HOST_CHAR can be printed
literally --- that is, if it can be readably printed as itself in a
character or string constant. Return zero if it should be printed
using some kind of numeric escape, like '\031' in C, '^(25)' in
Chill, or #25 in Pascal. */
int host_char_print_literally (int host_char);
In all cases aside from EOF, *PTR is set to point to the first
converted target byte. *LEN is set to the number of bytes
converted.
A zero result means one of several unusual results. *OUT_RESULT is
set to indicate the type of un-ordinary return.
/* If the host character HOST_CHAR has an equivalent in the target
character set, set *TARGET_CHAR to that equivalent, and return
non-zero. Otherwise, return zero. */
int host_char_to_target (int host_char, int *target_char);
wchar_iterate_invalid means that an invalid input character was
seen. The iterator is advanced by WIDTH (the argument to
make_wchar_iterator) bytes.
wchar_iterate_incomplete means that an incomplete character was
seen at the end of the input sequence.
wchar_iterate_eof means that all bytes were successfully
converted. The other output arguments are not set. */
int wchar_iterate (struct wchar_iterator *iter,
enum wchar_iterate_result *out_result,
gdb_wchar_t **out_chars,
const gdb_byte **ptr, size_t *len);
/* If the target character TARGET_CHAR has an equivalent in the host
character set, set *HOST_CHAR to that equivalent, and return
non-zero. Otherwise, return zero. */
int target_char_to_host (int target_char, int *host_char);
/* GDB needs to know a few details of its execution character set.
This knowledge is isolated here and in charset.c. */
/* If the target character TARGET_CHAR has a corresponding control
character (also in the target character set), set *TARGET_CTRL_CHAR
to the control character, and return non-zero. Otherwise, return
zero. */
int target_char_to_control_char (int target_char, int *target_ctrl_char);
/* The escape character. */
#define HOST_ESCAPE_CHAR 27
/* Convert a letter, like 'c', to its corresponding control
character. */
char host_letter_to_control_character (char c);
/* Convert a hex digit character to its numeric value. E.g., 'f' is
converted to 15. This function assumes that C is a valid hex
digit. Both upper- and lower-case letters are recognized. */
int host_hex_value (char c);
#endif /* CHARSET_H */

View File

@ -169,12 +169,18 @@
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the `iconvlist' function. */
#undef HAVE_ICONVLIST
/* Define if your compiler supports the #include_next directive. */
#undef HAVE_INCLUDE_NEXT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES

586
gdb/configure vendored
View File

@ -314,7 +314,7 @@ ac_subdirs_all="$ac_subdirs_all doc testsuite"
ac_subdirs_all="$ac_subdirs_all gdbtk"
ac_subdirs_all="$ac_subdirs_all multi-ice"
ac_subdirs_all="$ac_subdirs_all gdbserver"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags nm_h LIBICONV LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG LIBICONV LIBICONV_INCLUDE LIBICONV_LIBDIR READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags nm_h LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
ac_subst_files='host_makefile_frag'
ac_pwd=`pwd`
@ -885,6 +885,7 @@ Optional Packages:
--with-libunwind Use libunwind frame unwinding support
--with-pkgversion=PKG Use PKG in the version string in place of "GDB"
--with-bugurl=URL Direct users to URL to report a bug
--with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
--with-system-readline use installed readline library
--with-expat include expat support (auto/yes/no)
--with-gnu-ld assume the C compiler uses GNU ld default=no
@ -899,7 +900,6 @@ Optional Packages:
--with-tcl directory containing tcl configuration (tclConfig.sh)
--with-tk directory containing tk configuration (tkConfig.sh)
--with-x use the X Window System
--with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
Some influential environment variables:
CC C compiler command
@ -9989,6 +9989,296 @@ if test "$ac_cv_search_dlgetmodinfo" != no; then
fi
# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
if test "${with_libiconv_prefix+set}" = set; then
withval="$with_libiconv_prefix"
for dir in `echo "$withval" | tr : ' '`; do
if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; LDFLAGS="$LDFLAGS -L$dir/lib"; fi
done
fi;
BUILD_LIBICONV_LIBDIR="-L../libiconv/lib/.libs -L../libiconv/lib/_libs"
BUILD_LIBICONV_INCLUDE="-I../libiconv/include"
echo "$as_me:$LINENO: checking for iconv" >&5
echo $ECHO_N "checking for iconv... $ECHO_C" >&6
if test "${am_cv_func_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
am_cv_use_build_libiconv=no
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS -liconv"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_lib_iconv=yes
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS="$am_save_LIBS"
fi
# Look for libiconv in the build tree.
if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
am_save_LIBS="$LIBS"
am_save_CPPFLAGS="$CPPFLAGS"
LIBS="$LIBS $BUILD_LIBICONV_LIBDIR -liconv"
CPPFLAGS="$CPPFLAGS $BUILD_LIBICONV_INCLUDE"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_lib_iconv=yes
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS="$am_save_LIBS"
if test "$am_cv_func_iconv" = "yes"; then
am_cv_use_build_libiconv=yes
else
CPPFLAGS="$am_save_CPPFLAGS"
fi
fi
fi
echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
echo "${ECHO_T}$am_cv_func_iconv" >&6
if test "$am_cv_func_iconv" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ICONV 1
_ACEOF
echo "$as_me:$LINENO: checking for iconv declaration" >&5
echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
if test "${am_cv_proto_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_proto_iconv_arg1=""
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
am_cv_proto_iconv_arg1="const"
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
fi
am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
echo "$as_me:$LINENO: result: ${ac_t:-
}$am_cv_proto_iconv" >&5
echo "${ECHO_T}${ac_t:-
}$am_cv_proto_iconv" >&6
cat >>confdefs.h <<_ACEOF
#define ICONV_CONST $am_cv_proto_iconv_arg1
_ACEOF
fi
LIBICONV=
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
fi
if test "$am_cv_use_build_libiconv" = yes; then
LIBICONV_LIBDIR="$BUILD_LIBICONV_LIBDIR"
LIBICONV_INCLUDE="$BUILD_LIBICONV_INCLUDE"
fi
# On alpha-osf, it appears that libtermcap and libcurses are not compatible.
# There is a very specific comment in /usr/include/curses.h explaining that
# termcap routines built into libcurses must not be used.
@ -15444,11 +15734,12 @@ fi
for ac_func in canonicalize_file_name realpath getrusage getuid \
getgid poll pread64 sbrk setpgid setpgrp setsid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder setlocale
ttrace wborder setlocale iconvlist
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@ -15550,6 +15841,70 @@ fi
done
echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5
echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
if test "${am_cv_langinfo_codeset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <langinfo.h>
int
main ()
{
char* cs = nl_langinfo(CODESET);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_langinfo_codeset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
am_cv_langinfo_codeset=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5
echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
if test $am_cv_langinfo_codeset = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_LANGINFO_CODESET 1
_ACEOF
fi
# Check the return and argument types of ptrace. No canned test for
# this, so roll our own.
gdb_ptrace_headers='
@ -20776,230 +21131,11 @@ done
cat >>confdefs.h <<\_ACEOF
#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
#define GDB_DEFAULT_HOST_CHARSET "UTF-8"
_ACEOF
# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
if test "${with_libiconv_prefix+set}" = set; then
withval="$with_libiconv_prefix"
for dir in `echo "$withval" | tr : ' '`; do
if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
done
fi;
echo "$as_me:$LINENO: checking for iconv" >&5
echo $ECHO_N "checking for iconv... $ECHO_C" >&6
if test "${am_cv_func_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS -liconv"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_lib_iconv=yes
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS="$am_save_LIBS"
fi
fi
echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
echo "${ECHO_T}$am_cv_func_iconv" >&6
if test "$am_cv_func_iconv" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ICONV 1
_ACEOF
echo "$as_me:$LINENO: checking for iconv declaration" >&5
echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
if test "${am_cv_proto_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_proto_iconv_arg1=""
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
am_cv_proto_iconv_arg1="const"
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
fi
am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
echo "$as_me:$LINENO: result: ${ac_t:-
}$am_cv_proto_iconv" >&5
echo "${ECHO_T}${ac_t:-
}$am_cv_proto_iconv" >&6
cat >>confdefs.h <<_ACEOF
#define ICONV_CONST $am_cv_proto_iconv_arg1
_ACEOF
fi
LIBICONV=
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
fi
ac_config_files="$ac_config_files Makefile .gdbinit:gdbinit.in gnulib/Makefile"
ac_config_commands="$ac_config_commands default"
cat >confcache <<\_ACEOF
@ -21880,6 +22016,9 @@ s,@WINDRES@,$WINDRES,;t t
s,@ac_ct_WINDRES@,$ac_ct_WINDRES,;t t
s,@MIG@,$MIG,;t t
s,@ac_ct_MIG@,$ac_ct_MIG,;t t
s,@LIBICONV@,$LIBICONV,;t t
s,@LIBICONV_INCLUDE@,$LIBICONV_INCLUDE,;t t
s,@LIBICONV_LIBDIR@,$LIBICONV_LIBDIR,;t t
s,@READLINE@,$READLINE,;t t
s,@READLINE_DEPS@,$READLINE_DEPS,;t t
s,@READLINE_CFLAGS@,$READLINE_CFLAGS,;t t
@ -21944,7 +22083,6 @@ s,@CONFIG_UNINSTALL@,$CONFIG_UNINSTALL,;t t
s,@target_subdir@,$target_subdir,;t t
s,@frags@,$frags,;t t
s,@nm_h@,$nm_h,;t t
s,@LIBICONV@,$LIBICONV,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
s,@gl_LIBOBJS@,$gl_LIBOBJS,;t t

View File

@ -1,6 +1,6 @@
dnl Autoconf configure script for GDB, the GNU debugger.
dnl Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
dnl 2005, 2006, 2007, 2008
dnl 2005, 2006, 2007, 2008, 2009
dnl Free Software Foundation, Inc.
dnl
dnl This file is part of GDB.
@ -430,6 +430,8 @@ AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
AM_ICONV
# On alpha-osf, it appears that libtermcap and libcurses are not compatible.
# There is a very specific comment in /usr/include/curses.h explaining that
# termcap routines built into libcurses must not be used.
@ -776,7 +778,8 @@ AC_FUNC_VFORK
AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid \
getgid poll pread64 sbrk setpgid setpgrp setsid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder setlocale])
ttrace wborder setlocale iconvlist])
AM_LANGINFO_CODESET
# Check the return and argument types of ptrace. No canned test for
# this, so roll our own.
@ -1930,17 +1933,10 @@ dnl Check for exe extension set on certain hosts (e.g. Win32)
AC_EXEEXT
dnl Detect the character set used by this host.
dnl At the moment, we just assume it's ISO-8859-1 (which is a
dnl superset of ASCII containing the characters needed for French,
dnl German, Spanish, Italian, and possibly others), but if were
dnl *were* to support any host character sets other than ISO-8859-1,
dnl here's where we'd detect it.
AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "ISO-8859-1",
dnl At the moment, we just assume it's UTF-8.
AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
[Define to be a string naming the default host character set.])
AM_ICONV
AC_OUTPUT(Makefile .gdbinit:gdbinit.in gnulib/Makefile,
[
dnl Autoconf doesn't provide a mechanism for modifying definitions

View File

@ -61,6 +61,8 @@
#include "gdb_locale.h"
#include "gdb_wchar.h"
/* For ``enum target_signal''. */
#include "gdb/signals.h"

View File

@ -1,3 +1,9 @@
2009-03-20 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-17 Hui Zhu <teawater@gmail.com>
* gdb.texinfo: Change the introduce of "disassemble-next-line".

View File

@ -7959,13 +7959,17 @@ support:
@table @code
@item set target-charset @var{charset}
@kindex set target-charset
Set the current target character set to @var{charset}. We list the
character set names @value{GDBN} recognizes below, but if you type
@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
list the target character sets it supports.
@end table
Set the current target character set to @var{charset}. If you type
@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN}
will list the target character sets it supports.
@item set target-wide-charset @var{charset}
@kindex set target-wide-charset
Set the current target wide character set to @var{charset}. The
target wide character set is the character set used by @code{wchar_t}.
If you type @code{set target-charset} followed by @key{TAB}@key{TAB},
@value{GDBN} will list the target character sets it supports.
@table @code
@item set host-charset @var{charset}
@kindex set host-charset
Set the current host character set to @var{charset}.
@ -7975,10 +7979,9 @@ system it is running on; you can override that default using the
@code{set host-charset} command.
@value{GDBN} can only use certain character sets as its host character
set. We list the character set names @value{GDBN} recognizes below, and
indicate which can be host character sets, but if you type
@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
list the host character sets it supports.
set. If you type @code{set target-charset} followed by
@key{TAB}@key{TAB}, @value{GDBN} will list the host character sets it
supports.
@item set charset @var{charset}
@kindex set charset
@ -8002,37 +8005,6 @@ Show the name of the current target charset.
@end table
@value{GDBN} currently includes support for the following character
sets:
@table @code
@item ASCII
@cindex ASCII character set
Seven-bit U.S. @sc{ascii}. @value{GDBN} can use this as its host
character set.
@item ISO-8859-1
@cindex ISO 8859-1 character set
@cindex ISO Latin 1 character set
The ISO Latin 1 character set. This extends @sc{ascii} with accented
characters needed for French, German, and Spanish. @value{GDBN} can use
this as its host character set.
@item EBCDIC-US
@itemx IBM1047
@cindex EBCDIC character set
@cindex IBM1047 character set
Variants of the @sc{ebcdic} character set, used on some of IBM's
mainframe operating systems. (@sc{gnu}/Linux on the S/390 uses U.S. @sc{ascii}.)
@value{GDBN} cannot use these as its host character set.
@end table
Note that these are all single-byte character sets. More work inside
@value{GDBN} is needed to support multi-byte or variable-width character
encodings, like the UTF-8 and UCS-2 encodings of Unicode.
Here is an example of @value{GDBN}'s character set support in action.
Assume that the following source code has been placed in the file
@file{charset-test.c}:
@ -24826,6 +24798,24 @@ The @samp{zlib} library is likely included with your operating system
distribution; if it is not, you can get the latest version from
@url{http://zlib.net}.
@item iconv
@value{GDBN}'s features related to character sets (@pxref{Character
Sets}) require a functioning @code{iconv} implementation. If you are
on a GNU system, then this is provided by the GNU C Library. Some
other systems also provide a working @code{iconv}.
On systems with @code{iconv}, you can install GNU Libiconv. If you
have previously installed Libiconv, you can use the
@option{--with-libiconv-prefix} option to configure.
@value{GDBN}'s top-level @file{configure} and @file{Makefile} will
arrange to build Libiconv if a directory named @file{libiconv} appears
in the top-most source directory. If Libiconv is built this way, and
if the operating system does not provide a suitable @code{iconv}
implementation, then the just-built library will automatically be used
by @value{GDBN}. One easy way to set this up is to download GNU
Libiconv, unpack it, and then rename the directory holding the
Libiconv source code to @samp{libiconv}.
@end table
@node Running Configure

View File

@ -186,8 +186,8 @@ print_subexp_standard (struct expression *exp, int *pos,
If necessary, we can temporarily set it to zero, or pass it as an
additional parameter to LA_PRINT_STRING. -fnf */
get_user_print_options (&opts);
LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
&opts);
LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
&exp->elts[pc + 2].string, nargs, 0, &opts);
}
return;
@ -205,8 +205,8 @@ print_subexp_standard (struct expression *exp, int *pos,
(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
fputs_filtered ("@\"", stream);
get_user_print_options (&opts);
LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
&opts);
LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
&exp->elts[pc + 2].string, nargs, 0, &opts);
fputs_filtered ("\"", stream);
}
return;
@ -291,8 +291,8 @@ print_subexp_standard (struct expression *exp, int *pos,
{
struct value_print_options opts;
get_user_print_options (&opts);
LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
&opts);
LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
tempstr, nargs - 1, 0, &opts);
(*pos) = pc;
}
else

View File

@ -70,8 +70,9 @@ static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void);
static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int);
#endif
static void f_printchar (int c, struct ui_file * stream);
static void f_emit_char (int c, struct ui_file * stream, int quoter);
static void f_printchar (int c, struct type *type, struct ui_file * stream);
static void f_emit_char (int c, struct type *type,
struct ui_file * stream, int quoter);
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
@ -80,7 +81,7 @@ static void f_emit_char (int c, struct ui_file * stream, int quoter);
be replaced with a true F77 version. */
static void
f_emit_char (int c, struct ui_file *stream, int quoter)
f_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
c &= 0xFF; /* Avoid sign bit follies */
@ -126,10 +127,10 @@ f_emit_char (int c, struct ui_file *stream, int quoter)
be replaced with a true F77version. */
static void
f_printchar (int c, struct ui_file *stream)
f_printchar (int c, struct type *type, struct ui_file *stream)
{
fputs_filtered ("'", stream);
LA_EMIT_CHAR (c, stream, '\'');
LA_EMIT_CHAR (c, type, stream, '\'');
fputs_filtered ("'", stream);
}
@ -141,14 +142,15 @@ f_printchar (int c, struct ui_file *stream)
be replaced with a true F77 version. */
static void
f_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
int width = TYPE_LENGTH (type);
if (length == 0)
{
@ -190,7 +192,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("', ", stream);
in_quotes = 0;
}
f_printchar (string[i], stream);
f_printchar (string[i], type, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += options->repeat_count_threshold;
@ -206,7 +208,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("'", stream);
in_quotes = 1;
}
LA_EMIT_CHAR (string[i], stream, '"');
LA_EMIT_CHAR (string[i], type, stream, '"');
++things_printed;
}
}

View File

@ -256,7 +256,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
{
case TYPE_CODE_STRING:
f77_get_dynamic_length_of_aggregate (type);
LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
LA_PRINT_STRING (stream, builtin_type (current_gdbarch)->builtin_char,
valaddr, TYPE_LENGTH (type), 0, options);
break;
case TYPE_CODE_ARRAY:
@ -293,7 +294,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (options->format == 0 || options->format == 's')
&& addr != 0)
i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
i = val_print_string (TYPE_TARGET_TYPE (type), addr, -1, stream,
options);
/* Return number of characters printed, including the terminating
@ -365,7 +366,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
{
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr),
stream);
type, stream);
}
}
break;

View File

@ -41,4 +41,8 @@
# define N_(String) (String)
#endif
#ifdef HAVE_LANGINFO_CODESET
#include <langinfo.h>
#endif
#endif /* GDB_LOCALE_H */

View File

@ -45,4 +45,7 @@
#define obstack_grow_str0(OBSTACK,STRING) \
obstack_grow0 (OBSTACK, STRING, strlen (STRING))
#define obstack_grow_wstr(OBSTACK, WSTRING) \
obstack_grow (OBSTACK, WSTRING, sizeof (gdb_wchar_t) * gdb_wcslen (WSTRING))
#endif

62
gdb/gdb_wchar.h Normal file
View File

@ -0,0 +1,62 @@
/* Wide characters for gdb
Copyright (C) 2009 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef GDB_WCHAR_H
#define GDB_WCHAR_H
/* If this host has wchar_t and if iconv is available (perhaps via GNU
libiconv), then we arrange to use those. Otherwise, we provide a
phony iconv which only handles a single character set, and we
provide wrappers for the wchar_t functionality we use. */
#if defined(HAVE_ICONV) && defined(HAVE_WCHAR_H)
#include <iconv.h>
#include <wchar.h>
#include <wctype.h>
typedef wchar_t gdb_wchar_t;
typedef wint_t gdb_wint_t;
#define gdb_wcslen wcslen
#define gdb_iswprint iswprint
#define gdb_iswdigit iswdigit
#define gdb_btowc btowc
#define gdb_WEOF WEOF
#define LCST(X) L ## X
#else
typedef char gdb_wchar_t;
typedef int gdb_wint_t;
#define gdb_wcslen strlen
#define gdb_iswprint isprint
#define gdb_iswdigit isdigit
#define gdb_btowc /* empty */
#define gdb_WEOF EOF
#define LCST(X) X
/* This define is used elsewhere so we don't need to duplicate the
same checking logic in multiple places. */
#define PHONY_ICONV
#endif /* defined(HAVE_ICONV) && defined(HAVE_WCHAR_H) */
#endif /* GDB_WCHAR_H */

View File

@ -61,7 +61,8 @@ static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
static int java_class_is_primitive (struct value *clas);
static struct value *java_value_string (char *ptr, int len);
static void java_emit_char (int c, struct ui_file * stream, int quoter);
static void java_emit_char (int c, struct type *type,
struct ui_file * stream, int quoter);
static char *java_class_name_from_physname (const char *physname);
@ -796,7 +797,7 @@ java_value_string (char *ptr, int len)
characters and strings is language specific. */
static void
java_emit_char (int c, struct ui_file *stream, int quoter)
java_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
switch (c)
{

View File

@ -230,7 +230,7 @@ java_value_print (struct value *val, struct ui_file *stream,
value_free_to_mark (mark); /* Release unnecessary values */
val_print_string (data + boffset, count, 2, stream, options);
val_print_string (java_char_type, data + boffset, count, stream, options);
return 0;
}
@ -520,7 +520,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
|| (TYPE_CODE (type) == TYPE_CODE_INT
&& TYPE_LENGTH (type) == 2
&& strcmp (TYPE_NAME (type), "char") == 0))
LA_PRINT_CHAR ((int) unpack_long (type, valaddr), stream);
LA_PRINT_CHAR ((int) unpack_long (type, valaddr), type, stream);
else
val_print_type_code_int (type, valaddr, stream);
break;

View File

@ -65,9 +65,11 @@ static void set_check (char *, int);
static void set_type_range_case (void);
static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
static void unk_lang_emit_char (int c, struct type *type,
struct ui_file *stream, int quoter);
static void unk_lang_printchar (int c, struct ui_file *stream);
static void unk_lang_printchar (int c, struct type *type,
struct ui_file *stream);
static void unk_lang_print_type (struct type *, char *, struct ui_file *,
int, int);
@ -1065,20 +1067,22 @@ unk_lang_error (char *msg)
}
static void
unk_lang_emit_char (int c, struct ui_file *stream, int quoter)
unk_lang_emit_char (int c, struct type *type, struct ui_file *stream,
int quoter)
{
error (_("internal error - unimplemented function unk_lang_emit_char called."));
}
static void
unk_lang_printchar (int c, struct ui_file *stream)
unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
{
error (_("internal error - unimplemented function unk_lang_printchar called."));
}
static void
unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
unk_lang_printstr (struct ui_file *stream, struct type *type,
const gdb_byte *string, unsigned int length,
int force_ellipses,
const struct value_print_options *options)
{
error (_("internal error - unimplemented function unk_lang_printstr called."));

View File

@ -186,14 +186,15 @@ struct language_defn
void (*la_post_parser) (struct expression ** expp, int void_context_p);
void (*la_printchar) (int ch, struct ui_file * stream);
void (*la_printchar) (int ch, struct type *chtype, struct ui_file * stream);
void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
unsigned int length, int width,
void (*la_printstr) (struct ui_file * stream, struct type *elttype,
const gdb_byte *string, unsigned int length,
int force_ellipses,
const struct value_print_options *);
void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
void (*la_emitchar) (int ch, struct type *chtype,
struct ui_file * stream, int quoter);
/* Print a type using syntax appropriate for this language. */
@ -381,13 +382,13 @@ extern enum language set_language (enum language);
#define LA_VALUE_PRINT(val,stream,options) \
(current_language->la_value_print(val,stream,options))
#define LA_PRINT_CHAR(ch, stream) \
(current_language->la_printchar(ch, stream))
#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
(current_language->la_printstr(stream, string, length, width, \
#define LA_PRINT_CHAR(ch, type, stream) \
(current_language->la_printchar(ch, type, stream))
#define LA_PRINT_STRING(stream, elttype, string, length, force_ellipses,options) \
(current_language->la_printstr(stream, elttype, string, length, \
force_ellipses,options))
#define LA_EMIT_CHAR(ch, stream, quoter) \
(current_language->la_emitchar(ch, stream, quoter))
#define LA_EMIT_CHAR(ch, type, stream, quoter) \
(current_language->la_emitchar(ch, type, stream, quoter))
#define LA_GET_STRING(value, buffer, length, encoding) \
(current_language->la_get_string(value, buffer, length, encoding))

View File

@ -29,8 +29,8 @@
#include "valprint.h"
extern void _initialize_m2_language (void);
static void m2_printchar (int, struct ui_file *);
static void m2_emit_char (int, struct ui_file *, int);
static void m2_printchar (int, struct type *, struct ui_file *);
static void m2_emit_char (int, struct type *, struct ui_file *, int);
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
@ -39,7 +39,7 @@ static void m2_emit_char (int, struct ui_file *, int);
be replaced with a true Modula version. */
static void
m2_emit_char (int c, struct ui_file *stream, int quoter)
m2_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
c &= 0xFF; /* Avoid sign bit follies */
@ -88,10 +88,10 @@ m2_emit_char (int c, struct ui_file *stream, int quoter)
be replaced with a true Modula version. */
static void
m2_printchar (int c, struct ui_file *stream)
m2_printchar (int c, struct type *type, struct ui_file *stream)
{
fputs_filtered ("'", stream);
LA_EMIT_CHAR (c, stream, '\'');
LA_EMIT_CHAR (c, type, stream, '\'');
fputs_filtered ("'", stream);
}
@ -103,14 +103,15 @@ m2_printchar (int c, struct ui_file *stream)
be replaced with a true Modula version. */
static void
m2_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
int width = TYPE_LENGTH (type);
if (length == 0)
{
@ -152,7 +153,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("\", ", stream);
in_quotes = 0;
}
m2_printchar (string[i], stream);
m2_printchar (string[i], type, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += options->repeat_count_threshold;
@ -168,7 +169,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("\"", stream);
in_quotes = 1;
}
LA_EMIT_CHAR (string[i], stream, '"');
LA_EMIT_CHAR (string[i], type, stream, '"');
++things_printed;
}
}

View File

@ -237,7 +237,8 @@ print_unpacked_pointer (struct type *type,
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (options->format == 0 || options->format == 's')
&& addr != 0)
return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
return val_print_string (TYPE_TARGET_TYPE (type), addr, -1,
stream, options);
return 0;
}
@ -294,7 +295,7 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
|| ((current_language->la_language == language_m2)
&& (TYPE_CODE (type) == TYPE_CODE_CHAR)))
&& (options->format == 0 || options->format == 's'))
val_print_string (address, len+1, eltlen, stream, options);
val_print_string (type, address, len+1, stream, options);
else
{
fprintf_filtered (stream, "{");
@ -359,7 +360,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
len = temp_len;
}
LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
valaddr + embedded_offset, len, 0,
options);
i = len;
}
@ -547,7 +549,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
else
fprintf_filtered (stream, "%d", (int) val);
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) val, stream);
LA_PRINT_CHAR ((unsigned char) val, type, stream);
}
break;

View File

@ -23,6 +23,7 @@
#include "macrotab.h"
#include "macroexp.h"
#include "gdb_assert.h"
#include "c-lang.h"
@ -320,14 +321,17 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
way GDB's C/C++ lexer does. So we call parse_escape in utils.c
to handle escape sequences. */
if ((p + 1 <= end && *p == '\'')
|| (p + 2 <= end && p[0] == 'L' && p[1] == '\''))
|| (p + 2 <= end
&& (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
&& p[1] == '\''))
{
char *tok_start = p;
char *body_start;
int char_count = 0;
if (*p == '\'')
p++;
else if (*p == 'L')
else if (*p == 'L' || *p == 'u' || *p == 'U')
p += 2;
else
gdb_assert (0);
@ -339,7 +343,7 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
error (_("Unmatched single quote."));
else if (*p == '\'')
{
if (p == body_start)
if (!char_count)
error (_("A character constant must contain at least one "
"character."));
p++;
@ -348,10 +352,13 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
else if (*p == '\\')
{
p++;
parse_escape (&p);
char_count += c_parse_escape (&p, NULL);
}
else
p++;
{
p++;
char_count++;
}
}
set_token (tok, tok_start, p);
@ -370,16 +377,16 @@ static int
get_string_literal (struct macro_buffer *tok, char *p, char *end)
{
if ((p + 1 <= end
&& *p == '\"')
&& *p == '"')
|| (p + 2 <= end
&& p[0] == 'L'
&& p[1] == '\"'))
&& (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
&& p[1] == '"'))
{
char *tok_start = p;
if (*p == '\"')
if (*p == '"')
p++;
else if (*p == 'L')
else if (*p == 'L' || *p == 'u' || *p == 'U')
p += 2;
else
gdb_assert (0);
@ -388,7 +395,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
{
if (p >= end)
error (_("Unterminated string in expression."));
else if (*p == '\"')
else if (*p == '"')
{
p++;
break;
@ -399,7 +406,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
else if (*p == '\\')
{
p++;
parse_escape (&p);
c_parse_escape (&p, NULL);
}
else
p++;

View File

@ -280,7 +280,7 @@ objc_demangle (const char *mangled, int options)
for printing characters and strings is language specific. */
static void
objc_emit_char (int c, struct ui_file *stream, int quoter)
objc_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
c &= 0xFF; /* Avoid sign bit follies. */
@ -326,10 +326,10 @@ objc_emit_char (int c, struct ui_file *stream, int quoter)
}
static void
objc_printchar (int c, struct ui_file *stream)
objc_printchar (int c, struct type *type, struct ui_file *stream)
{
fputs_filtered ("'", stream);
objc_emit_char (c, stream, '\'');
objc_emit_char (c, type, stream, '\'');
fputs_filtered ("'", stream);
}
@ -340,14 +340,16 @@ objc_printchar (int c, struct ui_file *stream)
FORCE_ELLIPSES. */
static void
objc_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
objc_printstr (struct ui_file *stream, struct type *type,
const gdb_byte *string, unsigned int length,
int force_ellipses,
const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
int width = TYPE_LENGTH (type);
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in
@ -395,7 +397,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("\", ", stream);
in_quotes = 0;
}
objc_printchar (string[i], stream);
objc_printchar (string[i], type, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += options->repeat_count_threshold;
@ -411,7 +413,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("\"", stream);
in_quotes = 1;
}
objc_emit_char (string[i], stream, '"');
objc_emit_char (string[i], type, stream, '"');
++things_printed;
}
}

View File

@ -97,7 +97,8 @@ pascal_main_name (void)
but this does not happen for Free Pascal nor for GPC. */
int
is_pascal_string_type (struct type *type,int *length_pos,
int *length_size, int *string_pos, int *char_size,
int *length_size, int *string_pos,
struct type **char_type,
char **arrayname)
{
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
@ -114,8 +115,8 @@ is_pascal_string_type (struct type *type,int *length_pos,
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (char_size)
*char_size = 1;
if (char_type)
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
if (arrayname)
*arrayname = TYPE_FIELDS (type)[1].name;
return 2;
@ -126,7 +127,6 @@ is_pascal_string_type (struct type *type,int *length_pos,
&& strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
&& strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
{
struct type *char_type;
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (length_size)
@ -134,13 +134,12 @@ is_pascal_string_type (struct type *type,int *length_pos,
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */
char_type = TYPE_FIELD_TYPE (type,2);
if (char_size && TYPE_CODE (char_type) == TYPE_CODE_ARRAY)
if (char_type)
{
*char_size = TYPE_LENGTH (TYPE_TARGET_TYPE (char_type));
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
if (TYPE_CODE (*char_type) == TYPE_CODE_ARRAY)
*char_type = TYPE_TARGET_TYPE (*char_type);
}
else if (char_size)
*char_size = 1;
if (arrayname)
*arrayname = TYPE_FIELDS (type)[2].name;
return 3;
@ -182,14 +181,15 @@ pascal_one_char (int c, struct ui_file *stream, int *in_quotes)
}
}
static void pascal_emit_char (int c, struct ui_file *stream, int quoter);
static void pascal_emit_char (int c, struct type *type,
struct ui_file *stream, int quoter);
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
characters and strings is language specific. */
static void
pascal_emit_char (int c, struct ui_file *stream, int quoter)
pascal_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
int in_quotes = 0;
pascal_one_char (c, stream, &in_quotes);
@ -198,7 +198,7 @@ pascal_emit_char (int c, struct ui_file *stream, int quoter)
}
void
pascal_printchar (int c, struct ui_file *stream)
pascal_printchar (int c, struct type *type, struct ui_file *stream)
{
int in_quotes = 0;
pascal_one_char (c, stream, &in_quotes);
@ -212,14 +212,16 @@ pascal_printchar (int c, struct ui_file *stream)
had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
void
pascal_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
pascal_printstr (struct ui_file *stream, struct type *type,
const gdb_byte *string, unsigned int length,
int force_ellipses,
const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
int width = TYPE_LENGTH (type);
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
@ -273,7 +275,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
fputs_filtered ("', ", stream);
in_quotes = 0;
}
pascal_printchar (current_char, stream);
pascal_printchar (current_char, type, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += options->repeat_count_threshold;

View File

@ -48,12 +48,13 @@ extern void pascal_type_print_method_args (char *, char *,
/* These are in p-lang.c: */
extern int
is_pascal_string_type (struct type *, int *, int *, int *, int *, char **);
is_pascal_string_type (struct type *, int *, int *, int *,
struct type **, char **);
extern void pascal_printchar (int, struct ui_file *);
extern void pascal_printchar (int, struct type *, struct ui_file *);
extern void pascal_printstr (struct ui_file *, const gdb_byte *,
unsigned int, int, int,
extern void pascal_printstr (struct ui_file *, struct type *, const gdb_byte *,
unsigned int, int,
const struct value_print_options *);
extern struct type **const (pascal_builtin_types[]);

View File

@ -61,7 +61,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct type *elttype;
unsigned eltlen;
int length_pos, length_size, string_pos;
int char_size;
struct type *char_type;
LONGEST val;
CORE_ADDR addr;
@ -100,8 +100,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
len = temp_len;
}
LA_PRINT_STRING (stream, valaddr + embedded_offset, len,
eltlen, 0, options);
LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
valaddr + embedded_offset, len, 0,
options);
i = len;
}
else
@ -175,8 +176,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
&& addr != 0)
{
/* no wide string yet */
i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
options);
i = val_print_string (elttype, addr, -1, stream, options);
}
/* also for pointers to pascal strings */
/* Note: this is Free Pascal specific:
@ -184,7 +184,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
Pascal strings are mapped to records
with lowercase names PM */
if (is_pascal_string_type (elttype, &length_pos, &length_size,
&string_pos, &char_size, NULL)
&string_pos, &char_type, NULL)
&& addr != 0)
{
ULONGEST string_length;
@ -193,7 +193,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
read_memory (addr + length_pos, buffer, length_size);
string_length = extract_unsigned_integer (buffer, length_size);
xfree (buffer);
i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
i = val_print_string (char_type ,addr + string_pos, string_length, stream, options);
}
else if (pascal_object_is_vtbl_member (type))
{
@ -298,10 +298,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
else
{
if (is_pascal_string_type (type, &length_pos, &length_size,
&string_pos, &char_size, NULL))
&string_pos, &char_type, NULL))
{
len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, 0, options);
}
else
pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
@ -426,7 +426,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
else
fprintf_filtered (stream, "%d", (int) val);
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) val, stream);
LA_PRINT_CHAR ((unsigned char) val, type, stream);
}
break;

View File

@ -352,6 +352,65 @@ write_exp_string (struct stoken str)
write_exp_elt_longcst ((LONGEST) len);
}
/* Add a vector of string constants to the end of the expression.
This adds an OP_STRING operation, but encodes the contents
differently from write_exp_string. The language is expected to
handle evaluation of this expression itself.
After the usual OP_STRING header, TYPE is written into the
expression as a long constant. The interpretation of this field is
up to the language evaluator.
Next, each string in VEC is written. The length is written as a
long constant, followed by the contents of the string. */
void
write_exp_string_vector (int type, struct stoken_vector *vec)
{
int i, n_slots, len;
/* Compute the size. We compute the size in number of slots to
avoid issues with string padding. */
n_slots = 0;
for (i = 0; i < vec->len; ++i)
{
/* One slot for the length of this element, plus the number of
slots needed for this string. */
n_slots += 1 + BYTES_TO_EXP_ELEM (vec->tokens[i].length);
}
/* One more slot for the type of the string. */
++n_slots;
/* Now compute a phony string length. */
len = EXP_ELEM_TO_BYTES (n_slots) - 1;
n_slots += 4;
if ((expout_ptr + n_slots) >= expout_size)
{
expout_size = max (expout_size * 2, expout_ptr + n_slots + 10);
expout = (struct expression *)
xrealloc ((char *) expout, (sizeof (struct expression)
+ EXP_ELEM_TO_BYTES (expout_size)));
}
write_exp_elt_opcode (OP_STRING);
write_exp_elt_longcst (len);
write_exp_elt_longcst (type);
for (i = 0; i < vec->len; ++i)
{
write_exp_elt_longcst (vec->tokens[i].length);
memcpy (&expout->elts[expout_ptr], vec->tokens[i].ptr,
vec->tokens[i].length);
expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
}
write_exp_elt_longcst (len);
write_exp_elt_opcode (OP_STRING);
}
/* Add a bitstring constant to the end of the expression.
Bitstring constants are stored by first writing an expression element

View File

@ -69,6 +69,22 @@ struct stoken
int length;
};
struct typed_stoken
{
/* A language-specific type field. */
int type;
/* Pointer to first byte of char-string or first bit of bit-string */
char *ptr;
/* Length of string in bytes for char-string or bits for bit-string */
int length;
};
struct stoken_vector
{
int len;
struct typed_stoken *tokens;
};
struct ttype
{
struct stoken stoken;
@ -130,6 +146,8 @@ extern void write_exp_elt_intern (struct internalvar *);
extern void write_exp_string (struct stoken);
void write_exp_string_vector (int type, struct stoken_vector *vec);
extern void write_exp_bitstring (struct stoken);
extern void write_exp_elt_block (struct block *);

View File

@ -48,6 +48,7 @@
#include "solist.h"
#include "solib.h"
#include "parser-defs.h"
#include "charset.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
@ -276,10 +277,13 @@ print_formatted (struct value *val, int size,
switch (options->format)
{
case 's':
/* FIXME: Need to handle wchar_t's here... */
next_address = VALUE_ADDRESS (val)
+ val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
options);
{
struct type *elttype = value_type (val);
next_address = (VALUE_ADDRESS (val)
+ val_print_string (elttype,
VALUE_ADDRESS (val), -1,
stream, options));
}
return;
case 'i':
@ -374,7 +378,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
print_hex_chars (stream, valaddr, len, byte_order);
return;
case 'c':
print_char_chars (stream, valaddr, len, byte_order);
print_char_chars (stream, type, valaddr, len, byte_order);
return;
default:
break;
@ -1958,7 +1962,8 @@ printf_command (char *arg, int from_tty)
enum argclass
{
int_arg, long_arg, long_long_arg, ptr_arg, string_arg,
int_arg, long_arg, long_long_arg, ptr_arg,
string_arg, wide_string_arg, wide_char_arg,
double_arg, long_double_arg, decfloat_arg
};
enum argclass *argclass;
@ -2090,8 +2095,8 @@ printf_command (char *arg, int from_tty)
break;
case 'c':
this_argclass = int_arg;
if (lcount || seen_h || seen_big_l)
this_argclass = lcount == 0 ? int_arg : wide_char_arg;
if (lcount > 1 || seen_h || seen_big_l)
bad = 1;
if (seen_prec || seen_zero || seen_space || seen_plus)
bad = 1;
@ -2106,8 +2111,8 @@ printf_command (char *arg, int from_tty)
break;
case 's':
this_argclass = string_arg;
if (lcount || seen_h || seen_big_l)
this_argclass = lcount == 0 ? string_arg : wide_string_arg;
if (lcount > 1 || seen_h || seen_big_l)
bad = 1;
if (seen_zero || seen_space || seen_plus)
bad = 1;
@ -2159,6 +2164,15 @@ printf_command (char *arg, int from_tty)
last_arg[length_before_ll + lcount];
current_substring += length_before_ll + 4;
}
else if (this_argclass == wide_string_arg
|| this_argclass == wide_char_arg)
{
/* Convert %ls or %lc to %s. */
int length_before_ls = f - last_arg - 2;
strncpy (current_substring, last_arg, length_before_ls);
strcpy (current_substring + length_before_ls, "s");
current_substring += length_before_ls + 2;
}
else
{
strncpy (current_substring, last_arg, f - last_arg);
@ -2223,6 +2237,76 @@ printf_command (char *arg, int from_tty)
printf_filtered (current_substring, (char *) str);
}
break;
case wide_string_arg:
{
gdb_byte *str;
CORE_ADDR tem;
int j;
struct type *wctype = lookup_typename ("wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype);
gdb_byte *buf = alloca (wcwidth);
struct obstack output;
struct cleanup *inner_cleanup;
tem = value_as_address (val_args[i]);
/* This is a %s argument. Find the length of the string. */
for (j = 0;; j += wcwidth)
{
QUIT;
read_memory (tem + j, buf, wcwidth);
if (extract_unsigned_integer (buf, wcwidth) == 0)
break;
}
/* Copy the string contents into a string inside GDB. */
str = (gdb_byte *) alloca (j + wcwidth);
if (j != 0)
read_memory (tem, str, j);
memset (&str[j], 0, wcwidth);
obstack_init (&output);
inner_cleanup = make_cleanup_obstack_free (&output);
convert_between_encodings (target_wide_charset (),
host_charset (),
str, j, wcwidth,
&output, translit_char);
obstack_grow_str0 (&output, "");
printf_filtered (current_substring, obstack_base (&output));
do_cleanups (inner_cleanup);
}
break;
case wide_char_arg:
{
struct type *wctype = lookup_typename ("wchar_t", NULL, 0);
struct type *valtype;
struct obstack output;
struct cleanup *inner_cleanup;
const gdb_byte *bytes;
valtype = value_type (val_args[i]);
if (TYPE_LENGTH (valtype) != TYPE_LENGTH (wctype)
|| TYPE_CODE (valtype) != TYPE_CODE_INT)
error (_("expected wchar_t argument for %%lc"));
bytes = value_contents (val_args[i]);
obstack_init (&output);
inner_cleanup = make_cleanup_obstack_free (&output);
convert_between_encodings (target_wide_charset (),
host_charset (),
bytes, TYPE_LENGTH (valtype),
TYPE_LENGTH (valtype),
&output, translit_char);
obstack_grow_str0 (&output, "");
printf_filtered (current_substring, obstack_base (&output));
do_cleanups (inner_cleanup);
}
break;
case double_arg:
{
struct type *type = value_type (val_args[i]);

View File

@ -43,14 +43,14 @@ static int in_eval_c (void);
struct type *builtin_type_scm;
void
scm_printchar (int c, struct ui_file *stream)
scm_printchar (int c, struct type *type, struct ui_file *stream)
{
fprintf_filtered (stream, "#\\%c", c);
}
static void
scm_printstr (struct ui_file *stream, const gdb_byte *string,
unsigned int length, int width, int force_ellipses,
scm_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
fprintf_filtered (stream, "\"%s\"", string);

View File

@ -59,7 +59,7 @@ extern void scm_scmval_print (LONGEST, struct ui_file *, int,
extern int is_scmvalue_type (struct type *);
extern void scm_printchar (int, struct ui_file *);
extern void scm_printchar (int, struct type *, struct ui_file *);
extern struct value *scm_evaluate_string (char *, int);

View File

@ -187,7 +187,8 @@ taloop:
if (SCM_ICHRP (svalue))
{
svalue = SCM_ICHR (svalue);
scm_printchar (svalue, stream);
scm_printchar (svalue, builtin_type (current_gdbarch)->builtin_char,
stream);
break;
}
else if (SCM_IFLAGP (svalue)

View File

@ -1,3 +1,28 @@
2009-03-20 Tom Tromey <tromey@redhat.com>
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
2009-03-19 Jerome Guitton <guitton@adacore.com>
* gdb.ada/fixed_points/fixed_points.adb: Add a test on overprecise

View File

@ -186,7 +186,7 @@ if {![gdb_skip_float_test "print print_two_floats(*f3)"] && \
if ![gdb_skip_stdio_test "print print_bit_flags_char(*cflags)"] {
print_struct_call "print_bit_flags_char(*cflags)" \
".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\0', gamma = 1 '\\\\001', delta = 0 '\\\\0', epsilon = 1 '\\\\001', omega = 0 '\\\\0'\\}"
".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\1', beta = 0 '\\\\0', gamma = 1 '\\\\1', delta = 0 '\\\\0', epsilon = 1 '\\\\1', omega = 0 '\\\\0'\\}"
}
if ![gdb_skip_stdio_test "print print_bit_flags_short(*sflags)"] {

View File

@ -437,7 +437,7 @@ gdb_test "print t_small_values(1,3,5,7,9,11,13,15,17,19)" \
"The program being debugged stopped while.*" \
"stop at nested call level 4"
gdb_test "backtrace" \
"\#0 t_small_values \\(arg1=1 '.001', arg2=3, arg3=5, arg4=7 '.a', arg5=9, arg6=11 '.v', arg7=13, arg8=15, arg9=17, arg10=19\\).*\#2 sum10 \\(i0=2, i1=4, i2=6, i3=8, i4=10, i5=12, i6=14, i7=16, i8=18, i9=20\\).*\#3 <function called from gdb>.*\#4 add \\(a=4, b=5\\).*\#5 <function called from gdb>.*\#6 add \\(a=2, b=3\\).*\#7 <function called from gdb>.*\#8 main.*" \
"\#0 t_small_values \\(arg1=1 '.1', arg2=3, arg3=5, arg4=7 '.a', arg5=9, arg6=11 '.v', arg7=13, arg8=15, arg9=17, arg10=19\\).*\#2 sum10 \\(i0=2, i1=4, i2=6, i3=8, i4=10, i5=12, i6=14, i7=16, i8=18, i9=20\\).*\#3 <function called from gdb>.*\#4 add \\(a=4, b=5\\).*\#5 <function called from gdb>.*\#6 add \\(a=2, b=3\\).*\#7 <function called from gdb>.*\#8 main.*" \
"backtrace at nested call level 4"
gdb_test "finish" "Value returned is .* = 100" \
"Finish from nested call level 4"

View File

@ -20,11 +20,6 @@
Please email any bugs, comments, and/or additions to this file to:
bug-gdb@gnu.org */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* X_string is a null-terminated string in the X charset whose
elements are as follows. X should be the name the `set charset'
command uses for the character set, in lower-case, with any
@ -54,6 +49,21 @@ char iso_8859_1_string[NUM_CHARS];
char ebcdic_us_string[NUM_CHARS];
char ibm1047_string[NUM_CHARS];
/* We make a phony wchar_t and then pretend that this platform uses
UCS-4 (or UCS-2, depending on the size -- same difference for the
purposes of this test). */
typedef unsigned int wchar_t;
wchar_t ucs_4_string[NUM_CHARS];
/* We also define a couple phony types for testing the u'' and U''
support. It is ok if these have the wrong size on some platforms
-- the test case will skip the tests in that case. */
typedef unsigned short char16_t;
typedef unsigned int char32_t;
/* Make sure to use the typedefs. */
char16_t uvar;
char32_t Uvar;
void
init_string (char string[],
@ -62,7 +72,10 @@ init_string (char string[],
char line_feed, char carriage_return, char horizontal_tab,
char vertical_tab, char cent, char misc_ctrl)
{
memset (string, x, NUM_CHARS);
int i;
for (i = 0; i < NUM_CHARS; ++i)
string[i] = x;
string[0] = alert;
string[1] = backspace;
string[2] = form_feed;
@ -85,13 +98,21 @@ fill_run (char string[], int start, int len, int first)
}
void
init_ucs4 ()
{
int i;
for (i = 0; i < NUM_CHARS; ++i)
ucs_4_string[i] = iso_8859_1_string[i] & 0xff;
}
int main ()
{
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
(void) malloc (1);
/* Initialize ascii_string. */
init_string (ascii_string,
120,
@ -146,5 +167,7 @@ int main ()
/* The digits, at least, are contiguous. */
fill_run (ibm1047_string, 59, 10, 240);
puts ("All set!"); /* all strings initialized */
init_ucs4 ();
return 0; /* all strings initialized */
}

View File

@ -47,13 +47,7 @@ proc parse_show_charset_output {testname} {
global gdb_prompt
gdb_expect {
-re "The current host and target character set is `(.*)'\\.\[\r\n\]+$gdb_prompt $" {
set host_charset $expect_out(1,string)
set target_charset $expect_out(1,string)
set retlist [list $host_charset $target_charset]
pass $testname
}
-re "The current host character set is `(.*)'\\.\[\r\n\]+The current target character set is `(.*)'\\.\[\r\n\]+$gdb_prompt $" {
-re "The host character set is \"(.*)\"\\.\[\r\n\]+The target character set is \"(.*)\"\\.\[\r\n\]+The target wide character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" {
set host_charset $expect_out(1,string)
set target_charset $expect_out(2,string)
set retlist [list $host_charset $target_charset]
@ -81,76 +75,31 @@ proc parse_show_charset_output {testname} {
}
# Try the various `show charset' commands. These are all aliases of each
# other; `show target-charset' and `show host-charset' actually print
# both the host and target charsets.
# Try the various `show charset' commands.
send_gdb "show charset\n"
set show_charset [parse_show_charset_output "show charset"]
send_gdb "show target-charset\n"
set show_target_charset [parse_show_charset_output "show target-charset"]
set show_target_charset \
[lindex [parse_show_charset_output "show target-charset"] 0]
if {[lsearch $show_charset $show_target_charset] >= 0} {
if {[lsearch -exact $show_charset $show_target_charset] >= 0} {
pass "check `show target-charset' against `show charset'"
} else {
fail "check `show target-charset' against `show charset'"
}
send_gdb "show host-charset\n"
set show_host_charset [parse_show_charset_output "show host-charset"]
set show_host_charset \
[lindex [parse_show_charset_output "show host-charset"] 0]
if {[lsearch $show_charset $show_host_charset] >= 0} {
if {[lsearch -exact $show_charset $show_host_charset] >= 0} {
pass "check `show host-charset' against `show charset'"
} else {
fail "check `show host-charset' against `show charset'"
}
# Get the list of supported (host) charsets as possible completions.
send_gdb "set charset \t\t"
# Check that we can at least use ASCII as a host character set.
sleep 1
gdb_expect {
-re "^set charset .*\r\nASCII.*\r\n$gdb_prompt set charset " {
# We got the output that we wanted, including ASCII as possible
# charset. Send a newline to get us back to the prompt. This will
# also generate an error message. Let's not check here that the error
# message makes sense, we do that below, as a separate testcase.
send_gdb "\n"
gdb_expect {
-re ".*Requires an argument.*$gdb_prompt $" {
pass "get valid character sets"
}
-re ".*$gdb_prompt $" {
send_gdb "\n"
gdb_expect {
-re ".*$gdb_prompt $" {
fail "get valid character sets"
}
}
}
timeout {
fail "(timeout) get valid character sets"
}
}
}
-re ".*$gdb_prompt $" {
# We got some output that ended with a regular prompt
fail "get valid character sets"
}
-re ".*$gdb_prompt set charset.*$" {
# We got some other output, send a cntrl-c to gdb to get us back
# to the prompt.
send_gdb "\003"
fail "get valid character sets"
}
timeout {
fail "get valid character sets (timeout)"
}
}
# Try a malformed `set charset'.
gdb_test "set charset" \
"Requires an argument. Valid arguments are.*" \
@ -179,7 +128,7 @@ proc all_charset_names {} {
proc valid_host_charset {charset} {
global charsets
return $charsets($charset)
return [expr {[info exists charsets($charset)] && $charsets($charset)}]
}
send_gdb "set host-charset\n"
@ -211,6 +160,13 @@ gdb_expect {
}
}
# If gdb was built with a phony iconv, it will only have two character
# sets: "auto" and the default. In this situation, this set of tests
# is pointless.
if {[llength [array names charsets]] < 3} {
untested charset.exp
return -1
}
send_gdb "set target-charset\n"
gdb_expect {
@ -244,8 +200,10 @@ gdb_expect {
}
}
# Make sure that GDB supports every host/target charset combination.
foreach host_charset [all_charset_names] {
# We don't want to test all the charset names here, since that would
# be too many combinations. We we pick a subset.
set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047}
foreach host_charset $charset_subset {
if {[valid_host_charset $host_charset]} {
set testname "try `set host-charset $host_charset'"
@ -279,7 +237,7 @@ foreach host_charset [all_charset_names] {
# Now try setting every possible target character set,
# given that host charset.
foreach target_charset [all_charset_names] {
foreach target_charset $charset_subset {
set testname "try `set target-charset $target_charset'"
send_gdb "set target-charset $target_charset\n"
gdb_expect {
@ -404,23 +362,42 @@ gdb_expect {
}
# We only try the wide character tests on machines where the wchar_t
# typedef in the test case has the right size.
set wchar_size [get_sizeof wchar_t 99]
set wchar_ok 0
if {$wchar_size == 2} {
lappend charset_subset UCS-2
set wchar_ok 1
} elseif {$wchar_size == 4} {
lappend charset_subset UCS-4
set wchar_ok 1
}
gdb_test "set host-charset ASCII" ""
foreach target_charset [all_charset_names] {
send_gdb "set target-charset $target_charset\n"
foreach target_charset $charset_subset {
if {$target_charset == "UCS-4" || $target_charset == "UCS-2"} {
set param target-wide-charset
set L L
} else {
set param target-charset
set L ""
}
send_gdb "set $param $target_charset\n"
gdb_expect {
-re "$gdb_prompt $" {
pass "set target-charset $target_charset"
pass "set $param $target_charset"
}
timeout {
fail "set target-charset $target_charset (timeout)"
fail "set $param $target_charset (timeout)"
}
}
# Try printing the null character. There seems to be a bug in
# gdb_test that requires us to use gdb_expect here.
send_gdb "print '\\0'\n"
send_gdb "print $L'\\0'\n"
gdb_expect {
-re "\\\$${decimal} = 0 '\\\\0'\[\r\n\]+$gdb_prompt $" {
-re "\\\$${decimal} = 0 $L'\\\\0'\[\r\n\]+$gdb_prompt $" {
pass "print the null character in ${target_charset}"
}
-re "$gdb_prompt $" {
@ -435,8 +412,14 @@ foreach target_charset [all_charset_names] {
# a string in $target_charset. The variable's name is the
# character set's name, in lower-case, with all non-identifier
# characters replaced with '_', with "_string" stuck on the end.
set var_name [string tolower "${target_charset}_string"]
regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
if {$target_charset == "UCS-2"} {
# We still use the ucs_4_string variable -- but the size is
# correct for UCS-2.
set var_name ucs_4_string
} else {
set var_name [string tolower "${target_charset}_string"]
regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
}
# Compute a regexp matching the results we expect. This is static,
# but it's easier than writing it out.
@ -444,12 +427,12 @@ foreach target_charset [all_charset_names] {
set uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set lowercase "abcdefghijklmnopqrstuvwxyz"
set digits "0123456789"
set octal_escape "\\\\\[0-9\]\[0-9\]\[0-9\]"
set octal_escape "\\\\\[0-9\]+"
send_gdb "print $var_name\n"
# ${escapes}${uppercase}${lowercase}${digits}${octal}${octal}
gdb_expect {
-re ".* = \"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(\\\\\[0-9\]\[0-9\]\[0-9\]|x)(\\\\\[0-9\]\[0-9\]\[0-9\]|x).*\"\[\r\n\]+$gdb_prompt $" {
-re ".* = $L\"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(${octal_escape}|x)+\"\[\r\n\]+$gdb_prompt $" {
pass "print string in $target_charset"
}
-re "$gdb_prompt $" {
@ -461,22 +444,22 @@ foreach target_charset [all_charset_names] {
}
# Try entering a character literal, and see if it comes back unchanged.
gdb_test "print 'A'" \
" = \[0-9-\]+ 'A'" \
gdb_test "print $L'A'" \
" = \[0-9-\]+ $L'A'" \
"parse character literal in ${target_charset}"
# Check that the character literal was encoded correctly.
gdb_test "print 'A' == $var_name\[7\]" \
gdb_test "print $L'A' == $var_name\[7\]" \
" = 1" \
"check value of parsed character literal in ${target_charset}"
# Try entering a string literal, and see if it comes back unchanged.
gdb_test "print \"abcdefABCDEF012345\"" \
" = \"abcdefABCDEF012345\"" \
gdb_test "print $L\"abcdefABCDEF012345\"" \
" = $L\"abcdefABCDEF012345\"" \
"parse string literal in ${target_charset}"
# Check that the string literal was encoded correctly.
gdb_test "print \"q\"\[0\] == $var_name\[49\]" \
gdb_test "print $L\"q\"\[0\] == $var_name\[49\]" \
" = 1" \
"check value of parsed string literal in ${target_charset}"
@ -509,7 +492,7 @@ foreach target_charset [all_charset_names] {
send_gdb "print $var_name\[$i\]\n"
set have_escape 1
gdb_expect {
-re "= \[0-9-\]+ '\\\\${escape}'\[\r\n\]+$gdb_prompt $" {
-re "= \[0-9-\]+ $L'\\\\${escape}'\[\r\n\]+$gdb_prompt $" {
pass "try printing '\\${escape}' in ${target_charset}"
}
-re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" {
@ -527,12 +510,12 @@ foreach target_charset [all_charset_names] {
if {$have_escape} {
# Try parsing a backslash escape in a character literal.
gdb_test "print '\\${escape}' == $var_name\[$i\]" \
gdb_test "print $L'\\${escape}' == $var_name\[$i\]" \
" = 1" \
"check value of '\\${escape}' in ${target_charset}"
# Try parsing a backslash escape in a string literal.
gdb_test "print \"\\${escape}\"\[0\] == $var_name\[$i\]" \
gdb_test "print $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
" = 1" \
"check value of \"\\${escape}\" in ${target_charset}"
}
@ -540,10 +523,73 @@ foreach target_charset [all_charset_names] {
# Try printing a character escape that doesn't exist. We should
# get the unescaped character, in the target character set.
gdb_test "print '\\q'" " = \[0-9-\]+ 'q'" \
gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \
"print escape that doesn't exist in $target_charset"
gdb_test "print '\\q' == $var_name\[49\]" " = 1" \
gdb_test "print $L'\\q' == $var_name\[49\]" " = 1" \
"check value of escape that doesn't exist in $target_charset"
}
# Reset the target charset.
gdb_test "set target-charset UTF-8" ""
# \242 is not a valid UTF-8 character.
gdb_test "print \"\\242\"" " = \"\\\\242\"" \
"non-representable target character"
gdb_test "print '\\x'" "\\\\x escape without a following hex digit."
gdb_test "print '\\u'" "\\\\u escape without a following hex digit."
gdb_test "print '\\9'" " = \[0-9\]+ '9'"
# Tests for wide- or unicode- strings. L is the prefix letter to use,
# either "L" (for wide strings), "u" (for UCS-2), or "U" (for UCS-4).
# NAME is used in the test names and should be related to the prefix
# letter in some easy-to-undestand way.
proc test_wide_or_unicode {L name} {
gdb_test "print $L\"ab\" $L\"c\"" " = $L\"abc\"" \
"basic $name string concatenation"
gdb_test "print $L\"ab\" \"c\"" " = $L\"abc\"" \
"narrow and $name string concatenation"
gdb_test "print \"ab\" $L\"c\"" " = $L\"abc\"" \
"$name and narrow string concatenation"
gdb_test "print $L\"\\xe\" $L\"c\"" " = $L\"\\\\16c\"" \
"$name string concatenation with escape"
gdb_test "print $L\"\" \"abcdef\" \"g\"" \
"$L\"abcdefg\"" \
"concatenate three strings with empty $name string"
gdb_test "print $L'a'" "= \[0-9\]+ $L'a'" \
"basic $name character"
}
if {$wchar_ok} {
test_wide_or_unicode L wide
}
set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}]
if {$ucs2_ok} {
test_wide_or_unicode u UCS-2
}
set ucs4_ok [expr {[get_sizeof char32_t 99] == 4}]
if {$ucs4_ok} {
test_wide_or_unicode U UCS-4
}
# Test an invalid string combination.
proc test_combination {L1 name1 L2 name2} {
gdb_test "print $L1\"abc\" $L2\"def\"" \
"Undefined string concatenation." \
"undefined concatenation of $name1 and $name2"
}
if {$wchar_ok && $ucs2_ok} {
test_combination L wide u UCS-2
}
if {$wchar_ok && $ucs4_ok} {
test_combination L wide U UCS-4
}
if {$ucs2_ok && $ucs4_ok} {
test_combination u UCS-2 U UCS-4
}
gdb_exit

View File

@ -161,7 +161,7 @@ proc do_constvar_tests {} {
gdb_test "print laconic" " = 65 'A'"
local_compiler_xfail_check
gdb_test "ptype laconic" "type = const char"
gdb_test "print laggard" " = 1 '.001'"
gdb_test "print laggard" " = 1 '.1'"
local_compiler_xfail_check
gdb_test "ptype laggard" "type = const unsigned char"
gdb_test "print lagoon" " = 2"
@ -209,7 +209,7 @@ proc do_constvar_tests {} {
gdb_test "print *lewd" " = 65 'A'"
local_compiler_xfail_check
gdb_test "ptype lewd" "type = const char \\* const"
gdb_test "print *lexicographer" " = 1 '.001'"
gdb_test "print *lexicographer" " = 1 '.1'"
local_compiler_xfail_check
gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
gdb_test "print *lexicon" " = 2"
@ -233,7 +233,7 @@ proc do_constvar_tests {} {
gdb_test "print *languish" " = 65 'A'"
local_compiler_xfail_check
gdb_test "ptype languish" "type = const char \\*"
gdb_test "print *languor" " = 1 '.001'"
gdb_test "print *languor" " = 1 '.1'"
local_compiler_xfail_check
gdb_test "ptype languor" "type = const unsigned char \\*"
gdb_test "print *lank" " = 2"

View File

@ -210,7 +210,7 @@ gdb_test_char "p/o *(char *)c" "01"
gdb_test_char "p/t *(char *)c" "1"
gdb_test_char "p/a *(char *)c" "0x1( <.*>)?"
gdb_test_char "p/f *(char *)c" "1"
gdb_test_char "p/c *(char *)c" "1 '.001'"
gdb_test_char "p/c *(char *)c" "1 '.1'"
gdb_test_short "p/x *(short *)s" "" "0x123" ""
gdb_test_short "p/d *(short *)s" "" "291" ""
@ -257,7 +257,7 @@ gdb_test "x/u w" "19088743"
gdb_test "x/o w" "0110642547"
gdb_test "x/t w" "00000001001000110100010101100111"
gdb_test_xptr "x/a" { b "" } { h "" } { w "0x1234567" } { g "0x123456789abcdef" }
gdb_test "x/c b" "1 '.001'"
gdb_test "x/c b" "1 '.1'"
if { $sizeof_double == 8 || $sizeof_long_double == 8 } {
gdb_test "x/f &val.oct" "-5.9822653797615723e-120"
} else {
@ -273,7 +273,7 @@ gdb_test "x/2u g" "81985529216486895.*12046818088235383159"
gdb_test "x/2o g" "04432126361152746757.*01234567123456701234567"
gdb_test "x/2t g" "0000000100100011010001010110011110001001101010111100110111101111.*1010011100101110111001010011100101110111000001010011100101110111"
gdb_test_xptr "x/2a" { b "" } { h "" } { w "0x1234567.*0xa72ee539" } { g "0x123456789abcdef.*0xa72ee53977053977" }
gdb_test "x/2c b" "1 '.001'.*-89 '.'"
gdb_test "x/2c b" "1 '.1'.*-89 '.\[0-9\]*'"
if { $sizeof_double == 8 || $sizeof_long_double == 8 } {
gdb_test "x/2f &val.oct" "-5.9822653797615723e-120.*-5.9041889495880968e-100"
} else {
@ -288,7 +288,7 @@ gdb_test "x/2bu b" "1.*167"
gdb_test "x/2bo b" "01.*0247"
gdb_test "x/2bt b" "00000001.*10100111"
gdb_test_ptr "x/2ba b" "" "" "0x1.*0xffffffa7" "0x1.*0xffffffffffffffa7"
gdb_test "x/2bc b" "1 '.001'.*-89 '.'"
gdb_test "x/2bc b" "1 '.1'.*-89 '.\[0-9\]*'"
gdb_test "x/2bf b" "1.*-89"
gdb_test "x/2hx h" "0x0123.*0xa72e"
@ -315,7 +315,7 @@ gdb_test "x/2gu g" "81985529216486895.*12046818088235383159"
gdb_test "x/2go g" "04432126361152746757.*01234567123456701234567"
gdb_test "x/2gt g" "0000000100100011010001010110011110001001101010111100110111101111.*1010011100101110111001010011100101110111000001010011100101110111"
gdb_test_ptr "x/2ga g" "" "" "0x89abcdef.*0x77053977" "0x123456789abcdef.*0xa72ee53977053977"
gdb_test "x/2gc g" "-17 '.'.*119 'w'"
gdb_test "x/2gc g" "-17 '.\[0-9\]*'.*119 'w'"
gdb_test "x/2gf g" "3.5127005640885037e-303.*-5.9822653797615723e-120"
gdb_exit

View File

@ -389,7 +389,7 @@ gdb_expect {
send_gdb "print *pUC\n"
gdb_expect {
-re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" {
-re ".\[0-9\]* = 21 \'.25\'.*$gdb_prompt $" {
pass "print value of *pUC"
}
-re ".*$gdb_prompt $" { fail "print value of *pUC" }

View File

@ -137,12 +137,12 @@ proc test_print_all_chars {} {
global gdb_prompt
gdb_test "p ctable1\[0\]" " = 0 '\\\\0'"
gdb_test "p ctable1\[1\]" " = 1 '\\\\001'"
gdb_test "p ctable1\[2\]" " = 2 '\\\\002'"
gdb_test "p ctable1\[3\]" " = 3 '\\\\003'"
gdb_test "p ctable1\[4\]" " = 4 '\\\\004'"
gdb_test "p ctable1\[5\]" " = 5 '\\\\005'"
gdb_test "p ctable1\[6\]" " = 6 '\\\\006'"
gdb_test "p ctable1\[1\]" " = 1 '\\\\1'"
gdb_test "p ctable1\[2\]" " = 2 '\\\\2'"
gdb_test "p ctable1\[3\]" " = 3 '\\\\3'"
gdb_test "p ctable1\[4\]" " = 4 '\\\\4'"
gdb_test "p ctable1\[5\]" " = 5 '\\\\5'"
gdb_test "p ctable1\[6\]" " = 6 '\\\\6'"
gdb_test "p ctable1\[7\]" " = 7 '\\\\a'"
gdb_test "p ctable1\[8\]" " = 8 '\\\\b'"
gdb_test "p ctable1\[9\]" " = 9 '\\\\t'"
@ -150,24 +150,24 @@ proc test_print_all_chars {} {
gdb_test "p ctable1\[11\]" " = 11 '\\\\v'"
gdb_test "p ctable1\[12\]" " = 12 '\\\\f'"
gdb_test "p ctable1\[13\]" " = 13 '\\\\r'"
gdb_test "p ctable1\[14\]" " = 14 '\\\\016'"
gdb_test "p ctable1\[15\]" " = 15 '\\\\017'"
gdb_test "p ctable1\[16\]" " = 16 '\\\\020'"
gdb_test "p ctable1\[17\]" " = 17 '\\\\021'"
gdb_test "p ctable1\[18\]" " = 18 '\\\\022'"
gdb_test "p ctable1\[19\]" " = 19 '\\\\023'"
gdb_test "p ctable1\[20\]" " = 20 '\\\\024'"
gdb_test "p ctable1\[21\]" " = 21 '\\\\025'"
gdb_test "p ctable1\[22\]" " = 22 '\\\\026'"
gdb_test "p ctable1\[23\]" " = 23 '\\\\027'"
gdb_test "p ctable1\[24\]" " = 24 '\\\\030'"
gdb_test "p ctable1\[25\]" " = 25 '\\\\031'"
gdb_test "p ctable1\[26\]" " = 26 '\\\\032'"
gdb_test "p ctable1\[27\]" " = 27 '\\\\033'"
gdb_test "p ctable1\[28\]" " = 28 '\\\\034'"
gdb_test "p ctable1\[29\]" " = 29 '\\\\035'"
gdb_test "p ctable1\[30\]" " = 30 '\\\\036'"
gdb_test "p ctable1\[31\]" " = 31 '\\\\037'"
gdb_test "p ctable1\[14\]" " = 14 '\\\\16'"
gdb_test "p ctable1\[15\]" " = 15 '\\\\17'"
gdb_test "p ctable1\[16\]" " = 16 '\\\\20'"
gdb_test "p ctable1\[17\]" " = 17 '\\\\21'"
gdb_test "p ctable1\[18\]" " = 18 '\\\\22'"
gdb_test "p ctable1\[19\]" " = 19 '\\\\23'"
gdb_test "p ctable1\[20\]" " = 20 '\\\\24'"
gdb_test "p ctable1\[21\]" " = 21 '\\\\25'"
gdb_test "p ctable1\[22\]" " = 22 '\\\\26'"
gdb_test "p ctable1\[23\]" " = 23 '\\\\27'"
gdb_test "p ctable1\[24\]" " = 24 '\\\\30'"
gdb_test "p ctable1\[25\]" " = 25 '\\\\31'"
gdb_test "p ctable1\[26\]" " = 26 '\\\\32'"
gdb_test "p ctable1\[27\]" " = 27 '\\\\33'"
gdb_test "p ctable1\[28\]" " = 28 '\\\\34'"
gdb_test "p ctable1\[29\]" " = 29 '\\\\35'"
gdb_test "p ctable1\[30\]" " = 30 '\\\\36'"
gdb_test "p ctable1\[31\]" " = 31 '\\\\37'"
gdb_test "p ctable1\[32\]" " = 32 ' '"
gdb_test "p ctable1\[33\]" " = 33 '!'"
gdb_test "p ctable1\[34\]" " = 34 '\"'"
@ -475,13 +475,13 @@ proc test_print_strings {} {
gdb_test "p &ctable1\[0\]" \
" = \\(unsigned char \\*\\) \"\""
gdb_test "p &ctable1\[1\]" \
" = \\(unsigned char \\*\\) \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..."
" = \\(unsigned char \\*\\) \"\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\a\\\\b\"..."
gdb_test "p &ctable1\[1*8\]" \
" = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..."
" = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\16\\\\17\"..."
gdb_test "p &ctable1\[2*8\]" \
" = \\(unsigned char \\*\\) \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..."
" = \\(unsigned char \\*\\) \"\\\\20\\\\21\\\\22\\\\23\\\\24\\\\25\\\\26\\\\27\"..."
gdb_test "p &ctable1\[3*8\]" \
" = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..."
" = \\(unsigned char \\*\\) \"\\\\30\\\\31\\\\32\\\\33\\\\34\\\\35\\\\36\\\\37\"..."
gdb_test "p &ctable1\[4*8\]" \
" = \\(unsigned char \\*\\) \" !\\\\\"#\\\$%&'\"..."
gdb_test "p &ctable1\[5*8\]" \
@ -622,7 +622,7 @@ proc test_print_string_constants {} {
set timeout 60;
gdb_test "p \"a string\"" " = \"a string\""
gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\""
gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\0 null\""
gdb_test "p \"abcd\"\[2\]" " = 99 'c'"
gdb_test "p sizeof (\"abcdef\")" " = 7"
gdb_test "ptype \"foo\"" " = char \\\[4\\\]"

View File

@ -121,7 +121,7 @@ proc test_set { args } {
#
test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0"
test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1"
test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.1\'" "set variable char=1"
test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)"
test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)"
test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')"
@ -132,7 +132,7 @@ test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'"
# test "set variable" for type "signed char"
#
test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0"
test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1"
test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.1\'" "set variable signed char=1"
test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)"
test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)"
test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')"
@ -151,7 +151,7 @@ gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
# test "set variable" for type "unsigned char"
#
test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0"
test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1"
test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.1\'" "set variable unsigned char=1"
test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)"
test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)"
test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')"

View File

@ -74,7 +74,7 @@ proc check_set { t l r new add } {
"${prefix}; print incremented l, expecting ${add}"
}
check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002."
check_set "charest" "-1 .*" "-2 .*" "4 ..4." "2 ..2."
check_set "short" "-1" "-2" "4" "2"
check_set "int" "-1" "-2" "4" "2"
check_set "long" "-1" "-2" "4" "2"
@ -102,7 +102,7 @@ proc up_set { t l r new } {
"${prefix}; print new l, expecting ${new}"
}
up_set "charest" "-1 .*" "-2 .*" "4 ..004."
up_set "charest" "-1 .*" "-2 .*" "4 ..4."
up_set "short" "-1" "-2" "4"
up_set "int" "-1" "-2" "4"
up_set "long" "-1" "-2" "4"

View File

@ -284,7 +284,7 @@ gdb_expect {
send_gdb "print UC\n"
gdb_expect {
-re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
-re ".\[0-9\]* = 21 '\.25'\.*$gdb_prompt $" {
pass "print value of UC"
}
-re ".*$gdb_prompt $" { fail "print value of UC" }
@ -557,7 +557,7 @@ gdb_expect {
send_gdb "print rUC\n"
gdb_expect {
-re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
-re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.25\'.*$gdb_prompt $" {
pass "print value of rUC"
}
-re ".*$gdb_prompt $" { fail "print value of rUC" }

View File

@ -1162,9 +1162,12 @@ proc default_gdb_start { } {
global gdb_prompt
global timeout
global gdb_spawn_id;
global env
gdb_stop_suppressing_tests;
set env(LC_CTYPE) C
verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
if [info exists gdb_spawn_id] {

View File

@ -236,7 +236,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
break;
case TYPE_CODE_CHAR:
LA_PRINT_CHAR ((unsigned char) val, stream);
LA_PRINT_CHAR ((unsigned char) val, type, stream);
break;
case TYPE_CODE_BOOL:

View File

@ -1571,21 +1571,33 @@ query (const char *ctlstr, ...)
va_end (args);
}
/* Print an error message saying that we couldn't make sense of a
\^mumble sequence in a string or character constant. START and END
indicate a substring of some larger string that contains the
erroneous backslash sequence, missing the initial backslash. */
static NORETURN int
no_control_char_error (const char *start, const char *end)
/* A helper for parse_escape that converts a host character to a
target character. C is the host character. If conversion is
possible, then the target character is stored in *TARGET_C and the
function returns 1. Otherwise, the function returns 0. */
static int
host_char_to_target (int c, int *target_c)
{
int len = end - start;
char *copy = alloca (end - start + 1);
struct obstack host_data;
char the_char = c;
struct cleanup *cleanups;
int result = 0;
memcpy (copy, start, len);
copy[len] = '\0';
obstack_init (&host_data);
cleanups = make_cleanup_obstack_free (&host_data);
error (_("There is no control character `\\%s' in the `%s' character set."),
copy, target_charset ());
convert_between_encodings (target_charset (), host_charset (),
&the_char, 1, 1, &host_data, translit_none);
if (obstack_object_size (&host_data) == 1)
{
result = 1;
*target_c = *(char *) obstack_base (&host_data);
}
do_cleanups (cleanups);
return result;
}
/* Parse a C escape sequence. STRING_PTR points to a variable
@ -1608,53 +1620,13 @@ parse_escape (char **string_ptr)
{
int target_char;
int c = *(*string_ptr)++;
if (c_parse_backslash (c, &target_char))
return target_char;
else
switch (c)
{
switch (c)
{
case '\n':
return -2;
case 0:
(*string_ptr)--;
return 0;
case '^':
{
/* Remember where this escape sequence started, for reporting
errors. */
char *sequence_start_pos = *string_ptr - 1;
c = *(*string_ptr)++;
if (c == '?')
{
/* XXXCHARSET: What is `delete' in the host character set? */
c = 0177;
if (!host_char_to_target (c, &target_char))
error (_("There is no character corresponding to `Delete' "
"in the target character set `%s'."), host_charset ());
return target_char;
}
else if (c == '\\')
target_char = parse_escape (string_ptr);
else
{
if (!host_char_to_target (c, &target_char))
no_control_char_error (sequence_start_pos, *string_ptr);
}
/* Now target_char is something like `c', and we want to find
its control-character equivalent. */
if (!target_char_to_control_char (target_char, &target_char))
no_control_char_error (sequence_start_pos, *string_ptr);
return target_char;
}
/* XXXCHARSET: we need to use isdigit and value-of-digit
methods of the host character set here. */
case '0':
case '1':
@ -1665,16 +1637,16 @@ parse_escape (char **string_ptr)
case '6':
case '7':
{
int i = c - '0';
int i = host_hex_value (c);
int count = 0;
while (++count < 3)
{
c = (**string_ptr);
if (c >= '0' && c <= '7')
if (isdigit (c) && c != '8' && c != '9')
{
(*string_ptr)++;
i *= 8;
i += c - '0';
i += host_hex_value (c);
}
else
{
@ -1683,14 +1655,39 @@ parse_escape (char **string_ptr)
}
return i;
}
default:
if (!host_char_to_target (c, &target_char))
error
("The escape sequence `\%c' is equivalent to plain `%c', which"
" has no equivalent\n" "in the `%s' character set.", c, c,
target_charset ());
return target_char;
}
case 'a':
c = '\a';
break;
case 'b':
c = '\b';
break;
case 'f':
c = '\f';
break;
case 'n':
c = '\n';
break;
case 'r':
c = '\r';
break;
case 't':
c = '\t';
break;
case 'v':
c = '\v';
break;
default:
break;
}
if (!host_char_to_target (c, &target_char))
error
("The escape sequence `\%c' is equivalent to plain `%c', which"
" has no equivalent\n" "in the `%s' character set.", c, c,
target_charset ());
return target_char;
}
/* Print the character C on STREAM as part of the contents of a literal

View File

@ -1352,6 +1352,24 @@ value_array (int lowbound, int highbound, struct value **elemvec)
return val;
}
struct value *
value_typed_string (char *ptr, int len, struct type *char_type)
{
struct value *val;
int lowbound = current_language->string_lower_bound;
int highbound = len / TYPE_LENGTH (char_type);
struct type *rangetype = create_range_type ((struct type *) NULL,
builtin_type_int32,
lowbound,
highbound + lowbound - 1);
struct type *stringtype
= create_array_type ((struct type *) NULL, char_type, rangetype);
val = allocate_value (stringtype);
memcpy (value_contents_raw (val), ptr, len);
return val;
}
/* Create a value for a string constant by allocating space in the
inferior, copying the data into that space, and returning the
address with type TYPE_CODE_STRING. PTR points to the string

View File

@ -919,7 +919,8 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
Omit any leading zero chars. */
void
print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
print_char_chars (struct ui_file *stream, struct type *type,
const gdb_byte *valaddr,
unsigned len, enum bfd_endian byte_order)
{
const gdb_byte *p;
@ -932,7 +933,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
while (p < valaddr + len)
{
LA_EMIT_CHAR (*p, stream, '\'');
LA_EMIT_CHAR (*p, type, stream, '\'');
++p;
}
}
@ -944,7 +945,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
while (p >= valaddr)
{
LA_EMIT_CHAR (*p, stream, '\'');
LA_EMIT_CHAR (*p, type, stream, '\'');
--p;
}
}
@ -1315,7 +1316,8 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
whichever is smaller. */
int
val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
val_print_string (struct type *elttype, CORE_ADDR addr, int len,
struct ui_file *stream,
const struct value_print_options *options)
{
int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
@ -1325,6 +1327,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
int bytes_read;
gdb_byte *buffer = NULL; /* Dynamically growable fetch buffer. */
struct cleanup *old_chain = NULL; /* Top of the old cleanup chain. */
int width = TYPE_LENGTH (elttype);
/* First we need to figure out the limit on the number of characters we are
going to attempt to fetch and print. This is actually pretty simple. If
@ -1378,7 +1381,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
{
fputs_filtered (" ", stream);
}
LA_PRINT_STRING (stream, buffer, bytes_read / width, width, force_ellipsis, options);
LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width, force_ellipsis, options);
}
if (errcode != 0)

View File

@ -134,9 +134,10 @@ extern void print_decimal_chars (struct ui_file *, const gdb_byte *,
extern void print_hex_chars (struct ui_file *, const gdb_byte *,
unsigned int, enum bfd_endian);
extern void print_char_chars (struct ui_file *, const gdb_byte *,
unsigned int, enum bfd_endian);
extern void print_char_chars (struct ui_file *, struct type *,
const gdb_byte *, unsigned int, enum bfd_endian);
int read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
gdb_byte **buffer, int *bytes_read);
#endif

View File

@ -388,6 +388,8 @@ extern struct value *value_mark (void);
extern void value_free_to_mark (struct value *mark);
extern struct value *value_typed_string (char *ptr, int len,
struct type *char_type);
extern struct value *value_string (char *ptr, int len);
extern struct value *value_bitstring (char *ptr, int len);
@ -619,7 +621,7 @@ extern int common_val_print (struct value *val,
const struct value_print_options *options,
const struct language_defn *language);
extern int val_print_string (CORE_ADDR addr, int len, int width,
extern int val_print_string (struct type *elttype, CORE_ADDR addr, int len,
struct ui_file *stream,
const struct value_print_options *options);