From f870a310ee7fbfd6ccaea95d632063cbdbd2b9c9 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 5 Mar 2010 20:18:19 +0000 Subject: gdb 2010-03-05 Corinna Vinschen Tom Tromey * utils.c (host_char_to_target): Add 'gdbarch' argument. (parse_escape): Likewise. * python/py-utils.c (unicode_to_target_string): Update. (unicode_to_target_python_string): Update. (target_string_to_unicode): Update. * printcmd.c (printf_command): Update. * p-exp.y (yylex): Update. * objc-exp.y (yylex): Update. * mi/mi-parse.c: Include charset.h. (mi_parse_escape): New function. (mi_parse_argv): Use it. * jv-exp.y (yylex): Update. * i386-cygwin-tdep.c (i386_cygwin_auto_wide_charset): New function. (i386_cygwin_init_abi): Call set_gdbarch_auto_wide_charset. * gdbarch.sh (auto_charset, auto_wide_charset): New. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * defs.h (parse_escape): Update. * cli/cli-setshow.c: Include arch-utils.h. (do_setshow_command): Update. * cli/cli-cmds.c (echo_command): Update. * charset.h (target_charset, target_wide_charset): Update. * charset.c: Include arch-utils.h. (target_charset_name): Default to "auto". (target_wide_charset_name): Likewise. (show_target_charset_name): Handle "auto". (show_target_wide_charset_name): Likewise. (be_le_arch): New global. (set_be_le_names): Add 'gdbarch' argument. (validate): Likewise. Don't call set_be_le_names. (set_charset_sfunc, set_host_charset_sfunc) (set_target_charset_sfunc, set_target_wide_charset_sfunc): Update. (target_charset): Add 'gdbarch' argument. (target_wide_charset): Likewise. Remove 'byte_order' argument. (auto_target_charset_name): New global. (default_auto_charset, default_auto_wide_charset): New functions. (_initialize_charset): Set auto_target_charset_name. Allow "auto" for target charsets. Copy result of nl_langinfo. Use GetACP if USE_WIN32API. * c-lang.c (charset_for_string_type): Add 'gdbarch' argument, remove 'byte_order' argument. Update. (classify_type): Likewise. (c_emit_char): Update. (c_printchar): Update. (c_printstr): Update. (c_get_string): Update. (evaluate_subexp_c): Update. * arch-utils.h (default_auto_charset, default_auto_wide_charset): Declare. * python/python.c (gdbpy_target_charset): New function. (gdbpy_target_wide_charset): Likewise. (GdbMethods): Update. * NEWS: Update. gdb/doc * gdb.texinfo (Basic Python): Document target_charset and target_wide_charset. gdb/testsuite * gdb.python/py-prettyprint.py (pp_nullstr.to_string): Use gdb.target_charset. (pp_ns.to_string): Likewise. --- gdb/mi/mi-parse.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) (limited to 'gdb/mi') diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c index 8548b67..c3f5eeb 100644 --- a/gdb/mi/mi-parse.c +++ b/gdb/mi/mi-parse.c @@ -23,10 +23,83 @@ #include "defs.h" #include "mi-cmds.h" #include "mi-parse.h" +#include "charset.h" #include #include "gdb_string.h" +/* Like parse_escape, but leave the results as a host char, not a + target char. */ + +static int +mi_parse_escape (char **string_ptr) +{ + int c = *(*string_ptr)++; + switch (c) + { + case '\n': + return -2; + case 0: + (*string_ptr)--; + return 0; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + int i = host_hex_value (c); + int count = 0; + while (++count < 3) + { + c = (**string_ptr); + if (isdigit (c) && c != '8' && c != '9') + { + (*string_ptr)++; + i *= 8; + i += host_hex_value (c); + } + else + { + break; + } + } + return i; + } + + 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; + } + + return c; +} + static void mi_parse_argv (char *args, struct mi_parse *parse) { @@ -60,7 +133,7 @@ mi_parse_argv (char *args, struct mi_parse *parse) if (*chp == '\\') { chp++; - if (parse_escape (&chp) <= 0) + if (mi_parse_escape (&chp) <= 0) { /* Do not allow split lines or "\000" */ freeargv (argv); @@ -93,7 +166,7 @@ mi_parse_argv (char *args, struct mi_parse *parse) if (*chp == '\\') { chp++; - arg[len] = parse_escape (&chp); + arg[len] = mi_parse_escape (&chp); } else arg[len] = *chp++; -- cgit v1.1