public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix printcmds.exp failure for wide strings tests.
Date: Tue, 09 Jul 2019 17:39:00 -0000	[thread overview]
Message-ID: <20190709173941.29400.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0826779b99b49f7f8df5d186f3c481b6007010d4

commit 0826779b99b49f7f8df5d186f3c481b6007010d4
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Tue Jul 9 19:36:17 2019 +0200

    Fix printcmds.exp failure for wide strings tests.
    
    wchar_t type must be known to create wide strings.
    As this type is predefined when current GDB language is C++,
    switch to c++ for the wide strings tests.
    
    Problem analysis and fix by Sergio.

Diff:
---
 gdb/testsuite/ChangeLog              |  6 ++++++
 gdb/testsuite/gdb.base/printcmds.exp | 29 ++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a7d09cb..3df5e58 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-09  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* gdb.base/printcmds.exp (test_printf_convenience_var): Set
+	language to "c++" before dealing with wchar_t.  Remove DO_WSTRING
+	argument and update callers.
+
 2019-07-09  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.arch/amd64-break-on-asm-line.S: New file.
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 0e3126b..edd5b31 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -935,11 +935,8 @@ proc test_repeat_bytes {} {
 # Test printf of convenience variables.
 # These tests can be done with or without a running inferior.
 # PREFIX ensures uniqueness of test names.
-# DO_WSTRING 1 tells to test printf of wide strings.  Wide strings tests
-# must be skipped (DO_WSTRING 0) if the wchar_t type is not yet known by
-# GDB, as this type is needed to create wide strings.
 
-proc test_printf_convenience_var {prefix do_wstring} {
+proc test_printf_convenience_var {prefix} {
 
     with_test_prefix "conv var: $prefix" {
 	gdb_test_no_output "set var \$cstr = \"abcde\"" "set \$cstr"
@@ -958,12 +955,16 @@ proc test_printf_convenience_var {prefix do_wstring} {
 	gdb_test_no_output "set language auto" "set language auto"
 	gdb_test "printf \"astr val = %s\\n\", \$astr" "astr val = fghij" \
 	    "printf \$astr, auto language"
-	if {$do_wstring} {
-	    gdb_test_no_output "set var \$wstr = L\"facile\"" \
-		"set \$wstr"
-	    gdb_test "printf \"wstr val = %ls\\n\", \$wstr" \
-		"wstr val = facile" "printf \$wstr"
-	}
+	# Wide strings can only be created when wchar_t type is known.
+	# Switch to c++ for the wide strings tests, as wchar_t is predefined
+	# when current language is c++.
+	# See above "set language ada" about why we use gdb_test.
+	gdb_test "set language c++" ".*" "set language c++"
+	gdb_test_no_output "set var \$wstr = L\"facile\"" \
+	    "set \$wstr"
+	gdb_test "printf \"wstr val = %ls\\n\", \$wstr" \
+	    "wstr val = facile" "printf \$wstr"
+	gdb_test_no_output "set language auto" "set language auto, wstring"
     }
 }
 
@@ -985,9 +986,7 @@ gdb_test "print \$cvar = \"abc\"" " = \"abc\""
 gdb_test "print sizeof (\$cvar)" " = 4"
 
 # Similarly, printf of a string convenience var should work without a target.
-# At this point, we cannot create a wide string convenience var, as the
-# wchar_t type is not yet known, so skip the wide string tests.
-test_printf_convenience_var "no target" 0
+test_printf_convenience_var "no target"
 
 # GDB used to complete the explicit location options even when
 # printing expressions.
@@ -1019,11 +1018,11 @@ if ![runto_main] then {
 }
 
 # With a running target, printf convenience vars should of course work.
-test_printf_convenience_var "with target" 1
+test_printf_convenience_var "with target"
 
 # It should also work when inferior function calls are forbidden.
 gdb_test_no_output "set may-call-functions off"
-test_printf_convenience_var "with target, may-call-functions off" 1
+test_printf_convenience_var "with target, may-call-functions off"
 gdb_test_no_output "set may-call-functions on"
 
 test_integer_literals_accepted


                 reply	other threads:[~2019-07-09 17:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190709173941.29400.qmail@sourceware.org \
    --to=philippe@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).