public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-charset: update NEWS
@ 2009-01-17  2:46 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2009-01-17  2:46 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-charset has been updated
       via  6cce89c8e398e9f909d666c835127183200b7614 (commit)
       via  0821d75ffb521363ef35f2f84e20960bf14c19ea (commit)
      from  3ba4f9e029fb84916f6e16a4d4dfd941796669ce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 6cce89c8e398e9f909d666c835127183200b7614
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Jan 16 19:45:35 2009 -0700

    update NEWS
    update error messages
    fix a couple comments; add a FIXME
    add many more tests

commit 0821d75ffb521363ef35f2f84e20960bf14c19ea
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Jan 16 17:56:17 2009 -0700

    	* gdb.base/remote.exp (get_sizeof): Remove.
    	* gdb.base/long_long.exp (get_valueof, get_sizeof): Remove.
    	* gdb.base/dfp-test.exp (get_valueof, get_sizeof): Remove.
    	* gdb.base/sizeof.exp (get_valueof, get_sizeof): Remove.
    	* lib/gdb.exp (get_valueof): Move from long_long.exp.
    	(get_sizeof): Likewise.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                        |    1 +
 gdb/NEWS                             |   12 ++++
 gdb/c-exp.y                          |   10 ++--
 gdb/c-lang.c                         |    4 +-
 gdb/charset.c                        |    3 +-
 gdb/testsuite/ChangeLog              |   17 ++++++
 gdb/testsuite/gdb.base/charset.c     |   15 +++++-
 gdb/testsuite/gdb.base/charset.exp   |   98 +++++++++++++++++++++++++++++++---
 gdb/testsuite/gdb.base/dfp-test.exp  |   20 -------
 gdb/testsuite/gdb.base/long_long.exp |   20 -------
 gdb/testsuite/gdb.base/remote.exp    |   16 ------
 gdb/testsuite/gdb.base/sizeof.exp    |   18 ------
 gdb/testsuite/lib/gdb.exp            |   23 ++++++++
 13 files changed, 167 insertions(+), 90 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8a21ea7..88aa713 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -3,6 +3,7 @@
 
 	PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
 	PR i18n/9401, PR exp/9613:
+	* NEWS: Update
 	* dwarf2read.c (process_die) <DW_TAG_typedef>: Call read_type_die
 	before calling new_symbol.
 	* value.h (value_typed_string): Declare.
diff --git a/gdb/NEWS b/gdb/NEWS
index 4532f9e..c80f732 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,13 @@
 
 *** 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'.
+
 * 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
@@ -169,6 +176,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
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 1873980..45cd282 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -629,7 +629,7 @@ exp	:	string_exp
 				case C_STRING_32:
 				  if (type != C_STRING
 				      && type != $1.tokens[i].type)
-				    error ("undefined string concatenation");
+				    error ("Undefined string concatenation.");
 				  type = $1.tokens[i].type;
 				  break;
 				default:
@@ -1429,9 +1429,8 @@ c_parse_escape (char **ptr, struct obstack *output)
 	}
       break;
 
-      /* Octal escapes do not undergo character set
-	 conversion, so keep the escape sequence for
-	 later.  */
+      /* Octal escapes do not undergo character set conversion, so
+	 keep the escape sequence for later.  */
     case '0':
     case '1':
     case '2':
@@ -1623,6 +1622,9 @@ parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
 	{
 	  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;
 	}
     }
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 85d1672..3e508cc 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -558,8 +558,8 @@ convert_ucn (char *p, char *limit, const char *dest_charset,
   return p;
 }
 
-/* Emit a character, VALUE, which was specified numerically to OUTPUT.
-   TYPE is the target character type.  */
+/* 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,
diff --git a/gdb/charset.c b/gdb/charset.c
index 6844640..c024377 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -363,7 +363,8 @@ convert_between_encodings (const char *from, const char *to,
 
 		/* Invalid input sequence.  */
 		if (translit == translit_none)
-		  error ("Could not convert character");
+		  error (_("Could not convert character to `%s' character set"),
+			 to);
 
 		/* We emit escape sequence for the bytes, skip them,
 		   and try again.  */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 60f3b5e..ee59b1f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2009-01-16  Tom Tromey  <tromey@redhat.com>
+
+	* 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.
+	* gdb.base/charset.c (char16_t, char32_t): New typedefs.
+	(uvar, Uvar): New globals.
+
+2009-01-16  Tom Tromey  <tromey@redhat.com>
+
+	* gdb.base/remote.exp (get_sizeof): Remove.
+	* gdb.base/long_long.exp (get_valueof, get_sizeof): Remove.
+	* gdb.base/dfp-test.exp (get_valueof, get_sizeof): Remove.
+	* gdb.base/sizeof.exp (get_valueof, get_sizeof): Remove.
+	* lib/gdb.exp (get_valueof): Move from long_long.exp.
+	(get_sizeof): Likewise.
+
 2009-01-14  Tom Tromey  <tromey@redhat.com>
 
 	* gdb.base/charset.exp (parse_show_charset_output): Update.
diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
index dc18979..55a50ce 100644
--- a/gdb/testsuite/gdb.base/charset.c
+++ b/gdb/testsuite/gdb.base/charset.c
@@ -50,10 +50,21 @@ 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.  */
-typedef unsigned long wchar_t;
+   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[],
              char x,
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index b52b272..2710915 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -100,9 +100,6 @@ if {[lsearch $show_charset $show_host_charset] >= 0} {
     fail "check `show host-charset' against `show charset'"
 }
 
