From patchwork Tue Jul 9 17:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 33638 Received: (qmail 35091 invoked by alias); 9 Jul 2019 17:41:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 35083 invoked by uid 89); 9 Jul 2019 17:41:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mailsec105.isp.belgacom.be Received: from mailsec105.isp.belgacom.be (HELO mailsec105.isp.belgacom.be) (195.238.20.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jul 2019 17:41:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1562694087; x=1594230087; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wRSsB7Wl3DNojHZvAgYW2ypRMIbWVu5yL8k2e1N0EyE=; b=ilWWSKJXTMH7FDgW1CmuGy7DNl7Fe7m1JaNHGpro/5F7mfwOJDb/uj1y +DiyrEm244qaWPP5t8NvVHlFTx2lCQ==; Received: from 96.218-128-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.128.218.96]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 09 Jul 2019 19:41:25 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [PUSHED/OBVIOUS] Fix printcmds.exp failure for wide strings tests. Date: Tue, 9 Jul 2019 19:41:18 +0200 Message-Id: <20190709174118.29243-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes 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. --- 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 a7d09cb802..3df5e587eb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-07-09 Sergio Durigan Junior + + * 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 * 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 0e3126bcf2..edd5b31fd4 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