From patchwork Tue Jun 18 00:38:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 33169 Received: (qmail 40077 invoked by alias); 18 Jun 2019 00:39:07 -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 40065 invoked by uid 89); 18 Jun 2019 00:39:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=UD:settings.exp, settingsexp, settings.exp X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jun 2019 00:39:06 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBB4D3081244; Tue, 18 Jun 2019 00:39:04 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D83D18E36; Tue, 18 Jun 2019 00:39:04 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [PATCH v2 1/4] Fix defaults of some "maint test-settings" subcommands Date: Tue, 18 Jun 2019 01:38:59 +0100 Message-Id: <20190618003902.19805-2-palves@redhat.com> In-Reply-To: <20190618003902.19805-1-palves@redhat.com> References: <20190618003902.19805-1-palves@redhat.com> New tests added later for the incoming "with" command exposed a couple invalid-default-value bugs in the "maint test-settings" commands: - var_filename commands don't allow setting the filename to the empty string (unlike var_optional_filename commands), yet, "maint test-settings filename"'s control variable was not initialized, so on startup, "maint test-settings show filename" shows an empty string. - "maint test-settings enum"'s control variable was not initialized, so on startup, "maint test-settings show enum" shows an empty value instead of a valid enum value. Both issues are fixed by initializing the control variables. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * maint-test-settings.c (maintenance_test_settings_xxx) (maintenance_test_settings_yyy, maintenance_test_settings_zzz): New. (maintenance_test_settings_enums): Use them. (maintenance_test_settings_enum): Default to maintenance_test_settings_xxx. (_initialize_maint_test_settings): Initialize MAINTENANCE_TEST_SETTINGS_FILENAME. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.base/settings.exp (test-string): Adjust expected out when testing "maint test-settings show filename" --- gdb/maint-test-settings.c | 16 +++++++++++++--- gdb/testsuite/gdb.base/settings.exp | 9 ++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c index fa13519eb96..79e002e727f 100644 --- a/gdb/maint-test-settings.c +++ b/gdb/maint-test-settings.c @@ -85,14 +85,22 @@ static char *maintenance_test_settings_optional_filename; static char *maintenance_test_settings_filename; -static const char *maintenance_test_settings_enum; - /* Enum values for the "maintenance test-settings set/show boolean" commands. */ +static const char maintenance_test_settings_xxx[] = "xxx"; +static const char maintenance_test_settings_yyy[] = "yyy"; +static const char maintenance_test_settings_zzz[] = "zzz"; + static const char *const maintenance_test_settings_enums[] = { - "xxx", "yyy", "zzz", nullptr + maintenance_test_settings_xxx, + maintenance_test_settings_yyy, + maintenance_test_settings_zzz, + nullptr }; +static const char *maintenance_test_settings_enum + = maintenance_test_settings_xxx; + /* The "maintenance test-options show xxx" commands. */ static void @@ -107,6 +115,8 @@ maintenance_test_settings_show_value_cmd void _initialize_maint_test_settings (void) { + maintenance_test_settings_filename = xstrdup ("/foo/bar"); + add_prefix_cmd ("test-settings", no_class, maintenance_test_settings_cmd, _("\ diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index aeca67c0e7f..b691ad8cf68 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -447,9 +447,12 @@ proc test-string {variant} { set set_cmd "maint test-settings set $variant" set show_cmd "maint test-settings show $variant" - # Empty string. Also checks that gdb doesn't crash if we haven't - # set the string yet. - gdb_test "$show_cmd" "^$show_cmd\r\n" "$show_cmd: empty first time" + # Checks that gdb doesn't crash if we haven't set the string yet. + if {$variant != "filename"} { + gdb_test "$show_cmd" "^$show_cmd\r\n" "$show_cmd: show default" + } else { + gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default" + } # A string value. gdb_test_no_output "$set_cmd hello world"