From patchwork Thu Oct 17 22:50:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 35106 Received: (qmail 106010 invoked by alias); 17 Oct 2019 22:50:36 -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 105931 invoked by uid 89); 17 Oct 2019 22:50:35 -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, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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; Thu, 17 Oct 2019 22:50:32 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B79F230860B9 for ; Thu, 17 Oct 2019 22:50:31 +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 495381001DD7 for ; Thu, 17 Oct 2019 22:50:31 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 03/24] Make "show remote exec-file" inferior-aware Date: Thu, 17 Oct 2019 23:50:05 +0100 Message-Id: <20191017225026.30496-4-palves@redhat.com> In-Reply-To: <20191017225026.30496-1-palves@redhat.com> References: <20191017225026.30496-1-palves@redhat.com> The "set remote exec-file" setting is per-inferior, but the "show remote exec-file" command always shows the last set exec-file, irrespective of the current inferior. E.g.: # Set inferior 1's exec-file: (gdb) set remote exec-file prog1 # Add inferior 2, switch to it, and set its exec-file: (gdb) add-inferior Added inferior 2 (gdb) inferior 2 (gdb) set remote exec-file prog2 # Switch back to inferior 1, and show its exec-file: (gdb) inferior 1 (gdb) show remote exec-file prog2 ^^^^^ should show "prog1" instead here. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * remote.c (show_remote_exec_file): Show the current inferior's exec-file instead of the command variable's value. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.base/remote-exec-file.exp: New file. --- gdb/remote.c | 2 +- gdb/testsuite/gdb.base/remote-exec-file.exp | 46 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.base/remote-exec-file.exp diff --git a/gdb/remote.c b/gdb/remote.c index f616569ff1..11853a9c12 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1272,7 +1272,7 @@ static void show_remote_exec_file (struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value) { - fprintf_filtered (file, "%s\n", remote_exec_file_var); + fprintf_filtered (file, "%s\n", get_remote_exec_file ()); } static int diff --git a/gdb/testsuite/gdb.base/remote-exec-file.exp b/gdb/testsuite/gdb.base/remote-exec-file.exp new file mode 100644 index 0000000000..3db009b830 --- /dev/null +++ b/gdb/testsuite/gdb.base/remote-exec-file.exp @@ -0,0 +1,46 @@ +# Copyright 2019 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 . + +# Check that "show remote exec-file" displays each inferior's +# exec-file. Regression test for a bug where "show remote exec-file" +# would show the last exec-file set, irrespective of the current +# inferior. + +clean_restart + +# Set remote exec-file in inferior 1. +with_test_prefix "set inf 1" { + gdb_test_no_output "set remote exec-file prog1" +} + +# Set remote exec-file in inferior 2. +with_test_prefix "set inf 2" { + gdb_test "add-inferior" "Added inferior 2" "add inferior 2" + gdb_test "inferior 2" "Switching to inferior 2.*" + gdb_test_no_output "set remote exec-file prog2" +} + +# Check that "show remote exec-file" diplays each inferior's +# exec-file. + +with_test_prefix "show inf 1" { + gdb_test "inferior 1" "Switching to inferior 1.*" + gdb_test "show remote exec-file" "prog1" +} + +with_test_prefix "show inf 2" { + gdb_test "inferior 2" "Switching to inferior 2.*" + gdb_test "show remote exec-file" "prog2" +}