-# Disable pagination.
-gdb_test "set height 0" ""
-
 # Get the list of supported (host) charsets as possible completions.
 send_gdb "set charset \t\t"
 
@@ -406,9 +403,21 @@ 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 {ASCII ISO-8859-1 EBCDIC-US IBM1047 UCS-4} {
-    if {$target_charset == "UCS-4"} {
+foreach target_charset $charset_subset {
+    if {$target_charset == "UCS-4" || $target_charset == "UCS-2"} {
 	set param target-wide-charset
 	set L L
     } else {
@@ -444,8 +453,14 @@ foreach target_charset {ASCII ISO-8859-1 EBCDIC-US IBM1047 UCS-4} {
     # 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.
@@ -557,4 +572,73 @@ foreach target_charset {ASCII ISO-8859-1 EBCDIC-US IBM1047 UCS-4} {
              "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\"\\\\u000ec\"" \
+      "$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_test "set target-charset ASCII" ""
+gdb_test "set host-charset ISO-8859-1" ""
+# Note that the escape here is translated by Tcl.
+gdb_test "print \"\242\"" \
+  "Could not convert character to `ASCII' character set"
+
 gdb_exit 
diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp
index 32f36a9..94fcb41 100644
--- a/gdb/testsuite/gdb.base/dfp-test.exp
+++ b/gdb/testsuite/gdb.base/dfp-test.exp
@@ -43,26 +43,6 @@ if ![runto_main] then {
     continue
 }
 
-# Detect the size of the target's basic types (from gdb.base/long_long.exp).
-
-proc get_valueof { fmt exp default } {
-    global gdb_prompt
-    send_gdb "print${fmt} ${exp}\n"
-    gdb_expect {
-	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
-	    set val $expect_out(1,string)
-	}
-	timeout {
-	    set val ${default}
-	}
-    }
-    return ${val}
-}
-
-proc get_sizeof { type default } {
-    return [get_valueof "/d" "sizeof (${type})" $default]
-}
-
 set sizeof_long [get_sizeof "long" 4]
 
 proc d32_set_tests {} {
diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
index e585396..d0ad5ba 100644
--- a/gdb/testsuite/gdb.base/long_long.exp
+++ b/gdb/testsuite/gdb.base/long_long.exp
@@ -74,26 +74,6 @@ gdb_expect {
 
 # Detect the size of the target's basic types.
 
-proc get_valueof { fmt exp default } {
-    global gdb_prompt
-    send_gdb "print${fmt} ${exp}\n"
-    gdb_expect {
-	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
-	    set val $expect_out(1,string)
-	    pass "get value of ${exp} ($val)"
-	}
-	timeout {
-	    set size ${default}
-	    fail "get value of ${exp} (timeout)"
-	}
-    }
-    return ${val}
-}
-
-proc get_sizeof { type default } {
-    return [get_valueof "/d" "sizeof (${type})" $default]
-}
-
 set sizeof_char [get_sizeof "char" 1]
 set sizeof_short [get_sizeof "short" 2]
 set sizeof_int [get_sizeof "int" 4]
diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp
index 0dee13a..113c56b 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -125,22 +125,6 @@ gdb_load_timed $binfile "limit" 0
 # Query GDB for the size of various types
 #
 
-proc get_sizeof { type default } {
-    global gdb_prompt
-    send_gdb "print/d sizeof (${type})\n"
-    gdb_expect {
-	-re "\\$\[0-9\]* = (\[0-9\]*).*$gdb_prompt $" {
-	    set size $expect_out(1,string)
-	    pass "get sizeof ${type} ($size)"
-	}
-	timeout {
-	    set size ${default}
-	    fail "get sizeof ${type} (timeout)"
-	}
-    }
-    return ${size}
-}
-
 # Get the size of random_data table (defaults to 48K).
 set sizeof_random_data [get_sizeof "random_data" 48*1024]
 
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index 61a6be3..82f0da2 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -61,24 +61,6 @@ if ![runto_main] then {
 # Query GDB for the size of various types
 #
 
-proc get_valueof { fmt exp default } {
-    global gdb_prompt
-
-    set test "get valueof \"${exp}\""
-    set val ${default}
-    gdb_test_multiple "print${fmt} ${exp}" "$test" {
-	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
-	    set val $expect_out(1,string)
-	    pass "$test ($val)"
-	}
-    }
-    return ${val}
-}
-
-proc get_sizeof { type default } {
-    return [get_valueof "/d" "sizeof (${type})" $default]
-}
-
 gdb_test "next"
 
 set sizeof_char [get_sizeof "char" 1]
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b0059b7..e329b96 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2878,3 +2878,26 @@ proc prepare_for_testing { testname executable {sources ""} {options {debug}}} {
 
     return 0
 }
+
+proc get_valueof { fmt exp default } {
+    global gdb_prompt
+
+    set test "get valueof \"${exp}\""
+    set val ${default}
+    gdb_test_multiple "print${fmt} ${exp}" "$test" {
+	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
+	    set val $expect_out(1,string)
+	    pass "$test ($val)"
+	}
+	timeout {
+	    set size ${default}
+	    fail "get value of ${exp} (timeout)"
+	}
+    }
+    return ${val}
+}
+
+proc get_sizeof { type default } {
+    return [get_valueof "/d" "sizeof (${type})" $default]
+}
+


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-17  2:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-17  2:46 [SCM] archer-tromey-charset: update NEWS tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).