From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BBB6D3858439 for ; Tue, 4 Apr 2023 12:45:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBB6D3858439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nLJJSFl+p8bXMhTpJptRNF9kH2CeXWBvS7pX4JgikF4=; b=Ug6aqny93lHm21Gjw0JYH+h9o2AczJQErWXhGdmwXCKR2nAt2OBMZmwgrxghSbizf3g769 Btd69BlwS6rGBDcRjmt6rWwrdH1o0Dhe+VDuswkzcURMqXxLh5DC6nAKuFHZeUczQqk2us gQnQv5mZNPvADMSsZS1lQCsolzd0JyI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-LhoTC3GWNjOrqPqMWg5gSA-1; Tue, 04 Apr 2023 08:45:46 -0400 X-MC-Unique: LhoTC3GWNjOrqPqMWg5gSA-1 Received: by mail-qt1-f199.google.com with SMTP id p22-20020a05622a00d600b003e38f7f800bso21805783qtw.9 for ; Tue, 04 Apr 2023 05:45:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680612346; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=unyM0LlR6h1Nc8ipR/dyEdgIXtxdEXx6TwzM2wz1ra8=; b=CSupGIB1nf/GWCPb+x8GqfGgIqMNwenX4qoj9Ai+nh6OfvQu5OZE71T39zVYKcIoxU gsdZYWPOgETNwgGJURpD9fqBaeYZkGU/PguQCz3WLDtE2s6ggUGlvArBTs/YEKOebhTh rCJIT/aU7mwp/8E9Rm9Ld5gUv0SNBlqOXkVt+MgZZynoZFerxyzHBQ/myygbnmerxcMY aYAUfxNB/cUkuwp+K9O77ja4KLDsFpd4Vs614djnbojc/XjJOSom5BBqOp2xdyn+ttMx krE3BLnvggGasOHY9We1BZD300IWDcPOKZRDifctEsRBy+hM1oO9XxeznBhB2bSQZAEN b3+g== X-Gm-Message-State: AAQBX9fxiAJH2pXPlxeKExrwn7uI5yBqLth5sMIOMOExlt4ZNQBdJ/2w nL2xuaFTqkLN2TWFXERZNwY01GPrb8rHRAuij8Z63Gpr7KWf08vzHQVNb8pBpgoumsePB6hR09e Lk6FiRDvRNPeJVOml4OckGPBXNc1shja60ogNJms2K9fBOJTI8EoqhvwZ1eRk/nqs3BP4LBcjmw s9D1gRRA== X-Received: by 2002:a05:6214:2243:b0:56e:b557:2d4e with SMTP id c3-20020a056214224300b0056eb5572d4emr3742847qvc.6.1680612345673; Tue, 04 Apr 2023 05:45:45 -0700 (PDT) X-Google-Smtp-Source: AKy350YQAwwHiODkXs5ADUMizqVBpF8RELWh+G24MuuKG1n4nHPxURuaN6Zae4VS+EdNNZItQ/4UnA== X-Received: by 2002:a05:6214:2243:b0:56e:b557:2d4e with SMTP id c3-20020a056214224300b0056eb5572d4emr3742809qvc.6.1680612345331; Tue, 04 Apr 2023 05:45:45 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id dm38-20020a05620a1d6600b007467f8b76f0sm3561338qkb.41.2023.04.04.05.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 05:45:45 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/5] gdb: make set/show inferior-tty work with $_gdb_setting_str Date: Tue, 4 Apr 2023 13:45:30 +0100 Message-Id: <47a6f80078752b45ea06e9fe60ae7c57f1cb0b88.1680608960.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Like the previous two commits, this commit fixes set/show inferior-tty to work with $_gdb_setting_str. Instead of using a scratch variable which is then pushed into the current inferior from a set callback, move to the API that allows for getters and setters, and store the value directly within the current inferior. Update an existing test to check the inferior-tty setting. --- gdb/infcmd.c | 30 +++++++++++++---------- gdb/testsuite/gdb.base/inferior-clone.exp | 9 +++++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 2e26ae9b934..de586f830f6 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -66,11 +66,6 @@ static void step_1 (int, int, const char *); #define ERROR_NO_INFERIOR \ if (!target_has_execution ()) error (_("The program is not being run.")); -/* Scratch area where 'set inferior-tty' will store user-provided value. - We'll immediate copy it into per-inferior storage. */ - -static std::string inferior_io_terminal_scratch; - /* Pid of our debugged inferior, or 0 if no inferior now. Since various parts of infrun.c test this to see whether there is a program being debugged it should be nonzero (currently 3 is used) for remote @@ -94,15 +89,24 @@ static bool finish_print = true; +/* Store the new value passed to 'set inferior-tty'. */ + static void -set_inferior_tty_command (const char *args, int from_tty, - struct cmd_list_element *c) +set_tty_value (const std::string &tty) { - /* CLI has assigned the user-provided value to inferior_io_terminal_scratch. - Now route it to current inferior. */ - current_inferior ()->set_tty (inferior_io_terminal_scratch); + current_inferior ()->set_tty (tty); } +/* Get the current 'inferior-tty' value. */ + +static const std::string & +get_tty_value () +{ + return current_inferior ()->tty (); +} + +/* Implement 'show inferior-tty' command. */ + static void show_inferior_tty_command (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -3136,14 +3140,14 @@ _initialize_infcmd () /* Add the filename of the terminal connected to inferior I/O. */ auto tty_set_show = - add_setshow_optional_filename_cmd ("inferior-tty", class_run, - &inferior_io_terminal_scratch, _("\ + add_setshow_optional_filename_cmd ("inferior-tty", class_run, _("\ Set terminal for future runs of program being debugged."), _(" \ Show terminal for future runs of program being debugged."), _("\ Usage: set inferior-tty [TTY]\n\n\ If TTY is omitted, the default behavior of using the same terminal as GDB\n\ is restored."), - set_inferior_tty_command, + set_tty_value, + get_tty_value, show_inferior_tty_command, &setlist, &showlist); add_alias_cmd ("tty", tty_set_show.set, class_run, 0, &cmdlist); diff --git a/gdb/testsuite/gdb.base/inferior-clone.exp b/gdb/testsuite/gdb.base/inferior-clone.exp index 8e0378323f9..806ec0ad68c 100644 --- a/gdb/testsuite/gdb.base/inferior-clone.exp +++ b/gdb/testsuite/gdb.base/inferior-clone.exp @@ -30,6 +30,8 @@ with_test_prefix "setup inferior 1" { gdb_test_no_output "set environment FOO foo" gdb_test_no_output "set environment BAR bar" gdb_test_no_output "set inferior-tty some_tty" + gdb_test {print $_gdb_setting_str("inferior-tty")} \ + " = \"some_tty\"" } # Check that properties of inferior 1 have been copied @@ -45,6 +47,8 @@ with_test_prefix "inferior 2" { gdb_test "show environment ENVVAR" "ENVVAR = var" gdb_test "show inferior-tty" \ "Terminal for future runs of program being debugged is \"some_tty\"\." + gdb_test {print $_gdb_setting_str("inferior-tty")} \ + " = \"some_tty\"" } # Change this second inferior, to check that the next clone-inferior @@ -54,6 +58,9 @@ with_test_prefix "update inferior 2" { gdb_test_no_output "set args foo" gdb_test_no_output "set cwd /somewhere/else" gdb_test_no_output "set environment FOO oof" + gdb_test_no_output "set inferior-tty another_tty" + gdb_test {print $_gdb_setting_str("inferior-tty")} \ + " = \"another_tty\"" } with_test_prefix "inferior 1" { @@ -67,6 +74,8 @@ with_test_prefix "inferior 1" { gdb_test "show environment ENVVAR" "ENVVAR = var" gdb_test "show inferior-tty" \ "Terminal for future runs of program being debugged is \"some_tty\"\." + gdb_test {print $_gdb_setting_str("inferior-tty")} \ + " = \"some_tty\"" } # Tweak inferior 1 a bit more. -- 2.25.4