From patchwork Thu Jan 19 21:20:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 63425 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A135E385B533 for ; Thu, 19 Jan 2023 21:20:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 33FFF3858434 for ; Thu, 19 Jan 2023 21:20:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33FFF3858434 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-lf1-x134.google.com with SMTP id y25so5090128lfa.9 for ; Thu, 19 Jan 2023 13:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=56sn115Q8shH0brlRH+xDsOrdg9ejrn9mghfjBxg8lc=; b=dA31OOonkXTQQG8fnJti4zySomKVeD1tN1MERpCZXt+t9eI0jzafqe3rnzU5evru4o QZzD1gHJwVmuCQzFmte3wwykvhaZTeCcInPzqvZMAkdKgGGKPrtNacK0xlWo8pFWQd9M uarX6r1U/ndEQTGcrWz2UU0lkuuhMhBruFPwqQgHiAZXdKUBXUBkyyyIAZsrU2beN4I1 WBtuaQg7hd/b80c91ZcZqAkPTO//pfE0NbCQMC+geEpvzrZ9rm3TkR6ZuU2yStXeQro/ wwsdDRafIPXC6fOvZGyJR9VXAUPCFyFfd3lHaZri26UWNjRohasqJEbrFBDai4kuDQqF YewQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=56sn115Q8shH0brlRH+xDsOrdg9ejrn9mghfjBxg8lc=; b=MvZLomh3k5CDfXY7e0lUTLSOZWOFZY2qM5JBgNLEDw/kNwQObv769U2jQytpkHqiO0 Z+s/cnjfEce2qlWw8lPzp4ljIn9CcgiDbNy0vwZVYBNxVVEABUfrqnFDfo0myhboVjoQ sJPAY2J4YeHiRNiZVtXTpWfZ2QNg8jBmyDGrLyY91iDuPR1k7apfdUth/X1wDub3NMpy pLE3wtmVk7lgTBrAqXZ+zZfwz9VkUizaDcFij96ipSuFs67OV8zOHGLC2YylikqWssI3 kiEHh7YDAqBUWOTmdtw59xpj1y64Bksbwd1iN8fMY2OsZdCmU28sGikz94GHAqKBT79q MH2g== X-Gm-Message-State: AFqh2kqvD761k+rq3/fzihD7jKHzMrqO3NI9OQkIs/LiMbxvb2MOdvER rp4J5iu9zED71B0Rz9/Fz8ohvg== X-Google-Smtp-Source: AMrXdXvbFStlNmXssTMBnCHqtmlxVxMqtQhD5S0/t7e+JYxIX/6jHEb7/xeR+p1YDtU6EFeFvm7Mfg== X-Received: by 2002:a05:6512:24b:b0:4cb:64:ba93 with SMTP id b11-20020a056512024b00b004cb0064ba93mr2578264lfo.36.1674163214650; Thu, 19 Jan 2023 13:20:14 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id v9-20020a056512048900b004cb43eb09dfsm6009332lfq.123.2023.01.19.13.20.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2023 13:20:11 -0800 (PST) Date: Thu, 19 Jan 2023 21:20:06 +0000 (GMT) From: "Maciej W. Rozycki" To: Simon Marchi cc: gdb-patches@sourceware.org, Andrew Burgess , Tom Tromey , Simon Sobisch Subject: [COMMITTED PATCH v9 6/6] GDB/testsuite: Expand for character string limiting options In-Reply-To: Message-ID: References: <4a937b46-d937-619d-419d-93daefb92927@polymtl.ca> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Andrew Burgess Modify test cases that verify the operation of the array element limit with character strings such that they are executed twice, once with the `set print characters' option set to `elements' and the limit controlled with the `set print elements' option, and then again with the limit controlled with the `set print characters' option instead. Similarly with the `-elements' and `-characters' options for the `print' command. Additionally verify that said `print' command options combined yield the expected result. Verify correct $_gdb_setting and $_gdb_setting_str values for the `print characters' setting, in particular the `void' value for the `elements' default, which has no corresponding integer value exposed. Add Guile and Python coverage for the `print characters' GDB setting. There are new tests for Ada and Pascal, as the string printing code for these languages is different than the generic string printing code used by other languages. Modula2 also has different string printing code, but (a) this is similar to Pascal, and (b) there are no existing modula2 tests written in Modula2, so I'm not sure how I'd even test the Modula2 string printing. Co-Authored-By: Maciej W. Rozycki Approved-By: Simon Marchi --- Changes from v8: - Update internal Python test case documentation. - Change the Pascal test case to use `runto_main'. - Fix the Ada test case to use `require allow_ada_tests'. - Update copyright years for new files throughout. - Fix a minor formatting issue with a closing brace. Changes from v7: - py-parameter.exp regenerated for the special case of returning -1 for the value of `unlimited' with `var_pinteger' parameters in Python code. No change from v6.1. Changes from v6: - Add tests for $_gdb_setting and $_gdb_setting_str values with `print characters' to cover the `void' value in particular. Changes from v5: - Update testing for the use of `set print characters 0' now permitted. - Add Guile and Python `print characters' testing. No changes from v4. Changes from v3: - Split off from what is now 7/8; see the change log there for earlier changes. - Remove test case modifications to switch from the `set print elements' command to `set print characters'; instead run them twice with each of the two commands verified. - Likewise with the `print -elements' and `print -characters' commands. - Also cover `print -elements ... -characters ...', i.e. both options combined. - Expand the Ada and Pascal test cases to cover `set print characters elements' too. --- gdb/testsuite/gdb.ada/str_chars.exp | 70 ++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/str_chars/foo.adb | 26 +++++++++ gdb/testsuite/gdb.base/printcmds.exp | 68 +++++++++++++++++-------- gdb/testsuite/gdb.base/setshow.exp | 22 ++++++++ gdb/testsuite/gdb.guile/scm-parameter.exp | 11 +++- gdb/testsuite/gdb.pascal/str-chars.exp | 55 ++++++++++++++++++++ gdb/testsuite/gdb.pascal/str-chars.pas | 28 ++++++++++ gdb/testsuite/gdb.python/py-format-string.exp | 51 +++++++++++++----- gdb/testsuite/gdb.python/py-parameter.exp | 13 ++++ 9 files changed, 306 insertions(+), 38 deletions(-) gdb-aburgess-print-elements-characters-test.diff Index: src/gdb/testsuite/gdb.ada/str_chars.exp =================================================================== --- /dev/null +++ src/gdb/testsuite/gdb.ada/str_chars.exp @@ -0,0 +1,70 @@ +# Copyright 2023 Free Software Foundation, Inc. +# +# 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 . + +# Test GDB's 'set print characters' setting works for Ada strings. + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] +if ![runto "foo.adb:$bp_location" ] then { + return -1 +} + +gdb_test "print Arg" \ + " = \"abcdefghijklmnopqrstuvwxyz\"" \ + "print with default settings" + +gdb_test_no_output "set print characters 26" +gdb_test "print Arg" \ + " = \"abcdefghijklmnopqrstuvwxyz\"" \ + "print with character limit of 26" + +gdb_test "print -characters 11 -- Arg" \ + " = \"abcdefghijk\"\\.\\.\\." \ + "print with character limit of 11" + +gdb_test_no_output "set print characters 10" +gdb_test "print Arg" \ + " = \"abcdefghij\"\\.\\.\\." \ + "print with character limit of 10" + +gdb_test_no_output "set print characters unlimited" +gdb_test "print Arg" \ + " = \"abcdefghijklmnopqrstuvwxyz\"" \ + "print with unlimited character limit" + +# The 'set print elements' command used to control printing of characters +# in a string, before we created 'set print characters'. This test makes +# sure that 'set print elements' doens't effect string printing any more. +gdb_test_no_output "set print elements 12" +gdb_test "print Arg" \ + " = \"abcdefghijklmnopqrstuvwxyz\"" \ + "print with unlimited character limit, but lower element limit" + +# Except when 'set print characters elements' has been used. +gdb_test_no_output "set print characters elements" +gdb_test "print Arg" \ + " = \"abcdefghijkl\"\\.\\.\\." \ + "print with character limit of elements" Index: src/gdb/testsuite/gdb.ada/str_chars/foo.adb =================================================================== --- /dev/null +++ src/gdb/testsuite/gdb.ada/str_chars/foo.adb @@ -0,0 +1,26 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- 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 . + +procedure Foo is + + procedure Blah (Arg : String) is + begin + null; -- STOP + end; + +begin + + Blah ("abcdefghijklmnopqrstuvwxyz"); +end Foo; Index: src/gdb/testsuite/gdb.base/printcmds.exp =================================================================== --- src.orig/gdb/testsuite/gdb.base/printcmds.exp +++ src/gdb/testsuite/gdb.base/printcmds.exp @@ -449,13 +449,14 @@ proc test_print_all_chars {} { } # Test interaction of the number of print elements to print and the -# repeat count, set to the default of 10. +# repeat count, set to the default of 10. SETTING is the print +# setting to verify, either "elements" or "characters". -proc test_print_repeats_10 {} { +proc test_print_repeats_10_one { setting } { global gdb_prompt decimal for { set x 1 } { $x <= 16 } { incr x } { - gdb_test_no_output "set print elements $x" "elements $x repeats" + gdb_test_no_output "set print $setting $x" "$setting $x repeats" for { set e 1 } { $e <= 16 } {incr e } { set v [expr $e - 1] set command "p &ctable2\[${v}*16\]" @@ -495,11 +496,18 @@ proc test_print_repeats_10 {} { set xstr "${xstr}\[.\]\[.\]\[.\]" } set string " = \[(\]unsigned char \[*\]\[)\] ${a}${xstr}" - gdb_test "$command" "$string" "$command with print elements set to $x" + gdb_test "$command" "$string" "$command with print $setting set to $x" } } } +proc test_print_repeats_10 {} { + foreach_with_prefix setting { "elements" "characters" } { + test_print_repeats_10_one $setting + } + gdb_test_no_output "set print characters elements" +} + # This tests whether GDB uses the correct element content offsets # (relative to the complete `some_struct' value) when counting value # repetitions. @@ -512,7 +520,7 @@ proc test_print_repeats_embedded_array { "correct element repeats in array embedded at offset > 0" } -proc test_print_strings {} { +proc test_print_strings_one { setting } { global gdb_prompt decimal # We accept "(unsigned char *) " before the string. char vs. unsigned char @@ -520,35 +528,35 @@ proc test_print_strings {} { # Test that setting print elements unlimited doesn't completely suppress # printing; this was a bug in older gdb's. - gdb_test_no_output "set print elements 0" + gdb_test_no_output "set print $setting 0" gdb_test "p teststring" \ - " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 0" - gdb_test_no_output "set print elements 1" + " = (.unsigned char .. )?\"teststring contents\"" "p teststring with $setting set to 0" + gdb_test_no_output "set print $setting 1" gdb_test "p teststring" \ - " = (.unsigned char .. )?\"t\"\\.\\.\\." "p teststring with elements set to 1" - gdb_test_no_output "set print elements 5" + " = (.unsigned char .. )?\"t\"\\.\\.\\." "p teststring with $setting set to 1" + gdb_test_no_output "set print $setting 5" gdb_test "p teststring" \ - " = (.unsigned char .. )?\"tests\"\\.\\.\\." "p teststring with elements set to 5" - gdb_test_no_output "set print elements 19" + " = (.unsigned char .. )?\"tests\"\\.\\.\\." "p teststring with $setting set to 5" + gdb_test_no_output "set print $setting 19" gdb_test "p teststring" \ - " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 19" - gdb_test_no_output "set print elements 20" + " = (.unsigned char .. )?\"teststring contents\"" "p teststring with $setting set to 19" + gdb_test_no_output "set print $setting 20" gdb_test "p teststring" \ - " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 20" + " = (.unsigned char .. )?\"teststring contents\"" "p teststring with $setting set to 20" - gdb_test "p -elements 1 -- teststring" \ + gdb_test "p -$setting 1 -- teststring" \ " = (.unsigned char .. )?\"t\"\\.\\.\\." - gdb_test "p -elements 5 -- teststring" \ + gdb_test "p -$setting 5 -- teststring" \ " = (.unsigned char .. )?\"tests\"\\.\\.\\." - gdb_test "p -elements 19 -- teststring" \ + gdb_test "p -$setting 19 -- teststring" \ " = (.unsigned char .. )?\"teststring contents\"" - gdb_test "p -elements 20 -- teststring" \ + gdb_test "p -$setting 20 -- teststring" \ " = (.unsigned char .. )?\"teststring contents\"" gdb_test "print teststring2" \ " = \\(charptr\\) \"more contents\"" - gdb_test_no_output "set print elements 8" + gdb_test_no_output "set print $setting 8" # Set the target-charset to ASCII, because the output varies from # different charset. @@ -620,6 +628,26 @@ proc test_print_strings {} { gdb_test "p &ctable1\[31*8\]" \ " = \\(unsigned char \\*\\) \"\\\\370\\\\371\\\\372\\\\373\\\\374\\\\375\\\\376\\\\377\"..." } + + gdb_test_no_output "set print $setting unlimited" +} + +proc test_print_strings {} { + + foreach_with_prefix setting { "elements" "characters" } { + test_print_strings_one $setting + } + + gdb_test "p -elements 8 -- teststring" \ + " = (.unsigned char .. )?\"teststring contents\"" + gdb_test "p -characters 8 -- teststring" \ + " = (.unsigned char .. )?\"teststri\"\\.\\.\\." + gdb_test "p -elements 8 -characters elements -- teststring" \ + " = (.unsigned char .. )?\"teststri\"\\.\\.\\." + + with_test_prefix strings { + gdb_test_no_output "set print characters elements" + } } proc test_print_int_arrays {} { Index: src/gdb/testsuite/gdb.base/setshow.exp =================================================================== --- src.orig/gdb/testsuite/gdb.base/setshow.exp +++ src/gdb/testsuite/gdb.base/setshow.exp @@ -374,6 +374,27 @@ proc_with_prefix test_setshow_listsize { gdb_test "show listsize" "Number of source lines gdb will list by default is 100..*" "show listsize (100)" } +proc_with_prefix test_setshow_print_characters {} { + clean_restart + + gdb_test "p \$_gdb_setting(\"print characters\")" " = void" \ + "_gdb_setting print characters default" + gdb_test "p \$_gdb_setting_str(\"print characters\")" " = \"elements\"" \ + "_gdb_setting_str print characters default" + + gdb_test_no_output "set print characters unlimited" + gdb_test "p \$_gdb_setting(\"print characters\")" " = 0" \ + "_gdb_setting print characters unlimited" + gdb_test "p \$_gdb_setting_str(\"print characters\")" " = \"unlimited\"" \ + "_gdb_setting_str print characters unlimited" + + gdb_test_no_output "set print characters 1" + gdb_test "p \$_gdb_setting(\"print characters\")" " = 1" \ + "_gdb_setting print characters 1" + gdb_test "p \$_gdb_setting_str(\"print characters\")" " = \"1\"" \ + "_gdb_setting_str print characters 1" +} + proc_with_prefix test_setshow_prompt {} { clean_restart @@ -493,6 +514,7 @@ test_setshow_height test_setshow_history test_setshow_language test_setshow_listsize +test_setshow_print_characters test_setshow_prompt test_setshow_radix test_setshow_width Index: src/gdb/testsuite/gdb.guile/scm-parameter.exp =================================================================== --- src.orig/gdb/testsuite/gdb.guile/scm-parameter.exp +++ src/gdb/testsuite/gdb.guile/scm-parameter.exp @@ -104,6 +104,7 @@ foreach_with_prefix param { "listsize" "print elements" "max-completions" + "print characters" } { set param_range_error "integer -1 out of range" set param_type_error \ @@ -117,7 +118,8 @@ foreach_with_prefix param { set param_get_minus_one -1 set param_set_minus_one "" } - "print elements" { + "print elements" - + "print characters" { set param_get_zero "#:unlimited" set param_get_minus_one "#:unlimited" set param_set_minus_one $param_range_error @@ -152,6 +154,13 @@ foreach_with_prefix param { gdb_test "guile (print (parameter-value \"$param\"))" \ "#:unlimited" "test value of 'unlimited'" + + if {$param == "print characters"} { + gdb_test_no_output "set $param elements" "test set to 'elements'" + + gdb_test "guile (print (parameter-value \"$param\"))" \ + "#:elements" "test value of 'elements'" + } } foreach_with_prefix kind { Index: src/gdb/testsuite/gdb.pascal/str-chars.exp =================================================================== --- /dev/null +++ src/gdb/testsuite/gdb.pascal/str-chars.exp @@ -0,0 +1,55 @@ +# Copyright 2023 Free Software Foundation, Inc. +# +# 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 . + +load_lib "pascal.exp" + +standard_testfile .pas + +if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { + return -1 +} + +clean_restart ${testfile} + +if { ![runto_main] } { + return +} + +gdb_breakpoint ${srcfile}:[gdb_get_line_number "set breakpoint 1 here"] + +gdb_continue_to_breakpoint "continue to breakpoint" + +gdb_test "print message" " = 'abcdefghijklmnopqrstuvwxyz'" \ + "print message with the default settings" + +gdb_test_no_output "set print elements 10" +gdb_test "print message" " = 'abcdefghij'\\.\\.\\." \ + "print message with 'print elements' set to 10" + +gdb_test_no_output "set print characters 20" +gdb_test "print message" " = 'abcdefghijklmnopqrst'\\.\\.\\." \ + "print message with 'print characters' set to 20" + +gdb_test_no_output "set print elements 15" +gdb_test "print message" " = 'abcdefghijklmnopqrst'\\.\\.\\." \ + "print message with 'print elements' set to 15" + +gdb_test_no_output "set print characters unlimited" +gdb_test "print message" " = 'abcdefghijklmnopqrstuvwxyz'" \ + "print message with 'print characters' set to unlimited" + +gdb_test_no_output "set print characters elements" +gdb_test "print message" " = 'abcdefghijklmno'\\.\\.\\." \ + "print message with 'print characters' set to elements" Index: src/gdb/testsuite/gdb.pascal/str-chars.pas =================================================================== --- /dev/null +++ src/gdb/testsuite/gdb.pascal/str-chars.pas @@ -0,0 +1,28 @@ +{ + Copyright 2023 Free Software Foundation, Inc. + + 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 . +} + +program str_char; + +var + message : string; + +begin + + message := 'abcdefghijklmnopqrstuvwxyz'; + writeln (message) { set breakpoint 1 here } + +end. Index: src/gdb/testsuite/gdb.python/py-format-string.exp =================================================================== --- src.orig/gdb/testsuite/gdb.python/py-format-string.exp +++ src/gdb/testsuite/gdb.python/py-format-string.exp @@ -704,13 +704,17 @@ proc_with_prefix test_static_members {} } # Test the max_elements option for gdb.Value.format_string. -proc_with_prefix test_max_elements {} { +# SETTING is the print setting to verify, either "elements" +# or "characters". UNLIMITED is the numeric value to use +# for the "unlimited" setting. + +proc test_max_string_one { setting unlimited } { global current_lang global default_pointer_regexp # 200 is the default maximum number of elements, so setting it should # not change the output. - set opts "max_elements=200" + set opts "max_$setting=200" with_test_prefix $opts { check_format_string "a_point_t" $opts check_format_string "a_point_t_pointer" $opts @@ -721,8 +725,10 @@ proc_with_prefix test_max_elements {} { check_format_string "a_binary_string" $opts check_format_string "a_binary_string_array" $opts check_format_string "a_big_string" $opts - check_format_string "an_array" $opts - check_format_string "an_array_with_repetition" $opts + if { $setting == "elements" } { + check_format_string "an_array" $opts + check_format_string "an_array_with_repetition" $opts + } check_format_string "a_symbol_pointer" $opts if { $current_lang == "c++" } { @@ -731,7 +737,7 @@ proc_with_prefix test_max_elements {} { } } - set opts "max_elements=3" + set opts "max_$setting=3" with_test_prefix $opts { check_format_string "a_point_t" $opts check_format_string "a_point_t_pointer" $opts @@ -748,9 +754,11 @@ proc_with_prefix test_max_elements {} { "\"hell\"..." check_format_string "a_big_string" $opts \ [get_cut_big_string 3] - check_format_string "an_array" $opts - check_format_string "an_array_with_repetition" $opts \ - "\\{1, 3 ...\\}" + if { $setting == "elements"} { + check_format_string "an_array" $opts + check_format_string "an_array_with_repetition" $opts \ + "\\{1, 3 ...\\}" + } check_format_string "a_symbol_pointer" $opts if { $current_lang == "c++" } { @@ -759,9 +767,9 @@ proc_with_prefix test_max_elements {} { } } - # Both 1,000 (we don't have that many elements) and 0 (unlimited) should + # Both 1,000 (we don't have that many elements) and unlimited should # mean no truncation. - foreach opts { "max_elements=1000" "max_elements=0" } { + foreach opts [list "max_$setting=1000" "max_$setting=$unlimited"] { with_test_prefix $opts { check_format_string "a_point_t" $opts check_format_string "a_point_t_pointer" $opts @@ -773,8 +781,10 @@ proc_with_prefix test_max_elements {} { check_format_string "a_binary_string_array" $opts check_format_string "a_big_string" $opts \ [get_cut_big_string 1000] - check_format_string "an_array" $opts - check_format_string "an_array_with_repetition" $opts + if { $setting == "elements"} { + check_format_string "an_array" $opts + check_format_string "an_array_with_repetition" $opts + } check_format_string "a_symbol_pointer" $opts if { $current_lang == "c++" } { @@ -784,15 +794,24 @@ proc_with_prefix test_max_elements {} { } } - with_temp_option "set print elements 4" "set print elements 200" { + with_temp_option "set print $setting 4" "set print $setting 200" { check_format_string "a_string" "" \ "${default_pointer_regexp} \"hell\"..." check_format_string "a_binary_string" "" \ "${default_pointer_regexp} \"hell\"..." check_format_string "a_binary_string_array" "" \ "\"hell\"..." - check_format_string "an_array_with_repetition" "" \ - "\\{1, 3 ...\\}" + if { $setting == "elements"} { + check_format_string "an_array_with_repetition" "" \ + "\\{1, 3 ...\\}" + } + } +} + +proc_with_prefix test_max_string {} { + foreach_with_prefix setting { "elements" "characters" } { + test_max_string_one $setting \ + [string map {elements 0 characters 4294967295} $setting] } } @@ -1152,7 +1171,7 @@ proc_with_prefix test_all_common {} { test_deref_refs test_actual_objects test_static_members - test_max_elements + test_max_string test_max_depth test_repeat_threshold test_format Index: src/gdb/testsuite/gdb.python/py-parameter.exp =================================================================== --- src.orig/gdb/testsuite/gdb.python/py-parameter.exp +++ src/gdb/testsuite/gdb.python/py-parameter.exp @@ -337,6 +337,7 @@ proc_with_prefix test_gdb_parameter { } "listsize" "print elements" "max-completions" + "print characters" } { clean_restart @@ -349,7 +350,8 @@ proc_with_prefix test_gdb_parameter { } set param_get_unlimited None set param_set_minus_one "" } - "print elements" { + "print elements" - + "print characters" { set param_get_zero None set param_get_minus_one None set param_get_none None @@ -398,6 +400,15 @@ proc_with_prefix test_gdb_parameter { } gdb_test "python print(gdb.parameter('$param'))" \ $param_get_unlimited "test value of 'unlimited'" + + if {$param == "print characters"} { + gdb_test_no_output \ + "python gdb.set_parameter('$param', 'elements')" \ + "test set to 'elements'" + + gdb_test "python print(gdb.parameter('$param'))" \ + elements "test value of 'elements'" + } } clean_restart