From patchwork Thu Jun 13 21:16:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 33112 Received: (qmail 98040 invoked by alias); 13 Jun 2019 21:16:10 -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 98031 invoked by uid 89); 13 Jun 2019 21:16:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*RU:209.85.221.65, HX-Spam-Relays-External:209.85.221.65, sk:breakp, HX-Received:6000 X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jun 2019 21:16:08 +0000 Received: by mail-wr1-f65.google.com with SMTP id n9so299544wru.0 for ; Thu, 13 Jun 2019 14:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=myc7bQQXFeeeoJ67RHwCu4eotWrkvbAgA2PIgxQUN18=; b=Dll/NACPLaW+wD9gXSQwP/OX/QltJRbaErPSq7bjIuZUfyqaxklAnHPggH92uuxDBF GaQtnERqHLp5DmBqYIO/qHX3royeJNezBcyA/5XxL9rlWVsRpbkO1qzNGPwW4yxNNgaQ R9MY1oabXZs4rz6395OdRx7ZTuf77hhyL2VumLSANiiP+8xvx7fgB/7FOR59M3t36p9t Nhcpjz0o+YBZz4XqfmPBiApWocnVieoXsqcpev3ZB1uqd8R9DXVKycVrg0CoUVcuZry/ nTXflt93YVuIdpM/MJY2cwdK+3CpN+KTaqKTEGWu8sWvvPgI1A0dE2HlQ/P35kC3bRFe D9fA== Return-Path: Received: from localhost (host86-180-62-212.range86-180.btcentralplus.com. [86.180.62.212]) by smtp.gmail.com with ESMTPSA id v67sm1097226wme.24.2019.06.13.14.16.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 14:16:06 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: Use scoped_restore_terminal_state in annotate.c Date: Thu, 13 Jun 2019 22:16:03 +0100 Message-Id: <20190613211603.3232-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes In a couple of places in annotate.c we are manually backing up and restoring the terminal ownership, we could instead make use of scoped_restore_terminal_state. gdb/ChangeLog: * annotate.c (annotate_breakpoints_invalid): Make use of scoped_restore_terminal_state. (annotate_frames_invalid): Likewise. --- gdb/ChangeLog | 6 ++++++ gdb/annotate.c | 18 ++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/gdb/annotate.c b/gdb/annotate.c index e6e8084e9b1..84940ff031a 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -61,17 +61,10 @@ annotate_breakpoints_invalid (void) && (!breakpoints_invalid_emitted || current_ui->prompt_state != PROMPT_BLOCKED)) { - /* If the inferior owns the terminal (e.g., we're resuming), - make sure to leave with the inferior still owning it. */ - int was_inferior = target_terminal::is_inferior (); - + target_terminal::scoped_restore_terminal_state term_state; target_terminal::ours_for_output (); printf_unfiltered (("\n\032\032breakpoints-invalid\n")); - - if (was_inferior) - target_terminal::inferior (); - breakpoints_invalid_emitted = 1; } } @@ -208,17 +201,10 @@ annotate_frames_invalid (void) && (!frames_invalid_emitted || current_ui->prompt_state != PROMPT_BLOCKED)) { - /* If the inferior owns the terminal (e.g., we're resuming), - make sure to leave with the inferior still owning it. */ - int was_inferior = target_terminal::is_inferior (); - + target_terminal::scoped_restore_terminal_state term_state; target_terminal::ours_for_output (); printf_unfiltered (("\n\032\032frames-invalid\n")); - - if (was_inferior) - target_terminal::inferior (); - frames_invalid_emitted = 1; } }